| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665 |
- function wae(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 Gv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Co(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var gA={exports:{}},zx={};var mU;function Sae(){if(mU)return zx;mU=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 zx.Fragment=e,zx.jsx=n,zx.jsxs=n,zx}var pU;function Mae(){return pU||(pU=1,gA.exports=Sae()),gA.exports}var s=Mae(),xA={exports:{}},hn={};var gU;function Nae(){if(gU)return hn;gU=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 g(B){return B===null||typeof B!="object"?null:(B=m&&B[m]||B["@@iterator"],typeof B=="function"?B:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,b={};function v(B,G,J){this.props=B,this.context=G,this.refs=b,this.updater=J||x}v.prototype.isReactComponent={},v.prototype.setState=function(B,G){if(typeof B!="object"&&typeof B!="function"&&B!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,B,G,"setState")},v.prototype.forceUpdate=function(B){this.updater.enqueueForceUpdate(this,B,"forceUpdate")};function M(){}M.prototype=v.prototype;function S(B,G,J){this.props=B,this.context=G,this.refs=b,this.updater=J||x}var A=S.prototype=new M;A.constructor=S,y(A,v.prototype),A.isPureReactComponent=!0;var E=Array.isArray;function k(){}var C={H:null,A:null,T:null,S:null},R=Object.prototype.hasOwnProperty;function T(B,G,J){var te=J.ref;return{$$typeof:t,type:B,key:G,ref:te!==void 0?te:null,props:J}}function P(B,G){return T(B.type,G,B.props)}function F(B){return typeof B=="object"&&B!==null&&B.$$typeof===t}function L(B){var G={"=":"=0",":":"=2"};return"$"+B.replace(/[=:]/g,function(J){return G[J]})}var X=/\/+/g;function D(B,G){return typeof B=="object"&&B!==null&&B.key!=null?L(""+B.key):G.toString(36)}function K(B){switch(B.status){case"fulfilled":return B.value;case"rejected":throw B.reason;default:switch(typeof B.status=="string"?B.then(k,k):(B.status="pending",B.then(function(G){B.status==="pending"&&(B.status="fulfilled",B.value=G)},function(G){B.status==="pending"&&(B.status="rejected",B.reason=G)})),B.status){case"fulfilled":return B.value;case"rejected":throw B.reason}}throw B}function Y(B,G,J,te,ae){var de=typeof B;(de==="undefined"||de==="boolean")&&(B=null);var fe=!1;if(B===null)fe=!0;else switch(de){case"bigint":case"string":case"number":fe=!0;break;case"object":switch(B.$$typeof){case t:case e:fe=!0;break;case d:return fe=B._init,Y(fe(B._payload),G,J,te,ae)}}if(fe)return ae=ae(B),fe=te===""?"."+D(B,0):te,E(ae)?(J="",fe!=null&&(J=fe.replace(X,"$&/")+"/"),Y(ae,G,J,"",function(Me){return Me})):ae!=null&&(F(ae)&&(ae=P(ae,J+(ae.key==null||B&&B.key===ae.key?"":(""+ae.key).replace(X,"$&/")+"/")+fe)),G.push(ae)),1;fe=0;var Ae=te===""?".":te+":";if(E(B))for(var ge=0;ge<B.length;ge++)te=B[ge],de=Ae+D(te,ge),fe+=Y(te,G,J,de,ae);else if(ge=g(B),typeof ge=="function")for(B=ge.call(B),ge=0;!(te=B.next()).done;)te=te.value,de=Ae+D(te,ge++),fe+=Y(te,G,J,de,ae);else if(de==="object"){if(typeof B.then=="function")return Y(K(B),G,J,te,ae);throw G=String(B),Error("Objects are not valid as a React child (found: "+(G==="[object Object]"?"object with keys {"+Object.keys(B).join(", ")+"}":G)+"). If you meant to render a collection of children, use an array instead.")}return fe}function q(B,G,J){if(B==null)return B;var te=[],ae=0;return Y(B,te,"","",function(de){return G.call(J,de,ae++)}),te}function Z(B){if(B._status===-1){var G=B._result;G=G(),G.then(function(J){(B._status===0||B._status===-1)&&(B._status=1,B._result=J)},function(J){(B._status===0||B._status===-1)&&(B._status=2,B._result=J)}),B._status===-1&&(B._status=0,B._result=G)}if(B._status===1)return B._result.default;throw B._result}var re=typeof reportError=="function"?reportError:function(B){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var G=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof B=="object"&&B!==null&&typeof B.message=="string"?String(B.message):String(B),error:B});if(!window.dispatchEvent(G))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",B);return}console.error(B)},oe={map:q,forEach:function(B,G,J){q(B,function(){G.apply(this,arguments)},J)},count:function(B){var G=0;return q(B,function(){G++}),G},toArray:function(B){return q(B,function(G){return G})||[]},only:function(B){if(!F(B))throw Error("React.Children.only expected to receive a single React element child.");return B}};return hn.Activity=f,hn.Children=oe,hn.Component=v,hn.Fragment=n,hn.Profiler=i,hn.PureComponent=S,hn.StrictMode=r,hn.Suspense=c,hn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,hn.__COMPILER_RUNTIME={__proto__:null,c:function(B){return C.H.useMemoCache(B)}},hn.cache=function(B){return function(){return B.apply(null,arguments)}},hn.cacheSignal=function(){return null},hn.cloneElement=function(B,G,J){if(B==null)throw Error("The argument must be a React element, but you passed "+B+".");var te=y({},B.props),ae=B.key;if(G!=null)for(de in G.key!==void 0&&(ae=""+G.key),G)!R.call(G,de)||de==="key"||de==="__self"||de==="__source"||de==="ref"&&G.ref===void 0||(te[de]=G[de]);var de=arguments.length-2;if(de===1)te.children=J;else if(1<de){for(var fe=Array(de),Ae=0;Ae<de;Ae++)fe[Ae]=arguments[Ae+2];te.children=fe}return T(B.type,ae,te)},hn.createContext=function(B){return B={$$typeof:o,_currentValue:B,_currentValue2:B,_threadCount:0,Provider:null,Consumer:null},B.Provider=B,B.Consumer={$$typeof:a,_context:B},B},hn.createElement=function(B,G,J){var te,ae={},de=null;if(G!=null)for(te in G.key!==void 0&&(de=""+G.key),G)R.call(G,te)&&te!=="key"&&te!=="__self"&&te!=="__source"&&(ae[te]=G[te]);var fe=arguments.length-2;if(fe===1)ae.children=J;else if(1<fe){for(var Ae=Array(fe),ge=0;ge<fe;ge++)Ae[ge]=arguments[ge+2];ae.children=Ae}if(B&&B.defaultProps)for(te in fe=B.defaultProps,fe)ae[te]===void 0&&(ae[te]=fe[te]);return T(B,de,ae)},hn.createRef=function(){return{current:null}},hn.forwardRef=function(B){return{$$typeof:l,render:B}},hn.isValidElement=F,hn.lazy=function(B){return{$$typeof:d,_payload:{_status:-1,_result:B},_init:Z}},hn.memo=function(B,G){return{$$typeof:u,type:B,compare:G===void 0?null:G}},hn.startTransition=function(B){var G=C.T,J={};C.T=J;try{var te=B(),ae=C.S;ae!==null&&ae(J,te),typeof te=="object"&&te!==null&&typeof te.then=="function"&&te.then(k,re)}catch(de){re(de)}finally{G!==null&&J.types!==null&&(G.types=J.types),C.T=G}},hn.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},hn.use=function(B){return C.H.use(B)},hn.useActionState=function(B,G,J){return C.H.useActionState(B,G,J)},hn.useCallback=function(B,G){return C.H.useCallback(B,G)},hn.useContext=function(B){return C.H.useContext(B)},hn.useDebugValue=function(){},hn.useDeferredValue=function(B,G){return C.H.useDeferredValue(B,G)},hn.useEffect=function(B,G){return C.H.useEffect(B,G)},hn.useEffectEvent=function(B){return C.H.useEffectEvent(B)},hn.useId=function(){return C.H.useId()},hn.useImperativeHandle=function(B,G,J){return C.H.useImperativeHandle(B,G,J)},hn.useInsertionEffect=function(B,G){return C.H.useInsertionEffect(B,G)},hn.useLayoutEffect=function(B,G){return C.H.useLayoutEffect(B,G)},hn.useMemo=function(B,G){return C.H.useMemo(B,G)},hn.useOptimistic=function(B,G){return C.H.useOptimistic(B,G)},hn.useReducer=function(B,G,J){return C.H.useReducer(B,G,J)},hn.useRef=function(B){return C.H.useRef(B)},hn.useState=function(B){return C.H.useState(B)},hn.useSyncExternalStore=function(B,G,J){return C.H.useSyncExternalStore(B,G,J)},hn.useTransition=function(){return C.H.useTransition()},hn.version="19.2.0",hn}var xU;function Ag(){return xU||(xU=1,xA.exports=Nae()),xA.exports}var w=Ag();const jr=Co(w),Eae=wae({__proto__:null,default:jr},[w]);var bA={exports:{}},Bx={},yA={exports:{}},vA={};var bU;function Aae(){return bU||(bU=1,(function(t){function e(Y,q){var Z=Y.length;Y.push(q);e:for(;0<Z;){var re=Z-1>>>1,oe=Y[re];if(0<i(oe,q))Y[re]=q,Y[Z]=oe,Z=re;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],Z=Y.pop();if(Z!==q){Y[0]=Z;e:for(var re=0,oe=Y.length,B=oe>>>1;re<B;){var G=2*(re+1)-1,J=Y[G],te=G+1,ae=Y[te];if(0>i(J,Z))te<oe&&0>i(ae,J)?(Y[re]=ae,Y[te]=Z,re=te):(Y[re]=J,Y[G]=Z,re=G);else if(te<oe&&0>i(ae,Z))Y[re]=ae,Y[te]=Z,re=te;else break e}}return q}function i(Y,q){var Z=Y.sortIndex-q.sortIndex;return Z!==0?Z: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,g=!1,x=!1,y=!1,b=!1,v=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function A(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,A(Y),!x)if(n(c)!==null)x=!0,k||(k=!0,L());else{var q=n(u);q!==null&&K(E,q.startTime-Y)}}var k=!1,C=-1,R=5,T=-1;function P(){return b?!0:!(t.unstable_now()-T<R)}function F(){if(b=!1,k){var Y=t.unstable_now();T=Y;var q=!0;try{e:{x=!1,y&&(y=!1,M(C),C=-1),g=!0;var Z=m;try{t:{for(A(Y),f=n(c);f!==null&&!(f.expirationTime>Y&&P());){var re=f.callback;if(typeof re=="function"){f.callback=null,m=f.priorityLevel;var oe=re(f.expirationTime<=Y);if(Y=t.unstable_now(),typeof oe=="function"){f.callback=oe,A(Y),q=!0;break t}f===n(c)&&r(c),A(Y)}else r(c);f=n(c)}if(f!==null)q=!0;else{var B=n(u);B!==null&&K(E,B.startTime-Y),q=!1}}break e}finally{f=null,m=Z,g=!1}q=void 0}}finally{q?L():k=!1}}}var L;if(typeof S=="function")L=function(){S(F)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,D=X.port2;X.port1.onmessage=F,L=function(){D.postMessage(null)}}else L=function(){v(F,0)};function K(Y,q){C=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"):R=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 Z=m;m=q;try{return Y()}finally{m=Z}},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 Z=m;m=Y;try{return q()}finally{m=Z}},t.unstable_scheduleCallback=function(Y,q,Z){var re=t.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?re+Z:re):Z=re,Y){case 1:var oe=-1;break;case 2:oe=250;break;case 5:oe=1073741823;break;case 4:oe=1e4;break;default:oe=5e3}return oe=Z+oe,Y={id:d++,callback:q,priorityLevel:Y,startTime:Z,expirationTime:oe,sortIndex:-1},Z>re?(Y.sortIndex=Z,e(u,Y),n(c)===null&&Y===n(u)&&(y?(M(C),C=-1):y=!0,K(E,Z-re))):(Y.sortIndex=oe,e(c,Y),x||g||(x=!0,k||(k=!0,L()))),Y},t.unstable_shouldYield=P,t.unstable_wrapCallback=function(Y){var q=m;return function(){var Z=m;m=q;try{return Y.apply(this,arguments)}finally{m=Z}}}})(vA)),vA}var yU;function Tae(){return yU||(yU=1,yA.exports=Aae()),yA.exports}var _A={exports:{}},va={};var vU;function Cae(){if(vU)return va;vU=1;var t=Ag();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 va.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,va.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)},va.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()}},va.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))},va.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},va.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,g=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:g}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:m,fetchPriority:g,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},va.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)},va.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})}},va.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)},va.requestFormReset=function(c){r.d.r(c)},va.unstable_batchedUpdates=function(c,u){return c(u)},va.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},va.useFormStatus=function(){return o.H.useHostTransitionStatus()},va.version="19.2.0",va}var _U;function QG(){if(_U)return _A.exports;_U=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(),_A.exports=Cae(),_A.exports}var wU;function kae(){if(wU)return Bx;wU=1;var t=Tae(),e=Ag(),n=QG();function r(h){var p="https://react.dev/errors/"+h;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)p+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+h+"; visit "+p+" 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 p=h,_=h;if(h.alternate)for(;p.return;)p=p.return;else{h=p;do p=h,(p.flags&4098)!==0&&(_=p.return),h=p.return;while(h)}return p.tag===3?_:null}function o(h){if(h.tag===13){var p=h.memoizedState;if(p===null&&(h=h.alternate,h!==null&&(p=h.memoizedState)),p!==null)return p.dehydrated}return null}function l(h){if(h.tag===31){var p=h.memoizedState;if(p===null&&(h=h.alternate,h!==null&&(p=h.memoizedState)),p!==null)return p.dehydrated}return null}function c(h){if(a(h)!==h)throw Error(r(188))}function u(h){var p=h.alternate;if(!p){if(p=a(h),p===null)throw Error(r(188));return p!==h?null:h}for(var _=h,N=p;;){var j=_.return;if(j===null)break;var I=j.alternate;if(I===null){if(N=j.return,N!==null){_=N;continue}break}if(j.child===I.child){for(I=j.child;I;){if(I===_)return c(j),h;if(I===N)return c(j),p;I=I.sibling}throw Error(r(188))}if(_.return!==N.return)_=j,N=I;else{for(var ee=!1,me=j.child;me;){if(me===_){ee=!0,_=j,N=I;break}if(me===N){ee=!0,N=j,_=I;break}me=me.sibling}if(!ee){for(me=I.child;me;){if(me===_){ee=!0,_=I,N=j;break}if(me===N){ee=!0,N=I,_=j;break}me=me.sibling}if(!ee)throw Error(r(189))}}if(_.alternate!==N)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?h:p}function d(h){var p=h.tag;if(p===5||p===26||p===27||p===6)return h;for(h=h.child;h!==null;){if(p=d(h),p!==null)return p;h=h.sibling}return null}var f=Object.assign,m=Symbol.for("react.element"),g=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"),M=Symbol.for("react.consumer"),S=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),T=Symbol.for("react.activity"),P=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 X=Symbol.for("react.client.reference");function D(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===X?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 k:return"SuspenseList";case T:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case x:return"Portal";case S:return h.displayName||"Context";case M:return(h._context.displayName||"Context")+".Consumer";case A:var p=h.render;return h=h.displayName,h||(h=p.displayName||p.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case C:return p=h.displayName||null,p!==null?p:D(h.type)||"Memo";case R:p=h._payload,h=h._init;try{return D(h(p))}catch{}}return null}var K=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,Z={pending:!1,data:null,method:null,action:null},re=[],oe=-1;function B(h){return{current:h}}function G(h){0>oe||(h.current=re[oe],re[oe]=null,oe--)}function J(h,p){oe++,re[oe]=h.current,h.current=p}var te=B(null),ae=B(null),de=B(null),fe=B(null);function Ae(h,p){switch(J(de,p),J(ae,h),J(te,null),p.nodeType){case 9:case 11:h=(h=p.documentElement)&&(h=h.namespaceURI)?IF(h):0;break;default:if(h=p.tagName,p=p.namespaceURI)p=IF(p),h=FF(p,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}G(te),J(te,h)}function ge(){G(te),G(ae),G(de)}function Me(h){h.memoizedState!==null&&J(fe,h);var p=te.current,_=FF(p,h.type);p!==_&&(J(ae,h),J(te,_))}function je(h){ae.current===h&&(G(te),G(ae)),fe.current===h&&(G(fe),Lx._currentValue=Z)}var ne,Ke;function $(h){if(ne===void 0)try{throw Error()}catch(_){var p=_.stack.trim().match(/\n( *(at )?)/);ne=p&&p[1]||"",Ke=-1<_.stack.indexOf(`
- at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+ne+h+Ke}var z=!1;function W(h,p){if(!h||z)return"";z=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var N={DetermineComponentFrameRoot:function(){try{if(p){var bt=function(){throw Error()};if(Object.defineProperty(bt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(bt,[])}catch(lt){var it=lt}Reflect.construct(h,[],bt)}else{try{bt.call()}catch(lt){it=lt}h.call(bt.prototype)}}else{try{throw Error()}catch(lt){it=lt}(bt=h())&&typeof bt.catch=="function"&&bt.catch(function(){})}}catch(lt){if(lt&&it&&typeof lt.stack=="string")return[lt.stack,it.stack]}return[null,null]}};N.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var j=Object.getOwnPropertyDescriptor(N.DetermineComponentFrameRoot,"name");j&&j.configurable&&Object.defineProperty(N.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var I=N.DetermineComponentFrameRoot(),ee=I[0],me=I[1];if(ee&&me){var Pe=ee.split(`
- `),nt=me.split(`
- `);for(j=N=0;N<Pe.length&&!Pe[N].includes("DetermineComponentFrameRoot");)N++;for(;j<nt.length&&!nt[j].includes("DetermineComponentFrameRoot");)j++;if(N===Pe.length||j===nt.length)for(N=Pe.length-1,j=nt.length-1;1<=N&&0<=j&&Pe[N]!==nt[j];)j--;for(;1<=N&&0<=j;N--,j--)if(Pe[N]!==nt[j]){if(N!==1||j!==1)do if(N--,j--,0>j||Pe[N]!==nt[j]){var gt=`
- `+Pe[N].replace(" at new "," at ");return h.displayName&>.includes("<anonymous>")&&(gt=gt.replace("<anonymous>",h.displayName)),gt}while(1<=N&&0<=j);break}}}finally{z=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?$(_):""}function U(h,p){switch(h.tag){case 26:case 27:case 5:return $(h.type);case 16:return $("Lazy");case 13:return h.child!==p&&p!==null?$("Suspense Fallback"):$("Suspense");case 19:return $("SuspenseList");case 0:case 15:return W(h.type,!1);case 11:return W(h.type.render,!1);case 1:return W(h.type,!0);case 31:return $("Activity");default:return""}}function V(h){try{var p="",_=null;do p+=U(h,_),_=h,h=h.return;while(h);return p}catch(N){return`
- Error generating stack: `+N.message+`
- `+N.stack}}var Q=Object.prototype.hasOwnProperty,Ee=t.unstable_scheduleCallback,Ce=t.unstable_cancelCallback,Ne=t.unstable_shouldYield,H=t.unstable_requestPaint,O=t.unstable_now,ie=t.unstable_getCurrentPriorityLevel,ye=t.unstable_ImmediatePriority,_e=t.unstable_UserBlockingPriority,le=t.unstable_NormalPriority,ke=t.unstable_LowPriority,Oe=t.unstable_IdlePriority,Ze=t.log,ht=t.unstable_setDisableYieldValue,We=null,he=null;function rt(h){if(typeof Ze=="function"&&ht(h),he&&typeof he.setStrictMode=="function")try{he.setStrictMode(We,h)}catch{}}var qe=Math.clz32?Math.clz32:se,Je=Math.log,ot=Math.LN2;function se(h){return h>>>=0,h===0?32:31-(Je(h)/ot|0)|0}var $e=256,be=262144,Fe=4194304;function De(h){var p=h&42;if(p!==0)return p;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 ve(h,p,_){var N=h.pendingLanes;if(N===0)return 0;var j=0,I=h.suspendedLanes,ee=h.pingedLanes;h=h.warmLanes;var me=N&134217727;return me!==0?(N=me&~I,N!==0?j=De(N):(ee&=me,ee!==0?j=De(ee):_||(_=me&~h,_!==0&&(j=De(_))))):(me=N&~I,me!==0?j=De(me):ee!==0?j=De(ee):_||(_=N&~h,_!==0&&(j=De(_)))),j===0?0:p!==0&&p!==j&&(p&I)===0&&(I=j&-j,_=p&-p,I>=_||I===32&&(_&4194048)!==0)?p:j}function He(h,p){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&p)===0}function dt(h,p){switch(h){case 1:case 2:case 4:case 8:case 64:return p+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 p+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function kt(){var h=Fe;return Fe<<=1,(Fe&62914560)===0&&(Fe=4194304),h}function jt(h){for(var p=[],_=0;31>_;_++)p.push(h);return p}function Zt(h,p){h.pendingLanes|=p,p!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Rt(h,p,_,N,j,I){var ee=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var me=h.entanglements,Pe=h.expirationTimes,nt=h.hiddenUpdates;for(_=ee&~_;0<_;){var gt=31-qe(_),bt=1<<gt;me[gt]=0,Pe[gt]=-1;var it=nt[gt];if(it!==null)for(nt[gt]=null,gt=0;gt<it.length;gt++){var lt=it[gt];lt!==null&&(lt.lane&=-536870913)}_&=~bt}N!==0&&nn(h,N,0),I!==0&&j===0&&h.tag!==0&&(h.suspendedLanes|=I&~(ee&~p))}function nn(h,p,_){h.pendingLanes|=p,h.suspendedLanes&=~p;var N=31-qe(p);h.entangledLanes|=p,h.entanglements[N]=h.entanglements[N]|1073741824|_&261930}function pt(h,p){var _=h.entangledLanes|=p;for(h=h.entanglements;_;){var N=31-qe(_),j=1<<N;j&p|h[N]&p&&(h[N]|=p),_&=~j}}function $t(h,p){var _=p&-p;return _=(_&42)!==0?1:qt(_),(_&(h.suspendedLanes|p))!==0?0:_}function qt(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 wt(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function _r(){var h=q.p;return h!==0?h:(h=window.event,h===void 0?32:oU(h.type))}function $r(h,p){var _=q.p;try{return q.p=h,p()}finally{q.p=_}}var Tr=Math.random().toString(36).slice(2),hr="__reactFiber$"+Tr,yt="__reactProps$"+Tr,en="__reactContainer$"+Tr,wn="__reactEvents$"+Tr,ue="__reactListeners$"+Tr,Be="__reactHandles$"+Tr,Ye="__reactResources$"+Tr,Xe="__reactMarker$"+Tr;function Qe(h){delete h[hr],delete h[yt],delete h[wn],delete h[ue],delete h[Be]}function At(h){var p=h[hr];if(p)return p;for(var _=h.parentNode;_;){if(p=_[en]||_[hr]){if(_=p.alternate,p.child!==null||_!==null&&_.child!==null)for(h=GF(h);h!==null;){if(_=h[hr])return _;h=GF(h)}return p}h=_,_=h.parentNode}return null}function ce(h){if(h=h[hr]||h[en]){var p=h.tag;if(p===5||p===6||p===13||p===31||p===26||p===27||p===3)return h}return null}function we(h){var p=h.tag;if(p===5||p===26||p===27||p===6)return h.stateNode;throw Error(r(33))}function Ie(h){var p=h[Ye];return p||(p=h[Ye]={hoistableStyles:new Map,hoistableScripts:new Map}),p}function Le(h){h[Xe]=!0}var Re=new Set,ut={};function _t(h,p){Tt(h,p),Tt(h+"Capture",p)}function Tt(h,p){for(ut[h]=p,h=0;h<p.length;h++)Re.add(p[h])}var St=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]*$"),vt={},xe={};function st(h){return Q.call(xe,h)?!0:Q.call(vt,h)?!1:St.test(h)?xe[h]=!0:(vt[h]=!0,!1)}function Ht(h,p,_){if(st(p))if(_===null)h.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":h.removeAttribute(p);return;case"boolean":var N=p.toLowerCase().slice(0,5);if(N!=="data-"&&N!=="aria-"){h.removeAttribute(p);return}}h.setAttribute(p,""+_)}}function It(h,p,_){if(_===null)h.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(p);return}h.setAttribute(p,""+_)}}function on(h,p,_,N){if(N===null)h.removeAttribute(_);else{switch(typeof N){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(p,_,""+N)}}function un(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function Gt(h){var p=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(p==="checkbox"||p==="radio")}function Wt(h,p,_){var N=Object.getOwnPropertyDescriptor(h.constructor.prototype,p);if(!h.hasOwnProperty(p)&&typeof N<"u"&&typeof N.get=="function"&&typeof N.set=="function"){var j=N.get,I=N.set;return Object.defineProperty(h,p,{configurable:!0,get:function(){return j.call(this)},set:function(ee){_=""+ee,I.call(this,ee)}}),Object.defineProperty(h,p,{enumerable:N.enumerable}),{getValue:function(){return _},setValue:function(ee){_=""+ee},stopTracking:function(){h._valueTracker=null,delete h[p]}}}}function dn(h){if(!h._valueTracker){var p=Gt(h)?"checked":"value";h._valueTracker=Wt(h,p,""+h[p])}}function fn(h){if(!h)return!1;var p=h._valueTracker;if(!p)return!0;var _=p.getValue(),N="";return h&&(N=Gt(h)?h.checked?"true":"false":h.value),h=N,h!==_?(p.setValue(h),!0):!1}function Hr(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 ti=/[\n"\\]/g;function Wn(h){return h.replace(ti,function(p){return"\\"+p.charCodeAt(0).toString(16)+" "})}function Po(h,p,_,N,j,I,ee,me){h.name="",ee!=null&&typeof ee!="function"&&typeof ee!="symbol"&&typeof ee!="boolean"?h.type=ee:h.removeAttribute("type"),p!=null?ee==="number"?(p===0&&h.value===""||h.value!=p)&&(h.value=""+un(p)):h.value!==""+un(p)&&(h.value=""+un(p)):ee!=="submit"&&ee!=="reset"||h.removeAttribute("value"),p!=null?Ii(h,ee,un(p)):_!=null?Ii(h,ee,un(_)):N!=null&&h.removeAttribute("value"),j==null&&I!=null&&(h.defaultChecked=!!I),j!=null&&(h.checked=j&&typeof j!="function"&&typeof j!="symbol"),me!=null&&typeof me!="function"&&typeof me!="symbol"&&typeof me!="boolean"?h.name=""+un(me):h.removeAttribute("name")}function Xn(h,p,_,N,j,I,ee,me){if(I!=null&&typeof I!="function"&&typeof I!="symbol"&&typeof I!="boolean"&&(h.type=I),p!=null||_!=null){if(!(I!=="submit"&&I!=="reset"||p!=null)){dn(h);return}_=_!=null?""+un(_):"",p=p!=null?""+un(p):_,me||p===h.value||(h.value=p),h.defaultValue=p}N=N??j,N=typeof N!="function"&&typeof N!="symbol"&&!!N,h.checked=me?h.checked:!!N,h.defaultChecked=!!N,ee!=null&&typeof ee!="function"&&typeof ee!="symbol"&&typeof ee!="boolean"&&(h.name=ee),dn(h)}function Ii(h,p,_){p==="number"&&Hr(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function wi(h,p,_,N){if(h=h.options,p){p={};for(var j=0;j<_.length;j++)p["$"+_[j]]=!0;for(_=0;_<h.length;_++)j=p.hasOwnProperty("$"+h[_].value),h[_].selected!==j&&(h[_].selected=j),j&&N&&(h[_].defaultSelected=!0)}else{for(_=""+un(_),p=null,j=0;j<h.length;j++){if(h[j].value===_){h[j].selected=!0,N&&(h[j].defaultSelected=!0);return}p!==null||h[j].disabled||(p=h[j])}p!==null&&(p.selected=!0)}}function Fi(h,p,_){if(p!=null&&(p=""+un(p),p!==h.value&&(h.value=p),_==null)){h.defaultValue!==p&&(h.defaultValue=p);return}h.defaultValue=_!=null?""+un(_):""}function na(h,p,_,N){if(p==null){if(N!=null){if(_!=null)throw Error(r(92));if(K(N)){if(1<N.length)throw Error(r(93));N=N[0]}_=N}_==null&&(_=""),p=_}_=un(p),h.defaultValue=_,N=h.textContent,N===_&&N!==""&&N!==null&&(h.value=N),dn(h)}function ul(h,p){if(p){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=p;return}}h.textContent=p}var Yl=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 DL(h,p,_){var N=p.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?N?h.setProperty(p,""):p==="float"?h.cssFloat="":h[p]="":N?h.setProperty(p,_):typeof _!="number"||_===0||Yl.has(p)?p==="float"?h.cssFloat=_:h[p]=(""+_).trim():h[p]=_+"px"}function OL(h,p,_){if(p!=null&&typeof p!="object")throw Error(r(62));if(h=h.style,_!=null){for(var N in _)!_.hasOwnProperty(N)||p!=null&&p.hasOwnProperty(N)||(N.indexOf("--")===0?h.setProperty(N,""):N==="float"?h.cssFloat="":h[N]="");for(var j in p)N=p[j],p.hasOwnProperty(j)&&_[j]!==N&&DL(h,j,N)}else for(var I in p)p.hasOwnProperty(I)&&DL(h,I,p[I])}function hN(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 bre=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"]]),yre=/^[\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 Ly(h){return yre.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function Ql(){}var fN=null;function mN(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var Qf=null,Zf=null;function LL(h){var p=ce(h);if(p&&(h=p.stateNode)){var _=h[yt]||null;e:switch(h=p.stateNode,p.type){case"input":if(Po(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),p=_.name,_.type==="radio"&&p!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+Wn(""+p)+'"][type="radio"]'),p=0;p<_.length;p++){var N=_[p];if(N!==h&&N.form===h.form){var j=N[yt]||null;if(!j)throw Error(r(90));Po(N,j.value,j.defaultValue,j.defaultValue,j.checked,j.defaultChecked,j.type,j.name)}}for(p=0;p<_.length;p++)N=_[p],N.form===h.form&&fn(N)}break e;case"textarea":Fi(h,_.value,_.defaultValue);break e;case"select":p=_.value,p!=null&&wi(h,!!_.multiple,p,!1)}}}var pN=!1;function IL(h,p,_){if(pN)return h(p,_);pN=!0;try{var N=h(p);return N}finally{if(pN=!1,(Qf!==null||Zf!==null)&&(Sv(),Qf&&(p=Qf,h=Zf,Zf=Qf=null,LL(p),h)))for(p=0;p<h.length;p++)LL(h[p])}}function Jg(h,p){var _=h.stateNode;if(_===null)return null;var N=_[yt]||null;if(N===null)return null;_=N[p];e:switch(p){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(N=!N.disabled)||(h=h.type,N=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!N;break e;default:h=!1}if(h)return null;if(_&&typeof _!="function")throw Error(r(231,p,typeof _));return _}var Zl=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),gN=!1;if(Zl)try{var ex={};Object.defineProperty(ex,"passive",{get:function(){gN=!0}}),window.addEventListener("test",ex,ex),window.removeEventListener("test",ex,ex)}catch{gN=!1}var gu=null,xN=null,Iy=null;function FL(){if(Iy)return Iy;var h,p=xN,_=p.length,N,j="value"in gu?gu.value:gu.textContent,I=j.length;for(h=0;h<_&&p[h]===j[h];h++);var ee=_-h;for(N=1;N<=ee&&p[_-N]===j[I-N];N++);return Iy=j.slice(h,1<N?1-N:void 0)}function Fy(h){var p=h.keyCode;return"charCode"in h?(h=h.charCode,h===0&&p===13&&(h=13)):h=p,h===10&&(h=13),32<=h||h===13?h:0}function Uy(){return!0}function UL(){return!1}function Za(h){function p(_,N,j,I,ee){this._reactName=_,this._targetInst=j,this.type=N,this.nativeEvent=I,this.target=ee,this.currentTarget=null;for(var me in h)h.hasOwnProperty(me)&&(_=h[me],this[me]=_?_(I):I[me]);return this.isDefaultPrevented=(I.defaultPrevented!=null?I.defaultPrevented:I.returnValue===!1)?Uy:UL,this.isPropagationStopped=UL,this}return f(p.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=Uy)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=Uy)},persist:function(){},isPersistent:Uy}),p}var ih={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},zy=Za(ih),tx=f({},ih,{view:0,detail:0}),vre=Za(tx),bN,yN,nx,By=f({},tx,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:_N,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!==nx&&(nx&&h.type==="mousemove"?(bN=h.screenX-nx.screenX,yN=h.screenY-nx.screenY):yN=bN=0,nx=h),bN)},movementY:function(h){return"movementY"in h?h.movementY:yN}}),zL=Za(By),_re=f({},By,{dataTransfer:0}),wre=Za(_re),Sre=f({},tx,{relatedTarget:0}),vN=Za(Sre),Mre=f({},ih,{animationName:0,elapsedTime:0,pseudoElement:0}),Nre=Za(Mre),Ere=f({},ih,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),Are=Za(Ere),Tre=f({},ih,{data:0}),BL=Za(Tre),Cre={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},kre={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"},jre={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Pre(h){var p=this.nativeEvent;return p.getModifierState?p.getModifierState(h):(h=jre[h])?!!p[h]:!1}function _N(){return Pre}var Rre=f({},tx,{key:function(h){if(h.key){var p=Cre[h.key]||h.key;if(p!=="Unidentified")return p}return h.type==="keypress"?(h=Fy(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?kre[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:_N,charCode:function(h){return h.type==="keypress"?Fy(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?Fy(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),Dre=Za(Rre),Ore=f({},By,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),$L=Za(Ore),Lre=f({},tx,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:_N}),Ire=Za(Lre),Fre=f({},ih,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ure=Za(Fre),zre=f({},By,{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}),Bre=Za(zre),$re=f({},ih,{newState:0,oldState:0}),Hre=Za($re),Vre=[9,13,27,32],wN=Zl&&"CompositionEvent"in window,rx=null;Zl&&"documentMode"in document&&(rx=document.documentMode);var Gre=Zl&&"TextEvent"in window&&!rx,HL=Zl&&(!wN||rx&&8<rx&&11>=rx),VL=" ",GL=!1;function WL(h,p){switch(h){case"keyup":return Vre.indexOf(p.keyCode)!==-1;case"keydown":return p.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function qL(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var Jf=!1;function Wre(h,p){switch(h){case"compositionend":return qL(p);case"keypress":return p.which!==32?null:(GL=!0,VL);case"textInput":return h=p.data,h===VL&&GL?null:h;default:return null}}function qre(h,p){if(Jf)return h==="compositionend"||!wN&&WL(h,p)?(h=FL(),Iy=xN=gu=null,Jf=!1,h):null;switch(h){case"paste":return null;case"keypress":if(!(p.ctrlKey||p.altKey||p.metaKey)||p.ctrlKey&&p.altKey){if(p.char&&1<p.char.length)return p.char;if(p.which)return String.fromCharCode(p.which)}return null;case"compositionend":return HL&&p.locale!=="ko"?null:p.data;default:return null}}var Kre={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 KL(h){var p=h&&h.nodeName&&h.nodeName.toLowerCase();return p==="input"?!!Kre[h.type]:p==="textarea"}function XL(h,p,_,N){Qf?Zf?Zf.push(N):Zf=[N]:Qf=N,p=kv(p,"onChange"),0<p.length&&(_=new zy("onChange","change",null,_,N),h.push({event:_,listeners:p}))}var ix=null,ax=null;function Xre(h){jF(h,0)}function $y(h){var p=we(h);if(fn(p))return h}function YL(h,p){if(h==="change")return p}var QL=!1;if(Zl){var SN;if(Zl){var MN="oninput"in document;if(!MN){var ZL=document.createElement("div");ZL.setAttribute("oninput","return;"),MN=typeof ZL.oninput=="function"}SN=MN}else SN=!1;QL=SN&&(!document.documentMode||9<document.documentMode)}function JL(){ix&&(ix.detachEvent("onpropertychange",eI),ax=ix=null)}function eI(h){if(h.propertyName==="value"&&$y(ax)){var p=[];XL(p,ax,h,mN(h)),IL(Xre,p)}}function Yre(h,p,_){h==="focusin"?(JL(),ix=p,ax=_,ix.attachEvent("onpropertychange",eI)):h==="focusout"&&JL()}function Qre(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return $y(ax)}function Zre(h,p){if(h==="click")return $y(p)}function Jre(h,p){if(h==="input"||h==="change")return $y(p)}function eie(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var ws=typeof Object.is=="function"?Object.is:eie;function sx(h,p){if(ws(h,p))return!0;if(typeof h!="object"||h===null||typeof p!="object"||p===null)return!1;var _=Object.keys(h),N=Object.keys(p);if(_.length!==N.length)return!1;for(N=0;N<_.length;N++){var j=_[N];if(!Q.call(p,j)||!ws(h[j],p[j]))return!1}return!0}function tI(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function nI(h,p){var _=tI(h);h=0;for(var N;_;){if(_.nodeType===3){if(N=h+_.textContent.length,h<=p&&N>=p)return{node:_,offset:p-h};h=N}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=tI(_)}}function rI(h,p){return h&&p?h===p?!0:h&&h.nodeType===3?!1:p&&p.nodeType===3?rI(h,p.parentNode):"contains"in h?h.contains(p):h.compareDocumentPosition?!!(h.compareDocumentPosition(p)&16):!1:!1}function iI(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var p=Hr(h.document);p instanceof h.HTMLIFrameElement;){try{var _=typeof p.contentWindow.location.href=="string"}catch{_=!1}if(_)h=p.contentWindow;else break;p=Hr(h.document)}return p}function NN(h){var p=h&&h.nodeName&&h.nodeName.toLowerCase();return p&&(p==="input"&&(h.type==="text"||h.type==="search"||h.type==="tel"||h.type==="url"||h.type==="password")||p==="textarea"||h.contentEditable==="true")}var tie=Zl&&"documentMode"in document&&11>=document.documentMode,em=null,EN=null,ox=null,AN=!1;function aI(h,p,_){var N=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;AN||em==null||em!==Hr(N)||(N=em,"selectionStart"in N&&NN(N)?N={start:N.selectionStart,end:N.selectionEnd}:(N=(N.ownerDocument&&N.ownerDocument.defaultView||window).getSelection(),N={anchorNode:N.anchorNode,anchorOffset:N.anchorOffset,focusNode:N.focusNode,focusOffset:N.focusOffset}),ox&&sx(ox,N)||(ox=N,N=kv(EN,"onSelect"),0<N.length&&(p=new zy("onSelect","select",null,p,_),h.push({event:p,listeners:N}),p.target=em)))}function ah(h,p){var _={};return _[h.toLowerCase()]=p.toLowerCase(),_["Webkit"+h]="webkit"+p,_["Moz"+h]="moz"+p,_}var tm={animationend:ah("Animation","AnimationEnd"),animationiteration:ah("Animation","AnimationIteration"),animationstart:ah("Animation","AnimationStart"),transitionrun:ah("Transition","TransitionRun"),transitionstart:ah("Transition","TransitionStart"),transitioncancel:ah("Transition","TransitionCancel"),transitionend:ah("Transition","TransitionEnd")},TN={},sI={};Zl&&(sI=document.createElement("div").style,"AnimationEvent"in window||(delete tm.animationend.animation,delete tm.animationiteration.animation,delete tm.animationstart.animation),"TransitionEvent"in window||delete tm.transitionend.transition);function sh(h){if(TN[h])return TN[h];if(!tm[h])return h;var p=tm[h],_;for(_ in p)if(p.hasOwnProperty(_)&&_ in sI)return TN[h]=p[_];return h}var oI=sh("animationend"),lI=sh("animationiteration"),cI=sh("animationstart"),nie=sh("transitionrun"),rie=sh("transitionstart"),iie=sh("transitioncancel"),uI=sh("transitionend"),dI=new Map,CN="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(" ");CN.push("scrollEnd");function Ro(h,p){dI.set(h,p),_t(p,[h])}var Hy=typeof reportError=="function"?reportError:function(h){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var p=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(p))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",h);return}console.error(h)},Ks=[],nm=0,kN=0;function Vy(){for(var h=nm,p=kN=nm=0;p<h;){var _=Ks[p];Ks[p++]=null;var N=Ks[p];Ks[p++]=null;var j=Ks[p];Ks[p++]=null;var I=Ks[p];if(Ks[p++]=null,N!==null&&j!==null){var ee=N.pending;ee===null?j.next=j:(j.next=ee.next,ee.next=j),N.pending=j}I!==0&&hI(_,j,I)}}function Gy(h,p,_,N){Ks[nm++]=h,Ks[nm++]=p,Ks[nm++]=_,Ks[nm++]=N,kN|=N,h.lanes|=N,h=h.alternate,h!==null&&(h.lanes|=N)}function jN(h,p,_,N){return Gy(h,p,_,N),Wy(h)}function oh(h,p){return Gy(h,null,null,p),Wy(h)}function hI(h,p,_){h.lanes|=_;var N=h.alternate;N!==null&&(N.lanes|=_);for(var j=!1,I=h.return;I!==null;)I.childLanes|=_,N=I.alternate,N!==null&&(N.childLanes|=_),I.tag===22&&(h=I.stateNode,h===null||h._visibility&1||(j=!0)),h=I,I=I.return;return h.tag===3?(I=h.stateNode,j&&p!==null&&(j=31-qe(_),h=I.hiddenUpdates,N=h[j],N===null?h[j]=[p]:N.push(p),p.lane=_|536870912),I):null}function Wy(h){if(50<Cx)throw Cx=0,zE=null,Error(r(185));for(var p=h.return;p!==null;)h=p,p=h.return;return h.tag===3?h.stateNode:null}var rm={};function aie(h,p,_,N){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=p,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=N,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ss(h,p,_,N){return new aie(h,p,_,N)}function PN(h){return h=h.prototype,!(!h||!h.isReactComponent)}function Jl(h,p){var _=h.alternate;return _===null?(_=Ss(h.tag,p,h.key,h.mode),_.elementType=h.elementType,_.type=h.type,_.stateNode=h.stateNode,_.alternate=h,h.alternate=_):(_.pendingProps=p,_.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,p=h.dependencies,_.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext},_.sibling=h.sibling,_.index=h.index,_.ref=h.ref,_.refCleanup=h.refCleanup,_}function fI(h,p){h.flags&=65011714;var _=h.alternate;return _===null?(h.childLanes=0,h.lanes=p,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,p=_.dependencies,h.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),h}function qy(h,p,_,N,j,I){var ee=0;if(N=h,typeof h=="function")PN(h)&&(ee=1);else if(typeof h=="string")ee=uae(h,_,te.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case T:return h=Ss(31,_,p,j),h.elementType=T,h.lanes=I,h;case y:return lh(_.children,j,I,p);case b:ee=8,j|=24;break;case v:return h=Ss(12,_,p,j|2),h.elementType=v,h.lanes=I,h;case E:return h=Ss(13,_,p,j),h.elementType=E,h.lanes=I,h;case k:return h=Ss(19,_,p,j),h.elementType=k,h.lanes=I,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case S:ee=10;break e;case M:ee=9;break e;case A:ee=11;break e;case C:ee=14;break e;case R:ee=16,N=null;break e}ee=29,_=Error(r(130,h===null?"null":typeof h,"")),N=null}return p=Ss(ee,_,p,j),p.elementType=h,p.type=N,p.lanes=I,p}function lh(h,p,_,N){return h=Ss(7,h,N,p),h.lanes=_,h}function RN(h,p,_){return h=Ss(6,h,null,p),h.lanes=_,h}function mI(h){var p=Ss(18,null,null,0);return p.stateNode=h,p}function DN(h,p,_){return p=Ss(4,h.children!==null?h.children:[],h.key,p),p.lanes=_,p.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},p}var pI=new WeakMap;function Xs(h,p){if(typeof h=="object"&&h!==null){var _=pI.get(h);return _!==void 0?_:(p={value:h,source:p,stack:V(p)},pI.set(h,p),p)}return{value:h,source:p,stack:V(p)}}var im=[],am=0,Ky=null,lx=0,Ys=[],Qs=0,xu=null,dl=1,hl="";function ec(h,p){im[am++]=lx,im[am++]=Ky,Ky=h,lx=p}function gI(h,p,_){Ys[Qs++]=dl,Ys[Qs++]=hl,Ys[Qs++]=xu,xu=h;var N=dl;h=hl;var j=32-qe(N)-1;N&=~(1<<j),_+=1;var I=32-qe(p)+j;if(30<I){var ee=j-j%5;I=(N&(1<<ee)-1).toString(32),N>>=ee,j-=ee,dl=1<<32-qe(p)+j|_<<j|N,hl=I+h}else dl=1<<I|_<<j|N,hl=h}function ON(h){h.return!==null&&(ec(h,1),gI(h,1,0))}function LN(h){for(;h===Ky;)Ky=im[--am],im[am]=null,lx=im[--am],im[am]=null;for(;h===xu;)xu=Ys[--Qs],Ys[Qs]=null,hl=Ys[--Qs],Ys[Qs]=null,dl=Ys[--Qs],Ys[Qs]=null}function xI(h,p){Ys[Qs++]=dl,Ys[Qs++]=hl,Ys[Qs++]=xu,dl=p.id,hl=p.overflow,xu=h}var ra=null,wr=null,Rn=!1,bu=null,Zs=!1,IN=Error(r(519));function yu(h){var p=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw cx(Xs(p,h)),IN}function bI(h){var p=h.stateNode,_=h.type,N=h.memoizedProps;switch(p[hr]=h,p[yt]=N,_){case"dialog":En("cancel",p),En("close",p);break;case"iframe":case"object":case"embed":En("load",p);break;case"video":case"audio":for(_=0;_<jx.length;_++)En(jx[_],p);break;case"source":En("error",p);break;case"img":case"image":case"link":En("error",p),En("load",p);break;case"details":En("toggle",p);break;case"input":En("invalid",p),Xn(p,N.value,N.defaultValue,N.checked,N.defaultChecked,N.type,N.name,!0);break;case"select":En("invalid",p);break;case"textarea":En("invalid",p),na(p,N.value,N.defaultValue,N.children)}_=N.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||p.textContent===""+_||N.suppressHydrationWarning===!0||OF(p.textContent,_)?(N.popover!=null&&(En("beforetoggle",p),En("toggle",p)),N.onScroll!=null&&En("scroll",p),N.onScrollEnd!=null&&En("scrollend",p),N.onClick!=null&&(p.onclick=Ql),p=!0):p=!1,p||yu(h,!0)}function yI(h){for(ra=h.return;ra;)switch(ra.tag){case 5:case 31:case 13:Zs=!1;return;case 27:case 3:Zs=!0;return;default:ra=ra.return}}function sm(h){if(h!==ra)return!1;if(!Rn)return yI(h),Rn=!0,!1;var p=h.tag,_;if((_=p!==3&&p!==27)&&((_=p===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||tA(h.type,h.memoizedProps)),_=!_),_&&wr&&yu(h),yI(h),p===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));wr=VF(h)}else if(p===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));wr=VF(h)}else p===27?(p=wr,Ru(h.type)?(h=sA,sA=null,wr=h):wr=p):wr=ra?eo(h.stateNode.nextSibling):null;return!0}function ch(){wr=ra=null,Rn=!1}function FN(){var h=bu;return h!==null&&(ns===null?ns=h:ns.push.apply(ns,h),bu=null),h}function cx(h){bu===null?bu=[h]:bu.push(h)}var UN=B(null),uh=null,tc=null;function vu(h,p,_){J(UN,p._currentValue),p._currentValue=_}function nc(h){h._currentValue=UN.current,G(UN)}function zN(h,p,_){for(;h!==null;){var N=h.alternate;if((h.childLanes&p)!==p?(h.childLanes|=p,N!==null&&(N.childLanes|=p)):N!==null&&(N.childLanes&p)!==p&&(N.childLanes|=p),h===_)break;h=h.return}}function BN(h,p,_,N){var j=h.child;for(j!==null&&(j.return=h);j!==null;){var I=j.dependencies;if(I!==null){var ee=j.child;I=I.firstContext;e:for(;I!==null;){var me=I;I=j;for(var Pe=0;Pe<p.length;Pe++)if(me.context===p[Pe]){I.lanes|=_,me=I.alternate,me!==null&&(me.lanes|=_),zN(I.return,_,h),N||(ee=null);break e}I=me.next}}else if(j.tag===18){if(ee=j.return,ee===null)throw Error(r(341));ee.lanes|=_,I=ee.alternate,I!==null&&(I.lanes|=_),zN(ee,_,h),ee=null}else ee=j.child;if(ee!==null)ee.return=j;else for(ee=j;ee!==null;){if(ee===h){ee=null;break}if(j=ee.sibling,j!==null){j.return=ee.return,ee=j;break}ee=ee.return}j=ee}}function om(h,p,_,N){h=null;for(var j=p,I=!1;j!==null;){if(!I){if((j.flags&524288)!==0)I=!0;else if((j.flags&262144)!==0)break}if(j.tag===10){var ee=j.alternate;if(ee===null)throw Error(r(387));if(ee=ee.memoizedProps,ee!==null){var me=j.type;ws(j.pendingProps.value,ee.value)||(h!==null?h.push(me):h=[me])}}else if(j===fe.current){if(ee=j.alternate,ee===null)throw Error(r(387));ee.memoizedState.memoizedState!==j.memoizedState.memoizedState&&(h!==null?h.push(Lx):h=[Lx])}j=j.return}h!==null&&BN(p,h,_,N),p.flags|=262144}function Xy(h){for(h=h.firstContext;h!==null;){if(!ws(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function dh(h){uh=h,tc=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function ia(h){return vI(uh,h)}function Yy(h,p){return uh===null&&dh(h),vI(h,p)}function vI(h,p){var _=p._currentValue;if(p={context:p,memoizedValue:_,next:null},tc===null){if(h===null)throw Error(r(308));tc=p,h.dependencies={lanes:0,firstContext:p},h.flags|=524288}else tc=tc.next=p;return _}var sie=typeof AbortController<"u"?AbortController:function(){var h=[],p=this.signal={aborted:!1,addEventListener:function(_,N){h.push(N)}};this.abort=function(){p.aborted=!0,h.forEach(function(_){return _()})}},oie=t.unstable_scheduleCallback,lie=t.unstable_NormalPriority,oi={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function $N(){return{controller:new sie,data:new Map,refCount:0}}function ux(h){h.refCount--,h.refCount===0&&oie(lie,function(){h.controller.abort()})}var dx=null,HN=0,lm=0,cm=null;function cie(h,p){if(dx===null){var _=dx=[];HN=0,lm=WE(),cm={status:"pending",value:void 0,then:function(N){_.push(N)}}}return HN++,p.then(_I,_I),p}function _I(){if(--HN===0&&dx!==null){cm!==null&&(cm.status="fulfilled");var h=dx;dx=null,lm=0,cm=null;for(var p=0;p<h.length;p++)(0,h[p])()}}function uie(h,p){var _=[],N={status:"pending",value:null,reason:null,then:function(j){_.push(j)}};return h.then(function(){N.status="fulfilled",N.value=p;for(var j=0;j<_.length;j++)(0,_[j])(p)},function(j){for(N.status="rejected",N.reason=j,j=0;j<_.length;j++)(0,_[j])(void 0)}),N}var wI=Y.S;Y.S=function(h,p){aF=O(),typeof p=="object"&&p!==null&&typeof p.then=="function"&&cie(h,p),wI!==null&&wI(h,p)};var hh=B(null);function VN(){var h=hh.current;return h!==null?h:fr.pooledCache}function Qy(h,p){p===null?J(hh,hh.current):J(hh,p.pool)}function SI(){var h=VN();return h===null?null:{parent:oi._currentValue,pool:h}}var um=Error(r(460)),GN=Error(r(474)),Zy=Error(r(542)),Jy={then:function(){}};function MI(h){return h=h.status,h==="fulfilled"||h==="rejected"}function NI(h,p,_){switch(_=h[_],_===void 0?h.push(p):_!==p&&(p.then(Ql,Ql),p=_),p.status){case"fulfilled":return p.value;case"rejected":throw h=p.reason,AI(h),h;default:if(typeof p.status=="string")p.then(Ql,Ql);else{if(h=fr,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=p,h.status="pending",h.then(function(N){if(p.status==="pending"){var j=p;j.status="fulfilled",j.value=N}},function(N){if(p.status==="pending"){var j=p;j.status="rejected",j.reason=N}})}switch(p.status){case"fulfilled":return p.value;case"rejected":throw h=p.reason,AI(h),h}throw mh=p,um}}function fh(h){try{var p=h._init;return p(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(mh=_,um):_}}var mh=null;function EI(){if(mh===null)throw Error(r(459));var h=mh;return mh=null,h}function AI(h){if(h===um||h===Zy)throw Error(r(483))}var dm=null,hx=0;function ev(h){var p=hx;return hx+=1,dm===null&&(dm=[]),NI(dm,h,p)}function fx(h,p){p=p.props.ref,h.ref=p!==void 0?p:null}function tv(h,p){throw p.$$typeof===m?Error(r(525)):(h=Object.prototype.toString.call(p),Error(r(31,h==="[object Object]"?"object with keys {"+Object.keys(p).join(", ")+"}":h)))}function TI(h){function p(Ge,Ue){if(h){var tt=Ge.deletions;tt===null?(Ge.deletions=[Ue],Ge.flags|=16):tt.push(Ue)}}function _(Ge,Ue){if(!h)return null;for(;Ue!==null;)p(Ge,Ue),Ue=Ue.sibling;return null}function N(Ge){for(var Ue=new Map;Ge!==null;)Ge.key!==null?Ue.set(Ge.key,Ge):Ue.set(Ge.index,Ge),Ge=Ge.sibling;return Ue}function j(Ge,Ue){return Ge=Jl(Ge,Ue),Ge.index=0,Ge.sibling=null,Ge}function I(Ge,Ue,tt){return Ge.index=tt,h?(tt=Ge.alternate,tt!==null?(tt=tt.index,tt<Ue?(Ge.flags|=67108866,Ue):tt):(Ge.flags|=67108866,Ue)):(Ge.flags|=1048576,Ue)}function ee(Ge){return h&&Ge.alternate===null&&(Ge.flags|=67108866),Ge}function me(Ge,Ue,tt,xt){return Ue===null||Ue.tag!==6?(Ue=RN(tt,Ge.mode,xt),Ue.return=Ge,Ue):(Ue=j(Ue,tt),Ue.return=Ge,Ue)}function Pe(Ge,Ue,tt,xt){var Kt=tt.type;return Kt===y?gt(Ge,Ue,tt.props.children,xt,tt.key):Ue!==null&&(Ue.elementType===Kt||typeof Kt=="object"&&Kt!==null&&Kt.$$typeof===R&&fh(Kt)===Ue.type)?(Ue=j(Ue,tt.props),fx(Ue,tt),Ue.return=Ge,Ue):(Ue=qy(tt.type,tt.key,tt.props,null,Ge.mode,xt),fx(Ue,tt),Ue.return=Ge,Ue)}function nt(Ge,Ue,tt,xt){return Ue===null||Ue.tag!==4||Ue.stateNode.containerInfo!==tt.containerInfo||Ue.stateNode.implementation!==tt.implementation?(Ue=DN(tt,Ge.mode,xt),Ue.return=Ge,Ue):(Ue=j(Ue,tt.children||[]),Ue.return=Ge,Ue)}function gt(Ge,Ue,tt,xt,Kt){return Ue===null||Ue.tag!==7?(Ue=lh(tt,Ge.mode,xt,Kt),Ue.return=Ge,Ue):(Ue=j(Ue,tt),Ue.return=Ge,Ue)}function bt(Ge,Ue,tt){if(typeof Ue=="string"&&Ue!==""||typeof Ue=="number"||typeof Ue=="bigint")return Ue=RN(""+Ue,Ge.mode,tt),Ue.return=Ge,Ue;if(typeof Ue=="object"&&Ue!==null){switch(Ue.$$typeof){case g:return tt=qy(Ue.type,Ue.key,Ue.props,null,Ge.mode,tt),fx(tt,Ue),tt.return=Ge,tt;case x:return Ue=DN(Ue,Ge.mode,tt),Ue.return=Ge,Ue;case R:return Ue=fh(Ue),bt(Ge,Ue,tt)}if(K(Ue)||L(Ue))return Ue=lh(Ue,Ge.mode,tt,null),Ue.return=Ge,Ue;if(typeof Ue.then=="function")return bt(Ge,ev(Ue),tt);if(Ue.$$typeof===S)return bt(Ge,Yy(Ge,Ue),tt);tv(Ge,Ue)}return null}function it(Ge,Ue,tt,xt){var Kt=Ue!==null?Ue.key:null;if(typeof tt=="string"&&tt!==""||typeof tt=="number"||typeof tt=="bigint")return Kt!==null?null:me(Ge,Ue,""+tt,xt);if(typeof tt=="object"&&tt!==null){switch(tt.$$typeof){case g:return tt.key===Kt?Pe(Ge,Ue,tt,xt):null;case x:return tt.key===Kt?nt(Ge,Ue,tt,xt):null;case R:return tt=fh(tt),it(Ge,Ue,tt,xt)}if(K(tt)||L(tt))return Kt!==null?null:gt(Ge,Ue,tt,xt,null);if(typeof tt.then=="function")return it(Ge,Ue,ev(tt),xt);if(tt.$$typeof===S)return it(Ge,Ue,Yy(Ge,tt),xt);tv(Ge,tt)}return null}function lt(Ge,Ue,tt,xt,Kt){if(typeof xt=="string"&&xt!==""||typeof xt=="number"||typeof xt=="bigint")return Ge=Ge.get(tt)||null,me(Ue,Ge,""+xt,Kt);if(typeof xt=="object"&&xt!==null){switch(xt.$$typeof){case g:return Ge=Ge.get(xt.key===null?tt:xt.key)||null,Pe(Ue,Ge,xt,Kt);case x:return Ge=Ge.get(xt.key===null?tt:xt.key)||null,nt(Ue,Ge,xt,Kt);case R:return xt=fh(xt),lt(Ge,Ue,tt,xt,Kt)}if(K(xt)||L(xt))return Ge=Ge.get(tt)||null,gt(Ue,Ge,xt,Kt,null);if(typeof xt.then=="function")return lt(Ge,Ue,tt,ev(xt),Kt);if(xt.$$typeof===S)return lt(Ge,Ue,tt,Yy(Ue,xt),Kt);tv(Ue,xt)}return null}function Bt(Ge,Ue,tt,xt){for(var Kt=null,Fn=null,Vt=Ue,pn=Ue=0,Pn=null;Vt!==null&&pn<tt.length;pn++){Vt.index>pn?(Pn=Vt,Vt=null):Pn=Vt.sibling;var Un=it(Ge,Vt,tt[pn],xt);if(Un===null){Vt===null&&(Vt=Pn);break}h&&Vt&&Un.alternate===null&&p(Ge,Vt),Ue=I(Un,Ue,pn),Fn===null?Kt=Un:Fn.sibling=Un,Fn=Un,Vt=Pn}if(pn===tt.length)return _(Ge,Vt),Rn&&ec(Ge,pn),Kt;if(Vt===null){for(;pn<tt.length;pn++)Vt=bt(Ge,tt[pn],xt),Vt!==null&&(Ue=I(Vt,Ue,pn),Fn===null?Kt=Vt:Fn.sibling=Vt,Fn=Vt);return Rn&&ec(Ge,pn),Kt}for(Vt=N(Vt);pn<tt.length;pn++)Pn=lt(Vt,Ge,pn,tt[pn],xt),Pn!==null&&(h&&Pn.alternate!==null&&Vt.delete(Pn.key===null?pn:Pn.key),Ue=I(Pn,Ue,pn),Fn===null?Kt=Pn:Fn.sibling=Pn,Fn=Pn);return h&&Vt.forEach(function(Fu){return p(Ge,Fu)}),Rn&&ec(Ge,pn),Kt}function Jt(Ge,Ue,tt,xt){if(tt==null)throw Error(r(151));for(var Kt=null,Fn=null,Vt=Ue,pn=Ue=0,Pn=null,Un=tt.next();Vt!==null&&!Un.done;pn++,Un=tt.next()){Vt.index>pn?(Pn=Vt,Vt=null):Pn=Vt.sibling;var Fu=it(Ge,Vt,Un.value,xt);if(Fu===null){Vt===null&&(Vt=Pn);break}h&&Vt&&Fu.alternate===null&&p(Ge,Vt),Ue=I(Fu,Ue,pn),Fn===null?Kt=Fu:Fn.sibling=Fu,Fn=Fu,Vt=Pn}if(Un.done)return _(Ge,Vt),Rn&&ec(Ge,pn),Kt;if(Vt===null){for(;!Un.done;pn++,Un=tt.next())Un=bt(Ge,Un.value,xt),Un!==null&&(Ue=I(Un,Ue,pn),Fn===null?Kt=Un:Fn.sibling=Un,Fn=Un);return Rn&&ec(Ge,pn),Kt}for(Vt=N(Vt);!Un.done;pn++,Un=tt.next())Un=lt(Vt,Ge,pn,Un.value,xt),Un!==null&&(h&&Un.alternate!==null&&Vt.delete(Un.key===null?pn:Un.key),Ue=I(Un,Ue,pn),Fn===null?Kt=Un:Fn.sibling=Un,Fn=Un);return h&&Vt.forEach(function(_ae){return p(Ge,_ae)}),Rn&&ec(Ge,pn),Kt}function ir(Ge,Ue,tt,xt){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 g:e:{for(var Kt=tt.key;Ue!==null;){if(Ue.key===Kt){if(Kt=tt.type,Kt===y){if(Ue.tag===7){_(Ge,Ue.sibling),xt=j(Ue,tt.props.children),xt.return=Ge,Ge=xt;break e}}else if(Ue.elementType===Kt||typeof Kt=="object"&&Kt!==null&&Kt.$$typeof===R&&fh(Kt)===Ue.type){_(Ge,Ue.sibling),xt=j(Ue,tt.props),fx(xt,tt),xt.return=Ge,Ge=xt;break e}_(Ge,Ue);break}else p(Ge,Ue);Ue=Ue.sibling}tt.type===y?(xt=lh(tt.props.children,Ge.mode,xt,tt.key),xt.return=Ge,Ge=xt):(xt=qy(tt.type,tt.key,tt.props,null,Ge.mode,xt),fx(xt,tt),xt.return=Ge,Ge=xt)}return ee(Ge);case x:e:{for(Kt=tt.key;Ue!==null;){if(Ue.key===Kt)if(Ue.tag===4&&Ue.stateNode.containerInfo===tt.containerInfo&&Ue.stateNode.implementation===tt.implementation){_(Ge,Ue.sibling),xt=j(Ue,tt.children||[]),xt.return=Ge,Ge=xt;break e}else{_(Ge,Ue);break}else p(Ge,Ue);Ue=Ue.sibling}xt=DN(tt,Ge.mode,xt),xt.return=Ge,Ge=xt}return ee(Ge);case R:return tt=fh(tt),ir(Ge,Ue,tt,xt)}if(K(tt))return Bt(Ge,Ue,tt,xt);if(L(tt)){if(Kt=L(tt),typeof Kt!="function")throw Error(r(150));return tt=Kt.call(tt),Jt(Ge,Ue,tt,xt)}if(typeof tt.then=="function")return ir(Ge,Ue,ev(tt),xt);if(tt.$$typeof===S)return ir(Ge,Ue,Yy(Ge,tt),xt);tv(Ge,tt)}return typeof tt=="string"&&tt!==""||typeof tt=="number"||typeof tt=="bigint"?(tt=""+tt,Ue!==null&&Ue.tag===6?(_(Ge,Ue.sibling),xt=j(Ue,tt),xt.return=Ge,Ge=xt):(_(Ge,Ue),xt=RN(tt,Ge.mode,xt),xt.return=Ge,Ge=xt),ee(Ge)):_(Ge,Ue)}return function(Ge,Ue,tt,xt){try{hx=0;var Kt=ir(Ge,Ue,tt,xt);return dm=null,Kt}catch(Vt){if(Vt===um||Vt===Zy)throw Vt;var Fn=Ss(29,Vt,null,Ge.mode);return Fn.lanes=xt,Fn.return=Ge,Fn}finally{}}}var ph=TI(!0),CI=TI(!1),_u=!1;function WN(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function qN(h,p){h=h.updateQueue,p.updateQueue===h&&(p.updateQueue={baseState:h.baseState,firstBaseUpdate:h.firstBaseUpdate,lastBaseUpdate:h.lastBaseUpdate,shared:h.shared,callbacks:null})}function wu(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function Su(h,p,_){var N=h.updateQueue;if(N===null)return null;if(N=N.shared,(Hn&2)!==0){var j=N.pending;return j===null?p.next=p:(p.next=j.next,j.next=p),N.pending=p,p=Wy(h),hI(h,null,_),p}return Gy(h,N,p,_),Wy(h)}function mx(h,p,_){if(p=p.updateQueue,p!==null&&(p=p.shared,(_&4194048)!==0)){var N=p.lanes;N&=h.pendingLanes,_|=N,p.lanes=_,pt(h,_)}}function KN(h,p){var _=h.updateQueue,N=h.alternate;if(N!==null&&(N=N.updateQueue,_===N)){var j=null,I=null;if(_=_.firstBaseUpdate,_!==null){do{var ee={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};I===null?j=I=ee:I=I.next=ee,_=_.next}while(_!==null);I===null?j=I=p:I=I.next=p}else j=I=p;_={baseState:N.baseState,firstBaseUpdate:j,lastBaseUpdate:I,shared:N.shared,callbacks:N.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=p:h.next=p,_.lastBaseUpdate=p}var XN=!1;function px(){if(XN){var h=cm;if(h!==null)throw h}}function gx(h,p,_,N){XN=!1;var j=h.updateQueue;_u=!1;var I=j.firstBaseUpdate,ee=j.lastBaseUpdate,me=j.shared.pending;if(me!==null){j.shared.pending=null;var Pe=me,nt=Pe.next;Pe.next=null,ee===null?I=nt:ee.next=nt,ee=Pe;var gt=h.alternate;gt!==null&&(gt=gt.updateQueue,me=gt.lastBaseUpdate,me!==ee&&(me===null?gt.firstBaseUpdate=nt:me.next=nt,gt.lastBaseUpdate=Pe))}if(I!==null){var bt=j.baseState;ee=0,gt=nt=Pe=null,me=I;do{var it=me.lane&-536870913,lt=it!==me.lane;if(lt?(jn&it)===it:(N&it)===it){it!==0&&it===lm&&(XN=!0),gt!==null&&(gt=gt.next={lane:0,tag:me.tag,payload:me.payload,callback:null,next:null});e:{var Bt=h,Jt=me;it=p;var ir=_;switch(Jt.tag){case 1:if(Bt=Jt.payload,typeof Bt=="function"){bt=Bt.call(ir,bt,it);break e}bt=Bt;break e;case 3:Bt.flags=Bt.flags&-65537|128;case 0:if(Bt=Jt.payload,it=typeof Bt=="function"?Bt.call(ir,bt,it):Bt,it==null)break e;bt=f({},bt,it);break e;case 2:_u=!0}}it=me.callback,it!==null&&(h.flags|=64,lt&&(h.flags|=8192),lt=j.callbacks,lt===null?j.callbacks=[it]:lt.push(it))}else lt={lane:it,tag:me.tag,payload:me.payload,callback:me.callback,next:null},gt===null?(nt=gt=lt,Pe=bt):gt=gt.next=lt,ee|=it;if(me=me.next,me===null){if(me=j.shared.pending,me===null)break;lt=me,me=lt.next,lt.next=null,j.lastBaseUpdate=lt,j.shared.pending=null}}while(!0);gt===null&&(Pe=bt),j.baseState=Pe,j.firstBaseUpdate=nt,j.lastBaseUpdate=gt,I===null&&(j.shared.lanes=0),Tu|=ee,h.lanes=ee,h.memoizedState=bt}}function kI(h,p){if(typeof h!="function")throw Error(r(191,h));h.call(p)}function jI(h,p){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)kI(_[h],p)}var hm=B(null),nv=B(0);function PI(h,p){h=dc,J(nv,h),J(hm,p),dc=h|p.baseLanes}function YN(){J(nv,dc),J(hm,hm.current)}function QN(){dc=nv.current,G(hm),G(nv)}var Ms=B(null),Js=null;function Mu(h){var p=h.alternate;J(ni,ni.current&1),J(Ms,h),Js===null&&(p===null||hm.current!==null||p.memoizedState!==null)&&(Js=h)}function ZN(h){J(ni,ni.current),J(Ms,h),Js===null&&(Js=h)}function RI(h){h.tag===22?(J(ni,ni.current),J(Ms,h),Js===null&&(Js=h)):Nu()}function Nu(){J(ni,ni.current),J(Ms,Ms.current)}function Ns(h){G(Ms),Js===h&&(Js=null),G(ni)}var ni=B(0);function rv(h){for(var p=h;p!==null;){if(p.tag===13){var _=p.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||iA(_)||aA(_)))return p}else if(p.tag===19&&(p.memoizedProps.revealOrder==="forwards"||p.memoizedProps.revealOrder==="backwards"||p.memoizedProps.revealOrder==="unstable_legacy-backwards"||p.memoizedProps.revealOrder==="together")){if((p.flags&128)!==0)return p}else if(p.child!==null){p.child.return=p,p=p.child;continue}if(p===h)break;for(;p.sibling===null;){if(p.return===null||p.return===h)return null;p=p.return}p.sibling.return=p.return,p=p.sibling}return null}var rc=0,mn=null,nr=null,li=null,iv=!1,fm=!1,gh=!1,av=0,xx=0,mm=null,die=0;function Vr(){throw Error(r(321))}function JN(h,p){if(p===null)return!1;for(var _=0;_<p.length&&_<h.length;_++)if(!ws(h[_],p[_]))return!1;return!0}function eE(h,p,_,N,j,I){return rc=I,mn=p,p.memoizedState=null,p.updateQueue=null,p.lanes=0,Y.H=h===null||h.memoizedState===null?g5:pE,gh=!1,I=_(N,j),gh=!1,fm&&(I=OI(p,_,N,j)),DI(h),I}function DI(h){Y.H=vx;var p=nr!==null&&nr.next!==null;if(rc=0,li=nr=mn=null,iv=!1,xx=0,mm=null,p)throw Error(r(300));h===null||ci||(h=h.dependencies,h!==null&&Xy(h)&&(ci=!0))}function OI(h,p,_,N){mn=h;var j=0;do{if(fm&&(mm=null),xx=0,fm=!1,25<=j)throw Error(r(301));if(j+=1,li=nr=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=x5,I=p(_,N)}while(fm);return I}function hie(){var h=Y.H,p=h.useState()[0];return p=typeof p.then=="function"?bx(p):p,h=h.useState()[0],(nr!==null?nr.memoizedState:null)!==h&&(mn.flags|=1024),p}function tE(){var h=av!==0;return av=0,h}function nE(h,p,_){p.updateQueue=h.updateQueue,p.flags&=-2053,h.lanes&=~_}function rE(h){if(iv){for(h=h.memoizedState;h!==null;){var p=h.queue;p!==null&&(p.pending=null),h=h.next}iv=!1}rc=0,li=nr=mn=null,fm=!1,xx=av=0,mm=null}function Oa(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return li===null?mn.memoizedState=li=h:li=li.next=h,li}function ri(){if(nr===null){var h=mn.alternate;h=h!==null?h.memoizedState:null}else h=nr.next;var p=li===null?mn.memoizedState:li.next;if(p!==null)li=p,nr=h;else{if(h===null)throw mn.alternate===null?Error(r(467)):Error(r(310));nr=h,h={memoizedState:nr.memoizedState,baseState:nr.baseState,baseQueue:nr.baseQueue,queue:nr.queue,next:null},li===null?mn.memoizedState=li=h:li=li.next=h}return li}function sv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function bx(h){var p=xx;return xx+=1,mm===null&&(mm=[]),h=NI(mm,h,p),p=mn,(li===null?p.memoizedState:li.next)===null&&(p=p.alternate,Y.H=p===null||p.memoizedState===null?g5:pE),h}function ov(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return bx(h);if(h.$$typeof===S)return ia(h)}throw Error(r(438,String(h)))}function iE(h){var p=null,_=mn.updateQueue;if(_!==null&&(p=_.memoCache),p==null){var N=mn.alternate;N!==null&&(N=N.updateQueue,N!==null&&(N=N.memoCache,N!=null&&(p={data:N.data.map(function(j){return j.slice()}),index:0})))}if(p==null&&(p={data:[],index:0}),_===null&&(_=sv(),mn.updateQueue=_),_.memoCache=p,_=p.data[p.index],_===void 0)for(_=p.data[p.index]=Array(h),N=0;N<h;N++)_[N]=P;return p.index++,_}function ic(h,p){return typeof p=="function"?p(h):p}function lv(h){var p=ri();return aE(p,nr,h)}function aE(h,p,_){var N=h.queue;if(N===null)throw Error(r(311));N.lastRenderedReducer=_;var j=h.baseQueue,I=N.pending;if(I!==null){if(j!==null){var ee=j.next;j.next=I.next,I.next=ee}p.baseQueue=j=I,N.pending=null}if(I=h.baseState,j===null)h.memoizedState=I;else{p=j.next;var me=ee=null,Pe=null,nt=p,gt=!1;do{var bt=nt.lane&-536870913;if(bt!==nt.lane?(jn&bt)===bt:(rc&bt)===bt){var it=nt.revertLane;if(it===0)Pe!==null&&(Pe=Pe.next={lane:0,revertLane:0,gesture:null,action:nt.action,hasEagerState:nt.hasEagerState,eagerState:nt.eagerState,next:null}),bt===lm&&(gt=!0);else if((rc&it)===it){nt=nt.next,it===lm&&(gt=!0);continue}else bt={lane:0,revertLane:nt.revertLane,gesture:null,action:nt.action,hasEagerState:nt.hasEagerState,eagerState:nt.eagerState,next:null},Pe===null?(me=Pe=bt,ee=I):Pe=Pe.next=bt,mn.lanes|=it,Tu|=it;bt=nt.action,gh&&_(I,bt),I=nt.hasEagerState?nt.eagerState:_(I,bt)}else it={lane:bt,revertLane:nt.revertLane,gesture:nt.gesture,action:nt.action,hasEagerState:nt.hasEagerState,eagerState:nt.eagerState,next:null},Pe===null?(me=Pe=it,ee=I):Pe=Pe.next=it,mn.lanes|=bt,Tu|=bt;nt=nt.next}while(nt!==null&&nt!==p);if(Pe===null?ee=I:Pe.next=me,!ws(I,h.memoizedState)&&(ci=!0,gt&&(_=cm,_!==null)))throw _;h.memoizedState=I,h.baseState=ee,h.baseQueue=Pe,N.lastRenderedState=I}return j===null&&(N.lanes=0),[h.memoizedState,N.dispatch]}function sE(h){var p=ri(),_=p.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var N=_.dispatch,j=_.pending,I=p.memoizedState;if(j!==null){_.pending=null;var ee=j=j.next;do I=h(I,ee.action),ee=ee.next;while(ee!==j);ws(I,p.memoizedState)||(ci=!0),p.memoizedState=I,p.baseQueue===null&&(p.baseState=I),_.lastRenderedState=I}return[I,N]}function LI(h,p,_){var N=mn,j=ri(),I=Rn;if(I){if(_===void 0)throw Error(r(407));_=_()}else _=p();var ee=!ws((nr||j).memoizedState,_);if(ee&&(j.memoizedState=_,ci=!0),j=j.queue,cE(UI.bind(null,N,j,h),[h]),j.getSnapshot!==p||ee||li!==null&&li.memoizedState.tag&1){if(N.flags|=2048,pm(9,{destroy:void 0},FI.bind(null,N,j,_,p),null),fr===null)throw Error(r(349));I||(rc&127)!==0||II(N,p,_)}return _}function II(h,p,_){h.flags|=16384,h={getSnapshot:p,value:_},p=mn.updateQueue,p===null?(p=sv(),mn.updateQueue=p,p.stores=[h]):(_=p.stores,_===null?p.stores=[h]:_.push(h))}function FI(h,p,_,N){p.value=_,p.getSnapshot=N,zI(p)&&BI(h)}function UI(h,p,_){return _(function(){zI(p)&&BI(h)})}function zI(h){var p=h.getSnapshot;h=h.value;try{var _=p();return!ws(h,_)}catch{return!0}}function BI(h){var p=oh(h,2);p!==null&&rs(p,h,2)}function oE(h){var p=Oa();if(typeof h=="function"){var _=h;if(h=_(),gh){rt(!0);try{_()}finally{rt(!1)}}}return p.memoizedState=p.baseState=h,p.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ic,lastRenderedState:h},p}function $I(h,p,_,N){return h.baseState=_,aE(h,nr,typeof N=="function"?N:ic)}function fie(h,p,_,N,j){if(dv(h))throw Error(r(485));if(h=p.action,h!==null){var I={payload:j,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(ee){I.listeners.push(ee)}};Y.T!==null?_(!0):I.isTransition=!1,N(I),_=p.pending,_===null?(I.next=p.pending=I,HI(p,I)):(I.next=_.next,p.pending=_.next=I)}}function HI(h,p){var _=p.action,N=p.payload,j=h.state;if(p.isTransition){var I=Y.T,ee={};Y.T=ee;try{var me=_(j,N),Pe=Y.S;Pe!==null&&Pe(ee,me),VI(h,p,me)}catch(nt){lE(h,p,nt)}finally{I!==null&&ee.types!==null&&(I.types=ee.types),Y.T=I}}else try{I=_(j,N),VI(h,p,I)}catch(nt){lE(h,p,nt)}}function VI(h,p,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(N){GI(h,p,N)},function(N){return lE(h,p,N)}):GI(h,p,_)}function GI(h,p,_){p.status="fulfilled",p.value=_,WI(p),h.state=_,p=h.pending,p!==null&&(_=p.next,_===p?h.pending=null:(_=_.next,p.next=_,HI(h,_)))}function lE(h,p,_){var N=h.pending;if(h.pending=null,N!==null){N=N.next;do p.status="rejected",p.reason=_,WI(p),p=p.next;while(p!==N)}h.action=null}function WI(h){h=h.listeners;for(var p=0;p<h.length;p++)(0,h[p])()}function qI(h,p){return p}function KI(h,p){if(Rn){var _=fr.formState;if(_!==null){e:{var N=mn;if(Rn){if(wr){t:{for(var j=wr,I=Zs;j.nodeType!==8;){if(!I){j=null;break t}if(j=eo(j.nextSibling),j===null){j=null;break t}}I=j.data,j=I==="F!"||I==="F"?j:null}if(j){wr=eo(j.nextSibling),N=j.data==="F!";break e}}yu(N)}N=!1}N&&(p=_[0])}}return _=Oa(),_.memoizedState=_.baseState=p,N={pending:null,lanes:0,dispatch:null,lastRenderedReducer:qI,lastRenderedState:p},_.queue=N,_=f5.bind(null,mn,N),N.dispatch=_,N=oE(!1),I=mE.bind(null,mn,!1,N.queue),N=Oa(),j={state:p,dispatch:null,action:h,pending:null},N.queue=j,_=fie.bind(null,mn,j,I,_),j.dispatch=_,N.memoizedState=h,[p,_,!1]}function XI(h){var p=ri();return YI(p,nr,h)}function YI(h,p,_){if(p=aE(h,p,qI)[0],h=lv(ic)[0],typeof p=="object"&&p!==null&&typeof p.then=="function")try{var N=bx(p)}catch(ee){throw ee===um?Zy:ee}else N=p;p=ri();var j=p.queue,I=j.dispatch;return _!==p.memoizedState&&(mn.flags|=2048,pm(9,{destroy:void 0},mie.bind(null,j,_),null)),[N,I,h]}function mie(h,p){h.action=p}function QI(h){var p=ri(),_=nr;if(_!==null)return YI(p,_,h);ri(),p=p.memoizedState,_=ri();var N=_.queue.dispatch;return _.memoizedState=h,[p,N,!1]}function pm(h,p,_,N){return h={tag:h,create:_,deps:N,inst:p,next:null},p=mn.updateQueue,p===null&&(p=sv(),mn.updateQueue=p),_=p.lastEffect,_===null?p.lastEffect=h.next=h:(N=_.next,_.next=h,h.next=N,p.lastEffect=h),h}function ZI(){return ri().memoizedState}function cv(h,p,_,N){var j=Oa();mn.flags|=h,j.memoizedState=pm(1|p,{destroy:void 0},_,N===void 0?null:N)}function uv(h,p,_,N){var j=ri();N=N===void 0?null:N;var I=j.memoizedState.inst;nr!==null&&N!==null&&JN(N,nr.memoizedState.deps)?j.memoizedState=pm(p,I,_,N):(mn.flags|=h,j.memoizedState=pm(1|p,I,_,N))}function JI(h,p){cv(8390656,8,h,p)}function cE(h,p){uv(2048,8,h,p)}function pie(h){mn.flags|=4;var p=mn.updateQueue;if(p===null)p=sv(),mn.updateQueue=p,p.events=[h];else{var _=p.events;_===null?p.events=[h]:_.push(h)}}function e5(h){var p=ri().memoizedState;return pie({ref:p,nextImpl:h}),function(){if((Hn&2)!==0)throw Error(r(440));return p.impl.apply(void 0,arguments)}}function t5(h,p){return uv(4,2,h,p)}function n5(h,p){return uv(4,4,h,p)}function r5(h,p){if(typeof p=="function"){h=h();var _=p(h);return function(){typeof _=="function"?_():p(null)}}if(p!=null)return h=h(),p.current=h,function(){p.current=null}}function i5(h,p,_){_=_!=null?_.concat([h]):null,uv(4,4,r5.bind(null,p,h),_)}function uE(){}function a5(h,p){var _=ri();p=p===void 0?null:p;var N=_.memoizedState;return p!==null&&JN(p,N[1])?N[0]:(_.memoizedState=[h,p],h)}function s5(h,p){var _=ri();p=p===void 0?null:p;var N=_.memoizedState;if(p!==null&&JN(p,N[1]))return N[0];if(N=h(),gh){rt(!0);try{h()}finally{rt(!1)}}return _.memoizedState=[N,p],N}function dE(h,p,_){return _===void 0||(rc&1073741824)!==0&&(jn&261930)===0?h.memoizedState=p:(h.memoizedState=_,h=oF(),mn.lanes|=h,Tu|=h,_)}function o5(h,p,_,N){return ws(_,p)?_:hm.current!==null?(h=dE(h,_,N),ws(h,p)||(ci=!0),h):(rc&42)===0||(rc&1073741824)!==0&&(jn&261930)===0?(ci=!0,h.memoizedState=_):(h=oF(),mn.lanes|=h,Tu|=h,p)}function l5(h,p,_,N,j){var I=q.p;q.p=I!==0&&8>I?I:8;var ee=Y.T,me={};Y.T=me,mE(h,!1,p,_);try{var Pe=j(),nt=Y.S;if(nt!==null&&nt(me,Pe),Pe!==null&&typeof Pe=="object"&&typeof Pe.then=="function"){var gt=uie(Pe,N);yx(h,p,gt,Ts(h))}else yx(h,p,N,Ts(h))}catch(bt){yx(h,p,{then:function(){},status:"rejected",reason:bt},Ts())}finally{q.p=I,ee!==null&&me.types!==null&&(ee.types=me.types),Y.T=ee}}function gie(){}function hE(h,p,_,N){if(h.tag!==5)throw Error(r(476));var j=c5(h).queue;l5(h,j,p,Z,_===null?gie:function(){return u5(h),_(N)})}function c5(h){var p=h.memoizedState;if(p!==null)return p;p={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ic,lastRenderedState:Z},next:null};var _={};return p.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ic,lastRenderedState:_},next:null},h.memoizedState=p,h=h.alternate,h!==null&&(h.memoizedState=p),p}function u5(h){var p=c5(h);p.next===null&&(p=h.alternate.memoizedState),yx(h,p.next.queue,{},Ts())}function fE(){return ia(Lx)}function d5(){return ri().memoizedState}function h5(){return ri().memoizedState}function xie(h){for(var p=h.return;p!==null;){switch(p.tag){case 24:case 3:var _=Ts();h=wu(_);var N=Su(p,h,_);N!==null&&(rs(N,p,_),mx(N,p,_)),p={cache:$N()},h.payload=p;return}p=p.return}}function bie(h,p,_){var N=Ts();_={lane:N,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},dv(h)?m5(p,_):(_=jN(h,p,_,N),_!==null&&(rs(_,h,N),p5(_,p,N)))}function f5(h,p,_){var N=Ts();yx(h,p,_,N)}function yx(h,p,_,N){var j={lane:N,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(dv(h))m5(p,j);else{var I=h.alternate;if(h.lanes===0&&(I===null||I.lanes===0)&&(I=p.lastRenderedReducer,I!==null))try{var ee=p.lastRenderedState,me=I(ee,_);if(j.hasEagerState=!0,j.eagerState=me,ws(me,ee))return Gy(h,p,j,0),fr===null&&Vy(),!1}catch{}finally{}if(_=jN(h,p,j,N),_!==null)return rs(_,h,N),p5(_,p,N),!0}return!1}function mE(h,p,_,N){if(N={lane:2,revertLane:WE(),gesture:null,action:N,hasEagerState:!1,eagerState:null,next:null},dv(h)){if(p)throw Error(r(479))}else p=jN(h,_,N,2),p!==null&&rs(p,h,2)}function dv(h){var p=h.alternate;return h===mn||p!==null&&p===mn}function m5(h,p){fm=iv=!0;var _=h.pending;_===null?p.next=p:(p.next=_.next,_.next=p),h.pending=p}function p5(h,p,_){if((_&4194048)!==0){var N=p.lanes;N&=h.pendingLanes,_|=N,p.lanes=_,pt(h,_)}}var vx={readContext:ia,use:ov,useCallback:Vr,useContext:Vr,useEffect:Vr,useImperativeHandle:Vr,useLayoutEffect:Vr,useInsertionEffect:Vr,useMemo:Vr,useReducer:Vr,useRef:Vr,useState:Vr,useDebugValue:Vr,useDeferredValue:Vr,useTransition:Vr,useSyncExternalStore:Vr,useId:Vr,useHostTransitionStatus:Vr,useFormState:Vr,useActionState:Vr,useOptimistic:Vr,useMemoCache:Vr,useCacheRefresh:Vr};vx.useEffectEvent=Vr;var g5={readContext:ia,use:ov,useCallback:function(h,p){return Oa().memoizedState=[h,p===void 0?null:p],h},useContext:ia,useEffect:JI,useImperativeHandle:function(h,p,_){_=_!=null?_.concat([h]):null,cv(4194308,4,r5.bind(null,p,h),_)},useLayoutEffect:function(h,p){return cv(4194308,4,h,p)},useInsertionEffect:function(h,p){cv(4,2,h,p)},useMemo:function(h,p){var _=Oa();p=p===void 0?null:p;var N=h();if(gh){rt(!0);try{h()}finally{rt(!1)}}return _.memoizedState=[N,p],N},useReducer:function(h,p,_){var N=Oa();if(_!==void 0){var j=_(p);if(gh){rt(!0);try{_(p)}finally{rt(!1)}}}else j=p;return N.memoizedState=N.baseState=j,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:j},N.queue=h,h=h.dispatch=bie.bind(null,mn,h),[N.memoizedState,h]},useRef:function(h){var p=Oa();return h={current:h},p.memoizedState=h},useState:function(h){h=oE(h);var p=h.queue,_=f5.bind(null,mn,p);return p.dispatch=_,[h.memoizedState,_]},useDebugValue:uE,useDeferredValue:function(h,p){var _=Oa();return dE(_,h,p)},useTransition:function(){var h=oE(!1);return h=l5.bind(null,mn,h.queue,!0,!1),Oa().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,p,_){var N=mn,j=Oa();if(Rn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=p(),fr===null)throw Error(r(349));(jn&127)!==0||II(N,p,_)}j.memoizedState=_;var I={value:_,getSnapshot:p};return j.queue=I,JI(UI.bind(null,N,I,h),[h]),N.flags|=2048,pm(9,{destroy:void 0},FI.bind(null,N,I,_,p),null),_},useId:function(){var h=Oa(),p=fr.identifierPrefix;if(Rn){var _=hl,N=dl;_=(N&~(1<<32-qe(N)-1)).toString(32)+_,p="_"+p+"R_"+_,_=av++,0<_&&(p+="H"+_.toString(32)),p+="_"}else _=die++,p="_"+p+"r_"+_.toString(32)+"_";return h.memoizedState=p},useHostTransitionStatus:fE,useFormState:KI,useActionState:KI,useOptimistic:function(h){var p=Oa();p.memoizedState=p.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return p.queue=_,p=mE.bind(null,mn,!0,_),_.dispatch=p,[h,p]},useMemoCache:iE,useCacheRefresh:function(){return Oa().memoizedState=xie.bind(null,mn)},useEffectEvent:function(h){var p=Oa(),_={impl:h};return p.memoizedState=_,function(){if((Hn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},pE={readContext:ia,use:ov,useCallback:a5,useContext:ia,useEffect:cE,useImperativeHandle:i5,useInsertionEffect:t5,useLayoutEffect:n5,useMemo:s5,useReducer:lv,useRef:ZI,useState:function(){return lv(ic)},useDebugValue:uE,useDeferredValue:function(h,p){var _=ri();return o5(_,nr.memoizedState,h,p)},useTransition:function(){var h=lv(ic)[0],p=ri().memoizedState;return[typeof h=="boolean"?h:bx(h),p]},useSyncExternalStore:LI,useId:d5,useHostTransitionStatus:fE,useFormState:XI,useActionState:XI,useOptimistic:function(h,p){var _=ri();return $I(_,nr,h,p)},useMemoCache:iE,useCacheRefresh:h5};pE.useEffectEvent=e5;var x5={readContext:ia,use:ov,useCallback:a5,useContext:ia,useEffect:cE,useImperativeHandle:i5,useInsertionEffect:t5,useLayoutEffect:n5,useMemo:s5,useReducer:sE,useRef:ZI,useState:function(){return sE(ic)},useDebugValue:uE,useDeferredValue:function(h,p){var _=ri();return nr===null?dE(_,h,p):o5(_,nr.memoizedState,h,p)},useTransition:function(){var h=sE(ic)[0],p=ri().memoizedState;return[typeof h=="boolean"?h:bx(h),p]},useSyncExternalStore:LI,useId:d5,useHostTransitionStatus:fE,useFormState:QI,useActionState:QI,useOptimistic:function(h,p){var _=ri();return nr!==null?$I(_,nr,h,p):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:iE,useCacheRefresh:h5};x5.useEffectEvent=e5;function gE(h,p,_,N){p=h.memoizedState,_=_(N,p),_=_==null?p:f({},p,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var xE={enqueueSetState:function(h,p,_){h=h._reactInternals;var N=Ts(),j=wu(N);j.payload=p,_!=null&&(j.callback=_),p=Su(h,j,N),p!==null&&(rs(p,h,N),mx(p,h,N))},enqueueReplaceState:function(h,p,_){h=h._reactInternals;var N=Ts(),j=wu(N);j.tag=1,j.payload=p,_!=null&&(j.callback=_),p=Su(h,j,N),p!==null&&(rs(p,h,N),mx(p,h,N))},enqueueForceUpdate:function(h,p){h=h._reactInternals;var _=Ts(),N=wu(_);N.tag=2,p!=null&&(N.callback=p),p=Su(h,N,_),p!==null&&(rs(p,h,_),mx(p,h,_))}};function b5(h,p,_,N,j,I,ee){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(N,I,ee):p.prototype&&p.prototype.isPureReactComponent?!sx(_,N)||!sx(j,I):!0}function y5(h,p,_,N){h=p.state,typeof p.componentWillReceiveProps=="function"&&p.componentWillReceiveProps(_,N),typeof p.UNSAFE_componentWillReceiveProps=="function"&&p.UNSAFE_componentWillReceiveProps(_,N),p.state!==h&&xE.enqueueReplaceState(p,p.state,null)}function xh(h,p){var _=p;if("ref"in p){_={};for(var N in p)N!=="ref"&&(_[N]=p[N])}if(h=h.defaultProps){_===p&&(_=f({},_));for(var j in h)_[j]===void 0&&(_[j]=h[j])}return _}function v5(h){Hy(h)}function _5(h){console.error(h)}function w5(h){Hy(h)}function hv(h,p){try{var _=h.onUncaughtError;_(p.value,{componentStack:p.stack})}catch(N){setTimeout(function(){throw N})}}function S5(h,p,_){try{var N=h.onCaughtError;N(_.value,{componentStack:_.stack,errorBoundary:p.tag===1?p.stateNode:null})}catch(j){setTimeout(function(){throw j})}}function bE(h,p,_){return _=wu(_),_.tag=3,_.payload={element:null},_.callback=function(){hv(h,p)},_}function M5(h){return h=wu(h),h.tag=3,h}function N5(h,p,_,N){var j=_.type.getDerivedStateFromError;if(typeof j=="function"){var I=N.value;h.payload=function(){return j(I)},h.callback=function(){S5(p,_,N)}}var ee=_.stateNode;ee!==null&&typeof ee.componentDidCatch=="function"&&(h.callback=function(){S5(p,_,N),typeof j!="function"&&(Cu===null?Cu=new Set([this]):Cu.add(this));var me=N.stack;this.componentDidCatch(N.value,{componentStack:me!==null?me:""})})}function yie(h,p,_,N,j){if(_.flags|=32768,N!==null&&typeof N=="object"&&typeof N.then=="function"){if(p=_.alternate,p!==null&&om(p,_,j,!0),_=Ms.current,_!==null){switch(_.tag){case 31:case 13:return Js===null?Mv():_.alternate===null&&Gr===0&&(Gr=3),_.flags&=-257,_.flags|=65536,_.lanes=j,N===Jy?_.flags|=16384:(p=_.updateQueue,p===null?_.updateQueue=new Set([N]):p.add(N),HE(h,N,j)),!1;case 22:return _.flags|=65536,N===Jy?_.flags|=16384:(p=_.updateQueue,p===null?(p={transitions:null,markerInstances:null,retryQueue:new Set([N])},_.updateQueue=p):(_=p.retryQueue,_===null?p.retryQueue=new Set([N]):_.add(N)),HE(h,N,j)),!1}throw Error(r(435,_.tag))}return HE(h,N,j),Mv(),!1}if(Rn)return p=Ms.current,p!==null?((p.flags&65536)===0&&(p.flags|=256),p.flags|=65536,p.lanes=j,N!==IN&&(h=Error(r(422),{cause:N}),cx(Xs(h,_)))):(N!==IN&&(p=Error(r(423),{cause:N}),cx(Xs(p,_))),h=h.current.alternate,h.flags|=65536,j&=-j,h.lanes|=j,N=Xs(N,_),j=bE(h.stateNode,N,j),KN(h,j),Gr!==4&&(Gr=2)),!1;var I=Error(r(520),{cause:N});if(I=Xs(I,_),Tx===null?Tx=[I]:Tx.push(I),Gr!==4&&(Gr=2),p===null)return!0;N=Xs(N,_),_=p;do{switch(_.tag){case 3:return _.flags|=65536,h=j&-j,_.lanes|=h,h=bE(_.stateNode,N,h),KN(_,h),!1;case 1:if(p=_.type,I=_.stateNode,(_.flags&128)===0&&(typeof p.getDerivedStateFromError=="function"||I!==null&&typeof I.componentDidCatch=="function"&&(Cu===null||!Cu.has(I))))return _.flags|=65536,j&=-j,_.lanes|=j,j=M5(j),N5(j,h,_,N),KN(_,j),!1}_=_.return}while(_!==null);return!1}var yE=Error(r(461)),ci=!1;function aa(h,p,_,N){p.child=h===null?CI(p,null,_,N):ph(p,h.child,_,N)}function E5(h,p,_,N,j){_=_.render;var I=p.ref;if("ref"in N){var ee={};for(var me in N)me!=="ref"&&(ee[me]=N[me])}else ee=N;return dh(p),N=eE(h,p,_,ee,I,j),me=tE(),h!==null&&!ci?(nE(h,p,j),ac(h,p,j)):(Rn&&me&&ON(p),p.flags|=1,aa(h,p,N,j),p.child)}function A5(h,p,_,N,j){if(h===null){var I=_.type;return typeof I=="function"&&!PN(I)&&I.defaultProps===void 0&&_.compare===null?(p.tag=15,p.type=I,T5(h,p,I,N,j)):(h=qy(_.type,null,N,p,p.mode,j),h.ref=p.ref,h.return=p,p.child=h)}if(I=h.child,!AE(h,j)){var ee=I.memoizedProps;if(_=_.compare,_=_!==null?_:sx,_(ee,N)&&h.ref===p.ref)return ac(h,p,j)}return p.flags|=1,h=Jl(I,N),h.ref=p.ref,h.return=p,p.child=h}function T5(h,p,_,N,j){if(h!==null){var I=h.memoizedProps;if(sx(I,N)&&h.ref===p.ref)if(ci=!1,p.pendingProps=N=I,AE(h,j))(h.flags&131072)!==0&&(ci=!0);else return p.lanes=h.lanes,ac(h,p,j)}return vE(h,p,_,N,j)}function C5(h,p,_,N){var j=N.children,I=h!==null?h.memoizedState:null;if(h===null&&p.stateNode===null&&(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),N.mode==="hidden"){if((p.flags&128)!==0){if(I=I!==null?I.baseLanes|_:_,h!==null){for(N=p.child=h.child,j=0;N!==null;)j=j|N.lanes|N.childLanes,N=N.sibling;N=j&~I}else N=0,p.child=null;return k5(h,p,I,_,N)}if((_&536870912)!==0)p.memoizedState={baseLanes:0,cachePool:null},h!==null&&Qy(p,I!==null?I.cachePool:null),I!==null?PI(p,I):YN(),RI(p);else return N=p.lanes=536870912,k5(h,p,I!==null?I.baseLanes|_:_,_,N)}else I!==null?(Qy(p,I.cachePool),PI(p,I),Nu(),p.memoizedState=null):(h!==null&&Qy(p,null),YN(),Nu());return aa(h,p,j,_),p.child}function _x(h,p){return h!==null&&h.tag===22||p.stateNode!==null||(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),p.sibling}function k5(h,p,_,N,j){var I=VN();return I=I===null?null:{parent:oi._currentValue,pool:I},p.memoizedState={baseLanes:_,cachePool:I},h!==null&&Qy(p,null),YN(),RI(p),h!==null&&om(h,p,N,!0),p.childLanes=j,null}function fv(h,p){return p=pv({mode:p.mode,children:p.children},h.mode),p.ref=h.ref,h.child=p,p.return=h,p}function j5(h,p,_){return ph(p,h.child,null,_),h=fv(p,p.pendingProps),h.flags|=2,Ns(p),p.memoizedState=null,h}function vie(h,p,_){var N=p.pendingProps,j=(p.flags&128)!==0;if(p.flags&=-129,h===null){if(Rn){if(N.mode==="hidden")return h=fv(p,N),p.lanes=536870912,_x(null,h);if(ZN(p),(h=wr)?(h=HF(h,Zs),h=h!==null&&h.data==="&"?h:null,h!==null&&(p.memoizedState={dehydrated:h,treeContext:xu!==null?{id:dl,overflow:hl}:null,retryLane:536870912,hydrationErrors:null},_=mI(h),_.return=p,p.child=_,ra=p,wr=null)):h=null,h===null)throw yu(p);return p.lanes=536870912,null}return fv(p,N)}var I=h.memoizedState;if(I!==null){var ee=I.dehydrated;if(ZN(p),j)if(p.flags&256)p.flags&=-257,p=j5(h,p,_);else if(p.memoizedState!==null)p.child=h.child,p.flags|=128,p=null;else throw Error(r(558));else if(ci||om(h,p,_,!1),j=(_&h.childLanes)!==0,ci||j){if(N=fr,N!==null&&(ee=$t(N,_),ee!==0&&ee!==I.retryLane))throw I.retryLane=ee,oh(h,ee),rs(N,h,ee),yE;Mv(),p=j5(h,p,_)}else h=I.treeContext,wr=eo(ee.nextSibling),ra=p,Rn=!0,bu=null,Zs=!1,h!==null&&xI(p,h),p=fv(p,N),p.flags|=4096;return p}return h=Jl(h.child,{mode:N.mode,children:N.children}),h.ref=p.ref,p.child=h,h.return=p,h}function mv(h,p){var _=p.ref;if(_===null)h!==null&&h.ref!==null&&(p.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(h===null||h.ref!==_)&&(p.flags|=4194816)}}function vE(h,p,_,N,j){return dh(p),_=eE(h,p,_,N,void 0,j),N=tE(),h!==null&&!ci?(nE(h,p,j),ac(h,p,j)):(Rn&&N&&ON(p),p.flags|=1,aa(h,p,_,j),p.child)}function P5(h,p,_,N,j,I){return dh(p),p.updateQueue=null,_=OI(p,N,_,j),DI(h),N=tE(),h!==null&&!ci?(nE(h,p,I),ac(h,p,I)):(Rn&&N&&ON(p),p.flags|=1,aa(h,p,_,I),p.child)}function R5(h,p,_,N,j){if(dh(p),p.stateNode===null){var I=rm,ee=_.contextType;typeof ee=="object"&&ee!==null&&(I=ia(ee)),I=new _(N,I),p.memoizedState=I.state!==null&&I.state!==void 0?I.state:null,I.updater=xE,p.stateNode=I,I._reactInternals=p,I=p.stateNode,I.props=N,I.state=p.memoizedState,I.refs={},WN(p),ee=_.contextType,I.context=typeof ee=="object"&&ee!==null?ia(ee):rm,I.state=p.memoizedState,ee=_.getDerivedStateFromProps,typeof ee=="function"&&(gE(p,_,ee,N),I.state=p.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof I.getSnapshotBeforeUpdate=="function"||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(ee=I.state,typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount(),ee!==I.state&&xE.enqueueReplaceState(I,I.state,null),gx(p,N,I,j),px(),I.state=p.memoizedState),typeof I.componentDidMount=="function"&&(p.flags|=4194308),N=!0}else if(h===null){I=p.stateNode;var me=p.memoizedProps,Pe=xh(_,me);I.props=Pe;var nt=I.context,gt=_.contextType;ee=rm,typeof gt=="object"&>!==null&&(ee=ia(gt));var bt=_.getDerivedStateFromProps;gt=typeof bt=="function"||typeof I.getSnapshotBeforeUpdate=="function",me=p.pendingProps!==me,gt||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(me||nt!==ee)&&y5(p,I,N,ee),_u=!1;var it=p.memoizedState;I.state=it,gx(p,N,I,j),px(),nt=p.memoizedState,me||it!==nt||_u?(typeof bt=="function"&&(gE(p,_,bt,N),nt=p.memoizedState),(Pe=_u||b5(p,_,Pe,N,it,nt,ee))?(gt||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"&&(p.flags|=4194308)):(typeof I.componentDidMount=="function"&&(p.flags|=4194308),p.memoizedProps=N,p.memoizedState=nt),I.props=N,I.state=nt,I.context=ee,N=Pe):(typeof I.componentDidMount=="function"&&(p.flags|=4194308),N=!1)}else{I=p.stateNode,qN(h,p),ee=p.memoizedProps,gt=xh(_,ee),I.props=gt,bt=p.pendingProps,it=I.context,nt=_.contextType,Pe=rm,typeof nt=="object"&&nt!==null&&(Pe=ia(nt)),me=_.getDerivedStateFromProps,(nt=typeof me=="function"||typeof I.getSnapshotBeforeUpdate=="function")||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(ee!==bt||it!==Pe)&&y5(p,I,N,Pe),_u=!1,it=p.memoizedState,I.state=it,gx(p,N,I,j),px();var lt=p.memoizedState;ee!==bt||it!==lt||_u||h!==null&&h.dependencies!==null&&Xy(h.dependencies)?(typeof me=="function"&&(gE(p,_,me,N),lt=p.memoizedState),(gt=_u||b5(p,_,gt,N,it,lt,Pe)||h!==null&&h.dependencies!==null&&Xy(h.dependencies))?(nt||typeof I.UNSAFE_componentWillUpdate!="function"&&typeof I.componentWillUpdate!="function"||(typeof I.componentWillUpdate=="function"&&I.componentWillUpdate(N,lt,Pe),typeof I.UNSAFE_componentWillUpdate=="function"&&I.UNSAFE_componentWillUpdate(N,lt,Pe)),typeof I.componentDidUpdate=="function"&&(p.flags|=4),typeof I.getSnapshotBeforeUpdate=="function"&&(p.flags|=1024)):(typeof I.componentDidUpdate!="function"||ee===h.memoizedProps&&it===h.memoizedState||(p.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||ee===h.memoizedProps&&it===h.memoizedState||(p.flags|=1024),p.memoizedProps=N,p.memoizedState=lt),I.props=N,I.state=lt,I.context=Pe,N=gt):(typeof I.componentDidUpdate!="function"||ee===h.memoizedProps&&it===h.memoizedState||(p.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||ee===h.memoizedProps&&it===h.memoizedState||(p.flags|=1024),N=!1)}return I=N,mv(h,p),N=(p.flags&128)!==0,I||N?(I=p.stateNode,_=N&&typeof _.getDerivedStateFromError!="function"?null:I.render(),p.flags|=1,h!==null&&N?(p.child=ph(p,h.child,null,j),p.child=ph(p,null,_,j)):aa(h,p,_,j),p.memoizedState=I.state,h=p.child):h=ac(h,p,j),h}function D5(h,p,_,N){return ch(),p.flags|=256,aa(h,p,_,N),p.child}var _E={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function wE(h){return{baseLanes:h,cachePool:SI()}}function SE(h,p,_){return h=h!==null?h.childLanes&~_:0,p&&(h|=As),h}function O5(h,p,_){var N=p.pendingProps,j=!1,I=(p.flags&128)!==0,ee;if((ee=I)||(ee=h!==null&&h.memoizedState===null?!1:(ni.current&2)!==0),ee&&(j=!0,p.flags&=-129),ee=(p.flags&32)!==0,p.flags&=-33,h===null){if(Rn){if(j?Mu(p):Nu(),(h=wr)?(h=HF(h,Zs),h=h!==null&&h.data!=="&"?h:null,h!==null&&(p.memoizedState={dehydrated:h,treeContext:xu!==null?{id:dl,overflow:hl}:null,retryLane:536870912,hydrationErrors:null},_=mI(h),_.return=p,p.child=_,ra=p,wr=null)):h=null,h===null)throw yu(p);return aA(h)?p.lanes=32:p.lanes=536870912,null}var me=N.children;return N=N.fallback,j?(Nu(),j=p.mode,me=pv({mode:"hidden",children:me},j),N=lh(N,j,_,null),me.return=p,N.return=p,me.sibling=N,p.child=me,N=p.child,N.memoizedState=wE(_),N.childLanes=SE(h,ee,_),p.memoizedState=_E,_x(null,N)):(Mu(p),ME(p,me))}var Pe=h.memoizedState;if(Pe!==null&&(me=Pe.dehydrated,me!==null)){if(I)p.flags&256?(Mu(p),p.flags&=-257,p=NE(h,p,_)):p.memoizedState!==null?(Nu(),p.child=h.child,p.flags|=128,p=null):(Nu(),me=N.fallback,j=p.mode,N=pv({mode:"visible",children:N.children},j),me=lh(me,j,_,null),me.flags|=2,N.return=p,me.return=p,N.sibling=me,p.child=N,ph(p,h.child,null,_),N=p.child,N.memoizedState=wE(_),N.childLanes=SE(h,ee,_),p.memoizedState=_E,p=_x(null,N));else if(Mu(p),aA(me)){if(ee=me.nextSibling&&me.nextSibling.dataset,ee)var nt=ee.dgst;ee=nt,N=Error(r(419)),N.stack="",N.digest=ee,cx({value:N,source:null,stack:null}),p=NE(h,p,_)}else if(ci||om(h,p,_,!1),ee=(_&h.childLanes)!==0,ci||ee){if(ee=fr,ee!==null&&(N=$t(ee,_),N!==0&&N!==Pe.retryLane))throw Pe.retryLane=N,oh(h,N),rs(ee,h,N),yE;iA(me)||Mv(),p=NE(h,p,_)}else iA(me)?(p.flags|=192,p.child=h.child,p=null):(h=Pe.treeContext,wr=eo(me.nextSibling),ra=p,Rn=!0,bu=null,Zs=!1,h!==null&&xI(p,h),p=ME(p,N.children),p.flags|=4096);return p}return j?(Nu(),me=N.fallback,j=p.mode,Pe=h.child,nt=Pe.sibling,N=Jl(Pe,{mode:"hidden",children:N.children}),N.subtreeFlags=Pe.subtreeFlags&65011712,nt!==null?me=Jl(nt,me):(me=lh(me,j,_,null),me.flags|=2),me.return=p,N.return=p,N.sibling=me,p.child=N,_x(null,N),N=p.child,me=h.child.memoizedState,me===null?me=wE(_):(j=me.cachePool,j!==null?(Pe=oi._currentValue,j=j.parent!==Pe?{parent:Pe,pool:Pe}:j):j=SI(),me={baseLanes:me.baseLanes|_,cachePool:j}),N.memoizedState=me,N.childLanes=SE(h,ee,_),p.memoizedState=_E,_x(h.child,N)):(Mu(p),_=h.child,h=_.sibling,_=Jl(_,{mode:"visible",children:N.children}),_.return=p,_.sibling=null,h!==null&&(ee=p.deletions,ee===null?(p.deletions=[h],p.flags|=16):ee.push(h)),p.child=_,p.memoizedState=null,_)}function ME(h,p){return p=pv({mode:"visible",children:p},h.mode),p.return=h,h.child=p}function pv(h,p){return h=Ss(22,h,null,p),h.lanes=0,h}function NE(h,p,_){return ph(p,h.child,null,_),h=ME(p,p.pendingProps.children),h.flags|=2,p.memoizedState=null,h}function L5(h,p,_){h.lanes|=p;var N=h.alternate;N!==null&&(N.lanes|=p),zN(h.return,p,_)}function EE(h,p,_,N,j,I){var ee=h.memoizedState;ee===null?h.memoizedState={isBackwards:p,rendering:null,renderingStartTime:0,last:N,tail:_,tailMode:j,treeForkCount:I}:(ee.isBackwards=p,ee.rendering=null,ee.renderingStartTime=0,ee.last=N,ee.tail=_,ee.tailMode=j,ee.treeForkCount=I)}function I5(h,p,_){var N=p.pendingProps,j=N.revealOrder,I=N.tail;N=N.children;var ee=ni.current,me=(ee&2)!==0;if(me?(ee=ee&1|2,p.flags|=128):ee&=1,J(ni,ee),aa(h,p,N,_),N=Rn?lx:0,!me&&h!==null&&(h.flags&128)!==0)e:for(h=p.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&L5(h,_,p);else if(h.tag===19)L5(h,_,p);else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===p)break e;for(;h.sibling===null;){if(h.return===null||h.return===p)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}switch(j){case"forwards":for(_=p.child,j=null;_!==null;)h=_.alternate,h!==null&&rv(h)===null&&(j=_),_=_.sibling;_=j,_===null?(j=p.child,p.child=null):(j=_.sibling,_.sibling=null),EE(p,!1,j,_,I,N);break;case"backwards":case"unstable_legacy-backwards":for(_=null,j=p.child,p.child=null;j!==null;){if(h=j.alternate,h!==null&&rv(h)===null){p.child=j;break}h=j.sibling,j.sibling=_,_=j,j=h}EE(p,!0,_,null,I,N);break;case"together":EE(p,!1,null,null,void 0,N);break;default:p.memoizedState=null}return p.child}function ac(h,p,_){if(h!==null&&(p.dependencies=h.dependencies),Tu|=p.lanes,(_&p.childLanes)===0)if(h!==null){if(om(h,p,_,!1),(_&p.childLanes)===0)return null}else return null;if(h!==null&&p.child!==h.child)throw Error(r(153));if(p.child!==null){for(h=p.child,_=Jl(h,h.pendingProps),p.child=_,_.return=p;h.sibling!==null;)h=h.sibling,_=_.sibling=Jl(h,h.pendingProps),_.return=p;_.sibling=null}return p.child}function AE(h,p){return(h.lanes&p)!==0?!0:(h=h.dependencies,!!(h!==null&&Xy(h)))}function _ie(h,p,_){switch(p.tag){case 3:Ae(p,p.stateNode.containerInfo),vu(p,oi,h.memoizedState.cache),ch();break;case 27:case 5:Me(p);break;case 4:Ae(p,p.stateNode.containerInfo);break;case 10:vu(p,p.type,p.memoizedProps.value);break;case 31:if(p.memoizedState!==null)return p.flags|=128,ZN(p),null;break;case 13:var N=p.memoizedState;if(N!==null)return N.dehydrated!==null?(Mu(p),p.flags|=128,null):(_&p.child.childLanes)!==0?O5(h,p,_):(Mu(p),h=ac(h,p,_),h!==null?h.sibling:null);Mu(p);break;case 19:var j=(h.flags&128)!==0;if(N=(_&p.childLanes)!==0,N||(om(h,p,_,!1),N=(_&p.childLanes)!==0),j){if(N)return I5(h,p,_);p.flags|=128}if(j=p.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),J(ni,ni.current),N)break;return null;case 22:return p.lanes=0,C5(h,p,_,p.pendingProps);case 24:vu(p,oi,h.memoizedState.cache)}return ac(h,p,_)}function F5(h,p,_){if(h!==null)if(h.memoizedProps!==p.pendingProps)ci=!0;else{if(!AE(h,_)&&(p.flags&128)===0)return ci=!1,_ie(h,p,_);ci=(h.flags&131072)!==0}else ci=!1,Rn&&(p.flags&1048576)!==0&&gI(p,lx,p.index);switch(p.lanes=0,p.tag){case 16:e:{var N=p.pendingProps;if(h=fh(p.elementType),p.type=h,typeof h=="function")PN(h)?(N=xh(h,N),p.tag=1,p=R5(null,p,h,N,_)):(p.tag=0,p=vE(null,p,h,N,_));else{if(h!=null){var j=h.$$typeof;if(j===A){p.tag=11,p=E5(null,p,h,N,_);break e}else if(j===C){p.tag=14,p=A5(null,p,h,N,_);break e}}throw p=D(h)||h,Error(r(306,p,""))}}return p;case 0:return vE(h,p,p.type,p.pendingProps,_);case 1:return N=p.type,j=xh(N,p.pendingProps),R5(h,p,N,j,_);case 3:e:{if(Ae(p,p.stateNode.containerInfo),h===null)throw Error(r(387));N=p.pendingProps;var I=p.memoizedState;j=I.element,qN(h,p),gx(p,N,null,_);var ee=p.memoizedState;if(N=ee.cache,vu(p,oi,N),N!==I.cache&&BN(p,[oi],_,!0),px(),N=ee.element,I.isDehydrated)if(I={element:N,isDehydrated:!1,cache:ee.cache},p.updateQueue.baseState=I,p.memoizedState=I,p.flags&256){p=D5(h,p,N,_);break e}else if(N!==j){j=Xs(Error(r(424)),p),cx(j),p=D5(h,p,N,_);break e}else{switch(h=p.stateNode.containerInfo,h.nodeType){case 9:h=h.body;break;default:h=h.nodeName==="HTML"?h.ownerDocument.body:h}for(wr=eo(h.firstChild),ra=p,Rn=!0,bu=null,Zs=!0,_=CI(p,null,N,_),p.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(ch(),N===j){p=ac(h,p,_);break e}aa(h,p,N,_)}p=p.child}return p;case 26:return mv(h,p),h===null?(_=XF(p.type,null,p.pendingProps,null))?p.memoizedState=_:Rn||(_=p.type,h=p.pendingProps,N=jv(de.current).createElement(_),N[hr]=p,N[yt]=h,sa(N,_,h),Le(N),p.stateNode=N):p.memoizedState=XF(p.type,h.memoizedProps,p.pendingProps,h.memoizedState),null;case 27:return Me(p),h===null&&Rn&&(N=p.stateNode=WF(p.type,p.pendingProps,de.current),ra=p,Zs=!0,j=wr,Ru(p.type)?(sA=j,wr=eo(N.firstChild)):wr=j),aa(h,p,p.pendingProps.children,_),mv(h,p),h===null&&(p.flags|=4194304),p.child;case 5:return h===null&&Rn&&((j=N=wr)&&(N=Qie(N,p.type,p.pendingProps,Zs),N!==null?(p.stateNode=N,ra=p,wr=eo(N.firstChild),Zs=!1,j=!0):j=!1),j||yu(p)),Me(p),j=p.type,I=p.pendingProps,ee=h!==null?h.memoizedProps:null,N=I.children,tA(j,I)?N=null:ee!==null&&tA(j,ee)&&(p.flags|=32),p.memoizedState!==null&&(j=eE(h,p,hie,null,null,_),Lx._currentValue=j),mv(h,p),aa(h,p,N,_),p.child;case 6:return h===null&&Rn&&((h=_=wr)&&(_=Zie(_,p.pendingProps,Zs),_!==null?(p.stateNode=_,ra=p,wr=null,h=!0):h=!1),h||yu(p)),null;case 13:return O5(h,p,_);case 4:return Ae(p,p.stateNode.containerInfo),N=p.pendingProps,h===null?p.child=ph(p,null,N,_):aa(h,p,N,_),p.child;case 11:return E5(h,p,p.type,p.pendingProps,_);case 7:return aa(h,p,p.pendingProps,_),p.child;case 8:return aa(h,p,p.pendingProps.children,_),p.child;case 12:return aa(h,p,p.pendingProps.children,_),p.child;case 10:return N=p.pendingProps,vu(p,p.type,N.value),aa(h,p,N.children,_),p.child;case 9:return j=p.type._context,N=p.pendingProps.children,dh(p),j=ia(j),N=N(j),p.flags|=1,aa(h,p,N,_),p.child;case 14:return A5(h,p,p.type,p.pendingProps,_);case 15:return T5(h,p,p.type,p.pendingProps,_);case 19:return I5(h,p,_);case 31:return vie(h,p,_);case 22:return C5(h,p,_,p.pendingProps);case 24:return dh(p),N=ia(oi),h===null?(j=VN(),j===null&&(j=fr,I=$N(),j.pooledCache=I,I.refCount++,I!==null&&(j.pooledCacheLanes|=_),j=I),p.memoizedState={parent:N,cache:j},WN(p),vu(p,oi,j)):((h.lanes&_)!==0&&(qN(h,p),gx(p,null,null,_),px()),j=h.memoizedState,I=p.memoizedState,j.parent!==N?(j={parent:N,cache:N},p.memoizedState=j,p.lanes===0&&(p.memoizedState=p.updateQueue.baseState=j),vu(p,oi,N)):(N=I.cache,vu(p,oi,N),N!==j.cache&&BN(p,[oi],_,!0))),aa(h,p,p.pendingProps.children,_),p.child;case 29:throw p.pendingProps}throw Error(r(156,p.tag))}function sc(h){h.flags|=4}function TE(h,p,_,N,j){if((p=(h.mode&32)!==0)&&(p=!1),p){if(h.flags|=16777216,(j&335544128)===j)if(h.stateNode.complete)h.flags|=8192;else if(dF())h.flags|=8192;else throw mh=Jy,GN}else h.flags&=-16777217}function U5(h,p){if(p.type!=="stylesheet"||(p.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!eU(p))if(dF())h.flags|=8192;else throw mh=Jy,GN}function gv(h,p){p!==null&&(h.flags|=4),h.flags&16384&&(p=h.tag!==22?kt():536870912,h.lanes|=p,ym|=p)}function wx(h,p){if(!Rn)switch(h.tailMode){case"hidden":p=h.tail;for(var _=null;p!==null;)p.alternate!==null&&(_=p),p=p.sibling;_===null?h.tail=null:_.sibling=null;break;case"collapsed":_=h.tail;for(var N=null;_!==null;)_.alternate!==null&&(N=_),_=_.sibling;N===null?p||h.tail===null?h.tail=null:h.tail.sibling=null:N.sibling=null}}function Sr(h){var p=h.alternate!==null&&h.alternate.child===h.child,_=0,N=0;if(p)for(var j=h.child;j!==null;)_|=j.lanes|j.childLanes,N|=j.subtreeFlags&65011712,N|=j.flags&65011712,j.return=h,j=j.sibling;else for(j=h.child;j!==null;)_|=j.lanes|j.childLanes,N|=j.subtreeFlags,N|=j.flags,j.return=h,j=j.sibling;return h.subtreeFlags|=N,h.childLanes=_,p}function wie(h,p,_){var N=p.pendingProps;switch(LN(p),p.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Sr(p),null;case 1:return Sr(p),null;case 3:return _=p.stateNode,N=null,h!==null&&(N=h.memoizedState.cache),p.memoizedState.cache!==N&&(p.flags|=2048),nc(oi),ge(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(sm(p)?sc(p):h===null||h.memoizedState.isDehydrated&&(p.flags&256)===0||(p.flags|=1024,FN())),Sr(p),null;case 26:var j=p.type,I=p.memoizedState;return h===null?(sc(p),I!==null?(Sr(p),U5(p,I)):(Sr(p),TE(p,j,null,N,_))):I?I!==h.memoizedState?(sc(p),Sr(p),U5(p,I)):(Sr(p),p.flags&=-16777217):(h=h.memoizedProps,h!==N&&sc(p),Sr(p),TE(p,j,h,N,_)),null;case 27:if(je(p),_=de.current,j=p.type,h!==null&&p.stateNode!=null)h.memoizedProps!==N&&sc(p);else{if(!N){if(p.stateNode===null)throw Error(r(166));return Sr(p),null}h=te.current,sm(p)?bI(p):(h=WF(j,N,_),p.stateNode=h,sc(p))}return Sr(p),null;case 5:if(je(p),j=p.type,h!==null&&p.stateNode!=null)h.memoizedProps!==N&&sc(p);else{if(!N){if(p.stateNode===null)throw Error(r(166));return Sr(p),null}if(I=te.current,sm(p))bI(p);else{var ee=jv(de.current);switch(I){case 1:I=ee.createElementNS("http://www.w3.org/2000/svg",j);break;case 2:I=ee.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;default:switch(j){case"svg":I=ee.createElementNS("http://www.w3.org/2000/svg",j);break;case"math":I=ee.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;case"script":I=ee.createElement("div"),I.innerHTML="<script><\/script>",I=I.removeChild(I.firstChild);break;case"select":I=typeof N.is=="string"?ee.createElement("select",{is:N.is}):ee.createElement("select"),N.multiple?I.multiple=!0:N.size&&(I.size=N.size);break;default:I=typeof N.is=="string"?ee.createElement(j,{is:N.is}):ee.createElement(j)}}I[hr]=p,I[yt]=N;e:for(ee=p.child;ee!==null;){if(ee.tag===5||ee.tag===6)I.appendChild(ee.stateNode);else if(ee.tag!==4&&ee.tag!==27&&ee.child!==null){ee.child.return=ee,ee=ee.child;continue}if(ee===p)break e;for(;ee.sibling===null;){if(ee.return===null||ee.return===p)break e;ee=ee.return}ee.sibling.return=ee.return,ee=ee.sibling}p.stateNode=I;e:switch(sa(I,j,N),j){case"button":case"input":case"select":case"textarea":N=!!N.autoFocus;break e;case"img":N=!0;break e;default:N=!1}N&&sc(p)}}return Sr(p),TE(p,p.type,h===null?null:h.memoizedProps,p.pendingProps,_),null;case 6:if(h&&p.stateNode!=null)h.memoizedProps!==N&&sc(p);else{if(typeof N!="string"&&p.stateNode===null)throw Error(r(166));if(h=de.current,sm(p)){if(h=p.stateNode,_=p.memoizedProps,N=null,j=ra,j!==null)switch(j.tag){case 27:case 5:N=j.memoizedProps}h[hr]=p,h=!!(h.nodeValue===_||N!==null&&N.suppressHydrationWarning===!0||OF(h.nodeValue,_)),h||yu(p,!0)}else h=jv(h).createTextNode(N),h[hr]=p,p.stateNode=h}return Sr(p),null;case 31:if(_=p.memoizedState,h===null||h.memoizedState!==null){if(N=sm(p),_!==null){if(h===null){if(!N)throw Error(r(318));if(h=p.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[hr]=p}else ch(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;Sr(p),h=!1}else _=FN(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return p.flags&256?(Ns(p),p):(Ns(p),null);if((p.flags&128)!==0)throw Error(r(558))}return Sr(p),null;case 13:if(N=p.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(j=sm(p),N!==null&&N.dehydrated!==null){if(h===null){if(!j)throw Error(r(318));if(j=p.memoizedState,j=j!==null?j.dehydrated:null,!j)throw Error(r(317));j[hr]=p}else ch(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;Sr(p),j=!1}else j=FN(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=j),j=!0;if(!j)return p.flags&256?(Ns(p),p):(Ns(p),null)}return Ns(p),(p.flags&128)!==0?(p.lanes=_,p):(_=N!==null,h=h!==null&&h.memoizedState!==null,_&&(N=p.child,j=null,N.alternate!==null&&N.alternate.memoizedState!==null&&N.alternate.memoizedState.cachePool!==null&&(j=N.alternate.memoizedState.cachePool.pool),I=null,N.memoizedState!==null&&N.memoizedState.cachePool!==null&&(I=N.memoizedState.cachePool.pool),I!==j&&(N.flags|=2048)),_!==h&&_&&(p.child.flags|=8192),gv(p,p.updateQueue),Sr(p),null);case 4:return ge(),h===null&&YE(p.stateNode.containerInfo),Sr(p),null;case 10:return nc(p.type),Sr(p),null;case 19:if(G(ni),N=p.memoizedState,N===null)return Sr(p),null;if(j=(p.flags&128)!==0,I=N.rendering,I===null)if(j)wx(N,!1);else{if(Gr!==0||h!==null&&(h.flags&128)!==0)for(h=p.child;h!==null;){if(I=rv(h),I!==null){for(p.flags|=128,wx(N,!1),h=I.updateQueue,p.updateQueue=h,gv(p,h),p.subtreeFlags=0,h=_,_=p.child;_!==null;)fI(_,h),_=_.sibling;return J(ni,ni.current&1|2),Rn&&ec(p,N.treeForkCount),p.child}h=h.sibling}N.tail!==null&&O()>_v&&(p.flags|=128,j=!0,wx(N,!1),p.lanes=4194304)}else{if(!j)if(h=rv(I),h!==null){if(p.flags|=128,j=!0,h=h.updateQueue,p.updateQueue=h,gv(p,h),wx(N,!0),N.tail===null&&N.tailMode==="hidden"&&!I.alternate&&!Rn)return Sr(p),null}else 2*O()-N.renderingStartTime>_v&&_!==536870912&&(p.flags|=128,j=!0,wx(N,!1),p.lanes=4194304);N.isBackwards?(I.sibling=p.child,p.child=I):(h=N.last,h!==null?h.sibling=I:p.child=I,N.last=I)}return N.tail!==null?(h=N.tail,N.rendering=h,N.tail=h.sibling,N.renderingStartTime=O(),h.sibling=null,_=ni.current,J(ni,j?_&1|2:_&1),Rn&&ec(p,N.treeForkCount),h):(Sr(p),null);case 22:case 23:return Ns(p),QN(),N=p.memoizedState!==null,h!==null?h.memoizedState!==null!==N&&(p.flags|=8192):N&&(p.flags|=8192),N?(_&536870912)!==0&&(p.flags&128)===0&&(Sr(p),p.subtreeFlags&6&&(p.flags|=8192)):Sr(p),_=p.updateQueue,_!==null&&gv(p,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),N=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(N=p.memoizedState.cachePool.pool),N!==_&&(p.flags|=2048),h!==null&&G(hh),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),p.memoizedState.cache!==_&&(p.flags|=2048),nc(oi),Sr(p),null;case 25:return null;case 30:return null}throw Error(r(156,p.tag))}function Sie(h,p){switch(LN(p),p.tag){case 1:return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 3:return nc(oi),ge(),h=p.flags,(h&65536)!==0&&(h&128)===0?(p.flags=h&-65537|128,p):null;case 26:case 27:case 5:return je(p),null;case 31:if(p.memoizedState!==null){if(Ns(p),p.alternate===null)throw Error(r(340));ch()}return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 13:if(Ns(p),h=p.memoizedState,h!==null&&h.dehydrated!==null){if(p.alternate===null)throw Error(r(340));ch()}return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 19:return G(ni),null;case 4:return ge(),null;case 10:return nc(p.type),null;case 22:case 23:return Ns(p),QN(),h!==null&&G(hh),h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 24:return nc(oi),null;case 25:return null;default:return null}}function z5(h,p){switch(LN(p),p.tag){case 3:nc(oi),ge();break;case 26:case 27:case 5:je(p);break;case 4:ge();break;case 31:p.memoizedState!==null&&Ns(p);break;case 13:Ns(p);break;case 19:G(ni);break;case 10:nc(p.type);break;case 22:case 23:Ns(p),QN(),h!==null&&G(hh);break;case 24:nc(oi)}}function Sx(h,p){try{var _=p.updateQueue,N=_!==null?_.lastEffect:null;if(N!==null){var j=N.next;_=j;do{if((_.tag&h)===h){N=void 0;var I=_.create,ee=_.inst;N=I(),ee.destroy=N}_=_.next}while(_!==j)}}catch(me){Qn(p,p.return,me)}}function Eu(h,p,_){try{var N=p.updateQueue,j=N!==null?N.lastEffect:null;if(j!==null){var I=j.next;N=I;do{if((N.tag&h)===h){var ee=N.inst,me=ee.destroy;if(me!==void 0){ee.destroy=void 0,j=p;var Pe=_,nt=me;try{nt()}catch(gt){Qn(j,Pe,gt)}}}N=N.next}while(N!==I)}}catch(gt){Qn(p,p.return,gt)}}function B5(h){var p=h.updateQueue;if(p!==null){var _=h.stateNode;try{jI(p,_)}catch(N){Qn(h,h.return,N)}}}function $5(h,p,_){_.props=xh(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(N){Qn(h,p,N)}}function Mx(h,p){try{var _=h.ref;if(_!==null){switch(h.tag){case 26:case 27:case 5:var N=h.stateNode;break;case 30:N=h.stateNode;break;default:N=h.stateNode}typeof _=="function"?h.refCleanup=_(N):_.current=N}}catch(j){Qn(h,p,j)}}function fl(h,p){var _=h.ref,N=h.refCleanup;if(_!==null)if(typeof N=="function")try{N()}catch(j){Qn(h,p,j)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(j){Qn(h,p,j)}else _.current=null}function H5(h){var p=h.type,_=h.memoizedProps,N=h.stateNode;try{e:switch(p){case"button":case"input":case"select":case"textarea":_.autoFocus&&N.focus();break e;case"img":_.src?N.src=_.src:_.srcSet&&(N.srcset=_.srcSet)}}catch(j){Qn(h,h.return,j)}}function CE(h,p,_){try{var N=h.stateNode;Gie(N,h.type,_,p),N[yt]=p}catch(j){Qn(h,h.return,j)}}function V5(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&Ru(h.type)||h.tag===4}function kE(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||V5(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&&Ru(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 jE(h,p,_){var N=h.tag;if(N===5||N===6)h=h.stateNode,p?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(h,p):(p=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,p.appendChild(h),_=_._reactRootContainer,_!=null||p.onclick!==null||(p.onclick=Ql));else if(N!==4&&(N===27&&Ru(h.type)&&(_=h.stateNode,p=null),h=h.child,h!==null))for(jE(h,p,_),h=h.sibling;h!==null;)jE(h,p,_),h=h.sibling}function xv(h,p,_){var N=h.tag;if(N===5||N===6)h=h.stateNode,p?_.insertBefore(h,p):_.appendChild(h);else if(N!==4&&(N===27&&Ru(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(xv(h,p,_),h=h.sibling;h!==null;)xv(h,p,_),h=h.sibling}function G5(h){var p=h.stateNode,_=h.memoizedProps;try{for(var N=h.type,j=p.attributes;j.length;)p.removeAttributeNode(j[0]);sa(p,N,_),p[hr]=h,p[yt]=_}catch(I){Qn(h,h.return,I)}}var oc=!1,ui=!1,PE=!1,W5=typeof WeakSet=="function"?WeakSet:Set,Ui=null;function Mie(h,p){if(h=h.containerInfo,JE=Fv,h=iI(h),NN(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var N=_.getSelection&&_.getSelection();if(N&&N.rangeCount!==0){_=N.anchorNode;var j=N.anchorOffset,I=N.focusNode;N=N.focusOffset;try{_.nodeType,I.nodeType}catch{_=null;break e}var ee=0,me=-1,Pe=-1,nt=0,gt=0,bt=h,it=null;t:for(;;){for(var lt;bt!==_||j!==0&&bt.nodeType!==3||(me=ee+j),bt!==I||N!==0&&bt.nodeType!==3||(Pe=ee+N),bt.nodeType===3&&(ee+=bt.nodeValue.length),(lt=bt.firstChild)!==null;)it=bt,bt=lt;for(;;){if(bt===h)break t;if(it===_&&++nt===j&&(me=ee),it===I&&++gt===N&&(Pe=ee),(lt=bt.nextSibling)!==null)break;bt=it,it=bt.parentNode}bt=lt}_=me===-1||Pe===-1?null:{start:me,end:Pe}}else _=null}_=_||{start:0,end:0}}else _=null;for(eA={focusedElem:h,selectionRange:_},Fv=!1,Ui=p;Ui!==null;)if(p=Ui,h=p.child,(p.subtreeFlags&1028)!==0&&h!==null)h.return=p,Ui=h;else for(;Ui!==null;){switch(p=Ui,I=p.alternate,h=p.flags,p.tag){case 0:if((h&4)!==0&&(h=p.updateQueue,h=h!==null?h.events:null,h!==null))for(_=0;_<h.length;_++)j=h[_],j.ref.impl=j.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&I!==null){h=void 0,_=p,j=I.memoizedProps,I=I.memoizedState,N=_.stateNode;try{var Bt=xh(_.type,j);h=N.getSnapshotBeforeUpdate(Bt,I),N.__reactInternalSnapshotBeforeUpdate=h}catch(Jt){Qn(_,_.return,Jt)}}break;case 3:if((h&1024)!==0){if(h=p.stateNode.containerInfo,_=h.nodeType,_===9)rA(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":rA(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=p.sibling,h!==null){h.return=p.return,Ui=h;break}Ui=p.return}}function q5(h,p,_){var N=_.flags;switch(_.tag){case 0:case 11:case 15:cc(h,_),N&4&&Sx(5,_);break;case 1:if(cc(h,_),N&4)if(h=_.stateNode,p===null)try{h.componentDidMount()}catch(ee){Qn(_,_.return,ee)}else{var j=xh(_.type,p.memoizedProps);p=p.memoizedState;try{h.componentDidUpdate(j,p,h.__reactInternalSnapshotBeforeUpdate)}catch(ee){Qn(_,_.return,ee)}}N&64&&B5(_),N&512&&Mx(_,_.return);break;case 3:if(cc(h,_),N&64&&(h=_.updateQueue,h!==null)){if(p=null,_.child!==null)switch(_.child.tag){case 27:case 5:p=_.child.stateNode;break;case 1:p=_.child.stateNode}try{jI(h,p)}catch(ee){Qn(_,_.return,ee)}}break;case 27:p===null&&N&4&&G5(_);case 26:case 5:cc(h,_),p===null&&N&4&&H5(_),N&512&&Mx(_,_.return);break;case 12:cc(h,_);break;case 31:cc(h,_),N&4&&Y5(h,_);break;case 13:cc(h,_),N&4&&Q5(h,_),N&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=Rie.bind(null,_),Jie(h,_))));break;case 22:if(N=_.memoizedState!==null||oc,!N){p=p!==null&&p.memoizedState!==null||ui,j=oc;var I=ui;oc=N,(ui=p)&&!I?uc(h,_,(_.subtreeFlags&8772)!==0):cc(h,_),oc=j,ui=I}break;case 30:break;default:cc(h,_)}}function K5(h){var p=h.alternate;p!==null&&(h.alternate=null,K5(p)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(p=h.stateNode,p!==null&&Qe(p)),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 Cr=null,Ja=!1;function lc(h,p,_){for(_=_.child;_!==null;)X5(h,p,_),_=_.sibling}function X5(h,p,_){if(he&&typeof he.onCommitFiberUnmount=="function")try{he.onCommitFiberUnmount(We,_)}catch{}switch(_.tag){case 26:ui||fl(_,p),lc(h,p,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:ui||fl(_,p);var N=Cr,j=Ja;Ru(_.type)&&(Cr=_.stateNode,Ja=!1),lc(h,p,_),Rx(_.stateNode),Cr=N,Ja=j;break;case 5:ui||fl(_,p);case 6:if(N=Cr,j=Ja,Cr=null,lc(h,p,_),Cr=N,Ja=j,Cr!==null)if(Ja)try{(Cr.nodeType===9?Cr.body:Cr.nodeName==="HTML"?Cr.ownerDocument.body:Cr).removeChild(_.stateNode)}catch(I){Qn(_,p,I)}else try{Cr.removeChild(_.stateNode)}catch(I){Qn(_,p,I)}break;case 18:Cr!==null&&(Ja?(h=Cr,BF(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),Am(h)):BF(Cr,_.stateNode));break;case 4:N=Cr,j=Ja,Cr=_.stateNode.containerInfo,Ja=!0,lc(h,p,_),Cr=N,Ja=j;break;case 0:case 11:case 14:case 15:Eu(2,_,p),ui||Eu(4,_,p),lc(h,p,_);break;case 1:ui||(fl(_,p),N=_.stateNode,typeof N.componentWillUnmount=="function"&&$5(_,p,N)),lc(h,p,_);break;case 21:lc(h,p,_);break;case 22:ui=(N=ui)||_.memoizedState!==null,lc(h,p,_),ui=N;break;default:lc(h,p,_)}}function Y5(h,p){if(p.memoizedState===null&&(h=p.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{Am(h)}catch(_){Qn(p,p.return,_)}}}function Q5(h,p){if(p.memoizedState===null&&(h=p.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{Am(h)}catch(_){Qn(p,p.return,_)}}function Nie(h){switch(h.tag){case 31:case 13:case 19:var p=h.stateNode;return p===null&&(p=h.stateNode=new W5),p;case 22:return h=h.stateNode,p=h._retryCache,p===null&&(p=h._retryCache=new W5),p;default:throw Error(r(435,h.tag))}}function bv(h,p){var _=Nie(h);p.forEach(function(N){if(!_.has(N)){_.add(N);var j=Die.bind(null,h,N);N.then(j,j)}})}function es(h,p){var _=p.deletions;if(_!==null)for(var N=0;N<_.length;N++){var j=_[N],I=h,ee=p,me=ee;e:for(;me!==null;){switch(me.tag){case 27:if(Ru(me.type)){Cr=me.stateNode,Ja=!1;break e}break;case 5:Cr=me.stateNode,Ja=!1;break e;case 3:case 4:Cr=me.stateNode.containerInfo,Ja=!0;break e}me=me.return}if(Cr===null)throw Error(r(160));X5(I,ee,j),Cr=null,Ja=!1,I=j.alternate,I!==null&&(I.return=null),j.return=null}if(p.subtreeFlags&13886)for(p=p.child;p!==null;)Z5(p,h),p=p.sibling}var Do=null;function Z5(h,p){var _=h.alternate,N=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:es(p,h),ts(h),N&4&&(Eu(3,h,h.return),Sx(3,h),Eu(5,h,h.return));break;case 1:es(p,h),ts(h),N&512&&(ui||_===null||fl(_,_.return)),N&64&&oc&&(h=h.updateQueue,h!==null&&(N=h.callbacks,N!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?N:_.concat(N))));break;case 26:var j=Do;if(es(p,h),ts(h),N&512&&(ui||_===null||fl(_,_.return)),N&4){var I=_!==null?_.memoizedState:null;if(N=h.memoizedState,_===null)if(N===null)if(h.stateNode===null){e:{N=h.type,_=h.memoizedProps,j=j.ownerDocument||j;t:switch(N){case"title":I=j.getElementsByTagName("title")[0],(!I||I[Xe]||I[hr]||I.namespaceURI==="http://www.w3.org/2000/svg"||I.hasAttribute("itemprop"))&&(I=j.createElement(N),j.head.insertBefore(I,j.querySelector("head > title"))),sa(I,N,_),I[hr]=h,Le(I),N=I;break e;case"link":var ee=ZF("link","href",j).get(N+(_.href||""));if(ee){for(var me=0;me<ee.length;me++)if(I=ee[me],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)){ee.splice(me,1);break t}}I=j.createElement(N),sa(I,N,_),j.head.appendChild(I);break;case"meta":if(ee=ZF("meta","content",j).get(N+(_.content||""))){for(me=0;me<ee.length;me++)if(I=ee[me],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)){ee.splice(me,1);break t}}I=j.createElement(N),sa(I,N,_),j.head.appendChild(I);break;default:throw Error(r(468,N))}I[hr]=h,Le(I),N=I}h.stateNode=N}else JF(j,h.type,h.stateNode);else h.stateNode=QF(j,N,h.memoizedProps);else I!==N?(I===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):I.count--,N===null?JF(j,h.type,h.stateNode):QF(j,N,h.memoizedProps)):N===null&&h.stateNode!==null&&CE(h,h.memoizedProps,_.memoizedProps)}break;case 27:es(p,h),ts(h),N&512&&(ui||_===null||fl(_,_.return)),_!==null&&N&4&&CE(h,h.memoizedProps,_.memoizedProps);break;case 5:if(es(p,h),ts(h),N&512&&(ui||_===null||fl(_,_.return)),h.flags&32){j=h.stateNode;try{ul(j,"")}catch(Bt){Qn(h,h.return,Bt)}}N&4&&h.stateNode!=null&&(j=h.memoizedProps,CE(h,j,_!==null?_.memoizedProps:j)),N&1024&&(PE=!0);break;case 6:if(es(p,h),ts(h),N&4){if(h.stateNode===null)throw Error(r(162));N=h.memoizedProps,_=h.stateNode;try{_.nodeValue=N}catch(Bt){Qn(h,h.return,Bt)}}break;case 3:if(Dv=null,j=Do,Do=Pv(p.containerInfo),es(p,h),Do=j,ts(h),N&4&&_!==null&&_.memoizedState.isDehydrated)try{Am(p.containerInfo)}catch(Bt){Qn(h,h.return,Bt)}PE&&(PE=!1,J5(h));break;case 4:N=Do,Do=Pv(h.stateNode.containerInfo),es(p,h),ts(h),Do=N;break;case 12:es(p,h),ts(h);break;case 31:es(p,h),ts(h),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,bv(h,N)));break;case 13:es(p,h),ts(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(vv=O()),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,bv(h,N)));break;case 22:j=h.memoizedState!==null;var Pe=_!==null&&_.memoizedState!==null,nt=oc,gt=ui;if(oc=nt||j,ui=gt||Pe,es(p,h),ui=gt,oc=nt,ts(h),N&8192)e:for(p=h.stateNode,p._visibility=j?p._visibility&-2:p._visibility|1,j&&(_===null||Pe||oc||ui||bh(h)),_=null,p=h;;){if(p.tag===5||p.tag===26){if(_===null){Pe=_=p;try{if(I=Pe.stateNode,j)ee=I.style,typeof ee.setProperty=="function"?ee.setProperty("display","none","important"):ee.display="none";else{me=Pe.stateNode;var bt=Pe.memoizedProps.style,it=bt!=null&&bt.hasOwnProperty("display")?bt.display:null;me.style.display=it==null||typeof it=="boolean"?"":(""+it).trim()}}catch(Bt){Qn(Pe,Pe.return,Bt)}}}else if(p.tag===6){if(_===null){Pe=p;try{Pe.stateNode.nodeValue=j?"":Pe.memoizedProps}catch(Bt){Qn(Pe,Pe.return,Bt)}}}else if(p.tag===18){if(_===null){Pe=p;try{var lt=Pe.stateNode;j?$F(lt,!0):$F(Pe.stateNode,!1)}catch(Bt){Qn(Pe,Pe.return,Bt)}}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===h)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===h)break e;for(;p.sibling===null;){if(p.return===null||p.return===h)break e;_===p&&(_=null),p=p.return}_===p&&(_=null),p.sibling.return=p.return,p=p.sibling}N&4&&(N=h.updateQueue,N!==null&&(_=N.retryQueue,_!==null&&(N.retryQueue=null,bv(h,_))));break;case 19:es(p,h),ts(h),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,bv(h,N)));break;case 30:break;case 21:break;default:es(p,h),ts(h)}}function ts(h){var p=h.flags;if(p&2){try{for(var _,N=h.return;N!==null;){if(V5(N)){_=N;break}N=N.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var j=_.stateNode,I=kE(h);xv(h,I,j);break;case 5:var ee=_.stateNode;_.flags&32&&(ul(ee,""),_.flags&=-33);var me=kE(h);xv(h,me,ee);break;case 3:case 4:var Pe=_.stateNode.containerInfo,nt=kE(h);jE(h,nt,Pe);break;default:throw Error(r(161))}}catch(gt){Qn(h,h.return,gt)}h.flags&=-3}p&4096&&(h.flags&=-4097)}function J5(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var p=h;J5(p),p.tag===5&&p.flags&1024&&p.stateNode.reset(),h=h.sibling}}function cc(h,p){if(p.subtreeFlags&8772)for(p=p.child;p!==null;)q5(h,p.alternate,p),p=p.sibling}function bh(h){for(h=h.child;h!==null;){var p=h;switch(p.tag){case 0:case 11:case 14:case 15:Eu(4,p,p.return),bh(p);break;case 1:fl(p,p.return);var _=p.stateNode;typeof _.componentWillUnmount=="function"&&$5(p,p.return,_),bh(p);break;case 27:Rx(p.stateNode);case 26:case 5:fl(p,p.return),bh(p);break;case 22:p.memoizedState===null&&bh(p);break;case 30:bh(p);break;default:bh(p)}h=h.sibling}}function uc(h,p,_){for(_=_&&(p.subtreeFlags&8772)!==0,p=p.child;p!==null;){var N=p.alternate,j=h,I=p,ee=I.flags;switch(I.tag){case 0:case 11:case 15:uc(j,I,_),Sx(4,I);break;case 1:if(uc(j,I,_),N=I,j=N.stateNode,typeof j.componentDidMount=="function")try{j.componentDidMount()}catch(nt){Qn(N,N.return,nt)}if(N=I,j=N.updateQueue,j!==null){var me=N.stateNode;try{var Pe=j.shared.hiddenCallbacks;if(Pe!==null)for(j.shared.hiddenCallbacks=null,j=0;j<Pe.length;j++)kI(Pe[j],me)}catch(nt){Qn(N,N.return,nt)}}_&&ee&64&&B5(I),Mx(I,I.return);break;case 27:G5(I);case 26:case 5:uc(j,I,_),_&&N===null&&ee&4&&H5(I),Mx(I,I.return);break;case 12:uc(j,I,_);break;case 31:uc(j,I,_),_&&ee&4&&Y5(j,I);break;case 13:uc(j,I,_),_&&ee&4&&Q5(j,I);break;case 22:I.memoizedState===null&&uc(j,I,_),Mx(I,I.return);break;case 30:break;default:uc(j,I,_)}p=p.sibling}}function RE(h,p){var _=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),h=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(h=p.memoizedState.cachePool.pool),h!==_&&(h!=null&&h.refCount++,_!=null&&ux(_))}function DE(h,p){h=null,p.alternate!==null&&(h=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==h&&(p.refCount++,h!=null&&ux(h))}function Oo(h,p,_,N){if(p.subtreeFlags&10256)for(p=p.child;p!==null;)eF(h,p,_,N),p=p.sibling}function eF(h,p,_,N){var j=p.flags;switch(p.tag){case 0:case 11:case 15:Oo(h,p,_,N),j&2048&&Sx(9,p);break;case 1:Oo(h,p,_,N);break;case 3:Oo(h,p,_,N),j&2048&&(h=null,p.alternate!==null&&(h=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==h&&(p.refCount++,h!=null&&ux(h)));break;case 12:if(j&2048){Oo(h,p,_,N),h=p.stateNode;try{var I=p.memoizedProps,ee=I.id,me=I.onPostCommit;typeof me=="function"&&me(ee,p.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Pe){Qn(p,p.return,Pe)}}else Oo(h,p,_,N);break;case 31:Oo(h,p,_,N);break;case 13:Oo(h,p,_,N);break;case 23:break;case 22:I=p.stateNode,ee=p.alternate,p.memoizedState!==null?I._visibility&2?Oo(h,p,_,N):Nx(h,p):I._visibility&2?Oo(h,p,_,N):(I._visibility|=2,gm(h,p,_,N,(p.subtreeFlags&10256)!==0||!1)),j&2048&&RE(ee,p);break;case 24:Oo(h,p,_,N),j&2048&&DE(p.alternate,p);break;default:Oo(h,p,_,N)}}function gm(h,p,_,N,j){for(j=j&&((p.subtreeFlags&10256)!==0||!1),p=p.child;p!==null;){var I=h,ee=p,me=_,Pe=N,nt=ee.flags;switch(ee.tag){case 0:case 11:case 15:gm(I,ee,me,Pe,j),Sx(8,ee);break;case 23:break;case 22:var gt=ee.stateNode;ee.memoizedState!==null?gt._visibility&2?gm(I,ee,me,Pe,j):Nx(I,ee):(gt._visibility|=2,gm(I,ee,me,Pe,j)),j&&nt&2048&&RE(ee.alternate,ee);break;case 24:gm(I,ee,me,Pe,j),j&&nt&2048&&DE(ee.alternate,ee);break;default:gm(I,ee,me,Pe,j)}p=p.sibling}}function Nx(h,p){if(p.subtreeFlags&10256)for(p=p.child;p!==null;){var _=h,N=p,j=N.flags;switch(N.tag){case 22:Nx(_,N),j&2048&&RE(N.alternate,N);break;case 24:Nx(_,N),j&2048&&DE(N.alternate,N);break;default:Nx(_,N)}p=p.sibling}}var Ex=8192;function xm(h,p,_){if(h.subtreeFlags&Ex)for(h=h.child;h!==null;)tF(h,p,_),h=h.sibling}function tF(h,p,_){switch(h.tag){case 26:xm(h,p,_),h.flags&Ex&&h.memoizedState!==null&&dae(_,Do,h.memoizedState,h.memoizedProps);break;case 5:xm(h,p,_);break;case 3:case 4:var N=Do;Do=Pv(h.stateNode.containerInfo),xm(h,p,_),Do=N;break;case 22:h.memoizedState===null&&(N=h.alternate,N!==null&&N.memoizedState!==null?(N=Ex,Ex=16777216,xm(h,p,_),Ex=N):xm(h,p,_));break;default:xm(h,p,_)}}function nF(h){var p=h.alternate;if(p!==null&&(h=p.child,h!==null)){p.child=null;do p=h.sibling,h.sibling=null,h=p;while(h!==null)}}function Ax(h){var p=h.deletions;if((h.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var N=p[_];Ui=N,iF(N,h)}nF(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)rF(h),h=h.sibling}function rF(h){switch(h.tag){case 0:case 11:case 15:Ax(h),h.flags&2048&&Eu(9,h,h.return);break;case 3:Ax(h);break;case 12:Ax(h);break;case 22:var p=h.stateNode;h.memoizedState!==null&&p._visibility&2&&(h.return===null||h.return.tag!==13)?(p._visibility&=-3,yv(h)):Ax(h);break;default:Ax(h)}}function yv(h){var p=h.deletions;if((h.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var N=p[_];Ui=N,iF(N,h)}nF(h)}for(h=h.child;h!==null;){switch(p=h,p.tag){case 0:case 11:case 15:Eu(8,p,p.return),yv(p);break;case 22:_=p.stateNode,_._visibility&2&&(_._visibility&=-3,yv(p));break;default:yv(p)}h=h.sibling}}function iF(h,p){for(;Ui!==null;){var _=Ui;switch(_.tag){case 0:case 11:case 15:Eu(8,_,p);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var N=_.memoizedState.cachePool.pool;N!=null&&N.refCount++}break;case 24:ux(_.memoizedState.cache)}if(N=_.child,N!==null)N.return=_,Ui=N;else e:for(_=h;Ui!==null;){N=Ui;var j=N.sibling,I=N.return;if(K5(N),N===_){Ui=null;break e}if(j!==null){j.return=I,Ui=j;break e}Ui=I}}}var Eie={getCacheForType:function(h){var p=ia(oi),_=p.data.get(h);return _===void 0&&(_=h(),p.data.set(h,_)),_},cacheSignal:function(){return ia(oi).controller.signal}},Aie=typeof WeakMap=="function"?WeakMap:Map,Hn=0,fr=null,Nn=null,jn=0,Yn=0,Es=null,Au=!1,bm=!1,OE=!1,dc=0,Gr=0,Tu=0,yh=0,LE=0,As=0,ym=0,Tx=null,ns=null,IE=!1,vv=0,aF=0,_v=1/0,wv=null,Cu=null,Si=0,ku=null,vm=null,hc=0,FE=0,UE=null,sF=null,Cx=0,zE=null;function Ts(){return(Hn&2)!==0&&jn!==0?jn&-jn:Y.T!==null?WE():_r()}function oF(){if(As===0)if((jn&536870912)===0||Rn){var h=be;be<<=1,(be&3932160)===0&&(be=262144),As=h}else As=536870912;return h=Ms.current,h!==null&&(h.flags|=32),As}function rs(h,p,_){(h===fr&&(Yn===2||Yn===9)||h.cancelPendingCommit!==null)&&(_m(h,0),ju(h,jn,As,!1)),Zt(h,_),((Hn&2)===0||h!==fr)&&(h===fr&&((Hn&2)===0&&(yh|=_),Gr===4&&ju(h,jn,As,!1)),ml(h))}function lF(h,p,_){if((Hn&6)!==0)throw Error(r(327));var N=!_&&(p&127)===0&&(p&h.expiredLanes)===0||He(h,p),j=N?kie(h,p):$E(h,p,!0),I=N;do{if(j===0){bm&&!N&&ju(h,p,0,!1);break}else{if(_=h.current.alternate,I&&!Tie(_)){j=$E(h,p,!1),I=!1;continue}if(j===2){if(I=p,h.errorRecoveryDisabledLanes&I)var ee=0;else ee=h.pendingLanes&-536870913,ee=ee!==0?ee:ee&536870912?536870912:0;if(ee!==0){p=ee;e:{var me=h;j=Tx;var Pe=me.current.memoizedState.isDehydrated;if(Pe&&(_m(me,ee).flags|=256),ee=$E(me,ee,!1),ee!==2){if(OE&&!Pe){me.errorRecoveryDisabledLanes|=I,yh|=I,j=4;break e}I=ns,ns=j,I!==null&&(ns===null?ns=I:ns.push.apply(ns,I))}j=ee}if(I=!1,j!==2)continue}}if(j===1){_m(h,0),ju(h,p,0,!0);break}e:{switch(N=h,I=j,I){case 0:case 1:throw Error(r(345));case 4:if((p&4194048)!==p)break;case 6:ju(N,p,As,!Au);break e;case 2:ns=null;break;case 3:case 5:break;default:throw Error(r(329))}if((p&62914560)===p&&(j=vv+300-O(),10<j)){if(ju(N,p,As,!Au),ve(N,0,!0)!==0)break e;hc=p,N.timeoutHandle=UF(cF.bind(null,N,_,ns,wv,IE,p,As,yh,ym,Au,I,"Throttled",-0,0),j);break e}cF(N,_,ns,wv,IE,p,As,yh,ym,Au,I,null,-0,0)}}break}while(!0);ml(h)}function cF(h,p,_,N,j,I,ee,me,Pe,nt,gt,bt,it,lt){if(h.timeoutHandle=-1,bt=p.subtreeFlags,bt&8192||(bt&16785408)===16785408){bt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Ql},tF(p,I,bt);var Bt=(I&62914560)===I?vv-O():(I&4194048)===I?aF-O():0;if(Bt=hae(bt,Bt),Bt!==null){hc=I,h.cancelPendingCommit=Bt(xF.bind(null,h,p,I,_,N,j,ee,me,Pe,gt,bt,null,it,lt)),ju(h,I,ee,!nt);return}}xF(h,p,I,_,N,j,ee,me,Pe)}function Tie(h){for(var p=h;;){var _=p.tag;if((_===0||_===11||_===15)&&p.flags&16384&&(_=p.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var N=0;N<_.length;N++){var j=_[N],I=j.getSnapshot;j=j.value;try{if(!ws(I(),j))return!1}catch{return!1}}if(_=p.child,p.subtreeFlags&16384&&_!==null)_.return=p,p=_;else{if(p===h)break;for(;p.sibling===null;){if(p.return===null||p.return===h)return!0;p=p.return}p.sibling.return=p.return,p=p.sibling}}return!0}function ju(h,p,_,N){p&=~LE,p&=~yh,h.suspendedLanes|=p,h.pingedLanes&=~p,N&&(h.warmLanes|=p),N=h.expirationTimes;for(var j=p;0<j;){var I=31-qe(j),ee=1<<I;N[I]=-1,j&=~ee}_!==0&&nn(h,_,p)}function Sv(){return(Hn&6)===0?(kx(0),!1):!0}function BE(){if(Nn!==null){if(Yn===0)var h=Nn.return;else h=Nn,tc=uh=null,rE(h),dm=null,hx=0,h=Nn;for(;h!==null;)z5(h.alternate,h),h=h.return;Nn=null}}function _m(h,p){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,Kie(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),hc=0,BE(),fr=h,Nn=_=Jl(h.current,null),jn=p,Yn=0,Es=null,Au=!1,bm=He(h,p),OE=!1,ym=As=LE=yh=Tu=Gr=0,ns=Tx=null,IE=!1,(p&8)!==0&&(p|=p&32);var N=h.entangledLanes;if(N!==0)for(h=h.entanglements,N&=p;0<N;){var j=31-qe(N),I=1<<j;p|=h[j],N&=~I}return dc=p,Vy(),_}function uF(h,p){mn=null,Y.H=vx,p===um||p===Zy?(p=EI(),Yn=3):p===GN?(p=EI(),Yn=4):Yn=p===yE?8:p!==null&&typeof p=="object"&&typeof p.then=="function"?6:1,Es=p,Nn===null&&(Gr=1,hv(h,Xs(p,h.current)))}function dF(){var h=Ms.current;return h===null?!0:(jn&4194048)===jn?Js===null:(jn&62914560)===jn||(jn&536870912)!==0?h===Js:!1}function hF(){var h=Y.H;return Y.H=vx,h===null?vx:h}function fF(){var h=Y.A;return Y.A=Eie,h}function Mv(){Gr=4,Au||(jn&4194048)!==jn&&Ms.current!==null||(bm=!0),(Tu&134217727)===0&&(yh&134217727)===0||fr===null||ju(fr,jn,As,!1)}function $E(h,p,_){var N=Hn;Hn|=2;var j=hF(),I=fF();(fr!==h||jn!==p)&&(wv=null,_m(h,p)),p=!1;var ee=Gr;e:do try{if(Yn!==0&&Nn!==null){var me=Nn,Pe=Es;switch(Yn){case 8:BE(),ee=6;break e;case 3:case 2:case 9:case 6:Ms.current===null&&(p=!0);var nt=Yn;if(Yn=0,Es=null,wm(h,me,Pe,nt),_&&bm){ee=0;break e}break;default:nt=Yn,Yn=0,Es=null,wm(h,me,Pe,nt)}}Cie(),ee=Gr;break}catch(gt){uF(h,gt)}while(!0);return p&&h.shellSuspendCounter++,tc=uh=null,Hn=N,Y.H=j,Y.A=I,Nn===null&&(fr=null,jn=0,Vy()),ee}function Cie(){for(;Nn!==null;)mF(Nn)}function kie(h,p){var _=Hn;Hn|=2;var N=hF(),j=fF();fr!==h||jn!==p?(wv=null,_v=O()+500,_m(h,p)):bm=He(h,p);e:do try{if(Yn!==0&&Nn!==null){p=Nn;var I=Es;t:switch(Yn){case 1:Yn=0,Es=null,wm(h,p,I,1);break;case 2:case 9:if(MI(I)){Yn=0,Es=null,pF(p);break}p=function(){Yn!==2&&Yn!==9||fr!==h||(Yn=7),ml(h)},I.then(p,p);break e;case 3:Yn=7;break e;case 4:Yn=5;break e;case 7:MI(I)?(Yn=0,Es=null,pF(p)):(Yn=0,Es=null,wm(h,p,I,7));break;case 5:var ee=null;switch(Nn.tag){case 26:ee=Nn.memoizedState;case 5:case 27:var me=Nn;if(ee?eU(ee):me.stateNode.complete){Yn=0,Es=null;var Pe=me.sibling;if(Pe!==null)Nn=Pe;else{var nt=me.return;nt!==null?(Nn=nt,Nv(nt)):Nn=null}break t}}Yn=0,Es=null,wm(h,p,I,5);break;case 6:Yn=0,Es=null,wm(h,p,I,6);break;case 8:BE(),Gr=6;break e;default:throw Error(r(462))}}jie();break}catch(gt){uF(h,gt)}while(!0);return tc=uh=null,Y.H=N,Y.A=j,Hn=_,Nn!==null?0:(fr=null,jn=0,Vy(),Gr)}function jie(){for(;Nn!==null&&!Ne();)mF(Nn)}function mF(h){var p=F5(h.alternate,h,dc);h.memoizedProps=h.pendingProps,p===null?Nv(h):Nn=p}function pF(h){var p=h,_=p.alternate;switch(p.tag){case 15:case 0:p=P5(_,p,p.pendingProps,p.type,void 0,jn);break;case 11:p=P5(_,p,p.pendingProps,p.type.render,p.ref,jn);break;case 5:rE(p);default:z5(_,p),p=Nn=fI(p,dc),p=F5(_,p,dc)}h.memoizedProps=h.pendingProps,p===null?Nv(h):Nn=p}function wm(h,p,_,N){tc=uh=null,rE(p),dm=null,hx=0;var j=p.return;try{if(yie(h,j,p,_,jn)){Gr=1,hv(h,Xs(_,h.current)),Nn=null;return}}catch(I){if(j!==null)throw Nn=j,I;Gr=1,hv(h,Xs(_,h.current)),Nn=null;return}p.flags&32768?(Rn||N===1?h=!0:bm||(jn&536870912)!==0?h=!1:(Au=h=!0,(N===2||N===9||N===3||N===6)&&(N=Ms.current,N!==null&&N.tag===13&&(N.flags|=16384))),gF(p,h)):Nv(p)}function Nv(h){var p=h;do{if((p.flags&32768)!==0){gF(p,Au);return}h=p.return;var _=wie(p.alternate,p,dc);if(_!==null){Nn=_;return}if(p=p.sibling,p!==null){Nn=p;return}Nn=p=h}while(p!==null);Gr===0&&(Gr=5)}function gF(h,p){do{var _=Sie(h.alternate,h);if(_!==null){_.flags&=32767,Nn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!p&&(h=h.sibling,h!==null)){Nn=h;return}Nn=h=_}while(h!==null);Gr=6,Nn=null}function xF(h,p,_,N,j,I,ee,me,Pe){h.cancelPendingCommit=null;do Ev();while(Si!==0);if((Hn&6)!==0)throw Error(r(327));if(p!==null){if(p===h.current)throw Error(r(177));if(I=p.lanes|p.childLanes,I|=kN,Rt(h,_,I,ee,me,Pe),h===fr&&(Nn=fr=null,jn=0),vm=p,ku=h,hc=_,FE=I,UE=j,sF=N,(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,Oie(le,function(){return wF(),null})):(h.callbackNode=null,h.callbackPriority=0),N=(p.flags&13878)!==0,(p.subtreeFlags&13878)!==0||N){N=Y.T,Y.T=null,j=q.p,q.p=2,ee=Hn,Hn|=4;try{Mie(h,p,_)}finally{Hn=ee,q.p=j,Y.T=N}}Si=1,bF(),yF(),vF()}}function bF(){if(Si===1){Si=0;var h=ku,p=vm,_=(p.flags&13878)!==0;if((p.subtreeFlags&13878)!==0||_){_=Y.T,Y.T=null;var N=q.p;q.p=2;var j=Hn;Hn|=4;try{Z5(p,h);var I=eA,ee=iI(h.containerInfo),me=I.focusedElem,Pe=I.selectionRange;if(ee!==me&&me&&me.ownerDocument&&rI(me.ownerDocument.documentElement,me)){if(Pe!==null&&NN(me)){var nt=Pe.start,gt=Pe.end;if(gt===void 0&&(gt=nt),"selectionStart"in me)me.selectionStart=nt,me.selectionEnd=Math.min(gt,me.value.length);else{var bt=me.ownerDocument||document,it=bt&&bt.defaultView||window;if(it.getSelection){var lt=it.getSelection(),Bt=me.textContent.length,Jt=Math.min(Pe.start,Bt),ir=Pe.end===void 0?Jt:Math.min(Pe.end,Bt);!lt.extend&&Jt>ir&&(ee=ir,ir=Jt,Jt=ee);var Ge=nI(me,Jt),Ue=nI(me,ir);if(Ge&&Ue&&(lt.rangeCount!==1||lt.anchorNode!==Ge.node||lt.anchorOffset!==Ge.offset||lt.focusNode!==Ue.node||lt.focusOffset!==Ue.offset)){var tt=bt.createRange();tt.setStart(Ge.node,Ge.offset),lt.removeAllRanges(),Jt>ir?(lt.addRange(tt),lt.extend(Ue.node,Ue.offset)):(tt.setEnd(Ue.node,Ue.offset),lt.addRange(tt))}}}}for(bt=[],lt=me;lt=lt.parentNode;)lt.nodeType===1&&bt.push({element:lt,left:lt.scrollLeft,top:lt.scrollTop});for(typeof me.focus=="function"&&me.focus(),me=0;me<bt.length;me++){var xt=bt[me];xt.element.scrollLeft=xt.left,xt.element.scrollTop=xt.top}}Fv=!!JE,eA=JE=null}finally{Hn=j,q.p=N,Y.T=_}}h.current=p,Si=2}}function yF(){if(Si===2){Si=0;var h=ku,p=vm,_=(p.flags&8772)!==0;if((p.subtreeFlags&8772)!==0||_){_=Y.T,Y.T=null;var N=q.p;q.p=2;var j=Hn;Hn|=4;try{q5(h,p.alternate,p)}finally{Hn=j,q.p=N,Y.T=_}}Si=3}}function vF(){if(Si===4||Si===3){Si=0,H();var h=ku,p=vm,_=hc,N=sF;(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?Si=5:(Si=0,vm=ku=null,_F(h,h.pendingLanes));var j=h.pendingLanes;if(j===0&&(Cu=null),wt(_),p=p.stateNode,he&&typeof he.onCommitFiberRoot=="function")try{he.onCommitFiberRoot(We,p,void 0,(p.current.flags&128)===128)}catch{}if(N!==null){p=Y.T,j=q.p,q.p=2,Y.T=null;try{for(var I=h.onRecoverableError,ee=0;ee<N.length;ee++){var me=N[ee];I(me.value,{componentStack:me.stack})}}finally{Y.T=p,q.p=j}}(hc&3)!==0&&Ev(),ml(h),j=h.pendingLanes,(_&261930)!==0&&(j&42)!==0?h===zE?Cx++:(Cx=0,zE=h):Cx=0,kx(0)}}function _F(h,p){(h.pooledCacheLanes&=p)===0&&(p=h.pooledCache,p!=null&&(h.pooledCache=null,ux(p)))}function Ev(){return bF(),yF(),vF(),wF()}function wF(){if(Si!==5)return!1;var h=ku,p=FE;FE=0;var _=wt(hc),N=Y.T,j=q.p;try{q.p=32>_?32:_,Y.T=null,_=UE,UE=null;var I=ku,ee=hc;if(Si=0,vm=ku=null,hc=0,(Hn&6)!==0)throw Error(r(331));var me=Hn;if(Hn|=4,rF(I.current),eF(I,I.current,ee,_),Hn=me,kx(0,!1),he&&typeof he.onPostCommitFiberRoot=="function")try{he.onPostCommitFiberRoot(We,I)}catch{}return!0}finally{q.p=j,Y.T=N,_F(h,p)}}function SF(h,p,_){p=Xs(_,p),p=bE(h.stateNode,p,2),h=Su(h,p,2),h!==null&&(Zt(h,2),ml(h))}function Qn(h,p,_){if(h.tag===3)SF(h,h,_);else for(;p!==null;){if(p.tag===3){SF(p,h,_);break}else if(p.tag===1){var N=p.stateNode;if(typeof p.type.getDerivedStateFromError=="function"||typeof N.componentDidCatch=="function"&&(Cu===null||!Cu.has(N))){h=Xs(_,h),_=M5(2),N=Su(p,_,2),N!==null&&(N5(_,N,p,h),Zt(N,2),ml(N));break}}p=p.return}}function HE(h,p,_){var N=h.pingCache;if(N===null){N=h.pingCache=new Aie;var j=new Set;N.set(p,j)}else j=N.get(p),j===void 0&&(j=new Set,N.set(p,j));j.has(_)||(OE=!0,j.add(_),h=Pie.bind(null,h,p,_),p.then(h,h))}function Pie(h,p,_){var N=h.pingCache;N!==null&&N.delete(p),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,fr===h&&(jn&_)===_&&(Gr===4||Gr===3&&(jn&62914560)===jn&&300>O()-vv?(Hn&2)===0&&_m(h,0):LE|=_,ym===jn&&(ym=0)),ml(h)}function MF(h,p){p===0&&(p=kt()),h=oh(h,p),h!==null&&(Zt(h,p),ml(h))}function Rie(h){var p=h.memoizedState,_=0;p!==null&&(_=p.retryLane),MF(h,_)}function Die(h,p){var _=0;switch(h.tag){case 31:case 13:var N=h.stateNode,j=h.memoizedState;j!==null&&(_=j.retryLane);break;case 19:N=h.stateNode;break;case 22:N=h.stateNode._retryCache;break;default:throw Error(r(314))}N!==null&&N.delete(p),MF(h,_)}function Oie(h,p){return Ee(h,p)}var Av=null,Sm=null,VE=!1,Tv=!1,GE=!1,Pu=0;function ml(h){h!==Sm&&h.next===null&&(Sm===null?Av=Sm=h:Sm=Sm.next=h),Tv=!0,VE||(VE=!0,Iie())}function kx(h,p){if(!GE&&Tv){GE=!0;do for(var _=!1,N=Av;N!==null;){if(h!==0){var j=N.pendingLanes;if(j===0)var I=0;else{var ee=N.suspendedLanes,me=N.pingedLanes;I=(1<<31-qe(42|h)+1)-1,I&=j&~(ee&~me),I=I&201326741?I&201326741|1:I?I|2:0}I!==0&&(_=!0,TF(N,I))}else I=jn,I=ve(N,N===fr?I:0,N.cancelPendingCommit!==null||N.timeoutHandle!==-1),(I&3)===0||He(N,I)||(_=!0,TF(N,I));N=N.next}while(_);GE=!1}}function Lie(){NF()}function NF(){Tv=VE=!1;var h=0;Pu!==0&&qie()&&(h=Pu);for(var p=O(),_=null,N=Av;N!==null;){var j=N.next,I=EF(N,p);I===0?(N.next=null,_===null?Av=j:_.next=j,j===null&&(Sm=_)):(_=N,(h!==0||(I&3)!==0)&&(Tv=!0)),N=j}Si!==0&&Si!==5||kx(h),Pu!==0&&(Pu=0)}function EF(h,p){for(var _=h.suspendedLanes,N=h.pingedLanes,j=h.expirationTimes,I=h.pendingLanes&-62914561;0<I;){var ee=31-qe(I),me=1<<ee,Pe=j[ee];Pe===-1?((me&_)===0||(me&N)!==0)&&(j[ee]=dt(me,p)):Pe<=p&&(h.expiredLanes|=me),I&=~me}if(p=fr,_=jn,_=ve(h,h===p?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),N=h.callbackNode,_===0||h===p&&(Yn===2||Yn===9)||h.cancelPendingCommit!==null)return N!==null&&N!==null&&Ce(N),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||He(h,_)){if(p=_&-_,p===h.callbackPriority)return p;switch(N!==null&&Ce(N),wt(_)){case 2:case 8:_=_e;break;case 32:_=le;break;case 268435456:_=Oe;break;default:_=le}return N=AF.bind(null,h),_=Ee(_,N),h.callbackPriority=p,h.callbackNode=_,p}return N!==null&&N!==null&&Ce(N),h.callbackPriority=2,h.callbackNode=null,2}function AF(h,p){if(Si!==0&&Si!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(Ev()&&h.callbackNode!==_)return null;var N=jn;return N=ve(h,h===fr?N:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),N===0?null:(lF(h,N,p),EF(h,O()),h.callbackNode!=null&&h.callbackNode===_?AF.bind(null,h):null)}function TF(h,p){if(Ev())return null;lF(h,p,!0)}function Iie(){Xie(function(){(Hn&6)!==0?Ee(ye,Lie):NF()})}function WE(){if(Pu===0){var h=lm;h===0&&(h=$e,$e<<=1,($e&261888)===0&&($e=256)),Pu=h}return Pu}function CF(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:Ly(""+h)}function kF(h,p){var _=p.ownerDocument.createElement("input");return _.name=p.name,_.value=p.value,h.id&&_.setAttribute("form",h.id),p.parentNode.insertBefore(_,p),h=new FormData(h),_.parentNode.removeChild(_),h}function Fie(h,p,_,N,j){if(p==="submit"&&_&&_.stateNode===j){var I=CF((j[yt]||null).action),ee=N.submitter;ee&&(p=(p=ee[yt]||null)?CF(p.formAction):ee.getAttribute("formAction"),p!==null&&(I=p,ee=null));var me=new zy("action","action",null,N,j);h.push({event:me,listeners:[{instance:null,listener:function(){if(N.defaultPrevented){if(Pu!==0){var Pe=ee?kF(j,ee):new FormData(j);hE(_,{pending:!0,data:Pe,method:j.method,action:I},null,Pe)}}else typeof I=="function"&&(me.preventDefault(),Pe=ee?kF(j,ee):new FormData(j),hE(_,{pending:!0,data:Pe,method:j.method,action:I},I,Pe))},currentTarget:j}]})}}for(var qE=0;qE<CN.length;qE++){var KE=CN[qE],Uie=KE.toLowerCase(),zie=KE[0].toUpperCase()+KE.slice(1);Ro(Uie,"on"+zie)}Ro(oI,"onAnimationEnd"),Ro(lI,"onAnimationIteration"),Ro(cI,"onAnimationStart"),Ro("dblclick","onDoubleClick"),Ro("focusin","onFocus"),Ro("focusout","onBlur"),Ro(nie,"onTransitionRun"),Ro(rie,"onTransitionStart"),Ro(iie,"onTransitionCancel"),Ro(uI,"onTransitionEnd"),Tt("onMouseEnter",["mouseout","mouseover"]),Tt("onMouseLeave",["mouseout","mouseover"]),Tt("onPointerEnter",["pointerout","pointerover"]),Tt("onPointerLeave",["pointerout","pointerover"]),_t("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),_t("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),_t("onBeforeInput",["compositionend","keypress","textInput","paste"]),_t("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),_t("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),_t("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var jx="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(" "),Bie=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(jx));function jF(h,p){p=(p&4)!==0;for(var _=0;_<h.length;_++){var N=h[_],j=N.event;N=N.listeners;e:{var I=void 0;if(p)for(var ee=N.length-1;0<=ee;ee--){var me=N[ee],Pe=me.instance,nt=me.currentTarget;if(me=me.listener,Pe!==I&&j.isPropagationStopped())break e;I=me,j.currentTarget=nt;try{I(j)}catch(gt){Hy(gt)}j.currentTarget=null,I=Pe}else for(ee=0;ee<N.length;ee++){if(me=N[ee],Pe=me.instance,nt=me.currentTarget,me=me.listener,Pe!==I&&j.isPropagationStopped())break e;I=me,j.currentTarget=nt;try{I(j)}catch(gt){Hy(gt)}j.currentTarget=null,I=Pe}}}}function En(h,p){var _=p[wn];_===void 0&&(_=p[wn]=new Set);var N=h+"__bubble";_.has(N)||(PF(p,h,2,!1),_.add(N))}function XE(h,p,_){var N=0;p&&(N|=4),PF(_,h,N,p)}var Cv="_reactListening"+Math.random().toString(36).slice(2);function YE(h){if(!h[Cv]){h[Cv]=!0,Re.forEach(function(_){_!=="selectionchange"&&(Bie.has(_)||XE(_,!1,h),XE(_,!0,h))});var p=h.nodeType===9?h:h.ownerDocument;p===null||p[Cv]||(p[Cv]=!0,XE("selectionchange",!1,p))}}function PF(h,p,_,N){switch(oU(p)){case 2:var j=pae;break;case 8:j=gae;break;default:j=dA}_=j.bind(null,p,_,h),j=void 0,!gN||p!=="touchstart"&&p!=="touchmove"&&p!=="wheel"||(j=!0),N?j!==void 0?h.addEventListener(p,_,{capture:!0,passive:j}):h.addEventListener(p,_,!0):j!==void 0?h.addEventListener(p,_,{passive:j}):h.addEventListener(p,_,!1)}function QE(h,p,_,N,j){var I=N;if((p&1)===0&&(p&2)===0&&N!==null)e:for(;;){if(N===null)return;var ee=N.tag;if(ee===3||ee===4){var me=N.stateNode.containerInfo;if(me===j)break;if(ee===4)for(ee=N.return;ee!==null;){var Pe=ee.tag;if((Pe===3||Pe===4)&&ee.stateNode.containerInfo===j)return;ee=ee.return}for(;me!==null;){if(ee=At(me),ee===null)return;if(Pe=ee.tag,Pe===5||Pe===6||Pe===26||Pe===27){N=I=ee;continue e}me=me.parentNode}}N=N.return}IL(function(){var nt=I,gt=mN(_),bt=[];e:{var it=dI.get(h);if(it!==void 0){var lt=zy,Bt=h;switch(h){case"keypress":if(Fy(_)===0)break e;case"keydown":case"keyup":lt=Dre;break;case"focusin":Bt="focus",lt=vN;break;case"focusout":Bt="blur",lt=vN;break;case"beforeblur":case"afterblur":lt=vN;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":lt=zL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":lt=wre;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":lt=Ire;break;case oI:case lI:case cI:lt=Nre;break;case uI:lt=Ure;break;case"scroll":case"scrollend":lt=vre;break;case"wheel":lt=Bre;break;case"copy":case"cut":case"paste":lt=Are;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":lt=$L;break;case"toggle":case"beforetoggle":lt=Hre}var Jt=(p&4)!==0,ir=!Jt&&(h==="scroll"||h==="scrollend"),Ge=Jt?it!==null?it+"Capture":null:it;Jt=[];for(var Ue=nt,tt;Ue!==null;){var xt=Ue;if(tt=xt.stateNode,xt=xt.tag,xt!==5&&xt!==26&&xt!==27||tt===null||Ge===null||(xt=Jg(Ue,Ge),xt!=null&&Jt.push(Px(Ue,xt,tt))),ir)break;Ue=Ue.return}0<Jt.length&&(it=new lt(it,Bt,null,_,gt),bt.push({event:it,listeners:Jt}))}}if((p&7)===0){e:{if(it=h==="mouseover"||h==="pointerover",lt=h==="mouseout"||h==="pointerout",it&&_!==fN&&(Bt=_.relatedTarget||_.fromElement)&&(At(Bt)||Bt[en]))break e;if((lt||it)&&(it=gt.window===gt?gt:(it=gt.ownerDocument)?it.defaultView||it.parentWindow:window,lt?(Bt=_.relatedTarget||_.toElement,lt=nt,Bt=Bt?At(Bt):null,Bt!==null&&(ir=a(Bt),Jt=Bt.tag,Bt!==ir||Jt!==5&&Jt!==27&&Jt!==6)&&(Bt=null)):(lt=null,Bt=nt),lt!==Bt)){if(Jt=zL,xt="onMouseLeave",Ge="onMouseEnter",Ue="mouse",(h==="pointerout"||h==="pointerover")&&(Jt=$L,xt="onPointerLeave",Ge="onPointerEnter",Ue="pointer"),ir=lt==null?it:we(lt),tt=Bt==null?it:we(Bt),it=new Jt(xt,Ue+"leave",lt,_,gt),it.target=ir,it.relatedTarget=tt,xt=null,At(gt)===nt&&(Jt=new Jt(Ge,Ue+"enter",Bt,_,gt),Jt.target=tt,Jt.relatedTarget=ir,xt=Jt),ir=xt,lt&&Bt)t:{for(Jt=$ie,Ge=lt,Ue=Bt,tt=0,xt=Ge;xt;xt=Jt(xt))tt++;xt=0;for(var Kt=Ue;Kt;Kt=Jt(Kt))xt++;for(;0<tt-xt;)Ge=Jt(Ge),tt--;for(;0<xt-tt;)Ue=Jt(Ue),xt--;for(;tt--;){if(Ge===Ue||Ue!==null&&Ge===Ue.alternate){Jt=Ge;break t}Ge=Jt(Ge),Ue=Jt(Ue)}Jt=null}else Jt=null;lt!==null&&RF(bt,it,lt,Jt,!1),Bt!==null&&ir!==null&&RF(bt,ir,Bt,Jt,!0)}}e:{if(it=nt?we(nt):window,lt=it.nodeName&&it.nodeName.toLowerCase(),lt==="select"||lt==="input"&&it.type==="file")var Fn=YL;else if(KL(it))if(QL)Fn=Jre;else{Fn=Qre;var Vt=Yre}else lt=it.nodeName,!lt||lt.toLowerCase()!=="input"||it.type!=="checkbox"&&it.type!=="radio"?nt&&hN(nt.elementType)&&(Fn=YL):Fn=Zre;if(Fn&&(Fn=Fn(h,nt))){XL(bt,Fn,_,gt);break e}Vt&&Vt(h,it,nt),h==="focusout"&&nt&&it.type==="number"&&nt.memoizedProps.value!=null&&Ii(it,"number",it.value)}switch(Vt=nt?we(nt):window,h){case"focusin":(KL(Vt)||Vt.contentEditable==="true")&&(em=Vt,EN=nt,ox=null);break;case"focusout":ox=EN=em=null;break;case"mousedown":AN=!0;break;case"contextmenu":case"mouseup":case"dragend":AN=!1,aI(bt,_,gt);break;case"selectionchange":if(tie)break;case"keydown":case"keyup":aI(bt,_,gt)}var pn;if(wN)e:{switch(h){case"compositionstart":var Pn="onCompositionStart";break e;case"compositionend":Pn="onCompositionEnd";break e;case"compositionupdate":Pn="onCompositionUpdate";break e}Pn=void 0}else Jf?WL(h,_)&&(Pn="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(Pn="onCompositionStart");Pn&&(HL&&_.locale!=="ko"&&(Jf||Pn!=="onCompositionStart"?Pn==="onCompositionEnd"&&Jf&&(pn=FL()):(gu=gt,xN="value"in gu?gu.value:gu.textContent,Jf=!0)),Vt=kv(nt,Pn),0<Vt.length&&(Pn=new BL(Pn,h,null,_,gt),bt.push({event:Pn,listeners:Vt}),pn?Pn.data=pn:(pn=qL(_),pn!==null&&(Pn.data=pn)))),(pn=Gre?Wre(h,_):qre(h,_))&&(Pn=kv(nt,"onBeforeInput"),0<Pn.length&&(Vt=new BL("onBeforeInput","beforeinput",null,_,gt),bt.push({event:Vt,listeners:Pn}),Vt.data=pn)),Fie(bt,h,nt,_,gt)}jF(bt,p)})}function Px(h,p,_){return{instance:h,listener:p,currentTarget:_}}function kv(h,p){for(var _=p+"Capture",N=[];h!==null;){var j=h,I=j.stateNode;if(j=j.tag,j!==5&&j!==26&&j!==27||I===null||(j=Jg(h,_),j!=null&&N.unshift(Px(h,j,I)),j=Jg(h,p),j!=null&&N.push(Px(h,j,I))),h.tag===3)return N;h=h.return}return[]}function $ie(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function RF(h,p,_,N,j){for(var I=p._reactName,ee=[];_!==null&&_!==N;){var me=_,Pe=me.alternate,nt=me.stateNode;if(me=me.tag,Pe!==null&&Pe===N)break;me!==5&&me!==26&&me!==27||nt===null||(Pe=nt,j?(nt=Jg(_,I),nt!=null&&ee.unshift(Px(_,nt,Pe))):j||(nt=Jg(_,I),nt!=null&&ee.push(Px(_,nt,Pe)))),_=_.return}ee.length!==0&&h.push({event:p,listeners:ee})}var Hie=/\r\n?/g,Vie=/\u0000|\uFFFD/g;function DF(h){return(typeof h=="string"?h:""+h).replace(Hie,`
- `).replace(Vie,"")}function OF(h,p){return p=DF(p),DF(h)===p}function rr(h,p,_,N,j,I){switch(_){case"children":typeof N=="string"?p==="body"||p==="textarea"&&N===""||ul(h,N):(typeof N=="number"||typeof N=="bigint")&&p!=="body"&&ul(h,""+N);break;case"className":It(h,"class",N);break;case"tabIndex":It(h,"tabindex",N);break;case"dir":case"role":case"viewBox":case"width":case"height":It(h,_,N);break;case"style":OL(h,N,I);break;case"data":if(p!=="object"){It(h,"data",N);break}case"src":case"href":if(N===""&&(p!=="a"||_!=="href")){h.removeAttribute(_);break}if(N==null||typeof N=="function"||typeof N=="symbol"||typeof N=="boolean"){h.removeAttribute(_);break}N=Ly(""+N),h.setAttribute(_,N);break;case"action":case"formAction":if(typeof N=="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"?(p!=="input"&&rr(h,p,"name",j.name,j,null),rr(h,p,"formEncType",j.formEncType,j,null),rr(h,p,"formMethod",j.formMethod,j,null),rr(h,p,"formTarget",j.formTarget,j,null)):(rr(h,p,"encType",j.encType,j,null),rr(h,p,"method",j.method,j,null),rr(h,p,"target",j.target,j,null)));if(N==null||typeof N=="symbol"||typeof N=="boolean"){h.removeAttribute(_);break}N=Ly(""+N),h.setAttribute(_,N);break;case"onClick":N!=null&&(h.onclick=Ql);break;case"onScroll":N!=null&&En("scroll",h);break;case"onScrollEnd":N!=null&&En("scrollend",h);break;case"dangerouslySetInnerHTML":if(N!=null){if(typeof N!="object"||!("__html"in N))throw Error(r(61));if(_=N.__html,_!=null){if(j.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"multiple":h.multiple=N&&typeof N!="function"&&typeof N!="symbol";break;case"muted":h.muted=N&&typeof N!="function"&&typeof N!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(N==null||typeof N=="function"||typeof N=="boolean"||typeof N=="symbol"){h.removeAttribute("xlink:href");break}_=Ly(""+N),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":N!=null&&typeof N!="function"&&typeof N!="symbol"?h.setAttribute(_,""+N):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":N&&typeof N!="function"&&typeof N!="symbol"?h.setAttribute(_,""):h.removeAttribute(_);break;case"capture":case"download":N===!0?h.setAttribute(_,""):N!==!1&&N!=null&&typeof N!="function"&&typeof N!="symbol"?h.setAttribute(_,N):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":N!=null&&typeof N!="function"&&typeof N!="symbol"&&!isNaN(N)&&1<=N?h.setAttribute(_,N):h.removeAttribute(_);break;case"rowSpan":case"start":N==null||typeof N=="function"||typeof N=="symbol"||isNaN(N)?h.removeAttribute(_):h.setAttribute(_,N);break;case"popover":En("beforetoggle",h),En("toggle",h),Ht(h,"popover",N);break;case"xlinkActuate":on(h,"http://www.w3.org/1999/xlink","xlink:actuate",N);break;case"xlinkArcrole":on(h,"http://www.w3.org/1999/xlink","xlink:arcrole",N);break;case"xlinkRole":on(h,"http://www.w3.org/1999/xlink","xlink:role",N);break;case"xlinkShow":on(h,"http://www.w3.org/1999/xlink","xlink:show",N);break;case"xlinkTitle":on(h,"http://www.w3.org/1999/xlink","xlink:title",N);break;case"xlinkType":on(h,"http://www.w3.org/1999/xlink","xlink:type",N);break;case"xmlBase":on(h,"http://www.w3.org/XML/1998/namespace","xml:base",N);break;case"xmlLang":on(h,"http://www.w3.org/XML/1998/namespace","xml:lang",N);break;case"xmlSpace":on(h,"http://www.w3.org/XML/1998/namespace","xml:space",N);break;case"is":Ht(h,"is",N);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=bre.get(_)||_,Ht(h,_,N))}}function ZE(h,p,_,N,j,I){switch(_){case"style":OL(h,N,I);break;case"dangerouslySetInnerHTML":if(N!=null){if(typeof N!="object"||!("__html"in N))throw Error(r(61));if(_=N.__html,_!=null){if(j.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof N=="string"?ul(h,N):(typeof N=="number"||typeof N=="bigint")&&ul(h,""+N);break;case"onScroll":N!=null&&En("scroll",h);break;case"onScrollEnd":N!=null&&En("scrollend",h);break;case"onClick":N!=null&&(h.onclick=Ql);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ut.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(j=_.endsWith("Capture"),p=_.slice(2,j?_.length-7:void 0),I=h[yt]||null,I=I!=null?I[_]:null,typeof I=="function"&&h.removeEventListener(p,I,j),typeof N=="function")){typeof I!="function"&&I!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(p,N,j);break e}_ in h?h[_]=N:N===!0?h.setAttribute(_,""):Ht(h,_,N)}}}function sa(h,p,_){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":En("error",h),En("load",h);var N=!1,j=!1,I;for(I in _)if(_.hasOwnProperty(I)){var ee=_[I];if(ee!=null)switch(I){case"src":N=!0;break;case"srcSet":j=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:rr(h,p,I,ee,_,null)}}j&&rr(h,p,"srcSet",_.srcSet,_,null),N&&rr(h,p,"src",_.src,_,null);return;case"input":En("invalid",h);var me=I=ee=j=null,Pe=null,nt=null;for(N in _)if(_.hasOwnProperty(N)){var gt=_[N];if(gt!=null)switch(N){case"name":j=gt;break;case"type":ee=gt;break;case"checked":Pe=gt;break;case"defaultChecked":nt=gt;break;case"value":I=gt;break;case"defaultValue":me=gt;break;case"children":case"dangerouslySetInnerHTML":if(gt!=null)throw Error(r(137,p));break;default:rr(h,p,N,gt,_,null)}}Xn(h,I,me,Pe,nt,ee,j,!1);return;case"select":En("invalid",h),N=ee=I=null;for(j in _)if(_.hasOwnProperty(j)&&(me=_[j],me!=null))switch(j){case"value":I=me;break;case"defaultValue":ee=me;break;case"multiple":N=me;default:rr(h,p,j,me,_,null)}p=I,_=ee,h.multiple=!!N,p!=null?wi(h,!!N,p,!1):_!=null&&wi(h,!!N,_,!0);return;case"textarea":En("invalid",h),I=j=N=null;for(ee in _)if(_.hasOwnProperty(ee)&&(me=_[ee],me!=null))switch(ee){case"value":N=me;break;case"defaultValue":j=me;break;case"children":I=me;break;case"dangerouslySetInnerHTML":if(me!=null)throw Error(r(91));break;default:rr(h,p,ee,me,_,null)}na(h,N,j,I);return;case"option":for(Pe in _)if(_.hasOwnProperty(Pe)&&(N=_[Pe],N!=null))switch(Pe){case"selected":h.selected=N&&typeof N!="function"&&typeof N!="symbol";break;default:rr(h,p,Pe,N,_,null)}return;case"dialog":En("beforetoggle",h),En("toggle",h),En("cancel",h),En("close",h);break;case"iframe":case"object":En("load",h);break;case"video":case"audio":for(N=0;N<jx.length;N++)En(jx[N],h);break;case"image":En("error",h),En("load",h);break;case"details":En("toggle",h);break;case"embed":case"source":case"link":En("error",h),En("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(nt in _)if(_.hasOwnProperty(nt)&&(N=_[nt],N!=null))switch(nt){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:rr(h,p,nt,N,_,null)}return;default:if(hN(p)){for(gt in _)_.hasOwnProperty(gt)&&(N=_[gt],N!==void 0&&ZE(h,p,gt,N,_,void 0));return}}for(me in _)_.hasOwnProperty(me)&&(N=_[me],N!=null&&rr(h,p,me,N,_,null))}function Gie(h,p,_,N){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var j=null,I=null,ee=null,me=null,Pe=null,nt=null,gt=null;for(lt in _){var bt=_[lt];if(_.hasOwnProperty(lt)&&bt!=null)switch(lt){case"checked":break;case"value":break;case"defaultValue":Pe=bt;default:N.hasOwnProperty(lt)||rr(h,p,lt,null,N,bt)}}for(var it in N){var lt=N[it];if(bt=_[it],N.hasOwnProperty(it)&&(lt!=null||bt!=null))switch(it){case"type":I=lt;break;case"name":j=lt;break;case"checked":nt=lt;break;case"defaultChecked":gt=lt;break;case"value":ee=lt;break;case"defaultValue":me=lt;break;case"children":case"dangerouslySetInnerHTML":if(lt!=null)throw Error(r(137,p));break;default:lt!==bt&&rr(h,p,it,lt,N,bt)}}Po(h,ee,me,Pe,nt,gt,I,j);return;case"select":lt=ee=me=it=null;for(I in _)if(Pe=_[I],_.hasOwnProperty(I)&&Pe!=null)switch(I){case"value":break;case"multiple":lt=Pe;default:N.hasOwnProperty(I)||rr(h,p,I,null,N,Pe)}for(j in N)if(I=N[j],Pe=_[j],N.hasOwnProperty(j)&&(I!=null||Pe!=null))switch(j){case"value":it=I;break;case"defaultValue":me=I;break;case"multiple":ee=I;default:I!==Pe&&rr(h,p,j,I,N,Pe)}p=me,_=ee,N=lt,it!=null?wi(h,!!_,it,!1):!!N!=!!_&&(p!=null?wi(h,!!_,p,!0):wi(h,!!_,_?[]:"",!1));return;case"textarea":lt=it=null;for(me in _)if(j=_[me],_.hasOwnProperty(me)&&j!=null&&!N.hasOwnProperty(me))switch(me){case"value":break;case"children":break;default:rr(h,p,me,null,N,j)}for(ee in N)if(j=N[ee],I=_[ee],N.hasOwnProperty(ee)&&(j!=null||I!=null))switch(ee){case"value":it=j;break;case"defaultValue":lt=j;break;case"children":break;case"dangerouslySetInnerHTML":if(j!=null)throw Error(r(91));break;default:j!==I&&rr(h,p,ee,j,N,I)}Fi(h,it,lt);return;case"option":for(var Bt in _)if(it=_[Bt],_.hasOwnProperty(Bt)&&it!=null&&!N.hasOwnProperty(Bt))switch(Bt){case"selected":h.selected=!1;break;default:rr(h,p,Bt,null,N,it)}for(Pe in N)if(it=N[Pe],lt=_[Pe],N.hasOwnProperty(Pe)&&it!==lt&&(it!=null||lt!=null))switch(Pe){case"selected":h.selected=it&&typeof it!="function"&&typeof it!="symbol";break;default:rr(h,p,Pe,it,N,lt)}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 Jt in _)it=_[Jt],_.hasOwnProperty(Jt)&&it!=null&&!N.hasOwnProperty(Jt)&&rr(h,p,Jt,null,N,it);for(nt in N)if(it=N[nt],lt=_[nt],N.hasOwnProperty(nt)&&it!==lt&&(it!=null||lt!=null))switch(nt){case"children":case"dangerouslySetInnerHTML":if(it!=null)throw Error(r(137,p));break;default:rr(h,p,nt,it,N,lt)}return;default:if(hN(p)){for(var ir in _)it=_[ir],_.hasOwnProperty(ir)&&it!==void 0&&!N.hasOwnProperty(ir)&&ZE(h,p,ir,void 0,N,it);for(gt in N)it=N[gt],lt=_[gt],!N.hasOwnProperty(gt)||it===lt||it===void 0&<===void 0||ZE(h,p,gt,it,N,lt);return}}for(var Ge in _)it=_[Ge],_.hasOwnProperty(Ge)&&it!=null&&!N.hasOwnProperty(Ge)&&rr(h,p,Ge,null,N,it);for(bt in N)it=N[bt],lt=_[bt],!N.hasOwnProperty(bt)||it===lt||it==null&<==null||rr(h,p,bt,it,N,lt)}function LF(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Wie(){if(typeof performance.getEntriesByType=="function"){for(var h=0,p=0,_=performance.getEntriesByType("resource"),N=0;N<_.length;N++){var j=_[N],I=j.transferSize,ee=j.initiatorType,me=j.duration;if(I&&me&&LF(ee)){for(ee=0,me=j.responseEnd,N+=1;N<_.length;N++){var Pe=_[N],nt=Pe.startTime;if(nt>me)break;var gt=Pe.transferSize,bt=Pe.initiatorType;gt&&LF(bt)&&(Pe=Pe.responseEnd,ee+=gt*(Pe<me?1:(me-nt)/(Pe-nt)))}if(--N,p+=8*(I+ee)/(j.duration/1e3),h++,10<h)break}}if(0<h)return p/h/1e6}return navigator.connection&&(h=navigator.connection.downlink,typeof h=="number")?h:5}var JE=null,eA=null;function jv(h){return h.nodeType===9?h:h.ownerDocument}function IF(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 FF(h,p){if(h===0)switch(p){case"svg":return 1;case"math":return 2;default:return 0}return h===1&&p==="foreignObject"?0:h}function tA(h,p){return h==="textarea"||h==="noscript"||typeof p.children=="string"||typeof p.children=="number"||typeof p.children=="bigint"||typeof p.dangerouslySetInnerHTML=="object"&&p.dangerouslySetInnerHTML!==null&&p.dangerouslySetInnerHTML.__html!=null}var nA=null;function qie(){var h=window.event;return h&&h.type==="popstate"?h===nA?!1:(nA=h,!0):(nA=null,!1)}var UF=typeof setTimeout=="function"?setTimeout:void 0,Kie=typeof clearTimeout=="function"?clearTimeout:void 0,zF=typeof Promise=="function"?Promise:void 0,Xie=typeof queueMicrotask=="function"?queueMicrotask:typeof zF<"u"?function(h){return zF.resolve(null).then(h).catch(Yie)}:UF;function Yie(h){setTimeout(function(){throw h})}function Ru(h){return h==="head"}function BF(h,p){var _=p,N=0;do{var j=_.nextSibling;if(h.removeChild(_),j&&j.nodeType===8)if(_=j.data,_==="/$"||_==="/&"){if(N===0){h.removeChild(j),Am(p);return}N--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")N++;else if(_==="html")Rx(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,Rx(_);for(var I=_.firstChild;I;){var ee=I.nextSibling,me=I.nodeName;I[Xe]||me==="SCRIPT"||me==="STYLE"||me==="LINK"&&I.rel.toLowerCase()==="stylesheet"||_.removeChild(I),I=ee}}else _==="body"&&Rx(h.ownerDocument.body);_=j}while(_);Am(p)}function $F(h,p){var _=h;h=0;do{var N=_.nextSibling;if(_.nodeType===1?p?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(p?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),N&&N.nodeType===8)if(_=N.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=N}while(_)}function rA(h){var p=h.firstChild;for(p&&p.nodeType===10&&(p=p.nextSibling);p;){var _=p;switch(p=p.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":rA(_),Qe(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function Qie(h,p,_,N){for(;h.nodeType===1;){var j=_;if(h.nodeName.toLowerCase()!==p.toLowerCase()){if(!N&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(N){if(!h[Xe])switch(p){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!==j.rel||h.getAttribute("href")!==(j.href==null||j.href===""?null:j.href)||h.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin)||h.getAttribute("title")!==(j.title==null?null:j.title))break;return h;case"style":if(h.hasAttribute("data-precedence"))break;return h;case"script":if(I=h.getAttribute("src"),(I!==(j.src==null?null:j.src)||h.getAttribute("type")!==(j.type==null?null:j.type)||h.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin))&&I&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(p==="input"&&h.type==="hidden"){var I=j.name==null?null:""+j.name;if(j.type==="hidden"&&h.getAttribute("name")===I)return h}else return h;if(h=eo(h.nextSibling),h===null)break}return null}function Zie(h,p,_){if(p==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=eo(h.nextSibling),h===null))return null;return h}function HF(h,p){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!p||(h=eo(h.nextSibling),h===null))return null;return h}function iA(h){return h.data==="$?"||h.data==="$~"}function aA(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function Jie(h,p){var _=h.ownerDocument;if(h.data==="$~")h._reactRetry=p;else if(h.data!=="$?"||_.readyState!=="loading")p();else{var N=function(){p(),_.removeEventListener("DOMContentLoaded",N)};_.addEventListener("DOMContentLoaded",N),h._reactRetry=N}}function eo(h){for(;h!=null;h=h.nextSibling){var p=h.nodeType;if(p===1||p===3)break;if(p===8){if(p=h.data,p==="$"||p==="$!"||p==="$?"||p==="$~"||p==="&"||p==="F!"||p==="F")break;if(p==="/$"||p==="/&")return null}}return h}var sA=null;function VF(h){h=h.nextSibling;for(var p=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(p===0)return eo(h.nextSibling);p--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||p++}h=h.nextSibling}return null}function GF(h){h=h.previousSibling;for(var p=0;h;){if(h.nodeType===8){var _=h.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(p===0)return h;p--}else _!=="/$"&&_!=="/&"||p++}h=h.previousSibling}return null}function WF(h,p,_){switch(p=jv(_),h){case"html":if(h=p.documentElement,!h)throw Error(r(452));return h;case"head":if(h=p.head,!h)throw Error(r(453));return h;case"body":if(h=p.body,!h)throw Error(r(454));return h;default:throw Error(r(451))}}function Rx(h){for(var p=h.attributes;p.length;)h.removeAttributeNode(p[0]);Qe(h)}var to=new Map,qF=new Set;function Pv(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var fc=q.d;q.d={f:eae,r:tae,D:nae,C:rae,L:iae,m:aae,X:oae,S:sae,M:lae};function eae(){var h=fc.f(),p=Sv();return h||p}function tae(h){var p=ce(h);p!==null&&p.tag===5&&p.type==="form"?u5(p):fc.r(h)}var Mm=typeof document>"u"?null:document;function KF(h,p,_){var N=Mm;if(N&&typeof p=="string"&&p){var j=Wn(p);j='link[rel="'+h+'"][href="'+j+'"]',typeof _=="string"&&(j+='[crossorigin="'+_+'"]'),qF.has(j)||(qF.add(j),h={rel:h,crossOrigin:_,href:p},N.querySelector(j)===null&&(p=N.createElement("link"),sa(p,"link",h),Le(p),N.head.appendChild(p)))}}function nae(h){fc.D(h),KF("dns-prefetch",h,null)}function rae(h,p){fc.C(h,p),KF("preconnect",h,p)}function iae(h,p,_){fc.L(h,p,_);var N=Mm;if(N&&h&&p){var j='link[rel="preload"][as="'+Wn(p)+'"]';p==="image"&&_&&_.imageSrcSet?(j+='[imagesrcset="'+Wn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(j+='[imagesizes="'+Wn(_.imageSizes)+'"]')):j+='[href="'+Wn(h)+'"]';var I=j;switch(p){case"style":I=Nm(h);break;case"script":I=Em(h)}to.has(I)||(h=f({rel:"preload",href:p==="image"&&_&&_.imageSrcSet?void 0:h,as:p},_),to.set(I,h),N.querySelector(j)!==null||p==="style"&&N.querySelector(Dx(I))||p==="script"&&N.querySelector(Ox(I))||(p=N.createElement("link"),sa(p,"link",h),Le(p),N.head.appendChild(p)))}}function aae(h,p){fc.m(h,p);var _=Mm;if(_&&h){var N=p&&typeof p.as=="string"?p.as:"script",j='link[rel="modulepreload"][as="'+Wn(N)+'"][href="'+Wn(h)+'"]',I=j;switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":I=Em(h)}if(!to.has(I)&&(h=f({rel:"modulepreload",href:h},p),to.set(I,h),_.querySelector(j)===null)){switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Ox(I)))return}N=_.createElement("link"),sa(N,"link",h),Le(N),_.head.appendChild(N)}}}function sae(h,p,_){fc.S(h,p,_);var N=Mm;if(N&&h){var j=Ie(N).hoistableStyles,I=Nm(h);p=p||"default";var ee=j.get(I);if(!ee){var me={loading:0,preload:null};if(ee=N.querySelector(Dx(I)))me.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":p},_),(_=to.get(I))&&oA(h,_);var Pe=ee=N.createElement("link");Le(Pe),sa(Pe,"link",h),Pe._p=new Promise(function(nt,gt){Pe.onload=nt,Pe.onerror=gt}),Pe.addEventListener("load",function(){me.loading|=1}),Pe.addEventListener("error",function(){me.loading|=2}),me.loading|=4,Rv(ee,p,N)}ee={type:"stylesheet",instance:ee,count:1,state:me},j.set(I,ee)}}}function oae(h,p){fc.X(h,p);var _=Mm;if(_&&h){var N=Ie(_).hoistableScripts,j=Em(h),I=N.get(j);I||(I=_.querySelector(Ox(j)),I||(h=f({src:h,async:!0},p),(p=to.get(j))&&lA(h,p),I=_.createElement("script"),Le(I),sa(I,"link",h),_.head.appendChild(I)),I={type:"script",instance:I,count:1,state:null},N.set(j,I))}}function lae(h,p){fc.M(h,p);var _=Mm;if(_&&h){var N=Ie(_).hoistableScripts,j=Em(h),I=N.get(j);I||(I=_.querySelector(Ox(j)),I||(h=f({src:h,async:!0,type:"module"},p),(p=to.get(j))&&lA(h,p),I=_.createElement("script"),Le(I),sa(I,"link",h),_.head.appendChild(I)),I={type:"script",instance:I,count:1,state:null},N.set(j,I))}}function XF(h,p,_,N){var j=(j=de.current)?Pv(j):null;if(!j)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(p=Nm(_.href),_=Ie(j).hoistableStyles,N=_.get(p),N||(N={type:"style",instance:null,count:0,state:null},_.set(p,N)),N):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=Nm(_.href);var I=Ie(j).hoistableStyles,ee=I.get(h);if(ee||(j=j.ownerDocument||j,ee={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},I.set(h,ee),(I=j.querySelector(Dx(h)))&&!I._p&&(ee.instance=I,ee.state.loading=5),to.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},to.set(h,_),I||cae(j,h,_,ee.state))),p&&N===null)throw Error(r(528,""));return ee}if(p&&N!==null)throw Error(r(529,""));return null;case"script":return p=_.async,_=_.src,typeof _=="string"&&p&&typeof p!="function"&&typeof p!="symbol"?(p=Em(_),_=Ie(j).hoistableScripts,N=_.get(p),N||(N={type:"script",instance:null,count:0,state:null},_.set(p,N)),N):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function Nm(h){return'href="'+Wn(h)+'"'}function Dx(h){return'link[rel="stylesheet"]['+h+"]"}function YF(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function cae(h,p,_,N){h.querySelector('link[rel="preload"][as="style"]['+p+"]")?N.loading=1:(p=h.createElement("link"),N.preload=p,p.addEventListener("load",function(){return N.loading|=1}),p.addEventListener("error",function(){return N.loading|=2}),sa(p,"link",_),Le(p),h.head.appendChild(p))}function Em(h){return'[src="'+Wn(h)+'"]'}function Ox(h){return"script[async]"+h}function QF(h,p,_){if(p.count++,p.instance===null)switch(p.type){case"style":var N=h.querySelector('style[data-href~="'+Wn(_.href)+'"]');if(N)return p.instance=N,Le(N),N;var j=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return N=(h.ownerDocument||h).createElement("style"),Le(N),sa(N,"style",j),Rv(N,_.precedence,h),p.instance=N;case"stylesheet":j=Nm(_.href);var I=h.querySelector(Dx(j));if(I)return p.state.loading|=4,p.instance=I,Le(I),I;N=YF(_),(j=to.get(j))&&oA(N,j),I=(h.ownerDocument||h).createElement("link"),Le(I);var ee=I;return ee._p=new Promise(function(me,Pe){ee.onload=me,ee.onerror=Pe}),sa(I,"link",N),p.state.loading|=4,Rv(I,_.precedence,h),p.instance=I;case"script":return I=Em(_.src),(j=h.querySelector(Ox(I)))?(p.instance=j,Le(j),j):(N=_,(j=to.get(I))&&(N=f({},_),lA(N,j)),h=h.ownerDocument||h,j=h.createElement("script"),Le(j),sa(j,"link",N),h.head.appendChild(j),p.instance=j);case"void":return null;default:throw Error(r(443,p.type))}else p.type==="stylesheet"&&(p.state.loading&4)===0&&(N=p.instance,p.state.loading|=4,Rv(N,_.precedence,h));return p.instance}function Rv(h,p,_){for(var N=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),j=N.length?N[N.length-1]:null,I=j,ee=0;ee<N.length;ee++){var me=N[ee];if(me.dataset.precedence===p)I=me;else if(I!==j)break}I?I.parentNode.insertBefore(h,I.nextSibling):(p=_.nodeType===9?_.head:_,p.insertBefore(h,p.firstChild))}function oA(h,p){h.crossOrigin==null&&(h.crossOrigin=p.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=p.referrerPolicy),h.title==null&&(h.title=p.title)}function lA(h,p){h.crossOrigin==null&&(h.crossOrigin=p.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=p.referrerPolicy),h.integrity==null&&(h.integrity=p.integrity)}var Dv=null;function ZF(h,p,_){if(Dv===null){var N=new Map,j=Dv=new Map;j.set(_,N)}else j=Dv,N=j.get(_),N||(N=new Map,j.set(_,N));if(N.has(h))return N;for(N.set(h,null),_=_.getElementsByTagName(h),j=0;j<_.length;j++){var I=_[j];if(!(I[Xe]||I[hr]||h==="link"&&I.getAttribute("rel")==="stylesheet")&&I.namespaceURI!=="http://www.w3.org/2000/svg"){var ee=I.getAttribute(p)||"";ee=h+ee;var me=N.get(ee);me?me.push(I):N.set(ee,[I])}}return N}function JF(h,p,_){h=h.ownerDocument||h,h.head.insertBefore(_,p==="title"?h.querySelector("head > title"):null)}function uae(h,p,_){if(_===1||p.itemProp!=null)return!1;switch(h){case"meta":case"title":return!0;case"style":if(typeof p.precedence!="string"||typeof p.href!="string"||p.href==="")break;return!0;case"link":if(typeof p.rel!="string"||typeof p.href!="string"||p.href===""||p.onLoad||p.onError)break;switch(p.rel){case"stylesheet":return h=p.disabled,typeof p.precedence=="string"&&h==null;default:return!0}case"script":if(p.async&&typeof p.async!="function"&&typeof p.async!="symbol"&&!p.onLoad&&!p.onError&&p.src&&typeof p.src=="string")return!0}return!1}function eU(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function dae(h,p,_,N){if(_.type==="stylesheet"&&(typeof N.media!="string"||matchMedia(N.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var j=Nm(N.href),I=p.querySelector(Dx(j));if(I){p=I._p,p!==null&&typeof p=="object"&&typeof p.then=="function"&&(h.count++,h=Ov.bind(h),p.then(h,h)),_.state.loading|=4,_.instance=I,Le(I);return}I=p.ownerDocument||p,N=YF(N),(j=to.get(j))&&oA(N,j),I=I.createElement("link"),Le(I);var ee=I;ee._p=new Promise(function(me,Pe){ee.onload=me,ee.onerror=Pe}),sa(I,"link",N),_.instance=I}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,p),(p=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=Ov.bind(h),p.addEventListener("load",_),p.addEventListener("error",_))}}var cA=0;function hae(h,p){return h.stylesheets&&h.count===0&&Iv(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var N=setTimeout(function(){if(h.stylesheets&&Iv(h,h.stylesheets),h.unsuspend){var I=h.unsuspend;h.unsuspend=null,I()}},6e4+p);0<h.imgBytes&&cA===0&&(cA=62500*Wie());var j=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&Iv(h,h.stylesheets),h.unsuspend)){var I=h.unsuspend;h.unsuspend=null,I()}},(h.imgBytes>cA?50:800)+p);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(N),clearTimeout(j)}}:null}function Ov(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Iv(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var Lv=null;function Iv(h,p){h.stylesheets=null,h.unsuspend!==null&&(h.count++,Lv=new Map,p.forEach(fae,h),Lv=null,Ov.call(h))}function fae(h,p){if(!(p.state.loading&4)){var _=Lv.get(h);if(_)var N=_.get(null);else{_=new Map,Lv.set(h,_);for(var j=h.querySelectorAll("link[data-precedence],style[data-precedence]"),I=0;I<j.length;I++){var ee=j[I];(ee.nodeName==="LINK"||ee.getAttribute("media")!=="not all")&&(_.set(ee.dataset.precedence,ee),N=ee)}N&&_.set(null,N)}j=p.instance,ee=j.getAttribute("data-precedence"),I=_.get(ee)||N,I===N&&_.set(null,j),_.set(ee,j),this.count++,N=Ov.bind(this),j.addEventListener("load",N),j.addEventListener("error",N),I?I.parentNode.insertBefore(j,I.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(j,h.firstChild)),p.state.loading|=4}}var Lx={$$typeof:S,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function mae(h,p,_,N,j,I,ee,me,Pe){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=jt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=jt(0),this.hiddenUpdates=jt(null),this.identifierPrefix=N,this.onUncaughtError=j,this.onCaughtError=I,this.onRecoverableError=ee,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Pe,this.incompleteTransitions=new Map}function tU(h,p,_,N,j,I,ee,me,Pe,nt,gt,bt){return h=new mae(h,p,_,ee,Pe,nt,gt,bt,me),p=1,I===!0&&(p|=24),I=Ss(3,null,null,p),h.current=I,I.stateNode=h,p=$N(),p.refCount++,h.pooledCache=p,p.refCount++,I.memoizedState={element:N,isDehydrated:_,cache:p},WN(I),h}function nU(h){return h?(h=rm,h):rm}function rU(h,p,_,N,j,I){j=nU(j),N.context===null?N.context=j:N.pendingContext=j,N=wu(p),N.payload={element:_},I=I===void 0?null:I,I!==null&&(N.callback=I),_=Su(h,N,p),_!==null&&(rs(_,h,p),mx(_,h,p))}function iU(h,p){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<p?_:p}}function uA(h,p){iU(h,p),(h=h.alternate)&&iU(h,p)}function aU(h){if(h.tag===13||h.tag===31){var p=oh(h,67108864);p!==null&&rs(p,h,67108864),uA(h,67108864)}}function sU(h){if(h.tag===13||h.tag===31){var p=Ts();p=qt(p);var _=oh(h,p);_!==null&&rs(_,h,p),uA(h,p)}}var Fv=!0;function pae(h,p,_,N){var j=Y.T;Y.T=null;var I=q.p;try{q.p=2,dA(h,p,_,N)}finally{q.p=I,Y.T=j}}function gae(h,p,_,N){var j=Y.T;Y.T=null;var I=q.p;try{q.p=8,dA(h,p,_,N)}finally{q.p=I,Y.T=j}}function dA(h,p,_,N){if(Fv){var j=hA(N);if(j===null)QE(h,p,N,Uv,_),lU(h,N);else if(bae(j,h,p,_,N))N.stopPropagation();else if(lU(h,N),p&4&&-1<xae.indexOf(h)){for(;j!==null;){var I=ce(j);if(I!==null)switch(I.tag){case 3:if(I=I.stateNode,I.current.memoizedState.isDehydrated){var ee=De(I.pendingLanes);if(ee!==0){var me=I;for(me.pendingLanes|=2,me.entangledLanes|=2;ee;){var Pe=1<<31-qe(ee);me.entanglements[1]|=Pe,ee&=~Pe}ml(I),(Hn&6)===0&&(_v=O()+500,kx(0))}}break;case 31:case 13:me=oh(I,2),me!==null&&rs(me,I,2),Sv(),uA(I,2)}if(I=hA(N),I===null&&QE(h,p,N,Uv,_),I===j)break;j=I}j!==null&&N.stopPropagation()}else QE(h,p,N,null,_)}}function hA(h){return h=mN(h),fA(h)}var Uv=null;function fA(h){if(Uv=null,h=At(h),h!==null){var p=a(h);if(p===null)h=null;else{var _=p.tag;if(_===13){if(h=o(p),h!==null)return h;h=null}else if(_===31){if(h=l(p),h!==null)return h;h=null}else if(_===3){if(p.stateNode.current.memoizedState.isDehydrated)return p.tag===3?p.stateNode.containerInfo:null;h=null}else p!==h&&(h=null)}}return Uv=h,null}function oU(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(ie()){case ye:return 2;case _e:return 8;case le:case ke:return 32;case Oe:return 268435456;default:return 32}default:return 32}}var mA=!1,Du=null,Ou=null,Lu=null,Ix=new Map,Fx=new Map,Iu=[],xae="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 lU(h,p){switch(h){case"focusin":case"focusout":Du=null;break;case"dragenter":case"dragleave":Ou=null;break;case"mouseover":case"mouseout":Lu=null;break;case"pointerover":case"pointerout":Ix.delete(p.pointerId);break;case"gotpointercapture":case"lostpointercapture":Fx.delete(p.pointerId)}}function Ux(h,p,_,N,j,I){return h===null||h.nativeEvent!==I?(h={blockedOn:p,domEventName:_,eventSystemFlags:N,nativeEvent:I,targetContainers:[j]},p!==null&&(p=ce(p),p!==null&&aU(p)),h):(h.eventSystemFlags|=N,p=h.targetContainers,j!==null&&p.indexOf(j)===-1&&p.push(j),h)}function bae(h,p,_,N,j){switch(p){case"focusin":return Du=Ux(Du,h,p,_,N,j),!0;case"dragenter":return Ou=Ux(Ou,h,p,_,N,j),!0;case"mouseover":return Lu=Ux(Lu,h,p,_,N,j),!0;case"pointerover":var I=j.pointerId;return Ix.set(I,Ux(Ix.get(I)||null,h,p,_,N,j)),!0;case"gotpointercapture":return I=j.pointerId,Fx.set(I,Ux(Fx.get(I)||null,h,p,_,N,j)),!0}return!1}function cU(h){var p=At(h.target);if(p!==null){var _=a(p);if(_!==null){if(p=_.tag,p===13){if(p=o(_),p!==null){h.blockedOn=p,$r(h.priority,function(){sU(_)});return}}else if(p===31){if(p=l(_),p!==null){h.blockedOn=p,$r(h.priority,function(){sU(_)});return}}else if(p===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function zv(h){if(h.blockedOn!==null)return!1;for(var p=h.targetContainers;0<p.length;){var _=hA(h.nativeEvent);if(_===null){_=h.nativeEvent;var N=new _.constructor(_.type,_);fN=N,_.target.dispatchEvent(N),fN=null}else return p=ce(_),p!==null&&aU(p),h.blockedOn=_,!1;p.shift()}return!0}function uU(h,p,_){zv(h)&&_.delete(p)}function yae(){mA=!1,Du!==null&&zv(Du)&&(Du=null),Ou!==null&&zv(Ou)&&(Ou=null),Lu!==null&&zv(Lu)&&(Lu=null),Ix.forEach(uU),Fx.forEach(uU)}function Bv(h,p){h.blockedOn===p&&(h.blockedOn=null,mA||(mA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,yae)))}var $v=null;function dU(h){$v!==h&&($v=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){$v===h&&($v=null);for(var p=0;p<h.length;p+=3){var _=h[p],N=h[p+1],j=h[p+2];if(typeof N!="function"){if(fA(N||_)===null)continue;break}var I=ce(_);I!==null&&(h.splice(p,3),p-=3,hE(I,{pending:!0,data:j,method:_.method,action:N},N,j))}}))}function Am(h){function p(Pe){return Bv(Pe,h)}Du!==null&&Bv(Du,h),Ou!==null&&Bv(Ou,h),Lu!==null&&Bv(Lu,h),Ix.forEach(p),Fx.forEach(p);for(var _=0;_<Iu.length;_++){var N=Iu[_];N.blockedOn===h&&(N.blockedOn=null)}for(;0<Iu.length&&(_=Iu[0],_.blockedOn===null);)cU(_),_.blockedOn===null&&Iu.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(N=0;N<_.length;N+=3){var j=_[N],I=_[N+1],ee=j[yt]||null;if(typeof I=="function")ee||dU(_);else if(ee){var me=null;if(I&&I.hasAttribute("formAction")){if(j=I,ee=I[yt]||null)me=ee.formAction;else if(fA(j)!==null)continue}else me=ee.action;typeof me=="function"?_[N+1]=me:(_.splice(N,3),N-=3),dU(_)}}}function hU(){function h(I){I.canIntercept&&I.info==="react-transition"&&I.intercept({handler:function(){return new Promise(function(ee){return j=ee})},focusReset:"manual",scroll:"manual"})}function p(){j!==null&&(j(),j=null),N||setTimeout(_,20)}function _(){if(!N&&!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 N=!1,j=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",p),navigation.addEventListener("navigateerror",p),setTimeout(_,100),function(){N=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",p),navigation.removeEventListener("navigateerror",p),j!==null&&(j(),j=null)}}}function pA(h){this._internalRoot=h}Hv.prototype.render=pA.prototype.render=function(h){var p=this._internalRoot;if(p===null)throw Error(r(409));var _=p.current,N=Ts();rU(_,N,h,p,null,null)},Hv.prototype.unmount=pA.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var p=h.containerInfo;rU(h.current,2,null,h,null,null),Sv(),p[en]=null}};function Hv(h){this._internalRoot=h}Hv.prototype.unstable_scheduleHydration=function(h){if(h){var p=_r();h={blockedOn:null,target:h,priority:p};for(var _=0;_<Iu.length&&p!==0&&p<Iu[_].priority;_++);Iu.splice(_,0,h),_===0&&cU(h)}};var fU=e.version;if(fU!=="19.2.0")throw Error(r(527,fU,"19.2.0"));q.findDOMNode=function(h){var p=h._reactInternals;if(p===void 0)throw typeof h.render=="function"?Error(r(188)):(h=Object.keys(h).join(","),Error(r(268,h)));return h=u(p),h=h!==null?d(h):null,h=h===null?null:h.stateNode,h};var vae={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:Y,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Vv=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Vv.isDisabled&&Vv.supportsFiber)try{We=Vv.inject(vae),he=Vv}catch{}}return Bx.createRoot=function(h,p){if(!i(h))throw Error(r(299));var _=!1,N="",j=v5,I=_5,ee=w5;return p!=null&&(p.unstable_strictMode===!0&&(_=!0),p.identifierPrefix!==void 0&&(N=p.identifierPrefix),p.onUncaughtError!==void 0&&(j=p.onUncaughtError),p.onCaughtError!==void 0&&(I=p.onCaughtError),p.onRecoverableError!==void 0&&(ee=p.onRecoverableError)),p=tU(h,1,!1,null,null,_,N,null,j,I,ee,hU),h[en]=p.current,YE(h),new pA(p)},Bx.hydrateRoot=function(h,p,_){if(!i(h))throw Error(r(299));var N=!1,j="",I=v5,ee=_5,me=w5,Pe=null;return _!=null&&(_.unstable_strictMode===!0&&(N=!0),_.identifierPrefix!==void 0&&(j=_.identifierPrefix),_.onUncaughtError!==void 0&&(I=_.onUncaughtError),_.onCaughtError!==void 0&&(ee=_.onCaughtError),_.onRecoverableError!==void 0&&(me=_.onRecoverableError),_.formState!==void 0&&(Pe=_.formState)),p=tU(h,1,!0,p,_??null,N,j,Pe,I,ee,me,hU),p.context=nU(null),_=p.current,N=Ts(),N=qt(N),j=wu(N),j.callback=null,Su(_,j,N),_=N,p.current.lanes=_,Zt(p,_),ml(p),h[en]=p.current,YE(h),new Hv(p)},Bx.version="19.2.0",Bx}var SU;function jae(){if(SU)return bA.exports;SU=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(),bA.exports=kae(),bA.exports}var Pae=jae();const rn=t=>typeof t=="string",$x=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},MU=t=>t==null?"":""+t,Rae=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Dae=/###/g,NU=t=>t&&t.indexOf("###")>-1?t.replace(Dae,"."):t,EU=t=>!t||rn(t),kb=(t,e,n)=>{const r=rn(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(EU(t))return{};const a=NU(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return EU(t)?{}:{obj:t,k:NU(r[i])}},AU=(t,e,n)=>{const{obj:r,k:i}=kb(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=kb(t,o,Object);for(;l.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),l=kb(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},Oae=(t,e,n,r)=>{const{obj:i,k:a}=kb(t,e,Object);i[a]=i[a]||[],i[a].push(n)},rw=(t,e)=>{const{obj:n,k:r}=kb(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Lae=(t,e,n)=>{const r=rw(t,n);return r!==void 0?r:rw(e,n)},ZG=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?rn(t[r])||t[r]instanceof String||rn(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):ZG(t[r],e[r],n):t[r]=e[r]);return t},Tm=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Iae={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Fae=t=>rn(t)?t.replace(/[&<>"'\/]/g,e=>Iae[e]):t;class Uae{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 zae=[" ",",","?","!",";"],Bae=new Uae(20),$ae=(t,e,n)=>{e=e||"",n=n||"";const r=zae.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=Bae.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},Sj=(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},e0=t=>t?.replace("_","-"),Hae={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 iw{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Hae,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:(rn(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new iw(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new iw(this.logger,e)}}var El=new iw;let w2=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 TU extends w2{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):rn(r)&&a?l.push(...r.split(a)):l.push(r)));const c=rw(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!rn(r)?c:Sj(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),AU(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)(rn(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=rw(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?ZG(c,r,a):c={...c,...r},AU(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 JG={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 eW=Symbol("i18next/PATH_KEY");function Vae(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===eW?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function Mj(t,e){const{[eW]:n}=t(Vae());return n.join(e?.keySeparator??".")}const CU={},wA=t=>!rn(t)&&typeof t!="boolean"&&typeof t!="number";class aw extends w2{constructor(e,n={}){super(),Rae(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=El.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=wA(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&&!$ae(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:rn(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:rn(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=Mj(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 g=this.resolve(e,i);let x=g?.res;const y=g?.usedKey||l,b=g?.exactUsedKey||l,v=["[object Number]","[object Function]","[object RegExp]"],M=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,S=!this.i18nFormat||this.i18nFormat.handleAsObject,A=i.count!==void 0&&!rn(i.count),E=aw.hasDefaultValue(i),k=A?this.pluralResolver.getSuffix(f,i.count,i):"",C=i.ordinal&&A?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",R=A&&!i.ordinal&&i.count===0,T=R&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${k}`]||i[`defaultValue${C}`]||i.defaultValue;let P=x;S&&!x&&E&&(P=T);const F=wA(P),L=Object.prototype.toString.apply(P);if(S&&P&&F&&v.indexOf(L)<0&&!(rn(M)&&Array.isArray(P))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const X=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,P,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(g.res=X,g.usedParams=this.getUsedParamsDetails(i),g):X}if(o){const X=Array.isArray(P),D=X?[]:{},K=X?b:y;for(const Y in P)if(Object.prototype.hasOwnProperty.call(P,Y)){const q=`${K}${o}${Y}`;E&&!x?D[Y]=this.translate(q,{...i,defaultValue:wA(T)?T[Y]:void 0,joinArrays:!1,ns:c}):D[Y]=this.translate(q,{...i,joinArrays:!1,ns:c}),D[Y]===q&&(D[Y]=P[Y])}x=D}}else if(S&&rn(M)&&Array.isArray(x))x=x.join(M),x&&(x=this.extendTranslation(x,e,i,r));else{let X=!1,D=!1;!this.isValidLookup(x)&&E&&(X=!0,x=T),this.isValidLookup(x)||(D=!0,x=l);const Y=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&D?void 0:x,q=E&&T!==x&&this.options.updateMissing;if(D||X||q){if(this.logger.log(q?"updateKey":"missingKey",f,u,l,q?T:x),o){const B=this.resolve(l,{...i,keySeparator:!1});B&&B.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let Z=[];const re=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&re&&re[0])for(let B=0;B<re.length;B++)Z.push(re[B]);else this.options.saveMissingTo==="all"?Z=this.languageUtils.toResolveHierarchy(i.lng||this.language):Z.push(i.lng||this.language);const oe=(B,G,J)=>{const te=E&&J!==x?J:Y;this.options.missingKeyHandler?this.options.missingKeyHandler(B,u,G,te,q,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(B,u,G,te,q,i),this.emit("missingKey",B,u,G,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?Z.forEach(B=>{const G=this.pluralResolver.getSuffixes(B,i);R&&i[`defaultValue${this.options.pluralSeparator}zero`]&&G.indexOf(`${this.options.pluralSeparator}zero`)<0&&G.push(`${this.options.pluralSeparator}zero`),G.forEach(J=>{oe([B],l+J,i[`defaultValue${J}`]||T)})}):oe(Z,l,T))}x=this.extendTranslation(x,e,i,g,r),D&&x===l&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${l}`),(D||X)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,X?x:void 0,i))}return a?(g.res=x,g.usedParams=this.getUsedParamsDetails(i),g):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=rn(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&&!rn(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=rn(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=JG.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 rn(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&&!rn(n.count),g=m&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(rn(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,!CU[`${y[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(CU[`${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 M=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(M,d,v,b,n);else{let A;m&&(A=this.pluralResolver.getSuffix(v,n.count,n));const E=`${this.options.pluralSeparator}zero`,k=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(n.ordinal&&A.indexOf(k)===0&&M.push(d+A.replace(k,this.options.pluralSeparator)),M.push(d+A),g&&M.push(d+E)),x){const C=`${d}${this.options.contextSeparator||"_"}${n.context}`;M.push(C),m&&(n.ordinal&&A.indexOf(k)===0&&M.push(C+A.replace(k,this.options.pluralSeparator)),M.push(C+A),g&&M.push(C+E))}}let S;for(;S=M.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&&!rn(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 kU{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=El.create("languageUtils")}getScriptPartFromCode(e){if(e=e0(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=e0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(rn(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)),rn(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 rn(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))):rn(e)&&a(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&a(this.formatLanguageCode(o))}),i}}const jU={zero:0,one:1,two:2,few:3,many:4,other:5},PU={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Gae{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=El.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=e0(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!"),PU;if(!e.match(/-|_/))return PU;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)=>jU[i]-jU[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 RU=(t,e,n,r=".",i=!0)=>{let a=Lae(t,e,n);return!a&&i&&rn(n)&&(a=Sj(t,n,r),a===void 0&&(a=Sj(e,n,r))),a},SA=t=>t.replace(/\$/g,"$$$$");class Wae{constructor(e={}){this.logger=El.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:g,nestingSuffix:x,nestingSuffixEscaped:y,nestingOptionsSeparator:b,maxReplaces:v,alwaysFormat:M}=e.interpolation;this.escape=n!==void 0?n:Fae,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?Tm(a):o||"{{",this.suffix=l?Tm(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=m?Tm(m):g||Tm("$t("),this.nestingSuffix=x?Tm(x):y||Tm(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=v||1e3,this.alwaysFormat=M!==void 0?M:!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=g=>{if(g.indexOf(this.formatSeparator)<0){const v=RU(n,c,g,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,r,{...i,...n,interpolationkey:g}):v}const x=g.split(this.formatSeparator),y=x.shift().trim(),b=x.join(this.formatSeparator).trim();return this.format(RU(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:g=>SA(g)},{regex:this.regexp,safeValue:g=>this.escapeValue?SA(this.escape(g)):SA(g)}].forEach(g=>{for(l=0;a=g.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=rn(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!rn(o)&&!this.useRawValueToEscape&&(o=MU(o));const y=g.safeValue(o);if(e=e.replace(a[0],y),f?(g.regex.lastIndex+=o.length,g.regex.lastIndex-=a[0].length):g.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 g=m.match(/'/g),x=m.match(/"/g);((g?.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&&!rn(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&&!rn(a))return a;rn(a)||(a=MU(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 qae=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}},DU=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(e0(r),i),e[o]=l),l(n)}},Kae=t=>(e,n,r)=>t(e0(n),r)(e);class Xae{constructor(e={}){this.logger=El.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?DU:Kae;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()]=DU(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}=qae(c);if(this.formats[u]){let f=l;try{const m=i?.formatParams?.[i.interpolationkey]||{},g=m.locale||m.lng||i.locale||i.lng||r;f=this.formats[u](l,g,{...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 Yae=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Qae extends w2{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=El.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=>{Oae(c.loaded,[a],o),Yae(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();rn(e)&&(e=this.languageUtils.toResolveHierarchy(e)),rn(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 OU=()=>({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]),rn(t[1])&&(e.defaultValue=t[1]),rn(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}),LU=t=>(rn(t.ns)&&(t.ns=[t.ns]),rn(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),rn(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),Wv=()=>{},Zae=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class jb extends w2{constructor(e={},n){if(super(),this.options=LU(e),this.services={},this.logger=El,this.modules={external:[]},Zae(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&&(rn(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=OU();this.options={...r,...this.options,...LU(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?El.init(i(this.modules.logger),this.options):El.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Xae;const d=new kU(this.options);this.store=new TU(this.options.resources,this.options);const f=this.services;f.logger=El,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new Gae(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 Wae(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Qae(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(g,...x)=>{this.emit(g,...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 aw(this.services,this.options),this.translator.on("*",(g,...x)=>{this.emit(g,...x)}),this.modules.external.forEach(g=>{g.init&&g.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Wv),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=$x(),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=Wv){let r=n;const i=rn(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=$x();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=Wv),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"&&JG.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=$x();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=rn(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(rn(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=Mj(f,{...this.options,...o})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=Mj(a,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(d,c)};return rn(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=$x();return this.options.ns?(rn(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=$x();rn(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 kU(OU());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 jb(e,n);return r.createInstance=jb.createInstance,r}cloneInstance(e={},n=Wv){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new jb(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 TU(l,i),a.services.resourceStore=a.store}return a.translator=new aw(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 Qa=jb.createInstance();Qa.createInstance;Qa.dir;Qa.init;Qa.loadResources;Qa.reloadResources;Qa.use;Qa.changeLanguage;Qa.getFixedT;Qa.t;Qa.exists;Qa.setDefaultNamespace;Qa.hasLoadedNamespace;Qa.loadNamespaces;Qa.loadLanguages;const Jae=(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);xf(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},IU={},tW=(t,e,n,r)=>{xf(n)&&IU[n]||(xf(n)&&(IU[n]=new Date),Jae(t,e,n,r))},nW=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},Nj=(t,e,n)=>{t.loadNamespaces(e,nW(t,n))},FU=(t,e,n,r)=>{if(xf(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return Nj(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,nW(t,r))},ese=(t,e,n={})=>!e.languages||!e.languages.length?(tW(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}}),xf=t=>typeof t=="string",tse=t=>typeof t=="object"&&t!==null,nse=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,rse={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},ise=t=>rse[t],ase=t=>t.replace(nse,ise);let Ej={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:ase};const sse=(t={})=>{Ej={...Ej,...t}},ose=()=>Ej;let rW;const lse=t=>{rW=t},cse=()=>rW,use={type:"3rdParty",init(t){sse(t.options.react),lse(t)}},dse=w.createContext();class hse{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var MA={exports:{}},NA={};var UU;function fse(){if(UU)return NA;UU=1;var t=Ag();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 g=m(),x=r({inst:{value:g,getSnapshot:m}}),y=x[0].inst,b=x[1];return a(function(){y.value=g,y.getSnapshot=m,c(y)&&b({inst:y})},[f,g,m]),i(function(){return c(y)&&b({inst:y}),f(function(){c(y)&&b({inst:y})})},[f]),o(g),g}function c(f){var m=f.getSnapshot;f=f.value;try{var g=m();return!n(f,g)}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 NA.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,NA}var zU;function iW(){return zU||(zU=1,MA.exports=fse()),MA.exports}var UR=iW();const mse=(t,e)=>xf(e)?e:tse(e)&&xf(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,pse={t:mse,ready:!1},gse=()=>()=>{},Tg=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=w.useContext(dse)||{},a=n||r||cse();a&&!a.reportNamespaces&&(a.reportNamespaces=new hse),a||tW(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=w.useMemo(()=>({...ose(),...a?.options?.react,...e}),[a,e]),{useSuspense:l,keyPrefix:c}=o,u=i||a?.options?.defaultNS,d=xf(u)?[u]:u||["translation"],f=w.useMemo(()=>d,d);a?.reportNamespaces?.addUsedNamespaces?.(f);const m=w.useRef(0),g=w.useCallback(T=>{if(!a)return gse;const{bindI18n:P,bindI18nStore:F}=o,L=()=>{m.current+=1,T()};return P&&a.on(P,L),F&&a.store.on(F,L),()=>{P&&P.split(" ").forEach(X=>a.off(X,L)),F&&F.split(" ").forEach(X=>a.store.off(X,L))}},[a,o]),x=w.useRef(),y=w.useCallback(()=>{if(!a)return pse;const T=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(K=>ese(K,a,o)),P=e.lng||a.language,F=m.current,L=x.current;if(L&&L.ready===T&&L.lng===P&&L.keyPrefix===c&&L.revision===F)return L;const D={t:a.getFixedT(P,o.nsMode==="fallback"?f:f[0],c),ready:T,lng:P,keyPrefix:c,revision:F};return x.current=D,D},[a,f,c,o,e.lng]),[b,v]=w.useState(0),{t:M,ready:S}=UR.useSyncExternalStore(g,y,y);w.useEffect(()=>{if(a&&!S&&!l){const T=()=>v(P=>P+1);e.lng?FU(a,e.lng,f,T):Nj(a,f,T)}},[a,e.lng,f,S,l,b]);const A=a||{},E=w.useRef(null),k=w.useRef(),C=T=>{const P=Object.getOwnPropertyDescriptors(T);P.__original&&delete P.__original;const F=Object.create(Object.getPrototypeOf(T),P);if(!Object.prototype.hasOwnProperty.call(F,"__original"))try{Object.defineProperty(F,"__original",{value:T,writable:!1,enumerable:!1,configurable:!1})}catch{}return F},R=w.useMemo(()=>{const T=A,P=T?.language;let F=T;T&&(E.current&&E.current.__original===T?k.current!==P?(F=C(T),E.current=F,k.current=P):F=E.current:(F=C(T),E.current=F,k.current=P));const L=[M,F,S];return L.t=M,L.i18n=F,L.ready=S,L},[M,A,S,A.resolvedLanguage,A.language,A.languages]);if(a&&l&&!S)throw new Promise(T=>{const P=()=>T();e.lng?FU(a,e.lng,f,P):Nj(a,f,P)});return R},{slice:xse,forEach:bse}=[];function yse(t){return bse.call(xse.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function vse(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 BU=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,_se=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(!BU.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!BU.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},$U={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=_se(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 wse={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return $U.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&$U.create(n,t,r,i,a)}},Sse={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}},Mse={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 Cm=null;const HU=()=>{if(Cm!==null)return Cm;try{if(Cm=typeof window<"u"&&window.localStorage!==null,!Cm)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Cm=!1}return Cm};var Nse={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&HU())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&HU()&&window.localStorage.setItem(n,t)}};let km=null;const VU=()=>{if(km!==null)return km;try{if(km=typeof window<"u"&&window.sessionStorage!==null,!km)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{km=!1}return km};var Ese={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&VU())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&VU()&&window.sessionStorage.setItem(n,t)}},Ase={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}},Tse={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}},Cse={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}},kse={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 aW=!1;try{document.cookie,aW=!0}catch{}const sW=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];aW||sW.splice(1,1);const jse=()=>({order:sW,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class oW{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(e,n)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=e,this.options=yse(n,this.options||{},jse()),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(wse),this.addDetector(Sse),this.addDetector(Nse),this.addDetector(Ese),this.addDetector(Ase),this.addDetector(Tse),this.addDetector(Cse),this.addDetector(kse),this.addDetector(Mse)}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&&!vse(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)}))}}oW.type="languageDetector";const Pse={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",telemetry:"Anonymous telemetry",telemetryDescription:"Help improve BamBuddy by sending anonymous usage data",telemetryLearnMore:"Learn more",telemetryInfoTitle:"What data is collected?",telemetryInfoIntro:"BamBuddy collects minimal anonymous data to help understand how many people use the app, which versions and printer models are in use. This helps prioritize bug fixes and new features.",telemetryInfoCollected:"What we collect:",telemetryInfoItem1:"A random installation ID (not linked to you or your hardware)",telemetryInfoItem2:"The app version you're running",telemetryInfoItem3:"Printer model types (e.g., X1C, P1S) - not names or serial numbers",telemetryInfoItem4:"A timestamp (to count daily/weekly active users)",telemetryInfoNotCollected:"What we do NOT collect:",telemetryInfoNotItem1:"Your IP address is hashed and cannot be reversed",telemetryInfoNotItem2:"Printer names, serial numbers, or access codes",telemetryInfoNotItem3:"Print history, filenames, or any personal content",telemetryInfoNotItem4:"Any information that could identify you",telemetryInfoFooter:"You can disable telemetry at any time. The installation ID is randomly generated and cannot be traced back to you.",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?"}},Rse={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",telemetry:"Anonyme Telemetrie",telemetryDescription:"Helfen Sie BamBuddy zu verbessern, indem Sie anonyme Nutzungsdaten senden",telemetryLearnMore:"Mehr erfahren",telemetryInfoTitle:"Welche Daten werden gesammelt?",telemetryInfoIntro:"BamBuddy sammelt minimale anonyme Daten, um zu verstehen, wie viele Personen die App nutzen und welche Versionen verwendet werden. Dies hilft bei der Priorisierung von Fehlerbehebungen und neuen Funktionen.",telemetryInfoCollected:"Was wir sammeln:",telemetryInfoItem1:"Eine zufällige Installations-ID (nicht mit Ihnen oder Ihrer Hardware verknüpft)",telemetryInfoItem2:"Die App-Version, die Sie verwenden",telemetryInfoItem3:"Ein Zeitstempel (um tägliche/wöchentliche aktive Nutzer zu zählen)",telemetryInfoNotCollected:"Was wir NICHT sammeln:",telemetryInfoNotItem1:"IP-Adressen oder Standortdaten",telemetryInfoNotItem2:"Druckernamen, Seriennummern oder Druckerdaten",telemetryInfoNotItem3:"Druckverlauf, Dateinamen oder persönliche Inhalte",telemetryInfoNotItem4:"Informationen, die Sie identifizieren könnten",telemetryInfoFooter:"Sie können die Telemetrie jederzeit deaktivieren. Die Installations-ID wird zufällig generiert und kann nicht zu Ihnen zurückverfolgt werden.",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?"}},Dse={en:{translation:Pse},de:{translation:Rse}};Qa.use(oW).use(use).init({resources:Dse,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const GU=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var WU="popstate";function Ose(t={}){function e(r,i){let{pathname:a,search:o,hash:l}=r.location;return Aj("",{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:t0(i)}return Ise(e,n,null,t)}function Rr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Vs(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Lse(){return Math.random().toString(36).substring(2,10)}function qU(t,e){return{usr:t.state,key:t.key,idx:e}}function Aj(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Cg(e):e,state:n,key:e&&e.key||r||Lse()}}function t0({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 Cg(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 Ise(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 M=Aj(y.location,b,v);u=d()+1;let S=qU(M,u),A=y.createHref(M);try{o.pushState(S,"",A)}catch(E){if(E instanceof DOMException&&E.name==="DataCloneError")throw E;i.location.assign(A)}a&&c&&c({action:l,location:y.location,delta:1})}function g(b,v){l="REPLACE";let M=Aj(y.location,b,v);u=d();let S=qU(M,u),A=y.createHref(M);o.replaceState(S,"",A),a&&c&&c({action:l,location:y.location,delta:0})}function x(b){return Fse(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(WU,f),c=b,()=>{i.removeEventListener(WU,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:g,go(b){return o.go(b)}};return y}function Fse(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Rr(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:t0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function lW(t,e,n="/"){return Use(t,e,n,!1)}function Use(t,e,n,r){let i=typeof e=="string"?Cg(e):e,a=Zc(i.pathname||"/",n);if(a==null)return null;let o=cW(t);zse(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=Qse(a);l=Xse(o[c],u,r)}return l}function cW(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;Rr(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=Vc([r,d.relativePath]),m=n.concat(d);o.children&&o.children.length>0&&(Rr(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),cW(o.children,e,m,f,c)),!(o.path==null&&!o.index)&&e.push({path:f,score:qse(f,o.index),routesMeta:m})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))a(o,l);else for(let c of uW(o.path))a(o,l,!0,c)}),e}function uW(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=uW(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 zse(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:Kse(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Bse=/^:[\w-]+$/,$se=3,Hse=2,Vse=1,Gse=10,Wse=-2,KU=t=>t==="*";function qse(t,e){let n=t.split("/"),r=n.length;return n.some(KU)&&(r+=Wse),e&&(r+=Hse),n.filter(i=>!KU(i)).reduce((i,a)=>i+(Bse.test(a)?$se:a===""?Vse:Gse),r)}function Kse(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 Xse(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=sw({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),m=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=sw({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),o.push({params:i,pathname:Vc([a,f.pathname]),pathnameBase:noe(Vc([a,f.pathnameBase])),route:m}),f.pathnameBase!=="/"&&(a=Vc([a,f.pathnameBase]))}return o}function sw(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Yse(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 g=l[m];return f&&!g?u[d]=void 0:u[d]=(g||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:o,pattern:t}}function Yse(t,e=!1,n=!0){Vs(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 Qse(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Vs(!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 Zc(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 Zse=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Jse=t=>Zse.test(t);function eoe(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Cg(t):t,a;if(n)if(Jse(n))a=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Vs(!1,`Pathnames cannot have embedded double slashes - normalizing ${o} -> ${n}`)}n.startsWith("/")?a=XU(n.substring(1),"/"):a=XU(n,e)}else a=e;return{pathname:a,search:roe(r),hash:ioe(i)}}function XU(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 EA(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 toe(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function zR(t){let e=toe(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function BR(t,e,n,r=!1){let i;typeof t=="string"?i=Cg(t):(i={...t},Rr(!i.pathname||!i.pathname.includes("?"),EA("?","pathname","search",i)),Rr(!i.pathname||!i.pathname.includes("#"),EA("#","pathname","hash",i)),Rr(!i.search||!i.search.includes("#"),EA("#","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=eoe(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(a||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Vc=t=>t.join("/").replace(/\/\/+/g,"/"),noe=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),roe=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,ioe=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function aoe(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var dW=["POST","PUT","PATCH","DELETE"];new Set(dW);var soe=["GET",...dW];new Set(soe);var kg=w.createContext(null);kg.displayName="DataRouter";var S2=w.createContext(null);S2.displayName="DataRouterState";w.createContext(!1);var hW=w.createContext({isTransitioning:!1});hW.displayName="ViewTransition";var ooe=w.createContext(new Map);ooe.displayName="Fetchers";var loe=w.createContext(null);loe.displayName="Await";var sl=w.createContext(null);sl.displayName="Navigation";var q0=w.createContext(null);q0.displayName="Location";var ko=w.createContext({outlet:null,matches:[],isDataRoute:!1});ko.displayName="Route";var $R=w.createContext(null);$R.displayName="RouteError";function coe(t,{relative:e}={}){Rr(jg(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=w.useContext(sl),{hash:i,pathname:a,search:o}=K0(t,{relative:e}),l=a;return n!=="/"&&(l=a==="/"?n:Vc([n,a])),r.createHref({pathname:l,search:o,hash:i})}function jg(){return w.useContext(q0)!=null}function Gl(){return Rr(jg(),"useLocation() may be used only in the context of a <Router> component."),w.useContext(q0).location}var fW="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function mW(t){w.useContext(sl).static||w.useLayoutEffect(t)}function ol(){let{isDataRoute:t}=w.useContext(ko);return t?Moe():uoe()}function uoe(){Rr(jg(),"useNavigate() may be used only in the context of a <Router> component.");let t=w.useContext(kg),{basename:e,navigator:n}=w.useContext(sl),{matches:r}=w.useContext(ko),{pathname:i}=Gl(),a=JSON.stringify(zR(r)),o=w.useRef(!1);return mW(()=>{o.current=!0}),w.useCallback((c,u={})=>{if(Vs(o.current,fW),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=BR(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:Vc([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var doe=w.createContext(null);function hoe(t){let e=w.useContext(ko).outlet;return w.useMemo(()=>e&&w.createElement(doe.Provider,{value:t},e),[e,t])}function HR(){let{matches:t}=w.useContext(ko),e=t[t.length-1];return e?e.params:{}}function K0(t,{relative:e}={}){let{matches:n}=w.useContext(ko),{pathname:r}=Gl(),i=JSON.stringify(zR(n));return w.useMemo(()=>BR(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function foe(t,e){return pW(t,e)}function pW(t,e,n,r,i){Rr(jg(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=w.useContext(sl),{matches:o}=w.useContext(ko),l=o[o.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",f=l&&l.route;{let M=f&&f.path||"";gW(u,!f||M.endsWith("*")||M.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${M}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
- Please change the parent <Route path="${M}"> to <Route path="${M==="/"?"*":`${M}/*`}">.`)}let m=Gl(),g;if(e){let M=typeof e=="string"?Cg(e):e;Rr(d==="/"||M.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 "${M.pathname}" was given in the \`location\` prop.`),g=M}else g=m;let x=g.pathname||"/",y=x;if(d!=="/"){let M=d.replace(/^\//,"").split("/");y="/"+x.replace(/^\//,"").split("/").slice(M.length).join("/")}let b=lW(t,{pathname:y});Vs(f||b!=null,`No routes matched location "${g.pathname}${g.search}${g.hash}" `),Vs(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 "${g.pathname}${g.search}${g.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=boe(b&&b.map(M=>Object.assign({},M,{params:Object.assign({},c,M.params),pathname:Vc([d,a.encodeLocation?a.encodeLocation(M.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathname]),pathnameBase:M.pathnameBase==="/"?d:Vc([d,a.encodeLocation?a.encodeLocation(M.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathnameBase])})),o,n,r,i);return e&&v?w.createElement(q0.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...g},navigationType:"POP"}},v):v}function moe(){let t=Soe(),e=aoe(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 poe=w.createElement(moe,null),goe=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(){return this.state.error!==void 0?w.createElement(ko.Provider,{value:this.props.routeContext},w.createElement($R.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function xoe({routeContext:t,match:e,children:n}){let r=w.useContext(kg);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),w.createElement(ko.Provider,{value:t},n)}function boe(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);Rr(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:g}=n,x=f.route.loader&&!m.hasOwnProperty(f.route.id)&&(!g||g[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??{},errorInfo:f})}:void 0;return a.reduceRight((d,f,m)=>{let g,x=!1,y=null,b=null;n&&(g=o&&f.route.id?o[f.route.id]:void 0,y=f.route.errorElement||poe,l&&(c<0&&m===0?(gW("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)),M=()=>{let S;return g?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(xoe,{match:f,routeContext:{outlet:d,matches:v,isDataRoute:n!=null},children:S})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?w.createElement(goe,{location:n.location,revalidation:n.revalidation,component:y,error:g,children:M(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:u}):M()},null)}function VR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function yoe(t){let e=w.useContext(kg);return Rr(e,VR(t)),e}function voe(t){let e=w.useContext(S2);return Rr(e,VR(t)),e}function _oe(t){let e=w.useContext(ko);return Rr(e,VR(t)),e}function GR(t){let e=_oe(t),n=e.matches[e.matches.length-1];return Rr(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function woe(){return GR("useRouteId")}function Soe(){let t=w.useContext($R),e=voe("useRouteError"),n=GR("useRouteError");return t!==void 0?t:e.errors?.[n]}function Moe(){let{router:t}=yoe("useNavigate"),e=GR("useNavigate"),n=w.useRef(!1);return mW(()=>{n.current=!0}),w.useCallback(async(i,a={})=>{Vs(n.current,fW),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var YU={};function gW(t,e,n){!e&&!YU[t]&&(YU[t]=!0,Vs(!1,n))}w.memo(Noe);function Noe({routes:t,future:e,state:n,unstable_onError:r}){return pW(t,void 0,n,r,e)}function ow({to:t,replace:e,state:n,relative:r}){Rr(jg(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=w.useContext(sl);Vs(!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(ko),{pathname:o}=Gl(),l=ol(),c=BR(t,zR(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 Eoe(t){return hoe(t.context)}function $i(t){Rr(!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 Aoe({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1}){Rr(!jg(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let o=t.replace(/^\/*/,"/"),l=w.useMemo(()=>({basename:o,navigator:i,static:a,future:{}}),[o,i,a]);typeof n=="string"&&(n=Cg(n));let{pathname:c="/",search:u="",hash:d="",state:f=null,key:m="default"}=n,g=w.useMemo(()=>{let x=Zc(c,o);return x==null?null:{location:{pathname:x,search:u,hash:d,state:f,key:m},navigationType:r}},[o,c,u,d,f,m,r]);return Vs(g!=null,`<Router basename="${o}"> is not able to match the URL "${c}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),g==null?null:w.createElement(sl.Provider,{value:l},w.createElement(q0.Provider,{children:e,value:g}))}function Toe({children:t,location:e}){return foe(Tj(t),e)}function Tj(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,Tj(r.props.children,a));return}Rr(r.type===$i,`[${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>`),Rr(!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=Tj(r.props.children,a)),n.push(o)}),n}var k1="get",j1="application/x-www-form-urlencoded";function M2(t){return t!=null&&typeof t.tagName=="string"}function Coe(t){return M2(t)&&t.tagName.toLowerCase()==="button"}function koe(t){return M2(t)&&t.tagName.toLowerCase()==="form"}function joe(t){return M2(t)&&t.tagName.toLowerCase()==="input"}function Poe(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Roe(t,e){return t.button===0&&(!e||e==="_self")&&!Poe(t)}function Cj(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 Doe(t,e){let n=Cj(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(a=>{n.append(i,a)})}),n}var qv=null;function Ooe(){if(qv===null)try{new FormData(document.createElement("form"),0),qv=!1}catch{qv=!0}return qv}var Loe=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function AA(t){return t!=null&&!Loe.has(t)?(Vs(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${j1}"`),null):t}function Ioe(t,e){let n,r,i,a,o;if(koe(t)){let l=t.getAttribute("action");r=l?Zc(l,e):null,n=t.getAttribute("method")||k1,i=AA(t.getAttribute("enctype"))||j1,a=new FormData(t)}else if(Coe(t)||joe(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?Zc(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||k1,i=AA(t.getAttribute("formenctype"))||AA(l.getAttribute("enctype"))||j1,a=new FormData(l,t),!Ooe()){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(M2(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=k1,r=null,i=j1,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 WR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Foe(t,e,n){let r=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return r.pathname==="/"?r.pathname=`_root.${n}`:e&&Zc(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function Uoe(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 zoe(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 Boe(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let o=await Uoe(a,n);return o.links?o.links():[]}return[]}));return Goe(r.flat(1).filter(zoe).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function QU(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 $oe(t,e,{includeHydrateFallback:n}={}){return Hoe(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 Hoe(t){return[...new Set(t)]}function Voe(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function Goe(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(Voe(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function xW(){let t=w.useContext(kg);return WR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Woe(){let t=w.useContext(S2);return WR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var qR=w.createContext(void 0);qR.displayName="FrameworkContext";function bW(){let t=w.useContext(qR);return WR(t,"You must render this element inside a <HydratedRouter> element"),t}function qoe(t,e){let n=w.useContext(qR),[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(M=>{o(M.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 g=()=>{i(!0)},x=()=>{i(!1),o(!1)};return n?t!=="intent"?[a,m,{}]:[a,m,{onFocus:Hx(l,g),onBlur:Hx(c,x),onMouseEnter:Hx(u,g),onMouseLeave:Hx(d,x),onTouchStart:Hx(f,g)}]:[!1,m,{}]}function Hx(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Koe({page:t,...e}){let{router:n}=xW(),r=w.useMemo(()=>lW(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?w.createElement(Yoe,{page:t,matches:r,...e}):null}function Xoe(t){let{manifest:e,routeModules:n}=bW(),[r,i]=w.useState([]);return w.useEffect(()=>{let a=!1;return Boe(t,e,n).then(o=>{a||i(o)}),()=>{a=!0}},[t,e,n]),r}function Yoe({page:t,matches:e,...n}){let r=Gl(),{manifest:i,routeModules:a}=bW(),{basename:o}=xW(),{loaderData:l,matches:c}=Woe(),u=w.useMemo(()=>QU(t,e,c,i,r,"data"),[t,e,c,i,r]),d=w.useMemo(()=>QU(t,e,c,i,r,"assets"),[t,e,c,i,r]),f=w.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let x=new Set,y=!1;if(e.forEach(v=>{let M=i.routes[v.route.id];!M||!M.hasLoader||(!u.some(S=>S.route.id===v.route.id)&&v.route.id in l&&a[v.route.id]?.shouldRevalidate||M.hasClientLoader?y=!0:x.add(v.route.id))}),x.size===0)return[];let b=Foe(t,o,"data");return y&&x.size>0&&b.searchParams.set("_routes",e.filter(v=>x.has(v.route.id)).map(v=>v.route.id).join(",")),[b.pathname+b.search]},[o,l,r,i,u,e,t,a]),m=w.useMemo(()=>$oe(d,i),[d,i]),g=Xoe(d);return w.createElement(w.Fragment,null,f.map(x=>w.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),m.map(x=>w.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),g.map(({key:x,link:y})=>w.createElement("link",{key:x,nonce:n.nonce,...y})))}function Qoe(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var yW=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{yW&&(window.__reactRouterVersion="7.9.6")}catch{}function Zoe({basename:t,children:e,window:n}){let r=w.useRef();r.current==null&&(r.current=Ose({window:n,v5Compat:!0}));let i=r.current,[a,o]=w.useState({action:i.action,location:i.location}),l=w.useCallback(c=>{w.startTransition(()=>o(c))},[o]);return w.useLayoutEffect(()=>i.listen(l),[i,l]),w.createElement(Aoe,{basename:t,children:e,location:a.location,navigationType:a.action,navigator:i})}var vW=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ls=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,...m},g){let{basename:x}=w.useContext(sl),y=typeof u=="string"&&vW.test(u),b,v=!1;if(typeof u=="string"&&y&&(b=u,yW))try{let T=new URL(window.location.href),P=u.startsWith("//")?new URL(T.protocol+u):new URL(u),F=Zc(P.pathname,x);P.origin===T.origin&&F!=null?u=F+P.search+P.hash:v=!0}catch{Vs(!1,`<Link to="${u}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let M=coe(u,{relative:i}),[S,A,E]=qoe(r,m),k=tle(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:f});function C(T){e&&e(T),T.defaultPrevented||k(T)}let R=w.createElement("a",{...m,...E,href:b||M,onClick:v||a?e:C,ref:Qoe(g,A),target:c,"data-discover":!y&&n==="render"?"true":void 0});return S&&!y?w.createElement(w.Fragment,null,R,w.createElement(Koe,{page:M})):R});ls.displayName="Link";var pb=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=K0(o,{relative:u.relative}),m=Gl(),g=w.useContext(S2),{navigator:x,basename:y}=w.useContext(sl),b=g!=null&&sle(f)&&l===!0,v=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,M=m.pathname,S=g&&g.navigation&&g.navigation.location?g.navigation.location.pathname:null;n||(M=M.toLowerCase(),S=S?S.toLowerCase():null,v=v.toLowerCase()),S&&y&&(S=Zc(S,y)||S);const A=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let E=M===v||!i&&M.startsWith(v)&&M.charAt(A)==="/",k=S!=null&&(S===v||!i&&S.startsWith(v)&&S.charAt(v.length)==="/"),C={isActive:E,isPending:k,isTransitioning:b},R=E?e:void 0,T;typeof r=="function"?T=r(C):T=[r,E?"active":null,k?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let P=typeof a=="function"?a(C):a;return w.createElement(ls,{...u,"aria-current":R,className:T,ref:d,style:P,to:o,viewTransition:l},typeof c=="function"?c(C):c)});pb.displayName="NavLink";var Joe=w.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:o=k1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,...m},g)=>{let x=ile(),y=ale(l,{relative:u}),b=o.toLowerCase()==="get"?"get":"post",v=typeof l=="string"&&vW.test(l),M=S=>{if(c&&c(S),S.defaultPrevented)return;S.preventDefault();let A=S.nativeEvent.submitter,E=A?.getAttribute("formmethod")||o;x(A||S.currentTarget,{fetcherKey:e,method:E,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f})};return w.createElement("form",{ref:g,method:b,action:y,onSubmit:r?c:M,...m,"data-discover":!v&&t==="render"?"true":void 0})});Joe.displayName="Form";function ele(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function _W(t){let e=w.useContext(kg);return Rr(e,ele(t)),e}function tle(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o}={}){let l=ol(),c=Gl(),u=K0(t,{relative:a});return w.useCallback(d=>{if(Roe(d,e)){d.preventDefault();let f=n!==void 0?n:t0(c)===t0(u);l(t,{replace:f,state:r,preventScrollReset:i,relative:a,viewTransition:o})}},[c,l,u,n,r,e,t,i,a,o])}function wW(t){Vs(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(Cj(t)),n=w.useRef(!1),r=Gl(),i=w.useMemo(()=>Doe(r.search,n.current?null:e.current),[r.search]),a=ol(),o=w.useCallback((l,c)=>{const u=Cj(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,a("?"+u,c)},[a,i]);return[i,o]}var nle=0,rle=()=>`__${String(++nle)}__`;function ile(){let{router:t}=_W("useSubmit"),{basename:e}=w.useContext(sl),n=woe();return w.useCallback(async(r,i={})=>{let{action:a,method:o,encType:l,formData:c,body:u}=Ioe(r,e);if(i.navigate===!1){let d=i.fetcherKey||rle();await t.fetch(d,n,i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||o,formEncType:i.encType||l,flushSync:i.flushSync})}else await t.navigate(i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||o,formEncType:i.encType||l,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[t,e,n])}function ale(t,{relative:e}={}){let{basename:n}=w.useContext(sl),r=w.useContext(ko);Rr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...K0(t||".",{relative:e})},o=Gl();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:Vc([n,a.pathname])),t0(a)}function sle(t,{relative:e}={}){let n=w.useContext(hW);Rr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=_W("useViewTransitionState"),i=K0(t,{relative:e});if(!n.isTransitioning)return!1;let a=Zc(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Zc(n.nextLocation.pathname,r)||n.nextLocation.pathname;return sw(i.pathname,o)!=null||sw(i.pathname,a)!=null}var Ic=QG();const ole=Co(Ic);var Hf=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(){}},lle={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},cle=class{#t=lle;#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)}},Vh=new cle;function ule(t){setTimeout(t,0)}var bf=typeof window>"u"||"Deno"in globalThis;function Ta(){}function dle(t,e){return typeof t=="function"?t(e):t}function kj(t){return typeof t=="number"&&t>=0&&t!==1/0}function SW(t,e){return Math.max(t+(e||0)-Date.now(),0)}function _d(t,e){return typeof t=="function"?t(e):t}function uo(t,e){return typeof t=="function"?t(e):t}function ZU(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==KR(o,e.options))return!1}else if(!n0(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 JU(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(yf(e.options.mutationKey)!==yf(a))return!1}else if(!n0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function KR(t,e){return(e?.queryKeyHashFn||yf)(t)}function yf(t){return JSON.stringify(t,(e,n)=>jj(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function n0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>n0(t[n],e[n])):!1}var hle=Object.prototype.hasOwnProperty;function XR(t,e){if(t===e)return t;const n=ez(t)&&ez(e);if(!n&&!(jj(t)&&jj(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:hle.call(t,d))&&c++;continue}if(f===null||m===null||typeof f!="object"||typeof m!="object"){l[d]=m;continue}const g=XR(f,m);l[d]=g,g===f&&c++}return i===o&&c===i?t:l}function r0(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 ez(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function jj(t){if(!tz(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!tz(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function tz(t){return Object.prototype.toString.call(t)==="[object Object]"}function fle(t){return new Promise(e=>{Vh.setTimeout(e,t)})}function Pj(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?XR(t,e):e}function mle(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function ple(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var YR=Symbol();function MW(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===YR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function NW(t,e){return typeof t=="function"?t(...e):!!t}var gle=class extends Hf{#t;#e;#n;constructor(){super(),this.#n=t=>{if(!bf&&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"}},QR=new gle;function Rj(){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 xle=ule;function ble(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=xle;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 Yr=ble(),yle=class extends Hf{#t=!0;#e;#n;constructor(){super(),this.#n=t=>{if(!bf&&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}},lw=new yle;function vle(t){return Math.min(1e3*2**t,3e4)}function EW(t){return(t??"online")==="online"?lw.isOnline():!0}var Dj=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function AW(t){let e=!1,n=0,r;const i=Rj(),a=()=>i.status!=="pending",o=y=>{if(!a()){const b=new Dj(y);m(b),t.onCancel?.(b)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>QR.isFocused()&&(t.networkMode==="always"||lw.isOnline())&&t.canRun(),d=()=>EW(t.networkMode)&&t.canRun(),f=y=>{a()||(r?.(),i.resolve(y))},m=y=>{a()||(r?.(),i.reject(y))},g=()=>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 M=t.retry??(bf?0:3),S=t.retryDelay??vle,A=typeof S=="function"?S(n,v):S,E=M===!0||typeof M=="number"&&n<M||typeof M=="function"&&M(n,v);if(e||!E){m(v);return}n++,t.onFail?.(n,v),fle(A).then(()=>u()?void 0:g()).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():g().then(x),i)}}var TW=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),kj(this.gcTime)&&(this.#t=Vh.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(bf?1/0:300*1e3))}clearGcTimeout(){this.#t&&(Vh.clearTimeout(this.#t),this.#t=void 0)}},_le=class extends TW{#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=rz(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=rz(this.options);e.data!==void 0&&(this.setState(nz(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=Pj(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(Ta).catch(Ta):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(t=>uo(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===YR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>_d(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:!SW(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=MW(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=AW({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof Dj&&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 Dj){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,...CW(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...nz(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#e=t.manual?r:void 0,r;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),Yr.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function CW(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:EW(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function nz(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function rz(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 ZR=class extends Hf{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=Rj(),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),iz(this.#e,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Oj(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Oj(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 uo(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&&!r0(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&az(this.#e,n,this.options,e)&&this.#m(),this.updateResult(),r&&(this.#e!==n||uo(this.options.enabled,this.#e)!==uo(e.enabled,this.#e)||_d(this.options.staleTime,this.#e)!==_d(e.staleTime,this.#e))&&this.#g();const i=this.#x();r&&(this.#e!==n||uo(this.options.enabled,this.#e)!==uo(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 Sle(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(Ta)),e}#g(){this.#v();const t=_d(this.options.staleTime,this.#e);if(bf||this.#i.isStale||!kj(t))return;const n=SW(this.#i.dataUpdatedAt,t)+1;this.#c=Vh.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,!(bf||uo(this.options.enabled,this.#e)===!1||!kj(this.#l)||this.#l===0)&&(this.#u=Vh.setInterval(()=>{(this.options.refetchIntervalInBackground||QR.isFocused())&&this.#m()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(Vh.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(Vh.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 R=this.hasListeners(),T=!R&&iz(t,e),P=R&&az(t,n,e,r);(T||P)&&(d={...d,...CW(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:g,errorUpdatedAt:x,status:y}=d;m=d.data;let b=!1;if(e.placeholderData!==void 0&&m===void 0&&y==="pending"){let R;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(R=i.data,b=!0):R=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,R!==void 0&&(y="success",m=Pj(i?.data,R,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=Pj(i?.data,m,e),this.#d=m,this.#s=null}catch(R){this.#s=R}this.#s&&(g=this.#s,m=this.#d,x=Date.now(),y="error");const v=d.fetchStatus==="fetching",M=y==="pending",S=y==="error",A=M&&v,E=m!==void 0,C={status:y,fetchStatus:d.fetchStatus,isPending:M,isSuccess:y==="success",isError:S,isInitialLoading:A,isLoading:A,data:m,dataUpdatedAt:d.dataUpdatedAt,error:g,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&&!M,isLoadingError:S&&!E,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:S&&E,isStale:JR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:uo(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const R=F=>{C.status==="error"?F.reject(C.error):C.data!==void 0&&F.resolve(C.data)},T=()=>{const F=this.#o=C.promise=Rj();R(F)},P=this.#o;switch(P.status){case"pending":t.queryHash===n.queryHash&&R(P);break;case"fulfilled":(C.status==="error"||C.data!==P.value)&&T();break;case"rejected":(C.status!=="error"||C.error!==P.reason)&&T();break}}return C}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),r0(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){Yr.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function wle(t,e){return uo(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function iz(t,e){return wle(t,e)||t.state.data!==void 0&&Oj(t,e,e.refetchOnMount)}function Oj(t,e,n){if(uo(e.enabled,t)!==!1&&_d(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&JR(t,e)}return!1}function az(t,e,n,r){return(t!==e||uo(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&JR(t,n)}function JR(t,e){return uo(e.enabled,t)!==!1&&t.isStaleByTime(_d(e.staleTime,t))}function Sle(t,e){return!r0(t.getCurrentResult(),e)}function sz(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=MW(e.options,e.fetchOptions),g=async(x,y,b)=>{if(d)return Promise.reject();if(y==null&&x.pages.length)return Promise.resolve(x);const M=(()=>{const k={client:e.client,queryKey:e.queryKey,pageParam:y,direction:b?"backward":"forward",meta:e.options.meta};return f(k),k})(),S=await m(M),{maxPages:A}=e.options,E=b?ple:mle;return{pages:E(x.pages,S,A),pageParams:E(x.pageParams,y,A)}};if(i&&a.length){const x=i==="backward",y=x?Mle:oz,b={pages:a,pageParams:o},v=y(r,b);l=await g(b,v,x)}else{const x=t??a.length;do{const y=c===0?o[0]??r.initialPageParam:oz(r,l);if(c>0&&y==null)break;l=await g(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 oz(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 Mle(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var Nle=class extends TW{#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||kW(),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=AW({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),Yr.batch(()=>{this.#e.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function kW(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ele=class extends Hf{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 Nle({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=Kv(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=Kv(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=Kv(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=Kv(t);return typeof e=="string"?this.#e.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Yr.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=>JU(e,n))}findAll(t={}){return this.getAll().filter(e=>JU(t,e))}notify(t){Yr.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return Yr.batch(()=>Promise.all(t.map(e=>e.continue().catch(Ta))))}};function Kv(t){return t.options.scope?.id}var Ale=class extends Hf{#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),r0(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&yf(n.mutationKey)!==yf(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??kW();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){Yr.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 lz(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function Tle(t,e,n){const r=t.slice(0);return r[e]=n,r}var Cle=class extends Hf{#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,Yr.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||!r0(d,m)});!c&&!u||(c&&(this.#r=i),this.#e=a,this.hasListeners()&&(c&&(lz(n,i).forEach(d=>{d.destroy()}),lz(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=XR(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 ZR(this.#t,i);n.push({defaultedQueryOptions:i,observer:o})}),n}#u(t,e){const n=this.#r.indexOf(t);n!==-1&&(this.#e=Tle(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&&Yr.batch(()=>{this.listeners.forEach(r=>{r(this.#e)})})}}},kle=class extends Hf{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??KR(r,e);let a=this.get(i);return a||(a=new _le({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(){Yr.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=>ZU(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>ZU(t,n)):e}notify(t){Yr.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){Yr.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Yr.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},jle=class{#t;#e;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#t=t.queryCache||new kle,this.#e=t.mutationCache||new Ele,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=QR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=lw.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(_d(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=dle(e,a);if(o!==void 0)return this.#t.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return Yr.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;Yr.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#t;return Yr.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=Yr.batch(()=>this.#t.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Ta).catch(Ta)}invalidateQueries(t,e={}){return Yr.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=Yr.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(Ta)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Ta)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#t.build(this,e);return n.isStaleByTime(_d(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Ta).catch(Ta)}fetchInfiniteQuery(t){return t.behavior=sz(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ta).catch(Ta)}ensureInfiniteQueryData(t){return t.behavior=sz(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return lw.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(yf(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{n0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(yf(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{n0(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=KR(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===YR&&(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()}},jW=w.createContext(void 0),tn=t=>{const e=w.useContext(jW);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Ple=({client:t,children:e})=>(w.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),s.jsx(jW.Provider,{value:t,children:e})),PW=w.createContext(!1),RW=()=>w.useContext(PW);PW.Provider;function Rle(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Dle=w.createContext(Rle()),DW=()=>w.useContext(Dle),OW=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},LW=t=>{w.useEffect(()=>{t.clearReset()},[t])},IW=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||NW(n,[t.error,r])),FW=t=>{if(t.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},UW=(t,e)=>t.isLoading&&t.isFetching&&!e,Lj=(t,e)=>t?.suspense&&e.isPending,cw=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Ole({queries:t,...e},n){const r=tn(),i=RW(),a=DW(),o=w.useMemo(()=>t.map(y=>{const b=r.defaultQueryOptions(y);return b._optimisticResults=i?"isRestoring":"optimistic",b}),[t,r,i]);o.forEach(y=>{FW(y),OW(y,a)}),LW(a);const[l]=w.useState(()=>new Cle(r,o,e)),[c,u,d]=l.getOptimisticResult(o,e.combine),f=!i&&e.subscribed!==!1;w.useSyncExternalStore(w.useCallback(y=>f?l.subscribe(Yr.batchCalls(y)):Ta,[l,f]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),w.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const g=c.some((y,b)=>Lj(o[b],y))?c.flatMap((y,b)=>{const v=o[b];if(v){const M=new ZR(r,v);if(Lj(v,y))return cw(v,M,a);UW(y,i)&&cw(v,M,a)}return[]}):[];if(g.length>0)throw Promise.all(g);const x=c.find((y,b)=>{const v=o[b];return v&&IW({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 Lle(t,e,n){const r=RW(),i=DW(),a=tn(),o=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?"isRestoring":"optimistic",FW(o),OW(o,i),LW(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(Yr.batchCalls(f)):Ta;return c.updateResult(),m},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),w.useEffect(()=>{c.setOptions(o)},[o,c]),Lj(o,u))throw cw(o,c,i);if(IW({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&&!bf&&UW(u,r)&&(l?cw(o,c,i):a.getQueryCache().get(o.queryHash)?.promise)?.catch(Ta).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?u:c.trackResult(u)}function ct(t,e){return Lle(t,ZR)}function ft(t,e){const n=tn(),[r]=w.useState(()=>new Ale(n,t));w.useEffect(()=>{r.setOptions(t)},[r,t]);const i=w.useSyncExternalStore(w.useCallback(o=>r.subscribe(Yr.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=w.useCallback((o,l)=>{r.mutate(o,l).catch(Ta)},[r]);if(i.error&&NW(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const Ile=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Fle=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),cz=t=>{const e=Fle(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(),Ule=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var zle={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 Ble=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,...zle,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:zW("lucide",i),...!a&&!Ule(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>w.createElement(u,d)),...Array.isArray(a)?a:[a]]));const Ve=(t,e)=>{const n=w.forwardRef(({className:r,...i},a)=>w.createElement(Ble,{ref:a,iconNode:e,className:zW(`lucide-${Ile(cz(t))}`,`lucide-${t}`,r),...i}));return n.displayName=cz(t),n};const $le=[["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"}]],Hle=Ve("air-vent",$le);const Vle=[["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"}]],Ha=Ve("archive",Vle);const Gle=[["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"}]],Wle=Ve("arrow-down-wide-narrow",Gle);const qle=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],i0=Ve("arrow-down",qle);const Kle=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],BW=Ve("arrow-left",Kle);const Xle=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Ij=Ve("arrow-right",Xle);const Yle=[["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"}]],$W=Ve("arrow-up-down",Yle);const Qle=[["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"}]],Zle=Ve("arrow-up-narrow-wide",Qle);const Jle=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Kp=Ve("arrow-up",Jle);const ece=[["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"}]],tf=Ve("bell",ece);const tce=[["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"}]],nce=Ve("bold",tce);const rce=[["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"}]],ice=Ve("book",rce);const ace=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],sce=Ve("bookmark",ace);const oce=[["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"}]],Os=Ve("box",oce);const lce=[["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"}]],HW=Ve("briefcase",lce);const cce=[["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"}]],N2=Ve("bug",cce);const uce=[["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"}]],dce=Ve("cable",uce);const hce=[["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"}]],fce=Ve("calendar-days",hce);const mce=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Qr=Ve("calendar",mce);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"}]],Xp=Ve("camera",pce);const gce=[["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"}]],xce=Ve("chart-column",gce);const bce=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],xs=Ve("check",bce);const yce=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ji=Ve("chevron-down",yce);const vce=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Gs=Ve("chevron-right",vce);const _ce=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],vf=Ve("chevron-left",_ce);const wce=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Jc=Ve("chevron-up",wce);const Sce=[["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"}]],ea=Ve("circle-alert",Sce);const Mce=[["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"}]],TA=Ve("circle-arrow-up",Mce);const Nce=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Dn=Ve("circle-check-big",Nce);const Ece=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],E2=Ve("circle-check",Ece);const Ace=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Tce=Ve("circle-dot",Ace);const Cce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],kce=Ve("circle-stop",Cce);const jce=[["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"}]],qi=Ve("circle-x",jce);const Pce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Fj=Ve("circle",Pce);const Rce=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Gn=Ve("clock",Rce);const Dce=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],A2=Ve("cloud",Dce);const Oce=[["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"}]],Lce=Ve("code-xml",Oce);const Ice=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],VW=Ve("code",Ice);const Fce=[["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"}]],Uce=Ve("coffee",Fce);const zce=[["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"}]],Bce=Ve("cog",zce);const $ce=[["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"}]],Hce=Ve("compass",$ce);const Vce=[["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"}]],Jo=Ve("copy",Vce);const Gce=[["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"}]],Xv=Ve("cpu",Gce);const Wce=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],qce=Ve("cylinder",Wce);const Kce=[["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"}]],Yp=Ve("database",Kce);const Xce=[["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"}]],Uj=Ve("dollar-sign",Xce);const Yce=[["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"}]],Jr=Ve("download",Yce);const Qce=[["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"}]],eD=Ve("droplet",Qce);const Zce=[["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"}]],tD=Ve("droplets",Zce);const Jce=[["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"}]],wd=Ve("ellipsis-vertical",Jce);const eue=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],CA=Ve("equal",eue);const tue=[["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"}]],Lr=Ve("external-link",tue);const nue=[["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"}]],T2=Ve("eye-off",nue);const rue=[["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"}]],_f=Ve("eye",rue);const iue=[["path",{d:"M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z",key:"484a7f"}],["path",{d:"M12 12v.01",key:"u5ubse"}]],GW=Ve("fan",iue);const aue=[["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"}]],nf=Ve("file-box",aue);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"}]],uw=Ve("file-code",sue);const oue=[["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"}]],lue=Ve("file-exclamation-point",oue);const cue=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],dw=Ve("file-spreadsheet",cue);const uue=[["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"}]],za=Ve("file-text",uue);const due=[["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"}]],C2=Ve("file",due);const hue=[["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"}]],Sd=Ve("film",hue);const fue=[["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"}]],mue=Ve("flame",fue);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"}]],ba=Ve("folder-kanban",pue);const gue=[["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"}]],el=Ve("folder-open",gue);const xue=[["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"}]],bue=Ve("folder-plus",xue);const yue=[["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"}]],vue=Ve("folder-tree",yue);const _ue=[["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"}]],WW=Ve("folder",_ue);const wue=[["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"}]],Sue=Ve("fullscreen",wue);const Mue=[["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"}]],k2=Ve("funnel",Mue);const Nue=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],j2=Ve("gauge",Nue);const Eue=[["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"}]],Aue=Ve("gift",Eue);const Tue=[["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"}]],Rp=Ve("git-compare",Tue);const Cue=[["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"}]],uz=Ve("github",Cue);const kue=[["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"}]],Md=Ve("globe",kue);const jue=[["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"}]],Qp=Ve("grip-vertical",jue);const Pue=[["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"}]],qW=Ve("hand",Pue);const Rue=[["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"}]],P2=Ve("hard-drive",Rue);const Due=[["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"}]],Oue=Ve("hash",Due);const Lue=[["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"}]],Iue=Ve("headphones",Lue);const Fue=[["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"}]],Uue=Ve("heart",Fue);const zue=[["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"}]],hw=Ve("history",zue);const Bue=[["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"}]],R2=Ve("house",Bue);const $ue=[["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"}]],X0=Ve("image",$ue);const Hue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],tl=Ve("info",Hue);const Vue=[["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"}]],Gue=Ve("italic",Vue);const Wue=[["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"}]],Gh=Ve("key",Wue);const que=[["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"}]],zj=Ve("keyboard",que);const Kue=[["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"}]],nl=Ve("layers",Kue);const Xue=[["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"}]],D2=Ve("layout-grid",Xue);const Yue=[["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"}]],Que=Ve("link-2-off",Yue);const Zue=[["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"}]],kl=Ve("link-2",Zue);const Jue=[["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"}]],Y0=Ve("link",Jue);const ede=[["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"}]],KW=Ve("list-ordered",ede);const tde=[["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"}]],Bj=Ve("list-todo",tde);const nde=[["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"}]],O2=Ve("list",nde);const rde=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],mt=Ve("loader-circle",rde);const ide=[["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"}]],dz=Ve("lock-open",ide);const ade=[["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"}]],kA=Ve("lock",ade);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"}]],hz=Ve("log-in",sde);const ode=[["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"}]],$j=Ve("log-out",ode);const lde=[["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"}]],cde=Ve("mail",lde);const ude=[["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"}]],dde=Ve("map",ude);const hde=[["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"}]],XW=Ve("maximize-2",hde);const fde=[["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"}]],mde=Ve("maximize",fde);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"}]],gde=Ve("memory-stick",pde);const xde=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],bde=Ve("menu",xde);const yde=[["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"}]],YW=Ve("minimize-2",yde);const vde=[["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"}]],QW=Ve("minimize",vde);const _de=[["path",{d:"M5 12h14",key:"1ays0h"}]],Hj=Ve("minus",_de);const wde=[["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"}]],Sde=Ve("monitor",wde);const Mde=[["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"}]],fw=Ve("moon",Mde);const Nde=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],Ede=Ve("move-right",Nde);const Ade=[["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"}]],Vj=Ve("music",Ade);const Tde=[["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"}]],Dl=Ve("package",Tde);const Cde=[["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"}]],nD=Ve("palette",Cde);const kde=[["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"}]],rD=Ve("pause",kde);const jde=[["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"}]],wf=Ve("pen-line",jde);const Pde=[["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"}]],L2=Ve("pen",Pde);const Rde=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Ga=Ve("pencil",Rde);const Dde=[["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"}]],Ode=Ve("phone",Dde);const Lde=[["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"}]],rl=Ve("play",Lde);const Ide=[["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"}]],Us=Ve("plug",Ide);const Fde=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Kn=Ve("plus",Fde);const Ude=[["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"}]],I2=Ve("power-off",Ude);const zde=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],uu=Ve("power",zde);const Bde=[["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"}]],Ir=Ve("printer",Bde);const $de=[["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"}]],ZW=Ve("qr-code",$de);const Hde=[["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"}]],yr=Ve("refresh-cw",Hde);const Vde=[["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"}]],Vf=Ve("rotate-ccw",Vde);const Gde=[["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"}]],Wde=Ve("ruler",Gde);const qde=[["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"}]],ds=Ve("save",qde);const Kde=[["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"}]],JW=Ve("scan-search",Kde);const Xde=[["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"}]],Yde=Ve("scissors",Xde);const Qde=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],xa=Ve("search",Qde);const Zde=[["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"}]],iD=Ve("send",Zde);const Jde=[["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"}]],Ph=Ve("server",Jde);const ehe=[["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"}]],Dd=Ve("settings-2",ehe);const the=[["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"}]],F2=Ve("settings",the);const nhe=[["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"}]],P1=Ve("shield",nhe);const rhe=[["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"}]],eq=Ve("shopping-cart",rhe);const ihe=[["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"}]],ahe=Ve("signal",ihe);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"}]],ohe=Ve("skip-back",she);const lhe=[["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"}]],mw=Ve("skip-forward",lhe);const che=[["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"}]],fz=Ve("sliders-vertical",che);const uhe=[["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"}]],a0=Ve("sparkles",uhe);const dhe=[["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"}]],eu=Ve("square-check-big",dhe);const hhe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ol=Ve("square",hhe);const fhe=[["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"}]],Sf=Ve("star",fhe);const mhe=[["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"}]],tq=Ve("sticky-note",mhe);const phe=[["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"}]],mz=Ve("sun",phe);const ghe=[["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"}]],Zp=Ve("tag",ghe);const xhe=[["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"}]],nq=Ve("target",xhe);const bhe=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],rq=Ve("terminal",bhe);const yhe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],vhe=Ve("text-align-center",yhe);const _he=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],whe=Ve("text-align-end",_he);const She=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Mhe=Ve("text-align-start",She);const Nhe=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],U2=Ve("thermometer",Nhe);const Ehe=[["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"}]],md=Ve("timer",Ehe);const Ahe=[["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"}]],an=Ve("trash-2",Ahe);const The=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],iq=Ve("trending-down",The);const Che=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],aq=Ve("trending-up",Che);const khe=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Cn=Ve("triangle-alert",khe);const jhe=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Phe=Ve("underline",jhe);const Rhe=[["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"}]],aD=Ve("unlink",Rhe);const Dhe=[["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"}]],bi=Ve("upload",Dhe);const Ohe=[["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"}]],Gj=Ve("user",Ohe);const Lhe=[["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"}]],Wh=Ve("users",Lhe);const Ihe=[["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"}]],sD=Ve("video",Ihe);const Fhe=[["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"}]],Uhe=Ve("volume-2",Fhe);const zhe=[["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"}]],Bhe=Ve("volume-x",zhe);const $he=[["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"}]],Hhe=Ve("wand-sparkles",$he);const Vhe=[["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"}]],Pg=Ve("wifi-off",Vhe);const Ghe=[["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"}]],Dp=Ve("wifi",Ghe);const Whe=[["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"}]],sq=Ve("wind",Whe);const qhe=[["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"}]],Od=Ve("wrench",qhe);const Khe=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ut=Ve("x",Khe);const Xhe=[["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"}]],oD=Ve("zoom-in",Xhe);const Yhe=[["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"}]],Mf=Ve("zap",Yhe);const Qhe=[["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"}]],lD=Ve("zoom-out",Qhe),gn="/api/v1";let pw=localStorage.getItem("auth_token");function gb(t){pw=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function pz(){return pw}async function Te(t,e={}){const n={"Content-Type":"application/json",...e.headers};pw&&(n.Authorization=`Bearer ${pw}`);const r=await fetch(`${gn}${t}`,{...e,cache:"no-store",headers:n});if(!r.ok){r.status===401&&gb(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 pe={getAuthStatus:()=>Te("/auth/status"),setupAuth:t=>Te("/auth/setup",{method:"POST",body:JSON.stringify(t)}),login:t=>Te("/auth/login",{method:"POST",body:JSON.stringify(t)}),logout:()=>Te("/auth/logout",{method:"POST"}),getCurrentUser:()=>Te("/auth/me"),disableAuth:()=>Te("/auth/disable",{method:"POST"}),getUsers:()=>Te("/users/"),getUser:t=>Te(`/users/${t}`),createUser:t=>Te("/users/",{method:"POST",body:JSON.stringify(t)}),updateUser:(t,e)=>Te(`/users/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteUser:t=>Te(`/users/${t}`,{method:"DELETE"}),getPrinters:()=>Te("/printers/"),getPrinter:t=>Te(`/printers/${t}`),createPrinter:t=>Te("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Te(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>Te(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>Te(`/printers/${t}/status`),refreshPrinterStatus:t=>Te(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>Te(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Te(`/printers/${t}/disconnect`,{method:"POST"}),stopPrint:t=>Te(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>Te(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>Te(`/printers/${t}/print/resume`,{method:"POST"}),setChamberLight:(t,e)=>Te(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>Te(`/printers/${t}/print/objects`),skipObjects:(t,e)=>Te(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>Te(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>Te(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Te(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Te(`/printers/${t}/logging`),clearMQTTLogs:t=>Te(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Te(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${gn}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>Te(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Te(`/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)),Te(`/archives/?${i}`)},getArchive:t=>Te(`/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)),Te(`/archives/search?${n}`)},rebuildSearchIndex:()=>Te("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Te(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Te(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Te(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Te("/archives/stats"),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)),Te(`/archives/analysis/failures?${e}`)},compareArchives:t=>Te(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Te(`/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(`${gn}/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(`${gn}/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=>Te(`/archives/${t}/duplicates`),backfillContentHashes:()=>Te("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${gn}/archives/${t}/thumbnail?v=${Date.now()}`,getArchiveDownload:t=>`${gn}/archives/${t}/download`,getArchiveGcode:t=>`${gn}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${gn}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${gn}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>Te(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Te(`/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(`${gn}/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=>Te(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>Te(`/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(`${gn}/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)=>`${gn}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${gn}/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)=>Te(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${gn}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${gn}/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(`${gn}/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=>Te(`/archives/${t}/source`,{method:"DELETE"}),getF3dDownloadUrl:t=>`${gn}/archives/${t}/f3d`,uploadF3d:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${gn}/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=>Te(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${gn}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Te(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Te(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Te(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${gn}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${gn}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchivePlates:t=>Te(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>Te(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>Te(`/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?`${gn}/archives/upload?printer_id=${e}`:`${gn}/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?`${gn}/archives/upload-bulk?printer_id=${e}`:`${gn}/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:()=>Te("/settings/"),updateSettings:t=>Te("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>Te("/settings/mqtt/status"),resetSettings:()=>Te("/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.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=`${gn}/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=`${gn}/settings/restore${e?"?overwrite=true":""}`;return(await fetch(r,{method:"POST",body:n})).json()},checkFfmpeg:()=>Te("/settings/check-ffmpeg"),getCloudStatus:()=>Te("/cloud/status"),cloudLogin:(t,e,n="global")=>Te("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>Te("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>Te("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Te("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Te(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>Te(`/cloud/settings/${t}`),createCloudSetting:t=>Te("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Te(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Te(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Te("/cloud/devices"),getCloudFields:t=>Te(`/cloud/fields/${t}`),getAllCloudFields:()=>Te("/cloud/fields"),getFilamentInfo:t=>Te("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>Te("/smart-plugs/"),getSmartPlug:t=>Te(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Te(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>Te("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Te(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Te(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Te(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Te(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Te("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>fetch(`${gn}/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:()=>Te("/smart-plugs/discover/status"),stopTasmotaScan:()=>fetch(`${gn}/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:()=>Te("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>Te("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:t=>{const e=t?`?search=${encodeURIComponent(t)}`:"";return Te(`/smart-plugs/ha/entities${e}`)},getHASensorEntities:()=>Te("/smart-plugs/ha/sensors"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),Te(`/queue/?${n}`)},getQueueItem:t=>Te(`/queue/${t}`),addToQueue:t=>Te("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Te(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Te(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Te("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Te(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Te(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>Te(`/queue/${t}/start`,{method:"POST"}),getKProfiles:(t,e="0.4")=>Te(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Te(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Te(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Te(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Te(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Te(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Te(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Te(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Te(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>Te(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Te(`/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()),Te(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>Te(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>Te("/filaments/"),getFilament:t=>Te(`/filaments/${t}`),getFilamentsByType:t=>Te(`/filaments/by-type/${t}`),getNotificationProviders:()=>Te("/notifications/"),getNotificationProvider:t=>Te(`/notifications/${t}`),createNotificationProvider:t=>Te("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Te(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Te(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Te(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Te("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Te("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Te("/notification-templates"),getNotificationTemplate:t=>Te(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Te(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Te(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Te("/notification-templates/variables"),previewTemplate:t=>Te("/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)),Te(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Te(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Te(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Te("/spoolman/status"),connectSpoolman:()=>Te("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Te("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Te(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Te("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Te("/spoolman/spools"),getSpoolmanFilaments:()=>Te("/spoolman/filaments"),getUnlinkedSpools:()=>Te("/spoolman/spools/unlinked"),linkSpool:(t,e)=>Te(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getVersion:()=>Te("/updates/version"),checkForUpdates:()=>Te("/updates/check"),applyUpdate:()=>Te("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Te("/updates/status"),getMaintenanceTypes:()=>Te("/maintenance/types"),createMaintenanceType:t=>Te("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Te(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Te(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>Te("/maintenance/overview"),getPrinterMaintenance:t=>Te(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Te(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Te(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Te(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Te("/maintenance/summary"),setPrinterHours:(t,e)=>Te(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>Te(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>Te(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${gn}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${gn}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Te(`/printers/${t}/camera/test`),getExternalLinks:()=>Te("/external-links/"),getExternalLink:t=>Te(`/external-links/${t}`),createExternalLink:t=>Te("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Te(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Te(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Te("/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(`${gn}/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=>Te(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${gn}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),Te(`/projects/?${e}`)},getProject:t=>Te(`/projects/${t}`),createProject:t=>Te("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Te(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Te(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Te(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Te(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Te(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Te(`/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(`${gn}/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)=>`${gn}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>Te(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>Te(`/projects/${t}/bom`),createBOMItem:(t,e)=>Te(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>Te(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>Te(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>Te("/projects/templates/"),createTemplateFromProject:t=>Te(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>Te(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>Te(`/projects/${t}/timeline?limit=${e}`),getAPIKeys:()=>Te("/api-keys/"),createAPIKey:t=>Te("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Te(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Te(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Te(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Te("/system/info"),getLibraryFolders:()=>Te("/library/folders"),createLibraryFolder:t=>Te("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>Te(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>Te(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>Te(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>Te(`/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)),Te(`/library/files?${n}`)},getLibraryFile:t=>Te(`/library/files/${t}`),uploadLibraryFile:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`?folder_id=${e}`:"",i=await fetch(`${gn}/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)=>{const r=new FormData;r.append("file",t);const i=new URLSearchParams;e&&i.set("folder_id",String(e)),i.set("preserve_structure",String(n));const a=await fetch(`${gn}/library/files/extract-zip?${i}`,{method:"POST",body:r});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${a.status}`)}return a.json()},updateLibraryFile:(t,e)=>Te(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>Te(`/library/files/${t}`,{method:"DELETE"}),getLibraryFileDownloadUrl:t=>`${gn}/library/files/${t}/download`,getLibraryFileThumbnailUrl:t=>`${gn}/library/files/${t}/thumbnail`,getLibraryFileGcodeUrl:t=>`${gn}/library/files/${t}/gcode`,moveLibraryFiles:(t,e)=>Te("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>Te("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>Te("/library/stats"),addLibraryFilesToQueue:t=>Te("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})}),printLibraryFile:(t,e,n)=>Te(`/library/files/${t}/print?printer_id=${e}`,{method:"POST",body:n?JSON.stringify(n):void 0}),getLibraryFilePlates:t=>Te(`/library/files/${t}/plates`),getLibraryFileFilamentRequirements:(t,e)=>Te(`/library/files/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`)},pl={getInfo:()=>Te("/discovery/info"),getStatus:()=>Te("/discovery/status"),startDiscovery:(t=10)=>Te(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Te("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Te("/discovery/printers"),startSubnetScan:(t,e=1)=>Te("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>Te("/discovery/scan/status"),stopSubnetScan:()=>Te("/discovery/scan/stop",{method:"POST"})},R1={getSettings:()=>Te("/settings/virtual-printer"),getModels:()=>Te("/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),Te(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},yp={list:()=>Te("/pending-uploads/"),getCount:()=>Te("/pending-uploads/count"),get:t=>Te(`/pending-uploads/${t}`),archive:(t,e)=>Te(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>Te(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>Te("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>Te("/pending-uploads/discard-all",{method:"DELETE"})},D1={checkUpdates:()=>Te("/firmware/updates"),checkPrinterUpdate:t=>Te(`/firmware/updates/${t}`),prepareUpload:t=>Te(`/firmware/updates/${t}/prepare`),startUpload:t=>Te(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>Te(`/firmware/updates/${t}/upload/status`)},Op={getDebugLoggingState:()=>Te("/support/debug-logging"),setDebugLogging:t=>Te("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t=await fetch(`${gn}/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 Te(`/support/logs${n?`?${n}`:""}`)},clearLogs:()=>Te("/support/logs",{method:"DELETE"})},oq=w.createContext(void 0);function Zhe({children:t}){const[e,n]=w.useState(()=>{const C=localStorage.getItem("theme-mode"),R=localStorage.getItem("theme");return C||R||"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"),[g,x]=w.useState(()=>localStorage.getItem("light-accent")||"green");w.useEffect(()=>{pe.getSettings().then(C=>{C.dark_style&&(i(C.dark_style),localStorage.setItem("dark-style",C.dark_style)),C.dark_background&&(o(C.dark_background),localStorage.setItem("dark-background",C.dark_background)),C.dark_accent&&(c(C.dark_accent),localStorage.setItem("dark-accent",C.dark_accent)),C.light_style&&(d(C.light_style),localStorage.setItem("light-style",C.light_style)),C.light_background&&(m(C.light_background),localStorage.setItem("light-background",C.light_background)),C.light_accent&&(x(C.light_accent),localStorage.setItem("light-accent",C.light_accent))}).catch(()=>{})},[]),w.useEffect(()=>{const C=document.documentElement;C.classList.remove("dark","style-classic","style-glow","style-vibrant","bg-neutral","bg-warm","bg-cool","bg-oled","bg-slate","bg-forest","accent-green","accent-teal","accent-blue","accent-orange","accent-purple","accent-red"),e==="dark"?(C.classList.add("dark"),C.classList.add(`style-${r}`),C.classList.add(`bg-${a}`),C.classList.add(`accent-${l}`)):(C.classList.add(`style-${u}`),C.classList.add(`bg-${f}`),C.classList.add(`accent-${g}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,a,l,u,f,g]);const y=()=>n(C=>C==="dark"?"light":"dark"),b=C=>n(C),v=C=>{i(C),localStorage.setItem("dark-style",C),pe.updateSettings({dark_style:C}).catch(()=>{})},M=C=>{o(C),localStorage.setItem("dark-background",C),pe.updateSettings({dark_background:C}).catch(()=>{})},S=C=>{c(C),localStorage.setItem("dark-accent",C),pe.updateSettings({dark_accent:C}).catch(()=>{})},A=C=>{d(C),localStorage.setItem("light-style",C),pe.updateSettings({light_style:C}).catch(()=>{})},E=C=>{m(C),localStorage.setItem("light-background",C),pe.updateSettings({light_background:C}).catch(()=>{})},k=C=>{x(C),localStorage.setItem("light-accent",C),pe.updateSettings({light_accent:C}).catch(()=>{})};return s.jsx(oq.Provider,{value:{mode:e,darkStyle:r,darkBackground:a,darkAccent:l,lightStyle:u,lightBackground:f,lightAccent:g,toggleMode:y,setMode:b,setDarkStyle:v,setDarkBackground:M,setDarkAccent:S,setLightStyle:A,setLightBackground:E,setLightAccent:k},children:t})}function Xd(){const t=w.useContext(oq);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function Mt({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 mr({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 Jhe(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 gz({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 efe({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Tg(),i=Jhe(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(Mt,{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(zj,{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(Ut,{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(Lr,{className:"w-3 h-3 text-bambu-gray"})]}),s.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>s.jsx(gz,{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(gz,{children:"Esc"})," or click outside to close"]})})]})})})}function Se({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 Ln({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(Mt,{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(Cn,{className:"w-6 h-6"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),s.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),s.jsxs("div",{className:"flex gap-3 mt-6",children:[s.jsx(Se,{variant:"secondary",onClick:c,className:"flex-1",disabled:a,children:r}),s.jsx(Se,{onClick:l,className:`flex-1 ${d.button}`,disabled:a,children:a?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 mr-2 animate-spin"}),o||"Processing..."]}):n})]})]})})})}function tfe({plug:t}){const e=tn(),[n,r]=w.useState(null),{data:i,isLoading:a}=ct({queryKey:["smart-plug-status",t.id],queryFn:()=>pe.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=ft({mutationFn:f=>pe.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(Us,{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(mt,{className:"w-3 h-3 text-bambu-gray animate-spin"}):c?s.jsxs(s.Fragment,{children:[s.jsx(Dp,{className:"w-3 h-3 text-bambu-green"}),s.jsx("span",{className:l?"text-bambu-green":"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(Mf,{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(Pg,{className:"w-3 h-3 text-red-400"}),s.jsx("span",{className:"text-red-400",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(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(uu,{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(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(I2,{className:"w-4 h-4"})})]})]}),n&&s.jsx(Ln,{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 xz({onClose:t}){const{data:e,isLoading:n}=ct({queryKey:["smart-plugs"],queryFn:pe.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(Us,{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(mt,{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(Us,{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(tfe,{plug:i},i.id))})})]})}const lq=[{name:"globe",icon:Md},{name:"link",icon:Y0},{name:"external-link",icon:Lr},{name:"book",icon:ice},{name:"file-text",icon:za},{name:"home",icon:R2},{name:"star",icon:Sf},{name:"heart",icon:Uue},{name:"bookmark",icon:sce},{name:"shopping-cart",icon:eq},{name:"music",icon:Vj},{name:"video",icon:sD},{name:"image",icon:X0},{name:"camera",icon:Xp},{name:"map",icon:dde},{name:"compass",icon:Hce},{name:"coffee",icon:Uce},{name:"gift",icon:Aue},{name:"wrench",icon:Od},{name:"zap",icon:Mf},{name:"cloud",icon:A2},{name:"database",icon:Yp},{name:"folder",icon:WW},{name:"mail",icon:cde},{name:"phone",icon:Ode},{name:"user",icon:Gj},{name:"users",icon:Wh},{name:"server",icon:Ph},{name:"terminal",icon:rq},{name:"code",icon:VW}];function z2(t){return lq.find(n=>n.name===t)?.icon||Y0}function nfe({value:t,onChange:e}){const[n,r]=w.useState(!1),i=z2(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:lq.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 bz=768;function cq(){const[t,e]=w.useState(()=>typeof window<"u"?window.innerWidth<bz:!1);return w.useEffect(()=>{const n=window.matchMedia(`(max-width: ${bz-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const uq=w.createContext(void 0);function rfe({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=async()=>{try{const y=await pe.getAuthStatus();if(i(y.auth_enabled),o(y.requires_setup),y.auth_enabled)if(pz())try{const v=await pe.getCurrentUser();n(v)}catch{gb(null),n(null)}else n(null);else n(null)}catch(y){console.error("Failed to check auth status:",y),i(!1),n(null)}finally{c(!1)}};w.useEffect(()=>{d()},[]),w.useEffect(()=>{if(!l&&a&&!r){const y=window.location.pathname;y!=="/setup"&&!y.startsWith("/camera/")&&!u.current&&(u.current=!0,window.location.href="/setup")}else a||(u.current=!1)},[l,a,r]);const f=async(y,b)=>{const v=await pe.login({username:y,password:b});gb(v.access_token),n(v.user)},m=()=>{gb(null),n(null),pe.logout().catch(()=>{}),window.location.href="/login"},g=async()=>{if(r&&pz())try{const y=await pe.getCurrentUser();n(y)}catch{gb(null),n(null)}},x=async()=>{await d()};return s.jsx(uq.Provider,{value:{user:e,authEnabled:r,requiresSetup:a,loading:l,login:f,logout:m,refreshUser:g,refreshAuth:x},children:t})}function Yd(){const t=w.useContext(uq);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const s0=[{id:"printers",to:"/",icon:Ir,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:Ha,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:Qr,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:xce,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:A2,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:Od,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:ba,labelKey:"nav.projects"},{id:"files",to:"/files",icon:el,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:F2,labelKey:"nav.settings"}];function ife(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return s0.map(e=>e.id)}return s0.map(e=>e.id)}function afe(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function jA(t){return t.startsWith("ext-")}function dq(){return localStorage.getItem("defaultView")||"/"}function sfe(t){localStorage.setItem("defaultView",t)}function ofe(){const t=ol(),e=Gl(),{mode:n,toggleMode:r}=Xd(),{t:i}=Tg(),a=cq(),{user:o,authEnabled:l,logout:c}=Yd(),[u,d]=w.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[f,m]=w.useState(!1),[g,x]=w.useState(!1),[y,b]=w.useState(!1),[v,M]=w.useState(ife),[S,A]=w.useState(null),[E,k]=w.useState(null),C=w.useRef(!1),[R,T]=w.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),{data:P}=ct({queryKey:["version"],queryFn:pe.getVersion,staleTime:1/0}),{data:F}=ct({queryKey:["settings"],queryFn:pe.getSettings,staleTime:300*1e3}),{data:L}=ct({queryKey:["updateCheck"],queryFn:pe.checkForUpdates,enabled:F?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:X}=ct({queryKey:["external-links"],queryFn:pe.getExternalLinks}),{data:D}=ct({queryKey:["smart-plugs"],queryFn:pe.getSmartPlugs,staleTime:30*1e3}),K=D?.some($=>$.show_in_switchbar)??!1,{data:Y}=ct({queryKey:["debugLogging"],queryFn:Op.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:q}=ct({queryKey:["queue","pending"],queryFn:()=>pe.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),Z=q?.length??0,{data:re}=ct({queryKey:["pending-uploads","count"],queryFn:yp.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),oe=re?.count??0,[B,G]=w.useState(null);w.useEffect(()=>{if(!Y?.enabled||!Y.enabled_at){G(null);return}const $=new Date(Y.enabled_at).getTime(),z=()=>{G(Math.floor((Date.now()-$)/1e3))};z();const W=setInterval(z,1e3);return()=>clearInterval(W)},[Y?.enabled,Y?.enabled_at]);const J=w.useMemo(()=>new Map(s0.map($=>[$.id,$])),[]),te=w.useMemo(()=>new Map((X||[]).map($=>[`ext-${$.id}`,$])),[X]),ae=(()=>{const $=[],z=new Set,W=l&&o?.role==="user";for(const U of v)W&&U==="settings"||(J.has(U)||te.has(U))&&($.push(U),z.add(U));for(const U of s0)W&&U.id==="settings"||z.has(U.id)||($.push(U.id),z.add(U.id));for(const U of X||[]){const V=`ext-${U.id}`;z.has(V)||($.push(V),z.add(V))}return $})(),de=($,z)=>{A(z),$.dataTransfer.effectAllowed="move",$.dataTransfer.setData("text/plain",z)},fe=($,z)=>{$.preventDefault(),$.dataTransfer.dropEffect="move",k(z)},Ae=()=>{k(null)},ge=($,z)=>{if($.preventDefault(),S===null||S===z){A(null),k(null);return}const W=[...ae],U=W.indexOf(S),V=W.indexOf(z);if(U===-1||V===-1){A(null),k(null);return}W.splice(U,1),W.splice(V,0,S),M(W),afe(W),A(null),k(null)},Me=()=>{A(null),k(null)},je=L?.update_available&&L.latest_version&&L.latest_version!==R,ne=()=>{L?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",L.latest_version),T(L.latest_version))};w.useEffect(()=>{if(!C.current&&e.pathname==="/"){const $=dq();$!=="/"&&(C.current=!0,t($,{replace:!0}))}},[e.pathname,t]),w.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(u))},[u]),w.useEffect(()=>{a&&m(!1)},[e.pathname,a]);const Ke=w.useCallback($=>{const z=$.target;if(!(z.tagName==="INPUT"||z.tagName==="TEXTAREA"||z.isContentEditable)&&!$.metaKey&&!$.ctrlKey&&!$.altKey){const W=parseInt($.key);if(W>=1&&W<=ae.length&&W<=9){const U=ae[W-1];if($.preventDefault(),jA(U)){const V=U.replace("ext-","");t(`/external/${V}`)}else{const V=J.get(U);V&&t(V.to)}return}switch($.key){case"?":$.preventDefault(),x(!0);break;case"Escape":x(!1);break}}},[t,ae,J]);return w.useEffect(()=>(document.addEventListener("keydown",Ke),()=>document.removeEventListener("keydown",Ke)),[Ke]),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(bde,{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:ae.map($=>{if(jA($)){const W=te.get($);if(!W)return null;const U=W.custom_icon?null:z2(W.icon);return s.jsx("li",{draggable:!0,onDragStart:V=>de(V,$),onDragOver:V=>fe(V,$),onDragLeave:Ae,onDrop:V=>ge(V,$),onDragEnd:Me,className:`relative ${S===$?"opacity-50":""} ${E===$&&S!==$?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(pb,{to:`/external/${W.id}`,className:({isActive:V})=>`flex items-center ${a||u?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${V?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!u?W.name:void 0,children:[u&&!a&&s.jsx(Qp,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),W.custom_icon?s.jsx("img",{src:`/api/v1/external-links/${W.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):U&&s.jsx(U,{className:"w-5 h-5 flex-shrink-0"}),(a||u)&&s.jsx("span",{children:W.name})]})},$)}else{const W=J.get($);if(!W)return null;const{to:U,icon:V,labelKey:Q}=W,Ee=$==="queue"&&Z>0,Ce=$==="archives"&&oe>0,Ne=Ee?Z:Ce?oe:0,H=Ee||Ce;return s.jsx("li",{draggable:!0,onDragStart:O=>de(O,$),onDragOver:O=>fe(O,$),onDragLeave:Ae,onDrop:O=>ge(O,$),onDragEnd:Me,className:`relative ${S===$?"opacity-50":""} ${E===$&&S!==$?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(pb,{to:U,className:({isActive:O})=>`flex items-center ${a||u?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${O?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!u?i(Q):void 0,children:[u&&!a&&s.jsx(Qp,{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(V,{className:"w-5 h-5 flex-shrink-0"}),H&&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 ${Ce?"bg-blue-500 text-white":"bg-yellow-500 text-black"}`,children:Ne>99?"99+":Ne})]}),(a||u)&&s.jsx("span",{children:i(Q)})]})},$)}})})}),!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(vf,{className:"w-5 h-5"}):s.jsx(Gs,{className:"w-5 h-5"})}),s.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a||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:[K&&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(Us,{className:"w-5 h-5"})}),y&&s.jsx(xz,{onClose:()=>b(!1)})]}),s.jsx(pb,{to:"/system",className:({isActive:$})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${$?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(tl,{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(uz,{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(zj,{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(mz,{className:"w-5 h-5"}):s.jsx(fw,{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($j,{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",P?.version||"..."]}),L?.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:L.latest_version}),children:[s.jsx(TA,{className:"w-4 h-4"}),s.jsx("span",{children:i("nav.update")})]})]})]}):s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[L?.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:L.latest_version}),children:s.jsx(TA,{className:"w-5 h-5"})}),K&&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(Us,{className:"w-5 h-5"})}),y&&s.jsx(xz,{onClose:()=>b(!1)})]}),s.jsx(pb,{to:"/system",className:({isActive:$})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${$?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(tl,{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(uz,{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(zj,{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(mz,{className:"w-5 h-5"}):s.jsx(fw,{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($j,{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:[Y?.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(N2,{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"}),B!==null&&s.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(B/60),"m ",B%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"})})]})}),je&&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(TA,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{children:i("nav.updateAvailableBanner",{version:L?.latest_version,defaultValue:`Version ${L?.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:ne,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:s.jsx(Ut,{className:"w-4 h-4"})})]}),s.jsx(Eoe,{})]}),g&&s.jsx(efe,{onClose:()=>x(!1),sidebarItems:ae.map($=>{if(jA($)){const z=te.get($);return z?{type:"external",label:z.name}:null}else{const z=J.get($);return z?{type:"nav",label:z.labelKey,labelKey:z.labelKey}:null}}).filter(Boolean)})]})}function Pb(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function mi(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function Jp(t,e){const n=mi(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function eg(t,e="system",n){const r=mi(t);if(!r)return"";const a=Pb(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,a)}function lfe(t,e="system",n){const i=Pb({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}const hq=w.createContext(void 0);function $n(){const t=w.useContext(hq);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const cfe={success:s.jsx(Dn,{className:"w-5 h-5 text-green-400"}),error:s.jsx(qi,{className:"w-5 h-5 text-red-400"}),warning:s.jsx(ea,{className:"w-5 h-5 text-yellow-400"}),info:s.jsx(tl,{className:"w-5 h-5 text-blue-400"}),loading:s.jsx(mt,{className:"w-5 h-5 text-bambu-green animate-spin"})},ufe={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 dfe({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(hq.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 ${ufe[o.type]}`,children:[cfe[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(Ut,{className:"w-4 h-4"})})]},o.id))})]})}function hfe(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 yz(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 ffe(t,e){if(e)return WW;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return nf;case"gcode":return za;case"mp4":case"avi":return Sd;case"png":case"jpg":case"jpeg":return X0;default:return C2}}const mfe=[{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 pfe({printerId:t,printerName:e,onClose:n}){const{showToast:r}=$n(),i=tn(),[a,o]=w.useState("/"),[l,c]=w.useState(null),[u,d]=w.useState(""),[f,m]=w.useState(null),[g,x]=w.useState("name-asc");w.useEffect(()=>{const T=P=>{P.key==="Escape"&&n()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[n]);const{data:y,isLoading:b,refetch:v}=ct({queryKey:["printerFiles",t,a],queryFn:()=>pe.getPrinterFiles(t,a)}),{data:M}=ct({queryKey:["printerStorage",t],queryFn:()=>pe.getPrinterStorage(t),staleTime:3e4}),S=ft({mutationFn:T=>pe.deletePrinterFile(t,T),onSuccess:(T,P)=>{r(`Deleted: ${P.split("/").pop()}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(null)},onError:T=>{r(`Delete failed: ${T.message}`,"error")}}),A=T=>{o(T),c(null)},E=()=>{if(a==="/")return;const T=a.split("/").filter(Boolean);T.pop(),o(T.length?"/"+T.join("/"):"/"),c(null)},k=T=>{window.open(pe.getPrinterFileDownloadUrl(t,T),"_blank")},C=T=>{m(T)},R=[{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:T=>T.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(P2,{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:[M&&(M.used_bytes!=null||M.free_bytes!=null)&&s.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[M.used_bytes!=null&&s.jsxs("span",{children:["Used: ",yz(M.used_bytes)]}),M.used_bytes!=null&&M.free_bytes!=null&&s.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),M.free_bytes!=null&&s.jsxs("span",{children:["Free: ",yz(M.free_bytes)]})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ut,{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:[R.map(T=>s.jsx("button",{onClick:()=>{A(T.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===T.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:T.label},T.path)),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(xa,{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:T=>d(T.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($W,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("select",{value:g,onChange:T=>x(T.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:mfe.map(T=>s.jsx("option",{value:T.value,children:T.label},T.value))})]}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:()=>v(),disabled:b,children:s.jsx(yr,{className:`w-4 h-4 ${b?"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:E,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:s.jsx(vf,{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:b?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):y?.files?.length?s.jsx("div",{className:"space-y-1",children:[...y.files].filter(T=>!u||T.name.toLowerCase().includes(u.toLowerCase())).sort((T,P)=>{if(T.is_directory&&!P.is_directory)return-1;if(!T.is_directory&&P.is_directory)return 1;switch(g){case"name-asc":return T.name.localeCompare(P.name);case"name-desc":return P.name.localeCompare(T.name);case"size-asc":return T.size-P.size;case"size-desc":return P.size-T.size;case"date-asc":{const F=T.mtime?new Date(T.mtime).getTime():0,L=P.mtime?new Date(P.mtime).getTime():0;return F-L}case"date-desc":{const F=T.mtime?new Date(T.mtime).getTime():0;return(P.mtime?new Date(P.mtime).getTime():0)-F}default:return T.name.localeCompare(P.name)}}).map(T=>{const P=ffe(T.name,T.is_directory),F=l===T.path;return s.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${F?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{T.is_directory?A(T.path):c(F?null:T.path)},children:[s.jsx(P,{className:`w-5 h-5 flex-shrink-0 ${T.is_directory?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("span",{className:"flex-1 text-white truncate",children:T.name}),!T.is_directory&&s.jsx("span",{className:"text-sm text-bambu-gray",children:hfe(T.size)}),T.is_directory&&s.jsx(vf,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},T.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.jsx("div",{className:"text-sm text-bambu-gray",children:u?`${y?.files?.filter(T=>T.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${y?.files?.length||0} items`:`${y?.files?.length||0} items`}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Se,{variant:"secondary",disabled:!l,onClick:()=>l&&k(l),children:[s.jsx(Jr,{className:"w-4 h-4"}),"Download"]}),s.jsxs(Se,{variant:"secondary",disabled:!l||S.isPending,onClick:()=>l&&C(l),className:"text-red-400 hover:text-red-300",children:[S.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(an,{className:"w-4 h-4"}),"Delete"]})]})]})]}),f&&s.jsx(Ln,{title:"Delete File",message:`Delete "${f.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{S.mutate(f),m(null)},onCancel:()=>m(null)})]})}const gfe="embeddedCameraState_",vz=5,xfe=2e3,bfe=3e4,yfe=5e3,PA={x:window.innerWidth-420,y:20,width:400,height:300};function vfe({printerId:t,printerName:e,viewerIndex:n=0,onClose:r}){const i=`${gfe}${t}`,a=()=>{try{const ie=localStorage.getItem(i);if(ie){const ye=JSON.parse(ie);return{x:Math.min(Math.max(0,ye.x),window.innerWidth-100),y:Math.min(Math.max(0,ye.y),window.innerHeight-100),width:Math.max(200,Math.min(ye.width,window.innerWidth-20)),height:Math.max(150,Math.min(ye.height,window.innerHeight-20))}}}catch{}const O=n*30;return{...PA,x:Math.max(0,PA.x-O),y:Math.max(0,PA.y+O)}},[o,l]=w.useState(a),[c,u]=w.useState(!1),[d,f]=w.useState(!1),[m,g]=w.useState({x:0,y:0}),[x,y]=w.useState(!1),[b,v]=w.useState(!1),[M,S]=w.useState(1),[A,E]=w.useState({x:0,y:0}),[k,C]=w.useState(!1),[R,T]=w.useState({x:0,y:0}),[P,F]=w.useState(!1),[L,X]=w.useState(!0),[D,K]=w.useState(Date.now()),[Y,q]=w.useState(0),[Z,re]=w.useState(!1),[oe,B]=w.useState(0),G=w.useRef(null),J=w.useRef(null),te=w.useRef(null),ae=w.useRef(null),de=w.useRef(null),{data:fe}=ct({queryKey:["printer",t],queryFn:()=>pe.getPrinter(t),enabled:t>0});w.useEffect(()=>{const O=setTimeout(()=>{localStorage.setItem(i,JSON.stringify(o))},500);return()=>clearTimeout(O)},[o,i]);const Ae=w.useRef(!1);w.useEffect(()=>{Ae.current=!1;const O=`/api/v1/printers/${t}/camera/stop`,ie=()=>{t>0&&!Ae.current&&(Ae.current=!0,navigator.sendBeacon(O))},ye=J.current;return()=>{ye&&(ye.src=""),ie(),te.current&&clearTimeout(te.current),ae.current&&clearInterval(ae.current),de.current&&clearInterval(de.current)}},[t]),w.useEffect(()=>{if(L){const O=setTimeout(()=>X(!1),3e3);return()=>clearTimeout(O)}},[L,D]);const ge=w.useCallback(()=>{if(Y>=vz){re(!1),F(!0);return}const O=Math.min(xfe*Math.pow(2,Y),bfe);re(!0),B(Math.ceil(O/1e3)),ae.current=setInterval(()=>{B(ie=>ie<=1?(ae.current&&clearInterval(ae.current),0):ie-1)},1e3),te.current=setTimeout(()=>{q(ie=>ie+1),re(!1),X(!0),F(!1),J.current&&(J.current.src=""),K(Date.now())},O)},[Y]);w.useEffect(()=>{if(L||Z||x){de.current&&(clearInterval(de.current),de.current=null);return}return de.current=setInterval(async()=>{try{const O=await fetch(`/api/v1/printers/${t}/camera/status`);if(O.ok){const ie=await O.json();(ie.stalled||!ie.active&&!P)&&(de.current&&(clearInterval(de.current),de.current=null),X(!1),ge())}}catch{}},yfe),()=>{de.current&&(clearInterval(de.current),de.current=null)}},[L,P,Z,x,t,ge]),w.useEffect(()=>{const O=()=>{const ie=!!document.fullscreenElement;v(ie),ie||(S(1),E({x:0,y:0}))};return document.addEventListener("fullscreenchange",O),()=>document.removeEventListener("fullscreenchange",O)},[]);const Me=()=>{G.current&&(document.fullscreenElement?document.exitFullscreen():G.current.requestFullscreen())},je=()=>{S(O=>Math.min(O+.5,4))},ne=()=>{S(O=>{const ie=Math.max(O-.5,1);return ie===1&&E({x:0,y:0}),ie})},Ke=O=>{O.preventDefault(),O.deltaY<0?je():ne()},$=O=>{M>1&&(O.preventDefault(),C(!0),T({x:O.clientX-A.x,y:O.clientY-A.y}))},z=O=>{if(k&&M>1){const ie=O.clientX-R.x,ye=O.clientY-R.y,_e=(M-1)*150;E({x:Math.max(-_e,Math.min(_e,ie)),y:Math.max(-_e,Math.min(_e,ye))})}},W=()=>{C(!1)},U=()=>{S(1),E({x:0,y:0})},V=()=>{X(!1),Y<vz?ge():F(!0)},Q=()=>{X(!1),F(!1),q(0),re(!1),te.current&&clearTimeout(te.current),ae.current&&clearInterval(ae.current)},Ee=()=>{X(!0),F(!1),q(0),re(!1),te.current&&clearTimeout(te.current),ae.current&&clearInterval(ae.current),fetch(`/api/v1/printers/${t}/camera/stop`).catch(()=>{}),J.current&&(J.current.src=""),setTimeout(()=>K(Date.now()),100)},Ce=O=>{O.target.closest(".no-drag")||(u(!0),g({x:O.clientX-o.x,y:O.clientY-o.y}))},Ne=O=>{O.stopPropagation(),f(!0)};w.useEffect(()=>{const O=ye=>{if(c)l(_e=>({..._e,x:Math.max(0,Math.min(ye.clientX-m.x,window.innerWidth-_e.width)),y:Math.max(0,Math.min(ye.clientY-m.y,window.innerHeight-_e.height))}));else if(d&&G.current){const _e=G.current.getBoundingClientRect();l(le=>({...le,width:Math.max(200,Math.min(ye.clientX-_e.left,window.innerWidth-le.x-10)),height:Math.max(150,Math.min(ye.clientY-_e.top,window.innerHeight-le.y-10))}))}},ie=()=>{u(!1),f(!1)};if(c||d)return document.addEventListener("mousemove",O),document.addEventListener("mouseup",ie),()=>{document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",ie)}},[c,d,m]);const H=`/api/v1/printers/${t}/camera/stream?fps=10&t=${D}`;return s.jsxs("div",{ref:G,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:Ce,children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[s.jsx(Qp,{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:Ee,disabled:L||Z,className:"p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:"Refresh stream",children:s.jsx(yr,{className:`w-3.5 h-3.5 text-bambu-gray ${L?"animate-spin":""}`})}),s.jsx("button",{onClick:Me,className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:b?"Exit fullscreen":"Fullscreen",children:b?s.jsx(QW,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(Sue,{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(XW,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(YW,{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(Ut,{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:Ke,onMouseMove:z,onMouseUp:W,onMouseLeave:W,children:[L&&!Z&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:s.jsx(yr,{className:"w-6 h-6 text-bambu-gray animate-spin"})}),Z&&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(Pg,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Reconnecting in ",oe,"s..."]})]})}),P&&!Z&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:s.jsxs("div",{className:"text-center p-2",children:[s.jsx(Cn,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Camera unavailable"}),s.jsx("button",{onClick:Ee,className:"px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80",children:"Retry"})]})}),s.jsx("img",{ref:J,src:H,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${M}) translate(${A.x/M}px, ${A.y/M}px)`,cursor:M>1?k?"grabbing":"grab":"default"},onError:V,onLoad:Q,onMouseDown:$,draggable:!1},D),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:ne,disabled:M<=1,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:s.jsx(lD,{className:"w-3.5 h-3.5 text-white"})}),s.jsxs("button",{onClick:U,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(M*100),"%"]}),s.jsx("button",{onClick:je,disabled:M>=4,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:s.jsx(oD,{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:Ne,title:"Drag to resize",children:s.jsx("svg",{className:"w-6 h-6 text-bambu-gray/70 hover:text-bambu-gray",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M22 22H20V20H22V22ZM22 18H20V16H22V18ZM18 22H16V20H18V22ZM22 14H20V12H22V14ZM18 18H16V16H18V18ZM14 22H12V20H14V22ZM22 10H20V8H22V10ZM18 14H16V12H18V14ZM14 18H12V16H14V18ZM10 22H8V20H10V22Z"})})})]})]})}function _fe({printerId:t,printerName:e,onClose:n}){const r=tn(),[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:g,isLoading:x,refetch:y}=ct({queryKey:["mqtt-logs",t],queryFn:()=>pe.getMQTTLogs(t),refetchInterval:1e3}),b=ft({mutationFn:()=>pe.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),v=ft({mutationFn:()=>pe.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),M=ft({mutationFn:()=>pe.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});w.useEffect(()=>{const T=P=>{P.key==="Escape"&&n()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[n]),w.useEffect(()=>{i&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[g?.logs,i]);const S=T=>{l(P=>{const F=new Set(P);return F.has(T)?F.delete(T):F.add(T),F})},A=T=>new Date(T).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),E=(T,P)=>{if(T==null)return"<empty>";const F=typeof T=="string"?JSON.parse(T):T,L=JSON.stringify(F,null,P?2:0);return!P&&L.length>100?L.substring(0,100)+"...":L},k=g?.logging_enabled??!1,C=w.useMemo(()=>g?.logs??[],[g?.logs]),R=w.useMemo(()=>C.filter(T=>{if(d!=="all"&&T.direction!==d)return!1;if(c.trim()){const P=c.toLowerCase(),F=T.topic.toLowerCase().includes(P),X=JSON.stringify(T.payload).toLowerCase().includes(P);return F||X}return!0}),[C,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(Ut,{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:[k?s.jsxs(Se,{size:"sm",variant:"secondary",onClick:()=>v.mutate(),disabled:v.isPending,children:[s.jsx(Ol,{className:"w-4 h-4"}),"Stop"]}):s.jsxs(Se,{size:"sm",onClick:()=>b.mutate(),disabled:b.isPending,children:[s.jsx(rl,{className:"w-4 h-4"}),"Start Logging"]}),s.jsxs(Se,{size:"sm",variant:"secondary",onClick:()=>M.mutate(),disabled:M.isPending||C.length===0,children:[s.jsx(an,{className:"w-4 h-4"}),"Clear"]}),s.jsx(Se,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:x,children:s.jsx(yr,{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:T=>a(T.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[R.length,"/",C.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(xa,{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:T=>u(T.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(Ut,{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(i0,{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(Kp,{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:C.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"}),!k&&s.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):R.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:R.map((T,P)=>{const F=o.has(P),L=T.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(P),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray shrink-0",children:A(T.timestamp)}),s.jsx("span",{className:`shrink-0 ${L?"text-blue-400":"text-green-400"}`,title:L?"Incoming":"Outgoing",children:L?s.jsx(i0,{className:"w-3 h-3"}):s.jsx(Kp,{className:"w-3 h-3"})}),s.jsx("span",{className:"text-purple-400 shrink-0",children:T.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(T.payload,!0)}):s.jsx("pre",{className:"mt-1 text-white/80 truncate",children:E(T.payload,!1)})]},P)})})}),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:k?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(Se,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const Wj={"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 wfe(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:Cn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:Cn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:ea};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:tl}}}function qj(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 Sfe(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=qj(e.attr,n);return Wj[r]!==void 0})}function Mfe(){return"https://wiki.bambulab.com/en/hms/home"}function Nfe({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=qj(i.attr,a);return Wj[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(Cn,{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(Ut,{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(ea,{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}=wfe(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=qj(i.attr,d),m=Wj[f],g=Mfe(),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:g,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[s.jsx(Lr,{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 Efe(t){if(!t)return"ASAP";const e=mi(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 Afe({printerId:t}){const{data:e}=ct({queryKey:["queue",t,"pending"],queryFn:()=>pe.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:s.jsx(ls,{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(Qr,{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(Gn,{className:"w-3 h-3"}),Efe(n?.scheduled_time||null)]}),r>1&&s.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),s.jsx(Gs,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function fq(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=fq(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function In(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=fq(t))&&(r&&(r+=" "),r+=e);return r}var Tfe=["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 cD(t){if(typeof t!="string")return!1;var e=Tfe;return e.includes(t)}var Cfe=["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"],kfe=new Set(Cfe);function mq(t){return typeof t!="string"?!1:kfe.has(t)}function pq(t){return typeof t=="string"&&t.startsWith("data-")}function Wa(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(mq(n)||pq(n))&&(e[n]=t[n]);return e}function Nf(t){if(t==null)return null;if(w.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Wa(e)}return typeof t=="object"&&!Array.isArray(t)?Wa(t):null}function ya(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(mq(n)||pq(n)||cD(n))&&(e[n]=t[n]);return e}function jfe(t){return t==null?null:w.isValidElement(t)?ya(t.props):typeof t=="object"&&!Array.isArray(t)?ya(t):null}var Pfe=["children","width","height","viewBox","className","style","title","desc"];function Kj(){return Kj=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},Kj.apply(null,arguments)}function Rfe(t,e){if(t==null)return{};var n,r,i=Dfe(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 Dfe(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 uD=w.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:o,style:l,title:c,desc:u}=t,d=Rfe(t,Pfe),f=a||{width:r,height:i,x:0,y:0},m=In("recharts-surface",o);return w.createElement("svg",Kj({},ya(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)}),Ofe=["children","className"];function Xj(){return Xj=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},Xj.apply(null,arguments)}function Lfe(t,e){if(t==null)return{};var n,r,i=Ife(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 Ife(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 Fr=w.forwardRef((t,e)=>{var{children:n,className:r}=t,i=Lfe(t,Ofe),a=In("recharts-layer",r);return w.createElement("g",Xj({className:a},ya(i),{ref:e}),n)}),gq=w.createContext(null),Ffe=()=>w.useContext(gq);function br(t){return function(){return t}}const xq=Math.cos,gw=Math.sin,ll=Math.sqrt,xw=Math.PI,B2=2*xw,Yj=Math.PI,Qj=2*Yj,Rh=1e-6,Ufe=Qj-Rh;function bq(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function zfe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return bq;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 Bfe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?bq:zfe(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>Rh)if(!(Math.abs(f*c-u*d)>Rh)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let g=r-o,x=i-l,y=c*c+u*u,b=g*g+x*x,v=Math.sqrt(y),M=Math.sqrt(m),S=a*Math.tan((Yj-Math.acos((y+m-b)/(2*v*M)))/2),A=S/M,E=S/v;Math.abs(A-1)>Rh&&this._append`L${e+A*d},${n+A*f}`,this._append`A${a},${a},0,0,${+(f*g>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)>Rh||Math.abs(this._y1-d)>Rh)&&this._append`L${u},${d}`,r&&(m<0&&(m=m%Qj+Qj),m>Ufe?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>Rh&&this._append`A${r},${r},0,${+(m>=Yj)},${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 dD(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 Bfe(e)}function hD(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function yq(t){this._context=t}yq.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 $2(t){return new yq(t)}function vq(t){return t[0]}function _q(t){return t[1]}function wq(t,e){var n=br(!0),r=null,i=$2,a=null,o=dD(l);t=typeof t=="function"?t:t===void 0?vq:br(t),e=typeof e=="function"?e:e===void 0?_q:br(e);function l(c){var u,d=(c=hD(c)).length,f,m=!1,g;for(r==null&&(a=i(g=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(g)return a=null,g+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:br(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:br(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:br(!!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 Yv(t,e,n){var r=null,i=br(!0),a=null,o=$2,l=null,c=dD(u);t=typeof t=="function"?t:t===void 0?vq:br(+t),e=typeof e=="function"?e:br(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?_q:br(+n);function u(f){var m,g,x,y=(f=hD(f)).length,b,v=!1,M,S=new Array(y),A=new Array(y);for(a==null&&(l=o(M=c())),m=0;m<=y;++m){if(!(m<y&&i(b=f[m],m,f))===v)if(v=!v)g=m,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),x=m-1;x>=g;--x)l.point(S[x],A[x]);l.lineEnd(),l.areaEnd()}v&&(S[m]=+t(b,m,f),A[m]=+e(b,m,f),l.point(r?+r(b,m,f):S[m],n?+n(b,m,f):A[m]))}if(M)return l=null,M+""||null}function d(){return wq().defined(i).curve(o).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:br(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:br(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:br(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:br(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:br(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:br(+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:br(!!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 Sq{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 $fe(t){return new Sq(t,!0)}function Hfe(t){return new Sq(t,!1)}const fD={draw(t,e){const n=ll(e/xw);t.moveTo(n,0),t.arc(0,0,n,0,B2)}},Vfe={draw(t,e){const n=ll(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()}},Mq=ll(1/3),Gfe=Mq*2,Wfe={draw(t,e){const n=ll(e/Gfe),r=n*Mq;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},qfe={draw(t,e){const n=ll(e),r=-n/2;t.rect(r,r,n,n)}},Kfe=.8908130915292852,Nq=gw(xw/10)/gw(7*xw/10),Xfe=gw(B2/10)*Nq,Yfe=-xq(B2/10)*Nq,Qfe={draw(t,e){const n=ll(e*Kfe),r=Xfe*n,i=Yfe*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const o=B2*a/5,l=xq(o),c=gw(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},RA=ll(3),Zfe={draw(t,e){const n=-ll(e/(RA*3));t.moveTo(0,n*2),t.lineTo(-RA*n,-n),t.lineTo(RA*n,-n),t.closePath()}},no=-.5,ro=ll(3)/2,Zj=1/ll(12),Jfe=(Zj/2+1)*3,eme={draw(t,e){const n=ll(e/Jfe),r=n/2,i=n*Zj,a=r,o=n*Zj+n,l=-a,c=o;t.moveTo(r,i),t.lineTo(a,o),t.lineTo(l,c),t.lineTo(no*r-ro*i,ro*r+no*i),t.lineTo(no*a-ro*o,ro*a+no*o),t.lineTo(no*l-ro*c,ro*l+no*c),t.lineTo(no*r+ro*i,no*i-ro*r),t.lineTo(no*a+ro*o,no*o-ro*a),t.lineTo(no*l+ro*c,no*c-ro*l),t.closePath()}};function tme(t,e){let n=null,r=dD(i);t=typeof t=="function"?t:br(t||fD),e=typeof e=="function"?e:br(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:br(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:br(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function bw(){}function yw(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 Eq(t){this._context=t}Eq.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:yw(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:yw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function nme(t){return new Eq(t)}function Aq(t){this._context=t}Aq.prototype={areaStart:bw,areaEnd:bw,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:yw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function rme(t){return new Aq(t)}function Tq(t){this._context=t}Tq.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:yw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function ime(t){return new Tq(t)}function Cq(t){this._context=t}Cq.prototype={areaStart:bw,areaEnd:bw,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 ame(t){return new Cq(t)}function _z(t){return t<0?-1:1}function wz(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(_z(a)+_z(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(l))||0}function Sz(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function DA(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 vw(t){this._context=t}vw.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:DA(this,this._t0,Sz(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,DA(this,Sz(this,n=wz(this,t,e)),n);break;default:DA(this,this._t0,n=wz(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function kq(t){this._context=new jq(t)}(kq.prototype=Object.create(vw.prototype)).point=function(t,e){vw.prototype.point.call(this,e,t)};function jq(t){this._context=t}jq.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 sme(t){return new vw(t)}function ome(t){return new kq(t)}function Pq(t){this._context=t}Pq.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=Mz(t),i=Mz(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 Mz(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 lme(t){return new Pq(t)}function H2(t,e){this._context=t,this._t=e}H2.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 cme(t){return new H2(t,.5)}function ume(t){return new H2(t,0)}function dme(t){return new H2(t,1)}function tg(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 Jj(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function hme(t,e){return t[e]}function fme(t){const e=[];return e.key=t,e}function mme(){var t=br([]),e=Jj,n=tg,r=hme;function i(a){var o=Array.from(t.apply(this,arguments),fme),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=hD(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:br(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:br(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?Jj:typeof a=="function"?a:br(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??tg,i):n},i}function pme(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}tg(t,e)}}function gme(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}tg(t,e)}}function xme(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,g=(f-m)/2,x=0;x<l;++x){var y=t[e[x]],b=y[r][1]||0,v=y[r-1][1]||0;g+=b-v}c+=f,u+=g*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,tg(t,e)}}var OA={},LA={},Nz;function bme(){return Nz||(Nz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(LA)),LA}var IA={},Ez;function Rq(){return Ez||(Ez=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})(IA)),IA}var FA={},Az;function mD(){return Az||(Az=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})(FA)),FA}var UA={},zA={},Tz;function yme(){return Tz||(Tz=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})(zA)),zA}var Cz;function pD(){return Cz||(Cz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=yme(),n=mD();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})(UA)),UA}var kz;function gD(){return kz||(kz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=bme(),n=Rq(),r=mD(),i=pD();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})(OA)),OA}var BA,jz;function vme(){return jz||(jz=1,BA=gD().get),BA}var _me=vme();const Ef=Co(_me);var Xi=t=>t===0?0:t>0?1:-1,bs=t=>typeof t=="number"&&t!=+t,tu=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Ft=t=>(typeof t=="number"||t instanceof Number)&&!bs(t),Eo=t=>Ft(t)||typeof t=="string",wme=0,o0=t=>{var e=++wme;return"".concat(t||"").concat(e)},ja=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(!Ft(e)&&typeof e!="string")return r;var a;if(tu(e)){if(n==null)return r;var o=e.indexOf("%");a=n*parseFloat(e.slice(0,o))/100}else a=+e;return bs(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},Dq=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 qn(t,e,n){return Ft(t)&&Ft(e)?t+n*(e-t):e}function Oq(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Ef(r,e))===n)}var Ar=t=>t===null||typeof t>"u",Q0=t=>Ar(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function Sme(t){return t!=null}function Z0(){}var Mme=["type","size","sizeType"];function e3(){return e3=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},e3.apply(null,arguments)}function Pz(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 Rz(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Pz(Object(n),!0).forEach(function(r){Nme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Pz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Nme(t,e,n){return(e=Eme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Eme(t){var e=Ame(t,"string");return typeof e=="symbol"?e:e+""}function Ame(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 Tme(t,e){if(t==null)return{};var n,r,i=Cme(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 Cme(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 Lq={symbolCircle:fD,symbolCross:Vfe,symbolDiamond:Wfe,symbolSquare:qfe,symbolStar:Qfe,symbolTriangle:Zfe,symbolWye:eme},kme=Math.PI/180,jme=t=>{var e="symbol".concat(Q0(t));return Lq[e]||fD},Pme=(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*kme;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}},Rme=(t,e)=>{Lq["symbol".concat(Q0(t))]=e},xD=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=Tme(t,Mme),a=Rz(Rz({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var m=jme(o),g=tme().type(m).size(Pme(n,r,o)),x=g();if(x!==null)return x},{className:c,cx:u,cy:d}=a,f=ya(a);return Ft(u)&&Ft(d)&&Ft(n)?w.createElement("path",e3({},f,{className:In("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};xD.registerSymbol=Rme;var Iq=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,bD=(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=>{cD(i)&&(r[i]=(a=>n[i](n,a)))}),r},Dme=(t,e,n)=>r=>(t(e,n,r),null),J0=(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];cD(i)&&typeof a=="function"&&(r||(r={}),r[i]=Dme(a,e,n))}),r};function Dz(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 Ome(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Dz(Object(n),!0).forEach(function(r){Lme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Dz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Lme(t,e,n){return(e=Ime(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ime(t){var e=Fme(t,"string");return typeof e=="symbol"?e:e+""}function Fme(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 Ur(t,e){var n=Ome({},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 _w(){return _w=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},_w.apply(null,arguments)}function Oz(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 Ume(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Oz(Object(n),!0).forEach(function(r){zme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Oz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zme(t,e,n){return(e=Bme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Bme(t){var e=$me(t,"string");return typeof e=="symbol"?e:e+""}function $me(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 lo=32,Hme={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function Vme(t){var{data:e,iconType:n,inactiveColor:r}=t,i=lo/2,a=lo/6,o=lo/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:lo,y2:i,className:"recharts-legend-icon"})}if(c==="line")return w.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(i,"h").concat(o,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(2*o,",").concat(i,`
- H`).concat(lo,"M").concat(2*o,",").concat(i,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return w.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(lo/8,"h").concat(lo,"v").concat(lo*3/4,"h").concat(-lo,"z"),className:"recharts-legend-icon"});if(w.isValidElement(e.legendIcon)){var d=Ume({},e);return delete d.legendIcon,w.cloneElement(e.legendIcon,d)}return w.createElement(xD,{fill:l,cx:i,cy:i,size:lo,sizeType:"diameter",type:c})}function Gme(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:o}=t,l={x:0,y:0,width:lo,height:lo},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,g=In({"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",_w({className:g,style:c,key:"legend-item-".concat(f)},J0(t,d,f)),w.createElement(uD,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(y," legend icon")},w.createElement(Vme,{data:d,iconType:o,inactiveColor:a})),w.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},y))})}var Wme=t=>{var e=Ur(t,Hme),{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(Gme,_w({},e,{payload:n})))},$A={},HA={},Lz;function qme(){return Lz||(Lz=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})(HA)),HA}var VA={},Iz;function Fq(){return Iz||(Iz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(VA)),VA}var GA={},WA={},qA={},Fz;function Kme(){return Fz||(Fz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(qA)),qA}var Uz;function yD(){return Uz||(Uz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Kme();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(WA)),WA}var KA={},zz;function Xme(){return zz||(zz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(KA)),KA}var Bz;function Yme(){return Bz||(Bz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=yD(),n=Xme();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(GA)),GA}var XA={},YA={},$z;function Qme(){return $z||($z=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=gD();function n(r){return function(i){return e.get(i,r)}}t.property=n})(YA)),YA}var QA={},ZA={},JA={},eT={},Hz;function Uq(){return Hz||(Hz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n!==null&&(typeof n=="object"||typeof n=="function")}t.isObject=e})(eT)),eT}var tT={},Vz;function zq(){return Vz||(Vz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==null||typeof n!="object"&&typeof n!="function"}t.isPrimitive=e})(tT)),tT}var nT={},Gz;function Bq(){return Gz||(Gz=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})(nT)),nT}var Wz;function Zme(){return Wz||(Wz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Uq(),n=zq(),r=Bq();function i(d,f,m){return typeof m!="function"?i(d,f,()=>{}):a(d,f,function g(x,y,b,v,M,S){const A=m(x,y,b,v,M,S);return A!==void 0?!!A:a(x,y,g,S)},new Map)}function a(d,f,m,g){if(f===d)return!0;switch(typeof f){case"object":return o(d,f,m,g);case"function":return Object.keys(f).length>0?a(d,{...f},m,g):r.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.eq(d,f)}}function o(d,f,m,g){if(f==null)return!0;if(Array.isArray(f))return c(d,f,m,g);if(f instanceof Map)return l(d,f,m,g);if(f instanceof Set)return u(d,f,m,g);const x=Object.keys(f);if(d==null)return x.length===0;if(x.length===0)return!0;if(g?.has(f))return g.get(f)===d;g?.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,g))return!1}return!0}finally{g?.delete(f)}}function l(d,f,m,g){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,g)===!1)return!1}return!0}function c(d,f,m,g){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 M=0;M<d.length;M++){if(x.has(M))continue;const S=d[M];let A=!1;if(m(S,b,y,d,f,g)&&(A=!0),A){x.add(M),v=!0;break}}if(!v)return!1}return!0}function u(d,f,m,g){return f.size===0?!0:d instanceof Set?c([...d],[...f],m,g):!1}t.isMatchWith=i,t.isSetMatch=u})(JA)),JA}var qz;function $q(){return qz||(qz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Zme();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(ZA)),ZA}var rT={},iT={},aT={},Kz;function Jme(){return Kz||(Kz=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})(aT)),aT}var sT={},Xz;function Hq(){return Xz||(Xz=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})(sT)),sT}var oT={},Yz;function Vq(){return Yz||(Yz=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]",g="[object Object]",x="[object Error]",y="[object DataView]",b="[object Uint8Array]",v="[object Uint8ClampedArray]",M="[object Uint16Array]",S="[object Uint32Array]",A="[object BigUint64Array]",E="[object Int8Array]",k="[object Int16Array]",C="[object Int32Array]",R="[object BigInt64Array]",T="[object Float32Array]",P="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=m,t.arrayTag=d,t.bigInt64ArrayTag=R,t.bigUint64ArrayTag=A,t.booleanTag=i,t.dataViewTag=y,t.dateTag=l,t.errorTag=x,t.float32ArrayTag=T,t.float64ArrayTag=P,t.functionTag=f,t.int16ArrayTag=k,t.int32ArrayTag=C,t.int8ArrayTag=E,t.mapTag=c,t.numberTag=r,t.objectTag=g,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=o,t.uint16ArrayTag=M,t.uint32ArrayTag=S,t.uint8ArrayTag=b,t.uint8ClampedArrayTag=v})(oT)),oT}var lT={},Qz;function epe(){return Qz||(Qz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(lT)),lT}var Zz;function Gq(){return Zz||(Zz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Jme(),n=Hq(),r=Vq(),i=zq(),a=epe();function o(d,f){return l(d,void 0,d,new Map,f)}function l(d,f,m,g=new Map,x=void 0){const y=x?.(d,f,m,g);if(y!==void 0)return y;if(i.isPrimitive(d))return d;if(g.has(d))return g.get(d);if(Array.isArray(d)){const b=new Array(d.length);g.set(d,b);for(let v=0;v<d.length;v++)b[v]=l(d[v],v,m,g,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;g.set(d,b);for(const[v,M]of d)b.set(v,l(M,v,m,g,x));return b}if(d instanceof Set){const b=new Set;g.set(d,b);for(const v of d)b.add(l(v,void 0,m,g,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);g.set(d,b);for(let v=0;v<d.length;v++)b[v]=l(d[v],v,m,g,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 g.set(d,b),c(b,d,m,g,x),b}if(typeof File<"u"&&d instanceof File){const b=new File([d],d.name,{type:d.type});return g.set(d,b),c(b,d,m,g,x),b}if(typeof Blob<"u"&&d instanceof Blob){const b=new Blob([d],{type:d.type});return g.set(d,b),c(b,d,m,g,x),b}if(d instanceof Error){const b=new d.constructor;return g.set(d,b),b.message=d.message,b.name=d.name,b.stack=d.stack,b.cause=d.cause,c(b,d,m,g,x),b}if(d instanceof Boolean){const b=new Boolean(d.valueOf());return g.set(d,b),c(b,d,m,g,x),b}if(d instanceof Number){const b=new Number(d.valueOf());return g.set(d,b),c(b,d,m,g,x),b}if(d instanceof String){const b=new String(d.valueOf());return g.set(d,b),c(b,d,m,g,x),b}if(typeof d=="object"&&u(d)){const b=Object.create(Object.getPrototypeOf(d));return g.set(d,b),c(b,d,m,g,x),b}return d}function c(d,f,m=d,g,x){const y=[...Object.keys(f),...e.getSymbols(f)];for(let b=0;b<y.length;b++){const v=y[b],M=Object.getOwnPropertyDescriptor(d,v);(M==null||M.writable)&&(d[v]=l(f[v],v,m,g,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})(iT)),iT}var Jz;function tpe(){return Jz||(Jz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Gq();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(rT)),rT}var eB;function npe(){return eB||(eB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$q(),n=tpe();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(QA)),QA}var cT={},uT={},dT={},tB;function rpe(){return tB||(tB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Gq(),n=Vq();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})(dT)),dT}var nB;function ipe(){return nB||(nB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rpe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(uT)),uT}var hT={},fT={},rB;function Wq(){return rB||(rB=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})(fT)),fT}var mT={},iB;function ape(){return iB||(iB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Hq();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(mT)),mT}var aB;function spe(){return aB||(aB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Rq(),n=Wq(),r=ape(),i=pD();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})(hT)),hT}var sB;function ope(){return sB||(sB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$q(),n=mD(),r=ipe(),i=gD(),a=spe();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})(cT)),cT}var oB;function lpe(){return oB||(oB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Fq(),n=Qme(),r=npe(),i=ope();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})(XA)),XA}var lB;function cpe(){return lB||(lB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qme(),n=Fq(),r=Yme(),i=lpe();function a(o,l=n.identity){return r.isArrayLikeObject(o)?e.uniqBy(Array.from(o),i.iteratee(l)):[]}t.uniqBy=a})($A)),$A}var pT,cB;function upe(){return cB||(cB=1,pT=cpe().uniqBy),pT}var dpe=upe();const uB=Co(dpe);function qq(t,e,n){return e===!0?uB(t,n):typeof e=="function"?uB(t,e):t}var gT={exports:{}},xT={};var dB;function hpe(){if(dB)return xT;dB=1;var t=Ag(),e=iW();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 xT.useSyncExternalStoreWithSelector=function(u,d,f,m,g){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(k){if(!M){if(M=!0,S=k,k=m(k),g!==void 0&&y.hasValue){var C=y.value;if(g(C,k))return A=C}return A=k}if(C=A,r(S,k))return C;var R=m(k);return g!==void 0&&g(C,R)?(S=k,C):(S=k,A=R)}var M=!1,S,A,E=f===void 0?null:f;return[function(){return v(d())},E===null?void 0:function(){return v(E())}]},[d,f,m,g]);var b=i(u,x[0],x[1]);return o(function(){y.hasValue=!0,y.value=b},[b]),c(b),b},xT}var hB;function fpe(){return hB||(hB=1,gT.exports=hpe()),gT.exports}var Kq=fpe(),vD=w.createContext(null),mpe=t=>t,xr=()=>{var t=w.useContext(vD);return t?t.store.dispatch:mpe},O1=()=>{},ppe=()=>O1,gpe=(t,e)=>t===e;function Ot(t){var e=w.useContext(vD);return Kq.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:ppe,e?e.store.getState:O1,e?e.store.getState:O1,e?t:O1,gpe)}function xpe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function bpe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function ype(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 fB=t=>Array.isArray(t)?t:[t];function vpe(t){const e=Array.isArray(t[0])?t[0]:t;return ype(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function _pe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var wpe=class{constructor(t){this.value=t}deref(){return this.value}},Spe=typeof WeakRef<"u"?WeakRef:wpe,Mpe=0,mB=1;function Qv(){return{s:Mpe,v:void 0,o:null,p:null}}function Xq(t,e={}){let n=Qv();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 g=arguments[f];if(typeof g=="function"||typeof g=="object"&&g!==null){let x=l.o;x===null&&(l.o=x=new WeakMap);const y=x.get(g);y===void 0?(l=Qv(),x.set(g,l)):l=y}else{let x=l.p;x===null&&(l.p=x=new Map);const y=x.get(g);y===void 0?(l=Qv(),x.set(g,l)):l=y}}const u=l;let d;if(l.s===mB)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 Spe(d):d}return u.s=mB,u.v=d,d}return o.clearCache=()=>{n=Qv(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function Npe(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()),xpe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:m=[],argsMemoize:g=Xq,argsMemoizeOptions:x=[]}=d,y=fB(m),b=fB(x),v=vpe(i),M=f(function(){return a++,u.apply(null,arguments)},...y),S=g(function(){o++;const E=_pe(v,arguments);return l=M.apply(null,E),l},...b);return Object.assign(S,{resultFunc:u,memoizedResultFunc:M,dependencies:v,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:g})};return Object.assign(r,{withTypes:()=>r}),r}var et=Npe(Xq),Epe=Object.assign((t,e=et)=>{bpe(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:()=>Epe}),bT={},yT={},vT={},pB;function Ape(){return pB||(pB=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})(vT)),vT}var _T={},wT={},gB;function Yq(){return gB||(gB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(wT)),wT}var xB;function Tpe(){return xB||(xB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Yq(),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})(_T)),_T}var bB;function Cpe(){return bB||(bB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ape(),n=Tpe(),r=pD();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(g=>String(g));const u=(g,x)=>{let y=g;for(let b=0;b<x.length&&y!=null;++b)y=y[x[b]];return y},d=(g,x)=>x==null||g==null?x:typeof g=="object"&&"key"in g?Object.hasOwn(x,g.key)?x[g.key]:u(x,g.path):typeof g=="function"?g(x):Array.isArray(g)?u(x,g):typeof x=="object"?x[g]:x,f=o.map(g=>(Array.isArray(g)&&g.length===1&&(g=g[0]),g==null||typeof g=="function"||Array.isArray(g)||n.isKey(g)?g:{key:g,path:r.toPath(g)}));return a.map(g=>({original:g,criteria:f.map(x=>d(x,g))})).slice().sort((g,x)=>{for(let y=0;y<f.length;y++){const b=e.compareValues(g.criteria[y],x.criteria[y],l[y]);if(b!==0)return b}return 0}).map(g=>g.original)}t.orderBy=i})(yT)),yT}var ST={},yB;function kpe(){return yB||(yB=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})(ST)),ST}var MT={},vB;function Qq(){return vB||(vB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Wq(),n=yD(),r=Uq(),i=Bq();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})(MT)),MT}var _B;function jpe(){return _B||(_B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Cpe(),n=kpe(),r=Qq();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})(bT)),bT}var NT,wB;function Ppe(){return wB||(wB=1,NT=jpe().sortBy),NT}var Rpe=Ppe();const V2=Co(Rpe);var Zq=t=>t.legend.settings,Dpe=t=>t.legend.size,Ope=t=>t.legend.payload,Lpe=et([Ope,Zq],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?V2(r,n):r});function Ipe(){return Ot(Lpe)}var Zv=1;function Jq(){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)>Zv||Math.abs(o.left-e.left)>Zv||Math.abs(o.top-e.top)>Zv||Math.abs(o.width-e.width)>Zv)&&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 ua(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 Fpe=typeof Symbol=="function"&&Symbol.observable||"@@observable",SB=Fpe,ET=()=>Math.random().toString(36).substring(7).split("").join("."),Upe={INIT:`@@redux/INIT${ET()}`,REPLACE:`@@redux/REPLACE${ET()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ET()}`},ww=Upe;function _D(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 eK(t,e,n){if(typeof t!="function")throw new Error(ua(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(ua(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(ua(1));return n(eK)(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(ua(3));return i}function f(b){if(typeof b!="function")throw new Error(ua(4));if(c)throw new Error(ua(5));let v=!0;u();const M=l++;return o.set(M,b),function(){if(v){if(c)throw new Error(ua(6));v=!1,u(),o.delete(M),a=null}}}function m(b){if(!_D(b))throw new Error(ua(7));if(typeof b.type>"u")throw new Error(ua(8));if(typeof b.type!="string")throw new Error(ua(17));if(c)throw new Error(ua(9));try{c=!0,i=r(i,b)}finally{c=!1}return(a=o).forEach(M=>{M()}),b}function g(b){if(typeof b!="function")throw new Error(ua(10));r=b,m({type:ww.REPLACE})}function x(){const b=f;return{subscribe(v){if(typeof v!="object"||v===null)throw new Error(ua(11));function M(){const A=v;A.next&&A.next(d())}return M(),{unsubscribe:b(M)}},[SB](){return this}}}return m({type:ww.INIT}),{dispatch:m,subscribe:f,getState:d,replaceReducer:g,[SB]:x}}function zpe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:ww.INIT})>"u")throw new Error(ua(12));if(typeof n(void 0,{type:ww.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(ua(13))})}function tK(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{zpe(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],g=o[f],x=m(g,l);if(typeof x>"u")throw l&&l.type,new Error(ua(14));u[f]=x,c=c||x!==g}return c=c||r.length!==Object.keys(o).length,c?u:o}}function Sw(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function Bpe(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(ua(15))};const o={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},l=t.map(c=>c(o));return a=Sw(...l)(i.dispatch),{...i,dispatch:a}}}function nK(t){return _D(t)&&"type"in t&&typeof t.type=="string"}var rK=Symbol.for("immer-nothing"),MB=Symbol.for("immer-draftable"),qa=Symbol.for("immer-state");function Ho(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Fs=Object,ng=Fs.getPrototypeOf,Mw="constructor",G2="prototype",t3="configurable",Nw="enumerable",L1="writable",l0="value",nu=t=>!!t&&!!t[qa];function il(t){return t?iK(t)||W2(t)||!!t[MB]||!!t[Mw]?.[MB]||q2(t)||K2(t):!1}var $pe=Fs[G2][Mw].toString(),NB=new WeakMap;function iK(t){if(!t||!wD(t))return!1;const e=ng(t);if(e===null||e===Fs[G2])return!0;const n=Fs.hasOwnProperty.call(e,Mw)&&e[Mw];if(n===Object)return!0;if(!vp(n))return!1;let r=NB.get(n);return r===void 0&&(r=Function.toString.call(n),NB.set(n,r)),r===$pe}function ey(t,e,n=!0){ty(t)===0?(n?Reflect.ownKeys(t):Fs.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function ty(t){const e=t[qa];return e?e.type_:W2(t)?1:q2(t)?2:K2(t)?3:0}var EB=(t,e,n=ty(t))=>n===2?t.has(e):Fs[G2].hasOwnProperty.call(t,e),n3=(t,e,n=ty(t))=>n===2?t.get(e):t[e],Ew=(t,e,n,r=ty(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function Hpe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var W2=Array.isArray,q2=t=>t instanceof Map,K2=t=>t instanceof Set,wD=t=>typeof t=="object",vp=t=>typeof t=="function",AT=t=>typeof t=="boolean",Pc=t=>t.copy_||t.base_,SD=t=>t.modified_?t.copy_:t.base_;function r3(t,e){if(q2(t))return new Map(t);if(K2(t))return new Set(t);if(W2(t))return Array[G2].slice.call(t);const n=iK(t);if(e===!0||e==="class_only"&&!n){const r=Fs.getOwnPropertyDescriptors(t);delete r[qa];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l[L1]===!1&&(l[L1]=!0,l[t3]=!0),(l.get||l.set)&&(r[o]={[t3]:!0,[L1]:!0,[Nw]:l[Nw],[l0]:t[o]})}return Fs.create(ng(t),r)}else{const r=ng(t);if(r!==null&&n)return{...t};const i=Fs.create(r);return Fs.assign(i,t)}}function MD(t,e=!1){return X2(t)||nu(t)||!il(t)||(ty(t)>1&&Fs.defineProperties(t,{set:Jv,add:Jv,clear:Jv,delete:Jv}),Fs.freeze(t),e&&ey(t,(n,r)=>{MD(r,!0)},!1)),t}function Vpe(){Ho(2)}var Jv={[l0]:Vpe};function X2(t){return t===null||!wD(t)?!0:Fs.isFrozen(t)}var Aw="MapSet",i3="Patches",aK={};function rg(t){const e=aK[t];return e||Ho(0,t),e}var Gpe=t=>!!aK[t],c0,sK=()=>c0,Wpe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Gpe(Aw)?rg(Aw):void 0});function AB(t,e){e&&(t.patchPlugin_=rg(i3),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function a3(t){s3(t),t.drafts_.forEach(qpe),t.drafts_=null}function s3(t){t===c0&&(c0=t.parent_)}var TB=t=>c0=Wpe(c0,t);function qpe(t){const e=t[qa];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function CB(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[qa].modified_&&(a3(e),Ho(4)),il(t)&&(t=kB(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[qa].base_,t,e)}else t=kB(e,n);return Kpe(e,t,!0),a3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==rK?t:void 0}function kB(t,e){if(X2(e))return e;const n=e[qa];if(!n)return ND(e,t.handledSet_,t);if(!Y2(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);cK(n,t)}return n.copy_}function Kpe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&MD(e,n)}function oK(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var Y2=(t,e)=>t.scope_===e,Xpe=[];function lK(t,e,n,r){const i=Pc(t),a=t.type_;if(r!==void 0&&n3(i,r,a)===e){Ew(i,r,n,a);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;ey(i,(c,u)=>{if(nu(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??Xpe;for(const l of o)Ew(i,l,n,a)}function Ype(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!Y2(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=SD(a);lK(t,a.draft_??a,o,n),cK(a,i)})}function cK(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)}oK(t)}}function Qpe(t,e,n){const{scope_:r}=t;if(nu(n)){const i=n[qa];Y2(i,r)&&i.callbacks_.push(function(){I1(t);const o=SD(i);lK(t,n,o,e)})}else il(n)&&t.callbacks_.push(function(){const a=Pc(t);n3(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&ND(n3(t.copy_,e,t.type_),r.handledSet_,r)})}function ND(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||nu(t)||e.has(t)||!il(t)||X2(t)||(e.add(t),ey(t,(r,i)=>{if(nu(i)){const a=i[qa];if(Y2(a,n)){const o=SD(a);Ew(t,r,o,t.type_),oK(a)}}else il(i)&&ND(i,e,n)})),t}function Zpe(t,e){const n=W2(t),r={type_:n?1:0,scope_:e?e.scope_:sK(),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=ED;n&&(i=[r],a=u0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,[l,r]}var ED={get(t,e){if(e===qa)return t;const n=Pc(t);if(!EB(n,e,t.type_))return Jpe(t,n,e);const r=n[e];if(t.finalized_||!il(r))return r;if(r===TT(t.base_,e)){I1(t);const i=t.type_===1?+e:e,a=l3(t.scope_,r,t,i);return t.copy_[i]=a}return r},has(t,e){return e in Pc(t)},ownKeys(t){return Reflect.ownKeys(Pc(t))},set(t,e,n){const r=uK(Pc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=TT(Pc(t),e),a=i?.[qa];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(Hpe(n,i)&&(n!==void 0||EB(t.base_,e,t.type_)))return!0;I1(t),o3(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),Qpe(t,e,n)),!0},deleteProperty(t,e){return I1(t),TT(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),o3(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Pc(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[L1]:!0,[t3]:t.type_!==1||e!=="length",[Nw]:r[Nw],[l0]:n[e]}},defineProperty(){Ho(11)},getPrototypeOf(t){return ng(t.base_)},setPrototypeOf(){Ho(12)}},u0={};ey(ED,(t,e)=>{u0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});u0.deleteProperty=function(t,e){return u0.set.call(this,t,e,void 0)};u0.set=function(t,e,n){return ED.set.call(this,t[0],e,n,t[0])};function TT(t,e){const n=t[qa];return(n?Pc(n):t)[e]}function Jpe(t,e,n){const r=uK(e,n);return r?l0 in r?r[l0]:r.get?.call(t.draft_):void 0}function uK(t,e){if(!(e in t))return;let n=ng(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=ng(n)}}function o3(t){t.modified_||(t.modified_=!0,t.parent_&&o3(t.parent_))}function I1(t){t.copy_||(t.assigned_=new Map,t.copy_=r3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var ege=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(vp(n)&&!vp(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,f=>r.call(this,f,...d))}}vp(r)||Ho(6),i!==void 0&&!vp(i)&&Ho(7);let a;if(il(n)){const o=TB(this),l=l3(o,n,void 0);let c=!0;try{a=r(l),c=!1}finally{c?a3(o):s3(o)}return AB(o,i),CB(a,o)}else if(!n||!wD(n)){if(a=r(n),a===void 0&&(a=n),a===rK&&(a=void 0),this.autoFreeze_&&MD(a,!0),i){const o=[],l=[];rg(i3).generateReplacementPatches_(n,a,{patches_:o,inversePatches_:l}),i(o,l)}return a}else Ho(1,n)},this.produceWithPatches=(n,r)=>{if(vp(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]},AT(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),AT(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),AT(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){il(e)||Ho(8),nu(e)&&(e=Qo(e));const n=TB(this),r=l3(n,e,void 0);return r[qa].isManual_=!0,s3(n),r}finishDraft(e,n){const r=e&&e[qa];(!r||!r.isManual_)&&Ho(9);const{scope_:i}=r;return AB(i,n),CB(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=rg(i3).applyPatches_;return nu(e)?i(e,n):this.produce(e,a=>i(a,n))}};function l3(t,e,n,r){const[i,a]=q2(e)?rg(Aw).proxyMap_(e,n):K2(e)?rg(Aw).proxySet_(e,n):Zpe(e,n);return(n?.scope_??sK()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Ype(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 Qo(t){return nu(t)||Ho(10,t),dK(t)}function dK(t){if(!il(t)||X2(t))return t;const e=t[qa];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=r3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=r3(t,!0);return ey(n,(i,a)=>{Ew(n,i,dK(a))},r),e&&(e.finalized_=!1),n}var tge=new ege,hK=tge.produce;function fK(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var nge=fK(),rge=fK,ige=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Sw:Sw.apply(null,arguments)};function Ao(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(zs(0));return{type:t,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:t,payload:r[0]}}return n.toString=()=>`${t}`,n.type=t,n.match=r=>nK(r)&&r.type===t,n}var mK=class xb extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,xb.prototype)}static get[Symbol.species](){return xb}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new xb(...e[0].concat(this)):new xb(...e.concat(this))}};function jB(t){return il(t)?hK(t,()=>{}):t}function e_(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function age(t){return typeof t=="boolean"}var sge=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let o=new mK;return n&&(age(n)?o.push(nge):o.push(rge(n.extraArgument))),o},pK="RTK_autoBatch",kr=()=>t=>({payload:t,meta:{[pK]:!0}}),PB=t=>e=>{setTimeout(e,t)},gK=(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:PB(10):t.type==="callback"?t.queueNotification:PB(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?.[pK],a=!i,a&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},oge=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new mK(t);return r&&i.push(gK(typeof r=="object"?r:void 0)),i};function lge(t){const e=sge(),{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(_D(n))l=tK(n);else throw new Error(zs(1));let c;typeof r=="function"?c=r(e):c=e();let u=Sw;i&&(u=ige({trace:!1,...typeof i=="object"&&i}));const d=Bpe(...c),f=oge(d);let m=typeof o=="function"?o(f):f();const g=u(...m);return eK(l,a,g)}function xK(t){const e={},n=[];let r;const i={addCase(a,o){const l=typeof a=="string"?a:a.type;if(!l)throw new Error(zs(28));if(l in e)throw new Error(zs(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 cge(t){return typeof t=="function"}function uge(t,e){let[n,r,i]=xK(e),a;if(cge(t))a=()=>jB(t());else{const l=jB(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(nu(d)){const g=f(d,c);return g===void 0?d:g}else{if(il(d))return hK(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 dge="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",hge=(t=21)=>{let e="",n=t;for(;n--;)e+=dge[Math.random()*64|0];return e},fge=Symbol.for("rtk-slice-createasyncthunk");function mge(t,e){return`${t}/${e}`}function pge({creators:t}={}){const e=t?.asyncThunk?.[fge];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(zs(11));const o=(typeof r.reducers=="function"?r.reducers(xge()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(S,A){const E=typeof S=="string"?S:S.type;if(!E)throw new Error(zs(12));if(E in c.sliceCaseReducersByType)throw new Error(zs(13));return c.sliceCaseReducersByType[E]=A,u},addMatcher(S,A){return c.sliceMatchers.push({matcher:S,reducer:A}),u},exposeAction(S,A){return c.actionCreators[S]=A,u},exposeCaseReducer(S,A){return c.sliceCaseReducersByName[S]=A,u}};l.forEach(S=>{const A=o[S],E={reducerName:S,type:mge(i,S),createNotation:typeof r.reducers=="function"};yge(A)?_ge(E,A,u,e):bge(E,A,u)});function d(){const[S={},A=[],E=void 0]=typeof r.extraReducers=="function"?xK(r.extraReducers):[r.extraReducers],k={...S,...c.sliceCaseReducersByType};return uge(r.initialState,C=>{for(let R in k)C.addCase(R,k[R]);for(let R of c.sliceMatchers)C.addMatcher(R.matcher,R.reducer);for(let R of A)C.addMatcher(R.matcher,R.reducer);E&&C.addDefaultCase(E)})}const f=S=>S,m=new Map,g=new WeakMap;let x;function y(S,A){return x||(x=d()),x(S,A)}function b(){return x||(x=d()),x.getInitialState()}function v(S,A=!1){function E(C){let R=C[S];return typeof R>"u"&&A&&(R=e_(g,E,b)),R}function k(C=f){const R=e_(m,A,()=>new WeakMap);return e_(R,C,()=>{const T={};for(const[P,F]of Object.entries(r.selectors??{}))T[P]=gge(F,C,()=>e_(g,C,b),A);return T})}return{reducerPath:S,getSelectors:k,get selectors(){return k(E)},selectSlice:E}}const M={name:i,reducer:y,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:b,...v(a),injectInto(S,{reducerPath:A,...E}={}){const k=A??a;return S.inject({reducerPath:k,reducer:y},E),{...M,...v(k,!0)}}};return M}}function gge(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 ys=pge();function xge(){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 bge({type:t,reducerName:e,createNotation:n},r,i){let a,o;if("reducer"in r){if(n&&!vge(r))throw new Error(zs(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,o?Ao(t,o):Ao(t))}function yge(t){return t._reducerDefinitionType==="asyncThunk"}function vge(t){return t._reducerDefinitionType==="reducerWithPrepare"}function _ge({type:t,reducerName:e},n,r,i){if(!i)throw new Error(zs(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||t_,pending:l||t_,rejected:c||t_,settled:u||t_})}function t_(){}var wge="task",bK="listener",yK="completed",AD="cancelled",Sge=`task-${AD}`,Mge=`task-${yK}`,c3=`${bK}-${AD}`,Nge=`${bK}-${yK}`,Q2=class{constructor(t){this.code=t,this.message=`${wge} ${AD} (reason: ${t})`}name="TaskAbortError";message},TD=(t,e)=>{if(typeof t!="function")throw new TypeError(zs(32))},Tw=()=>{},vK=(t,e=Tw)=>(t.catch(e),t),_K=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),rf=(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))},af=t=>{if(t.aborted){const{reason:e}=t;throw new Q2(e)}};function wK(t,e){let n=Tw;return new Promise((r,i)=>{const a=()=>i(new Q2(t.reason));if(t.aborted){a();return}n=_K(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=Tw})}var Ege=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof Q2?"cancelled":"rejected",error:n}}finally{e?.()}},Cw=t=>e=>vK(wK(t,e).then(n=>(af(t),n))),SK=t=>{const e=Cw(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:Lp}=Object,RB={},Z2="listenerMiddleware",Age=(t,e)=>{const n=r=>_K(t,()=>rf(r,t.reason));return(r,i)=>{TD(r);const a=new AbortController;n(a);const o=Ege(async()=>{af(t),af(a.signal);const l=await r({pause:Cw(a.signal),delay:SK(a.signal),signal:a.signal});return af(a.signal),l},()=>rf(a,Mge));return i?.autoJoin&&e.push(o.catch(Tw)),{result:Cw(t)(o),cancel(){rf(a,Sge)}}}},Tge=(t,e)=>{const n=async(r,i)=>{af(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 wK(e,Promise.race(l));return af(e),c}finally{a()}};return(r,i)=>vK(n(r,i))},MK=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=Ao(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(zs(21));return TD(a),{predicate:i,type:e,effect:a}},NK=Lp(t=>{const{type:e,predicate:n,effect:r}=MK(t);return{id:hge(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(zs(22))}}},{withTypes:()=>NK}),DB=(t,e)=>{const{type:n,effect:r,predicate:i}=MK(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},u3=t=>{t.pending.forEach(e=>{rf(e,c3)})},Cge=(t,e)=>()=>{for(const n of e.keys())u3(n);t.clear()},OB=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},EK=Lp(Ao(`${Z2}/add`),{withTypes:()=>EK}),kge=Ao(`${Z2}/removeAll`),AK=Lp(Ao(`${Z2}/remove`),{withTypes:()=>AK}),jge=(...t)=>{console.error(`${Z2}/error`,...t)},ny=(t={})=>{const e=new Map,n=new Map,r=g=>{const x=n.get(g)??0;n.set(g,x+1)},i=g=>{const x=n.get(g)??1;x===1?n.delete(g):n.set(g,x-1)},{extra:a,onError:o=jge}=t;TD(o);const l=g=>(g.unsubscribe=()=>e.delete(g.id),e.set(g.id,g),x=>{g.unsubscribe(),x?.cancelActive&&u3(g)}),c=g=>{const x=DB(e,g)??NK(g);return l(x)};Lp(c,{withTypes:()=>c});const u=g=>{const x=DB(e,g);return x&&(x.unsubscribe(),g.cancelActive&&u3(x)),!!x};Lp(u,{withTypes:()=>u});const d=async(g,x,y,b)=>{const v=new AbortController,M=Tge(c,v.signal),S=[];try{g.pending.add(v),r(g),await Promise.resolve(g.effect(x,Lp({},y,{getOriginalState:b,condition:(A,E)=>M(A,E).then(Boolean),take:M,delay:SK(v.signal),pause:Cw(v.signal),extra:a,signal:v.signal,fork:Age(v.signal,S),unsubscribe:g.unsubscribe,subscribe:()=>{e.set(g.id,g)},cancelActiveListeners:()=>{g.pending.forEach((A,E,k)=>{A!==v&&(rf(A,c3),k.delete(A))})},cancel:()=>{rf(v,c3),g.pending.delete(v)},throwIfCancelled:()=>{af(v.signal)}})))}catch(A){A instanceof Q2||OB(o,A,{raisedBy:"effect"})}finally{await Promise.all(S),rf(v,Nge),i(g),g.pending.delete(v)}},f=Cge(e,n);return{middleware:g=>x=>y=>{if(!nK(y))return x(y);if(EK.match(y))return c(y.payload);if(kge.match(y)){f();return}if(AK.match(y))return u(y.payload);let b=g.getState();const v=()=>{if(b===RB)throw new Error(zs(23));return b};let M;try{if(M=x(y),e.size>0){const S=g.getState(),A=Array.from(e.values());for(const E of A){let k=!1;try{k=E.predicate(y,S,b)}catch(C){k=!1,OB(o,C,{raisedBy:"predicate"})}k&&d(E,y,g,v)}}}finally{b=RB}return M},startListening:c,stopListening:u,clearListeners:f}};function zs(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 Pge={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},TK=ys({name:"chartLayout",initialState:Pge,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:Rge,setLayout:Dge,setChartSize:Oge,setScale:Lge}=TK.actions,Ige=TK.reducer;function CK(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function LB(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 Ap(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?LB(Object(n),!0).forEach(function(r){Fge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):LB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Fge(t,e,n){return(e=Uge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Uge(t){var e=zge(t,"string");return typeof e=="symbol"?e:e+""}function zge(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 er(t,e,n){return Ar(t)||Ar(e)?n:Eo(e)?Ef(t,e,n):typeof e=="function"?e(t):n}var Bge=(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"&&Ft(t[a]))return Ap(Ap({},t),{},{[a]:t[a]+(r||0)});if((l==="horizontal"||l==="vertical"&&a==="center")&&o!=="middle"&&Ft(t[o]))return Ap(Ap({},t),{},{[o]:t[o]+(i||0)})}return t},Wl=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",kK=(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},jK=(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:g}=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=g==="angleAxis"&&a&&a.length>=2?Xi(a[0]-a[1])*2*y:y,f||m){var b=(f||m||[]).map((v,M)=>{var S=r?r.indexOf(v):v;return{coordinate:o(S)+y,value:v,offset:y,index:M}});return b.filter(v=>!bs(v.coordinate))}return c&&u?u.map((v,M)=>({coordinate:o(v)+y,value:v,index:M,offset:y})):o.ticks&&d!=null?o.ticks(d).map((v,M)=>({coordinate:o(v)+y,value:v,offset:y,index:M})):o.domain().map((v,M)=>({coordinate:o(v)+y,value:r?r[v]:v,index:M,offset:y}))},IB=1e-4,$ge=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-IB,a=Math.max(r[0],r[1])+IB,o=t(e[0]),l=t(e[n-1]);(o<i||o>a||l<i||l>a)&&t.domain([e[0],e[n-1]])}},Hge=(t,e)=>{if(!e||e.length!==2||!Ft(e[0])||!Ft(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(!Ft(t[0])||t[0]<n)&&(i[0]=n),(!Ft(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},Vge=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=bs(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])}},Gge=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=bs(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)}},Wge={sign:Vge,expand:pme,none:tg,silhouette:gme,wiggle:xme,positive:Gge},qge=(t,e,n)=>{var r=Wge[n],i=mme().keys(e).value((a,o)=>Number(er(a,o,0))).order(Jj).offset(r);return i(t)};function PK(t){return t==null?void 0:String(t)}function kw(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Ar(i[e.dataKey])){var l=Oq(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n[a]?n[a].coordinate+r/2:null}var c=er(i,Ar(o)?e.dataKey:o);return Ar(c)?null:e.scale(c)}var FB=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=er(a,e.dataKey,e.scale.domain()[o]);return Ar(l)?null:e.scale(l)-i/2+r},Kge=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]},Xge=t=>{var e=t.flat(2).filter(Ft);return[Math.min(...e),Math.max(...e)]},Yge=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],Qge=(t,e,n)=>{if(t!=null)return Yge(Object.keys(t).reduce((r,i)=>{var a=t[i],{stackedData:o}=a,l=o.reduce((c,u)=>{var d=CK(u,e,n),f=Xge(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]))},UB=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,zB=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Ld=(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=V2(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 BB(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return Ap(Ap({},e),{},{dataKey:n,payload:r,value:i,name:a})}function Qd(t,e){if(t)return String(t);if(typeof e=="string")return e}var Zge=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Jge=(t,e)=>e==="centric"?t.angle:t.radius,du=t=>t.layout.width,hu=t=>t.layout.height,exe=t=>t.layout.scale,RK=t=>t.layout.margin,J2=et(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),eM=et(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),DK="data-recharts-item-index",OK="data-recharts-item-data-key",ry=60;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 n_(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){txe(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 txe(t,e,n){return(e=nxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nxe(t){var e=rxe(t,"string");return typeof e=="symbol"?e:e+""}function rxe(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 ixe=t=>t.brush.height;function axe(t){var e=eM(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:ry;return n+i}return n},0)}function sxe(t){var e=eM(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:ry;return n+i}return n},0)}function oxe(t){var e=J2(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function lxe(t){var e=J2(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var ji=et([du,hu,RK,ixe,axe,sxe,oxe,lxe,Zq,Dpe],(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=n_(n_({},f),d),g=m.bottom;m.bottom+=r,m=Bge(m,c,u);var x=t-m.left-m.right,y=e-m.top-m.bottom;return n_(n_({brushBottom:g},m),{},{width:Math.max(x,0),height:Math.max(y,0)})}),cxe=et(ji,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),CD=et(du,hu,(t,e)=>({x:0,y:0,width:t,height:e})),uxe=w.createContext(null),Pi=()=>w.useContext(uxe)!=null,tM=t=>t.brush,nM=et([tM,ji,RK],(t,e,n)=>({height:t.height,x:Ft(t.x)?t.x:e.left,y:Ft(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Ft(t.width)?t.width:e.width})),CT={},kT={},jT={},HB;function dxe(){return HB||(HB=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 g=()=>{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(...M){if(i?.aborted)return;o=this,l=M;const S=m==null;g(),c&&S&&d()};return v.schedule=g,v.cancel=y,v.flush=b,i?.addEventListener("abort",y,{once:!0}),v}t.debounce=e})(jT)),jT}var VB;function hxe(){return VB||(VB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=dxe();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:o=!1,trailing:l=!0,maxWait:c}=a,u=Array(2);o&&(u[0]="leading"),l&&(u[1]="trailing");let d,f=null;const m=e.debounce(function(...y){d=r.apply(this,y),f=null},i,{edges:u}),g=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 g.cancel=m.cancel,g.flush=x,g}t.debounce=n})(kT)),kT}var GB;function fxe(){return GB||(GB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=hxe();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})(CT)),CT}var PT,WB;function mxe(){return WB||(WB=1,PT=fxe().throttle),PT}var pxe=mxe();const gxe=Co(pxe);var jw=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++]))}},LK=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:a,maxHeight:o}=n,l=tu(r)?t:Number(r),c=tu(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}},xxe={width:0,height:0,overflow:"visible"},bxe={width:0,overflowX:"visible"},yxe={height:0,overflowY:"visible"},vxe={},_xe=t=>{var{width:e,height:n}=t,r=tu(e),i=tu(n);return r&&i?xxe:r?bxe:i?yxe:vxe};function wxe(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 tr(t){return Number.isFinite(t)}function Ll(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function d3(){return d3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},d3.apply(null,arguments)}function qB(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 KB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qB(Object(n),!0).forEach(function(r){Sxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Sxe(t,e,n){return(e=Mxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Mxe(t){var e=Nxe(t,"string");return typeof e=="symbol"?e:e+""}function Nxe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var IK=w.createContext({width:-1,height:-1});function Exe(t){return Ll(t.width)&&Ll(t.height)}function FK(t){var{children:e,width:n,height:r}=t,i=w.useMemo(()=>({width:n,height:r}),[n,r]);return Exe(i)?w.createElement(IK.Provider,{value:i},e):null}var kD=()=>w.useContext(IK),Axe=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:g,style:x={}}=t,y=w.useRef(null),b=w.useRef();b.current=g,w.useImperativeHandle(e,()=>y.current);var[v,M]=w.useState({containerWidth:r.width,containerHeight:r.height}),S=w.useCallback((R,T)=>{M(P=>{var F=Math.round(R),L=Math.round(T);return P.containerWidth===F&&P.containerHeight===L?P:{containerWidth:F,containerHeight:L}})},[]);w.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return Z0;var R=L=>{var X,{width:D,height:K}=L[0].contentRect;S(D,K),(X=b.current)===null||X===void 0||X.call(b,D,K)};d>0&&(R=gxe(R,d,{trailing:!0,leading:!1}));var T=new ResizeObserver(R),{width:P,height:F}=y.current.getBoundingClientRect();return S(P,F),T.observe(y.current),()=>{T.disconnect()}},[S,d]);var{containerWidth:A,containerHeight:E}=v;jw(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:k,calculatedHeight:C}=LK(A,E,{width:i,height:a,aspect:n,maxHeight:c});return jw(k!=null&&k>0||C!=null&&C>0,`The width(%s) and height(%s) of chart should be greater than 0,
- please check the style of container, or the props width(%s) and height(%s),
- or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
- height and width.`,k,C,i,a,o,l,n),w.createElement("div",{id:f?"".concat(f):void 0,className:In("recharts-responsive-container",m),style:KB(KB({},x),{},{width:i,height:a,minWidth:o,minHeight:l,maxHeight:c}),ref:y},w.createElement("div",{style:_xe({width:i,height:a})},w.createElement(FK,{width:k,height:C},u)))}),F1=w.forwardRef((t,e)=>{var n=kD();if(Ll(n.width)&&Ll(n.height))return t.children;var{width:r,height:i}=wxe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:o}=LK(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Ft(a)&&Ft(o)?w.createElement(FK,{width:a,height:o},t.children):w.createElement(Axe,d3({},t,{width:r,height:i,ref:e}))});function UK(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 iy=()=>{var t,e=Pi(),n=Ot(cxe),r=Ot(nM),i=(t=Ot(tM))===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}},Txe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},zK=()=>{var t;return(t=Ot(ji))!==null&&t!==void 0?t:Txe},jD=()=>Ot(du),PD=()=>Ot(hu),Cxe=()=>Ot(t=>t.layout.margin),kn=t=>t.layout.layoutType,Gf=()=>Ot(kn),kxe=()=>{var t=Gf();if(t==="horizontal"||t==="vertical")return t},jxe=()=>{var t=Gf();return t!==void 0},rM=t=>{var e=xr(),n=Pi(),{width:r,height:i}=t,a=kD(),o=r,l=i;return a&&(o=a.width>0?a.width:r,l=a.height>0?a.height:i),w.useEffect(()=>{!n&&Ll(o)&&Ll(l)&&e(Oge({width:o,height:l}))},[e,n,o,l]),null},BK=Symbol.for("immer-nothing"),XB=Symbol.for("immer-draftable"),Ws=Symbol.for("immer-state");function Vo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var d0=Object.getPrototypeOf;function ig(t){return!!t&&!!t[Ws]}function Af(t){return t?$K(t)||Array.isArray(t)||!!t[XB]||!!t.constructor?.[XB]||ay(t)||aM(t):!1}var Pxe=Object.prototype.constructor.toString(),YB=new WeakMap;function $K(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=YB.get(n);return r===void 0&&(r=Function.toString.call(n),YB.set(n,r)),r===Pxe}function Pw(t,e,n=!0){iM(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 iM(t){const e=t[Ws];return e?e.type_:Array.isArray(t)?1:ay(t)?2:aM(t)?3:0}function h3(t,e){return iM(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function HK(t,e,n){const r=iM(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function Rxe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function ay(t){return t instanceof Map}function aM(t){return t instanceof Set}function Dh(t){return t.copy_||t.base_}function f3(t,e){if(ay(t))return new Map(t);if(aM(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=$K(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Ws];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(d0(t),r)}else{const r=d0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function RD(t,e=!1){return sM(t)||ig(t)||!Af(t)||(iM(t)>1&&Object.defineProperties(t,{set:r_,add:r_,clear:r_,delete:r_}),Object.freeze(t),e&&Object.values(t).forEach(n=>RD(n,!0))),t}function Dxe(){Vo(2)}var r_={value:Dxe};function sM(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var Oxe={};function Tf(t){const e=Oxe[t];return e||Vo(0,t),e}var h0;function VK(){return h0}function Lxe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function QB(t,e){e&&(Tf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function m3(t){p3(t),t.drafts_.forEach(Ixe),t.drafts_=null}function p3(t){t===h0&&(h0=t.parent_)}function ZB(t){return h0=Lxe(h0,t)}function Ixe(t){const e=t[Ws];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function JB(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Ws].modified_&&(m3(e),Vo(4)),Af(t)&&(t=Rw(e,t),e.parent_||Dw(e,t)),e.patches_&&Tf("Patches").generateReplacementPatches_(n[Ws].base_,t,e.patches_,e.inversePatches_)):t=Rw(e,n,[]),m3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==BK?t:void 0}function Rw(t,e,n){if(sM(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Ws];if(!i)return Pw(e,(a,o)=>e8(t,i,e,a,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return Dw(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),Pw(o,(c,u)=>e8(t,i,a,c,u,n,l),r),Dw(t,a,!1),n&&t.patches_&&Tf("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function e8(t,e,n,r,i,a,o){if(i==null||typeof i!="object"&&!o)return;const l=sM(i);if(!(l&&!o)){if(ig(i)){const c=a&&e&&e.type_!==3&&!h3(e.assigned_,r)?a.concat(r):void 0,u=Rw(t,i,c);if(HK(n,r,u),ig(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(Af(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;Rw(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(ay(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&Dw(t,i)}}}function Dw(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&RD(e,n)}function Fxe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:VK(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=DD;n&&(i=[r],a=f0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,l}var DD={get(t,e){if(e===Ws)return t;const n=Dh(t);if(!h3(n,e))return Uxe(t,n,e);const r=n[e];return t.finalized_||!Af(r)?r:r===RT(t.base_,e)?(DT(t),t.copy_[e]=x3(r,t)):r},has(t,e){return e in Dh(t)},ownKeys(t){return Reflect.ownKeys(Dh(t))},set(t,e,n){const r=GK(Dh(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=RT(Dh(t),e),a=i?.[Ws];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(Rxe(n,i)&&(n!==void 0||h3(t.base_,e)))return!0;DT(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_[e]=!0),!0},deleteProperty(t,e){return RT(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,DT(t),g3(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Dh(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Vo(11)},getPrototypeOf(t){return d0(t.base_)},setPrototypeOf(){Vo(12)}},f0={};Pw(DD,(t,e)=>{f0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});f0.deleteProperty=function(t,e){return f0.set.call(this,t,e,void 0)};f0.set=function(t,e,n){return DD.set.call(this,t[0],e,n,t[0])};function RT(t,e){const n=t[Ws];return(n?Dh(n):t)[e]}function Uxe(t,e,n){const r=GK(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function GK(t,e){if(!(e in t))return;let n=d0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=d0(n)}}function g3(t){t.modified_||(t.modified_=!0,t.parent_&&g3(t.parent_))}function DT(t){t.copy_||(t.copy_=f3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var zxe=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"&&Vo(6),r!==void 0&&typeof r!="function"&&Vo(7);let i;if(Af(e)){const a=ZB(this),o=x3(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?m3(a):p3(a)}return QB(a,r),JB(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===BK&&(i=void 0),this.autoFreeze_&&RD(i,!0),r){const a=[],o=[];Tf("Patches").generateReplacementPatches_(e,i,a,o),r(a,o)}return i}else Vo(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){Af(t)||Vo(8),ig(t)&&(t=Bxe(t));const e=ZB(this),n=x3(t,void 0);return n[Ws].isManual_=!0,p3(e),n}finishDraft(t,e){const n=t&&t[Ws];(!n||!n.isManual_)&&Vo(9);const{scope_:r}=n;return QB(r,e),JB(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=Tf("Patches").applyPatches_;return ig(t)?r(t,e):this.produce(t,i=>r(i,e))}};function x3(t,e){const n=ay(t)?Tf("MapSet").proxyMap_(t,e):aM(t)?Tf("MapSet").proxySet_(t,e):Fxe(t,e);return(e?e.scope_:VK()).drafts_.push(n),n}function Bxe(t){return ig(t)||Vo(10,t),WK(t)}function WK(t){if(!Af(t)||sM(t))return t;const e=t[Ws];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=f3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=f3(t,!0);return Pw(n,(i,a)=>{HK(n,i,WK(a))},r),e&&(e.finalized_=!1),n}var $xe=new zxe;$xe.produce;var Hxe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},qK=ys({name:"legend",initialState:Hxe,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:kr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Qo(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:kr()},removeLegendPayload:{reducer(t,e){var n=Qo(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:kr()}}}),{setLegendSize:t8,setLegendSettings:Vxe,addLegendPayload:KK,replaceLegendPayload:XK,removeLegendPayload:YK}=qK.actions,Gxe=qK.reducer,Wxe=["contextPayload"];function b3(){return b3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},b3.apply(null,arguments)}function n8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ag(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?n8(Object(n),!0).forEach(function(r){qxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):n8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qxe(t,e,n){return(e=Kxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Kxe(t){var e=Xxe(t,"string");return typeof e=="symbol"?e:e+""}function Xxe(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 Yxe(t,e){if(t==null)return{};var n,r,i=Qxe(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 Qxe(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 Zxe(t){return t.value}function Jxe(t){var{contextPayload:e}=t,n=Yxe(t,Wxe),r=qq(e,t.payloadUniqBy,Zxe),i=ag(ag({},n),{},{payload:r});return w.isValidElement(t.content)?w.cloneElement(t.content,i):typeof t.content=="function"?w.createElement(t.content,i):w.createElement(Wme,i)}function ebe(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}),ag(ag({},u),d)}function tbe(t){var e=xr();return w.useEffect(()=>{e(Vxe(t))},[e,t]),null}function nbe(t){var e=xr();return w.useEffect(()=>(e(t8(t)),()=>{e(t8({width:0,height:0}))}),[e,t]),null}function rbe(t,e,n,r){return t==="vertical"&&Ft(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var ibe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function OD(t){var e=Ur(t,ibe),n=Ipe(),r=Ffe(),i=Cxe(),{width:a,height:o,wrapperStyle:l,portal:c}=e,[u,d]=Jq([n]),f=jD(),m=PD();if(f==null||m==null)return null;var g=f-(i?.left||0)-(i?.right||0),x=rbe(e.layout,o,a,g),y=c?l:ag(ag({position:"absolute",width:x?.width||a||"auto",height:x?.height||o||"auto"},ebe(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(tbe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&w.createElement(nbe,{width:u.width,height:u.height}),w.createElement(Jxe,b3({},e,x,{margin:i,chartWidth:f,chartHeight:m,contextPayload:n})));return Ic.createPortal(v,b)}OD.displayName="Legend";function y3(){return y3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},y3.apply(null,arguments)}function r8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function OT(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?r8(Object(n),!0).forEach(function(r){abe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function abe(t,e,n){return(e=sbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sbe(t){var e=obe(t,"string");return typeof e=="symbol"?e:e+""}function obe(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 lbe(t){return Array.isArray(t)&&Eo(t[0])&&Eo(t[1])?t.join(" ~ "):t}var cbe=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,g=()=>{if(a&&a.length){var E={padding:0,margin:0},k=(l?V2(a,l):a).map((C,R)=>{if(C.type==="none")return null;var T=C.formatter||o||lbe,{value:P,name:F}=C,L=P,X=F;if(T){var D=T(P,F,C,R,a);if(Array.isArray(D))[L,X]=D;else if(D!=null)L=D;else return null}var K=OT({display:"block",paddingTop:4,paddingBottom:4,color:C.color||"#000"},r);return w.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(R),style:K},Eo(X)?w.createElement("span",{className:"recharts-tooltip-item-name"},X):null,Eo(X)?w.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,w.createElement("span",{className:"recharts-tooltip-item-value"},L),w.createElement("span",{className:"recharts-tooltip-item-unit"},C.unit||""))});return w.createElement("ul",{className:"recharts-tooltip-item-list",style:E},k)}return null},x=OT({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),y=OT({margin:0},i),b=!Ar(d),v=b?d:"",M=In("recharts-default-tooltip",c),S=In("recharts-tooltip-label",u);b&&f&&a!==void 0&&a!==null&&(v=f(d,a));var A=m?{role:"status","aria-live":"assertive"}:{};return w.createElement("div",y3({className:M,style:x},A),w.createElement("p",{className:S,style:y},w.isValidElement(v)?v:"".concat(v)),g())},Vx="recharts-tooltip-wrapper",ube={visibility:"hidden"};function dbe(t){var{coordinate:e,translateX:n,translateY:r}=t;return In(Vx,{["".concat(Vx,"-right")]:Ft(n)&&e&&Ft(e.x)&&n>=e.x,["".concat(Vx,"-left")]:Ft(n)&&e&&Ft(e.x)&&n<e.x,["".concat(Vx,"-bottom")]:Ft(r)&&e&&Ft(e.y)&&r>=e.y,["".concat(Vx,"-top")]:Ft(r)&&e&&Ft(e.y)&&r<e.y})}function i8(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:a,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(a&&Ft(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 g=d,x=m;return g<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 hbe(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 fbe(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=i8({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),f=i8({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),u=hbe({translateX:d,translateY:f,useTranslate3d:l})):u=ube,{cssProperties:u,cssClasses:dbe({translateX:d,translateY:f,coordinate:n})}}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 i_(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){v3(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 v3(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=pbe(t,"string");return typeof e=="symbol"?e:e+""}function pbe(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 gbe extends w.PureComponent{constructor(){super(...arguments),v3(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),v3(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:g,wrapperStyle:x,lastBoundingBox:y,innerRef:b,hasPortalFromProps:v}=this.props,{cssClasses:M,cssProperties:S}=fbe({allowEscapeViewBox:n,coordinate:o,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:y.height,width:y.width},useTranslate3d:m,viewBox:g}),A=v?{}:i_(i_({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=i_(i_({},A),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},x);return w.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:M,style:E,ref:b},a)}}var QK=()=>{var t;return(t=Ot(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function _3(){return _3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_3.apply(null,arguments)}function 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 o8(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){xbe(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 xbe(t,e,n){return(e=bbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bbe(t){var e=ybe(t,"string");return typeof e=="symbol"?e:e+""}function ybe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var l8={curveBasisClosed:rme,curveBasisOpen:ime,curveBasis:nme,curveBumpX:$fe,curveBumpY:Hfe,curveLinearClosed:ame,curveLinear:$2,curveMonotoneX:sme,curveMonotoneY:ome,curveNatural:lme,curveStep:cme,curveStepAfter:dme,curveStepBefore:ume},Ow=t=>tr(t.x)&&tr(t.y),c8=t=>t.base!=null&&Ow(t.base)&&Ow(t),Gx=t=>t.x,Wx=t=>t.y,vbe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Q0(t));return(n==="curveMonotone"||n==="curveBump")&&e?l8["".concat(n).concat(e==="vertical"?"Y":"X")]:l8[n]||$2},_be=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:a=!1}=t,o=vbe(e,i),l=a?n.filter(Ow):n,c;if(Array.isArray(r)){var u=n.map((g,x)=>o8(o8({},g),{},{base:r[x]}));i==="vertical"?c=Yv().y(Wx).x1(Gx).x0(g=>g.base.x):c=Yv().x(Gx).y1(Wx).y0(g=>g.base.y);var d=c.defined(c8).curve(o),f=a?u.filter(c8):u;return d(f)}i==="vertical"&&Ft(r)?c=Yv().y(Wx).x1(Gx).x0(r):Ft(r)?c=Yv().x(Gx).y1(Wx).y0(r):c=wq().x(Gx).y(Wx);var m=c.defined(Ow).curve(o);return m(l)},Ip=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var a=n&&n.length?_be(t):r;return w.createElement("path",_3({},Wa(t),bD(t),{className:In("recharts-curve",e),d:a===null?void 0:a,ref:i}))},wbe=["x","y","top","left","width","height","className"];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 u8(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 Sbe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?u8(Object(n),!0).forEach(function(r){Mbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Mbe(t,e,n){return(e=Nbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Nbe(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 Abe(t,e){if(t==null)return{};var n,r,i=Tbe(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 Tbe(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 Cbe=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),kbe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:o=0,className:l}=t,c=Abe(t,wbe),u=Sbe({x:e,y:n,top:r,left:i,width:a,height:o},c);return!Ft(e)||!Ft(n)||!Ft(a)||!Ft(o)||!Ft(r)||!Ft(i)?null:w.createElement("path",w3({},ya(u),{className:In("recharts-cross",l),d:Cbe(e,n,a,o,r,i)}))};function jbe(t,e,n,r){var i=r/2;return{stroke:"none",fill:"#ccc",x:t==="horizontal"?e.x-i:n.left+.5,y:t==="horizontal"?n.top+.5:e.y-i,width:t==="horizontal"?r:n.width-1,height:t==="horizontal"?n.height-1:r}}function 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 h8(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){Pbe(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 Pbe(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)}var Obe=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),ZK=(t,e,n)=>t.map(r=>"".concat(Obe(r)," ").concat(e,"ms ").concat(n)).join(","),Lbe=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),m0=(t,e)=>Object.keys(e).reduce((n,r)=>h8(h8({},n),{},{[r]:t(r,e[r])}),{});function f8(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 Ni(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?f8(Object(n),!0).forEach(function(r){Ibe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):f8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ibe(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=Ube(t,"string");return typeof e=="symbol"?e:e+""}function Ube(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 Lw=(t,e,n)=>t+(e-t)*n,S3=t=>{var{from:e,to:n}=t;return e!==n},JK=(t,e,n)=>{var r=m0((i,a)=>{if(S3(a)){var[o,l]=t(a.from,a.to,a.velocity);return Ni(Ni({},a),{},{from:o,velocity:l})}return a},e);return n<1?m0((i,a)=>S3(a)?Ni(Ni({},a),{},{velocity:Lw(a.velocity,r[i].velocity,n),from:Lw(a.from,r[i].from,n)}):a,e):JK(t,r,n-1)};function zbe(t,e,n,r,i,a){var o,l=r.reduce((m,g)=>Ni(Ni({},m),{},{[g]:{from:t[g],velocity:0,to:e[g]}}),{}),c=()=>m0((m,g)=>g.from,l),u=()=>!Object.values(l).filter(S3).length,d=null,f=m=>{o||(o=m);var g=m-o,x=g/n.dt;l=JK(n,l,x),i(Ni(Ni(Ni({},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 Bbe(t,e,n,r,i,a,o){var l=null,c=i.reduce((f,m)=>Ni(Ni({},f),{},{[m]:[t[m],e[m]]}),{}),u,d=f=>{u||(u=f);var m=(f-u)/r,g=m0((y,b)=>Lw(...b,n(m)),c);if(a(Ni(Ni(Ni({},t),e),g)),m<1)l=o.setTimeout(d);else{var x=m0((y,b)=>Lw(...b,n(1)),c);a(Ni(Ni(Ni({},t),e),x))}};return()=>(l=o.setTimeout(d),()=>{var f;(f=l)===null||f===void 0||f()})}const $be=(t,e,n,r,i,a)=>{var o=Lbe(t,e);return n==null?()=>(i(Ni(Ni({},t),e)),()=>{}):n.isStepper===!0?zbe(t,e,n,o,i,a):Bbe(t,e,n,r,o,i,a)};var Iw=1e-4,eX=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],tX=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),m8=(t,e)=>n=>{var r=eX(t,e);return tX(r,n)},Hbe=(t,e)=>n=>{var r=eX(t,e),i=[...r.map((a,o)=>a*o).slice(1),0];return tX(i,n)},Vbe=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]},Gbe=(t,e,n,r)=>{var i=m8(t,n),a=m8(e,r),o=Hbe(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 g=i(f)-d,x=o(f);if(Math.abs(g-d)<Iw||x<Iw)return a(f);f=l(f-g/x)}return a(f)};return c.isStepper=!1,c},p8=function(){return Gbe(...Vbe(...arguments))},Wbe=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)<Iw&&Math.abs(f)<Iw?[l,0]:[m,f]};return a.isStepper=!0,a.dt=i,a},qbe=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return p8(t);case"spring":return Wbe();default:if(t.split("(")[0]==="cubic-bezier")return p8(t)}return typeof t=="function"?t:null};function Kbe(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 Xbe{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 Ybe(){return Kbe(new Xbe)}var Qbe=w.createContext(Ybe);function Zbe(t,e){var n=w.useContext(Qbe);return w.useMemo(()=>e??n(t),[t,e,n])}var Jbe=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Rg={devToolsEnabled:!1,isSsr:Jbe()},e0e={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},g8={t:0},LT={t:1};function Dg(t){var e=Ur(t,e0e),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!Rg.isSsr:n,f=Zbe(e.animationId,e.animationManager),[m,g]=w.useState(d?g8:LT),x=w.useRef(null);return w.useEffect(()=>{d||g(LT)},[d]),w.useEffect(()=>{if(!d||!r)return Z0;var y=$be(g8,LT,qbe(a),i,g,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 Og(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=w.useRef(o0(e)),r=w.useRef(t);return r.current!==t&&(n.current=o0(e),r.current=t),n.current}var t0e=["radius"],n0e=["radius"];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){r0e(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 r0e(t,e,n){return(e=i0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i0e(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)}function Fw(){return Fw=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},Fw.apply(null,arguments)}function y8(t,e){if(t==null)return{};var n,r,i=s0e(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 s0e(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 v8=(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,`,
- `).concat(t+n,",").concat(e+o*d[1])),u+="L ".concat(t+n,",").concat(e+r-o*d[2]),d[2]>0&&(u+="A ".concat(d[2],",").concat(d[2],",0,0,").concat(c,`,
- `).concat(t+n-l*d[2],",").concat(e+r)),u+="L ".concat(t+l*d[3],",").concat(e+r),d[3]>0&&(u+="A ".concat(d[3],",").concat(d[3],",0,0,").concat(c,`,
- `).concat(t,",").concat(e+r-o*d[3])),u+="Z"}else if(a>0&&i===+i&&i>0){var g=Math.min(a,i);u="M ".concat(t,",").concat(e+o*g,`
- A `).concat(g,",").concat(g,",0,0,").concat(c,",").concat(t+l*g,",").concat(e,`
- L `).concat(t+n-l*g,",").concat(e,`
- A `).concat(g,",").concat(g,",0,0,").concat(c,",").concat(t+n,",").concat(e+o*g,`
- L `).concat(t+n,",").concat(e+r-o*g,`
- A `).concat(g,",").concat(g,",0,0,").concat(c,",").concat(t+n-l*g,",").concat(e+r,`
- L `).concat(t+l*g,",").concat(e+r,`
- A `).concat(g,",").concat(g,",0,0,").concat(c,",").concat(t,",").concat(e+r-o*g," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},_8={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},nX=t=>{var e=Ur(t,_8),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:g,isAnimationActive:x,isUpdateAnimationActive:y}=e,b=w.useRef(l),v=w.useRef(c),M=w.useRef(a),S=w.useRef(o),A=w.useMemo(()=>({x:a,y:o,width:l,height:c,radius:u}),[a,o,l,c,u]),E=Og(A,"rectangle-");if(a!==+a||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var k=In("recharts-rectangle",d);if(!y){var C=ya(e),{radius:R}=C,T=y8(C,t0e);return w.createElement("path",Fw({},T,{radius:typeof u=="number"?u:void 0,className:k,d:v8(a,o,l,c,u)}))}var P=b.current,F=v.current,L=M.current,X=S.current,D="0px ".concat(r===-1?1:r,"px"),K="".concat(r,"px 0px"),Y=ZK(["strokeDasharray"],m,typeof f=="string"?f:_8.animationEasing);return w.createElement(Dg,{animationId:E,key:E,canBegin:r>0,duration:m,easing:f,isActive:y,begin:g},q=>{var Z=qn(P,l,q),re=qn(F,c,q),oe=qn(L,a,q),B=qn(X,o,q);n.current&&(b.current=Z,v.current=re,M.current=oe,S.current=B);var G;x?q>0?G={transition:Y,strokeDasharray:K}:G={strokeDasharray:D}:G={strokeDasharray:K};var J=ya(e),{radius:te}=J,ae=y8(J,n0e);return w.createElement("path",Fw({},ae,{radius:typeof u=="number"?u:void 0,className:k,d:v8(oe,B,Z,re,u),ref:n,style:b8(b8({},G),e.style)}))})};function w8(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 S8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?w8(Object(n),!0).forEach(function(r){o0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function o0e(t,e,n){return(e=l0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l0e(t){var e=c0e(t,"string");return typeof e=="symbol"?e:e+""}function c0e(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 Uw=Math.PI/180,u0e=t=>t*180/Math.PI,gi=(t,e,n,r)=>({x:t+Math.cos(-Uw*r)*n,y:e+Math.sin(-Uw*r)*n}),rX=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(e-(r.left||0)-(r.right||0)),Math.abs(n-(r.top||0)-(r.bottom||0)))/2},d0e=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},h0e=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,o=d0e({x:n,y:r},{x:i,y:a});if(o<=0)return{radius:o,angle:0};var l=(n-i)/o,c=Math.acos(l);return r>a&&(c=2*Math.PI-c),{radius:o,angle:u0e(c),angleInRadian:c}},f0e=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}},m0e=(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},p0e=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=h0e({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=f0e(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?S8(S8({},e),{},{radius:i,angle:m0e(d,e)}):null};function iX(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,o=gi(e,n,r,i),l=gi(e,n,r,a);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}function M3(){return M3=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},M3.apply(null,arguments)}var g0e=(t,e)=>{var n=Xi(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},a_=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)/Uw,f=c?i:i+a*d,m=gi(e,n,u,f),g=gi(e,n,r,f),x=c?i-a*d:i,y=gi(e,n,u*Math.cos(d*Uw),x);return{center:m,circleTangency:g,lineTangency:y,theta:d}},aX=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=t,l=g0e(a,o),c=a+l,u=gi(e,n,i,a),d=gi(e,n,i,c),f="M ".concat(u.x,",").concat(u.y,`
- A `).concat(i,",").concat(i,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(a>c),`,
- `).concat(d.x,",").concat(d.y,`
- `);if(r>0){var m=gi(e,n,r,a),g=gi(e,n,r,c);f+="L ".concat(g.x,",").concat(g.y,`
- A `).concat(r,",").concat(r,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(a<=c),`,
- `).concat(m.x,",").concat(m.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},x0e=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=Xi(u-c),{circleTangency:f,lineTangency:m,theta:g}=a_({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:l}),{circleTangency:x,lineTangency:y,theta:b}=a_({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:l}),v=l?Math.abs(c-u):Math.abs(c-u)-g-b;if(v<0)return o?"M ".concat(m.x,",").concat(m.y,`
- a`).concat(a,",").concat(a,",0,0,1,").concat(a*2,`,0
- a`).concat(a,",").concat(a,",0,0,1,").concat(-a*2,`,0
- `):aX({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var M="M ".concat(m.x,",").concat(m.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(f.x,",").concat(f.y,`
- A`).concat(i,",").concat(i,",0,").concat(+(v>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(y.x,",").concat(y.y,`
- `);if(r>0){var{circleTangency:S,lineTangency:A,theta:E}=a_({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),{circleTangency:k,lineTangency:C,theta:R}=a_({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),T=l?Math.abs(c-u):Math.abs(c-u)-E-R;if(T<0&&a===0)return"".concat(M,"L").concat(e,",").concat(n,"Z");M+="L".concat(C.x,",").concat(C.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(k.x,",").concat(k.y,`
- A`).concat(r,",").concat(r,",0,").concat(+(T>180),",").concat(+(d>0),",").concat(S.x,",").concat(S.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(A.x,",").concat(A.y,"Z")}else M+="L".concat(e,",").concat(n,"Z");return M},b0e={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},sX=t=>{var e=Ur(t,b0e),{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=In("recharts-sector",f),g=a-i,x=ja(o,g,0,!0),y;return x>0&&Math.abs(u-d)<360?y=x0e({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(x,g/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):y=aX({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),w.createElement("path",M3({},ya(e),{className:m,d:y}))};function y0e(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(Iq(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:l}=e,c=gi(r,i,a,l),u=gi(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return iX(e)}}var IT={},FT={},UT={},M8;function v0e(){return M8||(M8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Yq();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(UT)),UT}var N8;function _0e(){return N8||(N8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=v0e();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})(FT)),FT}var E8;function w0e(){return E8||(E8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Qq(),n=_0e();function r(i,a,o){o&&typeof o!="number"&&e.isIterateeCall(i,a,o)&&(a=o=void 0),i=n.toFinite(i),a===void 0?(a=i,i=0):a=n.toFinite(a),o=o===void 0?i<a?1:-1:n.toFinite(o);const l=Math.max(Math.ceil((a-i)/(o||1)),0),c=new Array(l);for(let u=0;u<l;u++)c[u]=i,i+=o;return c}t.range=r})(IT)),IT}var zT,A8;function S0e(){return A8||(A8=1,zT=w0e().range),zT}var M0e=S0e();const oX=Co(M0e);function Nd(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function N0e(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function LD(t){let e,n,r;t.length!==2?(e=Nd,n=(l,c)=>Nd(t(l),c),r=(l,c)=>t(l)-c):(e=t===Nd||t===N0e?t:E0e,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 E0e(){return 0}function lX(t){return t===null?NaN:+t}function*A0e(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const T0e=LD(Nd),sy=T0e.right;LD(lX).center;class T8 extends Map{constructor(e,n=j0e){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),e!=null)for(const[r,i]of e)this.set(r,i)}get(e){return super.get(C8(this,e))}has(e){return super.has(C8(this,e))}set(e,n){return super.set(C0e(this,e),n)}delete(e){return super.delete(k0e(this,e))}}function C8({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function C0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function k0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function j0e(t){return t!==null&&typeof t=="object"?t.valueOf():t}function P0e(t=Nd){if(t===Nd)return cX;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 cX(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const R0e=Math.sqrt(50),D0e=Math.sqrt(10),O0e=Math.sqrt(2);function zw(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>=R0e?10:a>=D0e?5:a>=O0e?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?zw(t,e,n*2):[l,c,u]}function N3(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?zw(e,t,n):zw(t,e,n);if(!(a>=i))return[];const l=a-i+1,c=new Array(l);if(r)if(o<0)for(let u=0;u<l;++u)c[u]=(a-u)/-o;else for(let u=0;u<l;++u)c[u]=(a-u)*o;else if(o<0)for(let u=0;u<l;++u)c[u]=(i+u)/-o;else for(let u=0;u<l;++u)c[u]=(i+u)*o;return c}function E3(t,e,n){return e=+e,t=+t,n=+n,zw(t,e,n)[2]}function A3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?E3(e,t,n):E3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function k8(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function j8(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function uX(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?cX:P0e(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),g=Math.max(n,Math.floor(e-u*f/c+m)),x=Math.min(r,Math.floor(e+(c-u)*f/c+m));uX(t,e,g,x,i)}const a=t[e];let o=n,l=r;for(qx(t,n,e),i(t[r],a)>0&&qx(t,n,r);o<l;){for(qx(t,o,l),++o,--l;i(t[o],a)<0;)++o;for(;i(t[l],a)>0;)--l}i(t[n],a)===0?qx(t,n,l):(++l,qx(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function qx(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function L0e(t,e,n){if(t=Float64Array.from(A0e(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return j8(t);if(e>=1)return k8(t);var r,i=(r-1)*e,a=Math.floor(i),o=k8(uX(t,a).subarray(0,a+1)),l=j8(t.subarray(a+1));return o+(l-o)*(i-a)}}function I0e(t,e,n=lX){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 F0e(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 jo(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function fu(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 T3=Symbol("implicit");function ID(){var t=new T8,e=[],n=[],r=T3;function i(a){let o=t.get(a);if(o===void 0){if(r!==T3)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 T8;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 ID(e,n).unknown(r)},jo.apply(i,arguments),i}function FD(){var t=ID().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,g=i<r,x=g?i:r,y=g?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=F0e(m).map(function(v){return x+a*v});return n(g?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 FD(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},jo.apply(f(),arguments)}function dX(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return dX(e())},t}function U0e(){return dX(FD.apply(null,arguments).paddingInner(1))}function UD(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function hX(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function oy(){}var p0=.7,Bw=1/p0,Fp="\\s*([+-]?\\d+)\\s*",g0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",jl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",z0e=/^#([0-9a-f]{3,8})$/,B0e=new RegExp(`^rgb\\(${Fp},${Fp},${Fp}\\)$`),$0e=new RegExp(`^rgb\\(${jl},${jl},${jl}\\)$`),H0e=new RegExp(`^rgba\\(${Fp},${Fp},${Fp},${g0}\\)$`),V0e=new RegExp(`^rgba\\(${jl},${jl},${jl},${g0}\\)$`),G0e=new RegExp(`^hsl\\(${g0},${jl},${jl}\\)$`),W0e=new RegExp(`^hsla\\(${g0},${jl},${jl},${g0}\\)$`),P8={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};UD(oy,x0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:R8,formatHex:R8,formatHex8:q0e,formatHsl:K0e,formatRgb:D8,toString:D8});function R8(){return this.rgb().formatHex()}function q0e(){return this.rgb().formatHex8()}function K0e(){return fX(this).formatHsl()}function D8(){return this.rgb().formatRgb()}function x0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=z0e.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?O8(e):n===3?new hs(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?s_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?s_(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=B0e.exec(t))?new hs(e[1],e[2],e[3],1):(e=$0e.exec(t))?new hs(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=H0e.exec(t))?s_(e[1],e[2],e[3],e[4]):(e=V0e.exec(t))?s_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=G0e.exec(t))?F8(e[1],e[2]/100,e[3]/100,1):(e=W0e.exec(t))?F8(e[1],e[2]/100,e[3]/100,e[4]):P8.hasOwnProperty(t)?O8(P8[t]):t==="transparent"?new hs(NaN,NaN,NaN,0):null}function O8(t){return new hs(t>>16&255,t>>8&255,t&255,1)}function s_(t,e,n,r){return r<=0&&(t=e=n=NaN),new hs(t,e,n,r)}function X0e(t){return t instanceof oy||(t=x0(t)),t?(t=t.rgb(),new hs(t.r,t.g,t.b,t.opacity)):new hs}function C3(t,e,n,r){return arguments.length===1?X0e(t):new hs(t,e,n,r??1)}function hs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}UD(hs,C3,hX(oy,{brighter(t){return t=t==null?Bw:Math.pow(Bw,t),new hs(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?p0:Math.pow(p0,t),new hs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new hs(sf(this.r),sf(this.g),sf(this.b),$w(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:L8,formatHex:L8,formatHex8:Y0e,formatRgb:I8,toString:I8}));function L8(){return`#${qh(this.r)}${qh(this.g)}${qh(this.b)}`}function Y0e(){return`#${qh(this.r)}${qh(this.g)}${qh(this.b)}${qh((isNaN(this.opacity)?1:this.opacity)*255)}`}function I8(){const t=$w(this.opacity);return`${t===1?"rgb(":"rgba("}${sf(this.r)}, ${sf(this.g)}, ${sf(this.b)}${t===1?")":`, ${t})`}`}function $w(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function sf(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function qh(t){return t=sf(t),(t<16?"0":"")+t.toString(16)}function F8(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Go(t,e,n,r)}function fX(t){if(t instanceof Go)return new Go(t.h,t.s,t.l,t.opacity);if(t instanceof oy||(t=x0(t)),!t)return new Go;if(t instanceof Go)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 Go(o,l,c,t.opacity)}function Q0e(t,e,n,r){return arguments.length===1?fX(t):new Go(t,e,n,r??1)}function Go(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}UD(Go,Q0e,hX(oy,{brighter(t){return t=t==null?Bw:Math.pow(Bw,t),new Go(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?p0:Math.pow(p0,t),new Go(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 hs(BT(t>=240?t-240:t+120,i,r),BT(t,i,r),BT(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Go(U8(this.h),o_(this.s),o_(this.l),$w(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=$w(this.opacity);return`${t===1?"hsl(":"hsla("}${U8(this.h)}, ${o_(this.s)*100}%, ${o_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function U8(t){return t=(t||0)%360,t<0?t+360:t}function o_(t){return Math.max(0,Math.min(1,t||0))}function BT(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 zD=t=>()=>t;function Z0e(t,e){return function(n){return t+n*e}}function J0e(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 eye(t){return(t=+t)==1?mX:function(e,n){return n-e?J0e(e,n,t):zD(isNaN(e)?n:e)}}function mX(t,e){var n=e-t;return n?Z0e(t,n):zD(isNaN(t)?e:t)}const z8=(function t(e){var n=eye(e);function r(i,a){var o=n((i=C3(i)).r,(a=C3(a)).r),l=n(i.g,a.g),c=n(i.b,a.b),u=mX(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 tye(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 nye(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function rye(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]=Lg(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 iye(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Hw(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function aye(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]=Lg(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var k3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$T=new RegExp(k3.source,"g");function sye(t){return function(){return t}}function oye(t){return function(e){return t(e)+""}}function lye(t,e){var n=k3.lastIndex=$T.lastIndex=0,r,i,a,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=k3.exec(t))&&(i=$T.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:Hw(r,i)})),n=$T.lastIndex;return n<e.length&&(a=e.slice(n),l[o]?l[o]+=a:l[++o]=a),l.length<2?c[0]?oye(c[0].x):sye(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 Lg(t,e){var n=typeof e,r;return e==null||n==="boolean"?zD(e):(n==="number"?Hw:n==="string"?(r=x0(e))?(e=r,z8):lye:e instanceof x0?z8:e instanceof Date?iye:nye(e)?tye:Array.isArray(e)?rye:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?aye:Hw)(t,e)}function BD(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function cye(t,e){e===void 0&&(e=t,t=Lg);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 uye(t){return function(){return t}}function Vw(t){return+t}var B8=[0,1];function Ba(t){return t}function j3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:uye(isNaN(e)?NaN:.5)}function dye(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function hye(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=j3(i,r),a=n(o,a)):(r=j3(r,i),a=n(a,o)),function(l){return a(r(l))}}function fye(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]=j3(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(l){var c=sy(t,l,1,r)-1;return a[c](i[c](l))}}function ly(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function oM(){var t=B8,e=B8,n=Lg,r,i,a,o=Ba,l,c,u;function d(){var m=Math.min(t.length,e.length);return o!==Ba&&(o=dye(t[0],t[m-1])),l=m>2?fye:hye,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),Hw)))(m)))},f.domain=function(m){return arguments.length?(t=Array.from(m,Vw),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=BD,d()},f.clamp=function(m){return arguments.length?(o=m?!0:Ba,d()):o!==Ba},f.interpolate=function(m){return arguments.length?(n=m,d()):n},f.unknown=function(m){return arguments.length?(a=m,f):a},function(m,g){return r=m,i=g,d()}}function $D(){return oM()(Ba,Ba)}function mye(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Gw(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 sg(t){return t=Gw(Math.abs(t)),t?t[1]:NaN}function pye(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 gye(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var xye=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function b0(t){if(!(e=xye.exec(t)))throw new Error("invalid format: "+t);var e;return new HD({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]})}b0.prototype=HD.prototype;function HD(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+""}HD.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 bye(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 pX;function yye(t,e){var n=Gw(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(pX=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")+Gw(t,Math.max(0,e+a-1))[0]}function $8(t,e){var n=Gw(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 H8={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:mye,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)=>$8(t*100,e),r:$8,s:yye,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function V8(t){return t}var G8=Array.prototype.map,W8=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function vye(t){var e=t.grouping===void 0||t.thousands===void 0?V8:pye(G8.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?V8:gye(G8.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=b0(f);var m=f.fill,g=f.align,x=f.sign,y=f.symbol,b=f.zero,v=f.width,M=f.comma,S=f.precision,A=f.trim,E=f.type;E==="n"?(M=!0,E="g"):H8[E]||(S===void 0&&(S=12),A=!0,E="g"),(b||m==="0"&&g==="=")&&(b=!0,m="0",g="=");var k=y==="$"?n:y==="#"&&/[boxX]/.test(E)?"0"+E.toLowerCase():"",C=y==="$"?r:/[%p]/.test(E)?o:"",R=H8[E],T=/[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 P(F){var L=k,X=C,D,K,Y;if(E==="c")X=R(F)+X,F="";else{F=+F;var q=F<0||1/F<0;if(F=isNaN(F)?c:R(Math.abs(F),S),A&&(F=bye(F)),q&&+F==0&&x!=="+"&&(q=!1),L=(q?x==="("?x:l:x==="-"||x==="("?"":x)+L,X=(E==="s"?W8[8+pX/3]:"")+X+(q&&x==="("?")":""),T){for(D=-1,K=F.length;++D<K;)if(Y=F.charCodeAt(D),48>Y||Y>57){X=(Y===46?i+F.slice(D+1):F.slice(D))+X,F=F.slice(0,D);break}}}M&&!b&&(F=e(F,1/0));var Z=L.length+F.length+X.length,re=Z<v?new Array(v-Z+1).join(m):"";switch(M&&b&&(F=e(re+F,re.length?v-X.length:1/0),re=""),g){case"<":F=L+F+X+re;break;case"=":F=L+re+F+X;break;case"^":F=re.slice(0,Z=re.length>>1)+L+F+X+re.slice(Z);break;default:F=re+L+F+X;break}return a(F)}return P.toString=function(){return f+""},P}function d(f,m){var g=u((f=b0(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(sg(m)/3)))*3,y=Math.pow(10,-x),b=W8[8+x/3];return function(v){return g(y*v)+b}}return{format:u,formatPrefix:d}}var l_,VD,gX;_ye({thousands:",",grouping:[3],currency:["$",""]});function _ye(t){return l_=vye(t),VD=l_.format,gX=l_.formatPrefix,l_}function wye(t){return Math.max(0,-sg(Math.abs(t)))}function Sye(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(sg(e)/3)))*3-sg(Math.abs(t)))}function Mye(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,sg(e)-sg(t))+1}function xX(t,e,n,r){var i=A3(t,e,n),a;switch(r=b0(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=Sye(i,o))&&(r.precision=a),gX(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=Mye(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=wye(i))&&(r.precision=a-(r.type==="%")*2);break}}return VD(r)}function Zd(t){var e=t.domain;return t.ticks=function(n){var r=e();return N3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return xX(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,a=r.length-1,o=r[i],l=r[a],c,u,d=10;for(l<o&&(u=o,o=l,l=u,u=i,i=a,a=u);d-- >0;){if(u=E3(o,l,n),u===c)return r[i]=o,r[a]=l,e(r);if(u>0)o=Math.floor(o/u)*u,l=Math.ceil(l/u)*u;else if(u<0)o=Math.ceil(o*u)/u,l=Math.floor(l*u)/u;else break;c=u}return t},t}function bX(){var t=$D();return t.copy=function(){return ly(t,bX())},jo.apply(t,arguments),Zd(t)}function yX(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,Vw),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return yX(t).unknown(e)},t=arguments.length?Array.from(t,Vw):[0,1],Zd(n)}function vX(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 q8(t){return Math.log(t)}function K8(t){return Math.exp(t)}function Nye(t){return-Math.log(-t)}function Eye(t){return-Math.exp(-t)}function Aye(t){return isFinite(t)?+("1e"+t):t<0?0:t}function Tye(t){return t===10?Aye:t===Math.E?Math.exp:e=>Math.pow(t,e)}function Cye(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 X8(t){return(e,n)=>-t(-e,n)}function GD(t){const e=t(q8,K8),n=e.domain;let r=10,i,a;function o(){return i=Cye(r),a=Tye(r),n()[0]<0?(i=X8(i),a=X8(a),t(Nye,Eye)):t(q8,K8),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),g=i(d),x,y;const b=l==null?10:+l;let v=[];if(!(r%1)&&g-m<b){if(m=Math.floor(m),g=Math.ceil(g),u>0){for(;m<=g;++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<=g;++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=N3(u,d,b))}else v=N3(m,g,Math.min(g-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=b0(c)).precision==null&&(c.trim=!0),c=VD(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(vX(n(),{floor:l=>a(Math.floor(i(l))),ceil:l=>a(Math.ceil(i(l)))})),e}function _X(){const t=GD(oM()).domain([1,10]);return t.copy=()=>ly(t,_X()).base(t.base()),jo.apply(t,arguments),t}function Y8(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function Q8(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function WD(t){var e=1,n=t(Y8(e),Q8(e));return n.constant=function(r){return arguments.length?t(Y8(e=+r),Q8(e)):e},Zd(n)}function wX(){var t=WD(oM());return t.copy=function(){return ly(t,wX()).constant(t.constant())},jo.apply(t,arguments)}function Z8(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function kye(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function jye(t){return t<0?-t*t:t*t}function qD(t){var e=t(Ba,Ba),n=1;function r(){return n===1?t(Ba,Ba):n===.5?t(kye,jye):t(Z8(n),Z8(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},Zd(e)}function KD(){var t=qD(oM());return t.copy=function(){return ly(t,KD()).exponent(t.exponent())},jo.apply(t,arguments),t}function Pye(){return KD.apply(null,arguments).exponent(.5)}function J8(t){return Math.sign(t)*t*t}function Rye(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function SX(){var t=$D(),e=[0,1],n=!1,r;function i(a){var o=Rye(t(a));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(a){return t.invert(J8(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,Vw)).map(J8)),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 SX(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},jo.apply(i,arguments),Zd(i)}function MX(){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]=I0e(t,o/l);return a}function a(o){return o==null||isNaN(o=+o)?r:e[sy(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(Nd),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 MX().domain(t).range(e).unknown(r)},jo.apply(a,arguments)}function NX(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function o(c){return c!=null&&c<=c?i[sy(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 NX().domain([t,e]).range(i).unknown(a)},jo.apply(Zd(o),arguments)}function EX(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[sy(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 EX().domain(t).range(e).unknown(n)},jo.apply(i,arguments)}const HT=new Date,VT=new Date;function Ri(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=>Ri(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)=>(HT.setTime(+a),VT.setTime(+o),t(HT),t(VT),Math.floor(n(HT,VT))),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 Ww=Ri(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);Ww.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Ri(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):Ww);Ww.range;const Fc=1e3,vo=Fc*60,Uc=vo*60,ru=Uc*24,XD=ru*7,e6=ru*30,GT=ru*365,Kh=Ri(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Fc)},(t,e)=>(e-t)/Fc,t=>t.getUTCSeconds());Kh.range;const YD=Ri(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Fc)},(t,e)=>{t.setTime(+t+e*vo)},(t,e)=>(e-t)/vo,t=>t.getMinutes());YD.range;const QD=Ri(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*vo)},(t,e)=>(e-t)/vo,t=>t.getUTCMinutes());QD.range;const ZD=Ri(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Fc-t.getMinutes()*vo)},(t,e)=>{t.setTime(+t+e*Uc)},(t,e)=>(e-t)/Uc,t=>t.getHours());ZD.range;const JD=Ri(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Uc)},(t,e)=>(e-t)/Uc,t=>t.getUTCHours());JD.range;const cy=Ri(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*vo)/ru,t=>t.getDate()-1);cy.range;const lM=Ri(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/ru,t=>t.getUTCDate()-1);lM.range;const AX=Ri(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/ru,t=>Math.floor(t/ru));AX.range;function Wf(t){return Ri(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())*vo)/XD)}const cM=Wf(0),qw=Wf(1),Dye=Wf(2),Oye=Wf(3),og=Wf(4),Lye=Wf(5),Iye=Wf(6);cM.range;qw.range;Dye.range;Oye.range;og.range;Lye.range;Iye.range;function qf(t){return Ri(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)/XD)}const uM=qf(0),Kw=qf(1),Fye=qf(2),Uye=qf(3),lg=qf(4),zye=qf(5),Bye=qf(6);uM.range;Kw.range;Fye.range;Uye.range;lg.range;zye.range;Bye.range;const e4=Ri(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());e4.range;const t4=Ri(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());t4.range;const iu=Ri(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());iu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ri(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)});iu.range;const au=Ri(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());au.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ri(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)});au.range;function TX(t,e,n,r,i,a){const o=[[Kh,1,Fc],[Kh,5,5*Fc],[Kh,15,15*Fc],[Kh,30,30*Fc],[a,1,vo],[a,5,5*vo],[a,15,15*vo],[a,30,30*vo],[i,1,Uc],[i,3,3*Uc],[i,6,6*Uc],[i,12,12*Uc],[r,1,ru],[r,2,2*ru],[n,1,XD],[e,1,e6],[e,3,3*e6],[t,1,GT]];function l(u,d,f){const m=d<u;m&&([u,d]=[d,u]);const g=f&&typeof f.range=="function"?f:c(u,d,f),x=g?g.range(u,+d+1):[];return m?x.reverse():x}function c(u,d,f){const m=Math.abs(d-u)/f,g=LD(([,,b])=>b).right(o,m);if(g===o.length)return t.every(A3(u/GT,d/GT,f));if(g===0)return Ww.every(Math.max(A3(u,d,f),1));const[x,y]=o[m/o[g-1][2]<o[g][2]/m?g-1:g];return x.every(y)}return[l,c]}const[$ye,Hye]=TX(au,t4,uM,AX,JD,QD),[Vye,Gye]=TX(iu,e4,cM,cy,ZD,YD);function WT(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 qT(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 Kx(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function Wye(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=Xx(i),d=Yx(i),f=Xx(a),m=Yx(a),g=Xx(o),x=Yx(o),y=Xx(l),b=Yx(l),v=Xx(c),M=Yx(c),S={a:q,A:Z,b:re,B:oe,c:null,d:s6,e:s6,f:pve,g:Nve,G:Ave,H:hve,I:fve,j:mve,L:CX,m:gve,M:xve,p:B,q:G,Q:c6,s:u6,S:bve,u:yve,U:vve,V:_ve,w:wve,W:Sve,x:null,X:null,y:Mve,Y:Eve,Z:Tve,"%":l6},A={a:J,A:te,b:ae,B:de,c:null,d:o6,e:o6,f:Pve,g:$ve,G:Vve,H:Cve,I:kve,j:jve,L:jX,m:Rve,M:Dve,p:fe,q:Ae,Q:c6,s:u6,S:Ove,u:Lve,U:Ive,V:Fve,w:Uve,W:zve,x:null,X:null,y:Bve,Y:Hve,Z:Gve,"%":l6},E={a:P,A:F,b:L,B:X,c:D,d:i6,e:i6,f:lve,g:r6,G:n6,H:a6,I:a6,j:ive,L:ove,m:rve,M:ave,p:T,q:nve,Q:uve,s:dve,S:sve,u:Qye,U:Zye,V:Jye,w:Yye,W:eve,x:K,X:Y,y:r6,Y:n6,Z:tve,"%":cve};S.x=k(n,S),S.X=k(r,S),S.c=k(e,S),A.x=k(n,A),A.X=k(r,A),A.c=k(e,A);function k(ge,Me){return function(je){var ne=[],Ke=-1,$=0,z=ge.length,W,U,V;for(je instanceof Date||(je=new Date(+je));++Ke<z;)ge.charCodeAt(Ke)===37&&(ne.push(ge.slice($,Ke)),(U=t6[W=ge.charAt(++Ke)])!=null?W=ge.charAt(++Ke):U=W==="e"?" ":"0",(V=Me[W])&&(W=V(je,U)),ne.push(W),$=Ke+1);return ne.push(ge.slice($,Ke)),ne.join("")}}function C(ge,Me){return function(je){var ne=Kx(1900,void 0,1),Ke=R(ne,ge,je+="",0),$,z;if(Ke!=je.length)return null;if("Q"in ne)return new Date(ne.Q);if("s"in ne)return new Date(ne.s*1e3+("L"in ne?ne.L:0));if(Me&&!("Z"in ne)&&(ne.Z=0),"p"in ne&&(ne.H=ne.H%12+ne.p*12),ne.m===void 0&&(ne.m="q"in ne?ne.q:0),"V"in ne){if(ne.V<1||ne.V>53)return null;"w"in ne||(ne.w=1),"Z"in ne?($=qT(Kx(ne.y,0,1)),z=$.getUTCDay(),$=z>4||z===0?Kw.ceil($):Kw($),$=lM.offset($,(ne.V-1)*7),ne.y=$.getUTCFullYear(),ne.m=$.getUTCMonth(),ne.d=$.getUTCDate()+(ne.w+6)%7):($=WT(Kx(ne.y,0,1)),z=$.getDay(),$=z>4||z===0?qw.ceil($):qw($),$=cy.offset($,(ne.V-1)*7),ne.y=$.getFullYear(),ne.m=$.getMonth(),ne.d=$.getDate()+(ne.w+6)%7)}else("W"in ne||"U"in ne)&&("w"in ne||(ne.w="u"in ne?ne.u%7:"W"in ne?1:0),z="Z"in ne?qT(Kx(ne.y,0,1)).getUTCDay():WT(Kx(ne.y,0,1)).getDay(),ne.m=0,ne.d="W"in ne?(ne.w+6)%7+ne.W*7-(z+5)%7:ne.w+ne.U*7-(z+6)%7);return"Z"in ne?(ne.H+=ne.Z/100|0,ne.M+=ne.Z%100,qT(ne)):WT(ne)}}function R(ge,Me,je,ne){for(var Ke=0,$=Me.length,z=je.length,W,U;Ke<$;){if(ne>=z)return-1;if(W=Me.charCodeAt(Ke++),W===37){if(W=Me.charAt(Ke++),U=E[W in t6?Me.charAt(Ke++):W],!U||(ne=U(ge,je,ne))<0)return-1}else if(W!=je.charCodeAt(ne++))return-1}return ne}function T(ge,Me,je){var ne=u.exec(Me.slice(je));return ne?(ge.p=d.get(ne[0].toLowerCase()),je+ne[0].length):-1}function P(ge,Me,je){var ne=g.exec(Me.slice(je));return ne?(ge.w=x.get(ne[0].toLowerCase()),je+ne[0].length):-1}function F(ge,Me,je){var ne=f.exec(Me.slice(je));return ne?(ge.w=m.get(ne[0].toLowerCase()),je+ne[0].length):-1}function L(ge,Me,je){var ne=v.exec(Me.slice(je));return ne?(ge.m=M.get(ne[0].toLowerCase()),je+ne[0].length):-1}function X(ge,Me,je){var ne=y.exec(Me.slice(je));return ne?(ge.m=b.get(ne[0].toLowerCase()),je+ne[0].length):-1}function D(ge,Me,je){return R(ge,e,Me,je)}function K(ge,Me,je){return R(ge,n,Me,je)}function Y(ge,Me,je){return R(ge,r,Me,je)}function q(ge){return o[ge.getDay()]}function Z(ge){return a[ge.getDay()]}function re(ge){return c[ge.getMonth()]}function oe(ge){return l[ge.getMonth()]}function B(ge){return i[+(ge.getHours()>=12)]}function G(ge){return 1+~~(ge.getMonth()/3)}function J(ge){return o[ge.getUTCDay()]}function te(ge){return a[ge.getUTCDay()]}function ae(ge){return c[ge.getUTCMonth()]}function de(ge){return l[ge.getUTCMonth()]}function fe(ge){return i[+(ge.getUTCHours()>=12)]}function Ae(ge){return 1+~~(ge.getUTCMonth()/3)}return{format:function(ge){var Me=k(ge+="",S);return Me.toString=function(){return ge},Me},parse:function(ge){var Me=C(ge+="",!1);return Me.toString=function(){return ge},Me},utcFormat:function(ge){var Me=k(ge+="",A);return Me.toString=function(){return ge},Me},utcParse:function(ge){var Me=C(ge+="",!0);return Me.toString=function(){return ge},Me}}}var t6={"-":"",_:" ",0:"0"},ta=/^\s*\d+/,qye=/^%/,Kye=/[\\^$*+?|[\]().{}]/g;function Bn(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 Xye(t){return t.replace(Kye,"\\$&")}function Xx(t){return new RegExp("^(?:"+t.map(Xye).join("|")+")","i")}function Yx(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function Yye(t,e,n){var r=ta.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Qye(t,e,n){var r=ta.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Zye(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Jye(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function eve(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function n6(t,e,n){var r=ta.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function r6(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function tve(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 nve(t,e,n){var r=ta.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function rve(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function i6(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function ive(t,e,n){var r=ta.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function a6(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function ave(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function sve(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function ove(t,e,n){var r=ta.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function lve(t,e,n){var r=ta.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function cve(t,e,n){var r=qye.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function uve(t,e,n){var r=ta.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function dve(t,e,n){var r=ta.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function s6(t,e){return Bn(t.getDate(),e,2)}function hve(t,e){return Bn(t.getHours(),e,2)}function fve(t,e){return Bn(t.getHours()%12||12,e,2)}function mve(t,e){return Bn(1+cy.count(iu(t),t),e,3)}function CX(t,e){return Bn(t.getMilliseconds(),e,3)}function pve(t,e){return CX(t,e)+"000"}function gve(t,e){return Bn(t.getMonth()+1,e,2)}function xve(t,e){return Bn(t.getMinutes(),e,2)}function bve(t,e){return Bn(t.getSeconds(),e,2)}function yve(t){var e=t.getDay();return e===0?7:e}function vve(t,e){return Bn(cM.count(iu(t)-1,t),e,2)}function kX(t){var e=t.getDay();return e>=4||e===0?og(t):og.ceil(t)}function _ve(t,e){return t=kX(t),Bn(og.count(iu(t),t)+(iu(t).getDay()===4),e,2)}function wve(t){return t.getDay()}function Sve(t,e){return Bn(qw.count(iu(t)-1,t),e,2)}function Mve(t,e){return Bn(t.getFullYear()%100,e,2)}function Nve(t,e){return t=kX(t),Bn(t.getFullYear()%100,e,2)}function Eve(t,e){return Bn(t.getFullYear()%1e4,e,4)}function Ave(t,e){var n=t.getDay();return t=n>=4||n===0?og(t):og.ceil(t),Bn(t.getFullYear()%1e4,e,4)}function Tve(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Bn(e/60|0,"0",2)+Bn(e%60,"0",2)}function o6(t,e){return Bn(t.getUTCDate(),e,2)}function Cve(t,e){return Bn(t.getUTCHours(),e,2)}function kve(t,e){return Bn(t.getUTCHours()%12||12,e,2)}function jve(t,e){return Bn(1+lM.count(au(t),t),e,3)}function jX(t,e){return Bn(t.getUTCMilliseconds(),e,3)}function Pve(t,e){return jX(t,e)+"000"}function Rve(t,e){return Bn(t.getUTCMonth()+1,e,2)}function Dve(t,e){return Bn(t.getUTCMinutes(),e,2)}function Ove(t,e){return Bn(t.getUTCSeconds(),e,2)}function Lve(t){var e=t.getUTCDay();return e===0?7:e}function Ive(t,e){return Bn(uM.count(au(t)-1,t),e,2)}function PX(t){var e=t.getUTCDay();return e>=4||e===0?lg(t):lg.ceil(t)}function Fve(t,e){return t=PX(t),Bn(lg.count(au(t),t)+(au(t).getUTCDay()===4),e,2)}function Uve(t){return t.getUTCDay()}function zve(t,e){return Bn(Kw.count(au(t)-1,t),e,2)}function Bve(t,e){return Bn(t.getUTCFullYear()%100,e,2)}function $ve(t,e){return t=PX(t),Bn(t.getUTCFullYear()%100,e,2)}function Hve(t,e){return Bn(t.getUTCFullYear()%1e4,e,4)}function Vve(t,e){var n=t.getUTCDay();return t=n>=4||n===0?lg(t):lg.ceil(t),Bn(t.getUTCFullYear()%1e4,e,4)}function Gve(){return"+0000"}function l6(){return"%"}function c6(t){return+t}function u6(t){return Math.floor(+t/1e3)}var jm,RX,DX;Wve({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 Wve(t){return jm=Wye(t),RX=jm.format,jm.parse,DX=jm.utcFormat,jm.utcParse,jm}function qve(t){return new Date(t)}function Kve(t){return t instanceof Date?+t:+new Date(+t)}function n4(t,e,n,r,i,a,o,l,c,u){var d=$D(),f=d.invert,m=d.domain,g=u(".%L"),x=u(":%S"),y=u("%I:%M"),b=u("%I %p"),v=u("%a %d"),M=u("%b %d"),S=u("%B"),A=u("%Y");function E(k){return(c(k)<k?g:l(k)<k?x:o(k)<k?y:a(k)<k?b:r(k)<k?i(k)<k?v:M:n(k)<k?S:A)(k)}return d.invert=function(k){return new Date(f(k))},d.domain=function(k){return arguments.length?m(Array.from(k,Kve)):m().map(qve)},d.ticks=function(k){var C=m();return t(C[0],C[C.length-1],k??10)},d.tickFormat=function(k,C){return C==null?E:u(C)},d.nice=function(k){var C=m();return(!k||typeof k.range!="function")&&(k=e(C[0],C[C.length-1],k??10)),k?m(vX(C,k)):d},d.copy=function(){return ly(d,n4(t,e,n,r,i,a,o,l,c,u))},d}function Xve(){return jo.apply(n4(Vye,Gye,iu,e4,cM,cy,ZD,YD,Kh,RX).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Yve(){return jo.apply(n4($ye,Hye,au,t4,uM,lM,JD,QD,Kh,DX).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function dM(){var t=0,e=1,n,r,i,a,o=Ba,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 g,x;return arguments.length?([g,x]=m,o=f(g,x),u):[o(0),o(1)]}}return u.range=d(Lg),u.rangeRound=d(BD),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 Jd(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function OX(){var t=Zd(dM()(Ba));return t.copy=function(){return Jd(t,OX())},fu.apply(t,arguments)}function LX(){var t=GD(dM()).domain([1,10]);return t.copy=function(){return Jd(t,LX()).base(t.base())},fu.apply(t,arguments)}function IX(){var t=WD(dM());return t.copy=function(){return Jd(t,IX()).constant(t.constant())},fu.apply(t,arguments)}function r4(){var t=qD(dM());return t.copy=function(){return Jd(t,r4()).exponent(t.exponent())},fu.apply(t,arguments)}function Qve(){return r4.apply(null,arguments).exponent(.5)}function FX(){var t=[],e=Ba;function n(r){if(r!=null&&!isNaN(r=+r))return e((sy(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(Nd),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)=>L0e(t,a/r))},n.copy=function(){return FX(e).domain(t)},fu.apply(n,arguments)}function hM(){var t=0,e=.5,n=1,r=1,i,a,o,l,c,u=Ba,d,f=!1,m;function g(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))}g.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,g):[t,e,n]},g.clamp=function(y){return arguments.length?(f=!!y,g):f},g.interpolator=function(y){return arguments.length?(u=y,g):u};function x(y){return function(b){var v,M,S;return arguments.length?([v,M,S]=b,u=cye(y,[v,M,S]),g):[u(0),u(.5),u(1)]}}return g.range=x(Lg),g.rangeRound=x(BD),g.unknown=function(y){return arguments.length?(m=y,g):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,g}}function UX(){var t=Zd(hM()(Ba));return t.copy=function(){return Jd(t,UX())},fu.apply(t,arguments)}function zX(){var t=GD(hM()).domain([.1,1,10]);return t.copy=function(){return Jd(t,zX()).base(t.base())},fu.apply(t,arguments)}function BX(){var t=WD(hM());return t.copy=function(){return Jd(t,BX()).constant(t.constant())},fu.apply(t,arguments)}function i4(){var t=qD(hM());return t.copy=function(){return Jd(t,i4()).exponent(t.exponent())},fu.apply(t,arguments)}function Zve(){return i4.apply(null,arguments).exponent(.5)}const bb=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:FD,scaleDiverging:UX,scaleDivergingLog:zX,scaleDivergingPow:i4,scaleDivergingSqrt:Zve,scaleDivergingSymlog:BX,scaleIdentity:yX,scaleImplicit:T3,scaleLinear:bX,scaleLog:_X,scaleOrdinal:ID,scalePoint:U0e,scalePow:KD,scaleQuantile:MX,scaleQuantize:NX,scaleRadial:SX,scaleSequential:OX,scaleSequentialLog:LX,scaleSequentialPow:r4,scaleSequentialQuantile:FX,scaleSequentialSqrt:Qve,scaleSequentialSymlog:IX,scaleSqrt:Pye,scaleSymlog:wX,scaleThreshold:EX,scaleTime:Xve,scaleUtc:Yve,tickFormat:xX},Symbol.toStringTag,{value:"Module"}));var eh=t=>t.chartData,a4=et([eh],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),uy=(t,e,n,r)=>r?a4(t):eh(t);function Id(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(tr(e)&&tr(n))return!0}return!1}function d6(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function $X(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(tr(n))i=n;else if(typeof n=="function")return;if(tr(r))a=r;else if(typeof r=="function")return;var o=[i,a];if(Id(o))return o}}function Jve(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(Id(r))return d6(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(Ft(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&UB.test(i)){var c=UB.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(Ft(a))l=a;else if(typeof a=="function")try{e!=null&&(l=a(e?.[1]))}catch{}else if(typeof a=="string"&&zB.test(a)){var d=zB.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(Id(m))return e==null?m:d6(m,e,n)}}}var Ig=1e9,e_e={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},o4,Pr=!0,To="[DecimalError] ",of=To+"Invalid argument: ",s4=To+"Exponent out of range: ",Fg=Math.floor,Oh=Math.pow,t_e=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ls,Gi=1e7,Er=7,HX=9007199254740991,Xw=Fg(HX/Er),zt={};zt.absoluteValue=zt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};zt.comparedTo=zt.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};zt.decimalPlaces=zt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*Er;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};zt.dividedBy=zt.div=function(t){return Gc(this,new this.constructor(t))};zt.dividedToIntegerBy=zt.idiv=function(t){var e=this,n=e.constructor;return gr(Gc(e,new n(t),0,1),n.precision)};zt.equals=zt.eq=function(t){return!this.cmp(t)};zt.exponent=function(){return yi(this)};zt.greaterThan=zt.gt=function(t){return this.cmp(t)>0};zt.greaterThanOrEqualTo=zt.gte=function(t){return this.cmp(t)>=0};zt.isInteger=zt.isint=function(){return this.e>this.d.length-2};zt.isNegative=zt.isneg=function(){return this.s<0};zt.isPositive=zt.ispos=function(){return this.s>0};zt.isZero=function(){return this.s===0};zt.lessThan=zt.lt=function(t){return this.cmp(t)<0};zt.lessThanOrEqualTo=zt.lte=function(t){return this.cmp(t)<1};zt.logarithm=zt.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(Ls))throw Error(To+"NaN");if(n.s<1)throw Error(To+(n.s?"NaN":"-Infinity"));return n.eq(Ls)?new r(0):(Pr=!1,e=Gc(y0(n,a),y0(t,a),a),Pr=!0,gr(e,i))};zt.minus=zt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?WX(e,t):VX(e,(t.s=-t.s,t))};zt.modulo=zt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(To+"NaN");return n.s?(Pr=!1,e=Gc(n,t,0,1).times(t),Pr=!0,n.minus(e)):gr(new r(n),i)};zt.naturalExponential=zt.exp=function(){return GX(this)};zt.naturalLogarithm=zt.ln=function(){return y0(this)};zt.negated=zt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};zt.plus=zt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?VX(e,t):WX(e,(t.s=-t.s,t))};zt.precision=zt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(of+t);if(e=yi(i)+1,r=i.d.length-1,n=r*Er+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};zt.squareRoot=zt.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(To+"NaN")}for(t=yi(l),Pr=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=Al(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=Fg((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(Gc(l,a,o+2)).times(.5),Al(a.d).slice(0,o)===(e=Al(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(gr(a,n+1,0),a.times(a).eq(l)){r=a;break}}else if(e!="9999")break;o+=4}return Pr=!0,gr(r,n)};zt.times=zt.mul=function(t){var e,n,r,i,a,o,l,c,u,d=this,f=d.constructor,m=d.d,g=(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=g.length,c<u&&(a=m,m=g,g=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]+g[r]*m[i-r-1]+e,a[i--]=l%Gi|0,e=l/Gi|0;a[i]=(a[i]+e)%Gi|0}for(;!a[--o];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,Pr?gr(t,f.precision):t};zt.toDecimalPlaces=zt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(Il(t,0,Ig),e===void 0?e=r.rounding:Il(e,0,8),gr(n,t+yi(n)+1,e))};zt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Cf(r,!0):(Il(t,0,Ig),e===void 0?e=i.rounding:Il(e,0,8),r=gr(new i(r),t+1,e),n=Cf(r,!0,t+1)),n};zt.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?Cf(i):(Il(t,0,Ig),e===void 0?e=a.rounding:Il(e,0,8),r=gr(new a(i),t+yi(i)+1,e),n=Cf(r.abs(),!1,t+yi(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};zt.toInteger=zt.toint=function(){var t=this,e=t.constructor;return gr(new e(t),yi(t)+1,e.rounding)};zt.toNumber=function(){return+this};zt.toPower=zt.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(Ls);if(l=new c(l),!l.s){if(t.s<1)throw Error(To+"Infinity");return l}if(l.eq(Ls))return l;if(r=c.precision,t.eq(Ls))return gr(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,a=l.s,o){if((n=d<0?-d:d)<=HX){for(i=new c(Ls),e=Math.ceil(r/Er+4),Pr=!1;n%2&&(i=i.times(l),f6(i.d,e)),n=Fg(n/2),n!==0;)l=l.times(l),f6(l.d,e);return Pr=!0,t.s<0?new c(Ls).div(i):gr(i,r)}}else if(a<0)throw Error(To+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,Pr=!1,i=t.times(y0(l,r+u)),Pr=!0,i=GX(i),i.s=a,i};zt.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=yi(i),r=Cf(i,n<=a.toExpNeg||n>=a.toExpPos)):(Il(t,1,Ig),e===void 0?e=a.rounding:Il(e,0,8),i=gr(new a(i),t,e),n=yi(i),r=Cf(i,t<=n||n<=a.toExpNeg,t)),r};zt.toSignificantDigits=zt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(Il(t,1,Ig),e===void 0?e=r.rounding:Il(e,0,8)),gr(new r(n),t,e)};zt.toString=zt.valueOf=zt.val=zt.toJSON=zt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=yi(t),n=t.constructor;return Cf(t,e<=n.toExpNeg||e>=n.toExpPos)};function VX(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)),Pr?gr(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/Er),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)/Gi|0,c[a]%=Gi;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,Pr?gr(e,f):e}function Il(t,e,n){if(t!==~~t||t<e||t>n)throw Error(of+t)}function Al(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=Er-r.length,n&&(a+=nd(n)),a+=r;o=t[e],r=o+"",n=Er-r.length,n&&(a+=nd(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return a+o}var Gc=(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%Gi|0,o=a/Gi|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*Gi+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,g,x,y,b,v,M,S,A,E,k,C,R,T=r.constructor,P=r.s==i.s?1:-1,F=r.d,L=i.d;if(!r.s)return new T(r);if(!i.s)throw Error(To+"Division by zero");for(c=r.e-i.e,C=L.length,E=F.length,g=new T(P),x=g.d=[],u=0;L[u]==(F[u]||0);)++u;if(L[u]>(F[u]||0)&&--c,a==null?M=a=T.precision:o?M=a+(yi(r)-yi(i))+1:M=a,M<0)return new T(0);if(M=M/Er+2|0,u=0,C==1)for(d=0,L=L[0],M++;(u<E||d)&&M--;u++)S=d*Gi+(F[u]||0),x[u]=S/L|0,d=S%L|0;else{for(d=Gi/(L[0]+1)|0,d>1&&(L=t(L,d),F=t(F,d),C=L.length,E=F.length),A=C,y=F.slice(0,C),b=y.length;b<C;)y[b++]=0;R=L.slice(),R.unshift(0),k=L[0],L[1]>=Gi/2&&++k;do d=0,l=e(L,y,C,b),l<0?(v=y[0],C!=b&&(v=v*Gi+(y[1]||0)),d=v/k|0,d>1?(d>=Gi&&(d=Gi-1),f=t(L,d),m=f.length,b=y.length,l=e(f,y,m,b),l==1&&(d--,n(f,C<m?R: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,C,b),l<1&&(d++,n(y,C<b?R:L,b))),b=y.length):l===0&&(d++,y=[0]),x[u++]=d,l&&y[0]?y[b++]=F[A]||0:(y=[F[A]],b=1);while((A++<E||y[0]!==void 0)&&M--)}return x[0]||x.shift(),g.e=c,gr(g,o?a+yi(g)+1:a)}})();function GX(t,e){var n,r,i,a,o,l,c=0,u=0,d=t.constructor,f=d.precision;if(yi(t)>16)throw Error(s4+yi(t));if(!t.s)return new d(Ls);for(Pr=!1,l=f,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(Oh(2,u))/Math.LN10*2+5|0,l+=r,n=i=a=new d(Ls),d.precision=l;;){if(i=gr(i.times(t),l),n=n.times(++c),o=a.plus(Gc(i,n,l)),Al(o.d).slice(0,l)===Al(a.d).slice(0,l)){for(;u--;)a=gr(a.times(a),l);return d.precision=f,e==null?(Pr=!0,gr(a,f)):a}a=o}}function yi(t){for(var e=t.e*Er,n=t.d[0];n>=10;n/=10)e++;return e}function KT(t,e,n){if(e>t.LN10.sd())throw Pr=!0,n&&(t.precision=n),Error(To+"LN10 precision limit exceeded");return gr(new t(t.LN10),e)}function nd(t){for(var e="";t--;)e+="0";return e}function y0(t,e){var n,r,i,a,o,l,c,u,d,f=1,m=10,g=t,x=g.d,y=g.constructor,b=y.precision;if(g.s<1)throw Error(To+(g.s?"NaN":"-Infinity"));if(g.eq(Ls))return new y(0);if(e==null?(Pr=!1,u=b):u=e,g.eq(10))return e==null&&(Pr=!0),KT(y,u);if(u+=m,y.precision=u,n=Al(x),r=n.charAt(0),a=yi(g),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)g=g.times(t),n=Al(g.d),r=n.charAt(0),f++;a=yi(g),r>1?(g=new y("0."+n),a++):g=new y(r+"."+n.slice(1))}else return c=KT(y,u+2,b).times(a+""),g=y0(new y(r+"."+n.slice(1)),u-m).plus(c),y.precision=b,e==null?(Pr=!0,gr(g,b)):g;for(l=o=g=Gc(g.minus(Ls),g.plus(Ls),u),d=gr(g.times(g),u),i=3;;){if(o=gr(o.times(d),u),c=l.plus(Gc(o,new y(i),u)),Al(c.d).slice(0,u)===Al(l.d).slice(0,u))return l=l.times(2),a!==0&&(l=l.plus(KT(y,u+2,b).times(a+""))),l=Gc(l,new y(f),u),y.precision=b,e==null?(Pr=!0,gr(l,b)):l;l=c,i+=2}}function h6(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=Fg(n/Er),t.d=[],r=(n+1)%Er,n<0&&(r+=Er),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=Er;r<i;)t.d.push(+e.slice(r,r+=Er));e=e.slice(r),r=Er-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),Pr&&(t.e>Xw||t.e<-Xw))throw Error(s4+n)}else t.s=0,t.e=0,t.d=[0];return t}function gr(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+=Er,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/Er),a=f.length,d>=a)return t;for(u=a=f[d],o=1;a>=10;a/=10)o++;r%=Er,i=r-Er+o}if(n!==void 0&&(a=Oh(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/Oh(10,o-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=yi(t),f.length=1,e=e-a-1,f[0]=Oh(10,(Er-e%Er)%Er),t.e=Fg(-e/Er)||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=Oh(10,Er-r),f[d]=i>0?(u/Oh(10,o-i)%Oh(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==Gi&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=Gi)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(Pr&&(t.e>Xw||t.e<-Xw))throw Error(s4+yi(t));return t}function WX(t,e){var n,r,i,a,o,l,c,u,d,f,m=t.constructor,g=m.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new m(t),Pr?gr(e,g):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(g/Er),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]=Gi-1;--c[a],c[i]+=Gi}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,Pr?gr(e,g):e):new m(0)}function Cf(t,e,n){var r,i=yi(t),a=Al(t.d),o=a.length;return e?(n&&(r=n-o)>0?a=a.charAt(0)+"."+a.slice(1)+nd(r):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+nd(-i-1)+a,n&&(r=n-o)>0&&(a+=nd(r))):i>=o?(a+=nd(i+1-o),n&&(r=n-i-1)>0&&(a=a+"."+nd(r))):((r=i+1)<o&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+="."),a+=nd(r))),t.s<0?"-"+a:a}function f6(t,e){if(t.length>e)return t.length=e,!0}function qX(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(of+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 h6(o,a.toString())}else if(typeof a!="string")throw Error(of+a);if(a.charCodeAt(0)===45?(a=a.slice(1),o.s=-1):o.s=1,t_e.test(a))h6(o,a);else throw Error(of+a)}if(i.prototype=zt,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=qX,i.config=i.set=n_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 n_e(t){if(!t||typeof t!="object")throw Error(To+"Object expected");var e,n,r,i=["precision",1,Ig,"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(Fg(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(of+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(of+n+": "+r);return this}var o4=qX(e_e);Ls=new o4(1);const Jn=o4;var r_e=t=>t,KX={},XX=t=>t===KX,m6=t=>function e(){return arguments.length===0||arguments.length===1&&XX(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},YX=(t,e)=>t===1?e:m6(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!==KX).length;return a>=t?e(...r):YX(t-a,m6(function(){for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];var u=r.map(d=>XX(d)?l.shift():d);return e(...u,...l)}))}),i_e=t=>YX(t.length,t),P3=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},a_e=i_e((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),s_e=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return r_e;var i=n.reverse(),a=i[0],o=i.slice(1);return function(){return o.reduce((l,c)=>c(l),a(...arguments))}},R3=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function QX(t){var e;return t===0?e=1:e=Math.floor(new Jn(t).abs().log(10).toNumber())+1,e}function ZX(t,e,n){for(var r=new Jn(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var JX=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},eY=(t,e,n)=>{if(t.lte(0))return new Jn(0);var r=QX(t.toNumber()),i=new Jn(10).pow(r),a=t.div(i),o=r!==1?.05:.1,l=new Jn(Math.ceil(a.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new Jn(c.toNumber()):new Jn(Math.ceil(c.toNumber()))},o_e=(t,e,n)=>{var r=new Jn(1),i=new Jn(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new Jn(10).pow(QX(t)-1),i=new Jn(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new Jn(Math.floor(t)))}else t===0?i=new Jn(Math.floor((e-1)/2)):n||(i=new Jn(Math.floor(t)));var o=Math.floor((e-1)/2),l=s_e(a_e(c=>i.add(new Jn(c-o).mul(r)).toNumber()),P3);return l(0,e)},tY=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 Jn(0),tickMin:new Jn(0),tickMax:new Jn(0)};var o=eY(new Jn(n).sub(e).div(r-1),i,a),l;e<=0&&n>=0?l=new Jn(0):(l=new Jn(e).add(n).div(2),l=l.sub(new Jn(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new Jn(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?tY(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 Jn(c).mul(o)),tickMax:l.add(new Jn(u).mul(o))})},l_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]=JX([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...P3(0,i-1).map(()=>1/0)]:[...P3(0,i-1).map(()=>-1/0),c];return n>r?R3(u):u}if(l===c)return o_e(l,i,a);var{step:d,tickMin:f,tickMax:m}=tY(l,c,o,a,0),g=ZX(f,m.add(new Jn(.1).mul(d)),d);return n>r?R3(g):g},c_e=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=JX([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=eY(new Jn(l).sub(o).div(c-1),a,0),d=[...ZX(new Jn(o),new Jn(l),u),l];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?R3(d):d},nY=t=>t.rootProps.maxBarSize,u_e=t=>t.rootProps.barGap,rY=t=>t.rootProps.barCategoryGap,d_e=t=>t.rootProps.barSize,dy=t=>t.rootProps.stackOffset,iY=t=>t.rootProps.reverseStackOrder,l4=t=>t.options.chartName,c4=t=>t.rootProps.syncId,aY=t=>t.rootProps.syncMethod,u4=t=>t.options.eventEmitter,h_e=t=>t.rootProps.baseValue,Zr={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Rc={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},Rs={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},fM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},f_e={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Rc.angleAxisId,includeHidden:!1,name:void 0,reversed:Rc.reversed,scale:Rc.scale,tick:Rc.tick,tickCount:void 0,ticks:void 0,type:Rc.type,unit:void 0},m_e={allowDataOverflow:Rs.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:Rs.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Rs.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Rs.scale,tick:Rs.tick,tickCount:Rs.tickCount,ticks:void 0,type:Rs.type,unit:void 0},p_e={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:Rc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Rc.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Rc.scale,tick:Rc.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},g_e={allowDataOverflow:Rs.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:Rs.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Rs.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Rs.scale,tick:Rs.tick,tickCount:Rs.tickCount,ticks:void 0,type:"category",unit:void 0},d4=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?p_e:f_e,h4=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?g_e:m_e,mM=t=>t.polarOptions,f4=et([du,hu,ji],rX),sY=et([mM,f4],(t,e)=>{if(t!=null)return ja(t.innerRadius,e,0)}),oY=et([mM,f4],(t,e)=>{if(t!=null)return ja(t.outerRadius,e,e*.8)}),x_e=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},lY=et([mM],x_e);et([d4,lY],fM);var cY=et([f4,sY,oY],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});et([h4,cY],fM);var uY=et([kn,mM,sY,oY,du,hu],(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:ja(o,i,i/2),cy:ja(l,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),Dr=(t,e)=>e,hy=(t,e,n)=>n;function pM(t){return t?.id}function dY(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=pM(l);u.forEach((f,m)=>{var g=a==null||i?m:String(er(f,a,null)),x=er(f,l.dataKey,0),y;o.has(g)?y=o.get(g):y={},Object.assign(y,{[d]:x}),o.set(g,y)})}}),Array.from(o.values())}function gM(t){return t.stackId!=null&&t.dataKey!=null}var xM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function bM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function b_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 Di=t=>{var e=kn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},Ug=t=>t.tooltip.settings.axisId;function p6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Yw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?p6(Object(n),!0).forEach(function(r){y_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function y_e(t,e,n){return(e=v_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function v_e(t){var e=__e(t,"string");return typeof e=="symbol"?e:e+""}function __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 D3=[0,"auto"],Hi={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},hY=(t,e)=>t.cartesianAxis.xAxis[e],ql=(t,e)=>{var n=hY(t,e);return n??Hi},Vi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:D3,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:ry},fY=(t,e)=>t.cartesianAxis.yAxis[e],Kl=(t,e)=>{var n=fY(t,e);return n??Vi},w_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:""},m4=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??w_e},zr=(t,e,n)=>{switch(e){case"xAxis":return ql(t,n);case"yAxis":return Kl(t,n);case"zAxis":return m4(t,n);case"angleAxis":return d4(t,n);case"radiusAxis":return h4(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},S_e=(t,e,n)=>{switch(e){case"xAxis":return ql(t,n);case"yAxis":return Kl(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},fy=(t,e,n)=>{switch(e){case"xAxis":return ql(t,n);case"yAxis":return Kl(t,n);case"angleAxis":return d4(t,n);case"radiusAxis":return h4(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},mY=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function p4(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 my=t=>t.graphicalItems.cartesianItems,M_e=et([Dr,hy],p4),g4=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),py=et([my,zr,M_e],g4,{memoizeOptions:{resultEqualityCheck:bM}}),pY=et([py],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(gM)),gY=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),N_e=et([py],gY),x4=t=>t.map(e=>e.data).filter(Boolean).flat(1),E_e=et([py],x4,{memoizeOptions:{resultEqualityCheck:bM}}),b4=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},y4=et([E_e,uy],b4),v4=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:er(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:er(i,r)}))):t.map(r=>({value:r})),yM=et([y4,zr,py],v4);function xY(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function U1(t){if(Eo(t)||t instanceof Date){var e=Number(t);if(tr(e))return e}}function g6(t){if(Array.isArray(t)){var e=[U1(t[0]),U1(t[1])];return Id(e)?e:void 0}var n=U1(t);if(n!=null)return[n,n]}function su(t){return t.map(U1).filter(Sme)}function A_e(t,e,n){return!n||typeof e!="number"||bs(e)?[]:n.length?su(n.flatMap(r=>{var i=er(t,r.dataKey),a,o;if(Array.isArray(i)?[a,o]=i:a=o=i,!(!tr(a)||!tr(o)))return[e-a,e+o]})):[]}var Oi=t=>{var e=Di(t),n=Ug(t);return fy(t,e,n)},gy=et([Oi],t=>t?.dataKey),T_e=et([pY,uy,Oi],dY),bY=(t,e,n,r)=>{var i={},a=e.reduce((o,l)=>(l.stackId==null||(o[l.stackId]==null&&(o[l.stackId]=[]),o[l.stackId].push(l)),o),i);return Object.fromEntries(Object.entries(a).map(o=>{var[l,c]=o,u=r?[...c].reverse():c,d=u.map(pM);return[l,{stackedData:qge(t,d,n),graphicalItems:u}]}))},v0=et([T_e,pY,dy,iY],bY),yY=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var o=Qge(t,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},C_e=et([zr],t=>t.allowDataOverflow),_4=t=>{var e;if(t==null||!("domain"in t))return D3;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=su(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:D3},w4=et([zr],_4),S4=et([w4,C_e],$X),k_e=et([v0,eh,Dr,S4],yY,{memoizeOptions:{resultEqualityCheck:xM}}),vM=t=>t.errorBars,j_e=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>xY(n,r)),Qw=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]}},M4=(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=>xY(i,v)),m=er(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),g=A_e(l,m,f);if(g.length>=2){var x=Math.min(...g),y=Math.max(...g);(a==null||x<a)&&(a=x),(o==null||y>o)&&(o=y)}var b=g6(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=g6(er(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]))}),tr(a)&&tr(o))return[a,o]},P_e=et([y4,zr,N_e,vM,Dr],M4,{memoizeOptions:{resultEqualityCheck:xM}});function R_e(t){var{value:e}=t;if(Eo(e)||e instanceof Date)return e}var D_e=(t,e,n)=>{var r=t.map(R_e).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&Dq(r))?oX(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},vY=t=>t.referenceElements.dots,zg=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),O_e=et([vY,Dr,hy],zg),_Y=t=>t.referenceElements.areas,L_e=et([_Y,Dr,hy],zg),wY=t=>t.referenceElements.lines,I_e=et([wY,Dr,hy],zg),SY=(t,e)=>{var n=su(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},F_e=et(O_e,Dr,SY),MY=(t,e)=>{var n=su(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)]},U_e=et([L_e,Dr],MY);function z_e(t){var e;if(t.x!=null)return su([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:su(n)}function B_e(t){var e;if(t.y!=null)return su([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:su(n)}var NY=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?z_e(r):B_e(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},$_e=et([I_e,Dr],NY),H_e=et(F_e,$_e,U_e,(t,e,n)=>Qw(t,n,e)),N4=(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?Qw(r,a,i):Qw(a,i);return Jve(e,u,t.allowDataOverflow)},V_e=et([zr,w4,S4,k_e,P_e,H_e,kn,Dr],N4,{memoizeOptions:{resultEqualityCheck:xM}}),G_e=[0,1],E4=(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=Wl(e,a);if(u&&l==null){var d;return oX(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?D_e(r,t,u):i==="expand"?G_e:o}},A4=et([zr,kn,y4,yM,dy,Dr,V_e],E4),EY=(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(Q0(a));return l in bb?l:"point"}}},Bg=et([zr,kn,mY,l4,Dr],EY);function W_e(t){if(t!=null){if(t in bb)return bb[t]();var e="scale".concat(Q0(t));if(e in bb)return bb[e]()}}function T4(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=W_e(e);if(i!=null){var a=i.domain(n).range(r);return $ge(a),a}}}var C4=(t,e,n)=>{var r=_4(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&Id(t))return l_e(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&Id(t))return c_e(t,e.tickCount,e.allowDecimals)}},k4=et([A4,fy,Bg],C4),j4=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&Id(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},q_e=et([zr,A4,k4,Dr],j4),K_e=et(yM,zr,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(su(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}}),AY=et(K_e,kn,rY,ji,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!tr(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var o=ja(n,t*a),l=t*a/2;return l-o-(l-o)/a*o}return 0}),X_e=(t,e)=>{var n=ql(t,e);return n==null||typeof n.padding!="string"?0:AY(t,"xAxis",e,n.padding)},Y_e=(t,e)=>{var n=Kl(t,e);return n==null||typeof n.padding!="string"?0:AY(t,"yAxis",e,n.padding)},Q_e=et(ql,X_e,(t,e)=>{var n,r;if(t==null)return{left:0,right:0};var{padding:i}=t;return typeof i=="string"?{left:e,right:e}:{left:((n=i.left)!==null&&n!==void 0?n:0)+e,right:((r=i.right)!==null&&r!==void 0?r:0)+e}}),Z_e=et(Kl,Y_e,(t,e)=>{var n,r;if(t==null)return{top:0,bottom:0};var{padding:i}=t;return typeof i=="string"?{top:e,bottom:e}:{top:((n=i.top)!==null&&n!==void 0?n:0)+e,bottom:((r=i.bottom)!==null&&r!==void 0?r:0)+e}}),J_e=et([ji,Q_e,nM,tM,(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]}),e1e=et([ji,kn,Z_e,nM,tM,(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]}),xy=(t,e,n,r)=>{var i;switch(e){case"xAxis":return J_e(t,n,r);case"yAxis":return e1e(t,n,r);case"zAxis":return(i=m4(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return lY(t);case"radiusAxis":return cY(t,n);default:return}},TY=et([zr,xy],fM),Fd=et([zr,Bg,q_e,TY],T4);et([py,vM,Dr],j_e);function CY(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var _M=(t,e)=>e,wM=(t,e,n)=>n,t1e=et(J2,_M,wM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(CY)),n1e=et(eM,_M,wM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(CY)),kY=(t,e)=>({width:t.width,height:e.height}),r1e=(t,e)=>{var n=typeof e.width=="number"?e.width:ry;return{width:n,height:t.height}},jY=et(ji,ql,kY),i1e=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},a1e=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},s1e=et(hu,ji,t1e,_M,wM,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=kY(e,l);o==null&&(o=i1e(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}),o1e=et(du,ji,n1e,_M,wM,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=r1e(e,l);o==null&&(o=a1e(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}),l1e=(t,e)=>{var n=ql(t,e);if(n!=null)return s1e(t,n.orientation,n.mirror)},c1e=et([ji,ql,l1e,(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}}}),u1e=(t,e)=>{var n=Kl(t,e);if(n!=null)return o1e(t,n.orientation,n.mirror)},d1e=et([ji,Kl,u1e,(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}}}),PY=et(ji,Kl,(t,e)=>{var n=typeof e.width=="number"?e.width:ry;return{width:n,height:t.height}}),x6=(t,e,n)=>{switch(e){case"xAxis":return jY(t,n).width;case"yAxis":return PY(t,n).height;default:return}},RY=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,l=Wl(t,r),c=e.map(u=>u.value);if(o&&l&&a==="category"&&i&&Dq(c))return c}},P4=et([kn,yM,zr,Dr],RY),DY=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,o=Wl(t,r);if(o&&(i==="number"||a!=="auto"))return e.map(l=>l.value)}},R4=et([kn,yM,fy,Dr],DY),b6=et([kn,S_e,Bg,Fd,P4,R4,xy,k4,Dr],(t,e,n,r,i,a,o,l,c)=>{if(e!=null){var u=Wl(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}}}),h1e=(t,e,n,r,i,a,o,l,c)=>{if(!(e==null||r==null)){var u=Wl(t,c),{type:d,ticks:f,tickCount:m}=e,g=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/g:0;x=c==="angleAxis"&&a!=null&&a.length>=2?Xi(a[0]-a[1])*2*x:x;var y=f||i;if(y){var b=y.map((v,M)=>{var S=o?o.indexOf(v):v;return{index:M,coordinate:r(S)+x,value:v,offset:x}});return b.filter(v=>tr(v.coordinate))}return u&&l?l.map((v,M)=>({coordinate:r(v)+x,value:v,index:M,offset:x})).filter(v=>tr(v.coordinate)):r.ticks?r.ticks(m).map(v=>({coordinate:r(v)+x,value:v,offset:x})):r.domain().map((v,M)=>({coordinate:r(v)+x,value:o?o[v]:v,index:M,offset:x}))}},OY=et([kn,fy,Bg,Fd,k4,xy,P4,R4,Dr],h1e),f1e=(t,e,n,r,i,a,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=Wl(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?Xi(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}))}},Fl=et([kn,fy,Fd,xy,P4,R4,Dr],f1e),Ul=et(zr,Fd,(t,e)=>{if(!(t==null||e==null))return Yw(Yw({},t),{},{scale:e})}),m1e=et([zr,Bg,A4,TY],T4);et((t,e,n)=>m4(t,n),m1e,(t,e)=>{if(!(t==null||e==null))return Yw(Yw({},t),{},{scale:e})});var p1e=et([kn,J2,eM],(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}}),LY=t=>t.options.defaultTooltipEventType,IY=t=>t.options.validateTooltipEventTypes;function FY(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function D4(t,e){var n=LY(t),r=IY(t);return FY(e,n,r)}function g1e(t){return Ot(e=>D4(e,t))}var UY=(t,e)=>{var n,r=Number(e);if(!(bs(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},x1e=t=>t.tooltip.settings,ud={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},b1e={itemInteraction:{click:ud,hover:ud},axisInteraction:{click:ud,hover:ud},keyboardInteraction:ud,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}},zY=ys({name:"tooltip",initialState:b1e,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:kr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Qo(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:kr()},removeTooltipEntrySettings:{reducer(t,e){var n=Qo(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:kr()},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:y1e,replaceTooltipEntrySettings:v1e,removeTooltipEntrySettings:_1e,setTooltipSettingsState:w1e,setActiveMouseOverItemIndex:BY,mouseLeaveItem:S1e,mouseLeaveChart:$Y,setActiveClickItemIndex:M1e,setMouseOverAxisIndex:HY,setMouseClickAxisIndex:N1e,setSyncInteraction:O3,setKeyboardInteraction:L3}=zY.actions,E1e=zY.reducer;function y6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function c_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?y6(Object(n),!0).forEach(function(r){A1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function A1e(t,e,n){return(e=T1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function T1e(t){var e=C1e(t,"string");return typeof e=="symbol"?e:e+""}function C1e(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 k1e(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function j1e(t){return t.index!=null}var VY=(t,e,n,r)=>{if(e==null)return ud;var i=k1e(t,e,n);if(i==null)return ud;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(j1e(i)){if(a)return c_(c_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return c_(c_({},ud),{},{coordinate:i.coordinate})};function P1e(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 R1e(t,e){var n=P1e(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 D1e(t,e,n){if(n==null||e==null)return!0;var r=er(t,e);return r==null||!Id(n)?!0:R1e(r,n)}var O4=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!tr(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||D1e(u,n,r)?String(c):null},GY=(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}}}},WY=(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})},by=t=>t.options.tooltipPayloadSearcher,$g=t=>t.tooltip;function v6(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 _6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?v6(Object(n),!0).forEach(function(r){O1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):v6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function O1e(t,e,n){return(e=L1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function L1e(t){var e=I1e(t,"string");return typeof e=="symbol"?e:e+""}function I1e(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 F1e(t,e){return t??e}var qY=(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,g)=>{var x,{dataDefinedOnItem:y,settings:b}=g,v=F1e(y,l),M=Array.isArray(v)?CK(v,u,d):v,S=(x=b?.dataKey)!==null&&x!==void 0?x:r,A=b?.nameKey,E;if(r&&Array.isArray(M)&&!Array.isArray(M[0])&&o==="axis"?E=Oq(M,r,i):E=a(M,e,c,A),Array.isArray(E))E.forEach(C=>{var R=_6(_6({},b),{},{name:C.name,unit:C.unit,color:void 0,fill:void 0});m.push(BB({tooltipEntrySettings:R,dataKey:C.dataKey,payload:C.payload,value:er(C.payload,C.dataKey),name:C.name}))});else{var k;m.push(BB({tooltipEntrySettings:b,dataKey:S,payload:E,value:er(E,S),name:(k=er(E,A))!==null&&k!==void 0?k:b?.name}))}return m},f)}},L4=et([Oi,kn,mY,l4,Di],EY),U1e=et([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),z1e=et([Di,Ug],p4),yy=et([U1e,Oi,z1e],g4,{memoizeOptions:{resultEqualityCheck:bM}}),B1e=et([yy],t=>t.filter(gM)),$1e=et([yy],x4,{memoizeOptions:{resultEqualityCheck:bM}}),Hg=et([$1e,eh],b4),H1e=et([B1e,eh,Oi],dY),I4=et([Hg,Oi,yy],v4),KY=et([Oi],_4),V1e=et([Oi],t=>t.allowDataOverflow),XY=et([KY,V1e],$X),G1e=et([yy],t=>t.filter(gM)),W1e=et([H1e,G1e,dy,iY],bY),q1e=et([W1e,eh,Di,XY],yY),K1e=et([yy],gY),X1e=et([Hg,Oi,K1e,vM,Di],M4,{memoizeOptions:{resultEqualityCheck:xM}}),Y1e=et([vY,Di,Ug],zg),Q1e=et([Y1e,Di],SY),Z1e=et([_Y,Di,Ug],zg),J1e=et([Z1e,Di],MY),ewe=et([wY,Di,Ug],zg),twe=et([ewe,Di],NY),nwe=et([Q1e,twe,J1e],Qw),rwe=et([Oi,KY,XY,q1e,X1e,nwe,kn,Di],N4),vy=et([Oi,kn,Hg,I4,dy,Di,rwe],E4),iwe=et([vy,Oi,L4],C4),awe=et([Oi,vy,iwe,Di],j4),YY=t=>{var e=Di(t),n=Ug(t),r=!1;return xy(t,e,n,r)},QY=et([Oi,YY],fM),ZY=et([Oi,L4,awe,QY],T4),swe=et([kn,I4,Oi,Di],RY),owe=et([kn,I4,Oi,Di],DY),lwe=(t,e,n,r,i,a,o,l)=>{if(e){var{type:c}=e,u=Wl(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?Xi(i[0]-i[1])*2*f:f,u&&o?o.map((m,g)=>({coordinate:r(m)+f,value:m,index:g,offset:f})):r.domain().map((m,g)=>({coordinate:r(m)+f,value:a?a[m]:m,index:g,offset:f}))}}},mu=et([kn,Oi,L4,ZY,YY,swe,owe,Di],lwe),F4=et([LY,IY,x1e],(t,e,n)=>FY(n.shared,t,e)),JY=t=>t.tooltip.settings.trigger,U4=t=>t.tooltip.settings.defaultIndex,_y=et([$g,F4,JY,U4],VY),Ud=et([_y,Hg,gy,vy],O4),eQ=et([mu,Ud],UY),z4=et([_y],t=>{if(t)return t.dataKey}),cwe=et([_y],t=>{if(t)return t.graphicalItemId}),tQ=et([$g,F4,JY,U4],WY),uwe=et([du,hu,kn,ji,mu,U4,tQ,by],GY),dwe=et([_y,uwe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),hwe=et([_y],t=>t.active),fwe=et([tQ,Ud,eh,gy,eQ,by,F4],qY),mwe=et([fwe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function w6(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 S6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?w6(Object(n),!0).forEach(function(r){pwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pwe(t,e,n){return(e=gwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gwe(t){var e=xwe(t,"string");return typeof e=="symbol"?e:e+""}function xwe(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 bwe=()=>Ot(Oi),ywe=()=>{var t=bwe(),e=Ot(mu),n=Ot(ZY);return Ld(!t||!n?void 0:S6(S6({},t),{},{scale:n}),e)};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 Pm(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){vwe(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 vwe(t,e,n){return(e=_we(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _we(t){var e=wwe(t,"string");return typeof e=="symbol"?e:e+""}function wwe(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 Swe=(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}},Mwe=(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 Pm(Pm(Pm({},r),gi(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var l=i.coordinate,{angle:c}=r;return Pm(Pm(Pm({},r),gi(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 Nwe(t,e){var{chartX:n,chartY:r}=t;return n>=e.left&&n<=e.left+e.width&&r>=e.top&&r<=e.top+e.height}var nQ=(t,e,n,r,i)=>{var a,o=-1,l=(a=e?.length)!==null&&a!==void 0?a:0;if(l<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var c=0;c<l;c++){var u=c>0?n[c-1].coordinate:n[l-1].coordinate,d=n[c].coordinate,f=c>=l-1?n[0].coordinate:n[c+1].coordinate,m=void 0;if(Xi(d-u)!==Xi(f-d)){var g=[];if(Xi(f-d)===Xi(i[1]-i[0])){m=f;var x=d+i[1]-i[0];g[0]=Math.min(x,(x+u)/2),g[1]=Math.max(x,(x+u)/2)}else{m=u;var y=f+i[1]-i[0];g[0]=Math.min(d,(y+d)/2),g[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>=g[0]&&t<=g[1]){({index:o}=n[c]);break}}else{var v=Math.min(u,f),M=Math.max(u,f);if(t>(v+d)/2&&t<=(M+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},rQ=()=>Ot(l4),B4=(t,e)=>e,iQ=(t,e,n)=>n,$4=(t,e,n,r)=>r,Ewe=et(mu,t=>V2(t,e=>e.coordinate)),H4=et([$g,B4,iQ,$4],VY),V4=et([H4,Hg,gy,vy],O4),Awe=(t,e,n)=>{if(e!=null){var r=$g(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},aQ=et([$g,B4,iQ,$4],WY),Zw=et([du,hu,kn,ji,mu,$4,aQ,by],GY),Twe=et([H4,Zw],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),sQ=et([mu,V4],UY),Cwe=et([aQ,V4,eh,gy,sQ,by,B4],qY),kwe=et([H4,V4],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),jwe=(t,e,n,r,i,a,o)=>{if(!(!t||!n||!r||!i)&&Nwe(t,o)){var l=Zge(t,e),c=nQ(l,a,i,n,r),u=Swe(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},Pwe=(t,e,n,r,i,a,o)=>{if(!(!t||!r||!i||!a||!n)){var l=p0e(t,n);if(l){var c=Jge(l,e),u=nQ(c,o,a,r,i),d=Mwe(e,a,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},Rwe=(t,e,n,r,i,a,o,l)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?jwe(t,e,r,i,a,o,l):Pwe(t,e,n,r,i,a,o)},Dwe=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}}),Owe=et(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Zr)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:b_e}});function N6(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 E6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?N6(Object(n),!0).forEach(function(r){Lwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):N6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Lwe(t,e,n){return(e=Iwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Iwe(t){var e=Fwe(t,"string");return typeof e=="symbol"?e:e+""}function Fwe(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 Uwe={},zwe={zIndexMap:Object.values(Zr).reduce((t,e)=>E6(E6({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),Uwe)},Bwe=new Set(Object.values(Zr));function $we(t){return Bwe.has(t)}var oQ=ys({name:"zIndex",initialState:zwe,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:kr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!$we(n)&&delete t.zIndexMap[n])},prepare:kr()},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:kr()},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:kr()}}}),{registerZIndexPortal:Hwe,unregisterZIndexPortal:Vwe,registerZIndexPortalId:Gwe,unregisterZIndexPortalId:Wwe}=oQ.actions,qwe=oQ.reducer;function Pa(t){var{zIndex:e,children:n}=t,r=jxe(),i=r&&e!==void 0&&e!==0,a=Pi(),o=xr();w.useLayoutEffect(()=>i?(o(Hwe({zIndex:e})),()=>{o(Vwe({zIndex:e}))}):Z0,[o,e,i]);var l=Ot(u=>Dwe(u,e,a));if(!i)return n;if(!l)return null;var c=document.getElementById(l);return c?Ic.createPortal(n,c):null}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 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 u_(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){Kwe(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 Kwe(t,e,n){return(e=Xwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Xwe(t){var e=Ywe(t,"string");return typeof e=="symbol"?e:e+""}function Ywe(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 Qwe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return w.isValidElement(e)?w.cloneElement(e,r):w.createElement(n,r)}function Zwe(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,g=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var x,y,b;if(d==="ScatterChart")x=f,y=kbe,b=Zr.cursorLine;else if(d==="BarChart")x=jbe(l,f,a,o),y=nX,b=Zr.cursorRectangle;else if(l==="radial"&&Iq(f)){var{cx:v,cy:M,radius:S,startAngle:A,endAngle:E}=iX(f);x={cx:v,cy:M,startAngle:A,endAngle:E,innerRadius:S,outerRadius:S},y=sX,b=Zr.cursorLine}else x={points:y0e(l,f,a)},y=Ip,b=Zr.cursorLine;var k=typeof c=="object"&&"className"in c?c.className:void 0,C=u_(u_(u_(u_({stroke:"#ccc",pointerEvents:"none"},a),x),Nf(c)),{},{payload:m,payloadIndex:g,className:In("recharts-tooltip-cursor",k)});return w.createElement(Pa,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:b},w.createElement(Qwe,{cursor:c,cursorComp:y,cursorProps:C}))}function Jwe(t){var e=ywe(),n=zK(),r=Gf(),i=rQ();return e==null||n==null||r==null||i==null?null:w.createElement(Zwe,I3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var lQ=w.createContext(null),eSe=()=>w.useContext(lQ),XT={exports:{}},T6;function tSe(){return T6||(T6=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 g=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],g]:c._events[x].push(g):(c._events[x]=g,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,g=f.length,x=new Array(g);m<g;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,g,x){var y=n?n+u:u;if(!this._events[y])return!1;var b=this._events[y],v=arguments.length,M,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,g),!0;case 6:return b.fn.call(b.context,d,f,m,g,x),!0}for(S=1,M=new Array(v-1);S<v;S++)M[S-1]=arguments[S];b.fn.apply(b.context,M)}else{var A=b.length,E;for(S=0;S<A;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(!M)for(E=1,M=new Array(v-1);E<v;E++)M[E-1]=arguments[E];b[S].fn.apply(b[S].context,M)}}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 g=n?n+u:u;if(!this._events[g])return this;if(!d)return o(this,g),this;var x=this._events[g];if(x.fn)x.fn===d&&(!m||x.once)&&(!f||x.context===f)&&o(this,g);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[g]=b.length===1?b[0]:b:o(this,g)}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})(XT)),XT.exports}var nSe=tSe();const rSe=Co(nSe);var _0=new rSe,F3="recharts.syncEvent.tooltip",C6="recharts.syncEvent.brush";function SM(t,e){if(e){var n=Number.parseInt(e,10);if(!bs(n))return t?.[n]}}var iSe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},cQ=ys({name:"options",initialState:iSe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),aSe=cQ.reducer,{createEventEmitter:sSe}=cQ.actions;function oSe(t){return t.tooltip.syncInteraction}var lSe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},uQ=ys({name:"chartData",initialState:lSe,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:k6,setDataStartEndIndexes:cSe,setComputedData:iXe}=uQ.actions,uSe=uQ.reducer,dSe=["x","y"];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 Rm(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){hSe(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 hSe(t,e,n){return(e=fSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fSe(t){var e=mSe(t,"string");return typeof e=="symbol"?e:e+""}function mSe(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 pSe(t,e){if(t==null)return{};var n,r,i=gSe(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 gSe(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 xSe(){var t=Ot(c4),e=Ot(u4),n=xr(),r=Ot(aY),i=Ot(mu),a=Gf(),o=iy(),l=Ot(c=>c.rootProps.className);w.useEffect(()=>{if(t==null)return Z0;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 g=d.payload.coordinate,{x,y}=g,b=pSe(g,dSe),{x:v,y:M,width:S,height:A}=d.payload.sourceViewBox,E=Rm(Rm({},b),{},{x:o.x+(S?(x-v)/S:0)*o.width,y:o.y+(A?(y-M)/A:0)*o.height});n(Rm(Rm({},d),{},{payload:Rm(Rm({},d.payload),{},{coordinate:E})}))}else n(d);return}if(i!=null){var k;if(typeof r=="function"){var C={activeTooltipIndex:d.payload.index==null?void 0:Number(d.payload.index),isTooltipActive:d.payload.active,activeIndex:d.payload.index==null?void 0:Number(d.payload.index),activeLabel:d.payload.label,activeDataKey:d.payload.dataKey,activeCoordinate:d.payload.coordinate},R=r(i,C);k=i[R]}else r==="value"&&(k=i.find(Y=>String(Y.value)===d.payload.label));var{coordinate:T}=d.payload;if(k==null||d.payload.active===!1||T==null||o==null){n(O3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:P,y:F}=T,L=Math.min(P,o.x+o.width),X=Math.min(F,o.y+o.height),D={x:a==="horizontal"?k.coordinate:L,y:a==="horizontal"?X:k.coordinate},K=O3({active:d.payload.active,coordinate:D,dataKey:d.payload.dataKey,index:String(k.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(K)}}};return _0.on(F3,c),()=>{_0.off(F3,c)}},[l,n,e,t,r,i,a,o])}function bSe(){var t=Ot(c4),e=Ot(u4),n=xr();w.useEffect(()=>{if(t==null)return Z0;var r=(i,a,o)=>{e!==o&&t===i&&n(cSe(a))};return _0.on(C6,r),()=>{_0.off(C6,r)}},[n,e,t])}function ySe(){var t=xr();w.useEffect(()=>{t(sSe())},[t]),xSe(),bSe()}function vSe(t,e,n,r,i,a){var o=Ot(g=>Awe(g,t,e)),l=Ot(u4),c=Ot(c4),u=Ot(aY),d=Ot(oSe),f=d?.active,m=iy();w.useEffect(()=>{if(!f&&c!=null&&l!=null){var g=O3({active:a,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:m,graphicalItemId:void 0});_0.emit(F3,c,g,l)}},[f,n,o,i,r,l,c,u,a,m])}function P6(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 R6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P6(Object(n),!0).forEach(function(r){_Se(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _Se(t,e,n){return(e=wSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wSe(t){var e=SSe(t,"string");return typeof e=="symbol"?e:e+""}function SSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function MSe(t){return t.dataKey}function NSe(t,e){return w.isValidElement(t)?w.cloneElement(t,e):typeof t=="function"?w.createElement(t,e):w.createElement(cbe,e)}var D6=[],ESe={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 z1(t){var e,n,r=Ur(t,ESe),{active:i,allowEscapeViewBox:a,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:m,position:g,reverseDirection:x,useTranslate3d:y,wrapperStyle:b,cursor:v,shared:M,trigger:S,defaultIndex:A,portal:E,axisId:k}=r,C=xr(),R=typeof A=="number"?String(A):A;w.useEffect(()=>{C(w1e({shared:M,trigger:S,axisId:k,active:i,defaultIndex:R}))},[C,M,S,k,i,R]);var T=iy(),P=QK(),F=g1e(M),{activeIndex:L,isActive:X}=(e=Ot(fe=>kwe(fe,F,S,R)))!==null&&e!==void 0?e:{},D=Ot(fe=>Cwe(fe,F,S,R)),K=Ot(fe=>sQ(fe,F,S,R)),Y=Ot(fe=>Twe(fe,F,S,R)),q=D,Z=eSe(),re=(n=i??X)!==null&&n!==void 0?n:!1,[oe,B]=Jq([q,re]),G=F==="axis"?K:void 0;vSe(F,S,Y,G,L,re);var J=E??Z;if(J==null||T==null||F==null)return null;var te=q??D6;re||(te=D6),u&&te.length&&(te=qq(te.filter(fe=>fe.value!=null&&(fe.hide!==!0||r.includeHidden)),m,MSe));var ae=te.length>0,de=w.createElement(gbe,{allowEscapeViewBox:a,animationDuration:o,animationEasing:l,isAnimationActive:d,active:re,coordinate:Y,hasPayload:ae,offset:f,position:g,reverseDirection:x,useTranslate3d:y,viewBox:T,wrapperStyle:b,lastBoundingBox:oe,innerRef:B,hasPortalFromProps:!!E},NSe(c,R6(R6({},r),{},{payload:te,label:G,active:re,activeIndex:L,coordinate:Y,accessibilityLayer:P})));return w.createElement(w.Fragment,null,Ic.createPortal(de,J),re&&w.createElement(Jwe,{cursor:v,tooltipEventType:F,coordinate:Y,payload:te,index:L}))}var wy=t=>null;wy.displayName="Cell";function ASe(t,e,n){return(e=TSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function TSe(t){var e=CSe(t,"string");return typeof e=="symbol"?e:e+""}function CSe(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 kSe{constructor(e){ASe(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 O6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function jSe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?O6(Object(n),!0).forEach(function(r){PSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):O6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function PSe(t,e,n){return(e=RSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function RSe(t){var e=DSe(t,"string");return typeof e=="symbol"?e:e+""}function DSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var OSe={cacheSize:2e3,enableCache:!0},dQ=jSe({},OSe),L6=new kSe(dQ.cacheSize),LSe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},I6="recharts_measurement_span";function ISe(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 F6=(t,e)=>{try{var n=document.getElementById(I6);n||(n=document.createElement("span"),n.setAttribute("id",I6),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,LSe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},Rb=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Rg.isSsr)return{width:0,height:0};if(!dQ.enableCache)return F6(e,n);var r=ISe(e,n),i=L6.get(r);if(i)return i;var a=F6(e,n);return L6.set(r,a),a},U6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,z6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,FSe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,USe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,hQ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},zSe=Object.keys(hQ),Tp="NaN";function BSe(t,e){return t*hQ[e]}class ss{static parse(e){var n,[,r,i]=(n=USe.exec(e))!==null&&n!==void 0?n:[];return new ss(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,bs(e)&&(this.unit=""),n!==""&&!FSe.test(n)&&(this.num=NaN,this.unit=""),zSe.includes(n)&&(this.num=BSe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new ss(NaN,""):new ss(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new ss(NaN,""):new ss(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new ss(NaN,""):new ss(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new ss(NaN,""):new ss(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return bs(this.num)}}function fQ(t){if(t.includes(Tp))return Tp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=U6.exec(e))!==null&&n!==void 0?n:[],o=ss.parse(r??""),l=ss.parse(a??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return Tp;e=e.replace(U6,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,m]=(u=z6.exec(e))!==null&&u!==void 0?u:[],g=ss.parse(d??""),x=ss.parse(m??""),y=f==="+"?g.add(x):g.subtract(x);if(y.isNaN())return Tp;e=e.replace(z6,y.toString())}return e}var B6=/\(([^()]*)\)/;function $Se(t){for(var e=t,n;(n=B6.exec(e))!=null;){var[,r]=n;e=e.replace(B6,fQ(r))}return e}function HSe(t){var e=t.replace(/\s+/g,"");return e=$Se(e),e=fQ(e),e}function VSe(t){try{return HSe(t)}catch{return Tp}}function YT(t){var e=VSe(t.slice(5,-1));return e===Tp?"":e}var GSe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],WSe=["dx","dy","angle","className","breakAll"];function U3(){return U3=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},U3.apply(null,arguments)}function $6(t,e){if(t==null)return{};var n,r,i=qSe(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 qSe(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 mQ=/[ \f\n\r\t\v\u2028\u2029]+/,pQ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Ar(e)||(n?i=e.toString().split(""):i=e.toString().split(mQ));var a=i.map(l=>({word:l,width:Rb(l,r).width})),o=n?0:Rb(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:o}}catch{return null}};function KSe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var gQ=(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},[]),xQ=t=>t.reduce((e,n)=>e.width>n.width?e:n),XSe="…",H6=(t,e,n,r,i,a,o,l)=>{var c=t.slice(0,e),u=pQ({breakAll:n,style:r,children:c+XSe});if(!u)return[!1,[]];var d=gQ(u.wordsWithComputedWidth,a,o,l),f=d.length>i||xQ(d).width>Number(a);return[f,d]},YSe=(t,e,n,r,i)=>{var{maxLines:a,children:o,style:l,breakAll:c}=t,u=Ft(a),d=String(o),f=gQ(e,r,n,i);if(!u||i)return f;var m=f.length>a||xQ(f).width>Number(r);if(!m)return f;for(var g=0,x=d.length-1,y=0,b;g<=x&&y<=d.length-1;){var v=Math.floor((g+x)/2),M=v-1,[S,A]=H6(d,M,c,l,a,r,n,i),[E]=H6(d,v,c,l,a,r,n,i);if(!S&&!E&&(g=v+1),S&&E&&(x=v-1),!S&&E){b=A;break}y++}return b||f},V6=t=>{var e=Ar(t)?[]:t.toString().split(mQ);return[{words:e,width:void 0}]},QSe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=t;if((e||n)&&!Rg.isSsr){var l,c,u=pQ({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return V6(r);return YSe({breakAll:a,children:r,maxLines:o,style:i},l,c,e,!!n)}return V6(r)},bQ="#808080",ZSe={angle:0,breakAll:!1,capHeight:"0.71em",fill:bQ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},MM=w.forwardRef((t,e)=>{var n=Ur(t,ZSe),{x:r,y:i,lineHeight:a,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=$6(n,GSe),m=w.useMemo(()=>QSe({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:g,dy:x,angle:y,className:b,breakAll:v}=f,M=$6(f,WSe);if(!Eo(r)||!Eo(i)||m.length===0)return null;var S=Number(r)+(Ft(g)?g:0),A=Number(i)+(Ft(x)?x:0);if(!tr(S)||!tr(A))return null;var E;switch(d){case"start":E=YT("calc(".concat(o,")"));break;case"middle":E=YT("calc(".concat((m.length-1)/2," * -").concat(a," + (").concat(o," / 2))"));break;default:E=YT("calc(".concat(m.length-1," * -").concat(a,")"));break}var k=[];if(c){var C=m[0].width,{width:R}=f;k.push("scale(".concat(Ft(R)&&Ft(C)?R/C:1,")"))}return y&&k.push("rotate(".concat(y,", ").concat(S,", ").concat(A,")")),k.length&&(M.transform=k.join(" ")),w.createElement("text",U3({},ya(M),{ref:e,x:S,y:A,className:In("recharts-text",b),textAnchor:u,fill:l.includes("url")?bQ:l}),m.map((T,P)=>{var F=T.words.join(v?"":" ");return w.createElement("tspan",{x:S,dy:P===0?E:a,key:"".concat(F,"-").concat(P)},F)}))});MM.displayName="Text";var JSe=["labelRef"];function e2e(t,e){if(t==null)return{};var n,r,i=t2e(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 t2e(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 G6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ii(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?G6(Object(n),!0).forEach(function(r){n2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):G6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function n2e(t,e,n){return(e=r2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function r2e(t){var e=i2e(t,"string");return typeof e=="symbol"?e:e+""}function i2e(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 Dc(){return Dc=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},Dc.apply(null,arguments)}var yQ=w.createContext(null),vQ=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(yQ.Provider,{value:c},l)},_Q=()=>{var t=w.useContext(yQ),e=iy();return t||UK(e)},a2e=w.createContext(null),s2e=()=>{var t=w.useContext(a2e),e=Ot(uY);return t||e},o2e=t=>{var{value:e,formatter:n}=t,r=Ar(t.children)?e:t.children;return typeof n=="function"?n(r):r},G4=t=>t!=null&&typeof t=="function",l2e=(t,e)=>{var n=Xi(e-t),r=Math.min(Math.abs(e-t),360);return n*r},c2e=(t,e,n,r,i)=>{var{offset:a,className:o}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:m,clockWise:g}=i,x=(u+d)/2,y=l2e(f,m),b=y>=0?1:-1,v,M;switch(e){case"insideStart":v=f+b*a,M=g;break;case"insideEnd":v=m-b*a,M=!g;break;case"end":v=m+b*a,M=g;break;default:throw new Error("Unsupported position ".concat(e))}M=y<=0?M:!M;var S=gi(l,c,x,v),A=gi(l,c,x,v+(M?1:-1)*359),E="M".concat(S.x,",").concat(S.y,`
- A`).concat(x,",").concat(x,",0,1,").concat(M?0:1,`,
- `).concat(A.x,",").concat(A.y),k=Ar(t.id)?o0("recharts-radial-line-"):t.id;return w.createElement("text",Dc({},r,{dominantBaseline:"central",className:In("recharts-radial-bar-label",o)}),w.createElement("defs",null,w.createElement("path",{id:k,d:E})),w.createElement("textPath",{xlinkHref:"#".concat(k)},n))},u2e=(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}=gi(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:g,y:x}=gi(r,i,m,u);return{x:g,y:x,textAnchor:"middle",verticalAnchor:"middle"}},z3=t=>"cx"in t&&Ft(t.cx),d2e=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,a;n!=null&&!z3(n)&&(a=n);var{x:o,y:l,upperWidth:c,lowerWidth:u,height:d}=e,f=o,m=o+(c-u)/2,g=(f+m)/2,x=(c+u)/2,y=f+c/2,b=d>=0?1:-1,v=b*r,M=b>0?"end":"start",S=b>0?"start":"end",A=c>=0?1:-1,E=A*r,k=A>0?"end":"start",C=A>0?"start":"end";if(i==="top"){var R={x:f+c/2,y:l-v,textAnchor:"middle",verticalAnchor:M};return ii(ii({},R),a?{height:Math.max(l-a.y,0),width:c}:{})}if(i==="bottom"){var T={x:m+u/2,y:l+d+v,textAnchor:"middle",verticalAnchor:S};return ii(ii({},T),a?{height:Math.max(a.y+a.height-(l+d),0),width:u}:{})}if(i==="left"){var P={x:g-E,y:l+d/2,textAnchor:k,verticalAnchor:"middle"};return ii(ii({},P),a?{width:Math.max(P.x-a.x,0),height:d}:{})}if(i==="right"){var F={x:g+x+E,y:l+d/2,textAnchor:C,verticalAnchor:"middle"};return ii(ii({},F),a?{width:Math.max(a.x+a.width-F.x,0),height:d}:{})}var L=a?{width:x,height:d}:{};return i==="insideLeft"?ii({x:g+E,y:l+d/2,textAnchor:C,verticalAnchor:"middle"},L):i==="insideRight"?ii({x:g+x-E,y:l+d/2,textAnchor:k,verticalAnchor:"middle"},L):i==="insideTop"?ii({x:f+c/2,y:l+v,textAnchor:"middle",verticalAnchor:S},L):i==="insideBottom"?ii({x:m+u/2,y:l+d-v,textAnchor:"middle",verticalAnchor:M},L):i==="insideTopLeft"?ii({x:f+E,y:l+v,textAnchor:C,verticalAnchor:S},L):i==="insideTopRight"?ii({x:f+c-E,y:l+v,textAnchor:k,verticalAnchor:S},L):i==="insideBottomLeft"?ii({x:m+E,y:l+d-v,textAnchor:C,verticalAnchor:M},L):i==="insideBottomRight"?ii({x:m+u-E,y:l+d-v,textAnchor:k,verticalAnchor:M},L):i&&typeof i=="object"&&(Ft(i.x)||tu(i.x))&&(Ft(i.y)||tu(i.y))?ii({x:o+ja(i.x,x),y:l+ja(i.y,d),textAnchor:"end",verticalAnchor:"end"},L):ii({x:y,y:l+d/2,textAnchor:"middle",verticalAnchor:"middle"},L)},h2e={angle:0,offset:5,zIndex:Zr.label,position:"middle",textBreakAll:!1};function rd(t){var e=Ur(t,h2e),{viewBox:n,position:r,value:i,children:a,content:o,className:l="",textBreakAll:c,labelRef:u}=e,d=s2e(),f=_Q(),m=r==="center"?f:d??f,g,x,y;if(n==null?g=m:z3(n)?g=n:g=UK(n),!g||Ar(i)&&Ar(a)&&!w.isValidElement(o)&&typeof o!="function")return null;var b=ii(ii({},e),{},{viewBox:g});if(w.isValidElement(o)){var{labelRef:v}=b,M=e2e(b,JSe);return w.cloneElement(o,M)}if(typeof o=="function"){if(x=w.createElement(o,b),w.isValidElement(x))return x}else x=o2e(e);var S=ya(e);if(z3(g)){if(r==="insideStart"||r==="insideEnd"||r==="end")return c2e(e,r,x,S,g);y=u2e(g,e.offset,e.position)}else y=d2e(e,g);return w.createElement(Pa,{zIndex:e.zIndex},w.createElement(MM,Dc({ref:u,className:In("recharts-label",l)},S,y,{textAnchor:KSe(S.textAnchor)?S.textAnchor:y.textAnchor,breakAll:c}),x))}rd.displayName="Label";var f2e=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?w.createElement(rd,Dc({key:"label-implicit"},r)):Eo(t)?w.createElement(rd,Dc({key:"label-implicit",value:t},r)):w.isValidElement(t)?t.type===rd?w.cloneElement(t,ii({key:"label-implicit"},r)):w.createElement(rd,Dc({key:"label-implicit",content:t},r)):G4(t)?w.createElement(rd,Dc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?w.createElement(rd,Dc({},t,{key:"label-implicit"},r)):null};function wQ(t){var{label:e,labelRef:n}=t,r=_Q();return f2e(e,r,n)||null}var QT={},ZT={},W6;function m2e(){return W6||(W6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(ZT)),ZT}var JT={},q6;function p2e(){return q6||(q6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(JT)),JT}var K6;function g2e(){return K6||(K6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=m2e(),n=p2e(),r=yD();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(QT)),QT}var eC,X6;function x2e(){return X6||(X6=1,eC=g2e().last),eC}var b2e=x2e();const y2e=Co(b2e);var v2e=["valueAccessor"],_2e=["dataKey","clockWise","id","textBreakAll","zIndex"];function Jw(){return Jw=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},Jw.apply(null,arguments)}function Y6(t,e){if(t==null)return{};var n,r,i=w2e(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 w2e(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 S2e=t=>Array.isArray(t.value)?y2e(t.value):t.value,SQ=w.createContext(void 0),W4=SQ.Provider,MQ=w.createContext(void 0),M2e=MQ.Provider;function N2e(){return w.useContext(SQ)}function E2e(){return w.useContext(MQ)}function B1(t){var{valueAccessor:e=S2e}=t,n=Y6(t,v2e),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:l}=n,c=Y6(n,_2e),u=N2e(),d=E2e(),f=u||d;return!f||!f.length?null:w.createElement(Pa,{zIndex:l??Zr.label},w.createElement(Fr,{className:"recharts-label-list"},f.map((m,g)=>{var x,y=Ar(r)?e(m,g):er(m&&m.payload,r),b=Ar(a)?{}:{id:"".concat(a,"-").concat(g)};return w.createElement(rd,Jw({key:"label-".concat(g)},ya(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:g,zIndex:0}))})))}B1.displayName="LabelList";function NM(t){var{label:e}=t;return e?e===!0?w.createElement(B1,{key:"labelList-implicit"}):w.isValidElement(e)||G4(e)?w.createElement(B1,{key:"labelList-implicit",content:e}):typeof e=="object"?w.createElement(B1,Jw({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function B3(){return B3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},B3.apply(null,arguments)}var NQ=t=>{var{cx:e,cy:n,r,className:i}=t,a=In("recharts-dot",i);return Ft(e)&&Ft(n)&&Ft(r)?w.createElement("circle",B3({},Wa(t),bD(t),{className:a,cx:e,cy:n,r})):null},EQ=t=>t.graphicalItems.polarItems,A2e=et([Dr,hy],p4),EM=et([EQ,zr,A2e],g4),T2e=et([EM],x4),AM=et([T2e,a4],b4),C2e=et([AM,zr,EM],v4);et([AM,zr,EM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,o=er(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:er(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var Q6=()=>{},k2e=et([AM,zr,EM,vM,Dr],M4),j2e=et([zr,w4,S4,Q6,k2e,Q6,kn,Dr],N4),AQ=et([zr,kn,AM,C2e,dy,Dr,j2e],E4),P2e=et([AQ,zr,Bg],C4);et([zr,AQ,P2e,Dr],j4);var R2e={radiusAxis:{},angleAxis:{}},TQ=ys({name:"polarAxis",initialState:R2e,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:aXe,removeRadiusAxis:sXe,addAngleAxis:oXe,removeAngleAxis:lXe}=TQ.actions,D2e=TQ.reducer;function Z6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function J6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Z6(Object(n),!0).forEach(function(r){O2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Z6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function O2e(t,e,n){return(e=L2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function L2e(t){var e=I2e(t,"string");return typeof e=="symbol"?e:e+""}function I2e(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 F2e=(t,e)=>e,q4=et([EQ,F2e],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),U2e=[],K4=(t,e,n)=>n?.length===0?U2e:n,CQ=et([a4,q4,K4],(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=>J6(J6({},e.presentationProps),a.props))),i!=null)return i}}),z2e=et([CQ,q4,K4],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,o=er(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:Qd(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),B2e=et([CQ,q4,K4,ji],(t,e,n,r)=>{if(!(e==null||t==null))return $Me({offset:r,pieSettings:e,displayedData:t,cells:n})}),tC={exports:{}},ar={};var e$;function $2e(){if(e$)return ar;e$=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"),g=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 ar.ContextConsumer=a,ar.ContextProvider=o,ar.Element=t,ar.ForwardRef=l,ar.Fragment=n,ar.Lazy=f,ar.Memo=d,ar.Portal=e,ar.Profiler=i,ar.StrictMode=r,ar.Suspense=c,ar.SuspenseList=u,ar.isContextConsumer=function(y){return x(y)===a},ar.isContextProvider=function(y){return x(y)===o},ar.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},ar.isForwardRef=function(y){return x(y)===l},ar.isFragment=function(y){return x(y)===n},ar.isLazy=function(y){return x(y)===f},ar.isMemo=function(y){return x(y)===d},ar.isPortal=function(y){return x(y)===e},ar.isProfiler=function(y){return x(y)===i},ar.isStrictMode=function(y){return x(y)===r},ar.isSuspense=function(y){return x(y)===c},ar.isSuspenseList=function(y){return x(y)===u},ar.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===g||y.getModuleId!==void 0)},ar.typeOf=x,ar}var t$;function H2e(){return t$||(t$=1,tC.exports=$2e()),tC.exports}var V2e=H2e(),n$=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",r$=null,nC=null,kQ=t=>{if(t===r$&&Array.isArray(nC))return nC;var e=[];return w.Children.forEach(t,n=>{Ar(n)||(V2e.isFragment(n)?e=e.concat(kQ(n.props.children)):e.push(n))}),nC=e,r$=t,e};function X4(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>n$(i)):r=[n$(e)],kQ(t).forEach(i=>{var a=Ef(i,"type.displayName")||Ef(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var Y4=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,rC={},i$;function G2e(){return i$||(i$=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})(rC)),rC}var iC,a$;function W2e(){return a$||(a$=1,iC=G2e().isPlainObject),iC}var q2e=W2e();const K2e=Co(q2e);function s$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function o$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?s$(Object(n),!0).forEach(function(r){X2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function X2e(t,e,n){return(e=Y2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Y2e(t){var e=Q2e(t,"string");return typeof e=="symbol"?e:e+""}function Q2e(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 eS(){return eS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},eS.apply(null,arguments)}var l$=(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},Z2e={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},J2e=t=>{var e=Ur(t,Z2e),{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),[g,x]=w.useState(-1),y=w.useRef(i),b=w.useRef(a),v=w.useRef(o),M=w.useRef(n),S=w.useRef(r),A=Og(t,"trapezoid-");if(w.useEffect(()=>{if(m.current&&m.current.getTotalLength)try{var D=m.current.getTotalLength();D&&x(D)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var E=In("recharts-trapezoid",l);if(!f)return w.createElement("g",null,w.createElement("path",eS({},ya(e),{className:E,d:l$(n,r,i,a,o)})));var k=y.current,C=b.current,R=v.current,T=M.current,P=S.current,F="0px ".concat(g===-1?1:g,"px"),L="".concat(g,"px 0px"),X=ZK(["strokeDasharray"],u,c);return w.createElement(Dg,{animationId:A,key:A,canBegin:g>0,duration:u,easing:c,isActive:f,begin:d},D=>{var K=qn(k,i,D),Y=qn(C,a,D),q=qn(R,o,D),Z=qn(T,n,D),re=qn(P,r,D);m.current&&(y.current=K,b.current=Y,v.current=q,M.current=Z,S.current=re);var oe=D>0?{transition:X,strokeDasharray:L}:{strokeDasharray:F};return w.createElement("path",eS({},ya(e),{className:E,d:l$(Z,re,K,Y,q),ref:m,style:o$(o$({},oe),e.style)}))})},eMe=["option","shapeType","propTransformer","activeClassName"];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}function c$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function tS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?c$(Object(n),!0).forEach(function(r){rMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):c$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rMe(t,e,n){return(e=iMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function iMe(t){var e=aMe(t,"string");return typeof e=="symbol"?e:e+""}function aMe(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 sMe(t,e){return tS(tS({},e),t)}function oMe(t,e){return t==="symbols"}function u$(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return w.createElement(nX,n);case"trapezoid":return w.createElement(J2e,n);case"sector":return w.createElement(sX,n);case"symbols":if(oMe(e))return w.createElement(xD,n);break;case"curve":return w.createElement(Ip,n);default:return null}}function lMe(t){return w.isValidElement(t)?t.props:t}function Q4(t){var{option:e,shapeType:n,propTransformer:r=sMe,activeClassName:i="recharts-active-shape"}=t,a=tMe(t,eMe),o;if(w.isValidElement(e))o=w.cloneElement(e,tS(tS({},a),lMe(e)));else if(typeof e=="function")o=e(a,a.index);else if(K2e(e)&&typeof e!="boolean"){var l=r(e,a);o=w.createElement(u$,{shapeType:n,elementProps:l})}else{var c=a;o=w.createElement(u$,{shapeType:n,elementProps:c})}return a.isActive?w.createElement(Fr,{className:i},o):o}var Z4=(t,e,n)=>{var r=xr();return(i,a)=>o=>{t?.(i,a,o),r(BY({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},J4=t=>{var e=xr();return(n,r)=>i=>{t?.(n,r,i),e(S1e())}},eO=(t,e,n)=>{var r=xr();return(i,a)=>o=>{t?.(i,a,o),r(M1e({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function TM(t){var{tooltipEntrySettings:e}=t,n=xr(),r=Pi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(y1e(e)):i.current!==e&&n(v1e({prev:i.current,next:e})),i.current=e)},[e,n,r]),w.useLayoutEffect(()=>()=>{i.current&&(n(_1e(i.current)),i.current=null)},[n]),null}function tO(t){var{legendPayload:e}=t,n=xr(),r=Pi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(KK(e)):i.current!==e&&n(XK({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(YK(i.current)),i.current=null)},[n]),null}function cMe(t){var{legendPayload:e}=t,n=xr(),r=Ot(kn),i=w.useRef(null);return w.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(KK(e)):i.current!==e&&n(XK({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(YK(i.current)),i.current=null)},[n]),null}var aC,uMe=()=>{var[t]=w.useState(()=>o0("uid-"));return t},dMe=(aC=Eae.useId)!==null&&aC!==void 0?aC:uMe;function jQ(t,e){var n=dMe();return e||(t?"".concat(t,"-").concat(n):n)}var hMe=w.createContext(void 0),CM=t=>{var{id:e,type:n,children:r}=t,i=jQ("recharts-".concat(n),e);return w.createElement(hMe.Provider,{value:i},r(i))},fMe={cartesianItems:[],polarItems:[]},PQ=ys({name:"graphicalItems",initialState:fMe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:kr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Qo(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:kr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Qo(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:kr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:kr()},removePolarGraphicalItem:{reducer(t,e){var n=Qo(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:kr()}}}),{addCartesianGraphicalItem:mMe,replaceCartesianGraphicalItem:pMe,removeCartesianGraphicalItem:gMe,addPolarGraphicalItem:xMe,removePolarGraphicalItem:bMe}=PQ.actions,yMe=PQ.reducer,vMe=t=>{var e=xr(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(mMe(t)):n.current!==t&&e(pMe({prev:n.current,next:t})),n.current=t},[e,t]),w.useLayoutEffect(()=>()=>{n.current&&(e(gMe(n.current)),n.current=null)},[e]),null},nO=w.memo(vMe);function _Me(t){var e=xr();return w.useLayoutEffect(()=>(e(xMe(t)),()=>{e(bMe(t))}),[e,t]),null}var wMe=["key"],SMe=["onMouseEnter","onClick","onMouseLeave"],MMe=["id"],NMe=["id"];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 Kr(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){EMe(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 EMe(t,e,n){return(e=AMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function AMe(t){var e=TMe(t,"string");return typeof e=="symbol"?e:e+""}function TMe(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 zd(){return zd=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},zd.apply(null,arguments)}function kM(t,e){if(t==null)return{};var n,r,i=CMe(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 CMe(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 kMe(t){var e=w.useMemo(()=>X4(t.children,wy),[t.children]),n=Ot(r=>z2e(r,t.id,e));return n==null?null:w.createElement(cMe,{legendPayload:n})}var jMe=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:Qd(l,e),hide:c,type:u,color:o,unit:""}};return w.createElement(TM,{tooltipEntrySettings:d})}),PMe=(t,e)=>t>e?"start":t<e?"end":"middle",RMe=(t,e,n)=>ja(typeof e=="function"?e(t):e,n,n*.8),DMe=(t,e,n)=>{var{top:r,left:i,width:a,height:o}=e,l=rX(a,o),c=i+ja(t.cx,a,a/2),u=r+ja(t.cy,o,o/2),d=ja(t.innerRadius,l,0),f=RMe(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}},OMe=(t,e)=>{var n=Xi(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function LMe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var IMe=(t,e)=>{if(w.isValidElement(t))return w.cloneElement(t,e);if(typeof t=="function")return t(e);var n=In("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=kM(e,wMe);return w.createElement(Ip,zd({},i,{type:"linear",className:n}))},FMe=(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=In("recharts-pie-label-text",LMe(t));return w.createElement(MM,zd({},e,{alignmentBaseline:"middle",className:i}),r)};function UMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!e)return null;var l=Wa(n),c=Nf(i),u=Nf(a),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((m,g)=>{var x=(m.startAngle+m.endAngle)/2,y=gi(m.cx,m.cy,m.outerRadius+d,x),b=Kr(Kr(Kr(Kr({},l),m),{},{stroke:"none"},c),{},{index:g,textAnchor:PMe(y.x,m.cx)},y),v=Kr(Kr(Kr(Kr({},l),m),{},{fill:"none",stroke:m.fill},u),{},{index:g,points:[gi(m.cx,m.cy,m.outerRadius,x),y],key:"line"});return w.createElement(Pa,{zIndex:Zr.label,key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(g)},w.createElement(Fr,null,a&&IMe(a,v),FMe(i,b,er(m,o))))});return w.createElement(Fr,{className:"recharts-pie-labels"},f)}function zMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?w.createElement(NM,{label:i}):w.createElement(UMe,{sectors:e,props:n,showLabels:r})}function BMe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=t,l=Ot(Ud),c=Ot(z4),u=Ot(cwe),{onMouseEnter:d,onClick:f,onMouseLeave:m}=i,g=kM(i,SMe),x=Z4(d,i.dataKey,o),y=J4(m),b=eO(f,i.dataKey,o);return e==null||e.length===0?null:w.createElement(w.Fragment,null,e.map((v,M)=>{if(v?.startAngle===0&&v?.endAngle===0&&e.length!==1)return null;var S=u==null||u===o,A=String(M)===l&&(c==null||i.dataKey===c)&&S,E=l?r:null,k=n&&A?n:E,C=Kr(Kr({},v),{},{stroke:v.stroke,tabIndex:-1,[DK]:M,[OK]:i.dataKey});return w.createElement(Fr,zd({key:"sector-".concat(v?.startAngle,"-").concat(v?.endAngle,"-").concat(v.midAngle,"-").concat(M),tabIndex:-1,className:"recharts-pie-sector"},J0(g,v,M),{onMouseEnter:x(v,M),onMouseLeave:y(v,M),onClick:b(v,M)}),w.createElement(Q4,zd({option:a??k,index:M,shapeType:"sector",isActive:A},C)))}))}function $Me(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),g=OMe(l,c),x=Math.abs(g),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,b=r.filter(k=>er(k,u,0)!==0).length,v=(x>=360?b:b-1)*y,M=x-b*m-v,S=r.reduce((k,C)=>{var R=er(C,u,0);return k+(Ft(R)?R:0)},0),A;if(S>0){var E;A=r.map((k,C)=>{var R=er(k,u,0),T=er(k,d,C),P=DMe(n,a,k),F=(Ft(R)?R:0)/S,L,X=Kr(Kr({},k),i&&i[C]&&i[C].props);C?L=E.endAngle+Xi(g)*y*(R!==0?1:0):L=l;var D=L+Xi(g)*((R!==0?m:0)+F*M),K=(L+D)/2,Y=(P.innerRadius+P.outerRadius)/2,q=[{name:T,value:R,payload:X,dataKey:u,type:f}],Z=gi(P.cx,P.cy,Y,K);return E=Kr(Kr(Kr(Kr({},n.presentationProps),{},{percent:F,cornerRadius:typeof o=="string"?parseFloat(o):o,name:T,tooltipPayload:q,midAngle:K,middleRadius:Y,tooltipPosition:Z},X),P),{},{value:R,dataKey:u,startAngle:L,endAngle:D,payload:X,paddingAngle:Xi(g)*y}),E})}return A}function HMe(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(M2e,{value:e?i:void 0},r)}function VMe(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,g=Og(e,"recharts-pie-"),x=n.current,[y,b]=w.useState(!1),v=w.useCallback(()=>{typeof m=="function"&&m(),b(!1)},[m]),M=w.useCallback(()=>{typeof f=="function"&&f(),b(!0)},[f]);return w.createElement(HMe,{showLabels:!y,sectors:i},w.createElement(Dg,{animationId:g,begin:o,duration:l,isActive:a,easing:c,onAnimationStart:M,onAnimationEnd:v,key:g},S=>{var A=[],E=i&&i[0],k=E?.startAngle;return i?.forEach((C,R)=>{var T=x&&x[R],P=R>0?Ef(C,"paddingAngle",0):0;if(T){var F=qn(T.endAngle-T.startAngle,C.endAngle-C.startAngle,S),L=Kr(Kr({},C),{},{startAngle:k+P,endAngle:k+F+P});A.push(L),k=L.endAngle}else{var{endAngle:X,startAngle:D}=C,K=qn(0,X-D,S),Y=Kr(Kr({},C),{},{startAngle:k+P,endAngle:k+K+P});A.push(Y),k=Y.endAngle}}),n.current=A,w.createElement(Fr,null,w.createElement(BMe,{sectors:A,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),w.createElement(zMe,{showLabels:!y,sectors:i,props:e}),e.children)}var GMe={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:Zr.area};function WMe(t){var{id:e}=t,n=kM(t,MMe),{hide:r,className:i,rootTabIndex:a}=t,o=w.useMemo(()=>X4(t.children,wy),[t.children]),l=Ot(d=>B2e(d,e,o)),c=w.useRef(null),u=In("recharts-pie",i);return r||l==null?(c.current=null,w.createElement(Fr,{tabIndex:a,className:u})):w.createElement(Pa,{zIndex:t.zIndex},w.createElement(jMe,{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(Fr,{tabIndex:a,className:u},w.createElement(VMe,{props:Kr(Kr({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function RQ(t){var e=Ur(t,GMe),{id:n}=e,r=kM(e,NMe),i=Wa(r);return w.createElement(CM,{id:n,type:"pie"},a=>w.createElement(w.Fragment,null,w.createElement(_Me,{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(kMe,zd({},r,{id:a})),w.createElement(WMe,zd({},r,{id:a}))))}RQ.displayName="Pie";var qMe=["points"];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 sC(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){KMe(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 KMe(t,e,n){return(e=XMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XMe(t){var e=YMe(t,"string");return typeof e=="symbol"?e:e+""}function YMe(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 nS(){return nS=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},nS.apply(null,arguments)}function QMe(t,e){if(t==null)return{};var n,r,i=ZMe(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 ZMe(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 JMe(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=In(r,typeof e!="boolean"?e.className:""),a=n??{},{points:o}=a,l=QMe(a,qMe);return w.createElement(NQ,nS({},l,{className:i}))}function eNe(t,e){return t==null?!1:e?!0:t.length===1}function DQ(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:l,clipPathId:c,zIndex:u=Zr.scatter}=t;if(!eNe(e,n))return null;var d=Y4(n),f=jfe(n),m=e.map((x,y)=>{var b,v,M=sC(sC(sC({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(JMe,{key:"dot-".concat(y),option:n,dotProps:M,className:i})}),g={};return l&&c!=null&&(g.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),w.createElement(Pa,{zIndex:u},w.createElement(Fr,nS({className:r},g),m))}function f$(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?f$(Object(n),!0).forEach(function(r){tNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):f$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tNe(t,e,n){return(e=nNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nNe(t){var e=rNe(t,"string");return typeof e=="symbol"?e:e+""}function rNe(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 iNe={xAxis:{},yAxis:{},zAxis:{}},OQ=ys({name:"cartesianAxis",initialState:iNe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:kr()},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:kr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:kr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:kr()},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:kr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:kr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:kr()},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:kr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:kr()},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]=m$(m$({},t.yAxis[n]),{},{width:r,widthHistory:o})}}}}),{addXAxis:aNe,replaceXAxis:sNe,removeXAxis:oNe,addYAxis:lNe,replaceYAxis:cNe,removeYAxis:uNe,addZAxis:cXe,replaceZAxis:uXe,removeZAxis:dXe,updateYAxisWidth:dNe}=OQ.actions,hNe=OQ.reducer,fNe=et([ji],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),mNe=et([fNe,du,hu],(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)}}),jM=()=>Ot(mNe),pNe=()=>Ot(mwe);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 oC(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){gNe(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 gNe(t,e,n){return(e=xNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xNe(t){var e=bNe(t,"string");return typeof e=="symbol"?e:e+""}function bNe(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 yNe=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=oC(oC(oC({},l),Nf(i)),bD(i)),u;return w.isValidElement(i)?u=w.cloneElement(i,c):typeof i=="function"?u=i(c):u=w.createElement(NQ,c),w.createElement(Fr,{className:"recharts-active-dot",clipPath:o},u)};function $3(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=Zr.activeDot}=t,l=Ot(Ud),c=pNe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Ar(u)?null:w.createElement(Pa,{zIndex:o},w.createElement(yNe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var vNe="Invariant failed";function _Ne(t,e){throw new Error(vNe)}var wNe=["x","y"];function H3(){return H3=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},H3.apply(null,arguments)}function g$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Qx(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?g$(Object(n),!0).forEach(function(r){SNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):g$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function SNe(t,e,n){return(e=MNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function MNe(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 ENe(t,e){if(t==null)return{};var n,r,i=ANe(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 ANe(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 TNe(t,e){var{x:n,y:r}=t,i=ENe(t,wNe),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 Qx(Qx(Qx(Qx(Qx({},e),i),o?{x:o}:{}),c?{y:c}:{}),{},{height:d,width:m,name:e.name,radius:e.radius})}function rS(t){return w.createElement(Q4,H3({shapeType:"rectangle",propTransformer:TNe,activeClassName:"recharts-active-bar"},t))}var CNe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Ft(e))return e;var a=Ft(r)||Ar(r);return a?e(r,i):(a||_Ne(),n)}},kNe={},LQ=ys({name:"errorBars",initialState:kNe,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:hXe,replaceErrorBar:fXe,removeErrorBar:mXe}=LQ.actions,jNe=LQ.reducer,PNe=["children"];function RNe(t,e){if(t==null)return{};var n,r,i=DNe(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 DNe(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 ONe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},LNe=w.createContext(ONe);function IQ(t){var{children:e}=t,n=RNe(t,PNe);return w.createElement(LNe.Provider,{value:n},e)}function PM(t,e){var n,r,i=Ot(u=>ql(u,t)),a=Ot(u=>Kl(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Hi.allowDataOverflow,l=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:Vi.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function rO(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=jM(),{needClipX:a,needClipY:o,needClip:l}=PM(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 INe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&tr(t.zIndex)?t.zIndex:e}var lC={exports:{}},cC={};var x$;function FNe(){if(x$)return cC;x$=1;var t=Ag();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 cC.useSyncExternalStoreWithSelector=function(c,u,d,f,m){var g=i(null);if(g.current===null){var x={hasValue:!1,value:null};g.current=x}else x=g.current;g=o(function(){function b(E){if(!v){if(v=!0,M=E,E=f(E),m!==void 0&&x.hasValue){var k=x.value;if(m(k,E))return S=k}return S=E}if(k=S,n(M,E))return k;var C=f(E);return m!==void 0&&m(k,C)?(M=E,k):(M=E,S=C)}var v=!1,M,S,A=d===void 0?null:d;return[function(){return b(u())},A===null?void 0:function(){return b(A())}]},[u,d,f,m]);var y=r(c,g[0],g[1]);return a(function(){x.hasValue=!0,x.value=y},[y]),l(y),y},cC}var b$;function UNe(){return b$||(b$=1,lC.exports=FNe()),lC.exports}UNe();function zNe(t){t()}function BNe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){zNe(()=>{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 y$={notify(){},get:()=>[]};function $Ne(t,e){let n,r=y$,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=BNe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=y$)}function m(){a||(a=!0,d())}function g(){a&&(a=!1,f())}const x={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:m,tryUnsubscribe:g,getListeners:()=>r};return x}var HNe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",VNe=HNe(),GNe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",WNe=GNe(),qNe=()=>VNe||WNe?w.useLayoutEffect:w.useEffect,KNe=qNe();function v$(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function XNe(t,e){if(v$(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])||!v$(t[n[i]],e[n[i]]))return!1;return!0}var YNe=Symbol.for("react-redux-context"),QNe=typeof globalThis<"u"?globalThis:{};function ZNe(){if(!w.createContext)return{};const t=QNe[YNe]??=new Map;let e=t.get(w.createContext);return e||(e=w.createContext(null),t.set(w.createContext,e)),e}var JNe=ZNe();function eEe(t){const{children:e,context:n,serverState:r,store:i}=t,a=w.useMemo(()=>{const c=$Ne(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=w.useMemo(()=>i.getState(),[i]);KNe(()=>{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||JNe;return w.createElement(l.Provider,{value:a},e)}var tEe=eEe,nEe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function rEe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function Sy(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(nEe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!XNe(t[r],e[r]))return!1}else if(!rEe(t[r],e[r]))return!1;return!0}var iEe=["onMouseEnter","onMouseLeave","onClick"],aEe=["value","background","tooltipPosition"],sEe=["id"],oEe=["onMouseEnter","onClick","onMouseLeave"];function ou(){return ou=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},ou.apply(null,arguments)}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 Ua(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?_$(Object(n),!0).forEach(function(r){lEe(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 lEe(t,e,n){return(e=cEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cEe(t){var e=uEe(t,"string");return typeof e=="symbol"?e:e+""}function uEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function iS(t,e){if(t==null)return{};var n,r,i=dEe(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 dEe(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 hEe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Qd(n,e),payload:t}]},fEe=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:Qd(a,e),hide:o,type:c,color:i,unit:l}};return w.createElement(TM,{tooltipEntrySettings:u})});function mEe(t){var e=Ot(Ud),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=a,u=iS(a,iEe),d=Z4(o,r),f=J4(l),m=eO(c,r);if(!i||n==null)return null;var g=Nf(i);return w.createElement(Pa,{zIndex:INe(i,Zr.barBackground)},n.map((x,y)=>{var{value:b,background:v,tooltipPosition:M}=x,S=iS(x,aEe);if(!v)return null;var A=d(x,y),E=f(x,y),k=m(x,y),C=Ua(Ua(Ua(Ua(Ua({option:i,isActive:String(y)===e},S),{},{fill:"#eee"},v),g),J0(u,x,y)),{},{onMouseEnter:A,onMouseLeave:E,onClick:k,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return w.createElement(rS,ou({key:"background-bar-".concat(y)},C))}))}function pEe(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 Ua(Ua({},o),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:o,fill:a.fill})});return w.createElement(W4,{value:e?i:void 0},n)}function gEe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=t,l=Ot(Ud),c=Ot(z4),u=n&&String(a)===l&&(c==null||o===c),d=u?n:e;return u?w.createElement(Pa,{zIndex:Zr.activeBar},w.createElement(rS,ou({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))):w.createElement(rS,ou({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))}function xEe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return w.createElement(rS,ou({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function bEe(t){var e,{data:n,props:r}=t,i=(e=Wa(r))!==null&&e!==void 0?e:{},{id:a}=i,o=iS(i,sEe),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:m}=r,g=iS(r,oEe),x=Z4(d,c),y=J4(m),b=eO(f,c);return n?w.createElement(w.Fragment,null,n.map((v,M)=>w.createElement(Fr,ou({key:"rectangle-".concat(v?.x,"-").concat(v?.y,"-").concat(v?.value,"-").concat(M),className:"recharts-bar-rectangle"},J0(g,v,M),{onMouseEnter:x(v,M),onMouseLeave:y(v,M),onClick:b(v,M)}),u?w.createElement(gEe,{shape:l,activeBar:u,baseProps:o,entry:v,index:M,dataKey:c}):w.createElement(xEe,{shape:l,baseProps:o,entry:v,index:M,dataKey:c})))):null}function yEe(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=Og(e,"recharts-bar-"),[g,x]=w.useState(!1),y=!g,b=w.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),v=w.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return w.createElement(pEe,{showLabels:y,rects:r},w.createElement(Dg,{animationId:m,begin:o,duration:l,isActive:a,easing:c,onAnimationEnd:b,onAnimationStart:v,key:m},M=>{var S=M===1?r:r?.map((A,E)=>{var k=f&&f[E];if(k)return Ua(Ua({},A),{},{x:qn(k.x,A.x,M),y:qn(k.y,A.y,M),width:qn(k.width,A.width,M),height:qn(k.height,A.height,M)});if(i==="horizontal"){var C=qn(0,A.height,M),R=qn(A.stackedBarStart,A.y,M);return Ua(Ua({},A),{},{y:R,height:C})}var T=qn(0,A.width,M),P=qn(A.stackedBarStart,A.x,M);return Ua(Ua({},A),{},{width:T,x:P})});return M>0&&(n.current=S??null),S==null?null:w.createElement(Fr,null,w.createElement(bEe,{props:e,data:S}))}),w.createElement(NM,{label:e.label}),e.children)}function vEe(t){var e=w.useRef(null);return w.createElement(yEe,{previousRectanglesRef:e,props:t})}var FQ=0,_Ee=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:er(t,e)}};class wEe 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=In("recharts-bar",i),f=u;return w.createElement(Fr,{className:d,id:u},l&&w.createElement("defs",null,w.createElement(rO,{clipPathId:f,xAxisId:a,yAxisId:o})),w.createElement(Fr,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},w.createElement(mEe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),w.createElement(vEe,this.props)))}}var SEe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:FQ,xAxisId:0,yAxisId:0,zIndex:Zr.bar};function MEe(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}=PM(e,n),m=Gf(),g=Pi(),x=X4(t.children,wy),y=Ot(M=>ZEe(M,e,n,g,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(IQ,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:_Ee,errorBarOffset:b},w.createElement(wEe,ou({},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 NEe(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:g,parentViewBox:x,dataStartIndex:y}=t,b=e==="horizontal"?l:o,v=d?b.scale.domain():null,M=Kge({numericAxis:b}),S=b.scale(M);return f.map((A,E)=>{var k,C,R,T,P,F;d?k=Hge(d[E+y],v):(k=er(A,n),Array.isArray(k)||(k=[M,k]));var L=CNe(r,FQ)(k[1],E);if(e==="horizontal"){var X,[D,K]=[l.scale(k[0]),l.scale(k[1])];C=FB({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:A,index:E}),R=(X=K??D)!==null&&X!==void 0?X:void 0,T=i.size;var Y=D-K;if(P=bs(Y)?0:Y,F={x:C,y:m.top,width:T,height:m.height},Math.abs(L)>0&&Math.abs(P)<Math.abs(L)){var q=Xi(P||L)*(Math.abs(L)-Math.abs(P));R-=q,P+=q}}else{var[Z,re]=[o.scale(k[0]),o.scale(k[1])];if(C=Z,R=FB({axis:l,ticks:u,bandSize:a,offset:i.offset,entry:A,index:E}),T=re-Z,P=i.size,F={x:m.left,y:R,width:m.width,height:P},Math.abs(L)>0&&Math.abs(T)<Math.abs(L)){var oe=Xi(T||L)*(Math.abs(L)-Math.abs(T));T+=oe}}if(C==null||R==null||T==null||P==null)return null;var B=Ua(Ua({},A),{},{stackedBarStart:S,x:C,y:R,width:T,height:P,value:d?k:k[1],payload:A,background:F,tooltipPosition:{x:C+T/2,y:R+P/2},parentViewBox:x},g&&g[E]&&g[E].props);return B}).filter(Boolean)}function EEe(t){var e=Ur(t,SEe),n=Pi();return w.createElement(CM,{id:e.id,type:"bar"},r=>w.createElement(w.Fragment,null,w.createElement(tO,{legendPayload:hEe(e)}),w.createElement(fEe,{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(nO,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:PK(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),w.createElement(Pa,{zIndex:e.zIndex},w.createElement(MEe,ou({},e,{id:r})))))}var UQ=w.memo(EEe,Sy);UQ.displayName="Bar";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 d_(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){AEe(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 AEe(t,e,n){return(e=TEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function TEe(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)}var kEe=(t,e)=>e,jEe=(t,e,n)=>n,PEe=(t,e,n,r)=>r,REe=(t,e,n,r,i)=>i,My=et([my,REe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),DEe=et([My],t=>t?.maxBarSize),OEe=(t,e,n,r,i,a)=>a,S$=(t,e,n)=>{var r=n??t;if(!Ar(r))return ja(r,e,0)},LEe=et([kn,my,kEe,jEe,PEe],(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")),IEe=(t,e,n,r)=>{var i=kn(t);return i==="horizontal"?v0(t,"yAxis",n,r):v0(t,"xAxis",e,r)},FEe=(t,e,n)=>{var r=kn(t);return r==="horizontal"?x6(t,"xAxis",e):x6(t,"yAxis",n)},UEe=(t,e,n)=>{var r={},i=t.filter(gM),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),g=S$(e,n,f[0].barSize);return{stackId:d,dataKeys:m,barSize:g}}),c=a.map(u=>{var d=[u.dataKey].filter(m=>m!=null),f=S$(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]},zEe=et([LEe,d_e,FEe],UEe),BEe=(t,e,n,r,i)=>{var a,o,l=My(t,e,n,r,i);if(l!=null){var c=kn(t),u=nY(t),{maxBarSize:d}=l,f=Ar(d)?u:d,m,g;return c==="horizontal"?(m=Ul(t,"xAxis",e,r),g=Fl(t,"xAxis",e,r)):(m=Ul(t,"yAxis",n,r),g=Fl(t,"yAxis",n,r)),(a=(o=Ld(m,g,!0))!==null&&o!==void 0?o:f)!==null&&a!==void 0?a:0}},zQ=(t,e,n,r)=>{var i=kn(t),a,o;return i==="horizontal"?(a=Ul(t,"xAxis",e,r),o=Fl(t,"xAxis",e,r)):(a=Ul(t,"yAxis",n,r),o=Fl(t,"yAxis",n,r)),Ld(a,o)};function $Ee(t,e,n,r,i){var a=r.length;if(!(a<1)){var o=ja(t,n,0,!0),l,c=[];if(tr(r[0].barSize)){var u=!1,d=n/a,f=r.reduce((v,M)=>v+(M.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,g={offset:m-o,size:0};l=r.reduce((v,M)=>{var S,A={stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:g.offset+g.size+o,size:u?d:(S=M.barSize)!==null&&S!==void 0?S:0}},E=[...v,A];return g=E[E.length-1].position,E},c)}else{var x=ja(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=tr(i)?Math.min(y,i):y;l=r.reduce((v,M,S)=>[...v,{stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:x+(y+o)*S+(y-b)/2,size:b}}],c)}return l}}var HEe=(t,e,n,r,i,a,o)=>{var l=Ar(o)?e:o,c=$Ee(n,r,i!==a?i:a,t,l);return i!==a&&c!=null&&(c=c.map(u=>d_(d_({},u),{},{position:d_(d_({},u.position),{},{offset:u.position.offset-i/2})}))),c},VEe=et([zEe,nY,u_e,rY,BEe,zQ,DEe],HEe),GEe=(t,e,n,r)=>Ul(t,"xAxis",e,r),WEe=(t,e,n,r)=>Ul(t,"yAxis",n,r),qEe=(t,e,n,r)=>Fl(t,"xAxis",e,r),KEe=(t,e,n,r)=>Fl(t,"yAxis",n,r),XEe=et([VEe,My],(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}}),YEe=(t,e)=>{var n=pM(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)}}}},QEe=et([IEe,My],YEe),ZEe=et([ji,CD,GEe,WEe,qEe,KEe,XEe,kn,uy,zQ,QEe,My,OEe],(t,e,n,r,i,a,o,l,c,u,d,f,m)=>{var{chartData:g,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=g?.slice(x,y+1),v!=null)return NEe({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})}}),BQ=t=>{var{chartData:e}=t,n=xr(),r=Pi();return w.useEffect(()=>r?()=>{}:(n(k6(e)),()=>{n(k6(void 0))}),[e,n,r]),null},M$={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},$Q=ys({name:"brush",initialState:M$,reducers:{setBrushSettings(t,e){return e.payload==null?M$:e.payload}}}),{setBrushSettings:pXe}=$Q.actions,JEe=$Q.reducer;function N$(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?N$(Object(n),!0).forEach(function(r){HQ(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):N$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function HQ(t,e,n){return(e=eAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eAe(t){var e=tAe(t,"string");return typeof e=="symbol"?e:e+""}function tAe(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 nAe=(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)}},rAe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return nAe({x:e,y:n},{x:r,y:i})};class RM{static create(e){return new RM(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}}HQ(RM,"EPS",1e-4);var iAe=t=>{var e=Object.keys(t).reduce((n,r)=>h_(h_({},n),{},{[r]:RM.create(t[r])}),{});return h_(h_({},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 aAe(t){return(t%180+180)%180}var sAe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=aAe(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)},oAe={dots:[],areas:[],lines:[]},VQ=ys({name:"referenceElements",initialState:oAe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Qo(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=Qo(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=Qo(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:gXe,removeDot:xXe,addArea:bXe,removeArea:yXe,addLine:lAe,removeLine:cAe}=VQ.actions,uAe=VQ.reducer,GQ=w.createContext(void 0),dAe=t=>{var{children:e}=t,[n]=w.useState("".concat(o0("recharts"),"-clip")),r=jM();if(r==null)return null;var{x:i,y:a,width:o,height:l}=r;return w.createElement(GQ.Provider,{value:n},w.createElement("defs",null,w.createElement("clipPath",{id:n},w.createElement("rect",{x:i,y:a,height:l,width:o}))),e)},hAe=()=>w.useContext(GQ);function E$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function A$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?E$(Object(n),!0).forEach(function(r){fAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fAe(t,e,n){return(e=mAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mAe(t){var e=pAe(t,"string");return typeof e=="symbol"?e:e+""}function pAe(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 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)}var gAe=(t,e)=>{var n;if(w.isValidElement(t))n=w.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!tr(e.x1)||!tr(e.y1)||!tr(e.x2)||!tr(e.y2))return null;n=w.createElement("line",aS({},e,{className:"recharts-reference-line-line"}))}return n},xAe=(t,e,n,r,i,a)=>{var{x:o,width:l}=a,c=i.y.apply(t,{position:n});if(bs(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},bAe=(t,e,n,r,i,a)=>{var{y:o,height:l}=a,c=i.x.apply(t,{position:n});if(bs(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},yAe=(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},vAe=(t,e,n,r,i,a)=>{var{x:o,y:l,segment:c,ifOverflow:u}=a,d=Eo(o),f=Eo(l);return f?xAe(l,u,n,i,t,e):d?bAe(o,u,n,r,t,e):c!=null&&c.length===2?yAe(c,u,n,t):null};function _Ae(t){var e=xr();return w.useEffect(()=>(e(lAe(t)),()=>{e(cAe(t))})),null}function wAe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,o=Pi(),l=hAe(),c=Ot(k=>ql(k,e)),u=Ot(k=>Kl(k,n)),d=Ot(k=>Fd(k,"xAxis",e,o)),f=Ot(k=>Fd(k,"yAxis",n,o)),m=iy();if(!l||!m||c==null||u==null||d==null||f==null)return null;var g=iAe({x:d,y:f}),x=vAe(g,m,t.position,c.orientation,u.orientation,t);if(!x)return null;var[{x:y,y:b},{x:v,y:M}]=x,S=a==="hidden"?"url(#".concat(l,")"):void 0,A=A$(A$({clipPath:S},ya(t)),{},{x1:y,y1:b,x2:v,y2:M}),E=rAe({x1:y,y1:b,x2:v,y2:M});return w.createElement(Pa,{zIndex:t.zIndex},w.createElement(Fr,{className:In("recharts-reference-line",i)},gAe(r,A),w.createElement(vQ,aS({},E,{lowerWidth:E.width,upperWidth:E.width}),w.createElement(wQ,{label:t.label}),t.children)))}var SAe={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:Zr.line};function yb(t){var e=Ur(t,SAe);return w.createElement(w.Fragment,null,w.createElement(_Ae,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),w.createElement(wAe,e))}yb.displayName="ReferenceLine";function WQ(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 MAe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return sAe(r,n)}function NAe(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 sS(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 EAe(t,e){return WQ(t,e+1)}function AAe(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:WQ(r,u)};var y=c,b,v=()=>(b===void 0&&(b=n(x,y)),b),M=x.coordinate,S=c===0||sS(t,M,v,d,l);S||(c=0,d=o,u+=1),S&&(d=M+t*(v()/2+i),c+=u)},m;u<=a.length;)if(m=f(),m)return m.v;return[]}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 Ea(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){TAe(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 TAe(t,e,n){return(e=CAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function CAe(t){var e=kAe(t,"string");return typeof e=="symbol"?e:e+""}function kAe(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 jAe(t,e,n,r,i){for(var a=(r||[]).slice(),o=a.length,{start:l}=e,{end:c}=e,u=function(m){var g=a[m],x,y=()=>(x===void 0&&(x=n(g,m)),x);if(m===o-1){var b=t*(g.coordinate+t*y()/2-c);a[m]=g=Ea(Ea({},g),{},{tickCoord:b>0?g.coordinate-b*t:g.coordinate})}else a[m]=g=Ea(Ea({},g),{},{tickCoord:g.coordinate});if(g.tickCoord!=null){var v=sS(t,g.tickCoord,y,l,c);v&&(c=g.tickCoord-t*(y()/2+i),a[m]=Ea(Ea({},g),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return a}function PAe(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=Ea(Ea({},d),{},{tickCoord:m>0?d.coordinate-m*t:d.coordinate}),d.tickCoord!=null){var g=sS(t,d.tickCoord,()=>f,c,u);g&&(u=d.tickCoord-t*(f/2+i),o[l-1]=Ea(Ea({},d),{},{isShow:!0}))}}for(var x=a?l-1:l,y=function(M){var S=o[M],A,E=()=>(A===void 0&&(A=n(S,M)),A);if(M===0){var k=t*(S.coordinate-t*E()/2-c);o[M]=S=Ea(Ea({},S),{},{tickCoord:k<0?S.coordinate-k*t:S.coordinate})}else o[M]=S=Ea(Ea({},S),{},{tickCoord:S.coordinate});if(S.tickCoord!=null){var C=sS(t,S.tickCoord,E,c,u);C&&(c=S.tickCoord+t*(E()/2+i),o[M]=Ea(Ea({},S),{},{isShow:!0}))}},b=0;b<x;b++)y(b);return o}function iO(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(Ft(c)||Rg.isSsr){var m;return(m=EAe(i,Ft(c)?c:0))!==null&&m!==void 0?m:[]}var g=[],x=l==="top"||l==="bottom"?"width":"height",y=d&&x==="width"?Rb(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},b=(S,A)=>{var E=typeof u=="function"?u(S.value,A):S.value;return x==="width"?MAe(Rb(E,{fontSize:e,letterSpacing:n}),y,f):Rb(E,{fontSize:e,letterSpacing:n})[x]},v=i.length>=2?Xi(i[1].coordinate-i[0].coordinate):1,M=NAe(a,v,x);return c==="equidistantPreserveStart"?AAe(v,M,b,i,o):(c==="preserveStart"||c==="preserveStartEnd"?g=PAe(v,M,b,i,o,c==="preserveStartEnd"):g=jAe(v,M,b,i,o),g.filter(S=>S.isShow))}var RAe=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},DAe=["axisLine","width","height","className","hide","ticks","axisType"];function OAe(t,e){if(t==null)return{};var n,r,i=LAe(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 LAe(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 kf(){return kf=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},kf.apply(null,arguments)}function C$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function fi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?C$(Object(n),!0).forEach(function(r){IAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):C$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function IAe(t,e,n){return(e=FAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function FAe(t){var e=UAe(t,"string");return typeof e=="symbol"?e:e+""}function UAe(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 Wc={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:Zr.axis};function zAe(t){var{x:e,y:n,width:r,height:i,orientation:a,mirror:o,axisLine:l,otherSvgProps:c}=t;if(!l)return null;var u=fi(fi(fi({},c),Wa(l)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!o||a==="bottom"&&o);u=fi(fi({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(a==="left"&&!o||a==="right"&&o);u=fi(fi({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return w.createElement("line",kf({},u,{className:In("recharts-cartesian-axis-line",Ef(l,"className"))}))}function BAe(t,e,n,r,i,a,o,l,c){var u,d,f,m,g,x,y=l?-1:1,b=t.tickSize||o,v=Ft(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,g=v;break;case"left":f=m=t.coordinate,d=e+ +!l*r,u=d-y*b,g=u-y*c,x=v;break;case"right":f=m=t.coordinate,d=e+ +l*r,u=d+y*b,g=u+y*c,x=v;break;default:u=d=t.coordinate,m=n+ +l*i,f=m+y*b,x=f+y*c,g=v;break}return{line:{x1:u,y1:f,x2:d,y2:m},tick:{x:g,y:x}}}function $Ae(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function HAe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function VAe(t){var{option:e,tickProps:n,value:r}=t,i,a=In(n.className,"recharts-cartesian-axis-tick-value");if(w.isValidElement(e))i=w.cloneElement(e,fi(fi({},n),{},{className:a}));else if(typeof e=="function")i=e(fi(fi({},n),{},{className:a}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=In(o,e?.className)),i=w.createElement(MM,kf({},n,{className:o}),r)}return i}var GAe=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:g,width:x,height:y,tickSize:b,tickMargin:v,fontSize:M,letterSpacing:S,getTicksConfig:A,events:E,axisType:k}=t,C=iO(fi(fi({},A),{},{ticks:n}),M,S),R=$Ae(d,f),T=HAe(d,f),P=Wa(A),F=Nf(r),L={};typeof i=="object"&&(L=i);var X=fi(fi({},P),{},{fill:"none"},L),D=C.map(q=>fi({entry:q},BAe(q,m,g,x,y,d,b,f,v))),K=D.map(q=>{var{entry:Z,line:re}=q;return w.createElement(Fr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Z.value,"-").concat(Z.coordinate,"-").concat(Z.tickCoord)},i&&w.createElement("line",kf({},X,re,{className:In("recharts-cartesian-axis-tick-line",Ef(i,"className"))})))}),Y=D.map((q,Z)=>{var{entry:re,tick:oe}=q,B=fi(fi(fi(fi({textAnchor:R,verticalAnchor:T},P),{},{stroke:"none",fill:a},F),oe),{},{index:Z,payload:re,visibleTicksCount:C.length,tickFormatter:o,padding:c},u);return w.createElement(Fr,kf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(re.value,"-").concat(re.coordinate,"-").concat(re.tickCoord)},J0(E,re,Z)),r&&w.createElement(VAe,{option:r,tickProps:B,value:"".concat(typeof o=="function"?o(re.value,Z):re.value).concat(l||"")}))});return w.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(k,"-ticks")},Y.length>0&&w.createElement(Pa,{zIndex:Zr.label},w.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(k,"-tick-labels"),ref:e},Y)),K.length>0&&w.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(k,"-tick-lines")},K))}),WAe=w.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:l,axisType:c}=t,u=OAe(t,DAe),[d,f]=w.useState(""),[m,g]=w.useState(""),x=w.useRef(null);w.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var b;return RAe({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 M=v[0];if(M){var S=window.getComputedStyle(M),A=S.fontSize,E=S.letterSpacing;(A!==d||E!==m)&&(f(A),g(E))}}},[d,m]);return o||r!=null&&r<=0||i!=null&&i<=0?null:w.createElement(Pa,{zIndex:t.zIndex},w.createElement(Fr,{className:In("recharts-cartesian-axis",a)},w.createElement(zAe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Wa(t)}),w.createElement(GAe,{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(vQ,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},w.createElement(wQ,{label:t.label,labelRef:t.labelRef}),t.children)))}),aO=w.forwardRef((t,e)=>{var n=Ur(t,Wc);return w.createElement(WAe,kf({},n,{ref:e}))});aO.displayName="CartesianAxis";var qAe=["x1","y1","x2","y2","key"],KAe=["offset"],XAe=["xAxisId","yAxisId"],YAe=["xAxisId","yAxisId"];function k$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ca(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?k$(Object(n),!0).forEach(function(r){QAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):k$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function QAe(t,e,n){return(e=ZAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ZAe(t){var e=JAe(t,"string");return typeof e=="symbol"?e:e+""}function JAe(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 Xh(){return Xh=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},Xh.apply(null,arguments)}function oS(t,e){if(t==null)return{};var n,r,i=eTe(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 eTe(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 tTe=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 qQ(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=oS(n,qAe),f=(i=Wa(d))!==null&&i!==void 0?i:{},{offset:m}=f,g=oS(f,KAe);r=w.createElement("line",Xh({},g,{x1:a,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function nTe(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=oS(t,XAe),c=i.map((u,d)=>{var f=Ca(Ca({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return w.createElement(qQ,{key:"line-".concat(d),option:r,lineItemProps:f})});return w.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function rTe(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=oS(t,YAe),c=i.map((u,d)=>{var f=Ca(Ca({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return w.createElement(qQ,{option:r,lineItemProps:f,key:"line-".concat(d)})});return w.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function iTe(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 g=!u[m+1],x=g?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 aTe(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 g=!u[m+1],x=g?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 sTe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return kK(iO(Ca(Ca(Ca({},Wc),n),{},{ticks:jK(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},oTe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return kK(iO(Ca(Ca(Ca({},Wc),n),{},{ticks:jK(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},lTe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Zr.grid};function lS(t){var e=jD(),n=PD(),r=zK(),i=Ca(Ca({},Ur(t,lTe)),{},{x:Ft(t.x)?t.x:r.left,y:Ft(t.y)?t.y:r.top,width:Ft(t.width)?t.width:r.width,height:Ft(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:m,verticalValues:g}=i,x=Pi(),y=Ot(T=>b6(T,"xAxis",a,x)),b=Ot(T=>b6(T,"yAxis",o,x));if(!Ll(u)||!Ll(d)||!Ft(l)||!Ft(c))return null;var v=i.verticalCoordinatesGenerator||sTe,M=i.horizontalCoordinatesGenerator||oTe,{horizontalPoints:S,verticalPoints:A}=i;if((!S||!S.length)&&typeof M=="function"){var E=m&&m.length,k=M({yAxis:b?Ca(Ca({},b),{},{ticks:E?m:b.ticks}):void 0,width:e??u,height:n??d,offset:r},E?!0:f);jw(Array.isArray(k),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof k,"]")),Array.isArray(k)&&(S=k)}if((!A||!A.length)&&typeof v=="function"){var C=g&&g.length,R=v({xAxis:y?Ca(Ca({},y),{},{ticks:C?g:y.ticks}):void 0,width:e??u,height:n??d,offset:r},C?!0:f);jw(Array.isArray(R),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof R,"]")),Array.isArray(R)&&(A=R)}return w.createElement(Pa,{zIndex:i.zIndex},w.createElement("g",{className:"recharts-cartesian-grid"},w.createElement(tTe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),w.createElement(iTe,Xh({},i,{horizontalPoints:S})),w.createElement(aTe,Xh({},i,{verticalPoints:A})),w.createElement(nTe,Xh({},i,{offset:r,horizontalPoints:S,xAxis:y,yAxis:b})),w.createElement(rTe,Xh({},i,{offset:r,verticalPoints:A,xAxis:y,yAxis:b}))))}lS.displayName="CartesianGrid";var KQ=(t,e,n,r)=>Ul(t,"xAxis",e,r),XQ=(t,e,n,r)=>Fl(t,"xAxis",e,r),YQ=(t,e,n,r)=>Ul(t,"yAxis",n,r),QQ=(t,e,n,r)=>Fl(t,"yAxis",n,r),cTe=et([kn,KQ,YQ,XQ,QQ],(t,e,n,r,i)=>Wl(t,"xAxis")?Ld(e,r,!1):Ld(n,i,!1)),uTe=(t,e,n,r,i)=>i;function dTe(t){return t.type==="line"}var hTe=et([my,uTe],(t,e)=>t.filter(dTe).find(n=>n.id===e)),fTe=et([kn,KQ,YQ,XQ,QQ,hTe,cTe,uy],(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,g;if(m!=null&&m.length>0?g=m:g=c?.slice(u,d+1),g!=null)return RTe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:o,displayedData:g})}});function ZQ(t){var e=Nf(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 mTe=["id"],pTe=["type","layout","connectNulls","needClip","shape"],gTe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function w0(){return w0=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},w0.apply(null,arguments)}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 wl(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){xTe(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 xTe(t,e,n){return(e=bTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bTe(t){var e=yTe(t,"string");return typeof e=="symbol"?e:e+""}function yTe(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 sO(t,e){if(t==null)return{};var n,r,i=vTe(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 vTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var _Te=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Qd(n,e),payload:t}]},wTe=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:Qd(o,e),hide:l,type:u,color:r,unit:c}};return w.createElement(TM,{tooltipEntrySettings:d})}),JQ=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function STe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var MTe=(t,e,n)=>{var r=n.reduce((f,m)=>f+m);if(!r)return JQ(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[...STe(n,i),...l,...d].map(f=>"".concat(f,"px")).join(", ")};function NTe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:o}=r,{id:l}=r,c=sO(r,mTe),u=Wa(c);return w.createElement(DQ,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:o,clipPathId:e})}function ETe(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 wl(wl({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return w.createElement(W4,{value:e?i:void 0},n)}function P$(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=sO(a,pTe),m=wl(wl({},ya(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(Q4,w0({shapeType:"curve",option:d},m,{pathRef:n})),w.createElement(NTe,{points:r,clipPathId:e,props:a}))}function ATe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function TTe(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:g,height:x,onAnimationEnd:y,onAnimationStart:b}=n,v=i.current,M=Og(o,"recharts-line-"),S=w.useRef(M),[A,E]=w.useState(!1),k=!A,C=w.useCallback(()=>{typeof y=="function"&&y(),E(!1)},[y]),R=w.useCallback(()=>{typeof b=="function"&&b(),E(!0)},[b]),T=ATe(r.current),P=w.useRef(0);S.current!==M&&(P.current=a.current,S.current=M);var F=P.current;return w.createElement(ETe,{points:o,showLabels:k},n.children,w.createElement(Dg,{animationId:M,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:C,onAnimationStart:R,key:M},L=>{var X=qn(F,T+F,L),D=Math.min(X,T),K;if(c)if(l){var Y="".concat(l).split(/[,\s]+/gim).map(re=>parseFloat(re));K=MTe(D,T,Y)}else K=JQ(T,D);else K=l==null?void 0:String(l);if(L>0&&T>0&&(i.current=o,a.current=Math.max(a.current,D)),v){var q=v.length/o.length,Z=L===1?o:o.map((re,oe)=>{var B=Math.floor(oe*q);if(v[B]){var G=v[B];return wl(wl({},re),{},{x:qn(G.x,re.x,L),y:qn(G.y,re.y,L)})}return m?wl(wl({},re),{},{x:qn(g*2,re.x,L),y:qn(x/2,re.y,L)}):wl(wl({},re),{},{x:re.x,y:re.y})});return i.current=Z,w.createElement(P$,{props:n,points:Z,clipPathId:e,pathRef:r,strokeDasharray:K})}return w.createElement(P$,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:K})}),w.createElement(NM,{label:n.label}))}function CTe(t){var{clipPathId:e,props:n}=t,r=w.useRef(null),i=w.useRef(0),a=w.useRef(null);return w.createElement(TTe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var kTe=(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:er(t.payload,e)}};class jTe 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:g}=this.props;if(e)return null;var x=In("recharts-line",i),y=f,{r:b,strokeWidth:v}=ZQ(n),M=Y4(n),S=b*2+v,A=m?"url(#clipPath-".concat(M?"":"dots-").concat(y,")"):void 0;return w.createElement(Pa,{zIndex:g},w.createElement(Fr,{className:x},m&&w.createElement("defs",null,w.createElement(rO,{clipPathId:y,xAxisId:a,yAxisId:o}),!M&&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(IQ,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:kTe,errorBarOffset:0},w.createElement(CTe,{props:this.props,clipPathId:y}))),w.createElement($3,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:A}))}}var eZ={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:Zr.line,type:"linear"};function PTe(t){var e=Ur(t,eZ),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:f,legendType:m,xAxisId:g,yAxisId:x,id:y}=e,b=sO(e,gTe),{needClip:v}=PM(g,x),M=jM(),S=Gf(),A=Pi(),E=Ot(P=>fTe(P,g,x,A,y));if(S!=="horizontal"&&S!=="vertical"||E==null||M==null)return null;var{height:k,width:C,x:R,y:T}=M;return w.createElement(jTe,w0({},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:g,yAxisId:x,points:E,layout:S,height:k,width:C,left:R,top:T,needClip:v}))}function RTe(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=er(u,o);if(e==="horizontal"){var m=kw({axis:n,ticks:i,bandSize:l,entry:u,index:d}),g=Ar(f)?null:r.scale(f);return{x:m,y:g,value:f,payload:u}}var x=Ar(f)?null:n.scale(f),y=kw({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 DTe(t){var e=Ur(t,eZ),n=Pi();return w.createElement(CM,{id:e.id,type:"line"},r=>w.createElement(w.Fragment,null,w.createElement(tO,{legendPayload:_Te(e)}),w.createElement(wTe,{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(nO,{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(PTe,w0({},e,{id:r}))))}var tZ=w.memo(DTe,Sy);tZ.displayName="Line";var nZ=(t,e,n,r)=>Ul(t,"xAxis",e,r),rZ=(t,e,n,r)=>Fl(t,"xAxis",e,r),iZ=(t,e,n,r)=>Ul(t,"yAxis",n,r),aZ=(t,e,n,r)=>Fl(t,"yAxis",n,r),OTe=et([kn,nZ,iZ,rZ,aZ],(t,e,n,r,i)=>Wl(t,"xAxis")?Ld(e,r,!1):Ld(n,i,!1)),LTe=(t,e,n,r,i)=>i,sZ=et([my,LTe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),ITe=(t,e,n,r,i)=>{var a,o=sZ(t,e,n,r,i);if(o!=null){var l=kn(t),c=Wl(l,"xAxis"),u;if(c?u=v0(t,"yAxis",n,r):u=v0(t,"xAxis",e,r),u!=null){var{stackId:d}=o,f=pM(o);if(!(d==null||f==null)){var m=(a=u[d])===null||a===void 0?void 0:a.stackedData;return m?.find(g=>g.key===f)}}}},FTe=et([kn,nZ,iZ,rZ,aZ,ITe,uy,OTe,sZ,h_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:g}=c,x;if(g&&g.length>0?x=g:x=d?.slice(f,m+1),x!=null)return rCe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:x,chartBaseValue:u,bandSize:l})}}),UTe=["id"],zTe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function lf(){return lf=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},lf.apply(null,arguments)}function oZ(t,e){if(t==null)return{};var n,r,i=BTe(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 BTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function R$(t,e){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 Cp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?R$(Object(n),!0).forEach(function(r){$Te(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):R$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $Te(t,e,n){return(e=HTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function HTe(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)}function cS(t,e){return t&&t!=="none"?t:e}var GTe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:o}=t;return[{inactive:o,dataKey:e,type:a,color:cS(r,i),value:Qd(n,e),payload:t}]},WTe=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:Qd(o,e),hide:l,type:u,color:cS(r,a),unit:c}};return w.createElement(TM,{tooltipEntrySettings:d})});function qTe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:o}=r,l=Wa(r);return w.createElement(DQ,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function KTe(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 Cp(Cp({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return w.createElement(W4,{value:e?i:void 0},n)}function D$(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=oZ(a,UTe),g=Wa(m),x=ya(m);return w.createElement(w.Fragment,null,e?.length>1&&w.createElement(Fr,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},w.createElement(Ip,lf({},x,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&w.createElement(Ip,lf({},g,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&w.createElement(Ip,lf({},g,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),w.createElement(qTe,{points:e,props:m,clipPathId:i}))}function XTe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].y,o=r[r.length-1].y;if(!tr(a)||!tr(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.x||0));return Ft(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Ft(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 YTe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].x,o=r[r.length-1].x;if(!tr(a)||!tr(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.y||0));return Ft(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Ft(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 QTe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?w.createElement(XTe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):w.createElement(YTe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function ZTe(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:g}=r,x=w.useMemo(()=>({points:o,baseLine:l}),[o,l]),y=Og(x,"recharts-area-"),b=kxe(),[v,M]=w.useState(!1),S=!v,A=w.useCallback(()=>{typeof g=="function"&&g(),M(!1)},[g]),E=w.useCallback(()=>{typeof m=="function"&&m(),M(!0)},[m]);if(b==null)return null;var k=i.current,C=a.current;return w.createElement(KTe,{showLabels:S,points:o},r.children,w.createElement(Dg,{animationId:y,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:A,onAnimationStart:E,key:y},R=>{if(k){var T=k.length/o.length,P=R===1?o:o.map((L,X)=>{var D=Math.floor(X*T);if(k[D]){var K=k[D];return Cp(Cp({},L),{},{x:qn(K.x,L.x,R),y:qn(K.y,L.y,R)})}return L}),F;return Ft(l)?F=qn(C,l,R):Ar(l)||bs(l)?F=qn(C,0,R):F=l.map((L,X)=>{var D=Math.floor(X*T);if(Array.isArray(C)&&C[D]){var K=C[D];return Cp(Cp({},L),{},{x:qn(K.x,L.x,R),y:qn(K.y,L.y,R)})}return L}),R>0&&(i.current=P,a.current=F),w.createElement(D$,{points:P,baseLine:F,needClip:e,clipPathId:n,props:r})}return R>0&&(i.current=o,a.current=l),w.createElement(Fr,null,c&&w.createElement("defs",null,w.createElement("clipPath",{id:"animationClipPath-".concat(n)},w.createElement(QTe,{alpha:R,points:o,baseLine:l,layout:b,strokeWidth:r.strokeWidth}))),w.createElement(Fr,{clipPath:"url(#animationClipPath-".concat(n,")")},w.createElement(D$,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),w.createElement(NM,{label:r.label}))}function JTe(t){var{needClip:e,clipPathId:n,props:r}=t,i=w.useRef(null),a=w.useRef();return w.createElement(ZTe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class eCe 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:g,zIndex:x}=this.props;if(e)return null;var y=In("recharts-area",i),b=m,{r:v,strokeWidth:M}=ZQ(n),S=Y4(n),A=v*2+M,E=l?"url(#clipPath-".concat(S?"":"dots-").concat(b,")"):void 0;return w.createElement(Pa,{zIndex:x},w.createElement(Fr,{className:y},l&&w.createElement("defs",null,w.createElement(rO,{clipPathId:b,xAxisId:c,yAxisId:u}),!S&&w.createElement("clipPath",{id:"clipPath-dots-".concat(b)},w.createElement("rect",{x:o-A/2,y:a-A/2,width:d+A,height:f+A}))),w.createElement(JTe,{needClip:l,clipPathId:b,props:this.props})),w.createElement($3,{points:r,mainColor:cS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:E}),this.props.isRange&&Array.isArray(g)&&w.createElement($3,{points:g,mainColor:cS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:E}))}}var lZ={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:Zr.area};function tCe(t){var e,n=Ur(t,lZ),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:m,legendType:g,stroke:x,xAxisId:y,yAxisId:b}=n,v=oZ(n,zTe),M=Gf(),S=rQ(),{needClip:A}=PM(y,b),E=Pi(),{points:k,isRange:C,baseLine:R}=(e=Ot(D=>FTe(D,y,b,E,t.id)))!==null&&e!==void 0?e:{},T=jM();if(M!=="horizontal"&&M!=="vertical"||T==null||S!=="AreaChart"&&S!=="ComposedChart")return null;var{height:P,width:F,x:L,y:X}=T;return!k||!k.length?null:w.createElement(eCe,lf({},v,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,baseLine:R,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:P,hide:f,layout:M,isAnimationActive:m==="auto"?!Rg.isSsr:m,isRange:C,legendType:g,needClip:A,points:k,stroke:x,width:F,left:L,top:X,xAxisId:y,yAxisId:b}))}var nCe=(t,e,n,r,i)=>{var a=n??e;if(Ft(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 rCe(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:g}=t,x=i&&i.length,y=nCe(a,o,n,l,c),b=a==="horizontal",v=!1,M=u.map((A,E)=>{var k;x?k=i[d+E]:(k=er(A,r),Array.isArray(k)?v=!0:k=[y,k]);var C=k[1]==null||x&&!e&&er(A,r)==null;return b?{x:kw({axis:l,ticks:f,bandSize:g,entry:A,index:E}),y:C?null:c.scale(k[1]),value:k,payload:A}:{x:C?null:l.scale(k[1]),y:kw({axis:c,ticks:m,bandSize:g,entry:A,index:E}),value:k,payload:A}}),S;return x||v?S=M.map(A=>{var E=Array.isArray(A.value)?A.value[0]:null;return b?{x:A.x,y:E!=null&&A.y!=null?c.scale(E):null,payload:A.payload}:{x:E!=null?l.scale(E):null,y:A.y,payload:A.payload}}):S=b?c.scale(y):l.scale(y),{points:M,baseLine:S,isRange:v}}function iCe(t){var e=Ur(t,lZ),n=Pi();return w.createElement(CM,{id:e.id,type:"area"},r=>w.createElement(w.Fragment,null,w.createElement(tO,{legendPayload:GTe(e)}),w.createElement(WTe,{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(nO,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:PK(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),w.createElement(tCe,lf({},e,{id:r}))))}var cZ=w.memo(iCe,Sy);cZ.displayName="Area";var aCe=["domain","range"],sCe=["domain","range"];function O$(t,e){if(t==null)return{};var n,r,i=oCe(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 oCe(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 L$(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 uZ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=O$(t,aCe),{domain:a,range:o}=e,l=O$(e,sCe);return!L$(n,a)||!L$(r,o)?!1:Sy(i,l)}var lCe=["dangerouslySetInnerHTML","ticks"],cCe=["id"];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 I$(t,e){if(t==null)return{};var n,r,i=uCe(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 uCe(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 dCe(t){var e=xr(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(aNe(t)):n.current!==t&&e(sNe({prev:n.current,next:t})),n.current=t},[t,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(oNe(n.current)),n.current=null)},[e]),null}var hCe=t=>{var{xAxisId:e,className:n}=t,r=Ot(CD),i=Pi(),a="xAxis",o=Ot(b=>Fd(b,a,e,i)),l=Ot(b=>OY(b,a,e,i)),c=Ot(b=>jY(b,e)),u=Ot(b=>c1e(b,e)),d=Ot(b=>hY(b,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:m}=t,g=I$(t,lCe),{id:x}=d,y=I$(d,cCe);return w.createElement(aO,V3({},g,y,{scale:o,x:u.x,y:u.y,width:c.width,height:c.height,className:In("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:l,axisType:a}))},fCe={allowDataOverflow:Hi.allowDataOverflow,allowDecimals:Hi.allowDecimals,allowDuplicatedCategory:Hi.allowDuplicatedCategory,angle:Hi.angle,axisLine:Wc.axisLine,height:Hi.height,hide:!1,includeHidden:Hi.includeHidden,interval:Hi.interval,minTickGap:Hi.minTickGap,mirror:Hi.mirror,orientation:Hi.orientation,padding:Hi.padding,reversed:Hi.reversed,scale:Hi.scale,tick:Hi.tick,tickCount:Hi.tickCount,tickLine:Wc.tickLine,tickSize:Wc.tickSize,type:Hi.type,xAxisId:0},mCe=t=>{var e=Ur(t,fCe);return w.createElement(w.Fragment,null,w.createElement(dCe,{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(hCe,e))},uS=w.memo(mCe,uZ);uS.displayName="XAxis";var pCe=["dangerouslySetInnerHTML","ticks"],gCe=["id"];function G3(){return G3=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},G3.apply(null,arguments)}function F$(t,e){if(t==null)return{};var n,r,i=xCe(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 xCe(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 bCe(t){var e=xr(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(lNe(t)):n.current!==t&&e(cNe({prev:n.current,next:t})),n.current=t},[t,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(uNe(n.current)),n.current=null)},[e]),null}var yCe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,a=w.useRef(null),o=w.useRef(null),l=Ot(CD),c=Pi(),u=xr(),d="yAxis",f=Ot(E=>Fd(E,d,e,c)),m=Ot(E=>PY(E,e)),g=Ot(E=>d1e(E,e)),x=Ot(E=>OY(E,d,e,c)),y=Ot(E=>fY(E,e));if(w.useLayoutEffect(()=>{if(!(r!=="auto"||!m||G4(i)||w.isValidElement(i)||y==null)){var E=a.current;if(E){var k=E.getCalculatedWidth();Math.round(m.width)!==Math.round(k)&&u(dNe({id:e,width:k}))}}},[x,m,u,i,e,r,y]),m==null||g==null||y==null)return null;var{dangerouslySetInnerHTML:b,ticks:v}=t,M=F$(t,pCe),{id:S}=y,A=F$(y,gCe);return w.createElement(aO,G3({},M,A,{ref:a,labelRef:o,scale:f,x:g.x,y:g.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:m.width,height:m.height,className:In("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:x,axisType:d}))},vCe={allowDataOverflow:Vi.allowDataOverflow,allowDecimals:Vi.allowDecimals,allowDuplicatedCategory:Vi.allowDuplicatedCategory,angle:Vi.angle,axisLine:Wc.axisLine,hide:!1,includeHidden:Vi.includeHidden,interval:Vi.interval,minTickGap:Vi.minTickGap,mirror:Vi.mirror,orientation:Vi.orientation,padding:Vi.padding,reversed:Vi.reversed,scale:Vi.scale,tick:Vi.tick,tickCount:Vi.tickCount,tickLine:Wc.tickLine,tickSize:Wc.tickSize,type:Vi.type,width:Vi.width,yAxisId:0},_Ce=t=>{var e=Ur(t,vCe);return w.createElement(w.Fragment,null,w.createElement(bCe,{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(yCe,e))},dS=w.memo(_Ce,uZ);dS.displayName="YAxis";var wCe=(t,e)=>e,oO=et([wCe,kn,uY,Di,QY,mu,Ewe,ji],Rwe),lO=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)}},dZ=Ao("mouseClick"),hZ=ny();hZ.startListening({actionCreator:dZ,effect:(t,e)=>{var n=t.payload,r=oO(e.getState(),lO(n));r?.activeIndex!=null&&e.dispatch(N1e({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var W3=Ao("mouseMove"),fZ=ny(),f_=null;fZ.startListening({actionCreator:W3,effect:(t,e)=>{var n=t.payload;f_!==null&&cancelAnimationFrame(f_);var r=lO(n);f_=requestAnimationFrame(()=>{var i=e.getState(),a=D4(i,i.tooltip.settings.shared);if(a==="axis"){var o=oO(i,r);o?.activeIndex!=null?e.dispatch(HY({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch($Y())}f_=null})}});var U$={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},mZ=ys({name:"rootProps",initialState:U$,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:U$.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}}}),SCe=mZ.reducer,{updateOptions:MCe}=mZ.actions,pZ=ys({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:NCe}=pZ.actions,ECe=pZ.reducer,gZ=Ao("keyDown"),xZ=Ao("focus"),cO=ny();cO.startListening({actionCreator:gZ,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=O4(i,Hg(n),gy(n),vy(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=mu(n);if(a==="Enter"){var u=Zw(n,"axis","hover",String(i.index));e.dispatch(L3({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=p1e(n),f=d==="left-to-right"?1:-1,m=a==="ArrowRight"?1:-1,g=l+m*f;if(!(c==null||g>=c.length||g<0)){var x=Zw(n,"axis","hover",String(g));e.dispatch(L3({active:!0,activeIndex:g.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});cO.startListening({actionCreator:xZ,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=Zw(n,"axis","hover",String(a));e.dispatch(L3({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:o}))}}}});var oo=Ao("externalEvent"),bZ=ny(),uC=new Map;bZ.startListening({actionCreator:oo,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=uC.get(i);a!==void 0&&cancelAnimationFrame(a);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:dwe(l),activeDataKey:z4(l),activeIndex:Ud(l),activeLabel:eQ(l),activeTooltipIndex:Ud(l),isTooltipActive:hwe(l)};n(c,r)}finally{uC.delete(i)}});uC.set(i,o)}}});var ACe=et([$g],t=>t.tooltipItemPayloads),TCe=et([ACe,by,(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}}}),yZ=Ao("touchMove"),vZ=ny();vZ.startListening({actionCreator:yZ,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=D4(r,r.tooltip.settings.shared);if(i==="axis"){var a=oO(r,lO({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(HY({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(DK),d=(o=c.getAttribute(OK))!==null&&o!==void 0?o:void 0,f=TCe(e.getState(),u,d);e.dispatch(BY({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var CCe=tK({brush:JEe,cartesianAxis:hNe,chartData:uSe,errorBars:jNe,graphicalItems:yMe,layout:Ige,legend:Gxe,options:aSe,polarAxis:D2e,polarOptions:ECe,referenceElements:uAe,rootProps:SCe,tooltip:E1e,zIndex:qwe}),kCe=function(e){return lge({reducer:CCe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([hZ.middleware,fZ.middleware,cO.middleware,bZ.middleware,vZ.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(gK({type:"raf"}))},devTools:Rg.devToolsEnabled})};function _Z(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=Pi(),a=w.useRef(null);if(i)return n;a.current==null&&(a.current=kCe(e));var o=vD;return w.createElement(tEe,{context:o,store:a.current},n)}function jCe(t){var{layout:e,margin:n}=t,r=xr(),i=Pi();return w.useEffect(()=>{i||(r(Dge(e)),r(Rge(n)))},[r,i,e,n]),null}var wZ=w.memo(jCe,Sy);function SZ(t){var e=xr();return w.useEffect(()=>{e(MCe(t))},[e,t]),null}function z$(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=jQ("".concat(r).concat(e)),a=xr();return w.useLayoutEffect(()=>(a(Gwe({zIndex:e,elementId:i,isPanorama:n})),()=>{a(Wwe({zIndex:e,isPanorama:n}))}),[a,e,i,n]),w.createElement("g",{tabIndex:-1,id:i})}function B$(t){var{children:e,isPanorama:n}=t,r=Ot(Owe);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(z$,{key:o,zIndex:o,isPanorama:n})),e,a.map(o=>w.createElement(z$,{key:o,zIndex:o,isPanorama:n})))}var PCe=["children"];function RCe(t,e){if(t==null)return{};var n,r,i=DCe(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 DCe(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 hS(){return hS=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},hS.apply(null,arguments)}var OCe={width:"100%",height:"100%",display:"block"},LCe=w.forwardRef((t,e)=>{var n=jD(),r=PD(),i=QK();if(!Ll(n)||!Ll(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(uD,hS({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:OCe,ref:e}),a)}),ICe=t=>{var{children:e}=t,n=Ot(nM);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return w.createElement(uD,{width:r,height:i,x:o,y:a},e)},$$=w.forwardRef((t,e)=>{var{children:n}=t,r=RCe(t,PCe),i=Pi();return i?w.createElement(ICe,null,w.createElement(B$,{isPanorama:!0},n)):w.createElement(LCe,hS({ref:e},r),w.createElement(B$,{isPanorama:!1},n))});function FCe(){var t=xr(),[e,n]=w.useState(null),r=Ot(exe);return w.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;tr(a)&&a!==r&&t(Lge(a))}},[e,t,r]),n}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 UCe(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){zCe(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 zCe(t,e,n){return(e=BCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function BCe(t){var e=$Ce(t,"string");return typeof e=="symbol"?e:e+""}function $Ce(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function jf(){return jf=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},jf.apply(null,arguments)}var HCe=()=>(ySe(),null);function fS(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var VCe=w.forwardRef((t,e)=>{var n,r,i=w.useRef(null),[a,o]=w.useState({containerWidth:fS((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:fS((r=t.style)===null||r===void 0?void 0:r.height)}),l=w.useCallback((u,d)=>{o(f=>{var m=Math.round(u),g=Math.round(d);return f.containerWidth===m&&f.containerHeight===g?f:{containerWidth:m,containerHeight:g}})},[]),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)},g=new ResizeObserver(m);g.observe(u),i.current=g}},[e,l]);return w.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[l]),w.createElement(w.Fragment,null,w.createElement(rM,{width:a.containerWidth,height:a.containerHeight}),w.createElement("div",jf({ref:c},t)))}),GCe=w.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=w.useState({containerWidth:fS(n),containerHeight:fS(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(rM,{width:i.containerWidth,height:i.containerHeight}),w.createElement("div",jf({ref:l},t)))}),WCe=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return w.createElement(w.Fragment,null,w.createElement(rM,{width:n,height:r}),w.createElement("div",jf({ref:e},t)))}),qCe=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return tu(n)||tu(r)?w.createElement(GCe,jf({},t,{ref:e})):w.createElement(WCe,jf({},t,{ref:e}))});function KCe(t){return t===!0?VCe:qCe}var XCe=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:g,onTouchMove:x,onTouchStart:y,style:b,width:v,responsive:M,dispatchTouchEvents:S=!0}=t,A=w.useRef(null),E=xr(),[k,C]=w.useState(null),[R,T]=w.useState(null),P=FCe(),F=kD(),L=F?.width>0?F.width:v,X=F?.height>0?F.height:i,D=w.useCallback(ge=>{P(ge),typeof e=="function"&&e(ge),C(ge),T(ge),ge!=null&&(A.current=ge)},[P,e,C,T]),K=w.useCallback(ge=>{E(dZ(ge)),E(oo({handler:a,reactEvent:ge}))},[E,a]),Y=w.useCallback(ge=>{E(W3(ge)),E(oo({handler:u,reactEvent:ge}))},[E,u]),q=w.useCallback(ge=>{E($Y()),E(oo({handler:d,reactEvent:ge}))},[E,d]),Z=w.useCallback(ge=>{E(W3(ge)),E(oo({handler:f,reactEvent:ge}))},[E,f]),re=w.useCallback(()=>{E(xZ())},[E]),oe=w.useCallback(ge=>{E(gZ(ge.key))},[E]),B=w.useCallback(ge=>{E(oo({handler:o,reactEvent:ge}))},[E,o]),G=w.useCallback(ge=>{E(oo({handler:l,reactEvent:ge}))},[E,l]),J=w.useCallback(ge=>{E(oo({handler:c,reactEvent:ge}))},[E,c]),te=w.useCallback(ge=>{E(oo({handler:m,reactEvent:ge}))},[E,m]),ae=w.useCallback(ge=>{E(oo({handler:y,reactEvent:ge}))},[E,y]),de=w.useCallback(ge=>{S&&E(yZ(ge)),E(oo({handler:x,reactEvent:ge}))},[E,S,x]),fe=w.useCallback(ge=>{E(oo({handler:g,reactEvent:ge}))},[E,g]),Ae=KCe(M);return w.createElement(lQ.Provider,{value:k},w.createElement(gq.Provider,{value:R},w.createElement(Ae,{width:L??b?.width,height:X??b?.height,className:In("recharts-wrapper",r),style:UCe({position:"relative",cursor:"default",width:L,height:X},b),onClick:K,onContextMenu:B,onDoubleClick:G,onFocus:re,onKeyDown:oe,onMouseDown:J,onMouseEnter:Y,onMouseLeave:q,onMouseMove:Z,onMouseUp:te,onTouchEnd:fe,onTouchMove:de,onTouchStart:ae,ref:D},w.createElement(HCe,null),n)))}),YCe=["width","height","responsive","children","className","style","compact","title","desc"];function QCe(t,e){if(t==null)return{};var n,r,i=ZCe(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 ZCe(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 MZ=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=QCe(t,YCe),m=Wa(f);return c?w.createElement(w.Fragment,null,w.createElement(rM,{width:n,height:r}),w.createElement($$,{otherAttributes:m,title:u,desc:d},a)):w.createElement(XCe,{className:o,style:l,width:n,height:r,responsive:i??!1,onClick:t.onClick,onMouseLeave:t.onMouseLeave,onMouseEnter:t.onMouseEnter,onMouseMove:t.onMouseMove,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onContextMenu:t.onContextMenu,onDoubleClick:t.onDoubleClick,onTouchStart:t.onTouchStart,onTouchMove:t.onTouchMove,onTouchEnd:t.onTouchEnd},w.createElement($$,{otherAttributes:m,title:u,desc:d,ref:e},w.createElement(dAe,null,a)))});function q3(){return q3=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},q3.apply(null,arguments)}var JCe={top:5,right:5,bottom:5,left:5},eke={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:JCe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},uO=w.forwardRef(function(e,n){var r,i=Ur(e.categoricalChartProps,eke),{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(_Z,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},w.createElement(BQ,{chartData:u.data}),w.createElement(wZ,{layout:i.layout,margin:i.margin}),w.createElement(SZ,{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(MZ,q3({},i,{ref:n})))}),tke=["axis"],nke=w.forwardRef((t,e)=>w.createElement(uO,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:tke,tooltipPayloadSearcher:SM,categoricalChartProps:t,ref:e})),rke=["axis","item"],ike=w.forwardRef((t,e)=>w.createElement(uO,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:rke,tooltipPayloadSearcher:SM,categoricalChartProps:t,ref:e}));function ake(t){var e=xr();return w.useEffect(()=>{e(NCe(t))},[e,t]),null}var ske=["layout"];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 oke(t,e){if(t==null)return{};var n,r,i=lke(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 lke(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 cke={top:5,right:5,bottom:5,left:5},NZ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:cke,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},uke=w.forwardRef(function(e,n){var r,i=Ur(e.categoricalChartProps,NZ),{layout:a}=i,o=oke(i,ske),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return w.createElement(_Z,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},w.createElement(BQ,{chartData:i.data}),w.createElement(wZ,{layout:a,margin:i.margin}),w.createElement(SZ,{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(ake,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),w.createElement(MZ,K3({},o,{ref:n})))});function V$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function G$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?V$(Object(n),!0).forEach(function(r){dke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):V$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dke(t,e,n){return(e=hke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hke(t){var e=fke(t,"string");return typeof e=="symbol"?e:e+""}function fke(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 mke=["item"],pke=G$(G$({},NZ),{},{layout:"centric",startAngle:0,endAngle:360}),gke=w.forwardRef((t,e)=>{var n=Ur(t,pke);return w.createElement(uke,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:mke,tooltipPayloadSearcher:SM,categoricalChartProps:n,ref:e})}),xke=["axis"],bke=w.forwardRef((t,e)=>w.createElement(uO,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:xke,tooltipPayloadSearcher:SM,categoricalChartProps:t,ref:e}));const W$=[{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 yke({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:o="humidity",thresholds:l}){const{t:c}=Tg(),{mode:u}=Xd(),[d,f]=w.useState("24h"),[m,g]=w.useState(o),x=u==="dark",{data:y}=ct({queryKey:["settings"],queryFn:pe.getSettings}),b=y?.time_format||"system";w.useEffect(()=>{if(!t)return;const te=ae=>{ae.key==="Escape"&&e()};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},[t,e]);const v=W$.find(te=>te.value===d)?.hours||24,{data:M,isLoading:S,error:A}=ct({queryKey:["ams-history",n,i,v],queryFn:()=>pe.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const E=M?.data.map(te=>{const ae=mi(te.recorded_at)||new Date,de={hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}};return{time:ae.getTime(),humidity:te.humidity,temperature:te.temperature,timeLabel:ae.toLocaleTimeString([],Pb(de,b))}})||[],k=l?.humidityGood||40,C=l?.humidityFair||60,R=l?.tempGood||30,T=l?.tempFair||35,P=E[E.length-1],F=P?.humidity,L=P?.temperature,X=te=>{const ae=te.filter(je=>je!=null);if(ae.length<4)return"stable";const de=ae.slice(0,Math.floor(ae.length/4)),fe=ae.slice(-Math.floor(ae.length/4)),Ae=de.reduce((je,ne)=>je+ne,0)/de.length,Me=fe.reduce((je,ne)=>je+ne,0)/fe.length-Ae;return Math.abs(Me)<2?"stable":Me>0?"up":"down"},D=X(E.map(te=>te.humidity)),K=X(E.map(te=>te.temperature)),Y=({trend:te})=>te==="up"?s.jsx(aq,{className:"w-4 h-4 text-red-400"}):te==="down"?s.jsx(iq,{className:"w-4 h-4 text-green-400"}):s.jsx(Hj,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),q=te=>te==null?"#9ca3af":te<=k?"#22a352":te<=C?"#d4a017":"#c62828",Z=te=>te==null?"#9ca3af":te<=R?"#22a352":te<=T?"#d4a017":"#c62828",re=x?"#2d2d2d":"#ffffff",oe=x?"#1d1d1d":"#f3f4f6",B=x?"#3d3d3d":"#e5e7eb",G=x?"#ffffff":"#111827",J=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:re},onClick:te=>te.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:B},children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold",style:{color:G},children:[a," ",c("common.history","History")]}),s.jsx("p",{className:"text-sm",style:{color:J},children:r})]}),s.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:J},children:s.jsx(Ut,{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:oe},children:[s.jsxs("button",{onClick:()=>g("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:J}:void 0,children:[s.jsx(tD,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),s.jsxs("button",{onClick:()=>g("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:J}:void 0,children:[s.jsx(U2,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),s.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:oe},children:W$.map(te=>s.jsx("button",{onClick:()=>f(te.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===te.value?"bg-bambu-green text-white":""}`,style:d!==te.value?{color:J}:void 0,children:te.label},te.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:oe},children:[s.jsx("p",{className:"text-xs",style:{color:J},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:D})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:oe},children:[s.jsx("p",{className:"text-xs",style:{color:J},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:G},children:M?.avg_humidity!=null?`${M.avg_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:oe},children:[s.jsx("p",{className:"text-xs",style:{color:J},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-green-500",children:M?.min_humidity!=null?`${M.min_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:oe},children:[s.jsx("p",{className:"text-xs",style:{color:J},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:M?.max_humidity!=null?`${M.max_humidity}%`:"—"})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:oe},children:[s.jsx("p",{className:"text-xs",style:{color:J},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:Z(L)},children:L!=null?`${L}°C`:"—"}),s.jsx(Y,{trend:K})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:oe},children:[s.jsx("p",{className:"text-xs",style:{color:J},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:G},children:M?.avg_temperature!=null?`${M.avg_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:oe},children:[s.jsx("p",{className:"text-xs",style:{color:J},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-blue-500",children:M?.min_temperature!=null?`${M.min_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:oe},children:[s.jsx("p",{className:"text-xs",style:{color:J},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:M?.max_temperature!=null?`${M.max_temperature}°C`:"—"})]})]})}),s.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:oe},children:S?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:J},children:c("common.loading","Loading...")}):A?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:J},children:c("common.noData","No data available for this time range")}):s.jsx(F1,{width:"100%",height:300,children:s.jsxs(nke,{data:E,children:[s.jsx(lS,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),s.jsx(uS,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:te=>{const ae=new Date(te);return v>24?ae.toLocaleDateString([],{day:"numeric",month:"short"}):ae.toLocaleTimeString([],Pb({hour:"2-digit",minute:"2-digit"},b))},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),s.jsx(dS,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:m==="humidity"?[0,100]:["auto","auto"],tickFormatter:te=>m==="humidity"?`${te}%`:`${te}°C`}),s.jsx(z1,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:te=>new Date(te).toLocaleString(void 0,Pb({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},b)),formatter:te=>[m==="humidity"?`${te}%`:`${te}°C`,m==="humidity"?"Humidity":"Temperature"]}),s.jsx(OD,{}),m==="humidity"?s.jsxs(s.Fragment,{children:[s.jsx(yb,{y:k,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(yb,{y:C,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):s.jsxs(s.Fragment,{children:[s.jsx(yb,{y:R,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(yb,{y:T,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),s.jsx(tZ,{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:J},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function dC({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),g=w.useRef(null),x=w.useRef(null),y=()=>{const k=t.trayUuid;k&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(k).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)}).catch(()=>{b(k)}):b(k))},b=k=>{const C=document.createElement("textarea");C.value=k,C.style.position="fixed",C.style.opacity="0",document.body.appendChild(C),C.select();try{document.execCommand("copy"),f(!0),setTimeout(()=>f(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(C)};w.useEffect(()=>{if(o&&m.current&&g.current){const k=m.current.getBoundingClientRect(),C=g.current.offsetHeight,R=k.top,T=window.innerHeight-k.bottom;R<C+12&&T>R?u("bottom"):u("top")}},[o]);const v=()=>{n||(x.current&&clearTimeout(x.current),x.current=setTimeout(()=>l(!0),80))},M=()=>{x.current&&clearTimeout(x.current),x.current=setTimeout(()=>l(!1),100)};w.useEffect(()=>()=>{x.current&&clearTimeout(x.current)},[]);const S=k=>k<=15?"#ef4444":k<=30?"#f97316":k<=50?"#eab308":"#22c55e",A=k=>{if(!k)return!1;const C=k.replace("#",""),R=parseInt(C.slice(0,2),16),T=parseInt(C.slice(2,4),16),P=parseInt(C.slice(4,6),16);return(.299*R+.587*T+.114*P)/255>.6},E=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return s.jsxs("div",{ref:m,className:`relative ${r}`,onMouseEnter:v,onMouseLeave:M,children:[e,o&&s.jsxs("div",{ref:g,className:`
- absolute left-1/2 -translate-x-1/2 z-50
- ${c==="top"?"bottom-full mb-2":"top-full mt-2"}
- animate-in fade-in-0 zoom-in-95 duration-150
- `,style:{maxWidth:"calc(100vw - 24px)"},children:[s.jsxs("div",{className:`
- w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-lg shadow-xl overflow-hidden
- backdrop-blur-sm
- `,children:[s.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:E||"#3d3d3d"},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),s.jsx("div",{className:`
- absolute inset-0 flex items-center justify-center
- font-semibold text-sm tracking-wide
- ${A(E)?"text-black/80":"text-white/90"}
- `,children:t.colorName}),s.jsx("div",{className:`
- absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
- ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
- `,children:t.vendor==="Bambu Lab"?"BBL":"GEN"})]}),s.jsxs("div",{className:"p-3 space-y-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"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(tD,{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:k=>{k.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(xs,{className:"w-3 h-3 text-bambu-green"}):s.jsx(Jo,{className:"w-3 h-3"})]})]}),i.onLinkSpool&&s.jsxs("button",{onClick:k=>{k.stopPropagation(),i.hasUnlinkedSpools!==!1&&i.onLinkSpool?.(t.trayUuid)},disabled:i.hasUnlinkedSpools===!1,className:`w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors ${i.hasUnlinkedSpools===!1?"bg-bambu-gray/10 text-bambu-gray cursor-not-allowed":"bg-bambu-green/20 hover:bg-bambu-green/30 text-bambu-green"}`,title:i.hasUnlinkedSpools===!1?"No unlinked spools available":"Link this spool to a Spoolman spool",children:[s.jsx(kl,{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:k=>{k.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(Dd,{className:"w-3.5 h-3.5"}),"Configure"]})})]})]}),s.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 w-0 h-0
- border-l-[6px] border-l-transparent
- border-r-[6px] border-r-transparent
- ${c==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
- `})]})]})}function q$({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:`
- absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
- animate-in fade-in-0 zoom-in-95 duration-150
- `,children:[s.jsxs("div",{className:`
- bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-md shadow-lg overflow-hidden
- `,children:[s.jsx("div",{className:"px-3 py-1.5 text-xs text-bambu-gray whitespace-nowrap",children:"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(Dd,{className:"w-3.5 h-3.5"}),"Configure"]})})]}),s.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
- border-l-[5px] border-l-transparent
- border-r-[5px] border-r-transparent
- border-t-[5px] border-t-bambu-dark-tertiary
- `})]})]})}function vke({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const i=tn(),[a,o]=w.useState(null),{data:l,isLoading:c}=ct({queryKey:["unlinked-spools"],queryFn:pe.getUnlinkedSpools,enabled:t}),u=ft({mutationFn:f=>pe.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(kl,{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(Ut,{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(mt,{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(xs,{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(Se,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Se,{onClick:d,disabled:!a||u.isPending,children:u.isPending?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Linking..."]}):s.jsxs(s.Fragment,{children:[s.jsx(kl,{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 _ke(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 K$(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 wke=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function X$(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of wke){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 hC(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const Ske={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"},Mke=[{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"}],Nke=[{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 Eke(t){const e=t.toLowerCase().trim();return Ske[e]||null}function Ake({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,g]=w.useState(""),[x,y]=w.useState(""),[b,v]=w.useState(!1),[M,S]=w.useState(!1),{data:A,isLoading:E}=ct({queryKey:["cloudSettings"],queryFn:()=>pe.getCloudSettings(),enabled:t}),{data:k,isLoading:C}=ct({queryKey:["kprofiles",n,i],queryFn:()=>pe.getKProfiles(n,i),enabled:t&&!!n}),R=ft({mutationFn:async()=>{if(!o)throw new Error("No filament preset selected");const Z=A?.filament.find(ge=>ge.setting_id===o);if(!Z)throw new Error("Selected preset not found");const re=X$(Z.name),oe=c?.slot_id??-1,B=d||r.trayColor?.slice(0,6)||"FFFFFF",G=Z.name.replace(/@.+$/,"").trim();let J=K$(o);if(!o.startsWith("GFS"))try{const ge=await pe.getCloudSettingDetail(o);ge.filament_id?J=ge.filament_id:ge.base_id&&(J=K$(ge.base_id),console.log(`Derived tray_info_idx from base_id: ${ge.base_id} -> ${J}`))}catch(ge){console.warn("Failed to fetch preset detail for filament_id:",ge)}let te=190,ae=230;const de=re.material.toUpperCase();de.includes("PLA")?(te=190,ae=230):de.includes("PETG")?(te=220,ae=260):de.includes("ABS")||de.includes("ASA")?(te=240,ae=280):de.includes("TPU")?(te=200,ae=240):de.includes("PC")?(te=260,ae=300):(de.includes("PA")||de.includes("NYLON"))&&(te=250,ae=290);const fe=c?.k_value?parseFloat(c.k_value):0,Ae=await pe.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:J,tray_type:re.material||"PLA",tray_sub_brands:G,tray_color:B+"FF",nozzle_temp_min:te,nozzle_temp_max:ae,cali_idx:oe,nozzle_diameter:i,setting_id:o,kprofile_filament_id:c?.filament_id,kprofile_setting_id:c?.setting_id||void 0,k_value:fe});try{await pe.saveSlotPreset(n,r.amsId,r.trayId,o,G)}catch(ge){console.warn("Failed to save slot preset mapping:",ge)}return Ae},onSuccess:()=>{v(!0),a?.(),setTimeout(()=>{v(!1),e()},1500)}}),T=ft({mutationFn:async()=>pe.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{v(!0),a?.(),setTimeout(()=>{v(!1),e()},1500)}}),P=w.useMemo(()=>{if(!A?.filament)return[];const Z=x.toLowerCase();return A.filament.filter(re=>Z?re.name.toLowerCase().includes(Z):!0).sort((re,oe)=>{const B=hC(re.setting_id),G=hC(oe.setting_id);return B&&!G?-1:!B&&G?1:re.name.localeCompare(oe.name)})},[A?.filament,x]),F=w.useMemo(()=>{if(!o||!A?.filament)return null;const Z=A.filament.find(B=>B.setting_id===o);if(!Z)return null;let re=Z.name.replace(/@.+$/,"").trim();re.startsWith("# ")&&(re=re.slice(2).trim());const oe=X$(re);return{fullName:re,material:oe.material,brand:oe.brand}},[o,A?.filament]),L=F?.fullName||"",X=w.useMemo(()=>{if(!k?.profiles||!F)return[];const{fullName:Z,material:re,brand:oe}=F,B=Z.toUpperCase(),G=re.toUpperCase(),J=oe.toUpperCase();if(!G||G.length<2)return[];const te=k.profiles.filter(de=>{const fe=de.name.toUpperCase();if(J)return!(!fe.includes(J)||!fe.includes(G));if(fe.includes(B)||fe.includes(G))return!0;const ge={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[G]||[];for(const Me of ge)if(fe.includes(Me))return!0;return!1}),ae=new Map;for(const de of te){const fe=`${de.name}|${de.k_value}`,Ae=ae.get(fe);Ae?de.extruder_id===1&&Ae.extruder_id===0&&ae.set(fe,de):ae.set(fe,de)}return Array.from(ae.values())},[k?.profiles,F]);w.useEffect(()=>{if(t&&A?.filament){if(r.trayInfoIdx){const Z=A.filament.find(re=>re.setting_id===r.trayInfoIdx);Z&&l(Z.setting_id)}}else t||(l(""),u(null),f(""),g(""),y(""),v(!1))},[t,A?.filament,r.trayInfoIdx]),w.useEffect(()=>{X.length>0?u(X[0]):u(null)},[o,X]);const D=w.useCallback(Z=>{Z.key==="Escape"&&e()},[e]);if(w.useEffect(()=>{if(t)return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[t,D]),!t)return null;const K=E||C,Y=o&&!R.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(Dd,{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(Ut,{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(E2,{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:[_ke(r.amsId,r.trayCount)," Slot ",r.trayId+1]}),r.traySubBrands&&s.jsxs("span",{className:"text-bambu-gray",children:["(",r.traySubBrands,")"]})]})]}),K?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(mt,{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:Z=>y(Z.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:P.length===0?s.jsx("p",{className:"text-center py-4 text-bambu-gray",children:A?.filament?.length===0?"No cloud presets. Login to Bambu Cloud to sync.":"No matching presets found."}):P.map(Z=>s.jsx("button",{onClick:()=>l(Z.setting_id),className:`w-full p-2 rounded-lg border text-left transition-colors ${o===Z.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:Z.name}),hC(Z.setting_id)&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:"Custom"})]})},Z.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]})]}),X.length>0?s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:c?.name||"",onChange:Z=>{const re=X.find(oe=>oe.name===Z.target.value);u(re||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)"}),X.map(Z=>s.jsxs("option",{value:Z.name,children:[Z.name," (K=",Z.k_value,")"]},`${Z.name}-${Z.extruder_id}`))]}),s.jsx(Ji,{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:[Mke.map(Z=>s.jsx("button",{onClick:()=>{f(Z.hex),g(Z.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Z.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Z.hex}`},title:Z.name},Z.hex)),s.jsx("button",{onClick:()=>S(!M),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:M?"Show less colors":"Show more colors",children:M?"−":"+"})]}),M&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:Nke.map(Z=>s.jsx("button",{onClick:()=>{f(Z.hex),g(Z.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Z.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Z.hex}`},title:Z.name},Z.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:Z=>{const re=Z.target.value;g(re);const oe=Eke(re);if(oe)f(oe);else{const B=re.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();B.length===6?f(B):B.length===3&&f(B.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(""),g("")},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(Se,{variant:"secondary",onClick:()=>T.mutate(),disabled:T.isPending||R.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:T.isPending?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Vf,{className:"w-4 h-4"}),"Reset Slot"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Se,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Se,{onClick:()=>R.mutate(),disabled:!Y,children:R.isPending?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Configuring..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Dd,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(R.isError||T.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:R.error?.message||T.error?.message})]})]})}function Tke({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 Y$=({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"})]}),Q$={"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"},Cke={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 fC(t){if(!t)return null;if(Q$[t])return Q$[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return Cke[n]||null}function mC(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 pC(t){return(t??.02).toFixed(3)}function Z$({side:t}){const{mode:e}=Xd(),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 J$({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 kke({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 jke({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 Pke({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 Rke({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 Dke({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 gC({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 eH({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=J$:a<=l?d=kke:d=jke,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 tH({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=Pke):t<=o?(l="#d4a017",c="Fair",u=Rke):(l="#c62828",c="Bad",u=Dke),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 Uu(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 nH(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function Oke(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function Lke(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 Ike(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 Fke(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 xC(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 Uke({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(Os,{className:"w-8 h-8 text-bambu-gray"})]}):s.jsx(Os,{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 zke({printers:t}){const e=tn(),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 rH(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 iH({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=tn(),m=ol(),{showToast:g}=$n(),[x,y]=w.useState(!1),[b,v]=w.useState(!1),[M,S]=w.useState(!0),[A,E]=w.useState(!1),[k,C]=w.useState(!1),[R,T]=w.useState(!1),[P,F]=w.useState(!1),[L,X]=w.useState(!1),[D,K]=w.useState(!1),[Y,q]=w.useState(!1),[Z,re]=w.useState(!1),[oe,B]=w.useState(!1),[G,J]=w.useState(!1),[te,ae]=w.useState(null),[de,fe]=w.useState(null),[Ae,ge]=w.useState(null),[Me,je]=w.useState(!1),{data:ne}=ct({queryKey:["printerStatus",t.id],queryFn:()=>pe.getPrinterStatus(t.id),refetchInterval:3e4}),{data:Ke}=ct({queryKey:["firmwareUpdate",t.id],queryFn:()=>D1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3}),$=w.useMemo(()=>{const yt=new Set;if(ne?.ams)for(const en of ne.ams)for(const wn of en.tray||[])wn.tray_info_idx&&yt.add(wn.tray_info_idx);return ne?.vt_tray?.tray_info_idx&&yt.add(ne.vt_tray.tray_info_idx),Array.from(yt)},[ne?.ams,ne?.vt_tray]),{data:z}=ct({queryKey:["filamentInfo",$],queryFn:()=>pe.getFilamentInfo($),enabled:$.length>0,staleTime:300*1e3}),{data:W}=ct({queryKey:["slotPresets",t.id],queryFn:()=>pe.getSlotPresets(t.id),staleTime:120*1e3}),[U,V]=w.useState(null);w.useEffect(()=>{ne?.wifi_signal!=null&&V(ne.wifi_signal)},[ne?.wifi_signal]);const Q=ne?.wifi_signal??U,Ee=w.useRef(void 0);w.useEffect(()=>{ne?.connected!==void 0&&(Ee.current=ne.connected)},[ne?.connected]);const Ce=ne?.connected??Ee.current,Ne=w.useRef({});w.useEffect(()=>{ne?.ams_extruder_map&&Object.keys(ne.ams_extruder_map).length>0&&(Ne.current=ne.ams_extruder_map)},[ne?.ams_extruder_map]);const H=ne?.ams_extruder_map&&Object.keys(ne.ams_extruder_map).length>0?ne.ams_extruder_map:Ne.current,O=w.useRef([]);w.useEffect(()=>{ne?.ams&&ne.ams.length>0&&(O.current=ne.ams)},[ne?.ams]);const ie=ne?.ams&&ne.ams.length>0?ne.ams:O.current,ye=w.useRef(255),_e=ne?.tray_now;_e!==void 0&&_e!==255&&(ye.current=_e);const le=_e===void 0||_e===255?ye.current:_e,{data:ke}=ct({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>pe.getSmartPlugByPrinter(t.id)}),{data:Oe}=ct({queryKey:["smartPlugStatus",ke?.id],queryFn:()=>ke?pe.getSmartPlugStatus(ke.id):null,enabled:!!ke,refetchInterval:1e4}),{data:Ze}=ct({queryKey:["queue",t.id,"pending"],queryFn:()=>pe.getQueue(t.id,"pending")}),ht=Ze?.length||0,{data:We}=ct({queryKey:["archives",t.id,"last"],queryFn:()=>pe.getArchives(t.id,1,0),enabled:ne?.connected&&ne?.state!=="RUNNING"}),he=We?.[0],rt=e&&Ce===!1,qe=ft({mutationFn:yt=>pe.deletePrinter(t.id,yt.deleteArchives),onSuccess:()=>{f.invalidateQueries({queryKey:["printers"]}),f.invalidateQueries({queryKey:["archives"]}),f.invalidateQueries({queryKey:["maintenanceOverview"]})}}),Je=ft({mutationFn:()=>pe.connectPrinter(t.id),onSuccess:()=>{f.invalidateQueries({queryKey:["printerStatus",t.id]})}}),ot=ft({mutationFn:yt=>ke?pe.controlSmartPlug(ke.id,yt):Promise.reject("No plug"),onSuccess:()=>{f.invalidateQueries({queryKey:["smartPlugStatus",ke?.id]})}}),se=ft({mutationFn:yt=>ke?pe.updateSmartPlug(ke.id,{auto_off:yt}):Promise.reject("No plug"),onSuccess:()=>{f.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),f.invalidateQueries({queryKey:["smart-plugs"]})}}),$e=ft({mutationFn:()=>pe.stopPrint(t.id),onSuccess:()=>{g("Print stopped"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:yt=>g(yt.message||"Failed to stop print","error")}),be=ft({mutationFn:()=>pe.pausePrint(t.id),onSuccess:()=>{g("Print paused"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:yt=>g(yt.message||"Failed to pause print","error")}),Fe=ft({mutationFn:()=>pe.resumePrint(t.id),onSuccess:()=>{g("Print resumed"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:yt=>g(yt.message||"Failed to resume print","error")}),De=ft({mutationFn:yt=>pe.setChamberLight(t.id,yt),onMutate:async yt=>{await f.cancelQueries({queryKey:["printerStatus",t.id]});const en=f.getQueryData(["printerStatus",t.id]);return f.setQueryData(["printerStatus",t.id],wn=>({...wn,chamber_light:yt})),{previousStatus:en}},onSuccess:(yt,en)=>{g(`Chamber light ${en?"on":"off"}`)},onError:(yt,en,wn)=>{wn?.previousStatus&&f.setQueryData(["printerStatus",t.id],wn.previousStatus),g(yt.message||"Failed to control chamber light","error")}}),ve=(ne?.state==="RUNNING"||ne?.state==="PAUSE"||ne?.state==="PAUSED")&&(ne?.printable_objects_count??0)>=2,{data:He,refetch:dt}=ct({queryKey:["printableObjects",t.id],queryFn:()=>pe.getPrintableObjects(t.id),enabled:G||ve,refetchInterval:G?5e3:ve?3e4:!1}),kt=ft({mutationFn:yt=>pe.skipObjects(t.id,yt),onSuccess:yt=>{g(yt.message||"Objects skipped"),dt()},onError:yt=>g(yt.message||"Failed to skip objects","error")}),[jt,Zt]=w.useState(null),Rt=w.useRef(!1),nn=w.useRef(null),pt=w.useRef(!1),$t=ft({mutationFn:({amsId:yt,slotId:en})=>pe.refreshAmsSlot(t.id,yt,en),onMutate:({amsId:yt,slotId:en})=>{nn.current&&clearTimeout(nn.current),Rt.current=!1,pt.current=!1,Zt({amsId:yt,slotId:en}),setTimeout(()=>{pt.current=!0},2e3),nn.current=setTimeout(()=>{Zt(null)},3e4)},onSuccess:yt=>{g(yt.message||"RFID re-read initiated")},onError:yt=>{g(yt.message||"Failed to re-read RFID","error"),nn.current&&clearTimeout(nn.current),Zt(null)}}),qt=w.useRef(null);w.useEffect(()=>{if(!jt)return;const yt=ne?.ams_status_main??0;return yt!==0&&(Rt.current=!0,qt.current&&(clearTimeout(qt.current),qt.current=null)),Rt.current&&yt===0&&(pt.current?(nn.current&&clearTimeout(nn.current),Zt(null)):qt.current||(qt.current=setTimeout(()=>{nn.current&&clearTimeout(nn.current),Zt(null)},2e3))),()=>{qt.current&&clearTimeout(qt.current)}},[ne?.ams_status_main,jt]);const[wt,_r]=w.useState(null);if(rt)return null;const $r=()=>{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"}},Tr=()=>{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"}},hr=()=>{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(Mt,{className:"relative",children:[s.jsxs(Et,{className:i>=3?"p-5":"",children:[s.jsxs("div",{className:hr(),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:Ike(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${$r()}`}),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 ${Tr()}`,children:t.name}),r==="compact"&&s.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${ne?.connected?"bg-bambu-green":"bg-red-500"}`,title:ne?.connected?"Connected":"Offline"})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&ne?.nozzles&&ne.nozzles[0]?.nozzle_diameter&&s.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:ne.nozzles[0].nozzle_type||"Nozzle",children:["• ",ne.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(Gn,{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(Se,{variant:"ghost",size:"sm",onClick:()=>y(!x),children:s.jsx(wd,{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(Ga,{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:()=>{Je.mutate(),y(!1)},children:[s.jsx(yr,{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:()=>{T(!0),y(!1)},children:[s.jsx(rq,{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(an,{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 ${ne?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[ne?.connected?s.jsx(Y0,{className:"w-3 h-3"}):s.jsx(aD,{className:"w-3 h-3"}),ne?.connected?"Connected":"Offline"]}),ne?.connected&&Q!=null&&s.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${Q>=-50||Q>=-60?"bg-bambu-green/20 text-bambu-green":Q>=-70?"bg-amber-500/20 text-amber-600":Q>=-80?"bg-orange-500/20 text-orange-600":"bg-red-500/20 text-red-600"}`,title:`WiFi: ${Q} dBm - ${Fke(Q).label}`,children:[s.jsx(ahe,{className:"w-3 h-3"}),Q,"dBm"]}),ne?.connected&&(()=>{const yt=ne.hms_errors?Sfe(ne.hms_errors):[];return s.jsxs("button",{onClick:()=>K(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${yt.length>0?yt.some(en=>en.severity<=2)?"bg-red-500/20 text-red-400":"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:"Click to view HMS errors",children:[s.jsx(Cn,{className:"w-3 h-3"}),yt.length>0?yt.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-red-500/20 text-red-400":n.warning_count>0?"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,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(Od,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),ht>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:`${ht} print${ht>1?"s":""} in queue`,children:[s.jsx(nl,{className:"w-3 h-3"}),ht]}),Ke?.update_available&&s.jsxs("button",{onClick:()=>je(!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: ${Ke.current_version} → ${Ke.latest_version}`,children:[s.jsx(Jr,{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(Mt,{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(Cn,{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:M,onChange:yt=>S(yt.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:M?"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(Se,{variant:"secondary",onClick:()=>{v(!1),S(!0)},children:"Cancel"}),s.jsx(Se,{variant:"danger",onClick:()=>{qe.mutate({deleteArchives:M}),v(!1),S(!0)},children:"Delete"})]})]})})}),ne?.connected&&s.jsxs(s.Fragment,{children:[r==="compact"?s.jsx("div",{className:"mt-2",children:ne.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:`${ne.progress||0}%`}})}),s.jsxs("span",{className:"text-xs text-white",children:[Math.round(ne.progress||0),"%"]})]}):s.jsx("p",{className:"text-xs text-bambu-gray",children:rH(ne.state,ne.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:()=>J(!0),disabled:!(ne.state==="RUNNING"||ne.state==="PAUSE"||ne.state==="PAUSED")||(ne.printable_objects_count??0)<2,className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(ne.state==="RUNNING"||ne.state==="PAUSE"||ne.state==="PAUSED")&&(ne.printable_objects_count??0)>=2?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:ne.state==="RUNNING"||ne.state==="PAUSE"||ne.state==="PAUSED"?(ne.printable_objects_count??0)>=2?"Skip objects":"Skip objects (requires 2+ objects)":"Skip objects (only while printing)",children:[s.jsx(Y$,{className:"w-4 h-4"}),He&&He.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:He.skipped_count})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Uke,{url:ne.state==="RUNNING"?ne.cover_url:null,printName:ne.state==="RUNNING"&&(ne.subtask_name||ne.current_print)||void 0}),s.jsx("div",{className:"flex-1 min-w-0",children:ne.current_print&&ne.state==="RUNNING"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:ne.stg_cur_name||"Printing"}),s.jsx("p",{className:"text-white text-sm mb-2 truncate",children:ne.subtask_name||ne.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:`${ne.progress||0}%`}})}),s.jsxs("span",{className:"text-white",children:[Math.round(ne.progress||0),"%"]})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[ne.remaining_time!=null&&ne.remaining_time>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Gn,{className:"w-3 h-3"}),Oke(ne.remaining_time*60)]}),s.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",Lke(ne.remaining_time,c)]})]}),ne.layer_num!=null&&ne.total_layers!=null&&ne.total_layers>0&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(nl,{className:"w-3 h-3"}),ne.layer_num,"/",ne.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:rH(ne.state,ne.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:"—"})]}),he?s.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:he.print_name||he.filename,children:["Last: ",he.print_name||he.filename,he.completed_at&&s.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",Jp(he.completed_at,{month:"short",day:"numeric"})]})]}):s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})]}),ne.state!=="RUNNING"&&s.jsx(Afe,{printerId:t.id})]}),ne.temperatures&&r==="expanded"&&(()=>{const yt=ne.temperatures.nozzle_heating||ne.temperatures.nozzle_2_heating||!1,en=ne.temperatures.bed_heating||!1,wn=ne.temperatures.chamber_heating||!1,ue=t.nozzle_count===2||ne.temperatures.nozzle_2!==void 0,Be=ne.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(gC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-orange-400",isHeating:yt}),ne.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(ne.temperatures.nozzle||0),"° / ",Math.round(ne.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(ne.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(gC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-blue-400",isHeating:en}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Bed"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ne.temperatures.bed||0),"°C"]})]}),ne.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(gC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-green-400",isHeating:wn}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Chamber"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ne.temperatures.chamber||0),"°C"]})]}),ue&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg",title:`Active: ${Be==="L"?"Left":"Right"} nozzle`,children:[s.jsx("p",{className:`text-[11px] font-bold ${Be==="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 ${Be==="R"?"text-amber-400":"text-gray-500"}`,children:"R"})]})]})})(),r==="expanded"&&(()=>{const yt=ne.state==="RUNNING",en=ne.state==="PAUSED"||ne.state==="PAUSE",wn=yt||en,ue=$e.isPending||be.isPending||Fe.isPending,Be=ne.cooling_fan_speed,Ye=ne.big_fan1_speed,Xe=ne.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 ${Be&&Be>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:"Part Cooling Fan",children:[s.jsx(GW,{className:`w-3.5 h-3.5 ${Be&&Be>0?"text-cyan-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Be&&Be>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[Be??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Ye&&Ye>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:"Auxiliary Fan",children:[s.jsx(sq,{className:`w-3.5 h-3.5 ${Ye&&Ye>0?"text-blue-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Ye&&Ye>0?"text-blue-400":"text-bambu-gray/50"}`,children:[Ye??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Xe&&Xe>0?"bg-green-500/10":"bg-bambu-dark"}`,title:"Chamber Fan",children:[s.jsx(Hle,{className:`w-3.5 h-3.5 ${Xe&&Xe>0?"text-green-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Xe&&Xe>0?"text-green-400":"text-bambu-gray/50"}`,children:[Xe??0,"%"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>q(!0),disabled:!wn||ue,className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${wn?"bg-red-500/20 text-red-400 hover:bg-red-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
- `,title:"Stop print",children:[s.jsx(Ol,{className:"w-3 h-3"}),"Stop"]}),s.jsxs("button",{onClick:()=>en?B(!0):re(!0),disabled:!wn||ue,className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${wn?en?"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30":"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
- `,title:en?"Resume print":"Pause print",children:[en?s.jsx(rl,{className:"w-3 h-3"}):s.jsx(rD,{className:"w-3 h-3"}),en?"Resume":"Pause"]})]})]})]})})(),ie&&ie.length>0&&r==="expanded"&&(()=>{const yt=ie.filter(ue=>ue.tray.length>1),en=ie.filter(ue=>ue.tray.length===1),wn=t.nozzle_count===2||ne?.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:[yt.length>0&&s.jsx("div",{className:"grid grid-cols-2 gap-3",children:yt.map(ue=>{const Be=H[String(ue.id)],Ye=ue.id>=128?ue.id-128:ue.id,Xe=Be!==void 0?Be:Ye,Qe=Xe===1,At=Xe===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:Uu(ue.id,ue.tray.length)}),wn&&(Qe||At)&&s.jsx(Z$,{side:Qe?"L":"R"})]}),(ue.humidity!=null||ue.temp!=null)&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[ue.humidity!=null&&s.jsx(eH,{humidity:ue.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>ae({amsId:ue.id,amsLabel:Uu(ue.id,ue.tray.length),mode:"humidity"}),compact:!0}),ue.temp!=null&&s.jsx(tH,{temp:ue.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>ae({amsId:ue.id,amsLabel:Uu(ue.id,ue.tray.length),mode:"temperature"}),compact:!0})]})]}),s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(ce=>{const we=ue.tray[ce]||ue.tray.find(st=>st.id===ce),Ie=we?.tray_type&&we.remain>=0,Le=!we?.tray_type,Re=ue.id*4+ce,ut=le===Re,_t=we?.tray_info_idx?z?.[we.tray_info_idx]:null,Tt=W?.[Re],St=we?.tray_type?{vendor:xC(we)?"Bambu Lab":"Generic",profile:_t?.name||Tt?.preset_name||we.tray_sub_brands||we.tray_type,colorName:fC(we.tray_id_name)||mC(we.tray_color),colorHex:we.tray_color||null,kFactor:pC(we.k),fillLevel:Ie?we.remain:null,trayUuid:we.tray_uuid||null}:null,vt=jt?.amsId===ue.id&&jt?.slotId===ce,xe=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Le?"opacity-50":""} ${ut?"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:we?.tray_color?`#${we.tray_color}`:we?.tray_type?"#333":"transparent",borderColor:Le?"#666":"rgba(255,255,255,0.1)",borderStyle:Le?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:we?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Ie&&we?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${we.remain}%`,backgroundColor:nH(we.remain)}}):we?.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:[vt&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(yr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),ne?.state!=="RUNNING"&&s.jsx("button",{onClick:st=>{st.stopPropagation(),_r(wt?.amsId===ue.id&&wt?.slotId===ce?null:{amsId:ue.id,slotId:ce})},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(wd,{className:"w-2.5 h-2.5 text-bambu-gray"})}),ne?.state!=="RUNNING"&&wt?.amsId===ue.id&&wt?.slotId===ce&&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:st=>{st.stopPropagation(),$t.mutate({amsId:ue.id,slotId:ce}),_r(null)},disabled:vt,children:[s.jsx(yr,{className:`w-3 h-3 ${vt?"animate-spin":""}`}),"Re-read RFID"]})}),St?s.jsx(dC,{data:St,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&St.trayUuid?st=>{fe({trayUuid:st,trayInfo:{type:St.profile,color:St.colorHex||"",location:`${Uu(ue.id,ue.tray.length)} Slot ${ce+1}`}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:ue.id,trayId:ce,trayCount:ue.tray.length,trayType:we?.tray_type||void 0,trayColor:we?.tray_color||void 0,traySubBrands:we?.tray_sub_brands||void 0,trayInfoIdx:we?.tray_info_idx||void 0})},children:xe}):s.jsx(q$,{configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:ue.id,trayId:ce,trayCount:ue.tray.length})},children:xe})]},ce)})})]},ue.id)})}),(en.length>0||ne.vt_tray&&ne.vt_tray.tray_type)&&s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[en.map(ue=>{const Be=H[String(ue.id)],Ye=ue.id>=128?ue.id-128:ue.id,Xe=Be!==void 0?Be:Ye,Qe=Xe===1,At=Xe===0,ce=ue.tray[0],we=ce?.tray_type&&ce.remain>=0,Ie=!ce?.tray_type,Le=ue.id*4+(ce?.id??0),Re=le===Le,ut=ce?.tray_info_idx?z?.[ce.tray_info_idx]:null,_t=W?.[Le],Tt=ce?.tray_type?{vendor:xC(ce)?"Bambu Lab":"Generic",profile:ut?.name||_t?.preset_name||ce.tray_sub_brands||ce.tray_type,colorName:fC(ce.tray_id_name)||mC(ce.tray_color),colorHex:ce.tray_color||null,kFactor:pC(ce.k),fillLevel:we?ce.remain:null,trayUuid:ce.tray_uuid||null}:null,St=ce?.id??0,vt=jt?.amsId===ue.id&&jt?.slotId===St,xe=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Ie?"opacity-50":""} ${Re?"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:ce?.tray_color?`#${ce.tray_color}`:ce?.tray_type?"#333":"transparent",borderColor:Ie?"#666":"rgba(255,255,255,0.1)",borderStyle:Ie?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:ce?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:we?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${ce.remain}%`,backgroundColor:nH(ce.remain)}}):ce?.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:Uu(ue.id,ue.tray.length)}),wn&&(Qe||At)&&s.jsx(Z$,{side:Qe?"L":"R"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsxs("div",{className:"relative group flex-1",children:[vt&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(yr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),ne?.state!=="RUNNING"&&s.jsx("button",{onClick:st=>{st.stopPropagation(),_r(wt?.amsId===ue.id&&wt?.slotId===St?null:{amsId:ue.id,slotId:St})},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(wd,{className:"w-2.5 h-2.5 text-bambu-gray"})}),ne?.state!=="RUNNING"&&wt?.amsId===ue.id&&wt?.slotId===St&&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:st=>{st.stopPropagation(),$t.mutate({amsId:ue.id,slotId:St}),_r(null)},disabled:vt,children:[s.jsx(yr,{className:`w-3 h-3 ${vt?"animate-spin":""}`}),"Re-read RFID"]})}),Tt?s.jsx(dC,{data:Tt,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Tt.trayUuid?st=>{fe({trayUuid:st,trayInfo:{type:Tt.profile,color:Tt.colorHex||"",location:Uu(ue.id,ue.tray.length)}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:ue.id,trayId:St,trayCount:ue.tray.length,trayType:ce?.tray_type||void 0,trayColor:ce?.tray_color||void 0,traySubBrands:ce?.tray_sub_brands||void 0,trayInfoIdx:ce?.tray_info_idx||void 0})},children:xe}):s.jsx(q$,{configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:ue.id,trayId:St,trayCount:ue.tray.length})},children:xe})]}),(ue.humidity!=null||ue.temp!=null)&&s.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[ue.temp!=null&&s.jsx(tH,{temp:ue.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>ae({amsId:ue.id,amsLabel:Uu(ue.id,ue.tray.length),mode:"temperature"}),compact:!0}),ue.humidity!=null&&s.jsx(eH,{humidity:ue.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>ae({amsId:ue.id,amsLabel:Uu(ue.id,ue.tray.length),mode:"humidity"}),compact:!0})]})]})]},ue.id)}),ne.vt_tray&&ne.vt_tray.tray_type&&(()=>{const ue=ne.vt_tray,Be=le===254,Ye=ue.tray_info_idx?z?.[ue.tray_info_idx]:null,Xe=W?.[1020],Qe={vendor:xC(ue)?"Bambu Lab":"Generic",profile:Ye?.name||Xe?.preset_name||ue.tray_sub_brands||ue.tray_type||"Unknown",colorName:fC(ue.tray_id_name)||mC(ue.tray_color),colorHex:ue.tray_color||null,kFactor:pC(ue.k),fillLevel:null,trayUuid:ue.tray_uuid||null},At=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${Be?"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:ue.tray_color?`#${ue.tray_color}`:"#333",borderColor:Be?"var(--accent)":"rgba(255,255,255,0.1)"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:ue.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(dC,{data:Qe,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Qe.trayUuid?ce=>{fe({trayUuid:ce,trayInfo:{type:Qe.profile,color:Qe.colorHex||"",location:"External Spool"}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:255,trayId:0,trayCount:1,trayType:ue.tray_type||void 0,trayColor:ue.tray_color||void 0,traySubBrands:ue.tray_sub_brands||void 0,trayInfoIdx:ue.tray_info_idx||void 0})},children:At})]})})()]})]})]})})()]}),ke&&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(Mf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"text-sm text-white truncate",children:ke.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:ot.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(uu,{className:"w-3 h-3"}),"On"]}),s.jsxs("button",{onClick:()=>X(!0),disabled:ot.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(I2,{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 ${ke.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:ke.auto_off_executed?"Auto-off done":"Auto-off"}),s.jsx("button",{onClick:()=>se.mutate(!ke.auto_off),disabled:se.isPending||ke.auto_off_executed,title:ke.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 ${ke.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":ke.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 ${ke.auto_off||ke.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(Se,{variant:"secondary",size:"sm",onClick:()=>De.mutate(!ne?.chamber_light),disabled:!ne?.connected||De.isPending,title:ne?.chamber_light?"Turn off chamber light":"Turn on chamber light",className:ne?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:s.jsx(Tke,{on:ne?.chamber_light??!1,className:"w-4 h-4"})}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:()=>{if(u==="embedded"&&d)d(t.id,t.name);else{const yt=localStorage.getItem("cameraWindowState"),en=yt?JSON.parse(yt):{width:640,height:400},wn=[`width=${en.width}`,`height=${en.height}`,en.left!==void 0?`left=${en.left}`:"",en.top!==void 0?`top=${en.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,wn)}},disabled:!ne?.connected,title:u==="embedded"?"Open camera overlay":"Open camera in new window",children:s.jsx(sD,{className:"w-4 h-4"})}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>C(!0),title:"Browse printer files",children:[s.jsx(P2,{className:"w-4 h-4"}),"Files"]})]})]})]}),k&&s.jsx(pfe,{printerId:t.id,printerName:t.name,onClose:()=>C(!1)}),R&&s.jsx(_fe,{printerId:t.id,printerName:t.name,onClose:()=>T(!1)}),P&&ke&&s.jsx(Ln,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{ot.mutate("on"),F(!1)},onCancel:()=>F(!1)}),L&&ke&&s.jsx(Ln,{title:"Power Off Printer",message:ne?.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:()=>{ot.mutate("off"),X(!1)},onCancel:()=>X(!1)}),Y&&s.jsx(Ln,{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:()=>{$e.mutate(),q(!1)},onCancel:()=>q(!1)}),Z&&s.jsx(Ln,{title:"Pause Print",message:`Are you sure you want to pause the current print on "${t.name}"?`,confirmText:"Pause Print",variant:"default",onConfirm:()=>{be.mutate(),re(!1)},onCancel:()=>re(!1)}),oe&&s.jsx(Ln,{title:"Resume Print",message:`Are you sure you want to resume the print on "${t.name}"?`,confirmText:"Resume Print",variant:"default",onConfirm:()=>{Fe.mutate(),B(!1)},onCancel:()=>B(!1)}),G&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>J(!1),onKeyDown:yt=>yt.key==="Escape"&&J(!1),tabIndex:-1,ref:yt=>yt?.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:yt=>yt.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(Y$,{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:()=>J(!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(Ut,{className:"w-4 h-4"})})]}),He?He.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(Sde,{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:[He.skipped_count,"/",He.total," skipped"]})]}),(ne?.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(ea,{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 ",ne?.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:[ne?.cover_url?s.jsx("img",{src:`${ne.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(Os,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),He.objects.length>0&&s.jsx("div",{className:"absolute inset-0 pointer-events-none",children:He.objects.map((yt,en)=>{let wn,ue;if(yt.x!=null&&yt.y!=null&&He.bbox_all){const[Be,Ye,Xe,Qe]=He.bbox_all,At=Xe-Be,ce=Qe-Ye,we=8,Ie=100-we*2;wn=we+(yt.x-Be)/At*Ie,ue=we+(Qe-yt.y)/ce*Ie,wn=Math.max(5,Math.min(95,wn)),ue=Math.max(5,Math.min(95,ue))}else if(yt.x!=null&&yt.y!=null)wn=yt.x/256*100,ue=100-yt.y/256*100,wn=Math.max(5,Math.min(95,wn)),ue=Math.max(5,Math.min(95,ue));else{const Be=Math.ceil(Math.sqrt(He.objects.length)),Ye=Math.floor(en/Be),Xe=en%Be,Qe=Math.ceil(He.objects.length/Be);wn=15+Xe*(70/Be)+35/Be,ue=15+Ye*(70/Qe)+35/Qe}return s.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${yt.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${wn}%`,top:`${ue}%`,transform:"translate(-50%, -50%)"},title:yt.name,children:yt.id},yt.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:[He.objects.filter(yt=>!yt.skipped).length," active"]})]})}),s.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:He.objects.map(yt=>s.jsxs("div",{className:`
- flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0
- ${yt.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
- `,children:[s.jsxs("div",{className:`
- w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
- ${yt.skipped?"bg-red-100 dark:bg-red-500/20 border border-red-300 dark:border-red-500/40":"bg-green-100 dark:bg-bambu-green/20 border border-green-300 dark:border-bambu-green/40"}
- `,children:[s.jsx("span",{className:`text-lg font-mono font-bold ${yt.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:yt.id}),s.jsx("span",{className:`text-[8px] uppercase tracking-wider ${yt.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 ${yt.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:yt.name}),yt.skipped&&s.jsx("span",{className:"text-[10px] text-red-400/60",children:"Will be skipped"})]}),yt.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:()=>kt.mutate([yt.id]),disabled:kt.isPending||(ne?.layer_num??0)<=1,className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(ne?.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:(ne?.layer_num??0)<=1?"Wait for layer 2+":"Skip this object",children:"Skip"})]},yt.id))})]})]}):s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(mt,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),D&&s.jsx(Nfe,{printerName:t.name,errors:ne?.hms_errors||[],onClose:()=>K(!1)}),te&&s.jsx(yke,{isOpen:!!te,onClose:()=>ae(null),printerId:t.id,printerName:t.name,amsId:te.amsId,amsLabel:te.amsLabel,initialMode:te.mode,thresholds:a}),de&&s.jsx(vke,{isOpen:!!de,onClose:()=>fe(null),trayUuid:de.trayUuid,trayInfo:de.trayInfo}),Ae&&s.jsx(Ake,{isOpen:!!Ae,onClose:()=>ge(null),printerId:t.id,slotInfo:Ae,onSuccess:()=>{f.invalidateQueries({queryKey:["slotPresets",t.id]}),f.invalidateQueries({queryKey:["printerStatus",t.id]})}}),A&&s.jsx(Hke,{printer:t,onClose:()=>E(!1)}),Me&&Ke&&s.jsx($ke,{printer:t,firmwareInfo:Ke,onClose:()=>je(!1)}),wt&&s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>_r(null)})]})}function Bke({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),[g,x]=w.useState(!1),[y,b]=w.useState("192.168.1.0/24"),[v,M]=w.useState({scanned:0,total:0});w.useEffect(()=>{pl.getInfo().then(C=>{x(C.is_docker)}).catch(()=>{})},[]);const S=l.filter(C=>!n.includes(C.serial)),A=async()=>{d(""),c([]),o(!0),m(!1),M({scanned:0,total:0});try{if(g){await pl.startSubnetScan(y);const C=setInterval(async()=>{try{const R=await pl.getScanStatus();M({scanned:R.scanned,total:R.total});const T=await pl.getDiscoveredPrinters();c(T),R.running||(clearInterval(C),o(!1),m(!0))}catch(R){console.error("Failed to get scan status:",R)}},500)}else{await pl.startDiscovery(10);const C=setInterval(async()=>{try{const R=await pl.getDiscoveredPrinters();c(R)}catch(R){console.error("Failed to get discovered printers:",R)}},1e3);setTimeout(async()=>{clearInterval(C);try{await pl.stopDiscovery()}catch{}o(!1),m(!0);try{const R=await pl.getDiscoveredPrinters();c(R)}catch(R){console.error("Failed to get final discovered printers:",R)}},1e4)}}catch(C){console.error("Failed to start discovery:",C),d(C instanceof Error?C.message:"Failed to start discovery"),o(!1),m(!0)}},E=C=>C?{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"}[C]||C:"",k=C=>{const R=C.serial.startsWith("unknown-")?"":C.serial;i({...r,name:C.name||"",serial_number:R,ip_address:C.ip_address,model:E(C.model)}),c([])};return w.useEffect(()=>()=>{pl.stopDiscovery().catch(()=>{}),pl.stopSubnetScan().catch(()=>{})},[]),w.useEffect(()=>{const C=R=>{R.key==="Escape"&&t()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:s.jsx(Mt,{className:"w-full max-w-md",onClick:C=>C.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:[g&&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:C=>b(C.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(Se,{type:"button",variant:"secondary",onClick:A,disabled:a,className:"w-full",children:a?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),g&&v.total>0?`Scanning... ${v.scanned}/${v.total}`:"Scanning..."]}):s.jsxs(s.Fragment,{children:[s.jsx(xa,{className:"w-4 h-4"}),g?"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(C=>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:()=>k(C),children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-medium text-white text-sm truncate",children:C.name||C.serial}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[E(C.model)||"Unknown"," • ",C.ip_address,C.serial.startsWith("unknown-")&&s.jsx("span",{className:"text-yellow-500",children:" • Serial required"})]})]}),s.jsx(Ji,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},C.serial))}),a&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:g?"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",g?" 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:C=>{C.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:C=>i({...r,name:C.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:C=>i({...r,ip_address:C.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:C=>i({...r,serial_number:C.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:C=>i({...r,access_code:C.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:C=>i({...r,model:C.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:C=>i({...r,auto_archive:C.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(Se,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsx(Se,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function $ke({printer:t,firmwareInfo:e,onClose:n}){const r=tn(),{showToast:i}=$n(),[a,o]=w.useState(null),[l,c]=w.useState(!1),[u,d]=w.useState(null),{data:f,isLoading:m}=ct({queryKey:["firmwarePrepare",t.id],queryFn:()=>D1.prepareUpload(t.id),staleTime:3e4}),g=ft({mutationFn:()=>D1.startUpload(t.id),onSuccess:()=>{c(!0);const y=setInterval(async()=>{try{const b=await D1.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),g.mutate()};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(Mt,{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(Jr,{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(mt,{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(Os,{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(ea,{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-red-500":a.status==="complete"?"bg-bambu-green":"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(Se,{variant:"secondary",onClick:n,children:a?.status==="complete"?"Done":"Cancel"}),f?.can_proceed&&!l&&a?.status!=="complete"&&s.jsx(Se,{onClick:x,disabled:g.isPending,children:g.isPending?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin mr-2"}),"Starting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Jr,{className:"w-4 h-4 mr-2"}),"Upload Firmware"]})})]})]})})})}function Hke({printer:t,onClose:e}){const n=tn(),[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=ft({mutationFn:l=>pe.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(Mt,{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(Se,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsx(Se,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function Vke(t){const{data:e}=ct({queryKey:["printerStatus",t],queryFn:()=>pe.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function Gke({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=Vke(t.id),{data:a}=ct({queryKey:["smartPlugStatus",e.id],queryFn:()=>pe.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(uu,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function Wke(){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,g]=w.useState(()=>{const G=localStorage.getItem("printerCardSize");return G?parseInt(G,10):2}),x=m===1?"compact":"expanded",y=tn(),[b,v]=w.useState(()=>{const G=localStorage.getItem("openEmbeddedCameras");if(G)try{const J=JSON.parse(G);return new Map(J.map(te=>[te.id,te]))}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:M,isLoading:S}=ct({queryKey:["printers"],queryFn:pe.getPrinters}),{data:A}=ct({queryKey:["settings"],queryFn:pe.getSettings});w.useEffect(()=>{A?.camera_view_mode==="window"&&b.size>0&&v(new Map)},[A?.camera_view_mode,b.size]);const{data:E}=ct({queryKey:["smart-plugs"],queryFn:pe.getSmartPlugs}),{data:k}=ct({queryKey:["maintenanceOverview"],queryFn:pe.getMaintenanceOverview,staleTime:60*1e3}),{data:C}=ct({queryKey:["spoolman-status"],queryFn:pe.getSpoolmanStatus,staleTime:60*1e3}),R=C?.enabled&&C?.connected,{data:T}=ct({queryKey:["unlinked-spools"],queryFn:pe.getUnlinkedSpools,enabled:!!R,staleTime:30*1e3}),P=T&&T.length>0,F=k?.reduce((G,J)=>(G[J.printer_id]={due_count:J.due_count,warning_count:J.warning_count,total_print_hours:J.total_print_hours},G),{})||{},L=E?.reduce((G,J)=>(J.printer_id&&(G[J.printer_id]=J),G),{})||{},X=ft({mutationFn:pe.createPrinter,onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),y.invalidateQueries({queryKey:["maintenanceOverview"]}),e(!1)}}),D=ft({mutationFn:G=>pe.controlSmartPlug(G,"on"),onSuccess:()=>{y.invalidateQueries({queryKey:["smart-plugs"]}),l(null)},onError:()=>{l(null)}}),K=()=>{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))},Z=()=>{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"}},re=["S","M","L","XL"],oe=w.useMemo(()=>{if(!M)return[];const G=[...M];switch(c){case"name":G.sort((J,te)=>J.name.localeCompare(te.name));break;case"model":G.sort((J,te)=>(J.model||"").localeCompare(te.model||""));break;case"location":G.sort((J,te)=>{const ae=J.location||"",de=te.location||"";return!ae&&de?1:ae&&!de?-1:ae.localeCompare(de)||J.name.localeCompare(te.name)});break;case"status":G.sort((J,te)=>{const ae=y.getQueryData(["printerStatus",J.id]),de=y.getQueryData(["printerStatus",te.id]),fe=Ae=>Ae?.connected?Ae.state==="RUNNING"?0:1:2;return fe(ae)-fe(de)});break}return d||G.reverse(),G},[M,c,d,y]),B=w.useMemo(()=>{if(c!=="location")return null;const G={};return oe.forEach(J=>{const te=J.location||"Ungrouped";G[te]||(G[te]=[]),G[te].push(J)}),G},[c,oe]);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(zke,{printers:M})]}),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(Kp,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(i0,{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:re.map((G,J)=>{const te=J+1,ae=m===te;return s.jsx("button",{onClick:()=>{g(te),localStorage.setItem("printerCardSize",String(te))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${J===0?"rounded-l-lg":""} ${J===re.length-1?"rounded-r-lg":""} ${ae?"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:K,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(uu,{className:"w-4 h-4"}),"Power On",s.jsx(Ji,{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"}),M?.filter(G=>L[G.id]).map(G=>s.jsx(Gke,{printer:G,plug:L[G.id],onPowerOn:J=>{l(J),D.mutate(J)},isPowering:o===L[G.id]?.id},G.id)),M?.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(Se,{onClick:()=>e(!0),children:[s.jsx(Kn,{className:"w-4 h-4"}),"Add Printer"]})]})]}),S?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):M?.length===0?s.jsx(Mt,{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(Se,{onClick:()=>e(!0),children:[s.jsx(Kn,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):B?s.jsx("div",{className:"space-y-6",children:Object.entries(B).map(([G,J])=>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:["(",J.length,")"]})]}),s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${Z()}`,children:J.map(te=>s.jsx(iH,{printer:te,hideIfDisconnected:n,maintenanceInfo:F[te.id],viewMode:x,cardSize:m,amsThresholds:A?{humidityGood:Number(A.ams_humidity_good)||40,humidityFair:Number(A.ams_humidity_fair)||60,tempGood:Number(A.ams_temp_good)||28,tempFair:Number(A.ams_temp_fair)||35}:void 0,spoolmanEnabled:R,hasUnlinkedSpools:P,timeFormat:A?.time_format||"system",cameraViewMode:A?.camera_view_mode||"window",onOpenEmbeddedCamera:(ae,de)=>v(fe=>new Map(fe).set(ae,{id:ae,name:de}))},te.id))})]},G))}):s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${Z()}`,children:oe.map(G=>s.jsx(iH,{printer:G,hideIfDisconnected:n,maintenanceInfo:F[G.id],viewMode:x,cardSize:m,spoolmanEnabled:R,hasUnlinkedSpools:P,amsThresholds:A?{humidityGood:Number(A.ams_humidity_good)||40,humidityFair:Number(A.ams_humidity_fair)||60,tempGood:Number(A.ams_temp_good)||28,tempFair:Number(A.ams_temp_fair)||35}:void 0,timeFormat:A?.time_format||"system",cameraViewMode:A?.camera_view_mode||"window",onOpenEmbeddedCamera:(J,te)=>v(ae=>new Map(ae).set(J,{id:J,name:te}))},G.id))}),t&&s.jsx(Bke,{onClose:()=>e(!1),onAdd:G=>X.mutate(G),existingSerials:M?.map(G=>G.serial_number)||[]}),Array.from(b.values()).map((G,J)=>s.jsx(vfe,{printerId:G.id,printerName:G.name,viewerIndex:J,onClose:()=>v(te=>{const ae=new Map(te);return ae.delete(G.id),ae})},G.id))]})}function qke(){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 Kke(){switch(qke()){case"windows":return"bambustudio://";case"macos":case"linux":default:return"bambustudioopen://"}}function Oc(t){const e=Kke();window.location.href=`${e}${encodeURIComponent(t)}`}const dO="181",Up={ROTATE:0,DOLLY:1,PAN:2},kp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Xke=0,aH=1,Yke=2,EZ=1,Qke=2,Tc=3,Bd=0,fs=1,Ml=2,qc=0,zp=1,sH=2,oH=3,lH=4,Zke=5,Ih=100,Jke=101,eje=102,tje=103,nje=104,rje=200,ije=201,aje=202,sje=203,X3=204,Y3=205,oje=206,lje=207,cje=208,uje=209,dje=210,hje=211,fje=212,mje=213,pje=214,Q3=0,Z3=1,J3=2,cg=3,eP=4,tP=5,nP=6,rP=7,hO=0,gje=1,xje=2,Ed=0,bje=1,yje=2,vje=3,_je=4,wje=5,Sje=6,Mje=7,AZ=300,ug=301,dg=302,iP=303,aP=304,DM=306,sP=1e3,zc=1001,oP=1002,Bs=1003,Nje=1004,m_=1005,_o=1006,bC=1007,Yh=1008,zl=1009,TZ=1010,CZ=1011,S0=1012,fO=1013,Pf=1014,Bc=1015,Vg=1016,mO=1017,pO=1018,M0=1020,kZ=35902,jZ=35899,PZ=1021,RZ=1022,Ko=1023,N0=1026,E0=1027,DZ=1028,gO=1029,xO=1030,bO=1031,yO=1033,$1=33776,H1=33777,V1=33778,G1=33779,lP=35840,cP=35841,uP=35842,dP=35843,hP=36196,fP=37492,mP=37496,pP=37808,gP=37809,xP=37810,bP=37811,yP=37812,vP=37813,_P=37814,wP=37815,SP=37816,MP=37817,NP=37818,EP=37819,AP=37820,TP=37821,CP=36492,kP=36494,jP=36495,PP=36283,RP=36284,DP=36285,OP=36286,Eje=3200,Aje=3201,OZ=0,Tje=1,dd="",ho="srgb",hg="srgb-linear",mS="linear",sr="srgb",Dm=7680,cH=519,Cje=512,kje=513,jje=514,LZ=515,Pje=516,Rje=517,Dje=518,Oje=519,uH=35044,dH="300 es",Tl=2e3,pS=2001;function IZ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function gS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Lje(){const t=gS("canvas");return t.style.display="block",t}const hH={};function fH(...t){const e="THREE."+t.shift();console.log(e,...t)}function ln(...t){const e="THREE."+t.shift();console.warn(e,...t)}function ai(...t){const e="THREE."+t.shift();console.error(e,...t)}function A0(...t){const e=t.join(" ");e in hH||(hH[e]=!0,ln(...t))}function Ije(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 Kf=class{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,o=i.length;a<o;a++)i[a].call(this,e);e.target=null}}};const _a=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],W1=Math.PI/180,LP=180/Math.PI;function Ny(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(_a[t&255]+_a[t>>8&255]+_a[t>>16&255]+_a[t>>24&255]+"-"+_a[e&255]+_a[e>>8&255]+"-"+_a[e>>16&15|64]+_a[e>>24&255]+"-"+_a[n&63|128]+_a[n>>8&255]+"-"+_a[n>>16&255]+_a[n>>24&255]+_a[r&255]+_a[r>>8&255]+_a[r>>16&255]+_a[r>>24&255]).toLowerCase()}function An(t,e,n){return Math.max(e,Math.min(n,t))}function Fje(t,e){return(t%e+e)%e}function yC(t,e,n){return(1-n)*t+n*e}function Zx(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 is(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 Uje={DEG2RAD:W1};let vn=class FZ{constructor(e=0,n=0){FZ.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=An(this.x,e.x,n.x),this.y=An(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=An(this.x,e,n),this.y=An(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(An(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(An(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}},Rf=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],g=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]=g,e[n+2]=x,e[n+3]=y;return}if(f!==y||c!==m||u!==g||d!==x){let b=c*m+u*g+d*x+f*y;b<0&&(m=-m,g=-g,x=-x,y=-y,b=-b);let v=1-l;if(b<.9995){const M=Math.acos(b),S=Math.sin(M);v=Math.sin(v*M)/S,l=Math.sin(l*M)/S,c=c*v+m*l,u=u*v+g*l,d=d*v+x*l,f=f*v+y*l}else{c=c*v+m*l,u=u*v+g*l,d=d*v+x*l,f=f*v+y*l;const M=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=M,u*=M,d*=M,f*=M}}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],g=a[o+2],x=a[o+3];return e[n]=l*x+d*f+c*g-u*m,e[n+1]=c*x+d*m+u*f-l*g,e[n+2]=u*x+d*g+l*m-c*f,e[n+3]=d*x-l*f-c*m-u*g,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),g=c(i/2),x=c(a/2);switch(o){case"XYZ":this._x=m*d*f+u*g*x,this._y=u*g*f-m*d*x,this._z=u*d*x+m*g*f,this._w=u*d*f-m*g*x;break;case"YXZ":this._x=m*d*f+u*g*x,this._y=u*g*f-m*d*x,this._z=u*d*x-m*g*f,this._w=u*d*f+m*g*x;break;case"ZXY":this._x=m*d*f-u*g*x,this._y=u*g*f+m*d*x,this._z=u*d*x+m*g*f,this._w=u*d*f-m*g*x;break;case"ZYX":this._x=m*d*f-u*g*x,this._y=u*g*f+m*d*x,this._z=u*d*x-m*g*f,this._w=u*d*f+m*g*x;break;case"YZX":this._x=m*d*f+u*g*x,this._y=u*g*f+m*d*x,this._z=u*d*x-m*g*f,this._w=u*d*f-m*g*x;break;case"XZY":this._x=m*d*f-u*g*x,this._y=u*g*f-m*d*x,this._z=u*d*x+m*g*f,this._w=u*d*f+m*g*x;break;default:ln("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 g=.5/Math.sqrt(m+1);this._w=.25/g,this._x=(d-c)*g,this._y=(a-u)*g,this._z=(o-i)*g}else if(r>l&&r>f){const g=2*Math.sqrt(1+r-l-f);this._w=(d-c)/g,this._x=.25*g,this._y=(i+o)/g,this._z=(a+u)/g}else if(l>f){const g=2*Math.sqrt(1+l-r-f);this._w=(a-u)/g,this._x=(i+o)/g,this._y=.25*g,this._z=(c+d)/g}else{const g=2*Math.sqrt(1+f-r-l);this._w=(o-i)/g,this._x=(a+u)/g,this._y=(c+d)/g,this._z=.25*g}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(An(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}},at=class UZ{constructor(e=0,n=0,r=0){UZ.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(mH.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(mH.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=An(this.x,e.x,n.x),this.y=An(this.y,e.y,n.y),this.z=An(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=An(this.x,e,n),this.y=An(this.y,e,n),this.z=An(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(An(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 vC.copy(this).projectOnVector(e),this.sub(vC)}reflect(e){return this.sub(vC.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(An(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 vC=new at,mH=new Rf;let Sn=class zZ{constructor(e,n,r,i,a,o,l,c,u){zZ.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],g=r[5],x=r[8],y=i[0],b=i[3],v=i[6],M=i[1],S=i[4],A=i[7],E=i[2],k=i[5],C=i[8];return a[0]=o*y+l*M+c*E,a[3]=o*b+l*S+c*k,a[6]=o*v+l*A+c*C,a[1]=u*y+d*M+f*E,a[4]=u*b+d*S+f*k,a[7]=u*v+d*A+f*C,a[2]=m*y+g*M+x*E,a[5]=m*b+g*S+x*k,a[8]=m*v+g*A+x*C,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],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,g=u*a-o*c,x=n*f+r*m+i*g;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]=g*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(_C.makeScale(e,n)),this}rotate(e){return this.premultiply(_C.makeRotation(-e)),this}translate(e,n){return this.premultiply(_C.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 _C=new Sn,pH=new Sn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),gH=new Sn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function zje(){const t={enabled:!0,workingColorSpace:hg,spaces:{},convert:function(i,a,o){return this.enabled===!1||a===o||!a||!o||(this.spaces[a].transfer===sr&&(i.r=Kc(i.r),i.g=Kc(i.g),i.b=Kc(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===sr&&(i.r=Bp(i.r),i.g=Bp(i.g),i.b=Bp(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===dd?mS: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 A0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return A0("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({[hg]:{primaries:e,whitePoint:r,transfer:mS,toXYZ:pH,fromXYZ:gH,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:ho},outputColorSpaceConfig:{drawingBufferColorSpace:ho}},[ho]:{primaries:e,whitePoint:r,transfer:sr,toXYZ:pH,fromXYZ:gH,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:ho}}}),t}const zn=zje();function Kc(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Bp(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Om,Bje=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{Om===void 0&&(Om=gS("canvas")),Om.width=e.width,Om.height=e.height;const i=Om.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=Om}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=gS("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]=Kc(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(Kc(n[r]/255)*255):n[r]=Kc(n[r]);return{data:n,width:e.width,height:e.height}}else return ln("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},$je=0,vO=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:$je++}),this.uuid=Ny(),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(wC(i[o].image)):a.push(wC(i[o]))}else a=wC(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function wC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Bje.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(ln("Texture: Unable to serialize Texture."),{})}let Hje=0;const SC=new at;let cl=class q1 extends Kf{constructor(e=q1.DEFAULT_IMAGE,n=q1.DEFAULT_MAPPING,r=zc,i=zc,a=_o,o=Yh,l=Ko,c=zl,u=q1.DEFAULT_ANISOTROPY,d=dd){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Hje++}),this.uuid=Ny(),this.name="",this.source=new vO(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 vn(0,0),this.repeat=new vn(1,1),this.center=new vn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Sn,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(SC).x}get height(){return this.source.getSize(SC).y}get depth(){return this.source.getSize(SC).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){ln(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){ln(`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!==AZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case sP:e.x=e.x-Math.floor(e.x);break;case zc:e.x=e.x<0?0:1;break;case oP: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 sP:e.y=e.y-Math.floor(e.y);break;case zc:e.y=e.y<0?0:1;break;case oP: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++}};cl.DEFAULT_IMAGE=null;cl.DEFAULT_MAPPING=AZ;cl.DEFAULT_ANISOTROPY=1;let pi=class BZ{constructor(e=0,n=0,r=0,i=1){BZ.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],g=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+g+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const S=(u+1)/2,A=(g+1)/2,E=(v+1)/2,k=(d+m)/4,C=(f+y)/4,R=(x+b)/4;return S>A&&S>E?S<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(S),i=k/r,a=C/r):A>E?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=k/i,a=R/i):E<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(E),r=C/a,i=R/a),this.set(r,i,a,n),this}let M=Math.sqrt((b-x)*(b-x)+(f-y)*(f-y)+(m-d)*(m-d));return Math.abs(M)<.001&&(M=1),this.x=(b-x)/M,this.y=(f-y)/M,this.z=(m-d)/M,this.w=Math.acos((u+g+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=An(this.x,e.x,n.x),this.y=An(this.y,e.y,n.y),this.z=An(this.z,e.z,n.z),this.w=An(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=An(this.x,e,n),this.y=An(this.y,e,n),this.z=An(this.z,e,n),this.w=An(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(An(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}},Vje=class extends Kf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:_o,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 pi(0,0,e,n),this.scissorTest=!1,this.viewport=new pi(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new cl(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:_o,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 vO(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"})}},Df=class extends Vje{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},$Z=class extends cl{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=Bs,this.minFilter=Bs,this.wrapR=zc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Gje=class extends cl{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=Bs,this.minFilter=Bs,this.wrapR=zc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Of=class{constructor(e=new at(1/0,1/0,1/0),n=new at(-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(Lo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Lo.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=Lo.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,Lo):Lo.fromBufferAttribute(a,o),Lo.applyMatrix4(e.matrixWorld),this.expandByPoint(Lo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),p_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),p_.copy(r.boundingBox)),p_.applyMatrix4(e.matrixWorld),this.union(p_)}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,Lo),Lo.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(Jx),g_.subVectors(this.max,Jx),Lm.subVectors(e.a,Jx),Im.subVectors(e.b,Jx),Fm.subVectors(e.c,Jx),zu.subVectors(Im,Lm),Bu.subVectors(Fm,Im),vh.subVectors(Lm,Fm);let n=[0,-zu.z,zu.y,0,-Bu.z,Bu.y,0,-vh.z,vh.y,zu.z,0,-zu.x,Bu.z,0,-Bu.x,vh.z,0,-vh.x,-zu.y,zu.x,0,-Bu.y,Bu.x,0,-vh.y,vh.x,0];return!MC(n,Lm,Im,Fm,g_)||(n=[1,0,0,0,1,0,0,0,1],!MC(n,Lm,Im,Fm,g_))?!1:(x_.crossVectors(zu,Bu),n=[x_.x,x_.y,x_.z],MC(n,Lm,Im,Fm,g_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Lo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Lo).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)}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 mc=[new at,new at,new at,new at,new at,new at,new at,new at],Lo=new at,p_=new Of,Lm=new at,Im=new at,Fm=new at,zu=new at,Bu=new at,vh=new at,Jx=new at,g_=new at,x_=new at,_h=new at;function MC(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){_h.fromArray(t,a);const l=i.x*Math.abs(_h.x)+i.y*Math.abs(_h.y)+i.z*Math.abs(_h.z),c=e.dot(_h),u=n.dot(_h),d=r.dot(_h);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const Wje=new Of,eb=new at,NC=new at;let OM=class{constructor(e=new at,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):Wje.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;eb.subVectors(e,this.center);const n=eb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(eb,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):(NC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(eb.copy(e.center).add(NC)),this.expandByPoint(eb.copy(e.center).sub(NC))),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 pc=new at,EC=new at,b_=new at,$u=new at,AC=new at,y_=new at,TC=new at;let _O=class{constructor(e=new at,n=new at(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,pc)),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=pc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(pc.copy(this.origin).addScaledVector(this.direction,n),pc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){EC.copy(e).add(n).multiplyScalar(.5),b_.copy(n).sub(e).normalize(),$u.copy(this.origin).sub(EC);const a=e.distanceTo(n)*.5,o=-this.direction.dot(b_),l=$u.dot(this.direction),c=-$u.dot(b_),u=$u.lengthSq(),d=Math.abs(1-o*o);let f,m,g,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,g=f*(f+o*m+2*l)+m*(o*f+m+2*c)+u}else m=a,f=Math.max(0,-(o*m+l)),g=-f*f+m*(m+2*c)+u;else m=-a,f=Math.max(0,-(o*m+l)),g=-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),g=-f*f+m*(m+2*c)+u):m<=x?(f=0,m=Math.min(Math.max(-a,-c),a),g=m*(m+2*c)+u):(f=Math.max(0,-(o*a+l)),m=f>0?a:Math.min(Math.max(-a,-c),a),g=-f*f+m*(m+2*c)+u);else m=o>0?-a:a,f=Math.max(0,-(o*m+l)),g=-f*f+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(EC).addScaledVector(b_,m),g}intersectSphere(e,n){pc.subVectors(e.center,this.origin);const r=pc.dot(this.direction),i=pc.dot(pc)-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,pc)!==null}intersectTriangle(e,n,r,i,a){AC.subVectors(n,e),y_.subVectors(r,e),TC.crossVectors(AC,y_);let o=this.direction.dot(TC),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;$u.subVectors(this.origin,e);const c=l*this.direction.dot(y_.crossVectors($u,y_));if(c<0)return null;const u=l*this.direction.dot(AC.cross($u));if(u<0||c+u>o)return null;const d=-l*$u.dot(TC);return d<0?null:this.at(d/o,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},vi=class IP{constructor(e,n,r,i,a,o,l,c,u,d,f,m,g,x,y,b){IP.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,g,x,y,b)}set(e,n,r,i,a,o,l,c,u,d,f,m,g,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]=g,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 IP().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/Um.setFromMatrixColumn(e,0).length(),a=1/Um.setFromMatrixColumn(e,1).length(),o=1/Um.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,g=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=g+x*u,n[5]=m-y*u,n[9]=-l*c,n[2]=y-m*u,n[6]=x+g*u,n[10]=o*c}else if(e.order==="YXZ"){const m=c*d,g=c*f,x=u*d,y=u*f;n[0]=m+y*l,n[4]=x*l-g,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=g*l-x,n[6]=y+m*l,n[10]=o*c}else if(e.order==="ZXY"){const m=c*d,g=c*f,x=u*d,y=u*f;n[0]=m-y*l,n[4]=-o*f,n[8]=x+g*l,n[1]=g+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,g=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=x*u-g,n[8]=m*u+y,n[1]=c*f,n[5]=y*u+m,n[9]=g*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const m=o*c,g=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=y-m*f,n[8]=x*f+g,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=g*f+x,n[10]=m-y*f}else if(e.order==="XZY"){const m=o*c,g=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]=g*f-x,n[2]=x*f-g,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(qje,e,Kje)}lookAt(e,n,r){const i=this.elements;return Cs.subVectors(e,n),Cs.lengthSq()===0&&(Cs.z=1),Cs.normalize(),Hu.crossVectors(r,Cs),Hu.lengthSq()===0&&(Math.abs(r.z)===1?Cs.x+=1e-4:Cs.z+=1e-4,Cs.normalize(),Hu.crossVectors(r,Cs)),Hu.normalize(),v_.crossVectors(Cs,Hu),i[0]=Hu.x,i[4]=v_.x,i[8]=Cs.x,i[1]=Hu.y,i[5]=v_.y,i[9]=Cs.y,i[2]=Hu.z,i[6]=v_.z,i[10]=Cs.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],g=r[13],x=r[2],y=r[6],b=r[10],v=r[14],M=r[3],S=r[7],A=r[11],E=r[15],k=i[0],C=i[4],R=i[8],T=i[12],P=i[1],F=i[5],L=i[9],X=i[13],D=i[2],K=i[6],Y=i[10],q=i[14],Z=i[3],re=i[7],oe=i[11],B=i[15];return a[0]=o*k+l*P+c*D+u*Z,a[4]=o*C+l*F+c*K+u*re,a[8]=o*R+l*L+c*Y+u*oe,a[12]=o*T+l*X+c*q+u*B,a[1]=d*k+f*P+m*D+g*Z,a[5]=d*C+f*F+m*K+g*re,a[9]=d*R+f*L+m*Y+g*oe,a[13]=d*T+f*X+m*q+g*B,a[2]=x*k+y*P+b*D+v*Z,a[6]=x*C+y*F+b*K+v*re,a[10]=x*R+y*L+b*Y+v*oe,a[14]=x*T+y*X+b*q+v*B,a[3]=M*k+S*P+A*D+E*Z,a[7]=M*C+S*F+A*K+E*re,a[11]=M*R+S*L+A*Y+E*oe,a[15]=M*T+S*X+A*q+E*B,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],m=e[10],g=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*g-r*c*g)+y*(+n*c*g-n*u*m+a*o*m-i*o*g+i*u*d-a*c*d)+b*(+n*u*f-n*l*g-a*o*f+r*o*g+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],g=e[11],x=e[12],y=e[13],b=e[14],v=e[15],M=f*b*u-y*m*u+y*c*g-l*b*g-f*c*v+l*m*v,S=x*m*u-d*b*u-x*c*g+o*b*g+d*c*v-o*m*v,A=d*y*u-x*f*u+x*l*g-o*y*g-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,k=n*M+r*S+i*A+a*E;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/k;return e[0]=M*C,e[1]=(y*m*a-f*b*a-y*i*g+r*b*g+f*i*v-r*m*v)*C,e[2]=(l*b*a-y*c*a+y*i*u-r*b*u-l*i*v+r*c*v)*C,e[3]=(f*c*a-l*m*a-f*i*u+r*m*u+l*i*g-r*c*g)*C,e[4]=S*C,e[5]=(d*b*a-x*m*a+x*i*g-n*b*g-d*i*v+n*m*v)*C,e[6]=(x*c*a-o*b*a-x*i*u+n*b*u+o*i*v-n*c*v)*C,e[7]=(o*m*a-d*c*a+d*i*u-n*m*u-o*i*g+n*c*g)*C,e[8]=A*C,e[9]=(x*f*a-d*y*a-x*r*g+n*y*g+d*r*v-n*f*v)*C,e[10]=(o*y*a-x*l*a+x*r*u-n*y*u-o*r*v+n*l*v)*C,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*g-n*l*g)*C,e[12]=E*C,e[13]=(d*y*i-x*f*i+x*r*m-n*y*m-d*r*b+n*f*b)*C,e[14]=(x*l*i-o*y*i-x*r*c+n*y*c+o*r*b-n*l*b)*C,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*C,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,g=a*d,x=a*f,y=o*d,b=o*f,v=l*f,M=c*u,S=c*d,A=c*f,E=r.x,k=r.y,C=r.z;return i[0]=(1-(y+v))*E,i[1]=(g+A)*E,i[2]=(x-S)*E,i[3]=0,i[4]=(g-A)*k,i[5]=(1-(m+v))*k,i[6]=(b+M)*k,i[7]=0,i[8]=(x+S)*C,i[9]=(b-M)*C,i[10]=(1-(m+y))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let a=Um.set(i[0],i[1],i[2]).length();const o=Um.set(i[4],i[5],i[6]).length(),l=Um.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],Io.copy(this);const u=1/a,d=1/o,f=1/l;return Io.elements[0]*=u,Io.elements[1]*=u,Io.elements[2]*=u,Io.elements[4]*=d,Io.elements[5]*=d,Io.elements[6]*=d,Io.elements[8]*=f,Io.elements[9]*=f,Io.elements[10]*=f,n.setFromRotationMatrix(Io),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=Tl,c=!1){const u=this.elements,d=2*a/(n-e),f=2*a/(r-i),m=(n+e)/(n-e),g=(r+i)/(r-i);let x,y;if(c)x=a/(o-a),y=o*a/(o-a);else if(l===Tl)x=-(o+a)/(o-a),y=-2*o*a/(o-a);else if(l===pS)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]=g,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=Tl,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),m=-(n+e)/(n-e),g=-(r+i)/(r-i);let x,y;if(c)x=1/(o-a),y=o/(o-a);else if(l===Tl)x=-2/(o-a),y=-(o+a)/(o-a);else if(l===pS)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]=g,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 Um=new at,Io=new vi,qje=new at(0,0,0),Kje=new at(1,1,1),Hu=new at,v_=new at,Cs=new at,xH=new vi,bH=new Rf;let $d=class HZ{constructor(e=0,n=0,r=0,i=HZ.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],g=i[10];switch(n){case"XYZ":this._y=Math.asin(An(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,g),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-An(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,g),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(An(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-f,g),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-An(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(m,g),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(An(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,g));break;case"XZY":this._z=Math.asin(-An(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,g),this._y=0);break;default:ln("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return xH.makeRotationFromQuaternion(e),this.setFromRotationMatrix(xH,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return bH.setFromEuler(this),this.setFromQuaternion(bH,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}};$d.DEFAULT_ORDER="XYZ";let VZ=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}},Xje=0;const yH=new at,zm=new Rf,gc=new vi,__=new at,tb=new at,Yje=new at,Qje=new Rf,vH=new at(1,0,0),_H=new at(0,1,0),wH=new at(0,0,1),SH={type:"added"},Zje={type:"removed"},Bm={type:"childadded",child:null},CC={type:"childremoved",child:null};let qs=class K1 extends Kf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Xje++}),this.uuid=Ny(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=K1.DEFAULT_UP.clone();const e=new at,n=new $d,r=new Rf,i=new at(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new vi},normalMatrix:{value:new Sn}}),this.matrix=new vi,this.matrixWorld=new vi,this.matrixAutoUpdate=K1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=K1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new VZ,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 zm.setFromAxisAngle(e,n),this.quaternion.multiply(zm),this}rotateOnWorldAxis(e,n){return zm.setFromAxisAngle(e,n),this.quaternion.premultiply(zm),this}rotateX(e){return this.rotateOnAxis(vH,e)}rotateY(e){return this.rotateOnAxis(_H,e)}rotateZ(e){return this.rotateOnAxis(wH,e)}translateOnAxis(e,n){return yH.copy(e).applyQuaternion(this.quaternion),this.position.add(yH.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(vH,e)}translateY(e){return this.translateOnAxis(_H,e)}translateZ(e){return this.translateOnAxis(wH,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(gc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?__.copy(e):__.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),tb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?gc.lookAt(tb,__,this.up):gc.lookAt(__,tb,this.up),this.quaternion.setFromRotationMatrix(gc),i&&(gc.extractRotation(i.matrixWorld),zm.setFromRotationMatrix(gc),this.quaternion.premultiply(zm.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(ai("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(SH),Bm.child=e,this.dispatchEvent(Bm),Bm.child=null):ai("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(Zje),CC.child=e,this.dispatchEvent(CC),CC.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),gc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),gc.multiply(e.parent.matrixWorld)),e.applyMatrix4(gc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(SH),Bm.child=e,this.dispatchEvent(Bm),Bm.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(tb,e,Yje),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(tb,Qje,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),g=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),g.length>0&&(r.animations=g),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}};qs.DEFAULT_UP=new at(0,1,0);qs.DEFAULT_MATRIX_AUTO_UPDATE=!0;qs.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Fo=new at,xc=new at,kC=new at,bc=new at,$m=new at,Hm=new at,MH=new at,jC=new at,PC=new at,RC=new at,DC=new pi,OC=new pi,LC=new pi;let nb=class _p{constructor(e=new at,n=new at,r=new at){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Fo.subVectors(e,n),i.cross(Fo);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){Fo.subVectors(i,n),xc.subVectors(r,n),kC.subVectors(e,n);const o=Fo.dot(Fo),l=Fo.dot(xc),c=Fo.dot(kC),u=xc.dot(xc),d=xc.dot(kC),f=o*u-l*l;if(f===0)return a.set(0,0,0),null;const m=1/f,g=(u*c-l*d)*m,x=(o*d-l*c)*m;return a.set(1-g-x,x,g)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,bc)===null?!1:bc.x>=0&&bc.y>=0&&bc.x+bc.y<=1}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,bc)===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,bc.x),c.addScaledVector(o,bc.y),c.addScaledVector(l,bc.z),c)}static getInterpolatedAttribute(e,n,r,i,a,o){return DC.setScalar(0),OC.setScalar(0),LC.setScalar(0),DC.fromBufferAttribute(e,n),OC.fromBufferAttribute(e,r),LC.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(DC,a.x),o.addScaledVector(OC,a.y),o.addScaledVector(LC,a.z),o}static isFrontFacing(e,n,r,i){return Fo.subVectors(r,n),xc.subVectors(e,n),Fo.cross(xc).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Fo.subVectors(this.c,this.b),xc.subVectors(this.a,this.b),Fo.cross(xc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return _p.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return _p.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return _p.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return _p.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return _p.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;$m.subVectors(i,r),Hm.subVectors(a,r),jC.subVectors(e,r);const c=$m.dot(jC),u=Hm.dot(jC);if(c<=0&&u<=0)return n.copy(r);PC.subVectors(e,i);const d=$m.dot(PC),f=Hm.dot(PC);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($m,o);RC.subVectors(e,a);const g=$m.dot(RC),x=Hm.dot(RC);if(x>=0&&g<=x)return n.copy(a);const y=g*u-c*x;if(y<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Hm,l);const b=d*x-g*f;if(b<=0&&f-d>=0&&g-x>=0)return MH.subVectors(a,i),l=(f-d)/(f-d+(g-x)),n.copy(i).addScaledVector(MH,l);const v=1/(b+y+m);return o=y*v,l=m*v,n.copy(r).addScaledVector($m,o).addScaledVector(Hm,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const GZ={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},Vu={h:0,s:0,l:0},w_={h:0,s:0,l:0};function IC(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 Tn=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=ho){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,zn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=zn.workingColorSpace){return this.r=e,this.g=n,this.b=r,zn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=zn.workingColorSpace){if(e=Fje(e,1),n=An(n,0,1),r=An(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=IC(o,a,e+1/3),this.g=IC(o,a,e),this.b=IC(o,a,e-1/3)}return zn.colorSpaceToWorking(this,i),this}setStyle(e,n=ho){function r(a){a!==void 0&&parseFloat(a)<1&&ln("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:ln("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);ln("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=ho){const r=GZ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):ln("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=Kc(e.r),this.g=Kc(e.g),this.b=Kc(e.b),this}copyLinearToSRGB(e){return this.r=Bp(e.r),this.g=Bp(e.g),this.b=Bp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ho){return zn.workingToColorSpace(wa.copy(this),e),Math.round(An(wa.r*255,0,255))*65536+Math.round(An(wa.g*255,0,255))*256+Math.round(An(wa.b*255,0,255))}getHexString(e=ho){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=zn.workingColorSpace){zn.workingToColorSpace(wa.copy(this),n);const r=wa.r,i=wa.g,a=wa.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=zn.workingColorSpace){return zn.workingToColorSpace(wa.copy(this),n),e.r=wa.r,e.g=wa.g,e.b=wa.b,e}getStyle(e=ho){zn.workingToColorSpace(wa.copy(this),e);const n=wa.r,r=wa.g,i=wa.b;return e!==ho?`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(Vu),this.setHSL(Vu.h+e,Vu.s+n,Vu.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(Vu),e.getHSL(w_);const r=yC(Vu.h,w_.h,n),i=yC(Vu.s,w_.s,n),a=yC(Vu.l,w_.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 wa=new Tn;Tn.NAMES=GZ;let Jje=0,Gg=class extends Kf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Jje++}),this.uuid=Ny(),this.name="",this.type="Material",this.blending=zp,this.side=Bd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=X3,this.blendDst=Y3,this.blendEquation=Ih,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Tn(0,0,0),this.blendAlpha=0,this.depthFunc=cg,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=cH,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Dm,this.stencilZFail=Dm,this.stencilZPass=Dm,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){ln(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){ln(`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!==zp&&(r.blending=this.blending),this.side!==Bd&&(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!==X3&&(r.blendSrc=this.blendSrc),this.blendDst!==Y3&&(r.blendDst=this.blendDst),this.blendEquation!==Ih&&(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!==cg&&(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!==cH&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Dm&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Dm&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Dm&&(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++}},wO=class extends Gg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Tn(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 $d,this.combine=hO,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 di=new at,S_=new vn;let e3e=0,wo=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:e3e++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=uH,this.updateRanges=[],this.gpuType=Bc,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++)S_.fromBufferAttribute(this,n),S_.applyMatrix3(e),this.setXY(n,S_.x,S_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)di.fromBufferAttribute(this,n),di.applyMatrix3(e),this.setXYZ(n,di.x,di.y,di.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)di.fromBufferAttribute(this,n),di.applyMatrix4(e),this.setXYZ(n,di.x,di.y,di.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)di.fromBufferAttribute(this,n),di.applyNormalMatrix(e),this.setXYZ(n,di.x,di.y,di.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)di.fromBufferAttribute(this,n),di.transformDirection(e),this.setXYZ(n,di.x,di.y,di.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=Zx(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=is(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Zx(n,this.array)),n}setX(e,n){return this.normalized&&(n=is(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Zx(n,this.array)),n}setY(e,n){return this.normalized&&(n=is(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=Zx(n,this.array)),n}setZ(e,n){return this.normalized&&(n=is(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=Zx(n,this.array)),n}setW(e,n){return this.normalized&&(n=is(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=is(n,this.array),r=is(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=is(n,this.array),r=is(r,this.array),i=is(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=is(n,this.array),r=is(r,this.array),i=is(i,this.array),a=is(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!==uH&&(e.usage=this.usage),e}},WZ=class extends wo{constructor(e,n,r){super(new Uint16Array(e),n,r)}},qZ=class extends wo{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Zo=class extends wo{constructor(e,n,r){super(new Float32Array(e),n,r)}},t3e=0;const io=new vi,FC=new qs,Vm=new at,ks=new Of,rb=new Of,zi=new at;let Xl=class KZ extends Kf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:t3e++}),this.uuid=Ny(),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(IZ(e)?qZ:WZ)(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 Sn().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 io.makeRotationFromQuaternion(e),this.applyMatrix4(io),this}rotateX(e){return io.makeRotationX(e),this.applyMatrix4(io),this}rotateY(e){return io.makeRotationY(e),this.applyMatrix4(io),this}rotateZ(e){return io.makeRotationZ(e),this.applyMatrix4(io),this}translate(e,n,r){return io.makeTranslation(e,n,r),this.applyMatrix4(io),this}scale(e,n,r){return io.makeScale(e,n,r),this.applyMatrix4(io),this}lookAt(e){return FC.lookAt(e),FC.updateMatrix(),this.applyMatrix4(FC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Vm).negate(),this.translate(Vm.x,Vm.y,Vm.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 Zo(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&&ln("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 Of);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ai("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new at(-1/0,-1/0,-1/0),new at(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];ks.setFromBufferAttribute(a),this.morphTargetsRelative?(zi.addVectors(this.boundingBox.min,ks.min),this.boundingBox.expandByPoint(zi),zi.addVectors(this.boundingBox.max,ks.max),this.boundingBox.expandByPoint(zi)):(this.boundingBox.expandByPoint(ks.min),this.boundingBox.expandByPoint(ks.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ai('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 OM);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ai("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new at,1/0);return}if(e){const r=this.boundingSphere.center;if(ks.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];rb.setFromBufferAttribute(l),this.morphTargetsRelative?(zi.addVectors(ks.min,rb.min),ks.expandByPoint(zi),zi.addVectors(ks.max,rb.max),ks.expandByPoint(zi)):(ks.expandByPoint(rb.min),ks.expandByPoint(rb.max))}ks.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)zi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(zi));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++)zi.fromBufferAttribute(l,u),c&&(Vm.fromBufferAttribute(e,u),zi.add(Vm)),i=Math.max(i,r.distanceToSquared(zi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&ai('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){ai("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 wo(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let R=0;R<r.count;R++)l[R]=new at,c[R]=new at;const u=new at,d=new at,f=new at,m=new vn,g=new vn,x=new vn,y=new at,b=new at;function v(R,T,P){u.fromBufferAttribute(r,R),d.fromBufferAttribute(r,T),f.fromBufferAttribute(r,P),m.fromBufferAttribute(a,R),g.fromBufferAttribute(a,T),x.fromBufferAttribute(a,P),d.sub(u),f.sub(u),g.sub(m),x.sub(m);const F=1/(g.x*x.y-x.x*g.y);isFinite(F)&&(y.copy(d).multiplyScalar(x.y).addScaledVector(f,-g.y).multiplyScalar(F),b.copy(f).multiplyScalar(g.x).addScaledVector(d,-x.x).multiplyScalar(F),l[R].add(y),l[T].add(y),l[P].add(y),c[R].add(b),c[T].add(b),c[P].add(b))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let R=0,T=M.length;R<T;++R){const P=M[R],F=P.start,L=P.count;for(let X=F,D=F+L;X<D;X+=3)v(e.getX(X+0),e.getX(X+1),e.getX(X+2))}const S=new at,A=new at,E=new at,k=new at;function C(R){E.fromBufferAttribute(i,R),k.copy(E);const T=l[R];S.copy(T),S.sub(E.multiplyScalar(E.dot(T))).normalize(),A.crossVectors(k,T);const F=A.dot(c[R])<0?-1:1;o.setXYZW(R,S.x,S.y,S.z,F)}for(let R=0,T=M.length;R<T;++R){const P=M[R],F=P.start,L=P.count;for(let X=F,D=F+L;X<D;X+=3)C(e.getX(X+0)),C(e.getX(X+1)),C(e.getX(X+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 wo(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,g=r.count;m<g;m++)r.setXYZ(m,0,0,0);const i=new at,a=new at,o=new at,l=new at,c=new at,u=new at,d=new at,f=new at;if(e)for(let m=0,g=e.count;m<g;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,g=n.count;m<g;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++)zi.fromBufferAttribute(e,n),zi.normalize(),e.setXYZ(n,zi.x,zi.y,zi.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,m=new u.constructor(c.length*d);let g=0,x=0;for(let y=0,b=c.length;y<b;y++){l.isInterleavedBufferAttribute?g=c[y]*l.data.stride+l.offset:g=c[y]*d;for(let v=0;v<d;v++)m[x++]=u[g++]}return new wo(m,d,f)}if(this.index===null)return ln("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new KZ,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],g=e(m,r);c.push(g)}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 g=u[f];d.push(g.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,g=f.length;m<g;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 NH=new vi,wh=new _O,M_=new OM,EH=new at,N_=new at,E_=new at,A_=new at,UC=new at,T_=new at,AH=new at,C_=new at;let Bl=class extends qs{constructor(e=new Xl,n=new wO){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){T_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(UC.fromBufferAttribute(f,e),o?T_.addScaledVector(UC,d):T_.addScaledVector(UC.sub(n),d))}n.add(T_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),M_.copy(r.boundingSphere),M_.applyMatrix4(a),wh.copy(e.ray).recast(e.near),!(M_.containsPoint(wh.origin)===!1&&(wh.intersectSphere(M_,EH)===null||wh.origin.distanceToSquared(EH)>(e.far-e.near)**2))&&(NH.copy(a).invert(),wh.copy(e.ray).applyMatrix4(NH),!(r.boundingBox!==null&&wh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,wh)))}_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,g=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],M=Math.max(b.start,g.start),S=Math.min(l.count,Math.min(b.start+b.count,g.start+g.count));for(let A=M,E=S;A<E;A+=3){const k=l.getX(A),C=l.getX(A+1),R=l.getX(A+2);i=k_(this,v,e,r,u,d,f,k,C,R),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,g.start),y=Math.min(l.count,g.start+g.count);for(let b=x,v=y;b<v;b+=3){const M=l.getX(b),S=l.getX(b+1),A=l.getX(b+2);i=k_(this,o,e,r,u,d,f,M,S,A),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],M=Math.max(b.start,g.start),S=Math.min(c.count,Math.min(b.start+b.count,g.start+g.count));for(let A=M,E=S;A<E;A+=3){const k=A,C=A+1,R=A+2;i=k_(this,v,e,r,u,d,f,k,C,R),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,g.start),y=Math.min(c.count,g.start+g.count);for(let b=x,v=y;b<v;b+=3){const M=b,S=b+1,A=b+2;i=k_(this,o,e,r,u,d,f,M,S,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}};function n3e(t,e,n,r,i,a,o,l){let c;if(e.side===fs?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===Bd,l),c===null)return null;C_.copy(l),C_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(C_);return u<n.near||u>n.far?null:{distance:u,point:C_.clone(),object:t}}function k_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,N_),t.getVertexPosition(c,E_),t.getVertexPosition(u,A_);const d=n3e(t,e,n,r,N_,E_,A_,AH);if(d){const f=new at;nb.getBarycoord(AH,N_,E_,A_,f),i&&(d.uv=nb.getInterpolatedAttribute(i,l,c,u,f,new vn)),a&&(d.uv1=nb.getInterpolatedAttribute(a,l,c,u,f,new vn)),o&&(d.normal=nb.getInterpolatedAttribute(o,l,c,u,f,new at),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const m={a:l,b:c,c:u,normal:new at,materialIndex:0};nb.getNormal(N_,E_,A_,m.normal),d.face=m,d.barycoord=f}return d}let SO=class XZ extends Xl{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,g=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 Zo(u,3)),this.setAttribute("normal",new Zo(d,3)),this.setAttribute("uv",new Zo(f,2));function x(y,b,v,M,S,A,E,k,C,R,T){const P=A/C,F=E/R,L=A/2,X=E/2,D=k/2,K=C+1,Y=R+1;let q=0,Z=0;const re=new at;for(let oe=0;oe<Y;oe++){const B=oe*F-X;for(let G=0;G<K;G++){const J=G*P-L;re[y]=J*M,re[b]=B*S,re[v]=D,u.push(re.x,re.y,re.z),re[y]=0,re[b]=0,re[v]=k>0?1:-1,d.push(re.x,re.y,re.z),f.push(G/C),f.push(1-oe/R),q+=1}}for(let oe=0;oe<R;oe++)for(let B=0;B<C;B++){const G=m+B+K*oe,J=m+B+K*(oe+1),te=m+(B+1)+K*(oe+1),ae=m+(B+1)+K*oe;c.push(G,J,ae),c.push(J,te,ae),Z+=6}l.addGroup(g,Z,T),g+=Z,m+=q}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new XZ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function fg(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?(ln("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 Ia(t){const e={};for(let n=0;n<t.length;n++){const r=fg(t[n]);for(const i in r)e[i]=r[i]}return e}function r3e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function YZ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:zn.workingColorSpace}const i3e={clone:fg,merge:Ia};var a3e=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,s3e=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let lu=class extends Gg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=a3e,this.fragmentShader=s3e,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=fg(e.uniforms),this.uniformsGroups=r3e(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}},QZ=class extends qs{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new vi,this.projectionMatrix=new vi,this.projectionMatrixInverse=new vi,this.coordinateSystem=Tl,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 Gu=new at,TH=new vn,CH=new vn;let po=class extends QZ{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=LP*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(W1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return LP*2*Math.atan(Math.tan(W1*.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){Gu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Gu.x,Gu.y).multiplyScalar(-e/Gu.z),Gu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Gu.x,Gu.y).multiplyScalar(-e/Gu.z)}getViewSize(e,n){return this.getViewBounds(e,TH,CH),n.subVectors(CH,TH)}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(W1*.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 Gm=-90,Wm=1;let o3e=class extends qs{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new po(Gm,Wm,e,n);i.layers=this.layers,this.add(i);const a=new po(Gm,Wm,e,n);a.layers=this.layers,this.add(a);const o=new po(Gm,Wm,e,n);o.layers=this.layers,this.add(o);const l=new po(Gm,Wm,e,n);l.layers=this.layers,this.add(l);const c=new po(Gm,Wm,e,n);c.layers=this.layers,this.add(c);const u=new po(Gm,Wm,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===Tl)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===pS)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(),g=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,g),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},ZZ=class extends cl{constructor(e=[],n=ug,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}},l3e=class extends Df{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 ZZ(i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new SO(5,5,5),a=new lu({name:"CubemapFromEquirect",uniforms:fg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:fs,blending:qc});a.uniforms.tEquirect.value=n;const o=new Bl(i,a),l=n.minFilter;return n.minFilter===Yh&&(n.minFilter=_o),new o3e(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)}},vb=class extends qs{constructor(){super(),this.isGroup=!0,this.type="Group"}};const c3e={type:"move"};let zC=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new vb,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 vb,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new at,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new at),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new vb,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new at,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new at),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),g=.02,x=.005;u.inputState.pinching&&m>g+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=g-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(c3e)))}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 vb;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},u3e=class extends qs{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 $d,this.environmentIntensity=1,this.environmentRotation=new $d,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}},d3e=class extends cl{constructor(e=null,n=1,r=1,i,a,o,l,c,u=Bs,d=Bs,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 BC=new at,h3e=new at,f3e=new Sn;let id=class{constructor(e=new at(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=BC.subVectors(r,n).cross(h3e.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(BC),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||f3e.getNormalMatrix(e),i=this.coplanarPoint(BC).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 Sh=new OM,m3e=new vn(.5,.5),j_=new at;let MO=class{constructor(e=new id,n=new id,r=new id,i=new id,a=new id,o=new id){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=Tl,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],g=a[7],x=a[8],y=a[9],b=a[10],v=a[11],M=a[12],S=a[13],A=a[14],E=a[15];if(i[0].setComponents(u-o,g-d,v-x,E-M).normalize(),i[1].setComponents(u+o,g+d,v+x,E+M).normalize(),i[2].setComponents(u+l,g+f,v+y,E+S).normalize(),i[3].setComponents(u-l,g-f,v-y,E-S).normalize(),r)i[4].setComponents(c,m,b,A).normalize(),i[5].setComponents(u-c,g-m,v-b,E-A).normalize();else if(i[4].setComponents(u-c,g-m,v-b,E-A).normalize(),n===Tl)i[5].setComponents(u+c,g+m,v+b,E+A).normalize();else if(n===pS)i[5].setComponents(c,m,b,A).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Sh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Sh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Sh)}intersectsSprite(e){Sh.center.set(0,0,0);const n=m3e.distanceTo(e.center);return Sh.radius=.7071067811865476+n,Sh.applyMatrix4(e.matrixWorld),this.intersectsSphere(Sh)}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(j_.x=i.normal.x>0?e.max.x:e.min.x,j_.y=i.normal.y>0?e.max.y:e.min.y,j_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(j_)<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)}},JZ=class extends Gg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Tn(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 xS=new at,bS=new at,kH=new vi,ib=new _O,P_=new OM,$C=new at,jH=new at;let p3e=class extends qs{constructor(e=new Xl,n=new JZ){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++)xS.fromBufferAttribute(n,i-1),bS.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=xS.distanceTo(bS);e.setAttribute("lineDistance",new Zo(r,1))}else ln("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(),P_.copy(r.boundingSphere),P_.applyMatrix4(i),P_.radius+=a,e.ray.intersectsSphere(P_)===!1)return;kH.copy(i).invert(),ib.copy(e.ray).applyMatrix4(kH);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 g=Math.max(0,o.start),x=Math.min(d.count,o.start+o.count);for(let y=g,b=x-1;y<b;y+=u){const v=d.getX(y),M=d.getX(y+1),S=R_(this,e,ib,c,v,M,y);S&&n.push(S)}if(this.isLineLoop){const y=d.getX(x-1),b=d.getX(g),v=R_(this,e,ib,c,y,b,x-1);v&&n.push(v)}}else{const g=Math.max(0,o.start),x=Math.min(m.count,o.start+o.count);for(let y=g,b=x-1;y<b;y+=u){const v=R_(this,e,ib,c,y,y+1,y);v&&n.push(v)}if(this.isLineLoop){const y=R_(this,e,ib,c,x-1,g,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 R_(t,e,n,r,i,a,o){const l=t.geometry.attributes.position;if(xS.fromBufferAttribute(l,i),bS.fromBufferAttribute(l,a),n.distanceSqToSegment(xS,bS,$C,jH)>r)return;$C.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo($C);if(!(u<e.near||u>e.far))return{distance:u,point:jH.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const PH=new at,RH=new at;let g3e=class extends p3e{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)PH.fromBufferAttribute(n,i),RH.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+PH.distanceTo(RH);e.setAttribute("lineDistance",new Zo(r,1))}else ln("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},eJ=class extends cl{constructor(e,n,r=Pf,i,a,o,l=Bs,c=Bs,u,d=N0,f=1){if(d!==N0&&d!==E0)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 vO(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 tJ extends cl{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let NO=class nJ extends Xl{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,g=[],x=[],y=[],b=[];for(let v=0;v<d;v++){const M=v*m-o;for(let S=0;S<u;S++){const A=S*f-a;x.push(A,-M,0),y.push(0,0,1),b.push(S/l),b.push(1-v/c)}}for(let v=0;v<c;v++)for(let M=0;M<l;M++){const S=M+u*v,A=M+u*(v+1),E=M+1+u*(v+1),k=M+1+u*v;g.push(S,A,k),g.push(A,E,k)}this.setIndex(g),this.setAttribute("position",new Zo(x,3)),this.setAttribute("normal",new Zo(y,3)),this.setAttribute("uv",new Zo(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new nJ(e.width,e.height,e.widthSegments,e.heightSegments)}};class x3e extends Gg{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Tn(16777215),this.specular=new Tn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Tn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=OZ,this.normalScale=new vn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new $d,this.combine=hO,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 b3e=class extends Gg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Eje,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}},y3e=class extends Gg{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}},rJ=class extends qs{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Tn(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 HC=new vi,DH=new at,OH=new at;let v3e=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new vn(512,512),this.mapType=zl,this.map=null,this.mapPass=null,this.matrix=new vi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new MO,this._frameExtents=new vn(1,1),this._viewportCount=1,this._viewports=[new pi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;DH.setFromMatrixPosition(e.matrixWorld),n.position.copy(DH),OH.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(OH),n.updateMatrixWorld(),HC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(HC,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(HC)}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}},iJ=class extends QZ{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 _3e extends v3e{constructor(){super(new iJ(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class LH extends rJ{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(qs.DEFAULT_UP),this.updateMatrix(),this.target=new qs,this.shadow=new _3e}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let w3e=class extends rJ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},S3e=class extends po{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},IH=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=An(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(An(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class M3e extends g3e{constructor(e=10,n=10,r=4473924,i=8947848){r=new Tn(r),i=new Tn(i);const a=n/2,o=e/n,l=e/2,c=[],u=[];for(let m=0,g=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,g),g+=3,y.toArray(u,g),g+=3,y.toArray(u,g),g+=3,y.toArray(u,g),g+=3}const d=new Xl;d.setAttribute("position",new Zo(c,3)),d.setAttribute("color",new Zo(u,3));const f=new JZ({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class N3e extends Kf{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){ln("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function FH(t,e,n,r){const i=E3e(r);switch(n){case PZ:return t*e;case DZ:return t*e/i.components*i.byteLength;case gO:return t*e/i.components*i.byteLength;case xO:return t*e*2/i.components*i.byteLength;case bO:return t*e*2/i.components*i.byteLength;case RZ:return t*e*3/i.components*i.byteLength;case Ko:return t*e*4/i.components*i.byteLength;case yO:return t*e*4/i.components*i.byteLength;case $1:case H1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case V1:case G1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case cP:case dP:return Math.max(t,16)*Math.max(e,8)/4;case lP:case uP:return Math.max(t,8)*Math.max(e,8)/2;case hP:case fP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case mP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case pP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case gP:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case xP:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case bP:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case yP:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case vP:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case _P:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case wP:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case SP:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case MP:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case NP:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case EP:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case AP:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case TP:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case CP:case kP:case jP:return Math.ceil(t/4)*Math.ceil(e/4)*16;case PP:case RP:return Math.ceil(t/4)*Math.ceil(e/4)*8;case DP:case OP:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function E3e(t){switch(t){case zl:case TZ:return{byteLength:1,components:1};case S0:case CZ:case Vg:return{byteLength:2,components:1};case mO:case pO:return{byteLength:2,components:4};case Pf:case fO:case Bc:return{byteLength:4,components:1};case kZ:case jZ:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:dO}}));typeof window<"u"&&(window.__THREE__?ln("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=dO);function aJ(){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 A3e(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 g;if(u instanceof Float32Array)g=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)g=t.HALF_FLOAT;else if(u instanceof Uint16Array)l.isFloat16BufferAttribute?g=t.HALF_FLOAT:g=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)g=t.SHORT;else if(u instanceof Uint32Array)g=t.UNSIGNED_INT;else if(u instanceof Int32Array)g=t.INT;else if(u instanceof Int8Array)g=t.BYTE;else if(u instanceof Uint8Array)g=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)g=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:m,type:g,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((g,x)=>g.start-x.start);let m=0;for(let g=1;g<f.length;g++){const x=f[m],y=f[g];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 g=0,x=f.length;g<x;g++){const y=f[g];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 T3e=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,C3e=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,k3e=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,j3e=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,P3e=`#ifdef USE_ALPHATEST
- #ifdef ALPHA_TO_COVERAGE
- diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- if ( diffuseColor.a < alphaTest ) discard;
- #endif
- #endif`,R3e=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,D3e=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,O3e=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,L3e=`#ifdef USE_BATCHING
- #if ! defined( GL_ANGLE_multi_draw )
- #define gl_DrawID _gl_DrawID
- uniform int _gl_DrawID;
- #endif
- uniform highp sampler2D batchingTexture;
- uniform highp usampler2D batchingIdTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- float getIndirectIndex( const in int i ) {
- int size = textureSize( batchingIdTexture, 0 ).x;
- int x = i % size;
- int y = i / size;
- return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
- }
- #endif
- #ifdef USE_BATCHING_COLOR
- uniform sampler2D batchingColorTexture;
- vec3 getBatchingColor( const in float i ) {
- int size = textureSize( batchingColorTexture, 0 ).x;
- int j = int( i );
- int x = j % size;
- int y = j / size;
- return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
- }
- #endif`,I3e=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,F3e=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,U3e=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,z3e=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,B3e=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,$3e=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,H3e=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #ifdef ALPHA_TO_COVERAGE
- float distanceToPlane, distanceGradient;
- float clipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- if ( clipOpacity == 0.0 ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- float unionClipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- }
- #pragma unroll_loop_end
- clipOpacity *= 1.0 - unionClipOpacity;
- #endif
- diffuseColor.a *= clipOpacity;
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif
- #endif`,V3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,G3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,W3e=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,q3e=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,K3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,X3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,Y3e=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif
- #ifdef USE_BATCHING_COLOR
- vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
- vColor.xyz *= batchingColor.xyz;
- #endif`,Q3e=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,Z3e=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,J3e=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,ePe=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,tPe=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,nPe=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,rPe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,iPe="gl_FragColor = linearToOutputTexel( gl_FragColor );",aPe=`vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferEOTF( in vec4 value ) {
- return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }`,sPe=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,oPe=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- uniform mat3 envMapRotation;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
- #endif`,lPe=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,cPe=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,uPe=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,dPe=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,hPe=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,fPe=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,mPe=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,pPe=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,gPe=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,xPe=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,bPe=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,yPe=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,vPe=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,_Pe=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,wPe=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,SPe=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,MPe=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,NPe=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_DISPERSION
- material.dispersion = dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,EPe=`uniform sampler2D dfgLUT;
- struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- float dispersion;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 uv = vec2( roughness, dotNV );
- return texture2D( dfgLUT, uv ).rg;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
- vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
- vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
- vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
- float Ess_V = dfgV.x + dfgV.y;
- float Ess_L = dfgL.x + dfgL.y;
- float Ems_V = 1.0 - Ess_V;
- float Ems_L = 1.0 - Ess_L;
- vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
- vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
- float compensationFactor = Ems_V * Ems_L;
- vec3 multiScatter = Fms * compensationFactor;
- return singleScatter + multiScatter;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,APe=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,TPe=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,CPe=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,kPe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,jPe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,PPe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,RPe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,DPe=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,OPe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,LPe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,IPe=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,FPe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,UPe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,zPe=`#ifdef USE_INSTANCING_MORPH
- float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
- }
- #endif`,BPe=`#if defined( USE_MORPHCOLORS )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,$Pe=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,HPe=`#ifdef USE_MORPHTARGETS
- #ifndef USE_INSTANCING_MORPH
- uniform float morphTargetBaseInfluence;
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- #endif
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #endif`,VPe=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,GPe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,WPe=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,qPe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,KPe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,XPe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,YPe=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,QPe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,ZPe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,JPe=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,eRe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,tRe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,nRe=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
- const float Inv255 = 1. / 255.;
- const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
- const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
- const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
- const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
- vec4 packDepthToRGBA( const in float v ) {
- if( v <= 0.0 )
- return vec4( 0., 0., 0., 0. );
- if( v >= 1.0 )
- return vec4( 1., 1., 1., 1. );
- float vuf;
- float af = modf( v * PackFactors.a, vuf );
- float bf = modf( vuf * ShiftRight8, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
- }
- vec3 packDepthToRGB( const in float v ) {
- if( v <= 0.0 )
- return vec3( 0., 0., 0. );
- if( v >= 1.0 )
- return vec3( 1., 1., 1. );
- float vuf;
- float bf = modf( v * PackFactors.b, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec3( vuf * Inv255, gf * PackUpscale, bf );
- }
- vec2 packDepthToRG( const in float v ) {
- if( v <= 0.0 )
- return vec2( 0., 0. );
- if( v >= 1.0 )
- return vec2( 1., 1. );
- float vuf;
- float gf = modf( v * 256., vuf );
- return vec2( vuf * Inv255, gf );
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors4 );
- }
- float unpackRGBToDepth( const in vec3 v ) {
- return dot( v, UnpackFactors3 );
- }
- float unpackRGToDepth( const in vec2 v ) {
- return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
- }
- vec4 pack2HalfToRGBA( const in vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( const in vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,rRe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,iRe=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,aRe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,sRe=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,oRe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,lRe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,cRe=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- return step( depth, compare );
- #else
- return step( compare, depth );
- #endif
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float hard_shadow = step( distribution.x, compare );
- #else
- float hard_shadow = step( compare, distribution.x );
- #endif
- if ( hard_shadow != 1.0 ) {
- float distance = compare - distribution.x;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- float shadow = 1.0;
- vec3 lightToPosition = shadowCoord.xyz;
-
- float lightToPositionLength = length( lightToPosition );
- if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
- float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- shadow = (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- #endif`,uRe=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,dRe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,hRe=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,fRe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,mRe=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,pRe=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,gRe=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,xRe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,bRe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,yRe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,vRe=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 CineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
- vec3( 1.6605, - 0.1246, - 0.0182 ),
- vec3( - 0.5876, 1.1329, - 0.1006 ),
- vec3( - 0.0728, - 0.0083, 1.1187 )
- );
- const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
- vec3( 0.6274, 0.0691, 0.0164 ),
- vec3( 0.3293, 0.9195, 0.0880 ),
- vec3( 0.0433, 0.0113, 0.8956 )
- );
- vec3 agxDefaultContrastApprox( vec3 x ) {
- vec3 x2 = x * x;
- vec3 x4 = x2 * x2;
- return + 15.5 * x4 * x2
- - 40.14 * x4 * x
- + 31.96 * x4
- - 6.868 * x2 * x
- + 0.4298 * x2
- + 0.1191 * x
- - 0.00232;
- }
- vec3 AgXToneMapping( vec3 color ) {
- const mat3 AgXInsetMatrix = mat3(
- vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
- vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
- vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
- );
- const mat3 AgXOutsetMatrix = mat3(
- vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
- vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
- vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
- );
- const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
- color *= toneMappingExposure;
- color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
- color = AgXInsetMatrix * color;
- color = max( color, 1e-10 ); color = log2( color );
- color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
- color = clamp( color, 0.0, 1.0 );
- color = agxDefaultContrastApprox( color );
- color = AgXOutsetMatrix * color;
- color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
- color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
- color = clamp( color, 0.0, 1.0 );
- return color;
- }
- vec3 NeutralToneMapping( vec3 color ) {
- const float StartCompression = 0.8 - 0.04;
- const float Desaturation = 0.15;
- color *= toneMappingExposure;
- float x = min( color.r, min( color.g, color.b ) );
- float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
- color -= offset;
- float peak = max( color.r, max( color.g, color.b ) );
- if ( peak < StartCompression ) return color;
- float d = 1. - StartCompression;
- float newPeak = 1. - d * d / ( peak + d - StartCompression );
- color *= newPeak / peak;
- float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
- return mix( color, vec3( newPeak ), g );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,_Re=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,wRe=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec4 transmittedLight;
- vec3 transmittance;
- #ifdef USE_DISPERSION
- float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
- vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
- for ( int i = 0; i < 3; i ++ ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
- transmittedLight[ i ] = transmissionSample[ i ];
- transmittedLight.a += transmissionSample.a;
- transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
- }
- transmittedLight.a /= 3.0;
- #else
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- #endif
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,SRe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,MRe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,NRe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,ERe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const ARe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,TRe=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,CRe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,kRe=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- uniform mat3 backgroundRotation;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,jRe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,PRe=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,RRe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,DRe=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
- #else
- float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
- #endif
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #elif DEPTH_PACKING == 3202
- gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
- #elif DEPTH_PACKING == 3203
- gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
- #endif
- }`,ORe=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,LRe=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,IRe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,FRe=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,URe=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,zRe=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,BRe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,$Re=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,HRe=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,VRe=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,GRe=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,WRe=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,qRe=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,KRe=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,XRe=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,YRe=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,QRe=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,ZRe=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_DISPERSION
- uniform float dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,JRe=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,eDe=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,tDe=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,nDe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,rDe=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,iDe=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,aDe=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix[ 3 ];
- vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,sDe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,bn={alphahash_fragment:T3e,alphahash_pars_fragment:C3e,alphamap_fragment:k3e,alphamap_pars_fragment:j3e,alphatest_fragment:P3e,alphatest_pars_fragment:R3e,aomap_fragment:D3e,aomap_pars_fragment:O3e,batching_pars_vertex:L3e,batching_vertex:I3e,begin_vertex:F3e,beginnormal_vertex:U3e,bsdfs:z3e,iridescence_fragment:B3e,bumpmap_pars_fragment:$3e,clipping_planes_fragment:H3e,clipping_planes_pars_fragment:V3e,clipping_planes_pars_vertex:G3e,clipping_planes_vertex:W3e,color_fragment:q3e,color_pars_fragment:K3e,color_pars_vertex:X3e,color_vertex:Y3e,common:Q3e,cube_uv_reflection_fragment:Z3e,defaultnormal_vertex:J3e,displacementmap_pars_vertex:ePe,displacementmap_vertex:tPe,emissivemap_fragment:nPe,emissivemap_pars_fragment:rPe,colorspace_fragment:iPe,colorspace_pars_fragment:aPe,envmap_fragment:sPe,envmap_common_pars_fragment:oPe,envmap_pars_fragment:lPe,envmap_pars_vertex:cPe,envmap_physical_pars_fragment:vPe,envmap_vertex:uPe,fog_vertex:dPe,fog_pars_vertex:hPe,fog_fragment:fPe,fog_pars_fragment:mPe,gradientmap_pars_fragment:pPe,lightmap_pars_fragment:gPe,lights_lambert_fragment:xPe,lights_lambert_pars_fragment:bPe,lights_pars_begin:yPe,lights_toon_fragment:_Pe,lights_toon_pars_fragment:wPe,lights_phong_fragment:SPe,lights_phong_pars_fragment:MPe,lights_physical_fragment:NPe,lights_physical_pars_fragment:EPe,lights_fragment_begin:APe,lights_fragment_maps:TPe,lights_fragment_end:CPe,logdepthbuf_fragment:kPe,logdepthbuf_pars_fragment:jPe,logdepthbuf_pars_vertex:PPe,logdepthbuf_vertex:RPe,map_fragment:DPe,map_pars_fragment:OPe,map_particle_fragment:LPe,map_particle_pars_fragment:IPe,metalnessmap_fragment:FPe,metalnessmap_pars_fragment:UPe,morphinstance_vertex:zPe,morphcolor_vertex:BPe,morphnormal_vertex:$Pe,morphtarget_pars_vertex:HPe,morphtarget_vertex:VPe,normal_fragment_begin:GPe,normal_fragment_maps:WPe,normal_pars_fragment:qPe,normal_pars_vertex:KPe,normal_vertex:XPe,normalmap_pars_fragment:YPe,clearcoat_normal_fragment_begin:QPe,clearcoat_normal_fragment_maps:ZPe,clearcoat_pars_fragment:JPe,iridescence_pars_fragment:eRe,opaque_fragment:tRe,packing:nRe,premultiplied_alpha_fragment:rRe,project_vertex:iRe,dithering_fragment:aRe,dithering_pars_fragment:sRe,roughnessmap_fragment:oRe,roughnessmap_pars_fragment:lRe,shadowmap_pars_fragment:cRe,shadowmap_pars_vertex:uRe,shadowmap_vertex:dRe,shadowmask_pars_fragment:hRe,skinbase_vertex:fRe,skinning_pars_vertex:mRe,skinning_vertex:pRe,skinnormal_vertex:gRe,specularmap_fragment:xRe,specularmap_pars_fragment:bRe,tonemapping_fragment:yRe,tonemapping_pars_fragment:vRe,transmission_fragment:_Re,transmission_pars_fragment:wRe,uv_pars_fragment:SRe,uv_pars_vertex:MRe,uv_vertex:NRe,worldpos_vertex:ERe,background_vert:ARe,background_frag:TRe,backgroundCube_vert:CRe,backgroundCube_frag:kRe,cube_vert:jRe,cube_frag:PRe,depth_vert:RRe,depth_frag:DRe,distanceRGBA_vert:ORe,distanceRGBA_frag:LRe,equirect_vert:IRe,equirect_frag:FRe,linedashed_vert:URe,linedashed_frag:zRe,meshbasic_vert:BRe,meshbasic_frag:$Re,meshlambert_vert:HRe,meshlambert_frag:VRe,meshmatcap_vert:GRe,meshmatcap_frag:WRe,meshnormal_vert:qRe,meshnormal_frag:KRe,meshphong_vert:XRe,meshphong_frag:YRe,meshphysical_vert:QRe,meshphysical_frag:ZRe,meshtoon_vert:JRe,meshtoon_frag:eDe,points_vert:tDe,points_frag:nDe,shadow_vert:rDe,shadow_frag:iDe,sprite_vert:aDe,sprite_frag:sDe},Dt={common:{diffuse:{value:new Tn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Sn},alphaMap:{value:null},alphaMapTransform:{value:new Sn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Sn}},envmap:{envMap:{value:null},envMapRotation:{value:new Sn},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 Sn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Sn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Sn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Sn},normalScale:{value:new vn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Sn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Sn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Sn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Sn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Tn(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 Tn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Sn},alphaTest:{value:0},uvTransform:{value:new Sn}},sprite:{diffuse:{value:new Tn(16777215)},opacity:{value:1},center:{value:new vn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Sn},alphaMap:{value:null},alphaMapTransform:{value:new Sn},alphaTest:{value:0}}},Sl={basic:{uniforms:Ia([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.fog]),vertexShader:bn.meshbasic_vert,fragmentShader:bn.meshbasic_frag},lambert:{uniforms:Ia([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 Tn(0)}}]),vertexShader:bn.meshlambert_vert,fragmentShader:bn.meshlambert_frag},phong:{uniforms:Ia([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 Tn(0)},specular:{value:new Tn(1118481)},shininess:{value:30}}]),vertexShader:bn.meshphong_vert,fragmentShader:bn.meshphong_frag},standard:{uniforms:Ia([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 Tn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:bn.meshphysical_vert,fragmentShader:bn.meshphysical_frag},toon:{uniforms:Ia([Dt.common,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.gradientmap,Dt.fog,Dt.lights,{emissive:{value:new Tn(0)}}]),vertexShader:bn.meshtoon_vert,fragmentShader:bn.meshtoon_frag},matcap:{uniforms:Ia([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,{matcap:{value:null}}]),vertexShader:bn.meshmatcap_vert,fragmentShader:bn.meshmatcap_frag},points:{uniforms:Ia([Dt.points,Dt.fog]),vertexShader:bn.points_vert,fragmentShader:bn.points_frag},dashed:{uniforms:Ia([Dt.common,Dt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:bn.linedashed_vert,fragmentShader:bn.linedashed_frag},depth:{uniforms:Ia([Dt.common,Dt.displacementmap]),vertexShader:bn.depth_vert,fragmentShader:bn.depth_frag},normal:{uniforms:Ia([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,{opacity:{value:1}}]),vertexShader:bn.meshnormal_vert,fragmentShader:bn.meshnormal_frag},sprite:{uniforms:Ia([Dt.sprite,Dt.fog]),vertexShader:bn.sprite_vert,fragmentShader:bn.sprite_frag},background:{uniforms:{uvTransform:{value:new Sn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:bn.background_vert,fragmentShader:bn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Sn}},vertexShader:bn.backgroundCube_vert,fragmentShader:bn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:bn.cube_vert,fragmentShader:bn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:bn.equirect_vert,fragmentShader:bn.equirect_frag},distanceRGBA:{uniforms:Ia([Dt.common,Dt.displacementmap,{referencePosition:{value:new at},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:bn.distanceRGBA_vert,fragmentShader:bn.distanceRGBA_frag},shadow:{uniforms:Ia([Dt.lights,Dt.fog,{color:{value:new Tn(0)},opacity:{value:1}}]),vertexShader:bn.shadow_vert,fragmentShader:bn.shadow_frag}};Sl.physical={uniforms:Ia([Sl.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Sn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Sn},clearcoatNormalScale:{value:new vn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Sn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Sn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Sn},sheen:{value:0},sheenColor:{value:new Tn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Sn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Sn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Sn},transmissionSamplerSize:{value:new vn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Sn},attenuationDistance:{value:0},attenuationColor:{value:new Tn(0)},specularColor:{value:new Tn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Sn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Sn},anisotropyVector:{value:new vn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Sn}}]),vertexShader:bn.meshphysical_vert,fragmentShader:bn.meshphysical_frag};const D_={r:0,b:0,g:0},Mh=new $d,oDe=new vi;function lDe(t,e,n,r,i,a,o){const l=new Tn(0);let c=a===!0?0:1,u,d,f=null,m=0,g=null;function x(S){let A=S.isScene===!0?S.background:null;return A&&A.isTexture&&(A=(S.backgroundBlurriness>0?n:e).get(A)),A}function y(S){let A=!1;const E=x(S);E===null?v(l,c):E&&E.isColor&&(v(E,1),A=!0);const k=t.xr.getEnvironmentBlendMode();k==="additive"?r.buffers.color.setClear(0,0,0,1,o):k==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||A)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function b(S,A){const E=x(A);E&&(E.isCubeTexture||E.mapping===DM)?(d===void 0&&(d=new Bl(new SO(1,1,1),new lu({name:"BackgroundCubeMaterial",uniforms:fg(Sl.backgroundCube.uniforms),vertexShader:Sl.backgroundCube.vertexShader,fragmentShader:Sl.backgroundCube.fragmentShader,side:fs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(k,C,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),Mh.copy(A.backgroundRotation),Mh.x*=-1,Mh.y*=-1,Mh.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(Mh.y*=-1,Mh.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=A.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(oDe.makeRotationFromEuler(Mh)),d.material.toneMapped=zn.getTransfer(E.colorSpace)!==sr,(f!==E||m!==E.version||g!==t.toneMapping)&&(d.material.needsUpdate=!0,f=E,m=E.version,g=t.toneMapping),d.layers.enableAll(),S.unshift(d,d.geometry,d.material,0,0,null)):E&&E.isTexture&&(u===void 0&&(u=new Bl(new NO(2,2),new lu({name:"BackgroundMaterial",uniforms:fg(Sl.background.uniforms),vertexShader:Sl.background.vertexShader,fragmentShader:Sl.background.fragmentShader,side:Bd,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=A.backgroundIntensity,u.material.toneMapped=zn.getTransfer(E.colorSpace)!==sr,E.matrixAutoUpdate===!0&&E.updateMatrix(),u.material.uniforms.uvTransform.value.copy(E.matrix),(f!==E||m!==E.version||g!==t.toneMapping)&&(u.material.needsUpdate=!0,f=E,m=E.version,g=t.toneMapping),u.layers.enableAll(),S.unshift(u,u.geometry,u.material,0,0,null))}function v(S,A){S.getRGB(D_,YZ(t)),r.buffers.color.setClear(D_.r,D_.g,D_.b,A,o)}function M(){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,A=1){l.set(S),c=A,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(S){c=S,v(l,c)},render:y,addToRenderList:b,dispose:M}}function cDe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=m(null);let a=i,o=!1;function l(P,F,L,X,D){let K=!1;const Y=f(X,L,F);a!==Y&&(a=Y,u(a.object)),K=g(P,X,L,D),K&&x(P,X,L,D),D!==null&&e.update(D,t.ELEMENT_ARRAY_BUFFER),(K||o)&&(o=!1,A(P,F,L,X),D!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(D).buffer))}function c(){return t.createVertexArray()}function u(P){return t.bindVertexArray(P)}function d(P){return t.deleteVertexArray(P)}function f(P,F,L){const X=L.wireframe===!0;let D=r[P.id];D===void 0&&(D={},r[P.id]=D);let K=D[F.id];K===void 0&&(K={},D[F.id]=K);let Y=K[X];return Y===void 0&&(Y=m(c()),K[X]=Y),Y}function m(P){const F=[],L=[],X=[];for(let D=0;D<n;D++)F[D]=0,L[D]=0,X[D]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:L,attributeDivisors:X,object:P,attributes:{},index:null}}function g(P,F,L,X){const D=a.attributes,K=F.attributes;let Y=0;const q=L.getAttributes();for(const Z in q)if(q[Z].location>=0){const oe=D[Z];let B=K[Z];if(B===void 0&&(Z==="instanceMatrix"&&P.instanceMatrix&&(B=P.instanceMatrix),Z==="instanceColor"&&P.instanceColor&&(B=P.instanceColor)),oe===void 0||oe.attribute!==B||B&&oe.data!==B.data)return!0;Y++}return a.attributesNum!==Y||a.index!==X}function x(P,F,L,X){const D={},K=F.attributes;let Y=0;const q=L.getAttributes();for(const Z in q)if(q[Z].location>=0){let oe=K[Z];oe===void 0&&(Z==="instanceMatrix"&&P.instanceMatrix&&(oe=P.instanceMatrix),Z==="instanceColor"&&P.instanceColor&&(oe=P.instanceColor));const B={};B.attribute=oe,oe&&oe.data&&(B.data=oe.data),D[Z]=B,Y++}a.attributes=D,a.attributesNum=Y,a.index=X}function y(){const P=a.newAttributes;for(let F=0,L=P.length;F<L;F++)P[F]=0}function b(P){v(P,0)}function v(P,F){const L=a.newAttributes,X=a.enabledAttributes,D=a.attributeDivisors;L[P]=1,X[P]===0&&(t.enableVertexAttribArray(P),X[P]=1),D[P]!==F&&(t.vertexAttribDivisor(P,F),D[P]=F)}function M(){const P=a.newAttributes,F=a.enabledAttributes;for(let L=0,X=F.length;L<X;L++)F[L]!==P[L]&&(t.disableVertexAttribArray(L),F[L]=0)}function S(P,F,L,X,D,K,Y){Y===!0?t.vertexAttribIPointer(P,F,L,D,K):t.vertexAttribPointer(P,F,L,X,D,K)}function A(P,F,L,X){y();const D=X.attributes,K=L.getAttributes(),Y=F.defaultAttributeValues;for(const q in K){const Z=K[q];if(Z.location>=0){let re=D[q];if(re===void 0&&(q==="instanceMatrix"&&P.instanceMatrix&&(re=P.instanceMatrix),q==="instanceColor"&&P.instanceColor&&(re=P.instanceColor)),re!==void 0){const oe=re.normalized,B=re.itemSize,G=e.get(re);if(G===void 0)continue;const J=G.buffer,te=G.type,ae=G.bytesPerElement,de=te===t.INT||te===t.UNSIGNED_INT||re.gpuType===fO;if(re.isInterleavedBufferAttribute){const fe=re.data,Ae=fe.stride,ge=re.offset;if(fe.isInstancedInterleavedBuffer){for(let Me=0;Me<Z.locationSize;Me++)v(Z.location+Me,fe.meshPerAttribute);P.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=fe.meshPerAttribute*fe.count)}else for(let Me=0;Me<Z.locationSize;Me++)b(Z.location+Me);t.bindBuffer(t.ARRAY_BUFFER,J);for(let Me=0;Me<Z.locationSize;Me++)S(Z.location+Me,B/Z.locationSize,te,oe,Ae*ae,(ge+B/Z.locationSize*Me)*ae,de)}else{if(re.isInstancedBufferAttribute){for(let fe=0;fe<Z.locationSize;fe++)v(Z.location+fe,re.meshPerAttribute);P.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let fe=0;fe<Z.locationSize;fe++)b(Z.location+fe);t.bindBuffer(t.ARRAY_BUFFER,J);for(let fe=0;fe<Z.locationSize;fe++)S(Z.location+fe,B/Z.locationSize,te,oe,B*ae,B/Z.locationSize*fe*ae,de)}}else if(Y!==void 0){const oe=Y[q];if(oe!==void 0)switch(oe.length){case 2:t.vertexAttrib2fv(Z.location,oe);break;case 3:t.vertexAttrib3fv(Z.location,oe);break;case 4:t.vertexAttrib4fv(Z.location,oe);break;default:t.vertexAttrib1fv(Z.location,oe)}}}}M()}function E(){R();for(const P in r){const F=r[P];for(const L in F){const X=F[L];for(const D in X)d(X[D].object),delete X[D];delete F[L]}delete r[P]}}function k(P){if(r[P.id]===void 0)return;const F=r[P.id];for(const L in F){const X=F[L];for(const D in X)d(X[D].object),delete X[D];delete F[L]}delete r[P.id]}function C(P){for(const F in r){const L=r[F];if(L[P.id]===void 0)continue;const X=L[P.id];for(const D in X)d(X[D].object),delete X[D];delete L[P.id]}}function R(){T(),o=!0,a!==i&&(a=i,u(a.object))}function T(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:R,resetDefaultState:T,dispose:E,releaseStatesOfGeometry:k,releaseStatesOfProgram:C,initAttributes:y,enableAttribute:b,disableUnusedAttributes:M}}function uDe(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 g=0;for(let x=0;x<f;x++)g+=d[x];n.update(g,r,1)}function c(u,d,f,m){if(f===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let x=0;x<u.length;x++)o(u[x],d[x],m[x]);else{g.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 dDe(t,e,n,r){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(C){return!(C!==Ko&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(C){const R=C===Vg&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==zl&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==Bc&&!R)}function c(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let u=n.precision!==void 0?n.precision:"highp";const d=c(u);d!==u&&(ln("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,m=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),g=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),M=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),S=t.getParameter(t.MAX_VARYING_VECTORS),A=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),E=x>0,k=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:m,maxTextures:g,maxVertexTextures:x,maxTextureSize:y,maxCubemapSize:b,maxAttributes:v,maxVertexUniforms:M,maxVaryings:S,maxFragmentUniforms:A,vertexTextures:E,maxSamples:k}}function hDe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new id,l=new Sn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,m){const g=f.length!==0||m||r!==0||i;return i=m,r=f.length,g},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,g){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 M=a?0:r,S=M*4;let A=v.clippingState||null;c.value=A,A=d(x,m,S,g);for(let E=0;E!==S;++E)A[E]=n[E];v.clippingState=A,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=M}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,m,g,x){const y=f!==null?f.length:0;let b=null;if(y!==0){if(b=c.value,x!==!0||b===null){const v=g+y*4,M=m.matrixWorldInverse;l.getNormalMatrix(M),(b===null||b.length<v)&&(b=new Float32Array(v));for(let S=0,A=g;S!==y;++S,A+=4)o.copy(f[S]).applyMatrix4(M,l),o.normal.toArray(b,A),b[A+3]=o.constant}c.value=b,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,b}}function fDe(t){let e=new WeakMap;function n(o,l){return l===iP?o.mapping=ug:l===aP&&(o.mapping=dg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===iP||l===aP)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 l3e(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 pd=4,UH=[.125,.215,.35,.446,.526,.582],Fh=20,mDe=256,ab=new iJ,zH=new Tn;let VC=null,GC=0,WC=0,qC=!1;const pDe=new at;let BH=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=pDe}=a;VC=this._renderer.getRenderTarget(),GC=this._renderer.getActiveCubeFace(),WC=this._renderer.getActiveMipmapLevel(),qC=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=VH(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=HH(),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(VC,GC,WC),this._renderer.xr.enabled=qC,e.scissorTest=!1,qm(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===ug||e.mapping===dg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),VC=this._renderer.getRenderTarget(),GC=this._renderer.getActiveCubeFace(),WC=this._renderer.getActiveMipmapLevel(),qC=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:_o,minFilter:_o,generateMipmaps:!1,type:Vg,format:Ko,colorSpace:hg,depthBuffer:!1},i=$H(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=$H(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=gDe(a)),this._blurMaterial=bDe(a,e,n),this._ggxMaterial=xDe(a,e,n)}return i}_compileMaterial(e){const n=new Bl(new Xl,e);this._renderer.compile(n,ab)}_sceneToCubeUV(e,n,r,i,a){const c=new po(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,m=f.autoClear,g=f.toneMapping;f.getClearColor(zH),f.toneMapping=Ed,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Bl(new SO,new wO({name:"PMREM.Background",side:fs,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,b=y.material;let v=!1;const M=e.background;M?M.isColor&&(b.color.copy(M),e.background=null,v=!0):(b.color.copy(zH),v=!0);for(let S=0;S<6;S++){const A=S%3;A===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)):A===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;qm(i,A*E,S>2?E:0,E,E),f.setRenderTarget(i),v&&f.render(y,c),f.render(e,c)}f.toneMapping=g,f.autoClear=m,e.background=M}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===ug||e.mapping===dg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=VH()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=HH());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;qm(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,ab)}_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,g=f*m,{_lodMax:x}=this,y=this._sizeLods[r],b=3*y*(r>x-pd?r-x+pd:0),v=4*(this._cubeSize-y);c.envMap.value=e.texture,c.roughness.value=g,c.mipInt.value=x-n,qm(a,b,v,3*y,2*y),i.setRenderTarget(a),i.render(l,ab),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=x-r,qm(e,b,v,3*y,2*y),i.setRenderTarget(e),i.render(l,ab)}_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"&&ai("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const m=u.uniforms,g=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*g):2*Math.PI/(2*Fh-1),y=a/x,b=isFinite(a)?1+Math.floor(d*y):Fh;b>Fh&&ln(`sigmaRadians, ${a}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${Fh}`);const v=[];let M=0;for(let C=0;C<Fh;++C){const R=C/y,T=Math.exp(-R*R/2);v.push(T),C===0?M+=T:C<b&&(M+=2*T)}for(let C=0;C<v.length;C++)v[C]=v[C]/M;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 A=this._sizeLods[i],E=3*A*(i>S-pd?i-S+pd:0),k=4*(this._cubeSize-A);qm(n,E,k,3*A,2*A),c.setRenderTarget(n),c.render(f,ab)}};function gDe(t){const e=[],n=[],r=[];let i=t;const a=t-pd+1+UH.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-pd?c=UH[o-t+pd-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],g=6,x=6,y=3,b=2,v=1,M=new Float32Array(y*x*g),S=new Float32Array(b*x*g),A=new Float32Array(v*x*g);for(let k=0;k<g;k++){const C=k%3*2/3-1,R=k>2?0:-1,T=[C,R,0,C+2/3,R,0,C+2/3,R+1,0,C,R,0,C+2/3,R+1,0,C,R+1,0];M.set(T,y*x*k),S.set(m,b*x*k);const P=[k,k,k,k,k,k];A.set(P,v*x*k)}const E=new Xl;E.setAttribute("position",new wo(M,y)),E.setAttribute("uv",new wo(S,b)),E.setAttribute("faceIndex",new wo(A,v)),r.push(new Bl(E,null)),i>pd&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function $H(t,e,n){const r=new Df(t,e,n);return r.texture.mapping=DM,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function qm(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function xDe(t,e,n){return new lu({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:mDe,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:LM(),fragmentShader:`
- precision highp float;
- precision highp int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform float roughness;
- uniform float mipInt;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- #define PI 3.14159265359
- // Van der Corput radical inverse
- float radicalInverse_VdC(uint bits) {
- bits = (bits << 16u) | (bits >> 16u);
- bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
- bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
- bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
- bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
- return float(bits) * 2.3283064365386963e-10; // / 0x100000000
- }
- // Hammersley sequence
- vec2 hammersley(uint i, uint N) {
- return vec2(float(i) / float(N), radicalInverse_VdC(i));
- }
- // GGX VNDF importance sampling (Eric Heitz 2018)
- // "Sampling the GGX Distribution of Visible Normals"
- // https://jcgt.org/published/0007/04/01/
- vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
- float alpha = roughness * roughness;
- // Section 3.2: Transform view direction to hemisphere configuration
- vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
- // Section 4.1: Orthonormal basis
- float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
- vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
- vec3 T2 = cross(Vh, T1);
- // Section 4.2: Parameterization of projected area
- float r = sqrt(Xi.x);
- float phi = 2.0 * PI * Xi.y;
- float t1 = r * cos(phi);
- float t2 = r * sin(phi);
- float s = 0.5 * (1.0 + Vh.z);
- t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
- // Section 4.3: Reprojection onto hemisphere
- vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
- // Section 3.4: Transform back to ellipsoid configuration
- return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
- }
- void main() {
- vec3 N = normalize(vOutputDirection);
- vec3 V = N; // Assume view direction equals normal for pre-filtering
- vec3 prefilteredColor = vec3(0.0);
- float totalWeight = 0.0;
- // For very low roughness, just sample the environment directly
- if (roughness < 0.001) {
- gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
- return;
- }
- // Tangent space basis for VNDF sampling
- vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
- vec3 tangent = normalize(cross(up, N));
- vec3 bitangent = cross(N, tangent);
- for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
- vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
- // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
- vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
- // Transform H back to world space
- vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
- vec3 L = normalize(2.0 * dot(V, H) * H - V);
- float NdotL = max(dot(N, L), 0.0);
- if(NdotL > 0.0) {
- // Sample environment at fixed mip level
- // VNDF importance sampling handles the distribution filtering
- vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
- // Weight by NdotL for the split-sum approximation
- // VNDF PDF naturally accounts for the visible microfacet distribution
- prefilteredColor += sampleColor * NdotL;
- totalWeight += NdotL;
- }
- }
- if (totalWeight > 0.0) {
- prefilteredColor = prefilteredColor / totalWeight;
- }
- gl_FragColor = vec4(prefilteredColor, 1.0);
- }
- `,blending:qc,depthTest:!1,depthWrite:!1})}function bDe(t,e,n){const r=new Float32Array(Fh),i=new at(0,1,0);return new lu({name:"SphericalGaussianBlur",defines:{n:Fh,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:LM(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:qc,depthTest:!1,depthWrite:!1})}function HH(){return new lu({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:LM(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:qc,depthTest:!1,depthWrite:!1})}function VH(){return new lu({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:LM(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:qc,depthTest:!1,depthWrite:!1})}function LM(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function yDe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===iP||c===aP,d=c===ug||c===dg;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 BH(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 g=l.image;return u&&g&&g.height>0||d&&g&&i(g)?(n===null&&(n=new BH(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 vDe(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&&A0("WebGLRenderer: "+r+" extension not supported."),i}}}function _De(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 g=a.get(m);g&&(e.remove(g),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 g in m)e.update(m[g],t.ARRAY_BUFFER)}function u(f){const m=[],g=f.index,x=f.attributes.position;let y=0;if(g!==null){const M=g.array;y=g.version;for(let S=0,A=M.length;S<A;S+=3){const E=M[S+0],k=M[S+1],C=M[S+2];m.push(E,k,k,C,C,E)}}else if(x!==void 0){const M=x.array;y=x.version;for(let S=0,A=M.length/3-1;S<A;S+=3){const E=S+0,k=S+1,C=S+2;m.push(E,k,k,C,C,E)}}else return;const b=new(IZ(m)?qZ:WZ)(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 g=f.index;g!==null&&m.version<g.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function wDe(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,g){t.drawElements(r,g,a,m*o),n.update(g,r,1)}function u(m,g,x){x!==0&&(t.drawElementsInstanced(r,g,a,m*o,x),n.update(g,r,x))}function d(m,g,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,g,0,a,m,0,x);let b=0;for(let v=0;v<x;v++)b+=g[v];n.update(b,r,1)}function f(m,g,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,g[v],y[v]);else{b.multiDrawElementsInstancedWEBGL(r,g,0,a,m,0,y,0,x);let v=0;for(let M=0;M<x;M++)v+=g[M]*y[M];n.update(v,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function SDe(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:ai("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 MDe(t,e,n){const r=new WeakMap,i=new pi;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 P=function(){R.dispose(),r.delete(l),l.removeEventListener("dispose",P)};var g=P;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||[],M=l.morphAttributes.normal||[],S=l.morphAttributes.color||[];let A=0;x===!0&&(A=1),y===!0&&(A=2),b===!0&&(A=3);let E=l.attributes.position.count*A,k=1;E>e.maxTextureSize&&(k=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);const C=new Float32Array(E*k*4*f),R=new $Z(C,E,k,f);R.type=Bc,R.needsUpdate=!0;const T=A*4;for(let F=0;F<f;F++){const L=v[F],X=M[F],D=S[F],K=E*k*4*F;for(let Y=0;Y<L.count;Y++){const q=Y*T;x===!0&&(i.fromBufferAttribute(L,Y),C[K+q+0]=i.x,C[K+q+1]=i.y,C[K+q+2]=i.z,C[K+q+3]=0),y===!0&&(i.fromBufferAttribute(X,Y),C[K+q+4]=i.x,C[K+q+5]=i.y,C[K+q+6]=i.z,C[K+q+7]=0),b===!0&&(i.fromBufferAttribute(D,Y),C[K+q+8]=i.x,C[K+q+9]=i.y,C[K+q+10]=i.z,C[K+q+11]=D.itemSize===4?i.w:1)}}m={count:f,texture:R,size:new vn(E,k)},r.set(l,m),l.addEventListener("dispose",P)}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 NDe(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 sJ=new cl,GH=new eJ(1,1),oJ=new $Z,lJ=new Gje,cJ=new ZZ,WH=[],qH=[],KH=new Float32Array(16),XH=new Float32Array(9),YH=new Float32Array(4);function Wg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=WH[i];if(a===void 0&&(a=new Float32Array(i),WH[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 Ai(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 Ti(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function IM(t,e){let n=qH[e];n===void 0&&(n=new Int32Array(e),qH[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function EDe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function ADe(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(Ai(n,e))return;t.uniform2fv(this.addr,e),Ti(n,e)}}function TDe(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(Ai(n,e))return;t.uniform3fv(this.addr,e),Ti(n,e)}}function CDe(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(Ai(n,e))return;t.uniform4fv(this.addr,e),Ti(n,e)}}function kDe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ai(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Ti(n,e)}else{if(Ai(n,r))return;YH.set(r),t.uniformMatrix2fv(this.addr,!1,YH),Ti(n,r)}}function jDe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ai(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Ti(n,e)}else{if(Ai(n,r))return;XH.set(r),t.uniformMatrix3fv(this.addr,!1,XH),Ti(n,r)}}function PDe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ai(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Ti(n,e)}else{if(Ai(n,r))return;KH.set(r),t.uniformMatrix4fv(this.addr,!1,KH),Ti(n,r)}}function RDe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function DDe(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(Ai(n,e))return;t.uniform2iv(this.addr,e),Ti(n,e)}}function ODe(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(Ai(n,e))return;t.uniform3iv(this.addr,e),Ti(n,e)}}function LDe(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(Ai(n,e))return;t.uniform4iv(this.addr,e),Ti(n,e)}}function IDe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function FDe(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(Ai(n,e))return;t.uniform2uiv(this.addr,e),Ti(n,e)}}function UDe(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(Ai(n,e))return;t.uniform3uiv(this.addr,e),Ti(n,e)}}function zDe(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(Ai(n,e))return;t.uniform4uiv(this.addr,e),Ti(n,e)}}function BDe(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?(GH.compareFunction=LZ,a=GH):a=sJ,n.setTexture2D(e||a,i)}function $De(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||lJ,i)}function HDe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||cJ,i)}function VDe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||oJ,i)}function GDe(t){switch(t){case 5126:return EDe;case 35664:return ADe;case 35665:return TDe;case 35666:return CDe;case 35674:return kDe;case 35675:return jDe;case 35676:return PDe;case 5124:case 35670:return RDe;case 35667:case 35671:return DDe;case 35668:case 35672:return ODe;case 35669:case 35673:return LDe;case 5125:return IDe;case 36294:return FDe;case 36295:return UDe;case 36296:return zDe;case 35678:case 36198:case 36298:case 36306:case 35682:return BDe;case 35679:case 36299:case 36307:return $De;case 35680:case 36300:case 36308:case 36293:return HDe;case 36289:case 36303:case 36311:case 36292:return VDe}}function WDe(t,e){t.uniform1fv(this.addr,e)}function qDe(t,e){const n=Wg(e,this.size,2);t.uniform2fv(this.addr,n)}function KDe(t,e){const n=Wg(e,this.size,3);t.uniform3fv(this.addr,n)}function XDe(t,e){const n=Wg(e,this.size,4);t.uniform4fv(this.addr,n)}function YDe(t,e){const n=Wg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function QDe(t,e){const n=Wg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function ZDe(t,e){const n=Wg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function JDe(t,e){t.uniform1iv(this.addr,e)}function e4e(t,e){t.uniform2iv(this.addr,e)}function t4e(t,e){t.uniform3iv(this.addr,e)}function n4e(t,e){t.uniform4iv(this.addr,e)}function r4e(t,e){t.uniform1uiv(this.addr,e)}function i4e(t,e){t.uniform2uiv(this.addr,e)}function a4e(t,e){t.uniform3uiv(this.addr,e)}function s4e(t,e){t.uniform4uiv(this.addr,e)}function o4e(t,e,n){const r=this.cache,i=e.length,a=IM(n,i);Ai(r,a)||(t.uniform1iv(this.addr,a),Ti(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||sJ,a[o])}function l4e(t,e,n){const r=this.cache,i=e.length,a=IM(n,i);Ai(r,a)||(t.uniform1iv(this.addr,a),Ti(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||lJ,a[o])}function c4e(t,e,n){const r=this.cache,i=e.length,a=IM(n,i);Ai(r,a)||(t.uniform1iv(this.addr,a),Ti(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||cJ,a[o])}function u4e(t,e,n){const r=this.cache,i=e.length,a=IM(n,i);Ai(r,a)||(t.uniform1iv(this.addr,a),Ti(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||oJ,a[o])}function d4e(t){switch(t){case 5126:return WDe;case 35664:return qDe;case 35665:return KDe;case 35666:return XDe;case 35674:return YDe;case 35675:return QDe;case 35676:return ZDe;case 5124:case 35670:return JDe;case 35667:case 35671:return e4e;case 35668:case 35672:return t4e;case 35669:case 35673:return n4e;case 5125:return r4e;case 36294:return i4e;case 36295:return a4e;case 36296:return s4e;case 35678:case 36198:case 36298:case 36306:case 35682:return o4e;case 35679:case 36299:case 36307:return l4e;case 35680:case 36300:case 36308:case 36293:return c4e;case 36289:case 36303:case 36311:case 36292:return u4e}}let h4e=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=GDe(n.type)}},f4e=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=d4e(n.type)}},m4e=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 KC=/(\w+)(\])?(\[|\.)?/g;function QH(t,e){t.seq.push(e),t.map[e.id]=e}function p4e(t,e,n){const r=t.name,i=r.length;for(KC.lastIndex=0;;){const a=KC.exec(r),o=KC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){QH(n,u===void 0?new h4e(l,t,e):new f4e(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new m4e(l),QH(n,f)),n=f}}}let X1=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);p4e(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 ZH(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const g4e=37297;let x4e=0;function b4e(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let o=i;o<a;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
- `)}const JH=new Sn;function y4e(t){zn._getMatrix(JH,zn.workingColorSpace,t);const e=`mat3( ${JH.elements.map(n=>n.toFixed(4))} )`;switch(zn.getTransfer(t)){case mS:return[e,"LinearTransferOETF"];case sr:return[e,"sRGBTransferOETF"];default:return ln("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function eV(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),a=(t.getShaderInfoLog(e)||"").trim();if(r&&a==="")return"";const o=/ERROR: 0:(\d+)/.exec(a);if(o){const l=parseInt(o[1]);return n.toUpperCase()+`
- `+a+`
- `+b4e(t.getShaderSource(e),l)}else return a}function v4e(t,e){const n=y4e(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function _4e(t,e){let n;switch(e){case bje:n="Linear";break;case yje:n="Reinhard";break;case vje:n="Cineon";break;case _je:n="ACESFilmic";break;case Sje:n="AgX";break;case Mje:n="Neutral";break;case wje:n="Custom";break;default:ln("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const O_=new at;function w4e(){zn.getLuminanceCoefficients(O_);const t=O_.x.toFixed(4),e=O_.y.toFixed(4),n=O_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function S4e(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(_b).join(`
- `)}function M4e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function N4e(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 _b(t){return t!==""}function tV(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 nV(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const E4e=/^[ \t]*#include +<([\w\d./]+)>/gm;function FP(t){return t.replace(E4e,T4e)}const A4e=new Map;function T4e(t,e){let n=bn[e];if(n===void 0){const r=A4e.get(e);if(r!==void 0)n=bn[r],ln('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return FP(n)}const C4e=/#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 rV(t){return t.replace(C4e,k4e)}function k4e(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 iV(t){let e=`precision ${t.precision} float;
- precision ${t.precision} int;
- precision ${t.precision} sampler2D;
- precision ${t.precision} samplerCube;
- precision ${t.precision} sampler3D;
- precision ${t.precision} sampler2DArray;
- precision ${t.precision} sampler2DShadow;
- precision ${t.precision} samplerCubeShadow;
- precision ${t.precision} sampler2DArrayShadow;
- precision ${t.precision} isampler2D;
- precision ${t.precision} isampler3D;
- precision ${t.precision} isamplerCube;
- precision ${t.precision} isampler2DArray;
- precision ${t.precision} usampler2D;
- precision ${t.precision} usampler3D;
- precision ${t.precision} usamplerCube;
- precision ${t.precision} usampler2DArray;
- `;return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function j4e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===EZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Qke?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Tc&&(e="SHADOWMAP_TYPE_VSM"),e}function P4e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case ug:case dg:e="ENVMAP_TYPE_CUBE";break;case DM:e="ENVMAP_TYPE_CUBE_UV";break}return e}function R4e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case dg:e="ENVMAP_MODE_REFRACTION";break}return e}function D4e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case hO:e="ENVMAP_BLENDING_MULTIPLY";break;case gje:e="ENVMAP_BLENDING_MIX";break;case xje:e="ENVMAP_BLENDING_ADD";break}return e}function O4e(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 L4e(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=j4e(n),u=P4e(n),d=R4e(n),f=D4e(n),m=O4e(n),g=S4e(n),x=M4e(a),y=i.createProgram();let b,v,M=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(_b).join(`
- `),b.length>0&&(b+=`
- `),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(_b).join(`
- `),v.length>0&&(v+=`
- `)):(b=[iV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(_b).join(`
- `),v=[iV(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!==Ed?"#define TONE_MAPPING":"",n.toneMapping!==Ed?bn.tonemapping_pars_fragment:"",n.toneMapping!==Ed?_4e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",bn.colorspace_pars_fragment,v4e("linearToOutputTexel",n.outputColorSpace),w4e(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(_b).join(`
- `)),o=FP(o),o=tV(o,n),o=nV(o,n),l=FP(l),l=tV(l,n),l=nV(l,n),o=rV(o),l=rV(l),n.isRawShaderMaterial!==!0&&(M=`#version 300 es
- `,b=[g,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+b,v=["#define varying in",n.glslVersion===dH?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===dH?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
- `)+`
- `+v);const S=M+b+o,A=M+v+l,E=ZH(i,i.VERTEX_SHADER,S),k=ZH(i,i.FRAGMENT_SHADER,A);i.attachShader(y,E),i.attachShader(y,k),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function C(F){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(y)||"",X=i.getShaderInfoLog(E)||"",D=i.getShaderInfoLog(k)||"",K=L.trim(),Y=X.trim(),q=D.trim();let Z=!0,re=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(Z=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,E,k);else{const oe=eV(i,E,"vertex"),B=eV(i,k,"fragment");ai("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Material Name: `+F.name+`
- Material Type: `+F.type+`
- Program Info Log: `+K+`
- `+oe+`
- `+B)}else K!==""?ln("WebGLProgram: Program Info Log:",K):(Y===""||q==="")&&(re=!1);re&&(F.diagnostics={runnable:Z,programLog:K,vertexShader:{log:Y,prefix:b},fragmentShader:{log:q,prefix:v}})}i.deleteShader(E),i.deleteShader(k),R=new X1(i,y),T=N4e(i,y)}let R;this.getUniforms=function(){return R===void 0&&C(this),R};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let P=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=i.getProgramParameter(y,g4e)),P},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=x4e++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=E,this.fragmentShader=k,this}let I4e=0,F4e=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 U4e(e),n.set(e,r)),r}},U4e=class{constructor(e){this.id=I4e++,this.code=e,this.usedTimes=0}};function z4e(t,e,n,r,i,a,o){const l=new VZ,c=new F4e,u=new Set,d=[],f=i.logarithmicDepthBuffer,m=i.vertexTextures;let g=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(T){return u.add(T),T===0?"uv":`uv${T}`}function b(T,P,F,L,X){const D=L.fog,K=X.geometry,Y=T.isMeshStandardMaterial?L.environment:null,q=(T.isMeshStandardMaterial?n:e).get(T.envMap||Y),Z=q&&q.mapping===DM?q.image.height:null,re=x[T.type];T.precision!==null&&(g=i.getMaxPrecision(T.precision),g!==T.precision&&ln("WebGLProgram.getParameters:",T.precision,"not supported, using",g,"instead."));const oe=K.morphAttributes.position||K.morphAttributes.normal||K.morphAttributes.color,B=oe!==void 0?oe.length:0;let G=0;K.morphAttributes.position!==void 0&&(G=1),K.morphAttributes.normal!==void 0&&(G=2),K.morphAttributes.color!==void 0&&(G=3);let J,te,ae,de;if(re){const jt=Sl[re];J=jt.vertexShader,te=jt.fragmentShader}else J=T.vertexShader,te=T.fragmentShader,c.update(T),ae=c.getVertexShaderID(T),de=c.getFragmentShaderID(T);const fe=t.getRenderTarget(),Ae=t.state.buffers.depth.getReversed(),ge=X.isInstancedMesh===!0,Me=X.isBatchedMesh===!0,je=!!T.map,ne=!!T.matcap,Ke=!!q,$=!!T.aoMap,z=!!T.lightMap,W=!!T.bumpMap,U=!!T.normalMap,V=!!T.displacementMap,Q=!!T.emissiveMap,Ee=!!T.metalnessMap,Ce=!!T.roughnessMap,Ne=T.anisotropy>0,H=T.clearcoat>0,O=T.dispersion>0,ie=T.iridescence>0,ye=T.sheen>0,_e=T.transmission>0,le=Ne&&!!T.anisotropyMap,ke=H&&!!T.clearcoatMap,Oe=H&&!!T.clearcoatNormalMap,Ze=H&&!!T.clearcoatRoughnessMap,ht=ie&&!!T.iridescenceMap,We=ie&&!!T.iridescenceThicknessMap,he=ye&&!!T.sheenColorMap,rt=ye&&!!T.sheenRoughnessMap,qe=!!T.specularMap,Je=!!T.specularColorMap,ot=!!T.specularIntensityMap,se=_e&&!!T.transmissionMap,$e=_e&&!!T.thicknessMap,be=!!T.gradientMap,Fe=!!T.alphaMap,De=T.alphaTest>0,ve=!!T.alphaHash,He=!!T.extensions;let dt=Ed;T.toneMapped&&(fe===null||fe.isXRRenderTarget===!0)&&(dt=t.toneMapping);const kt={shaderID:re,shaderType:T.type,shaderName:T.name,vertexShader:J,fragmentShader:te,defines:T.defines,customVertexShaderID:ae,customFragmentShaderID:de,isRawShaderMaterial:T.isRawShaderMaterial===!0,glslVersion:T.glslVersion,precision:g,batching:Me,batchingColor:Me&&X._colorsTexture!==null,instancing:ge,instancingColor:ge&&X.instanceColor!==null,instancingMorph:ge&&X.morphTexture!==null,supportsVertexTextures:m,outputColorSpace:fe===null?t.outputColorSpace:fe.isXRRenderTarget===!0?fe.texture.colorSpace:hg,alphaToCoverage:!!T.alphaToCoverage,map:je,matcap:ne,envMap:Ke,envMapMode:Ke&&q.mapping,envMapCubeUVHeight:Z,aoMap:$,lightMap:z,bumpMap:W,normalMap:U,displacementMap:m&&V,emissiveMap:Q,normalMapObjectSpace:U&&T.normalMapType===Tje,normalMapTangentSpace:U&&T.normalMapType===OZ,metalnessMap:Ee,roughnessMap:Ce,anisotropy:Ne,anisotropyMap:le,clearcoat:H,clearcoatMap:ke,clearcoatNormalMap:Oe,clearcoatRoughnessMap:Ze,dispersion:O,iridescence:ie,iridescenceMap:ht,iridescenceThicknessMap:We,sheen:ye,sheenColorMap:he,sheenRoughnessMap:rt,specularMap:qe,specularColorMap:Je,specularIntensityMap:ot,transmission:_e,transmissionMap:se,thicknessMap:$e,gradientMap:be,opaque:T.transparent===!1&&T.blending===zp&&T.alphaToCoverage===!1,alphaMap:Fe,alphaTest:De,alphaHash:ve,combine:T.combine,mapUv:je&&y(T.map.channel),aoMapUv:$&&y(T.aoMap.channel),lightMapUv:z&&y(T.lightMap.channel),bumpMapUv:W&&y(T.bumpMap.channel),normalMapUv:U&&y(T.normalMap.channel),displacementMapUv:V&&y(T.displacementMap.channel),emissiveMapUv:Q&&y(T.emissiveMap.channel),metalnessMapUv:Ee&&y(T.metalnessMap.channel),roughnessMapUv:Ce&&y(T.roughnessMap.channel),anisotropyMapUv:le&&y(T.anisotropyMap.channel),clearcoatMapUv:ke&&y(T.clearcoatMap.channel),clearcoatNormalMapUv:Oe&&y(T.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ze&&y(T.clearcoatRoughnessMap.channel),iridescenceMapUv:ht&&y(T.iridescenceMap.channel),iridescenceThicknessMapUv:We&&y(T.iridescenceThicknessMap.channel),sheenColorMapUv:he&&y(T.sheenColorMap.channel),sheenRoughnessMapUv:rt&&y(T.sheenRoughnessMap.channel),specularMapUv:qe&&y(T.specularMap.channel),specularColorMapUv:Je&&y(T.specularColorMap.channel),specularIntensityMapUv:ot&&y(T.specularIntensityMap.channel),transmissionMapUv:se&&y(T.transmissionMap.channel),thicknessMapUv:$e&&y(T.thicknessMap.channel),alphaMapUv:Fe&&y(T.alphaMap.channel),vertexTangents:!!K.attributes.tangent&&(U||Ne),vertexColors:T.vertexColors,vertexAlphas:T.vertexColors===!0&&!!K.attributes.color&&K.attributes.color.itemSize===4,pointsUvs:X.isPoints===!0&&!!K.attributes.uv&&(je||Fe),fog:!!D,useFog:T.fog===!0,fogExp2:!!D&&D.isFogExp2,flatShading:T.flatShading===!0&&T.wireframe===!1,sizeAttenuation:T.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Ae,skinning:X.isSkinnedMesh===!0,morphTargets:K.morphAttributes.position!==void 0,morphNormals:K.morphAttributes.normal!==void 0,morphColors:K.morphAttributes.color!==void 0,morphTargetsCount:B,morphTextureStride:G,numDirLights:P.directional.length,numPointLights:P.point.length,numSpotLights:P.spot.length,numSpotLightMaps:P.spotLightMap.length,numRectAreaLights:P.rectArea.length,numHemiLights:P.hemi.length,numDirLightShadows:P.directionalShadowMap.length,numPointLightShadows:P.pointShadowMap.length,numSpotLightShadows:P.spotShadowMap.length,numSpotLightShadowsWithMaps:P.numSpotLightShadowsWithMaps,numLightProbes:P.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:T.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:dt,decodeVideoTexture:je&&T.map.isVideoTexture===!0&&zn.getTransfer(T.map.colorSpace)===sr,decodeVideoTextureEmissive:Q&&T.emissiveMap.isVideoTexture===!0&&zn.getTransfer(T.emissiveMap.colorSpace)===sr,premultipliedAlpha:T.premultipliedAlpha,doubleSided:T.side===Ml,flipSided:T.side===fs,useDepthPacking:T.depthPacking>=0,depthPacking:T.depthPacking||0,index0AttributeName:T.index0AttributeName,extensionClipCullDistance:He&&T.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(He&&T.extensions.multiDraw===!0||Me)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:T.customProgramCacheKey()};return kt.vertexUv1s=u.has(1),kt.vertexUv2s=u.has(2),kt.vertexUv3s=u.has(3),u.clear(),kt}function v(T){const P=[];if(T.shaderID?P.push(T.shaderID):(P.push(T.customVertexShaderID),P.push(T.customFragmentShaderID)),T.defines!==void 0)for(const F in T.defines)P.push(F),P.push(T.defines[F]);return T.isRawShaderMaterial===!1&&(M(P,T),S(P,T),P.push(t.outputColorSpace)),P.push(T.customProgramCacheKey),P.join()}function M(T,P){T.push(P.precision),T.push(P.outputColorSpace),T.push(P.envMapMode),T.push(P.envMapCubeUVHeight),T.push(P.mapUv),T.push(P.alphaMapUv),T.push(P.lightMapUv),T.push(P.aoMapUv),T.push(P.bumpMapUv),T.push(P.normalMapUv),T.push(P.displacementMapUv),T.push(P.emissiveMapUv),T.push(P.metalnessMapUv),T.push(P.roughnessMapUv),T.push(P.anisotropyMapUv),T.push(P.clearcoatMapUv),T.push(P.clearcoatNormalMapUv),T.push(P.clearcoatRoughnessMapUv),T.push(P.iridescenceMapUv),T.push(P.iridescenceThicknessMapUv),T.push(P.sheenColorMapUv),T.push(P.sheenRoughnessMapUv),T.push(P.specularMapUv),T.push(P.specularColorMapUv),T.push(P.specularIntensityMapUv),T.push(P.transmissionMapUv),T.push(P.thicknessMapUv),T.push(P.combine),T.push(P.fogExp2),T.push(P.sizeAttenuation),T.push(P.morphTargetsCount),T.push(P.morphAttributeCount),T.push(P.numDirLights),T.push(P.numPointLights),T.push(P.numSpotLights),T.push(P.numSpotLightMaps),T.push(P.numHemiLights),T.push(P.numRectAreaLights),T.push(P.numDirLightShadows),T.push(P.numPointLightShadows),T.push(P.numSpotLightShadows),T.push(P.numSpotLightShadowsWithMaps),T.push(P.numLightProbes),T.push(P.shadowMapType),T.push(P.toneMapping),T.push(P.numClippingPlanes),T.push(P.numClipIntersection),T.push(P.depthPacking)}function S(T,P){l.disableAll(),P.supportsVertexTextures&&l.enable(0),P.instancing&&l.enable(1),P.instancingColor&&l.enable(2),P.instancingMorph&&l.enable(3),P.matcap&&l.enable(4),P.envMap&&l.enable(5),P.normalMapObjectSpace&&l.enable(6),P.normalMapTangentSpace&&l.enable(7),P.clearcoat&&l.enable(8),P.iridescence&&l.enable(9),P.alphaTest&&l.enable(10),P.vertexColors&&l.enable(11),P.vertexAlphas&&l.enable(12),P.vertexUv1s&&l.enable(13),P.vertexUv2s&&l.enable(14),P.vertexUv3s&&l.enable(15),P.vertexTangents&&l.enable(16),P.anisotropy&&l.enable(17),P.alphaHash&&l.enable(18),P.batching&&l.enable(19),P.dispersion&&l.enable(20),P.batchingColor&&l.enable(21),P.gradientMap&&l.enable(22),T.push(l.mask),l.disableAll(),P.fog&&l.enable(0),P.useFog&&l.enable(1),P.flatShading&&l.enable(2),P.logarithmicDepthBuffer&&l.enable(3),P.reversedDepthBuffer&&l.enable(4),P.skinning&&l.enable(5),P.morphTargets&&l.enable(6),P.morphNormals&&l.enable(7),P.morphColors&&l.enable(8),P.premultipliedAlpha&&l.enable(9),P.shadowMapEnabled&&l.enable(10),P.doubleSided&&l.enable(11),P.flipSided&&l.enable(12),P.useDepthPacking&&l.enable(13),P.dithering&&l.enable(14),P.transmission&&l.enable(15),P.sheen&&l.enable(16),P.opaque&&l.enable(17),P.pointsUvs&&l.enable(18),P.decodeVideoTexture&&l.enable(19),P.decodeVideoTextureEmissive&&l.enable(20),P.alphaToCoverage&&l.enable(21),T.push(l.mask)}function A(T){const P=x[T.type];let F;if(P){const L=Sl[P];F=i3e.clone(L.uniforms)}else F=T.uniforms;return F}function E(T,P){let F;for(let L=0,X=d.length;L<X;L++){const D=d[L];if(D.cacheKey===P){F=D,++F.usedTimes;break}}return F===void 0&&(F=new L4e(t,P,T,a),d.push(F)),F}function k(T){if(--T.usedTimes===0){const P=d.indexOf(T);d[P]=d[d.length-1],d.pop(),T.destroy()}}function C(T){c.remove(T)}function R(){c.dispose()}return{getParameters:b,getProgramCacheKey:v,getUniforms:A,acquireProgram:E,releaseProgram:k,releaseShaderCache:C,programs:d,dispose:R}}function B4e(){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 $4e(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 aV(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 sV(){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,g,x,y,b){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:m,material:g,groupOrder:x,renderOrder:f.renderOrder,z:y,group:b},t[e]=v):(v.id=f.id,v.object=f,v.geometry=m,v.material=g,v.groupOrder=x,v.renderOrder=f.renderOrder,v.z=y,v.group=b),e++,v}function l(f,m,g,x,y,b){const v=o(f,m,g,x,y,b);g.transmission>0?r.push(v):g.transparent===!0?i.push(v):n.push(v)}function c(f,m,g,x,y,b){const v=o(f,m,g,x,y,b);g.transmission>0?r.unshift(v):g.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,m){n.length>1&&n.sort(f||$4e),r.length>1&&r.sort(m||aV),i.length>1&&i.sort(m||aV)}function d(){for(let f=e,m=t.length;f<m;f++){const g=t[f];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function H4e(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new sV,t.set(r,[o])):i>=a.length?(o=new sV,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function V4e(){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 at,color:new Tn};break;case"SpotLight":n={position:new at,direction:new at,color:new Tn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new at,color:new Tn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new at,skyColor:new Tn,groundColor:new Tn};break;case"RectAreaLight":n={color:new Tn,position:new at,halfWidth:new at,halfHeight:new at};break}return t[e.id]=n,n}}}function G4e(){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 vn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new vn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new vn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let W4e=0;function q4e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function K4e(t){const e=new V4e,n=G4e(),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 at);const i=new at,a=new vi,o=new vi;function l(u){let d=0,f=0,m=0;for(let T=0;T<9;T++)r.probe[T].set(0,0,0);let g=0,x=0,y=0,b=0,v=0,M=0,S=0,A=0,E=0,k=0,C=0;u.sort(q4e);for(let T=0,P=u.length;T<P;T++){const F=u[T],L=F.color,X=F.intensity,D=F.distance,K=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)d+=L.r*X,f+=L.g*X,m+=L.b*X;else if(F.isLightProbe){for(let Y=0;Y<9;Y++)r.probe[Y].addScaledVector(F.sh.coefficients[Y],X);C++}else if(F.isDirectionalLight){const Y=e.get(F);if(Y.color.copy(F.color).multiplyScalar(F.intensity),F.castShadow){const q=F.shadow,Z=n.get(F);Z.shadowIntensity=q.intensity,Z.shadowBias=q.bias,Z.shadowNormalBias=q.normalBias,Z.shadowRadius=q.radius,Z.shadowMapSize=q.mapSize,r.directionalShadow[g]=Z,r.directionalShadowMap[g]=K,r.directionalShadowMatrix[g]=F.shadow.matrix,M++}r.directional[g]=Y,g++}else if(F.isSpotLight){const Y=e.get(F);Y.position.setFromMatrixPosition(F.matrixWorld),Y.color.copy(L).multiplyScalar(X),Y.distance=D,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&&k++),r.spotLightMatrix[y]=q.matrix,F.castShadow){const Z=n.get(F);Z.shadowIntensity=q.intensity,Z.shadowBias=q.bias,Z.shadowNormalBias=q.normalBias,Z.shadowRadius=q.radius,Z.shadowMapSize=q.mapSize,r.spotShadow[y]=Z,r.spotShadowMap[y]=K,A++}y++}else if(F.isRectAreaLight){const Y=e.get(F);Y.color.copy(L).multiplyScalar(X),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,Z=n.get(F);Z.shadowIntensity=q.intensity,Z.shadowBias=q.bias,Z.shadowNormalBias=q.normalBias,Z.shadowRadius=q.radius,Z.shadowMapSize=q.mapSize,Z.shadowCameraNear=q.camera.near,Z.shadowCameraFar=q.camera.far,r.pointShadow[x]=Z,r.pointShadowMap[x]=K,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(X),Y.groundColor.copy(F.groundColor).multiplyScalar(X),r.hemi[v]=Y,v++}}b>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Dt.LTC_FLOAT_1,r.rectAreaLTC2=Dt.LTC_FLOAT_2):(r.rectAreaLTC1=Dt.LTC_HALF_1,r.rectAreaLTC2=Dt.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=m;const R=r.hash;(R.directionalLength!==g||R.pointLength!==x||R.spotLength!==y||R.rectAreaLength!==b||R.hemiLength!==v||R.numDirectionalShadows!==M||R.numPointShadows!==S||R.numSpotShadows!==A||R.numSpotMaps!==E||R.numLightProbes!==C)&&(r.directional.length=g,r.spot.length=y,r.rectArea.length=b,r.point.length=x,r.hemi.length=v,r.directionalShadow.length=M,r.directionalShadowMap.length=M,r.pointShadow.length=S,r.pointShadowMap.length=S,r.spotShadow.length=A,r.spotShadowMap.length=A,r.directionalShadowMatrix.length=M,r.pointShadowMatrix.length=S,r.spotLightMatrix.length=A+E-k,r.spotLightMap.length=E,r.numSpotLightShadowsWithMaps=k,r.numLightProbes=C,R.directionalLength=g,R.pointLength=x,R.spotLength=y,R.rectAreaLength=b,R.hemiLength=v,R.numDirectionalShadows=M,R.numPointShadows=S,R.numSpotShadows=A,R.numSpotMaps=E,R.numLightProbes=C,r.version=W4e++)}function c(u,d){let f=0,m=0,g=0,x=0,y=0;const b=d.matrixWorldInverse;for(let v=0,M=u.length;v<M;v++){const S=u[v];if(S.isDirectionalLight){const A=r.directional[f];A.direction.setFromMatrixPosition(S.matrixWorld),i.setFromMatrixPosition(S.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(b),f++}else if(S.isSpotLight){const A=r.spot[g];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(b),A.direction.setFromMatrixPosition(S.matrixWorld),i.setFromMatrixPosition(S.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(b),g++}else if(S.isRectAreaLight){const A=r.rectArea[x];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(b),o.identity(),a.copy(S.matrixWorld),a.premultiply(b),o.extractRotation(a),A.halfWidth.set(S.width*.5,0,0),A.halfHeight.set(0,S.height*.5,0),A.halfWidth.applyMatrix4(o),A.halfHeight.applyMatrix4(o),x++}else if(S.isPointLight){const A=r.point[m];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(b),m++}else if(S.isHemisphereLight){const A=r.hemi[y];A.direction.setFromMatrixPosition(S.matrixWorld),A.direction.transformDirection(b),y++}}}return{setup:l,setupView:c,state:r}}function oV(t){const e=new K4e(t),n=[],r=[];function i(d){u.camera=d,n.length=0,r.length=0}function a(d){n.push(d)}function o(d){r.push(d)}function l(){e.setup(n)}function c(d){e.setupView(n,d)}const u={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:u,setupLights:l,setupLightsView:c,pushLight:a,pushShadow:o}}function X4e(t){let e=new WeakMap;function n(i,a=0){const o=e.get(i);let l;return o===void 0?(l=new oV(t),e.set(i,[l])):a>=o.length?(l=new oV(t),o.push(l)):l=o[a],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const Y4e=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,Q4e=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function Z4e(t,e,n){let r=new MO;const i=new vn,a=new vn,o=new pi,l=new b3e({depthPacking:Aje}),c=new y3e,u={},d=n.maxTextureSize,f={[Bd]:fs,[fs]:Bd,[Ml]:Ml},m=new lu({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new vn},radius:{value:4}},vertexShader:Y4e,fragmentShader:Q4e}),g=m.clone();g.defines.HORIZONTAL_PASS=1;const x=new Xl;x.setAttribute("position",new wo(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Bl(x,m),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=EZ;let v=this.type;this.render=function(k,C,R){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||k.length===0)return;const T=t.getRenderTarget(),P=t.getActiveCubeFace(),F=t.getActiveMipmapLevel(),L=t.state;L.setBlending(qc),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 X=v!==Tc&&this.type===Tc,D=v===Tc&&this.type!==Tc;for(let K=0,Y=k.length;K<Y;K++){const q=k[K],Z=q.shadow;if(Z===void 0){ln("WebGLShadowMap:",q,"has no shadow.");continue}if(Z.autoUpdate===!1&&Z.needsUpdate===!1)continue;i.copy(Z.mapSize);const re=Z.getFrameExtents();if(i.multiply(re),a.copy(Z.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/re.x),i.x=a.x*re.x,Z.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/re.y),i.y=a.y*re.y,Z.mapSize.y=a.y)),Z.map===null||X===!0||D===!0){const B=this.type!==Tc?{minFilter:Bs,magFilter:Bs}:{};Z.map!==null&&Z.map.dispose(),Z.map=new Df(i.x,i.y,B),Z.map.texture.name=q.name+".shadowMap",Z.camera.updateProjectionMatrix()}t.setRenderTarget(Z.map),t.clear();const oe=Z.getViewportCount();for(let B=0;B<oe;B++){const G=Z.getViewport(B);o.set(a.x*G.x,a.y*G.y,a.x*G.z,a.y*G.w),L.viewport(o),Z.updateMatrices(q,B),r=Z.getFrustum(),A(C,R,Z.camera,q,this.type)}Z.isPointLightShadow!==!0&&this.type===Tc&&M(Z,R),Z.needsUpdate=!1}v=this.type,b.needsUpdate=!1,t.setRenderTarget(T,P,F)};function M(k,C){const R=e.update(y);m.defines.VSM_SAMPLES!==k.blurSamples&&(m.defines.VSM_SAMPLES=k.blurSamples,g.defines.VSM_SAMPLES=k.blurSamples,m.needsUpdate=!0,g.needsUpdate=!0),k.mapPass===null&&(k.mapPass=new Df(i.x,i.y)),m.uniforms.shadow_pass.value=k.map.texture,m.uniforms.resolution.value=k.mapSize,m.uniforms.radius.value=k.radius,t.setRenderTarget(k.mapPass),t.clear(),t.renderBufferDirect(C,null,R,m,y,null),g.uniforms.shadow_pass.value=k.mapPass.texture,g.uniforms.resolution.value=k.mapSize,g.uniforms.radius.value=k.radius,t.setRenderTarget(k.map),t.clear(),t.renderBufferDirect(C,null,R,g,y,null)}function S(k,C,R,T){let P=null;const F=R.isPointLight===!0?k.customDistanceMaterial:k.customDepthMaterial;if(F!==void 0)P=F;else if(P=R.isPointLight===!0?c:l,t.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0||C.alphaToCoverage===!0){const L=P.uuid,X=C.uuid;let D=u[L];D===void 0&&(D={},u[L]=D);let K=D[X];K===void 0&&(K=P.clone(),D[X]=K,C.addEventListener("dispose",E)),P=K}if(P.visible=C.visible,P.wireframe=C.wireframe,T===Tc?P.side=C.shadowSide!==null?C.shadowSide:C.side:P.side=C.shadowSide!==null?C.shadowSide:f[C.side],P.alphaMap=C.alphaMap,P.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,P.map=C.map,P.clipShadows=C.clipShadows,P.clippingPlanes=C.clippingPlanes,P.clipIntersection=C.clipIntersection,P.displacementMap=C.displacementMap,P.displacementScale=C.displacementScale,P.displacementBias=C.displacementBias,P.wireframeLinewidth=C.wireframeLinewidth,P.linewidth=C.linewidth,R.isPointLight===!0&&P.isMeshDistanceMaterial===!0){const L=t.properties.get(P);L.light=R}return P}function A(k,C,R,T,P){if(k.visible===!1)return;if(k.layers.test(C.layers)&&(k.isMesh||k.isLine||k.isPoints)&&(k.castShadow||k.receiveShadow&&P===Tc)&&(!k.frustumCulled||r.intersectsObject(k))){k.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,k.matrixWorld);const X=e.update(k),D=k.material;if(Array.isArray(D)){const K=X.groups;for(let Y=0,q=K.length;Y<q;Y++){const Z=K[Y],re=D[Z.materialIndex];if(re&&re.visible){const oe=S(k,re,T,P);k.onBeforeShadow(t,k,C,R,X,oe,Z),t.renderBufferDirect(R,null,X,oe,k,Z),k.onAfterShadow(t,k,C,R,X,oe,Z)}}}else if(D.visible){const K=S(k,D,T,P);k.onBeforeShadow(t,k,C,R,X,K,null),t.renderBufferDirect(R,null,X,K,k,null),k.onAfterShadow(t,k,C,R,X,K,null)}}const L=k.children;for(let X=0,D=L.length;X<D;X++)A(L[X],C,R,T,P)}function E(k){k.target.removeEventListener("dispose",E);for(const R in u){const T=u[R],P=k.target.uuid;P in T&&(T[P].dispose(),delete T[P])}}}const J4e={[Q3]:Z3,[J3]:nP,[eP]:rP,[cg]:tP,[Z3]:Q3,[nP]:J3,[rP]:eP,[tP]:cg};function eOe(t,e){function n(){let se=!1;const $e=new pi;let be=null;const Fe=new pi(0,0,0,0);return{setMask:function(De){be!==De&&!se&&(t.colorMask(De,De,De,De),be=De)},setLocked:function(De){se=De},setClear:function(De,ve,He,dt,kt){kt===!0&&(De*=dt,ve*=dt,He*=dt),$e.set(De,ve,He,dt),Fe.equals($e)===!1&&(t.clearColor(De,ve,He,dt),Fe.copy($e))},reset:function(){se=!1,be=null,Fe.set(-1,0,0,0)}}}function r(){let se=!1,$e=!1,be=null,Fe=null,De=null;return{setReversed:function(ve){if($e!==ve){const He=e.get("EXT_clip_control");ve?He.clipControlEXT(He.LOWER_LEFT_EXT,He.ZERO_TO_ONE_EXT):He.clipControlEXT(He.LOWER_LEFT_EXT,He.NEGATIVE_ONE_TO_ONE_EXT),$e=ve;const dt=De;De=null,this.setClear(dt)}},getReversed:function(){return $e},setTest:function(ve){ve?fe(t.DEPTH_TEST):Ae(t.DEPTH_TEST)},setMask:function(ve){be!==ve&&!se&&(t.depthMask(ve),be=ve)},setFunc:function(ve){if($e&&(ve=J4e[ve]),Fe!==ve){switch(ve){case Q3:t.depthFunc(t.NEVER);break;case Z3:t.depthFunc(t.ALWAYS);break;case J3:t.depthFunc(t.LESS);break;case cg:t.depthFunc(t.LEQUAL);break;case eP:t.depthFunc(t.EQUAL);break;case tP:t.depthFunc(t.GEQUAL);break;case nP:t.depthFunc(t.GREATER);break;case rP:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Fe=ve}},setLocked:function(ve){se=ve},setClear:function(ve){De!==ve&&($e&&(ve=1-ve),t.clearDepth(ve),De=ve)},reset:function(){se=!1,be=null,Fe=null,De=null,$e=!1}}}function i(){let se=!1,$e=null,be=null,Fe=null,De=null,ve=null,He=null,dt=null,kt=null;return{setTest:function(jt){se||(jt?fe(t.STENCIL_TEST):Ae(t.STENCIL_TEST))},setMask:function(jt){$e!==jt&&!se&&(t.stencilMask(jt),$e=jt)},setFunc:function(jt,Zt,Rt){(be!==jt||Fe!==Zt||De!==Rt)&&(t.stencilFunc(jt,Zt,Rt),be=jt,Fe=Zt,De=Rt)},setOp:function(jt,Zt,Rt){(ve!==jt||He!==Zt||dt!==Rt)&&(t.stencilOp(jt,Zt,Rt),ve=jt,He=Zt,dt=Rt)},setLocked:function(jt){se=jt},setClear:function(jt){kt!==jt&&(t.clearStencil(jt),kt=jt)},reset:function(){se=!1,$e=null,be=null,Fe=null,De=null,ve=null,He=null,dt=null,kt=null}}}const a=new n,o=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},f={},m=new WeakMap,g=[],x=null,y=!1,b=null,v=null,M=null,S=null,A=null,E=null,k=null,C=new Tn(0,0,0),R=0,T=!1,P=null,F=null,L=null,X=null,D=null;const K=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Y=!1,q=0;const Z=t.getParameter(t.VERSION);Z.indexOf("WebGL")!==-1?(q=parseFloat(/^WebGL (\d)/.exec(Z)[1]),Y=q>=1):Z.indexOf("OpenGL ES")!==-1&&(q=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),Y=q>=2);let re=null,oe={};const B=t.getParameter(t.SCISSOR_BOX),G=t.getParameter(t.VIEWPORT),J=new pi().fromArray(B),te=new pi().fromArray(G);function ae(se,$e,be,Fe){const De=new Uint8Array(4),ve=t.createTexture();t.bindTexture(se,ve),t.texParameteri(se,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(se,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let He=0;He<be;He++)se===t.TEXTURE_3D||se===t.TEXTURE_2D_ARRAY?t.texImage3D($e,0,t.RGBA,1,1,Fe,0,t.RGBA,t.UNSIGNED_BYTE,De):t.texImage2D($e+He,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,De);return ve}const de={};de[t.TEXTURE_2D]=ae(t.TEXTURE_2D,t.TEXTURE_2D,1),de[t.TEXTURE_CUBE_MAP]=ae(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),de[t.TEXTURE_2D_ARRAY]=ae(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),de[t.TEXTURE_3D]=ae(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),o.setClear(1),l.setClear(0),fe(t.DEPTH_TEST),o.setFunc(cg),W(!1),U(aH),fe(t.CULL_FACE),$(qc);function fe(se){d[se]!==!0&&(t.enable(se),d[se]=!0)}function Ae(se){d[se]!==!1&&(t.disable(se),d[se]=!1)}function ge(se,$e){return f[se]!==$e?(t.bindFramebuffer(se,$e),f[se]=$e,se===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=$e),se===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=$e),!0):!1}function Me(se,$e){let be=g,Fe=!1;if(se){be=m.get($e),be===void 0&&(be=[],m.set($e,be));const De=se.textures;if(be.length!==De.length||be[0]!==t.COLOR_ATTACHMENT0){for(let ve=0,He=De.length;ve<He;ve++)be[ve]=t.COLOR_ATTACHMENT0+ve;be.length=De.length,Fe=!0}}else be[0]!==t.BACK&&(be[0]=t.BACK,Fe=!0);Fe&&t.drawBuffers(be)}function je(se){return x!==se?(t.useProgram(se),x=se,!0):!1}const ne={[Ih]:t.FUNC_ADD,[Jke]:t.FUNC_SUBTRACT,[eje]:t.FUNC_REVERSE_SUBTRACT};ne[tje]=t.MIN,ne[nje]=t.MAX;const Ke={[rje]:t.ZERO,[ije]:t.ONE,[aje]:t.SRC_COLOR,[X3]:t.SRC_ALPHA,[dje]:t.SRC_ALPHA_SATURATE,[cje]:t.DST_COLOR,[oje]:t.DST_ALPHA,[sje]:t.ONE_MINUS_SRC_COLOR,[Y3]:t.ONE_MINUS_SRC_ALPHA,[uje]:t.ONE_MINUS_DST_COLOR,[lje]:t.ONE_MINUS_DST_ALPHA,[hje]:t.CONSTANT_COLOR,[fje]:t.ONE_MINUS_CONSTANT_COLOR,[mje]:t.CONSTANT_ALPHA,[pje]:t.ONE_MINUS_CONSTANT_ALPHA};function $(se,$e,be,Fe,De,ve,He,dt,kt,jt){if(se===qc){y===!0&&(Ae(t.BLEND),y=!1);return}if(y===!1&&(fe(t.BLEND),y=!0),se!==Zke){if(se!==b||jt!==T){if((v!==Ih||A!==Ih)&&(t.blendEquation(t.FUNC_ADD),v=Ih,A=Ih),jt)switch(se){case zp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case sH:t.blendFunc(t.ONE,t.ONE);break;case oH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case lH:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:ai("WebGLState: Invalid blending: ",se);break}else switch(se){case zp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case sH:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case oH:ai("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case lH:ai("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ai("WebGLState: Invalid blending: ",se);break}M=null,S=null,E=null,k=null,C.set(0,0,0),R=0,b=se,T=jt}return}De=De||$e,ve=ve||be,He=He||Fe,($e!==v||De!==A)&&(t.blendEquationSeparate(ne[$e],ne[De]),v=$e,A=De),(be!==M||Fe!==S||ve!==E||He!==k)&&(t.blendFuncSeparate(Ke[be],Ke[Fe],Ke[ve],Ke[He]),M=be,S=Fe,E=ve,k=He),(dt.equals(C)===!1||kt!==R)&&(t.blendColor(dt.r,dt.g,dt.b,kt),C.copy(dt),R=kt),b=se,T=!1}function z(se,$e){se.side===Ml?Ae(t.CULL_FACE):fe(t.CULL_FACE);let be=se.side===fs;$e&&(be=!be),W(be),se.blending===zp&&se.transparent===!1?$(qc):$(se.blending,se.blendEquation,se.blendSrc,se.blendDst,se.blendEquationAlpha,se.blendSrcAlpha,se.blendDstAlpha,se.blendColor,se.blendAlpha,se.premultipliedAlpha),o.setFunc(se.depthFunc),o.setTest(se.depthTest),o.setMask(se.depthWrite),a.setMask(se.colorWrite);const Fe=se.stencilWrite;l.setTest(Fe),Fe&&(l.setMask(se.stencilWriteMask),l.setFunc(se.stencilFunc,se.stencilRef,se.stencilFuncMask),l.setOp(se.stencilFail,se.stencilZFail,se.stencilZPass)),Q(se.polygonOffset,se.polygonOffsetFactor,se.polygonOffsetUnits),se.alphaToCoverage===!0?fe(t.SAMPLE_ALPHA_TO_COVERAGE):Ae(t.SAMPLE_ALPHA_TO_COVERAGE)}function W(se){P!==se&&(se?t.frontFace(t.CW):t.frontFace(t.CCW),P=se)}function U(se){se!==Xke?(fe(t.CULL_FACE),se!==F&&(se===aH?t.cullFace(t.BACK):se===Yke?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ae(t.CULL_FACE),F=se}function V(se){se!==L&&(Y&&t.lineWidth(se),L=se)}function Q(se,$e,be){se?(fe(t.POLYGON_OFFSET_FILL),(X!==$e||D!==be)&&(t.polygonOffset($e,be),X=$e,D=be)):Ae(t.POLYGON_OFFSET_FILL)}function Ee(se){se?fe(t.SCISSOR_TEST):Ae(t.SCISSOR_TEST)}function Ce(se){se===void 0&&(se=t.TEXTURE0+K-1),re!==se&&(t.activeTexture(se),re=se)}function Ne(se,$e,be){be===void 0&&(re===null?be=t.TEXTURE0+K-1:be=re);let Fe=oe[be];Fe===void 0&&(Fe={type:void 0,texture:void 0},oe[be]=Fe),(Fe.type!==se||Fe.texture!==$e)&&(re!==be&&(t.activeTexture(be),re=be),t.bindTexture(se,$e||de[se]),Fe.type=se,Fe.texture=$e)}function H(){const se=oe[re];se!==void 0&&se.type!==void 0&&(t.bindTexture(se.type,null),se.type=void 0,se.texture=void 0)}function O(){try{t.compressedTexImage2D(...arguments)}catch(se){se("WebGLState:",se)}}function ie(){try{t.compressedTexImage3D(...arguments)}catch(se){se("WebGLState:",se)}}function ye(){try{t.texSubImage2D(...arguments)}catch(se){se("WebGLState:",se)}}function _e(){try{t.texSubImage3D(...arguments)}catch(se){se("WebGLState:",se)}}function le(){try{t.compressedTexSubImage2D(...arguments)}catch(se){se("WebGLState:",se)}}function ke(){try{t.compressedTexSubImage3D(...arguments)}catch(se){se("WebGLState:",se)}}function Oe(){try{t.texStorage2D(...arguments)}catch(se){se("WebGLState:",se)}}function Ze(){try{t.texStorage3D(...arguments)}catch(se){se("WebGLState:",se)}}function ht(){try{t.texImage2D(...arguments)}catch(se){se("WebGLState:",se)}}function We(){try{t.texImage3D(...arguments)}catch(se){se("WebGLState:",se)}}function he(se){J.equals(se)===!1&&(t.scissor(se.x,se.y,se.z,se.w),J.copy(se))}function rt(se){te.equals(se)===!1&&(t.viewport(se.x,se.y,se.z,se.w),te.copy(se))}function qe(se,$e){let be=u.get($e);be===void 0&&(be=new WeakMap,u.set($e,be));let Fe=be.get(se);Fe===void 0&&(Fe=t.getUniformBlockIndex($e,se.name),be.set(se,Fe))}function Je(se,$e){const Fe=u.get($e).get(se);c.get($e)!==Fe&&(t.uniformBlockBinding($e,Fe,se.__bindingPointIndex),c.set($e,Fe))}function ot(){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={},re=null,oe={},f={},m=new WeakMap,g=[],x=null,y=!1,b=null,v=null,M=null,S=null,A=null,E=null,k=null,C=new Tn(0,0,0),R=0,T=!1,P=null,F=null,L=null,X=null,D=null,J.set(0,0,t.canvas.width,t.canvas.height),te.set(0,0,t.canvas.width,t.canvas.height),a.reset(),o.reset(),l.reset()}return{buffers:{color:a,depth:o,stencil:l},enable:fe,disable:Ae,bindFramebuffer:ge,drawBuffers:Me,useProgram:je,setBlending:$,setMaterial:z,setFlipSided:W,setCullFace:U,setLineWidth:V,setPolygonOffset:Q,setScissorTest:Ee,activeTexture:Ce,bindTexture:Ne,unbindTexture:H,compressedTexImage2D:O,compressedTexImage3D:ie,texImage2D:ht,texImage3D:We,updateUBOMapping:qe,uniformBlockBinding:Je,texStorage2D:Oe,texStorage3D:Ze,texSubImage2D:ye,texSubImage3D:_e,compressedTexSubImage2D:le,compressedTexSubImage3D:ke,scissor:he,viewport:rt,reset:ot}}function tOe(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 vn,d=new WeakMap;let f;const m=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(H,O){return g?new OffscreenCanvas(H,O):gS("canvas")}function y(H,O,ie){let ye=1;const _e=Ne(H);if((_e.width>ie||_e.height>ie)&&(ye=ie/Math.max(_e.width,_e.height)),ye<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 le=Math.floor(ye*_e.width),ke=Math.floor(ye*_e.height);f===void 0&&(f=x(le,ke));const Oe=O?x(le,ke):f;return Oe.width=le,Oe.height=ke,Oe.getContext("2d").drawImage(H,0,0,le,ke),ln("WebGLRenderer: Texture has been resized from ("+_e.width+"x"+_e.height+") to ("+le+"x"+ke+")."),Oe}else return"data"in H&&ln("WebGLRenderer: Image in DataTexture is too big ("+_e.width+"x"+_e.height+")."),H;return H}function b(H){return H.generateMipmaps}function v(H){t.generateMipmap(H)}function M(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,O,ie,ye,_e=!1){if(H!==null){if(t[H]!==void 0)return t[H];ln("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+H+"'")}let le=O;if(O===t.RED&&(ie===t.FLOAT&&(le=t.R32F),ie===t.HALF_FLOAT&&(le=t.R16F),ie===t.UNSIGNED_BYTE&&(le=t.R8)),O===t.RED_INTEGER&&(ie===t.UNSIGNED_BYTE&&(le=t.R8UI),ie===t.UNSIGNED_SHORT&&(le=t.R16UI),ie===t.UNSIGNED_INT&&(le=t.R32UI),ie===t.BYTE&&(le=t.R8I),ie===t.SHORT&&(le=t.R16I),ie===t.INT&&(le=t.R32I)),O===t.RG&&(ie===t.FLOAT&&(le=t.RG32F),ie===t.HALF_FLOAT&&(le=t.RG16F),ie===t.UNSIGNED_BYTE&&(le=t.RG8)),O===t.RG_INTEGER&&(ie===t.UNSIGNED_BYTE&&(le=t.RG8UI),ie===t.UNSIGNED_SHORT&&(le=t.RG16UI),ie===t.UNSIGNED_INT&&(le=t.RG32UI),ie===t.BYTE&&(le=t.RG8I),ie===t.SHORT&&(le=t.RG16I),ie===t.INT&&(le=t.RG32I)),O===t.RGB_INTEGER&&(ie===t.UNSIGNED_BYTE&&(le=t.RGB8UI),ie===t.UNSIGNED_SHORT&&(le=t.RGB16UI),ie===t.UNSIGNED_INT&&(le=t.RGB32UI),ie===t.BYTE&&(le=t.RGB8I),ie===t.SHORT&&(le=t.RGB16I),ie===t.INT&&(le=t.RGB32I)),O===t.RGBA_INTEGER&&(ie===t.UNSIGNED_BYTE&&(le=t.RGBA8UI),ie===t.UNSIGNED_SHORT&&(le=t.RGBA16UI),ie===t.UNSIGNED_INT&&(le=t.RGBA32UI),ie===t.BYTE&&(le=t.RGBA8I),ie===t.SHORT&&(le=t.RGBA16I),ie===t.INT&&(le=t.RGBA32I)),O===t.RGB&&(ie===t.UNSIGNED_INT_5_9_9_9_REV&&(le=t.RGB9_E5),ie===t.UNSIGNED_INT_10F_11F_11F_REV&&(le=t.R11F_G11F_B10F)),O===t.RGBA){const ke=_e?mS:zn.getTransfer(ye);ie===t.FLOAT&&(le=t.RGBA32F),ie===t.HALF_FLOAT&&(le=t.RGBA16F),ie===t.UNSIGNED_BYTE&&(le=ke===sr?t.SRGB8_ALPHA8:t.RGBA8),ie===t.UNSIGNED_SHORT_4_4_4_4&&(le=t.RGBA4),ie===t.UNSIGNED_SHORT_5_5_5_1&&(le=t.RGB5_A1)}return(le===t.R16F||le===t.R32F||le===t.RG16F||le===t.RG32F||le===t.RGBA16F||le===t.RGBA32F)&&e.get("EXT_color_buffer_float"),le}function A(H,O){let ie;return H?O===null||O===Pf||O===M0?ie=t.DEPTH24_STENCIL8:O===Bc?ie=t.DEPTH32F_STENCIL8:O===S0&&(ie=t.DEPTH24_STENCIL8,ln("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):O===null||O===Pf||O===M0?ie=t.DEPTH_COMPONENT24:O===Bc?ie=t.DEPTH_COMPONENT32F:O===S0&&(ie=t.DEPTH_COMPONENT16),ie}function E(H,O){return b(H)===!0||H.isFramebufferTexture&&H.minFilter!==Bs&&H.minFilter!==_o?Math.log2(Math.max(O.width,O.height))+1:H.mipmaps!==void 0&&H.mipmaps.length>0?H.mipmaps.length:H.isCompressedTexture&&Array.isArray(H.image)?O.mipmaps.length:1}function k(H){const O=H.target;O.removeEventListener("dispose",k),R(O),O.isVideoTexture&&d.delete(O)}function C(H){const O=H.target;O.removeEventListener("dispose",C),P(O)}function R(H){const O=r.get(H);if(O.__webglInit===void 0)return;const ie=H.source,ye=m.get(ie);if(ye){const _e=ye[O.__cacheKey];_e.usedTimes--,_e.usedTimes===0&&T(H),Object.keys(ye).length===0&&m.delete(ie)}r.remove(H)}function T(H){const O=r.get(H);t.deleteTexture(O.__webglTexture);const ie=H.source,ye=m.get(ie);delete ye[O.__cacheKey],o.memory.textures--}function P(H){const O=r.get(H);if(H.depthTexture&&(H.depthTexture.dispose(),r.remove(H.depthTexture)),H.isWebGLCubeRenderTarget)for(let ye=0;ye<6;ye++){if(Array.isArray(O.__webglFramebuffer[ye]))for(let _e=0;_e<O.__webglFramebuffer[ye].length;_e++)t.deleteFramebuffer(O.__webglFramebuffer[ye][_e]);else t.deleteFramebuffer(O.__webglFramebuffer[ye]);O.__webglDepthbuffer&&t.deleteRenderbuffer(O.__webglDepthbuffer[ye])}else{if(Array.isArray(O.__webglFramebuffer))for(let ye=0;ye<O.__webglFramebuffer.length;ye++)t.deleteFramebuffer(O.__webglFramebuffer[ye]);else t.deleteFramebuffer(O.__webglFramebuffer);if(O.__webglDepthbuffer&&t.deleteRenderbuffer(O.__webglDepthbuffer),O.__webglMultisampledFramebuffer&&t.deleteFramebuffer(O.__webglMultisampledFramebuffer),O.__webglColorRenderbuffer)for(let ye=0;ye<O.__webglColorRenderbuffer.length;ye++)O.__webglColorRenderbuffer[ye]&&t.deleteRenderbuffer(O.__webglColorRenderbuffer[ye]);O.__webglDepthRenderbuffer&&t.deleteRenderbuffer(O.__webglDepthRenderbuffer)}const ie=H.textures;for(let ye=0,_e=ie.length;ye<_e;ye++){const le=r.get(ie[ye]);le.__webglTexture&&(t.deleteTexture(le.__webglTexture),o.memory.textures--),r.remove(ie[ye])}r.remove(H)}let F=0;function L(){F=0}function X(){const H=F;return H>=i.maxTextures&&ln("WebGLTextures: Trying to use "+H+" texture units while this GPU supports only "+i.maxTextures),F+=1,H}function D(H){const O=[];return O.push(H.wrapS),O.push(H.wrapT),O.push(H.wrapR||0),O.push(H.magFilter),O.push(H.minFilter),O.push(H.anisotropy),O.push(H.internalFormat),O.push(H.format),O.push(H.type),O.push(H.generateMipmaps),O.push(H.premultiplyAlpha),O.push(H.flipY),O.push(H.unpackAlignment),O.push(H.colorSpace),O.join()}function K(H,O){const ie=r.get(H);if(H.isVideoTexture&&Ee(H),H.isRenderTargetTexture===!1&&H.isExternalTexture!==!0&&H.version>0&&ie.__version!==H.version){const ye=H.image;if(ye===null)ln("WebGLRenderer: Texture marked for update but no image data found.");else if(ye.complete===!1)ln("WebGLRenderer: Texture marked for update but image is incomplete");else{de(ie,H,O);return}}else H.isExternalTexture&&(ie.__webglTexture=H.sourceTexture?H.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,ie.__webglTexture,t.TEXTURE0+O)}function Y(H,O){const ie=r.get(H);if(H.isRenderTargetTexture===!1&&H.version>0&&ie.__version!==H.version){de(ie,H,O);return}else H.isExternalTexture&&(ie.__webglTexture=H.sourceTexture?H.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,ie.__webglTexture,t.TEXTURE0+O)}function q(H,O){const ie=r.get(H);if(H.isRenderTargetTexture===!1&&H.version>0&&ie.__version!==H.version){de(ie,H,O);return}n.bindTexture(t.TEXTURE_3D,ie.__webglTexture,t.TEXTURE0+O)}function Z(H,O){const ie=r.get(H);if(H.version>0&&ie.__version!==H.version){fe(ie,H,O);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ie.__webglTexture,t.TEXTURE0+O)}const re={[sP]:t.REPEAT,[zc]:t.CLAMP_TO_EDGE,[oP]:t.MIRRORED_REPEAT},oe={[Bs]:t.NEAREST,[Nje]:t.NEAREST_MIPMAP_NEAREST,[m_]:t.NEAREST_MIPMAP_LINEAR,[_o]:t.LINEAR,[bC]:t.LINEAR_MIPMAP_NEAREST,[Yh]:t.LINEAR_MIPMAP_LINEAR},B={[Cje]:t.NEVER,[Oje]:t.ALWAYS,[kje]:t.LESS,[LZ]:t.LEQUAL,[jje]:t.EQUAL,[Dje]:t.GEQUAL,[Pje]:t.GREATER,[Rje]:t.NOTEQUAL};function G(H,O){if(O.type===Bc&&e.has("OES_texture_float_linear")===!1&&(O.magFilter===_o||O.magFilter===bC||O.magFilter===m_||O.magFilter===Yh||O.minFilter===_o||O.minFilter===bC||O.minFilter===m_||O.minFilter===Yh)&&ln("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,re[O.wrapS]),t.texParameteri(H,t.TEXTURE_WRAP_T,re[O.wrapT]),(H===t.TEXTURE_3D||H===t.TEXTURE_2D_ARRAY)&&t.texParameteri(H,t.TEXTURE_WRAP_R,re[O.wrapR]),t.texParameteri(H,t.TEXTURE_MAG_FILTER,oe[O.magFilter]),t.texParameteri(H,t.TEXTURE_MIN_FILTER,oe[O.minFilter]),O.compareFunction&&(t.texParameteri(H,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(H,t.TEXTURE_COMPARE_FUNC,B[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(O.magFilter===Bs||O.minFilter!==m_&&O.minFilter!==Yh||O.type===Bc&&e.has("OES_texture_float_linear")===!1)return;if(O.anisotropy>1||r.get(O).__currentAnisotropy){const ie=e.get("EXT_texture_filter_anisotropic");t.texParameterf(H,ie.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy}}}function J(H,O){let ie=!1;H.__webglInit===void 0&&(H.__webglInit=!0,O.addEventListener("dispose",k));const ye=O.source;let _e=m.get(ye);_e===void 0&&(_e={},m.set(ye,_e));const le=D(O);if(le!==H.__cacheKey){_e[le]===void 0&&(_e[le]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,ie=!0),_e[le].usedTimes++;const ke=_e[H.__cacheKey];ke!==void 0&&(_e[H.__cacheKey].usedTimes--,ke.usedTimes===0&&T(O)),H.__cacheKey=le,H.__webglTexture=_e[le].texture}return ie}function te(H,O,ie){return Math.floor(Math.floor(H/ie)/O)}function ae(H,O,ie,ye){const le=H.updateRanges;if(le.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,O.width,O.height,ie,ye,O.data);else{le.sort((We,he)=>We.start-he.start);let ke=0;for(let We=1;We<le.length;We++){const he=le[ke],rt=le[We],qe=he.start+he.count,Je=te(rt.start,O.width,4),ot=te(he.start,O.width,4);rt.start<=qe+1&&Je===ot&&te(rt.start+rt.count-1,O.width,4)===Je?he.count=Math.max(he.count,rt.start+rt.count-he.start):(++ke,le[ke]=rt)}le.length=ke+1;const Oe=t.getParameter(t.UNPACK_ROW_LENGTH),Ze=t.getParameter(t.UNPACK_SKIP_PIXELS),ht=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,O.width);for(let We=0,he=le.length;We<he;We++){const rt=le[We],qe=Math.floor(rt.start/4),Je=Math.ceil(rt.count/4),ot=qe%O.width,se=Math.floor(qe/O.width),$e=Je,be=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,ot),t.pixelStorei(t.UNPACK_SKIP_ROWS,se),n.texSubImage2D(t.TEXTURE_2D,0,ot,se,$e,be,ie,ye,O.data)}H.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Oe),t.pixelStorei(t.UNPACK_SKIP_PIXELS,Ze),t.pixelStorei(t.UNPACK_SKIP_ROWS,ht)}}function de(H,O,ie){let ye=t.TEXTURE_2D;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(ye=t.TEXTURE_2D_ARRAY),O.isData3DTexture&&(ye=t.TEXTURE_3D);const _e=J(H,O),le=O.source;n.bindTexture(ye,H.__webglTexture,t.TEXTURE0+ie);const ke=r.get(le);if(le.version!==ke.__version||_e===!0){n.activeTexture(t.TEXTURE0+ie);const Oe=zn.getPrimaries(zn.workingColorSpace),Ze=O.colorSpace===dd?null:zn.getPrimaries(O.colorSpace),ht=O.colorSpace===dd||Oe===Ze?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ht);let We=y(O.image,!1,i.maxTextureSize);We=Ce(O,We);const he=a.convert(O.format,O.colorSpace),rt=a.convert(O.type);let qe=S(O.internalFormat,he,rt,O.colorSpace,O.isVideoTexture);G(ye,O);let Je;const ot=O.mipmaps,se=O.isVideoTexture!==!0,$e=ke.__version===void 0||_e===!0,be=le.dataReady,Fe=E(O,We);if(O.isDepthTexture)qe=A(O.format===E0,O.type),$e&&(se?n.texStorage2D(t.TEXTURE_2D,1,qe,We.width,We.height):n.texImage2D(t.TEXTURE_2D,0,qe,We.width,We.height,0,he,rt,null));else if(O.isDataTexture)if(ot.length>0){se&&$e&&n.texStorage2D(t.TEXTURE_2D,Fe,qe,ot[0].width,ot[0].height);for(let De=0,ve=ot.length;De<ve;De++)Je=ot[De],se?be&&n.texSubImage2D(t.TEXTURE_2D,De,0,0,Je.width,Je.height,he,rt,Je.data):n.texImage2D(t.TEXTURE_2D,De,qe,Je.width,Je.height,0,he,rt,Je.data);O.generateMipmaps=!1}else se?($e&&n.texStorage2D(t.TEXTURE_2D,Fe,qe,We.width,We.height),be&&ae(O,We,he,rt)):n.texImage2D(t.TEXTURE_2D,0,qe,We.width,We.height,0,he,rt,We.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){se&&$e&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Fe,qe,ot[0].width,ot[0].height,We.depth);for(let De=0,ve=ot.length;De<ve;De++)if(Je=ot[De],O.format!==Ko)if(he!==null)if(se){if(be)if(O.layerUpdates.size>0){const He=FH(Je.width,Je.height,O.format,O.type);for(const dt of O.layerUpdates){const kt=Je.data.subarray(dt*He/Je.data.BYTES_PER_ELEMENT,(dt+1)*He/Je.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,De,0,0,dt,Je.width,Je.height,1,he,kt)}O.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,De,0,0,0,Je.width,Je.height,We.depth,he,Je.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,De,qe,Je.width,Je.height,We.depth,0,Je.data,0,0);else ln("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else se?be&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,De,0,0,0,Je.width,Je.height,We.depth,he,rt,Je.data):n.texImage3D(t.TEXTURE_2D_ARRAY,De,qe,Je.width,Je.height,We.depth,0,he,rt,Je.data)}else{se&&$e&&n.texStorage2D(t.TEXTURE_2D,Fe,qe,ot[0].width,ot[0].height);for(let De=0,ve=ot.length;De<ve;De++)Je=ot[De],O.format!==Ko?he!==null?se?be&&n.compressedTexSubImage2D(t.TEXTURE_2D,De,0,0,Je.width,Je.height,he,Je.data):n.compressedTexImage2D(t.TEXTURE_2D,De,qe,Je.width,Je.height,0,Je.data):ln("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):se?be&&n.texSubImage2D(t.TEXTURE_2D,De,0,0,Je.width,Je.height,he,rt,Je.data):n.texImage2D(t.TEXTURE_2D,De,qe,Je.width,Je.height,0,he,rt,Je.data)}else if(O.isDataArrayTexture)if(se){if($e&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Fe,qe,We.width,We.height,We.depth),be)if(O.layerUpdates.size>0){const De=FH(We.width,We.height,O.format,O.type);for(const ve of O.layerUpdates){const He=We.data.subarray(ve*De/We.data.BYTES_PER_ELEMENT,(ve+1)*De/We.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,ve,We.width,We.height,1,he,rt,He)}O.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,We.width,We.height,We.depth,he,rt,We.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,qe,We.width,We.height,We.depth,0,he,rt,We.data);else if(O.isData3DTexture)se?($e&&n.texStorage3D(t.TEXTURE_3D,Fe,qe,We.width,We.height,We.depth),be&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,We.width,We.height,We.depth,he,rt,We.data)):n.texImage3D(t.TEXTURE_3D,0,qe,We.width,We.height,We.depth,0,he,rt,We.data);else if(O.isFramebufferTexture){if($e)if(se)n.texStorage2D(t.TEXTURE_2D,Fe,qe,We.width,We.height);else{let De=We.width,ve=We.height;for(let He=0;He<Fe;He++)n.texImage2D(t.TEXTURE_2D,He,qe,De,ve,0,he,rt,null),De>>=1,ve>>=1}}else if(ot.length>0){if(se&&$e){const De=Ne(ot[0]);n.texStorage2D(t.TEXTURE_2D,Fe,qe,De.width,De.height)}for(let De=0,ve=ot.length;De<ve;De++)Je=ot[De],se?be&&n.texSubImage2D(t.TEXTURE_2D,De,0,0,he,rt,Je):n.texImage2D(t.TEXTURE_2D,De,qe,he,rt,Je);O.generateMipmaps=!1}else if(se){if($e){const De=Ne(We);n.texStorage2D(t.TEXTURE_2D,Fe,qe,De.width,De.height)}be&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,he,rt,We)}else n.texImage2D(t.TEXTURE_2D,0,qe,he,rt,We);b(O)&&v(ye),ke.__version=le.version,O.onUpdate&&O.onUpdate(O)}H.__version=O.version}function fe(H,O,ie){if(O.image.length!==6)return;const ye=J(H,O),_e=O.source;n.bindTexture(t.TEXTURE_CUBE_MAP,H.__webglTexture,t.TEXTURE0+ie);const le=r.get(_e);if(_e.version!==le.__version||ye===!0){n.activeTexture(t.TEXTURE0+ie);const ke=zn.getPrimaries(zn.workingColorSpace),Oe=O.colorSpace===dd?null:zn.getPrimaries(O.colorSpace),Ze=O.colorSpace===dd||ke===Oe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ze);const ht=O.isCompressedTexture||O.image[0].isCompressedTexture,We=O.image[0]&&O.image[0].isDataTexture,he=[];for(let ve=0;ve<6;ve++)!ht&&!We?he[ve]=y(O.image[ve],!0,i.maxCubemapSize):he[ve]=We?O.image[ve].image:O.image[ve],he[ve]=Ce(O,he[ve]);const rt=he[0],qe=a.convert(O.format,O.colorSpace),Je=a.convert(O.type),ot=S(O.internalFormat,qe,Je,O.colorSpace),se=O.isVideoTexture!==!0,$e=le.__version===void 0||ye===!0,be=_e.dataReady;let Fe=E(O,rt);G(t.TEXTURE_CUBE_MAP,O);let De;if(ht){se&&$e&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Fe,ot,rt.width,rt.height);for(let ve=0;ve<6;ve++){De=he[ve].mipmaps;for(let He=0;He<De.length;He++){const dt=De[He];O.format!==Ko?qe!==null?se?be&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,He,0,0,dt.width,dt.height,qe,dt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,He,ot,dt.width,dt.height,0,dt.data):ln("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):se?be&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,He,0,0,dt.width,dt.height,qe,Je,dt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,He,ot,dt.width,dt.height,0,qe,Je,dt.data)}}}else{if(De=O.mipmaps,se&&$e){De.length>0&&Fe++;const ve=Ne(he[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Fe,ot,ve.width,ve.height)}for(let ve=0;ve<6;ve++)if(We){se?be&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,he[ve].width,he[ve].height,qe,Je,he[ve].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,ot,he[ve].width,he[ve].height,0,qe,Je,he[ve].data);for(let He=0;He<De.length;He++){const kt=De[He].image[ve].image;se?be&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,He+1,0,0,kt.width,kt.height,qe,Je,kt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,He+1,ot,kt.width,kt.height,0,qe,Je,kt.data)}}else{se?be&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,qe,Je,he[ve]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,ot,qe,Je,he[ve]);for(let He=0;He<De.length;He++){const dt=De[He];se?be&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,He+1,0,0,qe,Je,dt.image[ve]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,He+1,ot,qe,Je,dt.image[ve])}}}b(O)&&v(t.TEXTURE_CUBE_MAP),le.__version=_e.version,O.onUpdate&&O.onUpdate(O)}H.__version=O.version}function Ae(H,O,ie,ye,_e,le){const ke=a.convert(ie.format,ie.colorSpace),Oe=a.convert(ie.type),Ze=S(ie.internalFormat,ke,Oe,ie.colorSpace),ht=r.get(O),We=r.get(ie);if(We.__renderTarget=O,!ht.__hasExternalTextures){const he=Math.max(1,O.width>>le),rt=Math.max(1,O.height>>le);_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?n.texImage3D(_e,le,Ze,he,rt,O.depth,0,ke,Oe,null):n.texImage2D(_e,le,Ze,he,rt,0,ke,Oe,null)}n.bindFramebuffer(t.FRAMEBUFFER,H),Q(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ye,_e,We.__webglTexture,0,V(O)):(_e===t.TEXTURE_2D||_e>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ye,_e,We.__webglTexture,le),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ge(H,O,ie){if(t.bindRenderbuffer(t.RENDERBUFFER,H),O.depthBuffer){const ye=O.depthTexture,_e=ye&&ye.isDepthTexture?ye.type:null,le=A(O.stencilBuffer,_e),ke=O.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Oe=V(O);Q(O)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Oe,le,O.width,O.height):ie?t.renderbufferStorageMultisample(t.RENDERBUFFER,Oe,le,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,le,O.width,O.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,ke,t.RENDERBUFFER,H)}else{const ye=O.textures;for(let _e=0;_e<ye.length;_e++){const le=ye[_e],ke=a.convert(le.format,le.colorSpace),Oe=a.convert(le.type),Ze=S(le.internalFormat,ke,Oe,le.colorSpace),ht=V(O);ie&&Q(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ht,Ze,O.width,O.height):Q(O)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ht,Ze,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,Ze,O.width,O.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Me(H,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,H),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ye=r.get(O.depthTexture);ye.__renderTarget=O,(!ye.__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),K(O.depthTexture,0);const _e=ye.__webglTexture,le=V(O);if(O.depthTexture.format===N0)Q(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,_e,0,le):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,_e,0);else if(O.depthTexture.format===E0)Q(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,_e,0,le):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,_e,0);else throw new Error("Unknown depthTexture format")}function je(H){const O=r.get(H),ie=H.isWebGLCubeRenderTarget===!0;if(O.__boundDepthTexture!==H.depthTexture){const ye=H.depthTexture;if(O.__depthDisposeCallback&&O.__depthDisposeCallback(),ye){const _e=()=>{delete O.__boundDepthTexture,delete O.__depthDisposeCallback,ye.removeEventListener("dispose",_e)};ye.addEventListener("dispose",_e),O.__depthDisposeCallback=_e}O.__boundDepthTexture=ye}if(H.depthTexture&&!O.__autoAllocateDepthBuffer){if(ie)throw new Error("target.depthTexture not supported in Cube render targets");const ye=H.texture.mipmaps;ye&&ye.length>0?Me(O.__webglFramebuffer[0],H):Me(O.__webglFramebuffer,H)}else if(ie){O.__webglDepthbuffer=[];for(let ye=0;ye<6;ye++)if(n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[ye]),O.__webglDepthbuffer[ye]===void 0)O.__webglDepthbuffer[ye]=t.createRenderbuffer(),ge(O.__webglDepthbuffer[ye],H,!1);else{const _e=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,le=O.__webglDepthbuffer[ye];t.bindRenderbuffer(t.RENDERBUFFER,le),t.framebufferRenderbuffer(t.FRAMEBUFFER,_e,t.RENDERBUFFER,le)}}else{const ye=H.texture.mipmaps;if(ye&&ye.length>0?n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer===void 0)O.__webglDepthbuffer=t.createRenderbuffer(),ge(O.__webglDepthbuffer,H,!1);else{const _e=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,le=O.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,le),t.framebufferRenderbuffer(t.FRAMEBUFFER,_e,t.RENDERBUFFER,le)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function ne(H,O,ie){const ye=r.get(H);O!==void 0&&Ae(ye.__webglFramebuffer,H,H.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ie!==void 0&&je(H)}function Ke(H){const O=H.texture,ie=r.get(H),ye=r.get(O);H.addEventListener("dispose",C);const _e=H.textures,le=H.isWebGLCubeRenderTarget===!0,ke=_e.length>1;if(ke||(ye.__webglTexture===void 0&&(ye.__webglTexture=t.createTexture()),ye.__version=O.version,o.memory.textures++),le){ie.__webglFramebuffer=[];for(let Oe=0;Oe<6;Oe++)if(O.mipmaps&&O.mipmaps.length>0){ie.__webglFramebuffer[Oe]=[];for(let Ze=0;Ze<O.mipmaps.length;Ze++)ie.__webglFramebuffer[Oe][Ze]=t.createFramebuffer()}else ie.__webglFramebuffer[Oe]=t.createFramebuffer()}else{if(O.mipmaps&&O.mipmaps.length>0){ie.__webglFramebuffer=[];for(let Oe=0;Oe<O.mipmaps.length;Oe++)ie.__webglFramebuffer[Oe]=t.createFramebuffer()}else ie.__webglFramebuffer=t.createFramebuffer();if(ke)for(let Oe=0,Ze=_e.length;Oe<Ze;Oe++){const ht=r.get(_e[Oe]);ht.__webglTexture===void 0&&(ht.__webglTexture=t.createTexture(),o.memory.textures++)}if(H.samples>0&&Q(H)===!1){ie.__webglMultisampledFramebuffer=t.createFramebuffer(),ie.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ie.__webglMultisampledFramebuffer);for(let Oe=0;Oe<_e.length;Oe++){const Ze=_e[Oe];ie.__webglColorRenderbuffer[Oe]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ie.__webglColorRenderbuffer[Oe]);const ht=a.convert(Ze.format,Ze.colorSpace),We=a.convert(Ze.type),he=S(Ze.internalFormat,ht,We,Ze.colorSpace,H.isXRRenderTarget===!0),rt=V(H);t.renderbufferStorageMultisample(t.RENDERBUFFER,rt,he,H.width,H.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Oe,t.RENDERBUFFER,ie.__webglColorRenderbuffer[Oe])}t.bindRenderbuffer(t.RENDERBUFFER,null),H.depthBuffer&&(ie.__webglDepthRenderbuffer=t.createRenderbuffer(),ge(ie.__webglDepthRenderbuffer,H,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(le){n.bindTexture(t.TEXTURE_CUBE_MAP,ye.__webglTexture),G(t.TEXTURE_CUBE_MAP,O);for(let Oe=0;Oe<6;Oe++)if(O.mipmaps&&O.mipmaps.length>0)for(let Ze=0;Ze<O.mipmaps.length;Ze++)Ae(ie.__webglFramebuffer[Oe][Ze],H,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ze);else Ae(ie.__webglFramebuffer[Oe],H,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,0);b(O)&&v(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ke){for(let Oe=0,Ze=_e.length;Oe<Ze;Oe++){const ht=_e[Oe],We=r.get(ht);let he=t.TEXTURE_2D;(H.isWebGL3DRenderTarget||H.isWebGLArrayRenderTarget)&&(he=H.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(he,We.__webglTexture),G(he,ht),Ae(ie.__webglFramebuffer,H,ht,t.COLOR_ATTACHMENT0+Oe,he,0),b(ht)&&v(he)}n.unbindTexture()}else{let Oe=t.TEXTURE_2D;if((H.isWebGL3DRenderTarget||H.isWebGLArrayRenderTarget)&&(Oe=H.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Oe,ye.__webglTexture),G(Oe,O),O.mipmaps&&O.mipmaps.length>0)for(let Ze=0;Ze<O.mipmaps.length;Ze++)Ae(ie.__webglFramebuffer[Ze],H,O,t.COLOR_ATTACHMENT0,Oe,Ze);else Ae(ie.__webglFramebuffer,H,O,t.COLOR_ATTACHMENT0,Oe,0);b(O)&&v(Oe),n.unbindTexture()}H.depthBuffer&&je(H)}function $(H){const O=H.textures;for(let ie=0,ye=O.length;ie<ye;ie++){const _e=O[ie];if(b(_e)){const le=M(H),ke=r.get(_e).__webglTexture;n.bindTexture(le,ke),v(le),n.unbindTexture()}}}const z=[],W=[];function U(H){if(H.samples>0){if(Q(H)===!1){const O=H.textures,ie=H.width,ye=H.height;let _e=t.COLOR_BUFFER_BIT;const le=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ke=r.get(H),Oe=O.length>1;if(Oe)for(let ht=0;ht<O.length;ht++)n.bindFramebuffer(t.FRAMEBUFFER,ke.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ht,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,ke.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ht,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,ke.__webglMultisampledFramebuffer);const Ze=H.texture.mipmaps;Ze&&Ze.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ke.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ke.__webglFramebuffer);for(let ht=0;ht<O.length;ht++){if(H.resolveDepthBuffer&&(H.depthBuffer&&(_e|=t.DEPTH_BUFFER_BIT),H.stencilBuffer&&H.resolveStencilBuffer&&(_e|=t.STENCIL_BUFFER_BIT)),Oe){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,ke.__webglColorRenderbuffer[ht]);const We=r.get(O[ht]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,We,0)}t.blitFramebuffer(0,0,ie,ye,0,0,ie,ye,_e,t.NEAREST),c===!0&&(z.length=0,W.length=0,z.push(t.COLOR_ATTACHMENT0+ht),H.depthBuffer&&H.resolveDepthBuffer===!1&&(z.push(le),W.push(le),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,W)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,z))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Oe)for(let ht=0;ht<O.length;ht++){n.bindFramebuffer(t.FRAMEBUFFER,ke.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ht,t.RENDERBUFFER,ke.__webglColorRenderbuffer[ht]);const We=r.get(O[ht]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,ke.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ht,t.TEXTURE_2D,We,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ke.__webglMultisampledFramebuffer)}else if(H.depthBuffer&&H.resolveDepthBuffer===!1&&c){const O=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[O])}}}function V(H){return Math.min(i.maxSamples,H.samples)}function Q(H){const O=r.get(H);return H.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function Ee(H){const O=o.render.frame;d.get(H)!==O&&(d.set(H,O),H.update())}function Ce(H,O){const ie=H.colorSpace,ye=H.format,_e=H.type;return H.isCompressedTexture===!0||H.isVideoTexture===!0||ie!==hg&&ie!==dd&&(zn.getTransfer(ie)===sr?(ye!==Ko||_e!==zl)&&ln("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ai("WebGLTextures: Unsupported texture color space:",ie)),O}function Ne(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=X,this.resetTextureUnits=L,this.setTexture2D=K,this.setTexture2DArray=Y,this.setTexture3D=q,this.setTextureCube=Z,this.rebindTextures=ne,this.setupRenderTarget=Ke,this.updateRenderTargetMipmap=$,this.updateMultisampleRenderTarget=U,this.setupDepthRenderbuffer=je,this.setupFrameBufferTexture=Ae,this.useMultisampledRTT=Q}function nOe(t,e){function n(r,i=dd){let a;const o=zn.getTransfer(i);if(r===zl)return t.UNSIGNED_BYTE;if(r===mO)return t.UNSIGNED_SHORT_4_4_4_4;if(r===pO)return t.UNSIGNED_SHORT_5_5_5_1;if(r===kZ)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===jZ)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===TZ)return t.BYTE;if(r===CZ)return t.SHORT;if(r===S0)return t.UNSIGNED_SHORT;if(r===fO)return t.INT;if(r===Pf)return t.UNSIGNED_INT;if(r===Bc)return t.FLOAT;if(r===Vg)return t.HALF_FLOAT;if(r===PZ)return t.ALPHA;if(r===RZ)return t.RGB;if(r===Ko)return t.RGBA;if(r===N0)return t.DEPTH_COMPONENT;if(r===E0)return t.DEPTH_STENCIL;if(r===DZ)return t.RED;if(r===gO)return t.RED_INTEGER;if(r===xO)return t.RG;if(r===bO)return t.RG_INTEGER;if(r===yO)return t.RGBA_INTEGER;if(r===$1||r===H1||r===V1||r===G1)if(o===sr)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===$1)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===H1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===V1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===G1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===$1)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===H1)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===V1)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===G1)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===lP||r===cP||r===uP||r===dP)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===lP)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===cP)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===uP)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===dP)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===hP||r===fP||r===mP)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===hP||r===fP)return o===sr?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===mP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===pP||r===gP||r===xP||r===bP||r===yP||r===vP||r===_P||r===wP||r===SP||r===MP||r===NP||r===EP||r===AP||r===TP)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===pP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===gP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===xP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===bP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===yP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===vP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===_P)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===wP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===SP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===MP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===NP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===EP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===AP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===TP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===CP||r===kP||r===jP)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===CP)return o===sr?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===kP)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===jP)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===PP||r===RP||r===DP||r===OP)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===PP)return a.COMPRESSED_RED_RGTC1_EXT;if(r===RP)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===DP)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===OP)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===M0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const rOe=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,iOe=`
- uniform sampler2DArray depthColor;
- uniform float depthWidth;
- uniform float depthHeight;
- void main() {
- vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
- if ( coord.x >= 1.0 ) {
- gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
- } else {
- gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
- }
- }`;class aOe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new tJ(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 lu({vertexShader:rOe,fragmentShader:iOe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Bl(new NO(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let sOe=class extends Kf{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,g=null,x=null;const y=typeof XRWebGLBinding<"u",b=new aOe,v={},M=n.getContextAttributes();let S=null,A=null;const E=[],k=[],C=new vn;let R=null;const T=new po;T.viewport=new pi;const P=new po;P.viewport=new pi;const F=[T,P],L=new S3e;let X=null,D=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(de){let fe=E[de];return fe===void 0&&(fe=new zC,E[de]=fe),fe.getTargetRaySpace()},this.getControllerGrip=function(de){let fe=E[de];return fe===void 0&&(fe=new zC,E[de]=fe),fe.getGripSpace()},this.getHand=function(de){let fe=E[de];return fe===void 0&&(fe=new zC,E[de]=fe),fe.getHandSpace()};function K(de){const fe=k.indexOf(de.inputSource);if(fe===-1)return;const Ae=E[fe];Ae!==void 0&&(Ae.update(de.inputSource,de.frame,u||o),Ae.dispatchEvent({type:de.type,data:de.inputSource}))}function Y(){i.removeEventListener("select",K),i.removeEventListener("selectstart",K),i.removeEventListener("selectend",K),i.removeEventListener("squeeze",K),i.removeEventListener("squeezestart",K),i.removeEventListener("squeezeend",K),i.removeEventListener("end",Y),i.removeEventListener("inputsourceschange",q);for(let de=0;de<E.length;de++){const fe=k[de];fe!==null&&(k[de]=null,E[de].disconnect(fe))}X=null,D=null,b.reset();for(const de in v)delete v[de];e.setRenderTarget(S),g=null,m=null,f=null,i=null,A=null,ae.stop(),r.isPresenting=!1,e.setPixelRatio(R),e.setSize(C.width,C.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(de){a=de,r.isPresenting===!0&&ln("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(de){l=de,r.isPresenting===!0&&ln("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(de){u=de},this.getBaseLayer=function(){return m!==null?m:g},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(de){if(i=de,i!==null){if(S=e.getRenderTarget(),i.addEventListener("select",K),i.addEventListener("selectstart",K),i.addEventListener("selectend",K),i.addEventListener("squeeze",K),i.addEventListener("squeezestart",K),i.addEventListener("squeezeend",K),i.addEventListener("end",Y),i.addEventListener("inputsourceschange",q),M.xrCompatible!==!0&&await n.makeXRCompatible(),R=e.getPixelRatio(),e.getSize(C),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ae=null,ge=null,Me=null;M.depth&&(Me=M.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ae=M.stencil?E0:N0,ge=M.stencil?M0:Pf);const je={colorFormat:n.RGBA8,depthFormat:Me,scaleFactor:a};f=this.getBinding(),m=f.createProjectionLayer(je),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),A=new Df(m.textureWidth,m.textureHeight,{format:Ko,type:zl,depthTexture:new eJ(m.textureWidth,m.textureHeight,ge,void 0,void 0,void 0,void 0,void 0,void 0,Ae),stencilBuffer:M.stencil,colorSpace:e.outputColorSpace,samples:M.antialias?4:0,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}else{const Ae={antialias:M.antialias,alpha:!0,depth:M.depth,stencil:M.stencil,framebufferScaleFactor:a};g=new XRWebGLLayer(i,n,Ae),i.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),A=new Df(g.framebufferWidth,g.framebufferHeight,{format:Ko,type:zl,colorSpace:e.outputColorSpace,stencilBuffer:M.stencil,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),ae.setContext(i),ae.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(de){for(let fe=0;fe<de.removed.length;fe++){const Ae=de.removed[fe],ge=k.indexOf(Ae);ge>=0&&(k[ge]=null,E[ge].disconnect(Ae))}for(let fe=0;fe<de.added.length;fe++){const Ae=de.added[fe];let ge=k.indexOf(Ae);if(ge===-1){for(let je=0;je<E.length;je++)if(je>=k.length){k.push(Ae),ge=je;break}else if(k[je]===null){k[je]=Ae,ge=je;break}if(ge===-1)break}const Me=E[ge];Me&&Me.connect(Ae)}}const Z=new at,re=new at;function oe(de,fe,Ae){Z.setFromMatrixPosition(fe.matrixWorld),re.setFromMatrixPosition(Ae.matrixWorld);const ge=Z.distanceTo(re),Me=fe.projectionMatrix.elements,je=Ae.projectionMatrix.elements,ne=Me[14]/(Me[10]-1),Ke=Me[14]/(Me[10]+1),$=(Me[9]+1)/Me[5],z=(Me[9]-1)/Me[5],W=(Me[8]-1)/Me[0],U=(je[8]+1)/je[0],V=ne*W,Q=ne*U,Ee=ge/(-W+U),Ce=Ee*-W;if(fe.matrixWorld.decompose(de.position,de.quaternion,de.scale),de.translateX(Ce),de.translateZ(Ee),de.matrixWorld.compose(de.position,de.quaternion,de.scale),de.matrixWorldInverse.copy(de.matrixWorld).invert(),Me[10]===-1)de.projectionMatrix.copy(fe.projectionMatrix),de.projectionMatrixInverse.copy(fe.projectionMatrixInverse);else{const Ne=ne+Ee,H=Ke+Ee,O=V-Ce,ie=Q+(ge-Ce),ye=$*Ke/H*Ne,_e=z*Ke/H*Ne;de.projectionMatrix.makePerspective(O,ie,ye,_e,Ne,H),de.projectionMatrixInverse.copy(de.projectionMatrix).invert()}}function B(de,fe){fe===null?de.matrixWorld.copy(de.matrix):de.matrixWorld.multiplyMatrices(fe.matrixWorld,de.matrix),de.matrixWorldInverse.copy(de.matrixWorld).invert()}this.updateCamera=function(de){if(i===null)return;let fe=de.near,Ae=de.far;b.texture!==null&&(b.depthNear>0&&(fe=b.depthNear),b.depthFar>0&&(Ae=b.depthFar)),L.near=P.near=T.near=fe,L.far=P.far=T.far=Ae,(X!==L.near||D!==L.far)&&(i.updateRenderState({depthNear:L.near,depthFar:L.far}),X=L.near,D=L.far),L.layers.mask=de.layers.mask|6,T.layers.mask=L.layers.mask&3,P.layers.mask=L.layers.mask&5;const ge=de.parent,Me=L.cameras;B(L,ge);for(let je=0;je<Me.length;je++)B(Me[je],ge);Me.length===2?oe(L,T,P):L.projectionMatrix.copy(T.projectionMatrix),G(de,L,ge)};function G(de,fe,Ae){Ae===null?de.matrix.copy(fe.matrixWorld):(de.matrix.copy(Ae.matrixWorld),de.matrix.invert(),de.matrix.multiply(fe.matrixWorld)),de.matrix.decompose(de.position,de.quaternion,de.scale),de.updateMatrixWorld(!0),de.projectionMatrix.copy(fe.projectionMatrix),de.projectionMatrixInverse.copy(fe.projectionMatrixInverse),de.isPerspectiveCamera&&(de.fov=LP*2*Math.atan(1/de.projectionMatrix.elements[5]),de.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(m===null&&g===null))return c},this.setFoveation=function(de){c=de,m!==null&&(m.fixedFoveation=de),g!==null&&g.fixedFoveation!==void 0&&(g.fixedFoveation=de)},this.hasDepthSensing=function(){return b.texture!==null},this.getDepthSensingMesh=function(){return b.getMesh(L)},this.getCameraTexture=function(de){return v[de]};let J=null;function te(de,fe){if(d=fe.getViewerPose(u||o),x=fe,d!==null){const Ae=d.views;g!==null&&(e.setRenderTargetFramebuffer(A,g.framebuffer),e.setRenderTarget(A));let ge=!1;Ae.length!==L.cameras.length&&(L.cameras.length=0,ge=!0);for(let Ke=0;Ke<Ae.length;Ke++){const $=Ae[Ke];let z=null;if(g!==null)z=g.getViewport($);else{const U=f.getViewSubImage(m,$);z=U.viewport,Ke===0&&(e.setRenderTargetTextures(A,U.colorTexture,U.depthStencilTexture),e.setRenderTarget(A))}let W=F[Ke];W===void 0&&(W=new po,W.layers.enable(Ke),W.viewport=new pi,F[Ke]=W),W.matrix.fromArray($.transform.matrix),W.matrix.decompose(W.position,W.quaternion,W.scale),W.projectionMatrix.fromArray($.projectionMatrix),W.projectionMatrixInverse.copy(W.projectionMatrix).invert(),W.viewport.set(z.x,z.y,z.width,z.height),Ke===0&&(L.matrix.copy(W.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),ge===!0&&L.cameras.push(W)}const Me=i.enabledFeatures;if(Me&&Me.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){f=r.getBinding();const Ke=f.getDepthInformation(Ae[0]);Ke&&Ke.isValid&&Ke.texture&&b.init(Ke,i.renderState)}if(Me&&Me.includes("camera-access")&&y){e.state.unbindTexture(),f=r.getBinding();for(let Ke=0;Ke<Ae.length;Ke++){const $=Ae[Ke].camera;if($){let z=v[$];z||(z=new tJ,v[$]=z);const W=f.getCameraImage($);z.sourceTexture=W}}}}for(let Ae=0;Ae<E.length;Ae++){const ge=k[Ae],Me=E[Ae];ge!==null&&Me!==void 0&&Me.update(ge,fe,u||o)}J&&J(de,fe),fe.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:fe}),x=null}const ae=new aJ;ae.setAnimationLoop(te),this.setAnimationLoop=function(de){J=de},this.dispose=function(){}}};const Nh=new $d,oOe=new vi;function lOe(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,YZ(t)),v.isFog?(b.fogNear.value=v.near,b.fogFar.value=v.far):v.isFogExp2&&(b.fogDensity.value=v.density)}function i(b,v,M,S,A){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&&g(b,v,A)):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,M,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===fs&&(b.bumpScale.value*=-1)),v.normalMap&&(b.normalMap.value=v.normalMap,n(v.normalMap,b.normalMapTransform),b.normalScale.value.copy(v.normalScale),v.side===fs&&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 M=e.get(v),S=M.envMap,A=M.envMapRotation;S&&(b.envMap.value=S,Nh.copy(A),Nh.x*=-1,Nh.y*=-1,Nh.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(Nh.y*=-1,Nh.z*=-1),b.envMapRotation.value.setFromMatrix4(oOe.makeRotationFromEuler(Nh)),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,M,S){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.size.value=v.size*M,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 g(b,v,M){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===fs&&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=M.texture,b.transmissionSamplerSize.value.set(M.width,M.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 M=e.get(v).light;b.referencePosition.value.setFromMatrixPosition(M.matrixWorld),b.nearDistance.value=M.shadow.camera.near,b.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function cOe(t,e,n,r){let i={},a={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,S){const A=S.program;r.uniformBlockBinding(M,A)}function u(M,S){let A=i[M.id];A===void 0&&(x(M),A=d(M),i[M.id]=A,M.addEventListener("dispose",b));const E=S.program;r.updateUBOMapping(M,E);const k=e.render.frame;a[M.id]!==k&&(m(M),a[M.id]=k)}function d(M){const S=f();M.__bindingPointIndex=S;const A=t.createBuffer(),E=M.__size,k=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,E,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,S,A),A}function f(){for(let M=0;M<l;M++)if(o.indexOf(M)===-1)return o.push(M),M;return ai("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(M){const S=i[M.id],A=M.uniforms,E=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,S);for(let k=0,C=A.length;k<C;k++){const R=Array.isArray(A[k])?A[k]:[A[k]];for(let T=0,P=R.length;T<P;T++){const F=R[T];if(g(F,k,T,E)===!0){const L=F.__offset,X=Array.isArray(F.value)?F.value:[F.value];let D=0;for(let K=0;K<X.length;K++){const Y=X[K],q=y(Y);typeof Y=="number"||typeof Y=="boolean"?(F.__data[0]=Y,t.bufferSubData(t.UNIFORM_BUFFER,L+D,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,D),D+=q.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,L,F.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function g(M,S,A,E){const k=M.value,C=S+"_"+A;if(E[C]===void 0)return typeof k=="number"||typeof k=="boolean"?E[C]=k:E[C]=k.clone(),!0;{const R=E[C];if(typeof k=="number"||typeof k=="boolean"){if(R!==k)return E[C]=k,!0}else if(R.equals(k)===!1)return R.copy(k),!0}return!1}function x(M){const S=M.uniforms;let A=0;const E=16;for(let C=0,R=S.length;C<R;C++){const T=Array.isArray(S[C])?S[C]:[S[C]];for(let P=0,F=T.length;P<F;P++){const L=T[P],X=Array.isArray(L.value)?L.value:[L.value];for(let D=0,K=X.length;D<K;D++){const Y=X[D],q=y(Y),Z=A%E,re=Z%q.boundary,oe=Z+re;A+=re,oe!==0&&E-oe<q.storage&&(A+=E-oe),L.__data=new Float32Array(q.storage/Float32Array.BYTES_PER_ELEMENT),L.__offset=A,A+=q.storage}}}const k=A%E;return k>0&&(A+=E-k),M.__size=A,M.__cache={},this}function y(M){const S={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(S.boundary=4,S.storage=4):M.isVector2?(S.boundary=8,S.storage=8):M.isVector3||M.isColor?(S.boundary=16,S.storage=12):M.isVector4?(S.boundary=16,S.storage=16):M.isMatrix3?(S.boundary=48,S.storage=48):M.isMatrix4?(S.boundary=64,S.storage=64):M.isTexture?ln("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ln("WebGLRenderer: Unsupported uniform value type.",M),S}function b(M){const S=M.target;S.removeEventListener("dispose",b);const A=o.indexOf(S.__bindingPointIndex);o.splice(A,1),t.deleteBuffer(i[S.id]),delete i[S.id],delete a[S.id]}function v(){for(const M in i)t.deleteBuffer(i[M]);o=[],i={},a={}}return{bind:c,update:u,dispose:v}}const uOe=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 yc=null;function dOe(){return yc===null&&(yc=new d3e(uOe,32,32,xO,Vg),yc.minFilter=_o,yc.magFilter=_o,yc.wrapS=zc,yc.wrapT=zc,yc.generateMipmaps=!1,yc.needsUpdate=!0),yc}let hOe=class{constructor(e={}){const{canvas:n=Lje(),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 g;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=r.getContextAttributes().alpha}else g=o;const x=new Set([yO,bO,gO]),y=new Set([zl,Pf,S0,M0,mO,pO]),b=new Uint32Array(4),v=new Int32Array(4);let M=null,S=null;const A=[],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=Ed,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const k=this;let C=!1;this._outputColorSpace=ho;let R=0,T=0,P=null,F=-1,L=null;const X=new pi,D=new pi;let K=null;const Y=new Tn(0);let q=0,Z=n.width,re=n.height,oe=1,B=null,G=null;const J=new pi(0,0,Z,re),te=new pi(0,0,Z,re);let ae=!1;const de=new MO;let fe=!1,Ae=!1;const ge=new vi,Me=new at,je=new pi,ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ke=!1;function $(){return P===null?oe:1}let z=r;function W(ce,we){return n.getContext(ce,we)}try{const ce={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${dO}`),n.addEventListener("webglcontextlost",De,!1),n.addEventListener("webglcontextrestored",ve,!1),n.addEventListener("webglcontextcreationerror",He,!1),z===null){const we="webgl2";if(z=W(we,ce),z===null)throw W(we)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ce){throw ce("WebGLRenderer: "+ce.message),ce}let U,V,Q,Ee,Ce,Ne,H,O,ie,ye,_e,le,ke,Oe,Ze,ht,We,he,rt,qe,Je,ot,se,$e;function be(){U=new vDe(z),U.init(),ot=new nOe(z,U),V=new dDe(z,U,e,ot),Q=new eOe(z,U),V.reversedDepthBuffer&&m&&Q.buffers.depth.setReversed(!0),Ee=new SDe(z),Ce=new B4e,Ne=new tOe(z,U,Q,Ce,V,ot,Ee),H=new fDe(k),O=new yDe(k),ie=new A3e(z),se=new cDe(z,ie),ye=new _De(z,ie,Ee,se),_e=new NDe(z,ye,ie,Ee),rt=new MDe(z,V,Ne),ht=new hDe(Ce),le=new z4e(k,H,O,U,V,se,ht),ke=new lOe(k,Ce),Oe=new H4e,Ze=new X4e(U),he=new lDe(k,H,O,Q,_e,g,c),We=new Z4e(k,_e,V),$e=new cOe(z,Ee,V,Q),qe=new uDe(z,U,Ee),Je=new wDe(z,U,Ee),Ee.programs=le.programs,k.capabilities=V,k.extensions=U,k.properties=Ce,k.renderLists=Oe,k.shadowMap=We,k.state=Q,k.info=Ee}be();const Fe=new sOe(k,z);this.xr=Fe,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){const ce=U.get("WEBGL_lose_context");ce&&ce.loseContext()},this.forceContextRestore=function(){const ce=U.get("WEBGL_lose_context");ce&&ce.restoreContext()},this.getPixelRatio=function(){return oe},this.setPixelRatio=function(ce){ce!==void 0&&(oe=ce,this.setSize(Z,re,!1))},this.getSize=function(ce){return ce.set(Z,re)},this.setSize=function(ce,we,Ie=!0){if(Fe.isPresenting){ln("WebGLRenderer: Can't change size while VR device is presenting.");return}Z=ce,re=we,n.width=Math.floor(ce*oe),n.height=Math.floor(we*oe),Ie===!0&&(n.style.width=ce+"px",n.style.height=we+"px"),this.setViewport(0,0,ce,we)},this.getDrawingBufferSize=function(ce){return ce.set(Z*oe,re*oe).floor()},this.setDrawingBufferSize=function(ce,we,Ie){Z=ce,re=we,oe=Ie,n.width=Math.floor(ce*Ie),n.height=Math.floor(we*Ie),this.setViewport(0,0,ce,we)},this.getCurrentViewport=function(ce){return ce.copy(X)},this.getViewport=function(ce){return ce.copy(J)},this.setViewport=function(ce,we,Ie,Le){ce.isVector4?J.set(ce.x,ce.y,ce.z,ce.w):J.set(ce,we,Ie,Le),Q.viewport(X.copy(J).multiplyScalar(oe).round())},this.getScissor=function(ce){return ce.copy(te)},this.setScissor=function(ce,we,Ie,Le){ce.isVector4?te.set(ce.x,ce.y,ce.z,ce.w):te.set(ce,we,Ie,Le),Q.scissor(D.copy(te).multiplyScalar(oe).round())},this.getScissorTest=function(){return ae},this.setScissorTest=function(ce){Q.setScissorTest(ae=ce)},this.setOpaqueSort=function(ce){B=ce},this.setTransparentSort=function(ce){G=ce},this.getClearColor=function(ce){return ce.copy(he.getClearColor())},this.setClearColor=function(){he.setClearColor(...arguments)},this.getClearAlpha=function(){return he.getClearAlpha()},this.setClearAlpha=function(){he.setClearAlpha(...arguments)},this.clear=function(ce=!0,we=!0,Ie=!0){let Le=0;if(ce){let Re=!1;if(P!==null){const ut=P.texture.format;Re=x.has(ut)}if(Re){const ut=P.texture.type,_t=y.has(ut),Tt=he.getClearColor(),St=he.getClearAlpha(),vt=Tt.r,xe=Tt.g,st=Tt.b;_t?(b[0]=vt,b[1]=xe,b[2]=st,b[3]=St,z.clearBufferuiv(z.COLOR,0,b)):(v[0]=vt,v[1]=xe,v[2]=st,v[3]=St,z.clearBufferiv(z.COLOR,0,v))}else Le|=z.COLOR_BUFFER_BIT}we&&(Le|=z.DEPTH_BUFFER_BIT),Ie&&(Le|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),z.clear(Le)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",De,!1),n.removeEventListener("webglcontextrestored",ve,!1),n.removeEventListener("webglcontextcreationerror",He,!1),he.dispose(),Oe.dispose(),Ze.dispose(),Ce.dispose(),H.dispose(),O.dispose(),_e.dispose(),se.dispose(),$e.dispose(),le.dispose(),Fe.dispose(),Fe.removeEventListener("sessionstart",pt),Fe.removeEventListener("sessionend",$t),qt.stop()};function De(ce){ce.preventDefault(),fH("WebGLRenderer: Context Lost."),C=!0}function ve(){fH("WebGLRenderer: Context Restored."),C=!1;const ce=Ee.autoReset,we=We.enabled,Ie=We.autoUpdate,Le=We.needsUpdate,Re=We.type;be(),Ee.autoReset=ce,We.enabled=we,We.autoUpdate=Ie,We.needsUpdate=Le,We.type=Re}function He(ce){ai("WebGLRenderer: A WebGL context could not be created. Reason: ",ce.statusMessage)}function dt(ce){const we=ce.target;we.removeEventListener("dispose",dt),kt(we)}function kt(ce){jt(ce),Ce.remove(ce)}function jt(ce){const we=Ce.get(ce).programs;we!==void 0&&(we.forEach(function(Ie){le.releaseProgram(Ie)}),ce.isShaderMaterial&&le.releaseShaderCache(ce))}this.renderBufferDirect=function(ce,we,Ie,Le,Re,ut){we===null&&(we=ne);const _t=Re.isMesh&&Re.matrixWorld.determinant()<0,Tt=ue(ce,we,Ie,Le,Re);Q.setMaterial(Le,_t);let St=Ie.index,vt=1;if(Le.wireframe===!0){if(St=ye.getWireframeAttribute(Ie),St===void 0)return;vt=2}const xe=Ie.drawRange,st=Ie.attributes.position;let Ht=xe.start*vt,It=(xe.start+xe.count)*vt;ut!==null&&(Ht=Math.max(Ht,ut.start*vt),It=Math.min(It,(ut.start+ut.count)*vt)),St!==null?(Ht=Math.max(Ht,0),It=Math.min(It,St.count)):st!=null&&(Ht=Math.max(Ht,0),It=Math.min(It,st.count));const on=It-Ht;if(on<0||on===1/0)return;se.setup(Re,Le,Tt,Ie,St);let un,Gt=qe;if(St!==null&&(un=ie.get(St),Gt=Je,Gt.setIndex(un)),Re.isMesh)Le.wireframe===!0?(Q.setLineWidth(Le.wireframeLinewidth*$()),Gt.setMode(z.LINES)):Gt.setMode(z.TRIANGLES);else if(Re.isLine){let Wt=Le.linewidth;Wt===void 0&&(Wt=1),Q.setLineWidth(Wt*$()),Re.isLineSegments?Gt.setMode(z.LINES):Re.isLineLoop?Gt.setMode(z.LINE_LOOP):Gt.setMode(z.LINE_STRIP)}else Re.isPoints?Gt.setMode(z.POINTS):Re.isSprite&&Gt.setMode(z.TRIANGLES);if(Re.isBatchedMesh)if(Re._multiDrawInstances!==null)A0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Gt.renderMultiDrawInstances(Re._multiDrawStarts,Re._multiDrawCounts,Re._multiDrawCount,Re._multiDrawInstances);else if(U.get("WEBGL_multi_draw"))Gt.renderMultiDraw(Re._multiDrawStarts,Re._multiDrawCounts,Re._multiDrawCount);else{const Wt=Re._multiDrawStarts,dn=Re._multiDrawCounts,fn=Re._multiDrawCount,Hr=St?ie.get(St).bytesPerElement:1,ti=Ce.get(Le).currentProgram.getUniforms();for(let Wn=0;Wn<fn;Wn++)ti.setValue(z,"_gl_DrawID",Wn),Gt.render(Wt[Wn]/Hr,dn[Wn])}else if(Re.isInstancedMesh)Gt.renderInstances(Ht,on,Re.count);else if(Ie.isInstancedBufferGeometry){const Wt=Ie._maxInstanceCount!==void 0?Ie._maxInstanceCount:1/0,dn=Math.min(Ie.instanceCount,Wt);Gt.renderInstances(Ht,on,dn)}else Gt.render(Ht,on)};function Zt(ce,we,Ie){ce.transparent===!0&&ce.side===Ml&&ce.forceSinglePass===!1?(ce.side=fs,ce.needsUpdate=!0,yt(ce,we,Ie),ce.side=Bd,ce.needsUpdate=!0,yt(ce,we,Ie),ce.side=Ml):yt(ce,we,Ie)}this.compile=function(ce,we,Ie=null){Ie===null&&(Ie=ce),S=Ze.get(Ie),S.init(we),E.push(S),Ie.traverseVisible(function(Re){Re.isLight&&Re.layers.test(we.layers)&&(S.pushLight(Re),Re.castShadow&&S.pushShadow(Re))}),ce!==Ie&&ce.traverseVisible(function(Re){Re.isLight&&Re.layers.test(we.layers)&&(S.pushLight(Re),Re.castShadow&&S.pushShadow(Re))}),S.setupLights();const Le=new Set;return ce.traverse(function(Re){if(!(Re.isMesh||Re.isPoints||Re.isLine||Re.isSprite))return;const ut=Re.material;if(ut)if(Array.isArray(ut))for(let _t=0;_t<ut.length;_t++){const Tt=ut[_t];Zt(Tt,Ie,Re),Le.add(Tt)}else Zt(ut,Ie,Re),Le.add(ut)}),S=E.pop(),Le},this.compileAsync=function(ce,we,Ie=null){const Le=this.compile(ce,we,Ie);return new Promise(Re=>{function ut(){if(Le.forEach(function(_t){Ce.get(_t).currentProgram.isReady()&&Le.delete(_t)}),Le.size===0){Re(ce);return}setTimeout(ut,10)}U.get("KHR_parallel_shader_compile")!==null?ut():setTimeout(ut,10)})};let Rt=null;function nn(ce){Rt&&Rt(ce)}function pt(){qt.stop()}function $t(){qt.start()}const qt=new aJ;qt.setAnimationLoop(nn),typeof self<"u"&&qt.setContext(self),this.setAnimationLoop=function(ce){Rt=ce,Fe.setAnimationLoop(ce),ce===null?qt.stop():qt.start()},Fe.addEventListener("sessionstart",pt),Fe.addEventListener("sessionend",$t),this.render=function(ce,we){if(we!==void 0&&we.isCamera!==!0){ai("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;if(ce.matrixWorldAutoUpdate===!0&&ce.updateMatrixWorld(),we.parent===null&&we.matrixWorldAutoUpdate===!0&&we.updateMatrixWorld(),Fe.enabled===!0&&Fe.isPresenting===!0&&(Fe.cameraAutoUpdate===!0&&Fe.updateCamera(we),we=Fe.getCamera()),ce.isScene===!0&&ce.onBeforeRender(k,ce,we,P),S=Ze.get(ce,E.length),S.init(we),E.push(S),ge.multiplyMatrices(we.projectionMatrix,we.matrixWorldInverse),de.setFromProjectionMatrix(ge,Tl,we.reversedDepth),Ae=this.localClippingEnabled,fe=ht.init(this.clippingPlanes,Ae),M=Oe.get(ce,A.length),M.init(),A.push(M),Fe.enabled===!0&&Fe.isPresenting===!0){const ut=k.xr.getDepthSensingMesh();ut!==null&&wt(ut,we,-1/0,k.sortObjects)}wt(ce,we,0,k.sortObjects),M.finish(),k.sortObjects===!0&&M.sort(B,G),Ke=Fe.enabled===!1||Fe.isPresenting===!1||Fe.hasDepthSensing()===!1,Ke&&he.addToRenderList(M,ce),this.info.render.frame++,fe===!0&&ht.beginShadows();const Ie=S.state.shadowsArray;We.render(Ie,ce,we),fe===!0&&ht.endShadows(),this.info.autoReset===!0&&this.info.reset();const Le=M.opaque,Re=M.transmissive;if(S.setupLights(),we.isArrayCamera){const ut=we.cameras;if(Re.length>0)for(let _t=0,Tt=ut.length;_t<Tt;_t++){const St=ut[_t];$r(Le,Re,ce,St)}Ke&&he.render(ce);for(let _t=0,Tt=ut.length;_t<Tt;_t++){const St=ut[_t];_r(M,ce,St,St.viewport)}}else Re.length>0&&$r(Le,Re,ce,we),Ke&&he.render(ce),_r(M,ce,we);P!==null&&T===0&&(Ne.updateMultisampleRenderTarget(P),Ne.updateRenderTargetMipmap(P)),ce.isScene===!0&&ce.onAfterRender(k,ce,we),se.resetDefaultState(),F=-1,L=null,E.pop(),E.length>0?(S=E[E.length-1],fe===!0&&ht.setGlobalState(k.clippingPlanes,S.state.camera)):S=null,A.pop(),A.length>0?M=A[A.length-1]:M=null};function wt(ce,we,Ie,Le){if(ce.visible===!1)return;if(ce.layers.test(we.layers)){if(ce.isGroup)Ie=ce.renderOrder;else if(ce.isLOD)ce.autoUpdate===!0&&ce.update(we);else if(ce.isLight)S.pushLight(ce),ce.castShadow&&S.pushShadow(ce);else if(ce.isSprite){if(!ce.frustumCulled||de.intersectsSprite(ce)){Le&&je.setFromMatrixPosition(ce.matrixWorld).applyMatrix4(ge);const _t=_e.update(ce),Tt=ce.material;Tt.visible&&M.push(ce,_t,Tt,Ie,je.z,null)}}else if((ce.isMesh||ce.isLine||ce.isPoints)&&(!ce.frustumCulled||de.intersectsObject(ce))){const _t=_e.update(ce),Tt=ce.material;if(Le&&(ce.boundingSphere!==void 0?(ce.boundingSphere===null&&ce.computeBoundingSphere(),je.copy(ce.boundingSphere.center)):(_t.boundingSphere===null&&_t.computeBoundingSphere(),je.copy(_t.boundingSphere.center)),je.applyMatrix4(ce.matrixWorld).applyMatrix4(ge)),Array.isArray(Tt)){const St=_t.groups;for(let vt=0,xe=St.length;vt<xe;vt++){const st=St[vt],Ht=Tt[st.materialIndex];Ht&&Ht.visible&&M.push(ce,_t,Ht,Ie,je.z,st)}}else Tt.visible&&M.push(ce,_t,Tt,Ie,je.z,null)}}const ut=ce.children;for(let _t=0,Tt=ut.length;_t<Tt;_t++)wt(ut[_t],we,Ie,Le)}function _r(ce,we,Ie,Le){const{opaque:Re,transmissive:ut,transparent:_t}=ce;S.setupLightsView(Ie),fe===!0&&ht.setGlobalState(k.clippingPlanes,Ie),Le&&Q.viewport(X.copy(Le)),Re.length>0&&Tr(Re,we,Ie),ut.length>0&&Tr(ut,we,Ie),_t.length>0&&Tr(_t,we,Ie),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1)}function $r(ce,we,Ie,Le){if((Ie.isScene===!0?Ie.overrideMaterial:null)!==null)return;S.state.transmissionRenderTarget[Le.id]===void 0&&(S.state.transmissionRenderTarget[Le.id]=new Df(1,1,{generateMipmaps:!0,type:U.has("EXT_color_buffer_half_float")||U.has("EXT_color_buffer_float")?Vg:zl,minFilter:Yh,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:zn.workingColorSpace}));const ut=S.state.transmissionRenderTarget[Le.id],_t=Le.viewport||X;ut.setSize(_t.z*k.transmissionResolutionScale,_t.w*k.transmissionResolutionScale);const Tt=k.getRenderTarget(),St=k.getActiveCubeFace(),vt=k.getActiveMipmapLevel();k.setRenderTarget(ut),k.getClearColor(Y),q=k.getClearAlpha(),q<1&&k.setClearColor(16777215,.5),k.clear(),Ke&&he.render(Ie);const xe=k.toneMapping;k.toneMapping=Ed;const st=Le.viewport;if(Le.viewport!==void 0&&(Le.viewport=void 0),S.setupLightsView(Le),fe===!0&&ht.setGlobalState(k.clippingPlanes,Le),Tr(ce,Ie,Le),Ne.updateMultisampleRenderTarget(ut),Ne.updateRenderTargetMipmap(ut),U.has("WEBGL_multisampled_render_to_texture")===!1){let Ht=!1;for(let It=0,on=we.length;It<on;It++){const un=we[It],{object:Gt,geometry:Wt,material:dn,group:fn}=un;if(dn.side===Ml&&Gt.layers.test(Le.layers)){const Hr=dn.side;dn.side=fs,dn.needsUpdate=!0,hr(Gt,Ie,Le,Wt,dn,fn),dn.side=Hr,dn.needsUpdate=!0,Ht=!0}}Ht===!0&&(Ne.updateMultisampleRenderTarget(ut),Ne.updateRenderTargetMipmap(ut))}k.setRenderTarget(Tt,St,vt),k.setClearColor(Y,q),st!==void 0&&(Le.viewport=st),k.toneMapping=xe}function Tr(ce,we,Ie){const Le=we.isScene===!0?we.overrideMaterial:null;for(let Re=0,ut=ce.length;Re<ut;Re++){const _t=ce[Re],{object:Tt,geometry:St,group:vt}=_t;let xe=_t.material;xe.allowOverride===!0&&Le!==null&&(xe=Le),Tt.layers.test(Ie.layers)&&hr(Tt,we,Ie,St,xe,vt)}}function hr(ce,we,Ie,Le,Re,ut){ce.onBeforeRender(k,we,Ie,Le,Re,ut),ce.modelViewMatrix.multiplyMatrices(Ie.matrixWorldInverse,ce.matrixWorld),ce.normalMatrix.getNormalMatrix(ce.modelViewMatrix),Re.onBeforeRender(k,we,Ie,Le,ce,ut),Re.transparent===!0&&Re.side===Ml&&Re.forceSinglePass===!1?(Re.side=fs,Re.needsUpdate=!0,k.renderBufferDirect(Ie,we,Le,Re,ce,ut),Re.side=Bd,Re.needsUpdate=!0,k.renderBufferDirect(Ie,we,Le,Re,ce,ut),Re.side=Ml):k.renderBufferDirect(Ie,we,Le,Re,ce,ut),ce.onAfterRender(k,we,Ie,Le,Re,ut)}function yt(ce,we,Ie){we.isScene!==!0&&(we=ne);const Le=Ce.get(ce),Re=S.state.lights,ut=S.state.shadowsArray,_t=Re.state.version,Tt=le.getParameters(ce,Re.state,ut,we,Ie),St=le.getProgramCacheKey(Tt);let vt=Le.programs;Le.environment=ce.isMeshStandardMaterial?we.environment:null,Le.fog=we.fog,Le.envMap=(ce.isMeshStandardMaterial?O:H).get(ce.envMap||Le.environment),Le.envMapRotation=Le.environment!==null&&ce.envMap===null?we.environmentRotation:ce.envMapRotation,vt===void 0&&(ce.addEventListener("dispose",dt),vt=new Map,Le.programs=vt);let xe=vt.get(St);if(xe!==void 0){if(Le.currentProgram===xe&&Le.lightsStateVersion===_t)return wn(ce,Tt),xe}else Tt.uniforms=le.getUniforms(ce),ce.onBeforeCompile(Tt,k),xe=le.acquireProgram(Tt,St),vt.set(St,xe),Le.uniforms=Tt.uniforms;const st=Le.uniforms;return(!ce.isShaderMaterial&&!ce.isRawShaderMaterial||ce.clipping===!0)&&(st.clippingPlanes=ht.uniform),wn(ce,Tt),Le.needsLights=Ye(ce),Le.lightsStateVersion=_t,Le.needsLights&&(st.ambientLightColor.value=Re.state.ambient,st.lightProbe.value=Re.state.probe,st.directionalLights.value=Re.state.directional,st.directionalLightShadows.value=Re.state.directionalShadow,st.spotLights.value=Re.state.spot,st.spotLightShadows.value=Re.state.spotShadow,st.rectAreaLights.value=Re.state.rectArea,st.ltc_1.value=Re.state.rectAreaLTC1,st.ltc_2.value=Re.state.rectAreaLTC2,st.pointLights.value=Re.state.point,st.pointLightShadows.value=Re.state.pointShadow,st.hemisphereLights.value=Re.state.hemi,st.directionalShadowMap.value=Re.state.directionalShadowMap,st.directionalShadowMatrix.value=Re.state.directionalShadowMatrix,st.spotShadowMap.value=Re.state.spotShadowMap,st.spotLightMatrix.value=Re.state.spotLightMatrix,st.spotLightMap.value=Re.state.spotLightMap,st.pointShadowMap.value=Re.state.pointShadowMap,st.pointShadowMatrix.value=Re.state.pointShadowMatrix),Le.currentProgram=xe,Le.uniformsList=null,xe}function en(ce){if(ce.uniformsList===null){const we=ce.currentProgram.getUniforms();ce.uniformsList=X1.seqWithValue(we.seq,ce.uniforms)}return ce.uniformsList}function wn(ce,we){const Ie=Ce.get(ce);Ie.outputColorSpace=we.outputColorSpace,Ie.batching=we.batching,Ie.batchingColor=we.batchingColor,Ie.instancing=we.instancing,Ie.instancingColor=we.instancingColor,Ie.instancingMorph=we.instancingMorph,Ie.skinning=we.skinning,Ie.morphTargets=we.morphTargets,Ie.morphNormals=we.morphNormals,Ie.morphColors=we.morphColors,Ie.morphTargetsCount=we.morphTargetsCount,Ie.numClippingPlanes=we.numClippingPlanes,Ie.numIntersection=we.numClipIntersection,Ie.vertexAlphas=we.vertexAlphas,Ie.vertexTangents=we.vertexTangents,Ie.toneMapping=we.toneMapping}function ue(ce,we,Ie,Le,Re){we.isScene!==!0&&(we=ne),Ne.resetTextureUnits();const ut=we.fog,_t=Le.isMeshStandardMaterial?we.environment:null,Tt=P===null?k.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:hg,St=(Le.isMeshStandardMaterial?O:H).get(Le.envMap||_t),vt=Le.vertexColors===!0&&!!Ie.attributes.color&&Ie.attributes.color.itemSize===4,xe=!!Ie.attributes.tangent&&(!!Le.normalMap||Le.anisotropy>0),st=!!Ie.morphAttributes.position,Ht=!!Ie.morphAttributes.normal,It=!!Ie.morphAttributes.color;let on=Ed;Le.toneMapped&&(P===null||P.isXRRenderTarget===!0)&&(on=k.toneMapping);const un=Ie.morphAttributes.position||Ie.morphAttributes.normal||Ie.morphAttributes.color,Gt=un!==void 0?un.length:0,Wt=Ce.get(Le),dn=S.state.lights;if(fe===!0&&(Ae===!0||ce!==L)){const Fi=ce===L&&Le.id===F;ht.setState(Le,ce,Fi)}let fn=!1;Le.version===Wt.__version?(Wt.needsLights&&Wt.lightsStateVersion!==dn.state.version||Wt.outputColorSpace!==Tt||Re.isBatchedMesh&&Wt.batching===!1||!Re.isBatchedMesh&&Wt.batching===!0||Re.isBatchedMesh&&Wt.batchingColor===!0&&Re.colorTexture===null||Re.isBatchedMesh&&Wt.batchingColor===!1&&Re.colorTexture!==null||Re.isInstancedMesh&&Wt.instancing===!1||!Re.isInstancedMesh&&Wt.instancing===!0||Re.isSkinnedMesh&&Wt.skinning===!1||!Re.isSkinnedMesh&&Wt.skinning===!0||Re.isInstancedMesh&&Wt.instancingColor===!0&&Re.instanceColor===null||Re.isInstancedMesh&&Wt.instancingColor===!1&&Re.instanceColor!==null||Re.isInstancedMesh&&Wt.instancingMorph===!0&&Re.morphTexture===null||Re.isInstancedMesh&&Wt.instancingMorph===!1&&Re.morphTexture!==null||Wt.envMap!==St||Le.fog===!0&&Wt.fog!==ut||Wt.numClippingPlanes!==void 0&&(Wt.numClippingPlanes!==ht.numPlanes||Wt.numIntersection!==ht.numIntersection)||Wt.vertexAlphas!==vt||Wt.vertexTangents!==xe||Wt.morphTargets!==st||Wt.morphNormals!==Ht||Wt.morphColors!==It||Wt.toneMapping!==on||Wt.morphTargetsCount!==Gt)&&(fn=!0):(fn=!0,Wt.__version=Le.version);let Hr=Wt.currentProgram;fn===!0&&(Hr=yt(Le,we,Re));let ti=!1,Wn=!1,Po=!1;const Xn=Hr.getUniforms(),Ii=Wt.uniforms;if(Q.useProgram(Hr.program)&&(ti=!0,Wn=!0,Po=!0),Le.id!==F&&(F=Le.id,Wn=!0),ti||L!==ce){Q.buffers.depth.getReversed()&&ce.reversedDepth!==!0&&(ce._reversedDepth=!0,ce.updateProjectionMatrix()),Xn.setValue(z,"projectionMatrix",ce.projectionMatrix),Xn.setValue(z,"viewMatrix",ce.matrixWorldInverse);const na=Xn.map.cameraPosition;na!==void 0&&na.setValue(z,Me.setFromMatrixPosition(ce.matrixWorld)),V.logarithmicDepthBuffer&&Xn.setValue(z,"logDepthBufFC",2/(Math.log(ce.far+1)/Math.LN2)),(Le.isMeshPhongMaterial||Le.isMeshToonMaterial||Le.isMeshLambertMaterial||Le.isMeshBasicMaterial||Le.isMeshStandardMaterial||Le.isShaderMaterial)&&Xn.setValue(z,"isOrthographic",ce.isOrthographicCamera===!0),L!==ce&&(L=ce,Wn=!0,Po=!0)}if(Re.isSkinnedMesh){Xn.setOptional(z,Re,"bindMatrix"),Xn.setOptional(z,Re,"bindMatrixInverse");const Fi=Re.skeleton;Fi&&(Fi.boneTexture===null&&Fi.computeBoneTexture(),Xn.setValue(z,"boneTexture",Fi.boneTexture,Ne))}Re.isBatchedMesh&&(Xn.setOptional(z,Re,"batchingTexture"),Xn.setValue(z,"batchingTexture",Re._matricesTexture,Ne),Xn.setOptional(z,Re,"batchingIdTexture"),Xn.setValue(z,"batchingIdTexture",Re._indirectTexture,Ne),Xn.setOptional(z,Re,"batchingColorTexture"),Re._colorsTexture!==null&&Xn.setValue(z,"batchingColorTexture",Re._colorsTexture,Ne));const wi=Ie.morphAttributes;if((wi.position!==void 0||wi.normal!==void 0||wi.color!==void 0)&&rt.update(Re,Ie,Hr),(Wn||Wt.receiveShadow!==Re.receiveShadow)&&(Wt.receiveShadow=Re.receiveShadow,Xn.setValue(z,"receiveShadow",Re.receiveShadow)),Le.isMeshGouraudMaterial&&Le.envMap!==null&&(Ii.envMap.value=St,Ii.flipEnvMap.value=St.isCubeTexture&&St.isRenderTargetTexture===!1?-1:1),Le.isMeshStandardMaterial&&Le.envMap===null&&we.environment!==null&&(Ii.envMapIntensity.value=we.environmentIntensity),Ii.dfgLUT!==void 0&&(Ii.dfgLUT.value=dOe()),Wn&&(Xn.setValue(z,"toneMappingExposure",k.toneMappingExposure),Wt.needsLights&&Be(Ii,Po),ut&&Le.fog===!0&&ke.refreshFogUniforms(Ii,ut),ke.refreshMaterialUniforms(Ii,Le,oe,re,S.state.transmissionRenderTarget[ce.id]),X1.upload(z,en(Wt),Ii,Ne)),Le.isShaderMaterial&&Le.uniformsNeedUpdate===!0&&(X1.upload(z,en(Wt),Ii,Ne),Le.uniformsNeedUpdate=!1),Le.isSpriteMaterial&&Xn.setValue(z,"center",Re.center),Xn.setValue(z,"modelViewMatrix",Re.modelViewMatrix),Xn.setValue(z,"normalMatrix",Re.normalMatrix),Xn.setValue(z,"modelMatrix",Re.matrixWorld),Le.isShaderMaterial||Le.isRawShaderMaterial){const Fi=Le.uniformsGroups;for(let na=0,ul=Fi.length;na<ul;na++){const Yl=Fi[na];$e.update(Yl,Hr),$e.bind(Yl,Hr)}}return Hr}function Be(ce,we){ce.ambientLightColor.needsUpdate=we,ce.lightProbe.needsUpdate=we,ce.directionalLights.needsUpdate=we,ce.directionalLightShadows.needsUpdate=we,ce.pointLights.needsUpdate=we,ce.pointLightShadows.needsUpdate=we,ce.spotLights.needsUpdate=we,ce.spotLightShadows.needsUpdate=we,ce.rectAreaLights.needsUpdate=we,ce.hemisphereLights.needsUpdate=we}function Ye(ce){return ce.isMeshLambertMaterial||ce.isMeshToonMaterial||ce.isMeshPhongMaterial||ce.isMeshStandardMaterial||ce.isShadowMaterial||ce.isShaderMaterial&&ce.lights===!0}this.getActiveCubeFace=function(){return R},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(ce,we,Ie){const Le=Ce.get(ce);Le.__autoAllocateDepthBuffer=ce.resolveDepthBuffer===!1,Le.__autoAllocateDepthBuffer===!1&&(Le.__useRenderToTexture=!1),Ce.get(ce.texture).__webglTexture=we,Ce.get(ce.depthTexture).__webglTexture=Le.__autoAllocateDepthBuffer?void 0:Ie,Le.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(ce,we){const Ie=Ce.get(ce);Ie.__webglFramebuffer=we,Ie.__useDefaultFramebuffer=we===void 0};const Xe=z.createFramebuffer();this.setRenderTarget=function(ce,we=0,Ie=0){P=ce,R=we,T=Ie;let Le=!0,Re=null,ut=!1,_t=!1;if(ce){const St=Ce.get(ce);if(St.__useDefaultFramebuffer!==void 0)Q.bindFramebuffer(z.FRAMEBUFFER,null),Le=!1;else if(St.__webglFramebuffer===void 0)Ne.setupRenderTarget(ce);else if(St.__hasExternalTextures)Ne.rebindTextures(ce,Ce.get(ce.texture).__webglTexture,Ce.get(ce.depthTexture).__webglTexture);else if(ce.depthBuffer){const st=ce.depthTexture;if(St.__boundDepthTexture!==st){if(st!==null&&Ce.has(st)&&(ce.width!==st.image.width||ce.height!==st.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Ne.setupDepthRenderbuffer(ce)}}const vt=ce.texture;(vt.isData3DTexture||vt.isDataArrayTexture||vt.isCompressedArrayTexture)&&(_t=!0);const xe=Ce.get(ce).__webglFramebuffer;ce.isWebGLCubeRenderTarget?(Array.isArray(xe[we])?Re=xe[we][Ie]:Re=xe[we],ut=!0):ce.samples>0&&Ne.useMultisampledRTT(ce)===!1?Re=Ce.get(ce).__webglMultisampledFramebuffer:Array.isArray(xe)?Re=xe[Ie]:Re=xe,X.copy(ce.viewport),D.copy(ce.scissor),K=ce.scissorTest}else X.copy(J).multiplyScalar(oe).floor(),D.copy(te).multiplyScalar(oe).floor(),K=ae;if(Ie!==0&&(Re=Xe),Q.bindFramebuffer(z.FRAMEBUFFER,Re)&&Le&&Q.drawBuffers(ce,Re),Q.viewport(X),Q.scissor(D),Q.setScissorTest(K),ut){const St=Ce.get(ce.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+we,St.__webglTexture,Ie)}else if(_t){const St=we;for(let vt=0;vt<ce.textures.length;vt++){const xe=Ce.get(ce.textures[vt]);z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0+vt,xe.__webglTexture,Ie,St)}}else if(ce!==null&&Ie!==0){const St=Ce.get(ce.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,St.__webglTexture,Ie)}F=-1},this.readRenderTargetPixels=function(ce,we,Ie,Le,Re,ut,_t,Tt=0){if(!(ce&&ce.isWebGLRenderTarget)){ai("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let St=Ce.get(ce).__webglFramebuffer;if(ce.isWebGLCubeRenderTarget&&_t!==void 0&&(St=St[_t]),St){Q.bindFramebuffer(z.FRAMEBUFFER,St);try{const vt=ce.textures[Tt],xe=vt.format,st=vt.type;if(!V.textureFormatReadable(xe)){ai("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!V.textureTypeReadable(st)){ai("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}we>=0&&we<=ce.width-Le&&Ie>=0&&Ie<=ce.height-Re&&(ce.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+Tt),z.readPixels(we,Ie,Le,Re,ot.convert(xe),ot.convert(st),ut))}finally{const vt=P!==null?Ce.get(P).__webglFramebuffer:null;Q.bindFramebuffer(z.FRAMEBUFFER,vt)}}},this.readRenderTargetPixelsAsync=async function(ce,we,Ie,Le,Re,ut,_t,Tt=0){if(!(ce&&ce.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let St=Ce.get(ce).__webglFramebuffer;if(ce.isWebGLCubeRenderTarget&&_t!==void 0&&(St=St[_t]),St)if(we>=0&&we<=ce.width-Le&&Ie>=0&&Ie<=ce.height-Re){Q.bindFramebuffer(z.FRAMEBUFFER,St);const vt=ce.textures[Tt],xe=vt.format,st=vt.type;if(!V.textureFormatReadable(xe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!V.textureTypeReadable(st))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ht=z.createBuffer();z.bindBuffer(z.PIXEL_PACK_BUFFER,Ht),z.bufferData(z.PIXEL_PACK_BUFFER,ut.byteLength,z.STREAM_READ),ce.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+Tt),z.readPixels(we,Ie,Le,Re,ot.convert(xe),ot.convert(st),0);const It=P!==null?Ce.get(P).__webglFramebuffer:null;Q.bindFramebuffer(z.FRAMEBUFFER,It);const on=z.fenceSync(z.SYNC_GPU_COMMANDS_COMPLETE,0);return z.flush(),await Ije(z,on,4),z.bindBuffer(z.PIXEL_PACK_BUFFER,Ht),z.getBufferSubData(z.PIXEL_PACK_BUFFER,0,ut),z.deleteBuffer(Ht),z.deleteSync(on),ut}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(ce,we=null,Ie=0){const Le=Math.pow(2,-Ie),Re=Math.floor(ce.image.width*Le),ut=Math.floor(ce.image.height*Le),_t=we!==null?we.x:0,Tt=we!==null?we.y:0;Ne.setTexture2D(ce,0),z.copyTexSubImage2D(z.TEXTURE_2D,Ie,0,0,_t,Tt,Re,ut),Q.unbindTexture()};const Qe=z.createFramebuffer(),At=z.createFramebuffer();this.copyTextureToTexture=function(ce,we,Ie=null,Le=null,Re=0,ut=null){ut===null&&(Re!==0?(A0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ut=Re,Re=0):ut=0);let _t,Tt,St,vt,xe,st,Ht,It,on;const un=ce.isCompressedTexture?ce.mipmaps[ut]:ce.image;if(Ie!==null)_t=Ie.max.x-Ie.min.x,Tt=Ie.max.y-Ie.min.y,St=Ie.isBox3?Ie.max.z-Ie.min.z:1,vt=Ie.min.x,xe=Ie.min.y,st=Ie.isBox3?Ie.min.z:0;else{const wi=Math.pow(2,-Re);_t=Math.floor(un.width*wi),Tt=Math.floor(un.height*wi),ce.isDataArrayTexture?St=un.depth:ce.isData3DTexture?St=Math.floor(un.depth*wi):St=1,vt=0,xe=0,st=0}Le!==null?(Ht=Le.x,It=Le.y,on=Le.z):(Ht=0,It=0,on=0);const Gt=ot.convert(we.format),Wt=ot.convert(we.type);let dn;we.isData3DTexture?(Ne.setTexture3D(we,0),dn=z.TEXTURE_3D):we.isDataArrayTexture||we.isCompressedArrayTexture?(Ne.setTexture2DArray(we,0),dn=z.TEXTURE_2D_ARRAY):(Ne.setTexture2D(we,0),dn=z.TEXTURE_2D),z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,we.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,we.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,we.unpackAlignment);const fn=z.getParameter(z.UNPACK_ROW_LENGTH),Hr=z.getParameter(z.UNPACK_IMAGE_HEIGHT),ti=z.getParameter(z.UNPACK_SKIP_PIXELS),Wn=z.getParameter(z.UNPACK_SKIP_ROWS),Po=z.getParameter(z.UNPACK_SKIP_IMAGES);z.pixelStorei(z.UNPACK_ROW_LENGTH,un.width),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,un.height),z.pixelStorei(z.UNPACK_SKIP_PIXELS,vt),z.pixelStorei(z.UNPACK_SKIP_ROWS,xe),z.pixelStorei(z.UNPACK_SKIP_IMAGES,st);const Xn=ce.isDataArrayTexture||ce.isData3DTexture,Ii=we.isDataArrayTexture||we.isData3DTexture;if(ce.isDepthTexture){const wi=Ce.get(ce),Fi=Ce.get(we),na=Ce.get(wi.__renderTarget),ul=Ce.get(Fi.__renderTarget);Q.bindFramebuffer(z.READ_FRAMEBUFFER,na.__webglFramebuffer),Q.bindFramebuffer(z.DRAW_FRAMEBUFFER,ul.__webglFramebuffer);for(let Yl=0;Yl<St;Yl++)Xn&&(z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Ce.get(ce).__webglTexture,Re,st+Yl),z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Ce.get(we).__webglTexture,ut,on+Yl)),z.blitFramebuffer(vt,xe,_t,Tt,Ht,It,_t,Tt,z.DEPTH_BUFFER_BIT,z.NEAREST);Q.bindFramebuffer(z.READ_FRAMEBUFFER,null),Q.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if(Re!==0||ce.isRenderTargetTexture||Ce.has(ce)){const wi=Ce.get(ce),Fi=Ce.get(we);Q.bindFramebuffer(z.READ_FRAMEBUFFER,Qe),Q.bindFramebuffer(z.DRAW_FRAMEBUFFER,At);for(let na=0;na<St;na++)Xn?z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,wi.__webglTexture,Re,st+na):z.framebufferTexture2D(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,wi.__webglTexture,Re),Ii?z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Fi.__webglTexture,ut,on+na):z.framebufferTexture2D(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,Fi.__webglTexture,ut),Re!==0?z.blitFramebuffer(vt,xe,_t,Tt,Ht,It,_t,Tt,z.COLOR_BUFFER_BIT,z.NEAREST):Ii?z.copyTexSubImage3D(dn,ut,Ht,It,on+na,vt,xe,_t,Tt):z.copyTexSubImage2D(dn,ut,Ht,It,vt,xe,_t,Tt);Q.bindFramebuffer(z.READ_FRAMEBUFFER,null),Q.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else Ii?ce.isDataTexture||ce.isData3DTexture?z.texSubImage3D(dn,ut,Ht,It,on,_t,Tt,St,Gt,Wt,un.data):we.isCompressedArrayTexture?z.compressedTexSubImage3D(dn,ut,Ht,It,on,_t,Tt,St,Gt,un.data):z.texSubImage3D(dn,ut,Ht,It,on,_t,Tt,St,Gt,Wt,un):ce.isDataTexture?z.texSubImage2D(z.TEXTURE_2D,ut,Ht,It,_t,Tt,Gt,Wt,un.data):ce.isCompressedTexture?z.compressedTexSubImage2D(z.TEXTURE_2D,ut,Ht,It,un.width,un.height,Gt,un.data):z.texSubImage2D(z.TEXTURE_2D,ut,Ht,It,_t,Tt,Gt,Wt,un);z.pixelStorei(z.UNPACK_ROW_LENGTH,fn),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,Hr),z.pixelStorei(z.UNPACK_SKIP_PIXELS,ti),z.pixelStorei(z.UNPACK_SKIP_ROWS,Wn),z.pixelStorei(z.UNPACK_SKIP_IMAGES,Po),ut===0&&we.generateMipmaps&&z.generateMipmap(dn),Q.unbindTexture()},this.initRenderTarget=function(ce){Ce.get(ce).__webglFramebuffer===void 0&&Ne.setupRenderTarget(ce)},this.initTexture=function(ce){ce.isCubeTexture?Ne.setTextureCube(ce,0):ce.isData3DTexture?Ne.setTexture3D(ce,0):ce.isDataArrayTexture||ce.isCompressedArrayTexture?Ne.setTexture2DArray(ce,0):Ne.setTexture2D(ce,0),Q.unbindTexture()},this.resetState=function(){R=0,T=0,P=null,Q.reset(),se.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Tl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=zn._getDrawingBufferColorSpace(e),n.unpackColorSpace=zn._getUnpackColorSpace()}};const lV={type:"change"},EO={type:"start"},uJ={type:"end"},L_=new _O,cV=new id,fOe=Math.cos(70*Uje.DEG2RAD),Mi=new at,as=2*Math.PI,cr={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},XC=1e-6;class mOe extends N3e{constructor(e,n=null){super(e,n),this.state=cr.NONE,this.target=new at,this.cursor=new at,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:Up.ROTATE,MIDDLE:Up.DOLLY,RIGHT:Up.PAN},this.touches={ONE:kp.ROTATE,TWO:kp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new at,this._lastQuaternion=new Rf,this._lastTargetPosition=new at,this._quat=new Rf().setFromUnitVectors(e.up,new at(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new IH,this._sphericalDelta=new IH,this._scale=1,this._panOffset=new at,this._rotateStart=new vn,this._rotateEnd=new vn,this._rotateDelta=new vn,this._panStart=new vn,this._panEnd=new vn,this._panDelta=new vn,this._dollyStart=new vn,this._dollyEnd=new vn,this._dollyDelta=new vn,this._dollyDirection=new at,this._mouse=new vn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=gOe.bind(this),this._onPointerDown=pOe.bind(this),this._onPointerUp=xOe.bind(this),this._onContextMenu=MOe.bind(this),this._onMouseWheel=vOe.bind(this),this._onKeyDown=_Oe.bind(this),this._onTouchStart=wOe.bind(this),this._onTouchMove=SOe.bind(this),this._onMouseDown=bOe.bind(this),this._onMouseMove=yOe.bind(this),this._interceptControlDown=NOe.bind(this),this._interceptControlUp=EOe.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(lV),this.update(),this.state=cr.NONE}update(e=null){const n=this.object.position;Mi.copy(n).sub(this.target),Mi.applyQuaternion(this._quat),this._spherical.setFromVector3(Mi),this.autoRotate&&this.state===cr.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+=as:r>Math.PI&&(r-=as),i<-Math.PI?i+=as:i>Math.PI&&(i-=as),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(Mi.setFromSpherical(this._spherical),Mi.applyQuaternion(this._quatInverse),n.copy(this.target).add(Mi),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=Mi.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 at(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 at(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=Mi.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):(L_.origin.copy(this.object.position),L_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(L_.direction))<fOe?this.object.lookAt(this.target):(cV.setFromNormalAndCoplanarPoint(this.object.up,this.target),L_.intersectPlane(cV,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>XC||8*(1-this._lastQuaternion.dot(this.object.quaternion))>XC||this._lastTargetPosition.distanceToSquared(this.target)>XC?(this.dispatchEvent(lV),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?as/60*this.autoRotateSpeed*e:as/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){Mi.setFromMatrixColumn(n,0),Mi.multiplyScalar(-e),this._panOffset.add(Mi)}_panUp(e,n){this.screenSpacePanning===!0?Mi.setFromMatrixColumn(n,1):(Mi.setFromMatrixColumn(n,0),Mi.crossVectors(this.object.up,Mi)),Mi.multiplyScalar(e),this._panOffset.add(Mi)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Mi.copy(i).sub(this.target);let a=Mi.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(as*this._rotateDelta.x/n.clientHeight),this._rotateUp(as*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(as*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(-as*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(as*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(-as*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(as*this._rotateDelta.x/n.clientHeight),this._rotateUp(as*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 vn,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 pOe(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 gOe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function xOe(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(uJ),this.state=cr.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 bOe(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 Up.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=cr.DOLLY;break;case Up.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=cr.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=cr.ROTATE}break;case Up.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=cr.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=cr.PAN}break;default:this.state=cr.NONE}this.state!==cr.NONE&&this.dispatchEvent(EO)}function yOe(t){switch(this.state){case cr.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case cr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case cr.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function vOe(t){this.enabled===!1||this.enableZoom===!1||this.state!==cr.NONE||(t.preventDefault(),this.dispatchEvent(EO),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(uJ))}function _Oe(t){this.enabled!==!1&&this._handleKeyDown(t)}function wOe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case kp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=cr.TOUCH_ROTATE;break;case kp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=cr.TOUCH_PAN;break;default:this.state=cr.NONE}break;case 2:switch(this.touches.TWO){case kp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=cr.TOUCH_DOLLY_PAN;break;case kp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=cr.TOUCH_DOLLY_ROTATE;break;default:this.state=cr.NONE}break;default:this.state=cr.NONE}this.state!==cr.NONE&&this.dispatchEvent(EO)}function SOe(t){switch(this._trackPointer(t),this.state){case cr.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case cr.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case cr.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case cr.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=cr.NONE}}function MOe(t){this.enabled!==!1&&t.preventDefault()}function NOe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function EOe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function AOe(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 Xl;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 g in f.attributes){if(!r.has(g))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+g+'" attribute exists among all geometries, or in none of them.'),null;a[g]===void 0&&(a[g]=[]),a[g].push(f.attributes[g]),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 g in f.morphAttributes){if(!i.has(g))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;o[g]===void 0&&(o[g]=[]),o[g].push(f.morphAttributes[g])}if(e){let g;if(n)g=f.index.count;else if(f.attributes.position!==void 0)g=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,g,d),u+=g}}if(n){let d=0;const f=[];for(let m=0;m<t.length;++m){const g=t[m].index;for(let x=0;x<g.count;++x)f.push(g.getX(x)+d);d+=t[m].attributes.position.count}c.setIndex(f)}for(const d in a){const f=uV(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 g=[];for(let y=0;y<o[d].length;++y)g.push(o[d][y][m]);const x=uV(g);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 uV(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 wo(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,g=d.count;m<g;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 I_(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 YC={exports:{}};var dV;function TOe(){return dV||(dV=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 I_=="function"&&I_;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 g=i[u]={exports:{}};r[u][0].call(g.exports,function(x){var y=r[u][1][x];return o(y||x)},g,g.exports,n,r,i,a)}return i[u].exports}for(var l=typeof I_=="function"&&I_,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,g,x,y,b=[],v=0,M=c.length,S=M,A=a.getTypeOf(c)!=="string";v<c.length;)S=M-v,f=A?(u=c[v++],d=v<M?c[v++]:0,v<M?c[v++]:0):(u=c.charCodeAt(v++),d=v<M?c.charCodeAt(v++):0,v<M?c.charCodeAt(v++):0),m=u>>2,g=(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(g)+l.charAt(x)+l.charAt(y));return b.join("")},i.decode=function(c){var u,d,f,m,g,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 M,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(M=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|(g=l.indexOf(c.charAt(y++)))>>2,f=(3&g)<<6|(x=l.indexOf(c.charAt(y++))),M[b++]=u,g!==64&&(M[b++]=d),x!==64&&(M[b++]=f);return M}},{"./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,g,x){this.compressedSize=d,this.uncompressedSize=f,this.crc32=m,this.compression=g,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 g=o,x=m+f;u^=-1;for(var y=m;y<x;y++)u=u>>>8^g[255&(u^d[y])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,m){var g=o,x=m+f;u^=-1;for(var y=m;y<x;y++)u=u>>>8^g[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(g,x){var y,b="";for(y=0;y<x;y++)b+=String.fromCharCode(255&g),g>>>=8;return b}function o(g,x,y,b,v,M){var S,A,E=g.file,k=g.compression,C=M!==u.utf8encode,R=l.transformTo("string",M(E.name)),T=l.transformTo("string",u.utf8encode(E.name)),P=E.comment,F=l.transformTo("string",M(P)),L=l.transformTo("string",u.utf8encode(P)),X=T.length!==E.name.length,D=L.length!==P.length,K="",Y="",q="",Z=E.dir,re=E.date,oe={crc32:0,compressedSize:0,uncompressedSize:0};x&&!y||(oe.crc32=g.crc32,oe.compressedSize=g.compressedSize,oe.uncompressedSize=g.uncompressedSize);var B=0;x&&(B|=8),C||!X&&!D||(B|=2048);var G=0,J=0;Z&&(G|=16),v==="UNIX"?(J=798,G|=(function(ae,de){var fe=ae;return ae||(fe=de?16893:33204),(65535&fe)<<16})(E.unixPermissions,Z)):(J=20,G|=(function(ae){return 63&(ae||0)})(E.dosPermissions)),S=re.getUTCHours(),S<<=6,S|=re.getUTCMinutes(),S<<=5,S|=re.getUTCSeconds()/2,A=re.getUTCFullYear()-1980,A<<=4,A|=re.getUTCMonth()+1,A<<=5,A|=re.getUTCDate(),X&&(Y=a(1,1)+a(d(R),4)+T,K+="up"+a(Y.length,2)+Y),D&&(q=a(1,1)+a(d(F),4)+L,K+="uc"+a(q.length,2)+q);var te="";return te+=`
- \0`,te+=a(B,2),te+=k.magic,te+=a(S,2),te+=a(A,2),te+=a(oe.crc32,4),te+=a(oe.compressedSize,4),te+=a(oe.uncompressedSize,4),te+=a(R.length,2),te+=a(K.length,2),{fileRecord:f.LOCAL_FILE_HEADER+te+R+K,dirRecord:f.CENTRAL_FILE_HEADER+a(J,2)+te+a(F.length,2)+"\0\0\0\0"+a(G,4)+a(b,4)+R+K+F}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function m(g,x,y,b){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=y,this.encodeFileName=b,this.streamFiles=g,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(g){var x=g.meta.percent||0,y=this.entriesCount,b=this._sources.length;this.accumulate?this.contentBuffer.push(g):(this.bytesWritten+=g.data.length,c.prototype.push.call(this,{data:g.data,meta:{currentFile:this.currentFile,percent:y?(x+100*(y-b-1))/y:100}}))},m.prototype.openedSource=function(g){this.currentSourceOffset=this.bytesWritten,this.currentFile=g.file.name;var x=this.streamFiles&&!g.file.dir;if(x){var y=o(g,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(g){this.accumulate=!1;var x=this.streamFiles&&!g.file.dir,y=o(g,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)})(g),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 g=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var y=this.bytesWritten-g,b=(function(v,M,S,A,E){var k=l.transformTo("string",E(A));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(v,2)+a(v,2)+a(M,4)+a(S,4)+a(k.length,2)+k})(this.dirRecords.length,y,g,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(g){this._sources.push(g);var x=this;return g.on("data",function(y){x.processChunk(y)}),g.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),g.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(g){var x=this._sources;if(!c.prototype.error.call(this,g))return!1;for(var y=0;y<x.length;y++)try{x[y].error(g)}catch{}return!0},m.prototype.lock=function(){c.prototype.lock.call(this);for(var g=this._sources,x=0;x<g.length;x++)g[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,g){f++;var x=(function(M,S){var A=M||S,E=a[A];if(!E)throw new Error(A+" is not a valid compression method !");return E})(g.options.compression,c.compression),y=g.options.compressionOptions||c.compressionOptions||{},b=g.dir,v=g.date;g._compressWorker(x,y).withStreamInfo("file",{name:m,dir:b,date:v,comment:g.comment||"",unixPermissions:g.unixPermissions,dosPermissions:g.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(g,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")):g()}).resume()})}r.exports=function(m,g){var x=this;return g=a.extend(g||{},{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,g.optimizedBinaryString,g.base64).then(function(y){var b=new c(g);return b.load(y),b}).then(function(y){var b=[o.Promise.resolve(y)],v=y.files;if(g.checkCRC32)for(var M=0;M<v.length;M++)b.push(f(v[M]));return o.Promise.all(b)}).then(function(y){for(var b=y.shift(),v=b.files,M=0;M<v.length;M++){var S=v[M],A=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:g.createFolders}),S.dir||(x.file(E).unsafeOriginalName=A)}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,k,C){var R,T=l.getTypeOf(k),P=l.extend(C||{},d);P.date=P.date||new Date,P.compression!==null&&(P.compression=P.compression.toUpperCase()),typeof P.unixPermissions=="string"&&(P.unixPermissions=parseInt(P.unixPermissions,8)),P.unixPermissions&&16384&P.unixPermissions&&(P.dir=!0),P.dosPermissions&&16&P.dosPermissions&&(P.dir=!0),P.dir&&(E=v(E)),P.createFolders&&(R=b(E))&&M.call(this,R,!0);var F=T==="string"&&P.binary===!1&&P.base64===!1;C&&C.binary!==void 0||(P.binary=!F),(k instanceof f&&k.uncompressedSize===0||P.dir||!k||k.length===0)&&(P.base64=!1,P.binary=!0,k="",P.compression="STORE",T="string");var L=null;L=k instanceof f||k instanceof c?k:x.isNode&&x.isStream(k)?new y(E,k):l.prepareContent(E,k,P.binary,P.optimizedBinaryString,P.base64);var X=new m(E,L,P);this.files[E]=X}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),m=n("./zipObject"),g=n("./generate"),x=n("./nodejsUtils"),y=n("./nodejs/NodejsStreamInputAdapter"),b=function(E){E.slice(-1)==="/"&&(E=E.substring(0,E.length-1));var k=E.lastIndexOf("/");return 0<k?E.substring(0,k):""},v=function(E){return E.slice(-1)!=="/"&&(E+="/"),E},M=function(E,k){return k=k!==void 0?k:d.createFolders,E=v(E),this.files[E]||a.call(this,E,null,{dir:!0,createFolders:k}),this.files[E]};function S(E){return Object.prototype.toString.call(E)==="[object RegExp]"}var A={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(E){var k,C,R;for(k in this.files)R=this.files[k],(C=k.slice(this.root.length,k.length))&&k.slice(0,this.root.length)===this.root&&E(C,R)},filter:function(E){var k=[];return this.forEach(function(C,R){E(C,R)&&k.push(R)}),k},file:function(E,k,C){if(arguments.length!==1)return E=this.root+E,a.call(this,E,k,C),this;if(S(E)){var R=E;return this.filter(function(P,F){return!F.dir&&R.test(P)})}var T=this.files[this.root+E];return T&&!T.dir?T:null},folder:function(E){if(!E)return this;if(S(E))return this.filter(function(T,P){return P.dir&&E.test(T)});var k=this.root+E,C=M.call(this,k),R=this.clone();return R.root=C.name,R},remove:function(E){E=this.root+E;var k=this.files[E];if(k||(E.slice(-1)!=="/"&&(E+="/"),k=this.files[E]),k&&!k.dir)delete this.files[E];else for(var C=this.filter(function(T,P){return P.name.slice(0,E.length)===E}),R=0;R<C.length;R++)delete this.files[C[R].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(E){var k,C={};try{if((C=l.extend(E||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=C.type.toLowerCase(),C.compression=C.compression.toUpperCase(),C.type==="binarystring"&&(C.type="string"),!C.type)throw new Error("No output type specified.");l.checkSupport(C.type),C.platform!=="darwin"&&C.platform!=="freebsd"&&C.platform!=="linux"&&C.platform!=="sunos"||(C.platform="UNIX"),C.platform==="win32"&&(C.platform="DOS");var R=C.comment||this.comment||"";k=g.generateWorker(this,C,R)}catch(T){(k=new c("error")).error(T)}return new u(k,C.type||"string",C.mimeType)},generateAsync:function(E,k){return this.generateInternalStream(E).accumulate(k)},generateNodeStream:function(E,k){return(E=E||{}).type||(E.type="nodebuffer"),this.generateInternalStream(E).toNodejsStream(k)}};r.exports=A},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var 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 M=[],S=x._internalType,A=x._outputType,E=x._mimeType;x.on("data",function(k,C){M.push(k),y&&y(C)}).on("error",function(k){M=[],v(k)}).on("end",function(){try{var k=(function(C,R,T){switch(C){case"blob":return a.newBlob(a.transformTo("arraybuffer",R),T);case"base64":return c.encode(R);default:return a.transformTo(C,R)}})(A,(function(C,R){var T,P=0,F=null,L=0;for(T=0;T<R.length;T++)L+=R[T].length;switch(C){case"string":return R.join("");case"array":return Array.prototype.concat.apply([],R);case"uint8array":for(F=new Uint8Array(L),T=0;T<R.length;T++)F.set(R[T],P),P+=R[T].length;return F;case"nodebuffer":return Buffer.concat(R);default:throw new Error("concat : unsupported type '"+C+"'")}})(S,M),E);b(k)}catch(C){v(C)}M=[]}).resume()})}function g(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(M){this._worker=new l("error"),this._worker.error(M)}}g.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=g},{"../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(g){return o.nodebuffer?l.newBufferFrom(g,"utf-8"):(function(x){var y,b,v,M,S,A=x.length,E=0;for(M=0;M<A;M++)(64512&(b=x.charCodeAt(M)))==55296&&M+1<A&&(64512&(v=x.charCodeAt(M+1)))==56320&&(b=65536+(b-55296<<10)+(v-56320),M++),E+=b<128?1:b<2048?2:b<65536?3:4;for(y=o.uint8array?new Uint8Array(E):new Array(E),M=S=0;S<E;M++)(64512&(b=x.charCodeAt(M)))==55296&&M+1<A&&(64512&(v=x.charCodeAt(M+1)))==56320&&(b=65536+(b-55296<<10)+(v-56320),M++),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})(g)},i.utf8decode=function(g){return o.nodebuffer?a.transformTo("nodebuffer",g).toString("utf-8"):(function(x){var y,b,v,M,S=x.length,A=new Array(2*S);for(y=b=0;y<S;)if((v=x[y++])<128)A[b++]=v;else if(4<(M=u[v]))A[b++]=65533,y+=M-1;else{for(v&=M===2?31:M===3?15:7;1<M&&y<S;)v=v<<6|63&x[y++],M--;1<M?A[b++]=65533:v<65536?A[b++]=v:(v-=65536,A[b++]=55296|v>>10&1023,A[b++]=56320|1023&v)}return A.length!==b&&(A.subarray?A=A.subarray(0,b):A.length=b),a.applyFromCharCode(A)})(g=a.transformTo(o.uint8array?"uint8array":"array",g))},a.inherits(f,c),f.prototype.processChunk=function(g){var x=a.transformTo(o.uint8array?"uint8array":"array",g.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(M,S){var A;for((S=S||M.length)>M.length&&(S=M.length),A=S-1;0<=A&&(192&M[A])==128;)A--;return A<0||A===0?S:A+u[M[A]]>S?A: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:g.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(g){this.push({data:i.utf8encode(g.data),meta:g.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 M=[],S=0,A=y.length;if(A<=v)return String.fromCharCode.apply(null,y);for(;S<A;)b==="array"||b==="nodebuffer"?M.push(String.fromCharCode.apply(null,y.slice(S,Math.min(S+v,A)))):M.push(String.fromCharCode.apply(null,y.subarray(S,Math.min(S+v,A)))),S+=v;return M.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),M=!0;if(v==="uint8array"?M=f.applyCanBeUsed.uint8array:v==="nodebuffer"&&(M=f.applyCanBeUsed.nodebuffer),M)for(;1<b;)try{return f.stringifyByChunk(y,v,b)}catch{b=Math.floor(b/2)}return f.stringifyByChar(y)}function g(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 g(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 g(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 g(y,new Array(y.length))},arraybuffer:function(y){return x.nodebuffer.uint8array(y).buffer},uint8array:function(y){return g(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=[],M=0;M<b.length;M++){var S=b[M];S==="."||S===""&&M!==0&&M!==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,M="";for(v=0;v<(y||"").length;v++)M+="\\x"+((b=y.charCodeAt(v))<16?"0":"")+b.toString(16).toUpperCase();return M},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,M,S){return c.Promise.resolve(b).then(function(A){return a.blob&&(A instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(A))!==-1)&&typeof FileReader<"u"?new c.Promise(function(E,k){var C=new FileReader;C.onload=function(R){E(R.target.result)},C.onerror=function(R){k(R.target.error)},C.readAsArrayBuffer(A)}):A}).then(function(A){var E=i.getTypeOf(A);return E?(E==="arraybuffer"?A=i.transformTo("uint8array",A):E==="string"&&(S?A=o.decode(A):v&&M!==!0&&(A=(function(k){return d(k,a.uint8array?new Uint8Array(k.length):new Array(k.length))})(A))),A):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 g=this.reader.index;this.reader.setIndex(f);var x=this.reader.readString(4)===m;return this.reader.setIndex(g),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",g=o.transformTo(m,f);this.zipComment=this.loadOptions.decodeFileName(g)},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,g,x=this.zip64EndOfCentralSize-44;0<x;)f=this.reader.readInt(2),m=this.reader.readInt(4),g=this.reader.readData(m),this.zip64ExtensibleData[f]={id:f,length:m,value:g}},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 g=this.centralDirOffset+this.centralDirSize;this.zip64&&(g+=20,g+=12+this.zip64EndOfCentralSize);var x=m-g;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(g,x){this.options=g,this.loadOptions=x}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(g){var x,y;if(g.skip(22),this.fileNameLength=g.readInt(2),y=g.readInt(2),this.fileName=g.readData(this.fileNameLength),g.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,g.readData(this.compressedSize))},readCentralPart:function(g){this.versionMadeBy=g.readInt(2),g.skip(2),this.bitFlag=g.readInt(2),this.compressionMethod=g.readString(2),this.date=g.readDate(),this.crc32=g.readInt(4),this.compressedSize=g.readInt(4),this.uncompressedSize=g.readInt(4);var x=g.readInt(2);if(this.extraFieldsLength=g.readInt(2),this.fileCommentLength=g.readInt(2),this.diskNumberStart=g.readInt(2),this.internalFileAttributes=g.readInt(2),this.externalFileAttributes=g.readInt(4),this.localHeaderOffset=g.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");g.skip(x),this.readExtraFields(g),this.parseZIP64ExtraField(g),this.fileComment=g.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var g=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),g==0&&(this.dosPermissions=63&this.externalFileAttributes),g==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var g=a(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=g.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=g.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=g.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=g.readInt(4))}},readExtraFields:function(g){var x,y,b,v=g.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});g.index+4<v;)x=g.readInt(2),y=g.readInt(2),b=g.readData(y),this.extraFields[x]={id:x,length:y,value:b};g.setIndex(v)},handleUTF8:function(){var g=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(g,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(y)}var b=this.findExtraFieldUnicodeComment();if(b!==null)this.fileCommentStr=b;else{var v=o.transformTo(g,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var g=this.extraFields[28789];if(g){var x=a(g.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(g.length-5))}return null},findExtraFieldUnicodeComment:function(){var g=this.extraFields[25461];if(g){var x=a(g.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(g.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 M=!this._dataBinary;M&&!v&&(y=y.pipe(new c.Utf8EncodeWorker)),!M&&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.")},g=0;g<f.length;g++)a.prototype[f[g]]=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 g=[];function x(){var y,b;l=!0;for(var v=g.length;v;){for(b=g,g=[],y=-1;++y<v;)b[y]();v=g.length}l=!1}r.exports=function(y){g.push(y)!==1||l||o()}}).call(this,typeof Gv<"u"?Gv: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,M,S){this.promise=v,typeof M=="function"&&(this.onFulfilled=M,this.callFulfilled=this.otherCallFulfilled),typeof S=="function"&&(this.onRejected=S,this.callRejected=this.otherCallRejected)}function g(v,M,S){a(function(){var A;try{A=M(S)}catch(E){return l.reject(v,E)}A===v?l.reject(v,new TypeError("Cannot resolve promise with itself")):l.resolve(v,A)})}function x(v){var M=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof M=="function")return function(){M.apply(v,arguments)}}function y(v,M){var S=!1;function A(C){S||(S=!0,l.reject(v,C))}function E(C){S||(S=!0,l.resolve(v,C))}var k=b(function(){M(E,A)});k.status==="error"&&A(k.value)}function b(v,M){var S={};try{S.value=v(M),S.status="success"}catch(A){S.status="error",S.value=A}return S}(r.exports=f).prototype.finally=function(v){if(typeof v!="function")return this;var M=this.constructor;return this.then(function(S){return M.resolve(v()).then(function(){return S})},function(S){return M.resolve(v()).then(function(){throw S})})},f.prototype.catch=function(v){return this.then(null,v)},f.prototype.then=function(v,M){if(typeof v!="function"&&this.state===u||typeof M!="function"&&this.state===c)return this;var S=new this.constructor(o);return this.state!==d?g(S,this.state===u?v:M,this.outcome):this.queue.push(new m(S,v,M)),S},m.prototype.callFulfilled=function(v){l.resolve(this.promise,v)},m.prototype.otherCallFulfilled=function(v){g(this.promise,this.onFulfilled,v)},m.prototype.callRejected=function(v){l.reject(this.promise,v)},m.prototype.otherCallRejected=function(v){g(this.promise,this.onRejected,v)},l.resolve=function(v,M){var S=b(x,M);if(S.status==="error")return l.reject(v,S.value);var A=S.value;if(A)y(v,A);else{v.state=u,v.outcome=M;for(var E=-1,k=v.queue.length;++E<k;)v.queue[E].callFulfilled(M)}return v},l.reject=function(v,M){v.state=c,v.outcome=M;for(var S=-1,A=v.queue.length;++S<A;)v.queue[S].callRejected(M);return v},f.resolve=function(v){return v instanceof this?v:l.resolve(new this(o),v)},f.reject=function(v){var M=new this(o);return l.reject(M,v)},f.all=function(v){var M=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=v.length,A=!1;if(!S)return this.resolve([]);for(var E=new Array(S),k=0,C=-1,R=new this(o);++C<S;)T(v[C],C);return R;function T(P,F){M.resolve(P).then(function(L){E[F]=L,++k!==S||A||(A=!0,l.resolve(R,E))},function(L){A||(A=!0,l.reject(R,L))})}},f.race=function(v){var M=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=v.length,A=!1;if(!S)return this.resolve([]);for(var E=-1,k=new this(o);++E<S;)C=v[E],M.resolve(C).then(function(R){A||(A=!0,l.resolve(k,R))},function(R){A||(A=!0,l.reject(k,R))});var C;return k}},{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,g=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:g,to:""},v||{});var M=this.options;M.raw&&0<M.windowBits?M.windowBits=-M.windowBits:M.gzip&&0<M.windowBits&&M.windowBits<16&&(M.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,M.level,M.method,M.windowBits,M.memLevel,M.strategy);if(S!==f)throw new Error(c[S]);if(M.header&&a.deflateSetHeader(this.strm,M.header),M.dictionary){var A;if(A=typeof M.dictionary=="string"?l.string2buf(M.dictionary):d.call(M.dictionary)==="[object ArrayBuffer]"?new Uint8Array(M.dictionary):M.dictionary,(S=a.deflateSetDictionary(this.strm,A))!==f)throw new Error(c[S]);this._dict_set=!0}}function b(v,M){var S=new y(M);if(S.push(v,!0),S.err)throw S.msg||c[S.err];return S.result}y.prototype.push=function(v,M){var S,A,E=this.strm,k=this.options.chunkSize;if(this.ended)return!1;A=M===~~M?M:M===!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(k),E.next_out=0,E.avail_out=k),(S=a.deflate(E,A))!==1&&S!==f)return this.onEnd(S),!(this.ended=!0);E.avail_out!==0&&(E.avail_in!==0||A!==4&&A!==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 A===4?(S=a.deflateEnd(this.strm),this.onEnd(S),this.ended=!0,S===f):A!==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,M){return(M=M||{}).raw=!0,b(v,M)},i.gzip=function(v,M){return(M=M||{}).gzip=!0,b(v,M)}},{"./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 g(y){if(!(this instanceof g))return new g(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 g(b);if(v.push(y,!0),v.err)throw v.msg||u[v.err];return v.result}g.prototype.push=function(y,b){var v,M,S,A,E,k,C=this.strm,R=this.options.chunkSize,T=this.options.dictionary,P=!1;if(this.ended)return!1;M=b===~~b?b:b===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof y=="string"?C.input=l.binstring2buf(y):m.call(y)==="[object ArrayBuffer]"?C.input=new Uint8Array(y):C.input=y,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new o.Buf8(R),C.next_out=0,C.avail_out=R),(v=a.inflate(C,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&T&&(k=typeof T=="string"?l.string2buf(T):m.call(T)==="[object ArrayBuffer]"?new Uint8Array(T):T,v=a.inflateSetDictionary(this.strm,k)),v===c.Z_BUF_ERROR&&P===!0&&(v=c.Z_OK,P=!1),v!==c.Z_STREAM_END&&v!==c.Z_OK)return this.onEnd(v),!(this.ended=!0);C.next_out&&(C.avail_out!==0&&v!==c.Z_STREAM_END&&(C.avail_in!==0||M!==c.Z_FINISH&&M!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(S=l.utf8border(C.output,C.next_out),A=C.next_out-S,E=l.buf2string(C.output,S),C.next_out=A,C.avail_out=R-A,A&&o.arraySet(C.output,C.output,S,A,0),this.onData(E)):this.onData(o.shrinkBuf(C.output,C.next_out)))),C.avail_in===0&&C.avail_out===0&&(P=!0)}while((0<C.avail_in||C.avail_out===0)&&v!==c.Z_STREAM_END);return v===c.Z_STREAM_END&&(M=c.Z_FINISH),M===c.Z_FINISH?(v=a.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===c.Z_OK):M!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(C.avail_out=0))},g.prototype.onData=function(y){this.chunks.push(y)},g.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=g,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 g=0;g<f;g++)c[m+g]=u[d+g]},flattenChunks:function(c){var u,d,f,m,g,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++)g=c[u],x.set(g,m),m+=g.length;return x}},l={arraySet:function(c,u,d,f,m){for(var g=0;g<f;g++)c[m+g]=u[d+g]},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 g="",x=0;x<m;x++)g+=String.fromCharCode(f[x]);return g}c[254]=c[254]=1,i.string2buf=function(f){var m,g,x,y,b,v=f.length,M=0;for(y=0;y<v;y++)(64512&(g=f.charCodeAt(y)))==55296&&y+1<v&&(64512&(x=f.charCodeAt(y+1)))==56320&&(g=65536+(g-55296<<10)+(x-56320),y++),M+=g<128?1:g<2048?2:g<65536?3:4;for(m=new a.Buf8(M),y=b=0;b<M;y++)(64512&(g=f.charCodeAt(y)))==55296&&y+1<v&&(64512&(x=f.charCodeAt(y+1)))==56320&&(g=65536+(g-55296<<10)+(x-56320),y++),g<128?m[b++]=g:(g<2048?m[b++]=192|g>>>6:(g<65536?m[b++]=224|g>>>12:(m[b++]=240|g>>>18,m[b++]=128|g>>>12&63),m[b++]=128|g>>>6&63),m[b++]=128|63&g);return m},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var m=new a.Buf8(f.length),g=0,x=m.length;g<x;g++)m[g]=f.charCodeAt(g);return m},i.buf2string=function(f,m){var g,x,y,b,v=m||f.length,M=new Array(2*v);for(g=x=0;g<v;)if((y=f[g++])<128)M[x++]=y;else if(4<(b=c[y]))M[x++]=65533,g+=b-1;else{for(y&=b===2?31:b===3?15:7;1<b&&g<v;)y=y<<6|63&f[g++],b--;1<b?M[x++]=65533:y<65536?M[x++]=y:(y-=65536,M[x++]=55296|y>>10&1023,M[x++]=56320|1023&y)}return d(M,x)},i.utf8border=function(f,m){var g;for((m=m||f.length)>f.length&&(m=f.length),g=m-1;0<=g&&(192&f[g])==128;)g--;return g<0||g===0?m:g+c[f[g]]>m?g: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,g=0,x=-2,y=-1,b=4,v=2,M=8,S=9,A=286,E=30,k=19,C=2*A+1,R=15,T=3,P=258,F=P+T+1,L=42,X=113,D=1,K=2,Y=3,q=4;function Z($,z){return $.msg=d[z],z}function re($){return($<<1)-(4<$?9:0)}function oe($){for(var z=$.length;0<=--z;)$[z]=0}function B($){var z=$.state,W=z.pending;W>$.avail_out&&(W=$.avail_out),W!==0&&(o.arraySet($.output,z.pending_buf,z.pending_out,W,$.next_out),$.next_out+=W,z.pending_out+=W,$.total_out+=W,$.avail_out-=W,z.pending-=W,z.pending===0&&(z.pending_out=0))}function G($,z){l._tr_flush_block($,0<=$.block_start?$.block_start:-1,$.strstart-$.block_start,z),$.block_start=$.strstart,B($.strm)}function J($,z){$.pending_buf[$.pending++]=z}function te($,z){$.pending_buf[$.pending++]=z>>>8&255,$.pending_buf[$.pending++]=255&z}function ae($,z){var W,U,V=$.max_chain_length,Q=$.strstart,Ee=$.prev_length,Ce=$.nice_match,Ne=$.strstart>$.w_size-F?$.strstart-($.w_size-F):0,H=$.window,O=$.w_mask,ie=$.prev,ye=$.strstart+P,_e=H[Q+Ee-1],le=H[Q+Ee];$.prev_length>=$.good_match&&(V>>=2),Ce>$.lookahead&&(Ce=$.lookahead);do if(H[(W=z)+Ee]===le&&H[W+Ee-1]===_e&&H[W]===H[Q]&&H[++W]===H[Q+1]){Q+=2,W++;do;while(H[++Q]===H[++W]&&H[++Q]===H[++W]&&H[++Q]===H[++W]&&H[++Q]===H[++W]&&H[++Q]===H[++W]&&H[++Q]===H[++W]&&H[++Q]===H[++W]&&H[++Q]===H[++W]&&Q<ye);if(U=P-(ye-Q),Q=ye-P,Ee<U){if($.match_start=z,Ce<=(Ee=U))break;_e=H[Q+Ee-1],le=H[Q+Ee]}}while((z=ie[z&O])>Ne&&--V!=0);return Ee<=$.lookahead?Ee:$.lookahead}function de($){var z,W,U,V,Q,Ee,Ce,Ne,H,O,ie=$.w_size;do{if(V=$.window_size-$.lookahead-$.strstart,$.strstart>=ie+(ie-F)){for(o.arraySet($.window,$.window,ie,ie,0),$.match_start-=ie,$.strstart-=ie,$.block_start-=ie,z=W=$.hash_size;U=$.head[--z],$.head[z]=ie<=U?U-ie:0,--W;);for(z=W=ie;U=$.prev[--z],$.prev[z]=ie<=U?U-ie:0,--W;);V+=ie}if($.strm.avail_in===0)break;if(Ee=$.strm,Ce=$.window,Ne=$.strstart+$.lookahead,H=V,O=void 0,O=Ee.avail_in,H<O&&(O=H),W=O===0?0:(Ee.avail_in-=O,o.arraySet(Ce,Ee.input,Ee.next_in,O,Ne),Ee.state.wrap===1?Ee.adler=c(Ee.adler,Ce,O,Ne):Ee.state.wrap===2&&(Ee.adler=u(Ee.adler,Ce,O,Ne)),Ee.next_in+=O,Ee.total_in+=O,O),$.lookahead+=W,$.lookahead+$.insert>=T)for(Q=$.strstart-$.insert,$.ins_h=$.window[Q],$.ins_h=($.ins_h<<$.hash_shift^$.window[Q+1])&$.hash_mask;$.insert&&($.ins_h=($.ins_h<<$.hash_shift^$.window[Q+T-1])&$.hash_mask,$.prev[Q&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=Q,Q++,$.insert--,!($.lookahead+$.insert<T)););}while($.lookahead<F&&$.strm.avail_in!==0)}function fe($,z){for(var W,U;;){if($.lookahead<F){if(de($),$.lookahead<F&&z===f)return D;if($.lookahead===0)break}if(W=0,$.lookahead>=T&&($.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+T-1])&$.hash_mask,W=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart),W!==0&&$.strstart-W<=$.w_size-F&&($.match_length=ae($,W)),$.match_length>=T)if(U=l._tr_tally($,$.strstart-$.match_start,$.match_length-T),$.lookahead-=$.match_length,$.match_length<=$.max_lazy_match&&$.lookahead>=T){for($.match_length--;$.strstart++,$.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+T-1])&$.hash_mask,W=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart,--$.match_length!=0;);$.strstart++}else $.strstart+=$.match_length,$.match_length=0,$.ins_h=$.window[$.strstart],$.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+1])&$.hash_mask;else U=l._tr_tally($,0,$.window[$.strstart]),$.lookahead--,$.strstart++;if(U&&(G($,!1),$.strm.avail_out===0))return D}return $.insert=$.strstart<T-1?$.strstart:T-1,z===m?(G($,!0),$.strm.avail_out===0?Y:q):$.last_lit&&(G($,!1),$.strm.avail_out===0)?D:K}function Ae($,z){for(var W,U,V;;){if($.lookahead<F){if(de($),$.lookahead<F&&z===f)return D;if($.lookahead===0)break}if(W=0,$.lookahead>=T&&($.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+T-1])&$.hash_mask,W=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart),$.prev_length=$.match_length,$.prev_match=$.match_start,$.match_length=T-1,W!==0&&$.prev_length<$.max_lazy_match&&$.strstart-W<=$.w_size-F&&($.match_length=ae($,W),$.match_length<=5&&($.strategy===1||$.match_length===T&&4096<$.strstart-$.match_start)&&($.match_length=T-1)),$.prev_length>=T&&$.match_length<=$.prev_length){for(V=$.strstart+$.lookahead-T,U=l._tr_tally($,$.strstart-1-$.prev_match,$.prev_length-T),$.lookahead-=$.prev_length-1,$.prev_length-=2;++$.strstart<=V&&($.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+T-1])&$.hash_mask,W=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart),--$.prev_length!=0;);if($.match_available=0,$.match_length=T-1,$.strstart++,U&&(G($,!1),$.strm.avail_out===0))return D}else if($.match_available){if((U=l._tr_tally($,0,$.window[$.strstart-1]))&&G($,!1),$.strstart++,$.lookahead--,$.strm.avail_out===0)return D}else $.match_available=1,$.strstart++,$.lookahead--}return $.match_available&&(U=l._tr_tally($,0,$.window[$.strstart-1]),$.match_available=0),$.insert=$.strstart<T-1?$.strstart:T-1,z===m?(G($,!0),$.strm.avail_out===0?Y:q):$.last_lit&&(G($,!1),$.strm.avail_out===0)?D:K}function ge($,z,W,U,V){this.good_length=$,this.max_lazy=z,this.nice_length=W,this.max_chain=U,this.func=V}function Me(){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=M,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new o.Buf16(2*C),this.dyn_dtree=new o.Buf16(2*(2*E+1)),this.bl_tree=new o.Buf16(2*(2*k+1)),oe(this.dyn_ltree),oe(this.dyn_dtree),oe(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(R+1),this.heap=new o.Buf16(2*A+1),oe(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*A+1),oe(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 je($){var z;return $&&$.state?($.total_in=$.total_out=0,$.data_type=v,(z=$.state).pending=0,z.pending_out=0,z.wrap<0&&(z.wrap=-z.wrap),z.status=z.wrap?L:X,$.adler=z.wrap===2?0:1,z.last_flush=f,l._tr_init(z),g):Z($,x)}function ne($){var z=je($);return z===g&&(function(W){W.window_size=2*W.w_size,oe(W.head),W.max_lazy_match=a[W.level].max_lazy,W.good_match=a[W.level].good_length,W.nice_match=a[W.level].nice_length,W.max_chain_length=a[W.level].max_chain,W.strstart=0,W.block_start=0,W.lookahead=0,W.insert=0,W.match_length=W.prev_length=T-1,W.match_available=0,W.ins_h=0})($.state),z}function Ke($,z,W,U,V,Q){if(!$)return x;var Ee=1;if(z===y&&(z=6),U<0?(Ee=0,U=-U):15<U&&(Ee=2,U-=16),V<1||S<V||W!==M||U<8||15<U||z<0||9<z||Q<0||b<Q)return Z($,x);U===8&&(U=9);var Ce=new Me;return($.state=Ce).strm=$,Ce.wrap=Ee,Ce.gzhead=null,Ce.w_bits=U,Ce.w_size=1<<Ce.w_bits,Ce.w_mask=Ce.w_size-1,Ce.hash_bits=V+7,Ce.hash_size=1<<Ce.hash_bits,Ce.hash_mask=Ce.hash_size-1,Ce.hash_shift=~~((Ce.hash_bits+T-1)/T),Ce.window=new o.Buf8(2*Ce.w_size),Ce.head=new o.Buf16(Ce.hash_size),Ce.prev=new o.Buf16(Ce.w_size),Ce.lit_bufsize=1<<V+6,Ce.pending_buf_size=4*Ce.lit_bufsize,Ce.pending_buf=new o.Buf8(Ce.pending_buf_size),Ce.d_buf=1*Ce.lit_bufsize,Ce.l_buf=3*Ce.lit_bufsize,Ce.level=z,Ce.strategy=Q,Ce.method=W,ne($)}a=[new ge(0,0,0,0,function($,z){var W=65535;for(W>$.pending_buf_size-5&&(W=$.pending_buf_size-5);;){if($.lookahead<=1){if(de($),$.lookahead===0&&z===f)return D;if($.lookahead===0)break}$.strstart+=$.lookahead,$.lookahead=0;var U=$.block_start+W;if(($.strstart===0||$.strstart>=U)&&($.lookahead=$.strstart-U,$.strstart=U,G($,!1),$.strm.avail_out===0)||$.strstart-$.block_start>=$.w_size-F&&(G($,!1),$.strm.avail_out===0))return D}return $.insert=0,z===m?(G($,!0),$.strm.avail_out===0?Y:q):($.strstart>$.block_start&&(G($,!1),$.strm.avail_out),D)}),new ge(4,4,8,4,fe),new ge(4,5,16,8,fe),new ge(4,6,32,32,fe),new ge(4,4,16,16,Ae),new ge(8,16,32,32,Ae),new ge(8,16,128,128,Ae),new ge(8,32,128,256,Ae),new ge(32,128,258,1024,Ae),new ge(32,258,258,4096,Ae)],i.deflateInit=function($,z){return Ke($,z,M,15,8,0)},i.deflateInit2=Ke,i.deflateReset=ne,i.deflateResetKeep=je,i.deflateSetHeader=function($,z){return $&&$.state?$.state.wrap!==2?x:($.state.gzhead=z,g):x},i.deflate=function($,z){var W,U,V,Q;if(!$||!$.state||5<z||z<0)return $?Z($,x):x;if(U=$.state,!$.output||!$.input&&$.avail_in!==0||U.status===666&&z!==m)return Z($,$.avail_out===0?-5:x);if(U.strm=$,W=U.last_flush,U.last_flush=z,U.status===L)if(U.wrap===2)$.adler=0,J(U,31),J(U,139),J(U,8),U.gzhead?(J(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)),J(U,255&U.gzhead.time),J(U,U.gzhead.time>>8&255),J(U,U.gzhead.time>>16&255),J(U,U.gzhead.time>>24&255),J(U,U.level===9?2:2<=U.strategy||U.level<2?4:0),J(U,255&U.gzhead.os),U.gzhead.extra&&U.gzhead.extra.length&&(J(U,255&U.gzhead.extra.length),J(U,U.gzhead.extra.length>>8&255)),U.gzhead.hcrc&&($.adler=u($.adler,U.pending_buf,U.pending,0)),U.gzindex=0,U.status=69):(J(U,0),J(U,0),J(U,0),J(U,0),J(U,0),J(U,U.level===9?2:2<=U.strategy||U.level<2?4:0),J(U,3),U.status=X);else{var Ee=M+(U.w_bits-8<<4)<<8;Ee|=(2<=U.strategy||U.level<2?0:U.level<6?1:U.level===6?2:3)<<6,U.strstart!==0&&(Ee|=32),Ee+=31-Ee%31,U.status=X,te(U,Ee),U.strstart!==0&&(te(U,$.adler>>>16),te(U,65535&$.adler)),$.adler=1}if(U.status===69)if(U.gzhead.extra){for(V=U.pending;U.gzindex<(65535&U.gzhead.extra.length)&&(U.pending!==U.pending_buf_size||(U.gzhead.hcrc&&U.pending>V&&($.adler=u($.adler,U.pending_buf,U.pending-V,V)),B($),V=U.pending,U.pending!==U.pending_buf_size));)J(U,255&U.gzhead.extra[U.gzindex]),U.gzindex++;U.gzhead.hcrc&&U.pending>V&&($.adler=u($.adler,U.pending_buf,U.pending-V,V)),U.gzindex===U.gzhead.extra.length&&(U.gzindex=0,U.status=73)}else U.status=73;if(U.status===73)if(U.gzhead.name){V=U.pending;do{if(U.pending===U.pending_buf_size&&(U.gzhead.hcrc&&U.pending>V&&($.adler=u($.adler,U.pending_buf,U.pending-V,V)),B($),V=U.pending,U.pending===U.pending_buf_size)){Q=1;break}Q=U.gzindex<U.gzhead.name.length?255&U.gzhead.name.charCodeAt(U.gzindex++):0,J(U,Q)}while(Q!==0);U.gzhead.hcrc&&U.pending>V&&($.adler=u($.adler,U.pending_buf,U.pending-V,V)),Q===0&&(U.gzindex=0,U.status=91)}else U.status=91;if(U.status===91)if(U.gzhead.comment){V=U.pending;do{if(U.pending===U.pending_buf_size&&(U.gzhead.hcrc&&U.pending>V&&($.adler=u($.adler,U.pending_buf,U.pending-V,V)),B($),V=U.pending,U.pending===U.pending_buf_size)){Q=1;break}Q=U.gzindex<U.gzhead.comment.length?255&U.gzhead.comment.charCodeAt(U.gzindex++):0,J(U,Q)}while(Q!==0);U.gzhead.hcrc&&U.pending>V&&($.adler=u($.adler,U.pending_buf,U.pending-V,V)),Q===0&&(U.status=103)}else U.status=103;if(U.status===103&&(U.gzhead.hcrc?(U.pending+2>U.pending_buf_size&&B($),U.pending+2<=U.pending_buf_size&&(J(U,255&$.adler),J(U,$.adler>>8&255),$.adler=0,U.status=X)):U.status=X),U.pending!==0){if(B($),$.avail_out===0)return U.last_flush=-1,g}else if($.avail_in===0&&re(z)<=re(W)&&z!==m)return Z($,-5);if(U.status===666&&$.avail_in!==0)return Z($,-5);if($.avail_in!==0||U.lookahead!==0||z!==f&&U.status!==666){var Ce=U.strategy===2?(function(Ne,H){for(var O;;){if(Ne.lookahead===0&&(de(Ne),Ne.lookahead===0)){if(H===f)return D;break}if(Ne.match_length=0,O=l._tr_tally(Ne,0,Ne.window[Ne.strstart]),Ne.lookahead--,Ne.strstart++,O&&(G(Ne,!1),Ne.strm.avail_out===0))return D}return Ne.insert=0,H===m?(G(Ne,!0),Ne.strm.avail_out===0?Y:q):Ne.last_lit&&(G(Ne,!1),Ne.strm.avail_out===0)?D:K})(U,z):U.strategy===3?(function(Ne,H){for(var O,ie,ye,_e,le=Ne.window;;){if(Ne.lookahead<=P){if(de(Ne),Ne.lookahead<=P&&H===f)return D;if(Ne.lookahead===0)break}if(Ne.match_length=0,Ne.lookahead>=T&&0<Ne.strstart&&(ie=le[ye=Ne.strstart-1])===le[++ye]&&ie===le[++ye]&&ie===le[++ye]){_e=Ne.strstart+P;do;while(ie===le[++ye]&&ie===le[++ye]&&ie===le[++ye]&&ie===le[++ye]&&ie===le[++ye]&&ie===le[++ye]&&ie===le[++ye]&&ie===le[++ye]&&ye<_e);Ne.match_length=P-(_e-ye),Ne.match_length>Ne.lookahead&&(Ne.match_length=Ne.lookahead)}if(Ne.match_length>=T?(O=l._tr_tally(Ne,1,Ne.match_length-T),Ne.lookahead-=Ne.match_length,Ne.strstart+=Ne.match_length,Ne.match_length=0):(O=l._tr_tally(Ne,0,Ne.window[Ne.strstart]),Ne.lookahead--,Ne.strstart++),O&&(G(Ne,!1),Ne.strm.avail_out===0))return D}return Ne.insert=0,H===m?(G(Ne,!0),Ne.strm.avail_out===0?Y:q):Ne.last_lit&&(G(Ne,!1),Ne.strm.avail_out===0)?D:K})(U,z):a[U.level].func(U,z);if(Ce!==Y&&Ce!==q||(U.status=666),Ce===D||Ce===Y)return $.avail_out===0&&(U.last_flush=-1),g;if(Ce===K&&(z===1?l._tr_align(U):z!==5&&(l._tr_stored_block(U,0,0,!1),z===3&&(oe(U.head),U.lookahead===0&&(U.strstart=0,U.block_start=0,U.insert=0))),B($),$.avail_out===0))return U.last_flush=-1,g}return z!==m?g:U.wrap<=0?1:(U.wrap===2?(J(U,255&$.adler),J(U,$.adler>>8&255),J(U,$.adler>>16&255),J(U,$.adler>>24&255),J(U,255&$.total_in),J(U,$.total_in>>8&255),J(U,$.total_in>>16&255),J(U,$.total_in>>24&255)):(te(U,$.adler>>>16),te(U,65535&$.adler)),B($),0<U.wrap&&(U.wrap=-U.wrap),U.pending!==0?g:1)},i.deflateEnd=function($){var z;return $&&$.state?(z=$.state.status)!==L&&z!==69&&z!==73&&z!==91&&z!==103&&z!==X&&z!==666?Z($,x):($.state=null,z===X?Z($,-3):g):x},i.deflateSetDictionary=function($,z){var W,U,V,Q,Ee,Ce,Ne,H,O=z.length;if(!$||!$.state||(Q=(W=$.state).wrap)===2||Q===1&&W.status!==L||W.lookahead)return x;for(Q===1&&($.adler=c($.adler,z,O,0)),W.wrap=0,O>=W.w_size&&(Q===0&&(oe(W.head),W.strstart=0,W.block_start=0,W.insert=0),H=new o.Buf8(W.w_size),o.arraySet(H,z,O-W.w_size,W.w_size,0),z=H,O=W.w_size),Ee=$.avail_in,Ce=$.next_in,Ne=$.input,$.avail_in=O,$.next_in=0,$.input=z,de(W);W.lookahead>=T;){for(U=W.strstart,V=W.lookahead-(T-1);W.ins_h=(W.ins_h<<W.hash_shift^W.window[U+T-1])&W.hash_mask,W.prev[U&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=U,U++,--V;);W.strstart=U,W.lookahead=T-1,de(W)}return W.strstart+=W.lookahead,W.block_start=W.strstart,W.insert=W.lookahead,W.lookahead=0,W.match_length=W.prev_length=T-1,W.match_available=0,$.next_in=Ce,$.input=Ne,$.avail_in=Ee,W.wrap=Q,g},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,g,x,y,b,v,M,S,A,E,k,C,R,T,P,F,L,X,D,K;l=a.state,c=a.next_in,D=a.input,u=c+(a.avail_in-5),d=a.next_out,K=a.output,f=d-(o-a.avail_out),m=d+(a.avail_out-257),g=l.dmax,x=l.wsize,y=l.whave,b=l.wnext,v=l.window,M=l.hold,S=l.bits,A=l.lencode,E=l.distcode,k=(1<<l.lenbits)-1,C=(1<<l.distbits)-1;e:do{S<15&&(M+=D[c++]<<S,S+=8,M+=D[c++]<<S,S+=8),R=A[M&k];t:for(;;){if(M>>>=T=R>>>24,S-=T,(T=R>>>16&255)===0)K[d++]=65535&R;else{if(!(16&T)){if((64&T)==0){R=A[(65535&R)+(M&(1<<T)-1)];continue t}if(32&T){l.mode=12;break e}a.msg="invalid literal/length code",l.mode=30;break e}P=65535&R,(T&=15)&&(S<T&&(M+=D[c++]<<S,S+=8),P+=M&(1<<T)-1,M>>>=T,S-=T),S<15&&(M+=D[c++]<<S,S+=8,M+=D[c++]<<S,S+=8),R=E[M&C];n:for(;;){if(M>>>=T=R>>>24,S-=T,!(16&(T=R>>>16&255))){if((64&T)==0){R=E[(65535&R)+(M&(1<<T)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(F=65535&R,S<(T&=15)&&(M+=D[c++]<<S,(S+=8)<T&&(M+=D[c++]<<S,S+=8)),g<(F+=M&(1<<T)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(M>>>=T,S-=T,(T=d-f)<F){if(y<(T=F-T)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(X=v,(L=0)===b){if(L+=x-T,T<P){for(P-=T;K[d++]=v[L++],--T;);L=d-F,X=K}}else if(b<T){if(L+=x+b-T,(T-=b)<P){for(P-=T;K[d++]=v[L++],--T;);if(L=0,b<P){for(P-=T=b;K[d++]=v[L++],--T;);L=d-F,X=K}}}else if(L+=b-T,T<P){for(P-=T;K[d++]=v[L++],--T;);L=d-F,X=K}for(;2<P;)K[d++]=X[L++],K[d++]=X[L++],K[d++]=X[L++],P-=3;P&&(K[d++]=X[L++],1<P&&(K[d++]=X[L++]))}else{for(L=d-F;K[d++]=K[L++],K[d++]=K[L++],K[d++]=K[L++],2<(P-=3););P&&(K[d++]=K[L++],1<P&&(K[d++]=K[L++]))}break}}break}}while(c<u&&d<m);c-=P=S>>3,M&=(1<<(S-=P<<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=M,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,g=-2,x=1,y=852,b=592;function v(L){return(L>>>24&255)+(L>>>8&65280)+((65280&L)<<8)+((255&L)<<24)}function M(){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 X;return L&&L.state?(X=L.state,L.total_in=L.total_out=X.total=0,L.msg="",X.wrap&&(L.adler=1&X.wrap),X.mode=x,X.last=0,X.havedict=0,X.dmax=32768,X.head=null,X.hold=0,X.bits=0,X.lencode=X.lendyn=new a.Buf32(y),X.distcode=X.distdyn=new a.Buf32(b),X.sane=1,X.back=-1,m):g}function A(L){var X;return L&&L.state?((X=L.state).wsize=0,X.whave=0,X.wnext=0,S(L)):g}function E(L,X){var D,K;return L&&L.state?(K=L.state,X<0?(D=0,X=-X):(D=1+(X>>4),X<48&&(X&=15)),X&&(X<8||15<X)?g:(K.window!==null&&K.wbits!==X&&(K.window=null),K.wrap=D,K.wbits=X,A(L))):g}function k(L,X){var D,K;return L?(K=new M,(L.state=K).window=null,(D=E(L,X))!==m&&(L.state=null),D):g}var C,R,T=!0;function P(L){if(T){var X;for(C=new a.Buf32(512),R=new a.Buf32(32),X=0;X<144;)L.lens[X++]=8;for(;X<256;)L.lens[X++]=9;for(;X<280;)L.lens[X++]=7;for(;X<288;)L.lens[X++]=8;for(u(d,L.lens,0,288,C,0,L.work,{bits:9}),X=0;X<32;)L.lens[X++]=5;u(f,L.lens,0,32,R,0,L.work,{bits:5}),T=!1}L.lencode=C,L.lenbits=9,L.distcode=R,L.distbits=5}function F(L,X,D,K){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)),K>=q.wsize?(a.arraySet(q.window,X,D-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(K<(Y=q.wsize-q.wnext)&&(Y=K),a.arraySet(q.window,X,D-K,Y,q.wnext),(K-=Y)?(a.arraySet(q.window,X,D-K,K,0),q.wnext=K,q.whave=q.wsize):(q.wnext+=Y,q.wnext===q.wsize&&(q.wnext=0),q.whave<q.wsize&&(q.whave+=Y))),0}i.inflateReset=A,i.inflateReset2=E,i.inflateResetKeep=S,i.inflateInit=function(L){return k(L,15)},i.inflateInit2=k,i.inflate=function(L,X){var D,K,Y,q,Z,re,oe,B,G,J,te,ae,de,fe,Ae,ge,Me,je,ne,Ke,$,z,W,U,V=0,Q=new a.Buf8(4),Ee=[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 g;(D=L.state).mode===12&&(D.mode=13),Z=L.next_out,Y=L.output,oe=L.avail_out,q=L.next_in,K=L.input,re=L.avail_in,B=D.hold,G=D.bits,J=re,te=oe,z=m;e:for(;;)switch(D.mode){case x:if(D.wrap===0){D.mode=13;break}for(;G<16;){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}if(2&D.wrap&&B===35615){Q[D.check=0]=255&B,Q[1]=B>>>8&255,D.check=l(D.check,Q,2,0),G=B=0,D.mode=2;break}if(D.flags=0,D.head&&(D.head.done=!1),!(1&D.wrap)||(((255&B)<<8)+(B>>8))%31){L.msg="incorrect header check",D.mode=30;break}if((15&B)!=8){L.msg="unknown compression method",D.mode=30;break}if(G-=4,$=8+(15&(B>>>=4)),D.wbits===0)D.wbits=$;else if($>D.wbits){L.msg="invalid window size",D.mode=30;break}D.dmax=1<<$,L.adler=D.check=1,D.mode=512&B?10:12,G=B=0;break;case 2:for(;G<16;){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}if(D.flags=B,(255&D.flags)!=8){L.msg="unknown compression method",D.mode=30;break}if(57344&D.flags){L.msg="unknown header flags set",D.mode=30;break}D.head&&(D.head.text=B>>8&1),512&D.flags&&(Q[0]=255&B,Q[1]=B>>>8&255,D.check=l(D.check,Q,2,0)),G=B=0,D.mode=3;case 3:for(;G<32;){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}D.head&&(D.head.time=B),512&D.flags&&(Q[0]=255&B,Q[1]=B>>>8&255,Q[2]=B>>>16&255,Q[3]=B>>>24&255,D.check=l(D.check,Q,4,0)),G=B=0,D.mode=4;case 4:for(;G<16;){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}D.head&&(D.head.xflags=255&B,D.head.os=B>>8),512&D.flags&&(Q[0]=255&B,Q[1]=B>>>8&255,D.check=l(D.check,Q,2,0)),G=B=0,D.mode=5;case 5:if(1024&D.flags){for(;G<16;){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}D.length=B,D.head&&(D.head.extra_len=B),512&D.flags&&(Q[0]=255&B,Q[1]=B>>>8&255,D.check=l(D.check,Q,2,0)),G=B=0}else D.head&&(D.head.extra=null);D.mode=6;case 6:if(1024&D.flags&&(re<(ae=D.length)&&(ae=re),ae&&(D.head&&($=D.head.extra_len-D.length,D.head.extra||(D.head.extra=new Array(D.head.extra_len)),a.arraySet(D.head.extra,K,q,ae,$)),512&D.flags&&(D.check=l(D.check,K,ae,q)),re-=ae,q+=ae,D.length-=ae),D.length))break e;D.length=0,D.mode=7;case 7:if(2048&D.flags){if(re===0)break e;for(ae=0;$=K[q+ae++],D.head&&$&&D.length<65536&&(D.head.name+=String.fromCharCode($)),$&&ae<re;);if(512&D.flags&&(D.check=l(D.check,K,ae,q)),re-=ae,q+=ae,$)break e}else D.head&&(D.head.name=null);D.length=0,D.mode=8;case 8:if(4096&D.flags){if(re===0)break e;for(ae=0;$=K[q+ae++],D.head&&$&&D.length<65536&&(D.head.comment+=String.fromCharCode($)),$&&ae<re;);if(512&D.flags&&(D.check=l(D.check,K,ae,q)),re-=ae,q+=ae,$)break e}else D.head&&(D.head.comment=null);D.mode=9;case 9:if(512&D.flags){for(;G<16;){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}if(B!==(65535&D.check)){L.msg="header crc mismatch",D.mode=30;break}G=B=0}D.head&&(D.head.hcrc=D.flags>>9&1,D.head.done=!0),L.adler=D.check=0,D.mode=12;break;case 10:for(;G<32;){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}L.adler=D.check=v(B),G=B=0,D.mode=11;case 11:if(D.havedict===0)return L.next_out=Z,L.avail_out=oe,L.next_in=q,L.avail_in=re,D.hold=B,D.bits=G,2;L.adler=D.check=1,D.mode=12;case 12:if(X===5||X===6)break e;case 13:if(D.last){B>>>=7&G,G-=7&G,D.mode=27;break}for(;G<3;){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}switch(D.last=1&B,G-=1,3&(B>>>=1)){case 0:D.mode=14;break;case 1:if(P(D),D.mode=20,X!==6)break;B>>>=2,G-=2;break e;case 2:D.mode=17;break;case 3:L.msg="invalid block type",D.mode=30}B>>>=2,G-=2;break;case 14:for(B>>>=7&G,G-=7&G;G<32;){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}if((65535&B)!=(B>>>16^65535)){L.msg="invalid stored block lengths",D.mode=30;break}if(D.length=65535&B,G=B=0,D.mode=15,X===6)break e;case 15:D.mode=16;case 16:if(ae=D.length){if(re<ae&&(ae=re),oe<ae&&(ae=oe),ae===0)break e;a.arraySet(Y,K,q,ae,Z),re-=ae,q+=ae,oe-=ae,Z+=ae,D.length-=ae;break}D.mode=12;break;case 17:for(;G<14;){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}if(D.nlen=257+(31&B),B>>>=5,G-=5,D.ndist=1+(31&B),B>>>=5,G-=5,D.ncode=4+(15&B),B>>>=4,G-=4,286<D.nlen||30<D.ndist){L.msg="too many length or distance symbols",D.mode=30;break}D.have=0,D.mode=18;case 18:for(;D.have<D.ncode;){for(;G<3;){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}D.lens[Ee[D.have++]]=7&B,B>>>=3,G-=3}for(;D.have<19;)D.lens[Ee[D.have++]]=0;if(D.lencode=D.lendyn,D.lenbits=7,W={bits:D.lenbits},z=u(0,D.lens,0,19,D.lencode,0,D.work,W),D.lenbits=W.bits,z){L.msg="invalid code lengths set",D.mode=30;break}D.have=0,D.mode=19;case 19:for(;D.have<D.nlen+D.ndist;){for(;ge=(V=D.lencode[B&(1<<D.lenbits)-1])>>>16&255,Me=65535&V,!((Ae=V>>>24)<=G);){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}if(Me<16)B>>>=Ae,G-=Ae,D.lens[D.have++]=Me;else{if(Me===16){for(U=Ae+2;G<U;){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}if(B>>>=Ae,G-=Ae,D.have===0){L.msg="invalid bit length repeat",D.mode=30;break}$=D.lens[D.have-1],ae=3+(3&B),B>>>=2,G-=2}else if(Me===17){for(U=Ae+3;G<U;){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}G-=Ae,$=0,ae=3+(7&(B>>>=Ae)),B>>>=3,G-=3}else{for(U=Ae+7;G<U;){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}G-=Ae,$=0,ae=11+(127&(B>>>=Ae)),B>>>=7,G-=7}if(D.have+ae>D.nlen+D.ndist){L.msg="invalid bit length repeat",D.mode=30;break}for(;ae--;)D.lens[D.have++]=$}}if(D.mode===30)break;if(D.lens[256]===0){L.msg="invalid code -- missing end-of-block",D.mode=30;break}if(D.lenbits=9,W={bits:D.lenbits},z=u(d,D.lens,0,D.nlen,D.lencode,0,D.work,W),D.lenbits=W.bits,z){L.msg="invalid literal/lengths set",D.mode=30;break}if(D.distbits=6,D.distcode=D.distdyn,W={bits:D.distbits},z=u(f,D.lens,D.nlen,D.ndist,D.distcode,0,D.work,W),D.distbits=W.bits,z){L.msg="invalid distances set",D.mode=30;break}if(D.mode=20,X===6)break e;case 20:D.mode=21;case 21:if(6<=re&&258<=oe){L.next_out=Z,L.avail_out=oe,L.next_in=q,L.avail_in=re,D.hold=B,D.bits=G,c(L,te),Z=L.next_out,Y=L.output,oe=L.avail_out,q=L.next_in,K=L.input,re=L.avail_in,B=D.hold,G=D.bits,D.mode===12&&(D.back=-1);break}for(D.back=0;ge=(V=D.lencode[B&(1<<D.lenbits)-1])>>>16&255,Me=65535&V,!((Ae=V>>>24)<=G);){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}if(ge&&(240&ge)==0){for(je=Ae,ne=ge,Ke=Me;ge=(V=D.lencode[Ke+((B&(1<<je+ne)-1)>>je)])>>>16&255,Me=65535&V,!(je+(Ae=V>>>24)<=G);){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}B>>>=je,G-=je,D.back+=je}if(B>>>=Ae,G-=Ae,D.back+=Ae,D.length=Me,ge===0){D.mode=26;break}if(32&ge){D.back=-1,D.mode=12;break}if(64&ge){L.msg="invalid literal/length code",D.mode=30;break}D.extra=15&ge,D.mode=22;case 22:if(D.extra){for(U=D.extra;G<U;){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}D.length+=B&(1<<D.extra)-1,B>>>=D.extra,G-=D.extra,D.back+=D.extra}D.was=D.length,D.mode=23;case 23:for(;ge=(V=D.distcode[B&(1<<D.distbits)-1])>>>16&255,Me=65535&V,!((Ae=V>>>24)<=G);){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}if((240&ge)==0){for(je=Ae,ne=ge,Ke=Me;ge=(V=D.distcode[Ke+((B&(1<<je+ne)-1)>>je)])>>>16&255,Me=65535&V,!(je+(Ae=V>>>24)<=G);){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}B>>>=je,G-=je,D.back+=je}if(B>>>=Ae,G-=Ae,D.back+=Ae,64&ge){L.msg="invalid distance code",D.mode=30;break}D.offset=Me,D.extra=15&ge,D.mode=24;case 24:if(D.extra){for(U=D.extra;G<U;){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}D.offset+=B&(1<<D.extra)-1,B>>>=D.extra,G-=D.extra,D.back+=D.extra}if(D.offset>D.dmax){L.msg="invalid distance too far back",D.mode=30;break}D.mode=25;case 25:if(oe===0)break e;if(ae=te-oe,D.offset>ae){if((ae=D.offset-ae)>D.whave&&D.sane){L.msg="invalid distance too far back",D.mode=30;break}de=ae>D.wnext?(ae-=D.wnext,D.wsize-ae):D.wnext-ae,ae>D.length&&(ae=D.length),fe=D.window}else fe=Y,de=Z-D.offset,ae=D.length;for(oe<ae&&(ae=oe),oe-=ae,D.length-=ae;Y[Z++]=fe[de++],--ae;);D.length===0&&(D.mode=21);break;case 26:if(oe===0)break e;Y[Z++]=D.length,oe--,D.mode=21;break;case 27:if(D.wrap){for(;G<32;){if(re===0)break e;re--,B|=K[q++]<<G,G+=8}if(te-=oe,L.total_out+=te,D.total+=te,te&&(L.adler=D.check=D.flags?l(D.check,Y,te,Z-te):o(D.check,Y,te,Z-te)),te=oe,(D.flags?B:v(B))!==D.check){L.msg="incorrect data check",D.mode=30;break}G=B=0}D.mode=28;case 28:if(D.wrap&&D.flags){for(;G<32;){if(re===0)break e;re--,B+=K[q++]<<G,G+=8}if(B!==(4294967295&D.total)){L.msg="incorrect length check",D.mode=30;break}G=B=0}D.mode=29;case 29:z=1;break e;case 30:z=-3;break e;case 31:return-4;case 32:default:return g}return L.next_out=Z,L.avail_out=oe,L.next_in=q,L.avail_in=re,D.hold=B,D.bits=G,(D.wsize||te!==L.avail_out&&D.mode<30&&(D.mode<27||X!==4))&&F(L,L.output,L.next_out,te-L.avail_out)?(D.mode=31,-4):(J-=L.avail_in,te-=L.avail_out,L.total_in+=J,L.total_out+=te,D.total+=te,D.wrap&&te&&(L.adler=D.check=D.flags?l(D.check,Y,te,L.next_out-te):o(D.check,Y,te,L.next_out-te)),L.data_type=D.bits+(D.last?64:0)+(D.mode===12?128:0)+(D.mode===20||D.mode===15?256:0),(J==0&&te===0||X===4)&&z===m&&(z=-5),z)},i.inflateEnd=function(L){if(!L||!L.state)return g;var X=L.state;return X.window&&(X.window=null),L.state=null,m},i.inflateGetHeader=function(L,X){var D;return L&&L.state?(2&(D=L.state).wrap)==0?g:((D.head=X).done=!1,m):g},i.inflateSetDictionary=function(L,X){var D,K=X.length;return L&&L.state?(D=L.state).wrap!==0&&D.mode!==11?g:D.mode===11&&o(1,X,K,0)!==D.check?-3:F(L,X,K,K)?(D.mode=31,-4):(D.havedict=1,m):g},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,g,x,y,b,v){var M,S,A,E,k,C,R,T,P,F=v.bits,L=0,X=0,D=0,K=0,Y=0,q=0,Z=0,re=0,oe=0,B=0,G=null,J=0,te=new a.Buf16(16),ae=new a.Buf16(16),de=null,fe=0;for(L=0;L<=15;L++)te[L]=0;for(X=0;X<g;X++)te[f[m+X]]++;for(Y=F,K=15;1<=K&&te[K]===0;K--);if(K<Y&&(Y=K),K===0)return x[y++]=20971520,x[y++]=20971520,v.bits=1,0;for(D=1;D<K&&te[D]===0;D++);for(Y<D&&(Y=D),L=re=1;L<=15;L++)if(re<<=1,(re-=te[L])<0)return-1;if(0<re&&(d===0||K!==1))return-1;for(ae[1]=0,L=1;L<15;L++)ae[L+1]=ae[L]+te[L];for(X=0;X<g;X++)f[m+X]!==0&&(b[ae[f[m+X]]++]=X);if(C=d===0?(G=de=b,19):d===1?(G=o,J-=257,de=l,fe-=257,256):(G=c,de=u,-1),L=D,k=y,Z=X=B=0,A=-1,E=(oe=1<<(q=Y))-1,d===1&&852<oe||d===2&&592<oe)return 1;for(;;){for(R=L-Z,P=b[X]<C?(T=0,b[X]):b[X]>C?(T=de[fe+b[X]],G[J+b[X]]):(T=96,0),M=1<<L-Z,D=S=1<<q;x[k+(B>>Z)+(S-=M)]=R<<24|T<<16|P|0,S!==0;);for(M=1<<L-1;B&M;)M>>=1;if(M!==0?(B&=M-1,B+=M):B=0,X++,--te[L]==0){if(L===K)break;L=f[m+b[X]]}if(Y<L&&(B&E)!==A){for(Z===0&&(Z=Y),k+=D,re=1<<(q=L-Z);q+Z<K&&!((re-=te[q+Z])<=0);)q++,re<<=1;if(oe+=1<<q,d===1&&852<oe||d===2&&592<oe)return 1;x[A=B&E]=Y<<24|q<<16|k-y|0}}return B!==0&&(x[k+B]=L-Z<<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(V){for(var Q=V.length;0<=--Q;)V[Q]=0}var u=0,d=29,f=256,m=f+1+d,g=30,x=19,y=2*m+1,b=15,v=16,M=7,S=256,A=16,E=17,k=18,C=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],R=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],F=new Array(2*(m+2));c(F);var L=new Array(2*g);c(L);var X=new Array(512);c(X);var D=new Array(256);c(D);var K=new Array(d);c(K);var Y,q,Z,re=new Array(g);function oe(V,Q,Ee,Ce,Ne){this.static_tree=V,this.extra_bits=Q,this.extra_base=Ee,this.elems=Ce,this.max_length=Ne,this.has_stree=V&&V.length}function B(V,Q){this.dyn_tree=V,this.max_code=0,this.stat_desc=Q}function G(V){return V<256?X[V]:X[256+(V>>>7)]}function J(V,Q){V.pending_buf[V.pending++]=255&Q,V.pending_buf[V.pending++]=Q>>>8&255}function te(V,Q,Ee){V.bi_valid>v-Ee?(V.bi_buf|=Q<<V.bi_valid&65535,J(V,V.bi_buf),V.bi_buf=Q>>v-V.bi_valid,V.bi_valid+=Ee-v):(V.bi_buf|=Q<<V.bi_valid&65535,V.bi_valid+=Ee)}function ae(V,Q,Ee){te(V,Ee[2*Q],Ee[2*Q+1])}function de(V,Q){for(var Ee=0;Ee|=1&V,V>>>=1,Ee<<=1,0<--Q;);return Ee>>>1}function fe(V,Q,Ee){var Ce,Ne,H=new Array(b+1),O=0;for(Ce=1;Ce<=b;Ce++)H[Ce]=O=O+Ee[Ce-1]<<1;for(Ne=0;Ne<=Q;Ne++){var ie=V[2*Ne+1];ie!==0&&(V[2*Ne]=de(H[ie]++,ie))}}function Ae(V){var Q;for(Q=0;Q<m;Q++)V.dyn_ltree[2*Q]=0;for(Q=0;Q<g;Q++)V.dyn_dtree[2*Q]=0;for(Q=0;Q<x;Q++)V.bl_tree[2*Q]=0;V.dyn_ltree[2*S]=1,V.opt_len=V.static_len=0,V.last_lit=V.matches=0}function ge(V){8<V.bi_valid?J(V,V.bi_buf):0<V.bi_valid&&(V.pending_buf[V.pending++]=V.bi_buf),V.bi_buf=0,V.bi_valid=0}function Me(V,Q,Ee,Ce){var Ne=2*Q,H=2*Ee;return V[Ne]<V[H]||V[Ne]===V[H]&&Ce[Q]<=Ce[Ee]}function je(V,Q,Ee){for(var Ce=V.heap[Ee],Ne=Ee<<1;Ne<=V.heap_len&&(Ne<V.heap_len&&Me(Q,V.heap[Ne+1],V.heap[Ne],V.depth)&&Ne++,!Me(Q,Ce,V.heap[Ne],V.depth));)V.heap[Ee]=V.heap[Ne],Ee=Ne,Ne<<=1;V.heap[Ee]=Ce}function ne(V,Q,Ee){var Ce,Ne,H,O,ie=0;if(V.last_lit!==0)for(;Ce=V.pending_buf[V.d_buf+2*ie]<<8|V.pending_buf[V.d_buf+2*ie+1],Ne=V.pending_buf[V.l_buf+ie],ie++,Ce===0?ae(V,Ne,Q):(ae(V,(H=D[Ne])+f+1,Q),(O=C[H])!==0&&te(V,Ne-=K[H],O),ae(V,H=G(--Ce),Ee),(O=R[H])!==0&&te(V,Ce-=re[H],O)),ie<V.last_lit;);ae(V,S,Q)}function Ke(V,Q){var Ee,Ce,Ne,H=Q.dyn_tree,O=Q.stat_desc.static_tree,ie=Q.stat_desc.has_stree,ye=Q.stat_desc.elems,_e=-1;for(V.heap_len=0,V.heap_max=y,Ee=0;Ee<ye;Ee++)H[2*Ee]!==0?(V.heap[++V.heap_len]=_e=Ee,V.depth[Ee]=0):H[2*Ee+1]=0;for(;V.heap_len<2;)H[2*(Ne=V.heap[++V.heap_len]=_e<2?++_e:0)]=1,V.depth[Ne]=0,V.opt_len--,ie&&(V.static_len-=O[2*Ne+1]);for(Q.max_code=_e,Ee=V.heap_len>>1;1<=Ee;Ee--)je(V,H,Ee);for(Ne=ye;Ee=V.heap[1],V.heap[1]=V.heap[V.heap_len--],je(V,H,1),Ce=V.heap[1],V.heap[--V.heap_max]=Ee,V.heap[--V.heap_max]=Ce,H[2*Ne]=H[2*Ee]+H[2*Ce],V.depth[Ne]=(V.depth[Ee]>=V.depth[Ce]?V.depth[Ee]:V.depth[Ce])+1,H[2*Ee+1]=H[2*Ce+1]=Ne,V.heap[1]=Ne++,je(V,H,1),2<=V.heap_len;);V.heap[--V.heap_max]=V.heap[1],(function(le,ke){var Oe,Ze,ht,We,he,rt,qe=ke.dyn_tree,Je=ke.max_code,ot=ke.stat_desc.static_tree,se=ke.stat_desc.has_stree,$e=ke.stat_desc.extra_bits,be=ke.stat_desc.extra_base,Fe=ke.stat_desc.max_length,De=0;for(We=0;We<=b;We++)le.bl_count[We]=0;for(qe[2*le.heap[le.heap_max]+1]=0,Oe=le.heap_max+1;Oe<y;Oe++)Fe<(We=qe[2*qe[2*(Ze=le.heap[Oe])+1]+1]+1)&&(We=Fe,De++),qe[2*Ze+1]=We,Je<Ze||(le.bl_count[We]++,he=0,be<=Ze&&(he=$e[Ze-be]),rt=qe[2*Ze],le.opt_len+=rt*(We+he),se&&(le.static_len+=rt*(ot[2*Ze+1]+he)));if(De!==0){do{for(We=Fe-1;le.bl_count[We]===0;)We--;le.bl_count[We]--,le.bl_count[We+1]+=2,le.bl_count[Fe]--,De-=2}while(0<De);for(We=Fe;We!==0;We--)for(Ze=le.bl_count[We];Ze!==0;)Je<(ht=le.heap[--Oe])||(qe[2*ht+1]!==We&&(le.opt_len+=(We-qe[2*ht+1])*qe[2*ht],qe[2*ht+1]=We),Ze--)}})(V,Q),fe(H,_e,V.bl_count)}function $(V,Q,Ee){var Ce,Ne,H=-1,O=Q[1],ie=0,ye=7,_e=4;for(O===0&&(ye=138,_e=3),Q[2*(Ee+1)+1]=65535,Ce=0;Ce<=Ee;Ce++)Ne=O,O=Q[2*(Ce+1)+1],++ie<ye&&Ne===O||(ie<_e?V.bl_tree[2*Ne]+=ie:Ne!==0?(Ne!==H&&V.bl_tree[2*Ne]++,V.bl_tree[2*A]++):ie<=10?V.bl_tree[2*E]++:V.bl_tree[2*k]++,H=Ne,_e=(ie=0)===O?(ye=138,3):Ne===O?(ye=6,3):(ye=7,4))}function z(V,Q,Ee){var Ce,Ne,H=-1,O=Q[1],ie=0,ye=7,_e=4;for(O===0&&(ye=138,_e=3),Ce=0;Ce<=Ee;Ce++)if(Ne=O,O=Q[2*(Ce+1)+1],!(++ie<ye&&Ne===O)){if(ie<_e)for(;ae(V,Ne,V.bl_tree),--ie!=0;);else Ne!==0?(Ne!==H&&(ae(V,Ne,V.bl_tree),ie--),ae(V,A,V.bl_tree),te(V,ie-3,2)):ie<=10?(ae(V,E,V.bl_tree),te(V,ie-3,3)):(ae(V,k,V.bl_tree),te(V,ie-11,7));H=Ne,_e=(ie=0)===O?(ye=138,3):Ne===O?(ye=6,3):(ye=7,4)}}c(re);var W=!1;function U(V,Q,Ee,Ce){te(V,(u<<1)+(Ce?1:0),3),(function(Ne,H,O,ie){ge(Ne),J(Ne,O),J(Ne,~O),a.arraySet(Ne.pending_buf,Ne.window,H,O,Ne.pending),Ne.pending+=O})(V,Q,Ee)}i._tr_init=function(V){W||((function(){var Q,Ee,Ce,Ne,H,O=new Array(b+1);for(Ne=Ce=0;Ne<d-1;Ne++)for(K[Ne]=Ce,Q=0;Q<1<<C[Ne];Q++)D[Ce++]=Ne;for(D[Ce-1]=Ne,Ne=H=0;Ne<16;Ne++)for(re[Ne]=H,Q=0;Q<1<<R[Ne];Q++)X[H++]=Ne;for(H>>=7;Ne<g;Ne++)for(re[Ne]=H<<7,Q=0;Q<1<<R[Ne]-7;Q++)X[256+H++]=Ne;for(Ee=0;Ee<=b;Ee++)O[Ee]=0;for(Q=0;Q<=143;)F[2*Q+1]=8,Q++,O[8]++;for(;Q<=255;)F[2*Q+1]=9,Q++,O[9]++;for(;Q<=279;)F[2*Q+1]=7,Q++,O[7]++;for(;Q<=287;)F[2*Q+1]=8,Q++,O[8]++;for(fe(F,m+1,O),Q=0;Q<g;Q++)L[2*Q+1]=5,L[2*Q]=de(Q,5);Y=new oe(F,C,f+1,m,b),q=new oe(L,R,0,g,b),Z=new oe(new Array(0),T,0,x,M)})(),W=!0),V.l_desc=new B(V.dyn_ltree,Y),V.d_desc=new B(V.dyn_dtree,q),V.bl_desc=new B(V.bl_tree,Z),V.bi_buf=0,V.bi_valid=0,Ae(V)},i._tr_stored_block=U,i._tr_flush_block=function(V,Q,Ee,Ce){var Ne,H,O=0;0<V.level?(V.strm.data_type===2&&(V.strm.data_type=(function(ie){var ye,_e=4093624447;for(ye=0;ye<=31;ye++,_e>>>=1)if(1&_e&&ie.dyn_ltree[2*ye]!==0)return o;if(ie.dyn_ltree[18]!==0||ie.dyn_ltree[20]!==0||ie.dyn_ltree[26]!==0)return l;for(ye=32;ye<f;ye++)if(ie.dyn_ltree[2*ye]!==0)return l;return o})(V)),Ke(V,V.l_desc),Ke(V,V.d_desc),O=(function(ie){var ye;for($(ie,ie.dyn_ltree,ie.l_desc.max_code),$(ie,ie.dyn_dtree,ie.d_desc.max_code),Ke(ie,ie.bl_desc),ye=x-1;3<=ye&&ie.bl_tree[2*P[ye]+1]===0;ye--);return ie.opt_len+=3*(ye+1)+5+5+4,ye})(V),Ne=V.opt_len+3+7>>>3,(H=V.static_len+3+7>>>3)<=Ne&&(Ne=H)):Ne=H=Ee+5,Ee+4<=Ne&&Q!==-1?U(V,Q,Ee,Ce):V.strategy===4||H===Ne?(te(V,2+(Ce?1:0),3),ne(V,F,L)):(te(V,4+(Ce?1:0),3),(function(ie,ye,_e,le){var ke;for(te(ie,ye-257,5),te(ie,_e-1,5),te(ie,le-4,4),ke=0;ke<le;ke++)te(ie,ie.bl_tree[2*P[ke]+1],3);z(ie,ie.dyn_ltree,ye-1),z(ie,ie.dyn_dtree,_e-1)})(V,V.l_desc.max_code+1,V.d_desc.max_code+1,O+1),ne(V,V.dyn_ltree,V.dyn_dtree)),Ae(V),Ce&&ge(V)},i._tr_tally=function(V,Q,Ee){return V.pending_buf[V.d_buf+2*V.last_lit]=Q>>>8&255,V.pending_buf[V.d_buf+2*V.last_lit+1]=255&Q,V.pending_buf[V.l_buf+V.last_lit]=255&Ee,V.last_lit++,Q===0?V.dyn_ltree[2*Ee]++:(V.matches++,Q--,V.dyn_ltree[2*(D[Ee]+f+1)]++,V.dyn_dtree[2*G(Q)]++),V.last_lit===V.lit_bufsize-1},i._tr_align=function(V){te(V,2,3),ae(V,S,F),(function(Q){Q.bi_valid===16?(J(Q,Q.bi_buf),Q.bi_buf=0,Q.bi_valid=0):8<=Q.bi_valid&&(Q.pending_buf[Q.pending++]=255&Q.bi_buf,Q.bi_buf>>=8,Q.bi_valid-=8)})(V)}},{"../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,g={},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(A){process.nextTick(function(){M(A)})}:(function(){if(o.postMessage&&!o.importScripts){var A=!0,E=o.onmessage;return o.onmessage=function(){A=!1},o.postMessage("","*"),o.onmessage=E,A}})()?(f="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",S,!1):o.attachEvent("onmessage",S),function(A){o.postMessage(f+A,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(A){M(A.data)},function(A){d.port2.postMessage(A)}):y&&"onreadystatechange"in y.createElement("script")?(u=y.documentElement,function(A){var E=y.createElement("script");E.onreadystatechange=function(){M(A),E.onreadystatechange=null,u.removeChild(E),E=null},u.appendChild(E)}):function(A){setTimeout(M,0,A)},b.setImmediate=function(A){typeof A!="function"&&(A=new Function(""+A));for(var E=new Array(arguments.length-1),k=0;k<E.length;k++)E[k]=arguments[k+1];var C={callback:A,args:E};return g[m]=C,c(m),m++},b.clearImmediate=v}function v(A){delete g[A]}function M(A){if(x)setTimeout(M,0,A);else{var E=g[A];if(E){x=!0;try{(function(k){var C=k.callback,R=k.args;switch(R.length){case 0:C();break;case 1:C(R[0]);break;case 2:C(R[0],R[1]);break;case 3:C(R[0],R[1],R[2]);break;default:C.apply(l,R)}})(E)}finally{v(A),x=!1}}}}function S(A){A.source===o&&typeof A.data=="string"&&A.data.indexOf(f)===0&&M(+A.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof Gv<"u"?Gv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(YC)),YC.exports}var COe=TOe();const kOe=Co(COe);function jOe(t){const e=new vi;if(!t)return e;const n=t.trim().split(/\s+/).map(parseFloat);return n.length>=12&&e.set(n[0],n[1],n[2],n[9],n[3],n[4],n[5],n[10],n[6],n[7],n[8],n[11],0,0,0,1),e}const hV=jOe;async function fV(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 POe(t){const e=await kOe.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(g){const x=g.startsWith("/")?g.slice(1):g,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 g=await c.async("string"),y=i.parseFromString(g,"application/xml").getElementsByTagName("object");for(let b=0;b<y.length;b++){const v=y[b],M=v.getAttribute("id");if(!M)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(M,Math.max(0,parseInt(E,10)-1))}const A=v.getElementsByTagName("part");for(let E=0;E<A.length;E++){const k=A[E],C=k.getAttribute("id");if(!C)continue;const R=Array.from(k.children).filter(T=>T.tagName==="metadata"&&T.getAttribute("key")==="extruder");if(R.length>0){const T=R[0].getAttribute("value");T&&l.set(`${M}:${C}`,Math.max(0,parseInt(T,10)-1))}}}}catch{}const u=Object.keys(e.files).find(g=>g==="3D/3dmodel.model"||g.endsWith("/3dmodel.model"));if(!u){const g=Object.keys(e.files).find(x=>x.endsWith(".model"));if(g){const x=await a(g);if(x){const y=await fV(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 g=0;g<f.length;g++){const x=f[g],y=x.getAttribute("id");if(!y)continue;let b=o.get(y)??-1;if(b<0){const A=x.getAttribute("p:extruder")||x.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";b=Math.max(0,parseInt(A,10)-1)}const v=[],M=x.getElementsByTagName("mesh");for(let A=0;A<M.length;A++){const E=M[A],k=[],C=[],R=E.getElementsByTagName("vertex");for(let P=0;P<R.length;P++){const F=R[P];k.push(parseFloat(F.getAttribute("x")||"0"),parseFloat(F.getAttribute("y")||"0"),parseFloat(F.getAttribute("z")||"0"))}const T=E.getElementsByTagName("triangle");for(let P=0;P<T.length;P++){const F=T[P];C.push(parseInt(F.getAttribute("v1")||"0"),parseInt(F.getAttribute("v2")||"0"),parseInt(F.getAttribute("v3")||"0"))}k.length>0&&C.length>0&&v.push({vertices:k,triangles:C,extruder:b})}const S=x.getElementsByTagName("component");for(let A=0;A<S.length;A++){const E=S[A],k=E.getAttribute("p:path")||E.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),C=E.getAttribute("objectid");if(k){const R=await a(k);if(R){const T=C?`${y}:${C}`:null,P=T?l.get(T)??b:b,F=await fV(R,P),L=E.getAttribute("transform"),X=hV(L);for(const D of F)if(L){const K=[];for(let Y=0;Y<D.vertices.length;Y+=3){const q=new at(D.vertices[Y],D.vertices[Y+1],D.vertices[Y+2]);q.applyMatrix4(X),K.push(q.x,q.y,q.z)}v.push({vertices:K,triangles:D.triangles,extruder:D.extruder})}else v.push(D)}}}v.length>0&&n.set(y,{id:y,meshes:v,defaultExtruder:b})}const m=d.getElementsByTagName("build");if(m.length>0){const g=m[0].getElementsByTagName("item");for(let x=0;x<g.length;x++){const y=g[x],b=y.getAttribute("objectid");if(!b)continue;const v=hV(y.getAttribute("transform"));r.push({objectId:b,transform:v})}}return{objects:n,buildItems:r}}function mV(t){const e=new Xl,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 wo(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function ROe({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,M=new u3e;M.background=new Tn(1710618),o.current=M;const S=new po(45,b/v,.1,1e4);S.position.set(150,150,150),l.current=S;const A=new hOe({antialias:!0});A.setSize(b,v),A.setPixelRatio(window.devicePixelRatio),y.appendChild(A.domElement),a.current=A;const E=new mOe(S,A.domElement);E.enableDamping=!0,E.dampingFactor=.05,c.current=E;const k=new w3e(16777215,.6);M.add(k);const C=new LH(16777215,.8);C.position.set(100,100,100),M.add(C);const R=new LH(16777215,.4);R.position.set(-100,50,-100),M.add(R);const T=Math.max(e.x,e.y),P=Math.ceil(T/16),F=new M3e(T,P,4473924,3355443);M.add(F);const L=new NO(e.x,e.y),X=new wO({color:44610,transparent:!0,opacity:.15,side:Ml}),D=new Bl(L,X);D.rotation.x=-Math.PI/2,D.position.y=-.5,M.add(D);let K;const Y=()=>{K=requestAnimationFrame(Y),E.update(),A.render(M,S)};Y(),fetch(t).then(Z=>{if(!Z.ok)throw new Error("Failed to load file");return Z.arrayBuffer()}).then(POe).then(({objects:Z,buildItems:re})=>{if(Z.size===0)throw new Error("No meshes found in 3MF file");const oe=Me=>{const ne=n?.[Me]||"#00ae42",Ke=new Tn(ne);return new x3e({color:Ke,shininess:30,flatShading:!1})},B=new vb,G=new Map;if(re.length>0)for(const Me of re){const je=Z.get(Me.objectId);if(je)for(const ne of je.meshes){const Ke=Me.extruder??ne.extruder,$=[];for(let W=0;W<ne.vertices.length;W+=3){const U=new at(ne.vertices[W],ne.vertices[W+1],ne.vertices[W+2]);U.applyMatrix4(Me.transform),$.push(U.x,U.y,U.z)}const z=mV({vertices:$,triangles:ne.triangles});G.has(Ke)||G.set(Ke,[]),G.get(Ke).push(z)}}else for(const Me of Z.values())for(const je of Me.meshes){const ne=je.extruder,Ke=mV(je);G.has(ne)||G.set(ne,[]),G.get(ne).push(Ke)}for(const[Me,je]of G){if(je.length===0)continue;const ne=je.length===1?je[0]:AOe(je,!1);if(ne){const Ke=oe(Me),$=new Bl(ne,Ke);B.add($)}if(je.length>1)for(const Ke of je)Ke.dispose()}const J=new Of().setFromObject(B),te=J.getCenter(new at);B.position.y=-J.min.y,re.length===0&&(B.position.x=-te.x,B.position.z=-te.z),M.add(B);const ae=new Of().setFromObject(B),de=ae.getCenter(new at),fe=ae.getSize(new at),ge=Math.max(fe.x,fe.y,fe.z)*1.8;S.position.set(de.x+ge*.7,de.y+ge*.5,de.z+ge*.7),E.target.copy(de),E.update(),d(!1)}).catch(Z=>{m(Z.message),d(!1)});const q=()=>{if(!y)return;const Z=y.clientWidth,re=y.clientHeight;S.aspect=Z/re,S.updateProjectionMatrix(),A.setSize(Z,re)};return window.addEventListener("resize",q),()=>{window.removeEventListener("resize",q),cancelAnimationFrame(K),E.dispose(),A.dispose(),y.removeChild(A.domElement)}},[t,e,n]);const g=()=>{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(mt,{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(Se,{variant:"secondary",size:"sm",onClick:()=>x(.8),children:s.jsx(oD,{className:"w-4 h-4"})}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:()=>x(1.25),children:s.jsx(lD,{className:"w-4 h-4"})}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:g,children:s.jsx(Vf,{className:"w-4 h-4"})})]})]})}const FM="159",Km={ROTATE:0,DOLLY:1,PAN:2},Xm={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},DOe=0,pV=1,OOe=2,dJ=1,LOe=2,Cc=3,Hd=0,ms=1,Lc=2,Ad=0,$p=1,gV=2,xV=3,bV=4,IOe=5,Uh=100,FOe=101,UOe=102,yV=103,vV=104,zOe=200,BOe=201,$Oe=202,HOe=203,UP=204,zP=205,VOe=206,GOe=207,WOe=208,qOe=209,KOe=210,XOe=211,YOe=212,QOe=213,ZOe=214,JOe=0,eLe=1,tLe=2,yS=3,nLe=4,rLe=5,iLe=6,aLe=7,AO=0,sLe=1,oLe=2,Td=0,lLe=1,cLe=2,uLe=3,dLe=4,hLe=5,hJ=300,mg=301,pg=302,BP=303,$P=304,UM=306,HP=1e3,Wo=1001,VP=1002,ha=1003,_V=1004,QC=1005,go=1006,fLe=1007,T0=1008,Cd=1009,mLe=1010,pLe=1011,TO=1012,fJ=1013,gd=1014,$c=1015,C0=1016,mJ=1017,pJ=1018,cf=1020,gLe=1021,xo=1023,xLe=1024,bLe=1025,uf=1026,gg=1027,yLe=1028,gJ=1029,vLe=1030,xJ=1031,bJ=1033,ZC=33776,JC=33777,ek=33778,tk=33779,wV=35840,SV=35841,MV=35842,NV=35843,yJ=36196,EV=37492,AV=37496,TV=37808,CV=37809,kV=37810,jV=37811,PV=37812,RV=37813,DV=37814,OV=37815,LV=37816,IV=37817,FV=37818,UV=37819,zV=37820,BV=37821,nk=36492,$V=36494,HV=36495,_Le=36283,VV=36284,GV=36285,WV=36286,vJ=3e3,df=3001,wLe=3200,SLe=3201,_J=0,MLe=1,bo="",fa="srgb",cu="srgb-linear",CO="display-p3",zM="display-p3-linear",vS="linear",Mr="srgb",_S="rec709",wS="p3",Ym=7680,qV=519,NLe=512,ELe=513,ALe=514,wJ=515,TLe=516,CLe=517,kLe=518,jLe=519,GP=35044,KV="300 es",WP=1035,Cl=2e3,k0=2001;class Xf{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 Sa=["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 XV=1234567;const Db=Math.PI/180,j0=180/Math.PI;function Xc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Sa[t&255]+Sa[t>>8&255]+Sa[t>>16&255]+Sa[t>>24&255]+"-"+Sa[e&255]+Sa[e>>8&255]+"-"+Sa[e>>16&15|64]+Sa[e>>24&255]+"-"+Sa[n&63|128]+Sa[n>>8&255]+"-"+Sa[n>>16&255]+Sa[n>>24&255]+Sa[r&255]+Sa[r>>8&255]+Sa[r>>16&255]+Sa[r>>24&255]).toLowerCase()}function ma(t,e,n){return Math.max(e,Math.min(n,t))}function kO(t,e){return(t%e+e)%e}function PLe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function RLe(t,e,n){return t!==e?(n-t)/(e-t):0}function Ob(t,e,n){return(1-n)*t+n*e}function DLe(t,e,n,r){return Ob(t,e,1-Math.exp(-n*r))}function OLe(t,e=1){return e-Math.abs(kO(t,e*2)-e)}function LLe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function ILe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function FLe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function ULe(t,e){return t+Math.random()*(e-t)}function zLe(t){return t*(.5-Math.random())}function BLe(t){t!==void 0&&(XV=t);let e=XV+=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 $Le(t){return t*Db}function HLe(t){return t*j0}function qP(t){return(t&t-1)===0&&t!==0}function VLe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function SS(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function GLe(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),g=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*g,l*u);break;case"YXY":t.set(c*g,l*d,c*x,l*u);break;case"ZYZ":t.set(c*x,c*g,l*d,l*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Nl(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 or(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 SJ={DEG2RAD:Db,RAD2DEG:j0,generateUUID:Xc,clamp:ma,euclideanModulo:kO,mapLinear:PLe,inverseLerp:RLe,lerp:Ob,damp:DLe,pingpong:OLe,smoothstep:LLe,smootherstep:ILe,randInt:FLe,randFloat:ULe,randFloatSpread:zLe,seededRandom:BLe,degToRad:$Le,radToDeg:HLe,isPowerOfTwo:qP,ceilPowerOfTwo:VLe,floorPowerOfTwo:SS,setQuaternionFromProperEuler:GLe,normalize:or,denormalize:Nl};class cn{constructor(e=0,n=0){cn.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(ma(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 Mn{constructor(e,n,r,i,a,o,l,c,u){Mn.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],g=r[5],x=r[8],y=i[0],b=i[3],v=i[6],M=i[1],S=i[4],A=i[7],E=i[2],k=i[5],C=i[8];return a[0]=o*y+l*M+c*E,a[3]=o*b+l*S+c*k,a[6]=o*v+l*A+c*C,a[1]=u*y+d*M+f*E,a[4]=u*b+d*S+f*k,a[7]=u*v+d*A+f*C,a[2]=m*y+g*M+x*E,a[5]=m*b+g*S+x*k,a[8]=m*v+g*A+x*C,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],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,g=u*a-o*c,x=n*f+r*m+i*g;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]=g*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(rk.makeScale(e,n)),this}rotate(e){return this.premultiply(rk.makeRotation(-e)),this}translate(e,n){return this.premultiply(rk.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 rk=new Mn;function MJ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function MS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function WLe(){const t=MS("canvas");return t.style.display="block",t}const YV={};function Lb(t){t in YV||(YV[t]=!0,console.warn(t))}const QV=new Mn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),ZV=new Mn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),F_={[cu]:{transfer:vS,primaries:_S,toReference:t=>t,fromReference:t=>t},[fa]:{transfer:Mr,primaries:_S,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[zM]:{transfer:vS,primaries:wS,toReference:t=>t.applyMatrix3(ZV),fromReference:t=>t.applyMatrix3(QV)},[CO]:{transfer:Mr,primaries:wS,toReference:t=>t.convertSRGBToLinear().applyMatrix3(ZV),fromReference:t=>t.applyMatrix3(QV).convertLinearToSRGB()}},qLe=new Set([cu,zM]),lr={enabled:!0,_workingColorSpace:cu,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(!qLe.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=F_[e].toReference,i=F_[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 F_[t].primaries},getTransfer:function(t){return t===bo?vS:F_[t].transfer}};function Hp(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function ik(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Qm;class NJ{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Qm===void 0&&(Qm=MS("canvas")),Qm.width=e.width,Qm.height=e.height;const r=Qm.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Qm}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=MS("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]=Hp(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(Hp(n[r]/255)*255):n[r]=Hp(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 KLe=0;class EJ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:KLe++}),this.uuid=Xc(),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(ak(i[o].image)):a.push(ak(i[o]))}else a=ak(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function ak(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?NJ.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 XLe=0;class ps extends Xf{constructor(e=ps.DEFAULT_IMAGE,n=ps.DEFAULT_MAPPING,r=Wo,i=Wo,a=go,o=T0,l=xo,c=Cd,u=ps.DEFAULT_ANISOTROPY,d=bo){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:XLe++}),this.uuid=Xc(),this.name="",this.source=new EJ(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 cn(0,0),this.repeat=new cn(1,1),this.center=new cn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Mn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(Lb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===df?fa:bo),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!==hJ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case HP:e.x=e.x-Math.floor(e.x);break;case Wo:e.x=e.x<0?0:1;break;case VP: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 HP:e.y=e.y-Math.floor(e.y);break;case Wo:e.y=e.y<0?0:1;break;case VP: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 Lb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===fa?df:vJ}set encoding(e){Lb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===df?fa:bo}}ps.DEFAULT_IMAGE=null;ps.DEFAULT_MAPPING=hJ;ps.DEFAULT_ANISOTROPY=1;class ur{constructor(e=0,n=0,r=0,i=1){ur.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],g=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+g+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const S=(u+1)/2,A=(g+1)/2,E=(v+1)/2,k=(d+m)/4,C=(f+y)/4,R=(x+b)/4;return S>A&&S>E?S<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(S),i=k/r,a=C/r):A>E?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=k/i,a=R/i):E<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(E),r=C/a,i=R/a),this.set(r,i,a,n),this}let M=Math.sqrt((b-x)*(b-x)+(f-y)*(f-y)+(m-d)*(m-d));return Math.abs(M)<.001&&(M=1),this.x=(b-x)/M,this.y=(f-y)/M,this.z=(m-d)/M,this.w=Math.acos((u+g+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 YLe extends Xf{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new ur(0,0,e,n),this.scissorTest=!1,this.viewport=new ur(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(Lb("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===df?fa:bo),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:go,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new ps(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 EJ(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 Lf extends YLe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class AJ extends ps{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=ha,this.minFilter=ha,this.wrapR=Wo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class QLe extends ps{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=ha,this.minFilter=ha,this.wrapR=Wo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class If{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,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],g=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]=g,e[n+2]=x,e[n+3]=y;return}if(f!==y||c!==m||u!==g||d!==x){let b=1-l;const v=c*m+u*g+d*x+f*y,M=v>=0?1:-1,S=1-v*v;if(S>Number.EPSILON){const E=Math.sqrt(S),k=Math.atan2(E,v*M);b=Math.sin(b*k)/E,l=Math.sin(l*k)/E}const A=l*M;if(c=c*b+m*A,u=u*b+g*A,d=d*b+x*A,f=f*b+y*A,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],g=a[o+2],x=a[o+3];return e[n]=l*x+d*f+c*g-u*m,e[n+1]=c*x+d*m+u*f-l*g,e[n+2]=u*x+d*g+l*m-c*f,e[n+3]=d*x-l*f-c*m-u*g,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),g=c(i/2),x=c(a/2);switch(o){case"XYZ":this._x=m*d*f+u*g*x,this._y=u*g*f-m*d*x,this._z=u*d*x+m*g*f,this._w=u*d*f-m*g*x;break;case"YXZ":this._x=m*d*f+u*g*x,this._y=u*g*f-m*d*x,this._z=u*d*x-m*g*f,this._w=u*d*f+m*g*x;break;case"ZXY":this._x=m*d*f-u*g*x,this._y=u*g*f+m*d*x,this._z=u*d*x+m*g*f,this._w=u*d*f-m*g*x;break;case"ZYX":this._x=m*d*f-u*g*x,this._y=u*g*f+m*d*x,this._z=u*d*x-m*g*f,this._w=u*d*f+m*g*x;break;case"YZX":this._x=m*d*f+u*g*x,this._y=u*g*f+m*d*x,this._z=u*d*x-m*g*f,this._w=u*d*f-m*g*x;break;case"XZY":this._x=m*d*f-u*g*x,this._y=u*g*f-m*d*x,this._z=u*d*x+m*g*f,this._w=u*d*f+m*g*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 g=.5/Math.sqrt(m+1);this._w=.25/g,this._x=(d-c)*g,this._y=(a-u)*g,this._z=(o-i)*g}else if(r>l&&r>f){const g=2*Math.sqrt(1+r-l-f);this._w=(d-c)/g,this._x=.25*g,this._y=(i+o)/g,this._z=(a+u)/g}else if(l>f){const g=2*Math.sqrt(1+l-r-f);this._w=(a-u)/g,this._x=(i+o)/g,this._y=.25*g,this._z=(c+d)/g}else{const g=2*Math.sqrt(1+f-r-l);this._w=(o-i)/g,this._x=(a+u)/g,this._y=(c+d)/g,this._z=.25*g}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(ma(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 g=1-n;return this._w=g*o+n*this._w,this._x=g*r+n*this._x,this._y=g*i+n*this._y,this._z=g*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 ze{constructor(e=0,n=0,r=0){ze.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(JV.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(JV.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 sk.copy(this).projectOnVector(e),this.sub(sk)}reflect(e){return this.sub(sk.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(ma(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 sk=new ze,JV=new If;class So{constructor(e=new ze(1/0,1/0,1/0),n=new ze(-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(Uo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Uo.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=Uo.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,Uo):Uo.fromBufferAttribute(a,o),Uo.applyMatrix4(e.matrixWorld),this.expandByPoint(Uo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),U_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),U_.copy(r.boundingBox)),U_.applyMatrix4(e.matrixWorld),this.union(U_)}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,Uo),Uo.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(sb),z_.subVectors(this.max,sb),Zm.subVectors(e.a,sb),Jm.subVectors(e.b,sb),ep.subVectors(e.c,sb),Wu.subVectors(Jm,Zm),qu.subVectors(ep,Jm),Eh.subVectors(Zm,ep);let n=[0,-Wu.z,Wu.y,0,-qu.z,qu.y,0,-Eh.z,Eh.y,Wu.z,0,-Wu.x,qu.z,0,-qu.x,Eh.z,0,-Eh.x,-Wu.y,Wu.x,0,-qu.y,qu.x,0,-Eh.y,Eh.x,0];return!ok(n,Zm,Jm,ep,z_)||(n=[1,0,0,0,1,0,0,0,1],!ok(n,Zm,Jm,ep,z_))?!1:(B_.crossVectors(Wu,qu),n=[B_.x,B_.y,B_.z],ok(n,Zm,Jm,ep,z_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Uo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Uo).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:(vc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),vc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),vc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),vc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),vc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),vc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),vc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),vc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(vc),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 vc=[new ze,new ze,new ze,new ze,new ze,new ze,new ze,new ze],Uo=new ze,U_=new So,Zm=new ze,Jm=new ze,ep=new ze,Wu=new ze,qu=new ze,Eh=new ze,sb=new ze,z_=new ze,B_=new ze,Ah=new ze;function ok(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){Ah.fromArray(t,a);const l=i.x*Math.abs(Ah.x)+i.y*Math.abs(Ah.y)+i.z*Math.abs(Ah.z),c=e.dot(Ah),u=n.dot(Ah),d=r.dot(Ah);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const ZLe=new So,ob=new ze,lk=new ze;class Pl{constructor(e=new ze,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):ZLe.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;ob.subVectors(e,this.center);const n=ob.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(ob,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):(lk.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ob.copy(e.center).add(lk)),this.expandByPoint(ob.copy(e.center).sub(lk))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const _c=new ze,ck=new ze,$_=new ze,Ku=new ze,uk=new ze,H_=new ze,dk=new ze;class jO{constructor(e=new ze,n=new ze(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,_c)),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=_c.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(_c.copy(this.origin).addScaledVector(this.direction,n),_c.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){ck.copy(e).add(n).multiplyScalar(.5),$_.copy(n).sub(e).normalize(),Ku.copy(this.origin).sub(ck);const a=e.distanceTo(n)*.5,o=-this.direction.dot($_),l=Ku.dot(this.direction),c=-Ku.dot($_),u=Ku.lengthSq(),d=Math.abs(1-o*o);let f,m,g,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,g=f*(f+o*m+2*l)+m*(o*f+m+2*c)+u}else m=a,f=Math.max(0,-(o*m+l)),g=-f*f+m*(m+2*c)+u;else m=-a,f=Math.max(0,-(o*m+l)),g=-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),g=-f*f+m*(m+2*c)+u):m<=x?(f=0,m=Math.min(Math.max(-a,-c),a),g=m*(m+2*c)+u):(f=Math.max(0,-(o*a+l)),m=f>0?a:Math.min(Math.max(-a,-c),a),g=-f*f+m*(m+2*c)+u);else m=o>0?-a:a,f=Math.max(0,-(o*m+l)),g=-f*f+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(ck).addScaledVector($_,m),g}intersectSphere(e,n){_c.subVectors(e.center,this.origin);const r=_c.dot(this.direction),i=_c.dot(_c)-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,_c)!==null}intersectTriangle(e,n,r,i,a){uk.subVectors(n,e),H_.subVectors(r,e),dk.crossVectors(uk,H_);let o=this.direction.dot(dk),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(H_.crossVectors(Ku,H_));if(c<0)return null;const u=l*this.direction.dot(uk.cross(Ku));if(u<0||c+u>o)return null;const d=-l*Ku.dot(dk);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 vr{constructor(e,n,r,i,a,o,l,c,u,d,f,m,g,x,y,b){vr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u,d,f,m,g,x,y,b)}set(e,n,r,i,a,o,l,c,u,d,f,m,g,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]=g,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 vr().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,r){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){const n=this.elements,r=e.elements,i=1/tp.setFromMatrixColumn(e,0).length(),a=1/tp.setFromMatrixColumn(e,1).length(),o=1/tp.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,g=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=g+x*u,n[5]=m-y*u,n[9]=-l*c,n[2]=y-m*u,n[6]=x+g*u,n[10]=o*c}else if(e.order==="YXZ"){const m=c*d,g=c*f,x=u*d,y=u*f;n[0]=m+y*l,n[4]=x*l-g,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=g*l-x,n[6]=y+m*l,n[10]=o*c}else if(e.order==="ZXY"){const m=c*d,g=c*f,x=u*d,y=u*f;n[0]=m-y*l,n[4]=-o*f,n[8]=x+g*l,n[1]=g+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,g=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=x*u-g,n[8]=m*u+y,n[1]=c*f,n[5]=y*u+m,n[9]=g*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const m=o*c,g=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=y-m*f,n[8]=x*f+g,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=g*f+x,n[10]=m-y*f}else if(e.order==="XZY"){const m=o*c,g=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]=g*f-x,n[2]=x*f-g,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(JLe,e,eIe)}lookAt(e,n,r){const i=this.elements;return js.subVectors(e,n),js.lengthSq()===0&&(js.z=1),js.normalize(),Xu.crossVectors(r,js),Xu.lengthSq()===0&&(Math.abs(r.z)===1?js.x+=1e-4:js.z+=1e-4,js.normalize(),Xu.crossVectors(r,js)),Xu.normalize(),V_.crossVectors(js,Xu),i[0]=Xu.x,i[4]=V_.x,i[8]=js.x,i[1]=Xu.y,i[5]=V_.y,i[9]=js.y,i[2]=Xu.z,i[6]=V_.z,i[10]=js.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],g=r[13],x=r[2],y=r[6],b=r[10],v=r[14],M=r[3],S=r[7],A=r[11],E=r[15],k=i[0],C=i[4],R=i[8],T=i[12],P=i[1],F=i[5],L=i[9],X=i[13],D=i[2],K=i[6],Y=i[10],q=i[14],Z=i[3],re=i[7],oe=i[11],B=i[15];return a[0]=o*k+l*P+c*D+u*Z,a[4]=o*C+l*F+c*K+u*re,a[8]=o*R+l*L+c*Y+u*oe,a[12]=o*T+l*X+c*q+u*B,a[1]=d*k+f*P+m*D+g*Z,a[5]=d*C+f*F+m*K+g*re,a[9]=d*R+f*L+m*Y+g*oe,a[13]=d*T+f*X+m*q+g*B,a[2]=x*k+y*P+b*D+v*Z,a[6]=x*C+y*F+b*K+v*re,a[10]=x*R+y*L+b*Y+v*oe,a[14]=x*T+y*X+b*q+v*B,a[3]=M*k+S*P+A*D+E*Z,a[7]=M*C+S*F+A*K+E*re,a[11]=M*R+S*L+A*Y+E*oe,a[15]=M*T+S*X+A*q+E*B,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],m=e[10],g=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*g-r*c*g)+y*(+n*c*g-n*u*m+a*o*m-i*o*g+i*u*d-a*c*d)+b*(+n*u*f-n*l*g-a*o*f+r*o*g+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],g=e[11],x=e[12],y=e[13],b=e[14],v=e[15],M=f*b*u-y*m*u+y*c*g-l*b*g-f*c*v+l*m*v,S=x*m*u-d*b*u-x*c*g+o*b*g+d*c*v-o*m*v,A=d*y*u-x*f*u+x*l*g-o*y*g-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,k=n*M+r*S+i*A+a*E;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/k;return e[0]=M*C,e[1]=(y*m*a-f*b*a-y*i*g+r*b*g+f*i*v-r*m*v)*C,e[2]=(l*b*a-y*c*a+y*i*u-r*b*u-l*i*v+r*c*v)*C,e[3]=(f*c*a-l*m*a-f*i*u+r*m*u+l*i*g-r*c*g)*C,e[4]=S*C,e[5]=(d*b*a-x*m*a+x*i*g-n*b*g-d*i*v+n*m*v)*C,e[6]=(x*c*a-o*b*a-x*i*u+n*b*u+o*i*v-n*c*v)*C,e[7]=(o*m*a-d*c*a+d*i*u-n*m*u-o*i*g+n*c*g)*C,e[8]=A*C,e[9]=(x*f*a-d*y*a-x*r*g+n*y*g+d*r*v-n*f*v)*C,e[10]=(o*y*a-x*l*a+x*r*u-n*y*u-o*r*v+n*l*v)*C,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*g-n*l*g)*C,e[12]=E*C,e[13]=(d*y*i-x*f*i+x*r*m-n*y*m-d*r*b+n*f*b)*C,e[14]=(x*l*i-o*y*i-x*r*c+n*y*c+o*r*b-n*l*b)*C,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*C,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,g=a*d,x=a*f,y=o*d,b=o*f,v=l*f,M=c*u,S=c*d,A=c*f,E=r.x,k=r.y,C=r.z;return i[0]=(1-(y+v))*E,i[1]=(g+A)*E,i[2]=(x-S)*E,i[3]=0,i[4]=(g-A)*k,i[5]=(1-(m+v))*k,i[6]=(b+M)*k,i[7]=0,i[8]=(x+S)*C,i[9]=(b-M)*C,i[10]=(1-(m+y))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let a=tp.set(i[0],i[1],i[2]).length();const o=tp.set(i[4],i[5],i[6]).length(),l=tp.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],zo.copy(this);const u=1/a,d=1/o,f=1/l;return zo.elements[0]*=u,zo.elements[1]*=u,zo.elements[2]*=u,zo.elements[4]*=d,zo.elements[5]*=d,zo.elements[6]*=d,zo.elements[8]*=f,zo.elements[9]*=f,zo.elements[10]*=f,n.setFromRotationMatrix(zo),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=Cl){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 g,x;if(l===Cl)g=-(o+a)/(o-a),x=-2*o*a/(o-a);else if(l===k0)g=-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]=g,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=Cl){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(o-a),m=(n+e)*u,g=(r+i)*d;let x,y;if(l===Cl)x=(o+a)*f,y=-2*f;else if(l===k0)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]=-g,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 tp=new ze,zo=new vr,JLe=new ze(0,0,0),eIe=new ze(1,1,1),Xu=new ze,V_=new ze,js=new ze,e7=new vr,t7=new If;class Ey{constructor(e=0,n=0,r=0,i=Ey.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],g=i[10];switch(n){case"XYZ":this._y=Math.asin(ma(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,g),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-ma(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,g),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(ma(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-f,g),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-ma(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(m,g),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(ma(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,g));break;case"XZY":this._z=Math.asin(-ma(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,g),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 e7.makeRotationFromQuaternion(e),this.setFromRotationMatrix(e7,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return t7.setFromEuler(this),this.setFromQuaternion(t7,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}}Ey.DEFAULT_ORDER="XYZ";class TJ{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 tIe=0;const n7=new ze,np=new If,wc=new vr,G_=new ze,lb=new ze,nIe=new ze,rIe=new If,r7=new ze(1,0,0),i7=new ze(0,1,0),a7=new ze(0,0,1),iIe={type:"added"},aIe={type:"removed"};class Va extends Xf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:tIe++}),this.uuid=Xc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Va.DEFAULT_UP.clone();const e=new ze,n=new Ey,r=new If,i=new ze(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 vr},normalMatrix:{value:new Mn}}),this.matrix=new vr,this.matrixWorld=new vr,this.matrixAutoUpdate=Va.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Va.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new TJ,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 np.setFromAxisAngle(e,n),this.quaternion.multiply(np),this}rotateOnWorldAxis(e,n){return np.setFromAxisAngle(e,n),this.quaternion.premultiply(np),this}rotateX(e){return this.rotateOnAxis(r7,e)}rotateY(e){return this.rotateOnAxis(i7,e)}rotateZ(e){return this.rotateOnAxis(a7,e)}translateOnAxis(e,n){return n7.copy(e).applyQuaternion(this.quaternion),this.position.add(n7.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(r7,e)}translateY(e){return this.translateOnAxis(i7,e)}translateZ(e){return this.translateOnAxis(a7,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(wc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?G_.copy(e):G_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),lb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?wc.lookAt(lb,G_,this.up):wc.lookAt(G_,lb,this.up),this.quaternion.setFromRotationMatrix(wc),i&&(wc.extractRotation(i.matrixWorld),np.setFromRotationMatrix(wc),this.quaternion.premultiply(np.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(iIe)):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(aIe)),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),wc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),wc.multiply(e.parent.matrixWorld)),e.applyMatrix4(wc),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(lb,e,nIe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(lb,rIe,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),g=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),g.length>0&&(r.animations=g),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}}Va.DEFAULT_UP=new ze(0,1,0);Va.DEFAULT_MATRIX_AUTO_UPDATE=!0;Va.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Bo=new ze,Sc=new ze,hk=new ze,Mc=new ze,rp=new ze,ip=new ze,s7=new ze,fk=new ze,mk=new ze,pk=new ze;let W_=!1;class $o{constructor(e=new ze,n=new ze,r=new ze){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Bo.subVectors(e,n),i.cross(Bo);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){Bo.subVectors(i,n),Sc.subVectors(r,n),hk.subVectors(e,n);const o=Bo.dot(Bo),l=Bo.dot(Sc),c=Bo.dot(hk),u=Sc.dot(Sc),d=Sc.dot(hk),f=o*u-l*l;if(f===0)return a.set(-2,-1,-1);const m=1/f,g=(u*c-l*d)*m,x=(o*d-l*c)*m;return a.set(1-g-x,x,g)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Mc),Mc.x>=0&&Mc.y>=0&&Mc.x+Mc.y<=1}static getUV(e,n,r,i,a,o,l,c){return W_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),W_=!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,Mc),c.setScalar(0),c.addScaledVector(a,Mc.x),c.addScaledVector(o,Mc.y),c.addScaledVector(l,Mc.z),c}static isFrontFacing(e,n,r,i){return Bo.subVectors(r,n),Sc.subVectors(e,n),Bo.cross(Sc).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 Bo.subVectors(this.c,this.b),Sc.subVectors(this.a,this.b),Bo.cross(Sc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return $o.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return $o.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return W_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),W_=!0),$o.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return $o.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return $o.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return $o.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;rp.subVectors(i,r),ip.subVectors(a,r),fk.subVectors(e,r);const c=rp.dot(fk),u=ip.dot(fk);if(c<=0&&u<=0)return n.copy(r);mk.subVectors(e,i);const d=rp.dot(mk),f=ip.dot(mk);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(rp,o);pk.subVectors(e,a);const g=rp.dot(pk),x=ip.dot(pk);if(x>=0&&g<=x)return n.copy(a);const y=g*u-c*x;if(y<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(ip,l);const b=d*x-g*f;if(b<=0&&f-d>=0&&g-x>=0)return s7.subVectors(a,i),l=(f-d)/(f-d+(g-x)),n.copy(i).addScaledVector(s7,l);const v=1/(b+y+m);return o=y*v,l=m*v,n.copy(r).addScaledVector(rp,o).addScaledVector(ip,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const CJ={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},q_={h:0,s:0,l:0};function gk(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 Qt=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=fa){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,lr.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=lr.workingColorSpace){return this.r=e,this.g=n,this.b=r,lr.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=lr.workingColorSpace){if(e=kO(e,1),n=ma(n,0,1),r=ma(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=gk(o,a,e+1/3),this.g=gk(o,a,e),this.b=gk(o,a,e-1/3)}return lr.toWorkingColorSpace(this,i),this}setStyle(e,n=fa){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=fa){const r=CJ[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=Hp(e.r),this.g=Hp(e.g),this.b=Hp(e.b),this}copyLinearToSRGB(e){return this.r=ik(e.r),this.g=ik(e.g),this.b=ik(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=fa){return lr.fromWorkingColorSpace(Ma.copy(this),e),Math.round(ma(Ma.r*255,0,255))*65536+Math.round(ma(Ma.g*255,0,255))*256+Math.round(ma(Ma.b*255,0,255))}getHexString(e=fa){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=lr.workingColorSpace){lr.fromWorkingColorSpace(Ma.copy(this),n);const r=Ma.r,i=Ma.g,a=Ma.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=lr.workingColorSpace){return lr.fromWorkingColorSpace(Ma.copy(this),n),e.r=Ma.r,e.g=Ma.g,e.b=Ma.b,e}getStyle(e=fa){lr.fromWorkingColorSpace(Ma.copy(this),e);const n=Ma.r,r=Ma.g,i=Ma.b;return e!==fa?`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(q_);const r=Ob(Yu.h,q_.h,n),i=Ob(Yu.s,q_.s,n),a=Ob(Yu.l,q_.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 Ma=new Qt;Qt.NAMES=CJ;let sIe=0;class qg extends Xf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:sIe++}),this.uuid=Xc(),this.name="",this.type="Material",this.blending=$p,this.side=Hd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=UP,this.blendDst=zP,this.blendEquation=Uh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Qt(0,0,0),this.blendAlpha=0,this.depthFunc=yS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=qV,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ym,this.stencilZFail=Ym,this.stencilZPass=Ym,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!==$p&&(r.blending=this.blending),this.side!==Hd&&(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!==UP&&(r.blendSrc=this.blendSrc),this.blendDst!==zP&&(r.blendDst=this.blendDst),this.blendEquation!==Uh&&(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!==yS&&(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!==qV&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ym&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Ym&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Ym&&(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 kJ extends qg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Qt(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=AO,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 hi=new ze,K_=new cn;class $s{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=GP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=$c,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++)K_.fromBufferAttribute(this,n),K_.applyMatrix3(e),this.setXY(n,K_.x,K_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)hi.fromBufferAttribute(this,n),hi.applyMatrix3(e),this.setXYZ(n,hi.x,hi.y,hi.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)hi.fromBufferAttribute(this,n),hi.applyMatrix4(e),this.setXYZ(n,hi.x,hi.y,hi.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)hi.fromBufferAttribute(this,n),hi.applyNormalMatrix(e),this.setXYZ(n,hi.x,hi.y,hi.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)hi.fromBufferAttribute(this,n),hi.transformDirection(e),this.setXYZ(n,hi.x,hi.y,hi.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=Nl(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=or(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Nl(n,this.array)),n}setX(e,n){return this.normalized&&(n=or(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Nl(n,this.array)),n}setY(e,n){return this.normalized&&(n=or(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=Nl(n,this.array)),n}setZ(e,n){return this.normalized&&(n=or(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=Nl(n,this.array)),n}setW(e,n){return this.normalized&&(n=or(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=or(n,this.array),r=or(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=or(n,this.array),r=or(r,this.array),i=or(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=or(n,this.array),r=or(r,this.array),i=or(i,this.array),a=or(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!==GP&&(e.usage=this.usage),e}}class jJ extends $s{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class PJ extends $s{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class si extends $s{constructor(e,n,r){super(new Float32Array(e),n,r)}}let oIe=0;const ao=new vr,xk=new Va,ap=new ze,Ps=new So,cb=new So,Bi=new ze;class Ra extends Xf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:oIe++}),this.uuid=Xc(),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(MJ(e)?PJ:jJ)(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 Mn().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 ao.makeRotationFromQuaternion(e),this.applyMatrix4(ao),this}rotateX(e){return ao.makeRotationX(e),this.applyMatrix4(ao),this}rotateY(e){return ao.makeRotationY(e),this.applyMatrix4(ao),this}rotateZ(e){return ao.makeRotationZ(e),this.applyMatrix4(ao),this}translate(e,n,r){return ao.makeTranslation(e,n,r),this.applyMatrix4(ao),this}scale(e,n,r){return ao.makeScale(e,n,r),this.applyMatrix4(ao),this}lookAt(e){return xk.lookAt(e),xk.updateMatrix(),this.applyMatrix4(xk.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ap).negate(),this.translate(ap.x,ap.y,ap.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 si(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new So);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 ze(-1/0,-1/0,-1/0),new ze(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];Ps.setFromBufferAttribute(a),this.morphTargetsRelative?(Bi.addVectors(this.boundingBox.min,Ps.min),this.boundingBox.expandByPoint(Bi),Bi.addVectors(this.boundingBox.max,Ps.max),this.boundingBox.expandByPoint(Bi)):(this.boundingBox.expandByPoint(Ps.min),this.boundingBox.expandByPoint(Ps.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 Pl);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 ze,1/0);return}if(e){const r=this.boundingSphere.center;if(Ps.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];cb.setFromBufferAttribute(l),this.morphTargetsRelative?(Bi.addVectors(Ps.min,cb.min),Ps.expandByPoint(Bi),Bi.addVectors(Ps.max,cb.max),Ps.expandByPoint(Bi)):(Ps.expandByPoint(cb.min),Ps.expandByPoint(cb.max))}Ps.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)Bi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Bi));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++)Bi.fromBufferAttribute(l,u),c&&(ap.fromBufferAttribute(e,u),Bi.add(ap)),i=Math.max(i,r.distanceToSquared(Bi))}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 $s(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let P=0;P<l;P++)u[P]=new ze,d[P]=new ze;const f=new ze,m=new ze,g=new ze,x=new cn,y=new cn,b=new cn,v=new ze,M=new ze;function S(P,F,L){f.fromArray(i,P*3),m.fromArray(i,F*3),g.fromArray(i,L*3),x.fromArray(o,P*2),y.fromArray(o,F*2),b.fromArray(o,L*2),m.sub(f),g.sub(f),y.sub(x),b.sub(x);const X=1/(y.x*b.y-b.x*y.y);isFinite(X)&&(v.copy(m).multiplyScalar(b.y).addScaledVector(g,-y.y).multiplyScalar(X),M.copy(g).multiplyScalar(y.x).addScaledVector(m,-b.x).multiplyScalar(X),u[P].add(v),u[F].add(v),u[L].add(v),d[P].add(M),d[F].add(M),d[L].add(M))}let A=this.groups;A.length===0&&(A=[{start:0,count:r.length}]);for(let P=0,F=A.length;P<F;++P){const L=A[P],X=L.start,D=L.count;for(let K=X,Y=X+D;K<Y;K+=3)S(r[K+0],r[K+1],r[K+2])}const E=new ze,k=new ze,C=new ze,R=new ze;function T(P){C.fromArray(a,P*3),R.copy(C);const F=u[P];E.copy(F),E.sub(C.multiplyScalar(C.dot(F))).normalize(),k.crossVectors(R,F);const X=k.dot(d[P])<0?-1:1;c[P*4]=E.x,c[P*4+1]=E.y,c[P*4+2]=E.z,c[P*4+3]=X}for(let P=0,F=A.length;P<F;++P){const L=A[P],X=L.start,D=L.count;for(let K=X,Y=X+D;K<Y;K+=3)T(r[K+0]),T(r[K+1]),T(r[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 $s(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,g=r.count;m<g;m++)r.setXYZ(m,0,0,0);const i=new ze,a=new ze,o=new ze,l=new ze,c=new ze,u=new ze,d=new ze,f=new ze;if(e)for(let m=0,g=e.count;m<g;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,g=n.count;m<g;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++)Bi.fromBufferAttribute(e,n),Bi.normalize(),e.setXYZ(n,Bi.x,Bi.y,Bi.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,m=new u.constructor(c.length*d);let g=0,x=0;for(let y=0,b=c.length;y<b;y++){l.isInterleavedBufferAttribute?g=c[y]*l.data.stride+l.offset:g=c[y]*d;for(let v=0;v<d;v++)m[x++]=u[g++]}return new $s(m,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Ra,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],g=e(m,r);c.push(g)}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 g=u[f];d.push(g.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,g=f.length;m<g;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 o7=new vr,Th=new jO,X_=new Pl,l7=new ze,sp=new ze,op=new ze,lp=new ze,bk=new ze,Y_=new ze,Q_=new cn,Z_=new cn,J_=new cn,c7=new ze,u7=new ze,d7=new ze,e1=new ze,t1=new ze;class Xo extends Va{constructor(e=new Ra,n=new kJ){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){Y_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(bk.fromBufferAttribute(f,e),o?Y_.addScaledVector(bk,d):Y_.addScaledVector(bk.sub(n),d))}n.add(Y_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),X_.copy(r.boundingSphere),X_.applyMatrix4(a),Th.copy(e.ray).recast(e.near),!(X_.containsPoint(Th.origin)===!1&&(Th.intersectSphere(X_,l7)===null||Th.origin.distanceToSquared(l7)>(e.far-e.near)**2))&&(o7.copy(a).invert(),Th.copy(e.ray).applyMatrix4(o7),!(r.boundingBox!==null&&Th.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Th)))}_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,g=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],M=Math.max(b.start,g.start),S=Math.min(l.count,Math.min(b.start+b.count,g.start+g.count));for(let A=M,E=S;A<E;A+=3){const k=l.getX(A),C=l.getX(A+1),R=l.getX(A+2);i=n1(this,v,e,r,u,d,f,k,C,R),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,g.start),y=Math.min(l.count,g.start+g.count);for(let b=x,v=y;b<v;b+=3){const M=l.getX(b),S=l.getX(b+1),A=l.getX(b+2);i=n1(this,o,e,r,u,d,f,M,S,A),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],M=Math.max(b.start,g.start),S=Math.min(c.count,Math.min(b.start+b.count,g.start+g.count));for(let A=M,E=S;A<E;A+=3){const k=A,C=A+1,R=A+2;i=n1(this,v,e,r,u,d,f,k,C,R),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,g.start),y=Math.min(c.count,g.start+g.count);for(let b=x,v=y;b<v;b+=3){const M=b,S=b+1,A=b+2;i=n1(this,o,e,r,u,d,f,M,S,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}}function lIe(t,e,n,r,i,a,o,l){let c;if(e.side===ms?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===Hd,l),c===null)return null;t1.copy(l),t1.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(t1);return u<n.near||u>n.far?null:{distance:u,point:t1.clone(),object:t}}function n1(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,sp),t.getVertexPosition(c,op),t.getVertexPosition(u,lp);const d=lIe(t,e,n,r,sp,op,lp,e1);if(d){i&&(Q_.fromBufferAttribute(i,l),Z_.fromBufferAttribute(i,c),J_.fromBufferAttribute(i,u),d.uv=$o.getInterpolation(e1,sp,op,lp,Q_,Z_,J_,new cn)),a&&(Q_.fromBufferAttribute(a,l),Z_.fromBufferAttribute(a,c),J_.fromBufferAttribute(a,u),d.uv1=$o.getInterpolation(e1,sp,op,lp,Q_,Z_,J_,new cn),d.uv2=d.uv1),o&&(c7.fromBufferAttribute(o,l),u7.fromBufferAttribute(o,c),d7.fromBufferAttribute(o,u),d.normal=$o.getInterpolation(e1,sp,op,lp,c7,u7,d7,new ze),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:l,b:c,c:u,normal:new ze,materialIndex:0};$o.getNormal(sp,op,lp,f.normal),d.face=f}return d}class Ay extends Ra{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,g=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 si(u,3)),this.setAttribute("normal",new si(d,3)),this.setAttribute("uv",new si(f,2));function x(y,b,v,M,S,A,E,k,C,R,T){const P=A/C,F=E/R,L=A/2,X=E/2,D=k/2,K=C+1,Y=R+1;let q=0,Z=0;const re=new ze;for(let oe=0;oe<Y;oe++){const B=oe*F-X;for(let G=0;G<K;G++){const J=G*P-L;re[y]=J*M,re[b]=B*S,re[v]=D,u.push(re.x,re.y,re.z),re[y]=0,re[b]=0,re[v]=k>0?1:-1,d.push(re.x,re.y,re.z),f.push(G/C),f.push(1-oe/R),q+=1}}for(let oe=0;oe<R;oe++)for(let B=0;B<C;B++){const G=m+B+K*oe,J=m+B+K*(oe+1),te=m+(B+1)+K*(oe+1),ae=m+(B+1)+K*oe;c.push(G,J,ae),c.push(J,te,ae),Z+=6}l.addGroup(g,Z,T),g+=Z,m+=q}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ay(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function xg(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 Fa(t){const e={};for(let n=0;n<t.length;n++){const r=xg(t[n]);for(const i in r)e[i]=r[i]}return e}function cIe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function RJ(t){return t.getRenderTarget()===null?t.outputColorSpace:lr.workingColorSpace}const PO={clone:xg,merge:Fa};var uIe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,dIe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class Vd extends qg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=uIe,this.fragmentShader=dIe,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=xg(e.uniforms),this.uniformsGroups=cIe(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 DJ extends Va{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new vr,this.projectionMatrix=new vr,this.projectionMatrixInverse=new vr,this.coordinateSystem=Cl}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 Ds extends DJ{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=j0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Db*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return j0*2*Math.atan(Math.tan(Db*.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(Db*.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 cp=-90,up=1;class hIe extends Va{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Ds(cp,up,e,n);i.layers=this.layers,this.add(i);const a=new Ds(cp,up,e,n);a.layers=this.layers,this.add(a);const o=new Ds(cp,up,e,n);o.layers=this.layers,this.add(o);const l=new Ds(cp,up,e,n);l.layers=this.layers,this.add(l);const c=new Ds(cp,up,e,n);c.layers=this.layers,this.add(c);const u=new Ds(cp,up,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===Cl)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===k0)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(),g=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,g),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class OJ extends ps{constructor(e,n,r,i,a,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:mg,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 fIe extends Lf{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];n.encoding!==void 0&&(Lb("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===df?fa:bo),this.texture=new OJ(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:go}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new Ay(5,5,5),a=new Vd({name:"CubemapFromEquirect",uniforms:xg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ms,blending:Ad});a.uniforms.tEquirect.value=n;const o=new Xo(i,a),l=n.minFilter;return n.minFilter===T0&&(n.minFilter=go),new hIe(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 yk=new ze,mIe=new ze,pIe=new Mn;class ad{constructor(e=new ze(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=yk.subVectors(r,n).cross(mIe.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(yk),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||pIe.getNormalMatrix(e),i=this.coplanarPoint(yk).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 Ch=new Pl,r1=new ze;class BM{constructor(e=new ad,n=new ad,r=new ad,i=new ad,a=new ad,o=new ad){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=Cl){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],g=i[8],x=i[9],y=i[10],b=i[11],v=i[12],M=i[13],S=i[14],A=i[15];if(r[0].setComponents(c-a,m-u,b-g,A-v).normalize(),r[1].setComponents(c+a,m+u,b+g,A+v).normalize(),r[2].setComponents(c+o,m+d,b+x,A+M).normalize(),r[3].setComponents(c-o,m-d,b-x,A-M).normalize(),r[4].setComponents(c-l,m-f,b-y,A-S).normalize(),n===Cl)r[5].setComponents(c+l,m+f,b+y,A+S).normalize();else if(n===k0)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(),Ch.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Ch.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ch)}intersectsSprite(e){return Ch.center.set(0,0,0),Ch.radius=.7071067811865476,Ch.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ch)}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(r1.x=i.normal.x>0?e.max.x:e.min.x,r1.y=i.normal.y>0?e.max.y:e.min.y,r1.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(r1)<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 LJ(){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 gIe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,m=u.usage,g=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:g}}function a(u,d,f){const m=d.array,g=d._updateRange,x=d.updateRanges;if(t.bindBuffer(f,u),g.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()}g.count!==-1&&(n?t.bufferSubData(f,g.offset*m.BYTES_PER_ELEMENT,m,g.offset,g.count):t.bufferSubData(f,g.offset*m.BYTES_PER_ELEMENT,m.subarray(g.offset,g.offset+g.count)),g.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 RO extends Ra{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,g=[],x=[],y=[],b=[];for(let v=0;v<d;v++){const M=v*m-o;for(let S=0;S<u;S++){const A=S*f-a;x.push(A,-M,0),y.push(0,0,1),b.push(S/l),b.push(1-v/c)}}for(let v=0;v<c;v++)for(let M=0;M<l;M++){const S=M+u*v,A=M+u*(v+1),E=M+1+u*(v+1),k=M+1+u*v;g.push(S,A,k),g.push(A,E,k)}this.setIndex(g),this.setAttribute("position",new si(x,3)),this.setAttribute("normal",new si(y,3)),this.setAttribute("uv",new si(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new RO(e.width,e.height,e.widthSegments,e.heightSegments)}}var xIe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,bIe=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,yIe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,vIe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,_Ie=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,wIe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,SIe=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,MIe=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,NIe=`#ifdef USE_BATCHING
- attribute float batchId;
- uniform highp sampler2D batchingTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,EIe=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,AIe=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,TIe=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,CIe=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,kIe=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,jIe=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,PIe=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif`,RIe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,DIe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,OIe=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,LIe=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,IIe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,FIe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,UIe=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif`,zIe=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- mat3 transposeMat3( const in mat3 m ) {
- mat3 tmp;
- tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
- tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
- tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
- return tmp;
- }
- float luminance( const in vec3 rgb ) {
- const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
- return dot( weights, rgb );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,BIe=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_v0 0.339
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_v1 0.276
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_v4 0.046
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_v5 0.016
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_v6 0.0038
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,$Ie=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,HIe=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,VIe=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,GIe=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,WIe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,qIe="gl_FragColor = linearToOutputTexel( gl_FragColor );",KIe=`
- const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
- vec3( 0.8224621, 0.177538, 0.0 ),
- vec3( 0.0331941, 0.9668058, 0.0 ),
- vec3( 0.0170827, 0.0723974, 0.9105199 )
- );
- const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
- vec3( 1.2249401, - 0.2249404, 0.0 ),
- vec3( - 0.0420569, 1.0420571, 0.0 ),
- vec3( - 0.0196376, - 0.0786361, 1.0982735 )
- );
- vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
- return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
- }
- vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
- return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
- }
- vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }
- vec4 LinearToLinear( in vec4 value ) {
- return value;
- }
- vec4 LinearTosRGB( in vec4 value ) {
- return sRGBTransferOETF( value );
- }`,XIe=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,YIe=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,QIe=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,ZIe=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,JIe=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,e5e=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,t5e=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,n5e=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,r5e=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,i5e=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,a5e=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,s5e=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,o5e=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,l5e=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,c5e=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- #if defined ( LEGACY_LIGHTS )
- if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
- return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
- }
- return 1.0;
- #else
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- #endif
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,u5e=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,d5e=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,h5e=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,f5e=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,m5e=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,p5e=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,g5e=`struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
- const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
- vec4 r = roughness * c0 + c1;
- float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
- vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
- return fab;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,x5e=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,b5e=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,y5e=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,v5e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,_5e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,w5e=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,S5e=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #else
- if ( isPerspectiveMatrix( projectionMatrix ) ) {
- gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
- gl_Position.z *= gl_Position.w;
- }
- #endif
- #endif`,M5e=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
-
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,N5e=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,E5e=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,A5e=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,T5e=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,C5e=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,k5e=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,j5e=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
- objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
- objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
- objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
- #endif
- #endif`,P5e=`#ifdef USE_MORPHTARGETS
- uniform float morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #else
- #ifndef USE_MORPHNORMALS
- uniform float morphTargetInfluences[ 8 ];
- #else
- uniform float morphTargetInfluences[ 4 ];
- #endif
- #endif
- #endif`,R5e=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- transformed += morphTarget0 * morphTargetInfluences[ 0 ];
- transformed += morphTarget1 * morphTargetInfluences[ 1 ];
- transformed += morphTarget2 * morphTargetInfluences[ 2 ];
- transformed += morphTarget3 * morphTargetInfluences[ 3 ];
- #ifndef USE_MORPHNORMALS
- transformed += morphTarget4 * morphTargetInfluences[ 4 ];
- transformed += morphTarget5 * morphTargetInfluences[ 5 ];
- transformed += morphTarget6 * morphTargetInfluences[ 6 ];
- transformed += morphTarget7 * morphTargetInfluences[ 7 ];
- #endif
- #endif
- #endif`,D5e=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,O5e=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,L5e=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,I5e=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,F5e=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,U5e=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,z5e=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,B5e=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,$5e=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,H5e=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,V5e=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,G5e=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
- const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
- const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
- const float ShiftRight8 = 1. / 256.;
- vec4 packDepthToRGBA( const in float v ) {
- vec4 r = vec4( fract( v * PackFactors ), v );
- r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors );
- }
- vec2 packDepthToRG( in highp float v ) {
- return packDepthToRGBA( v ).yx;
- }
- float unpackRGToDepth( const in highp vec2 v ) {
- return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
- }
- vec4 pack2HalfToRGBA( vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,W5e=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,q5e=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,K5e=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,X5e=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,Y5e=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,Q5e=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,Z5e=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- float hard_shadow = step( compare , distribution.x );
- if (hard_shadow != 1.0 ) {
- float distance = compare - distribution.x ;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return shadow;
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- vec3 lightToPosition = shadowCoord.xyz;
- float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- return (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- #endif`,J5e=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,eFe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,tFe=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,nFe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,rFe=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,iFe=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,aFe=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,sFe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,oFe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,lFe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,cFe=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 OptimizedCineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,uFe=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,dFe=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,hFe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,fFe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,mFe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,pFe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const gFe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,xFe=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,bFe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,yFe=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,vFe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,_Fe=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,wFe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,SFe=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #endif
- }`,MFe=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,NFe=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,EFe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,AFe=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,TFe=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,CFe=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,kFe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,jFe=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,PFe=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,RFe=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,DFe=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,OFe=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,LFe=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,IFe=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,FFe=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,UFe=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,zFe=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,BFe=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,$Fe=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,HFe=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,VFe=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,GFe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,WFe=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,qFe=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,KFe=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
- vec2 scale;
- scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
- scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,XFe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,yn={alphahash_fragment:xIe,alphahash_pars_fragment:bIe,alphamap_fragment:yIe,alphamap_pars_fragment:vIe,alphatest_fragment:_Ie,alphatest_pars_fragment:wIe,aomap_fragment:SIe,aomap_pars_fragment:MIe,batching_pars_vertex:NIe,batching_vertex:EIe,begin_vertex:AIe,beginnormal_vertex:TIe,bsdfs:CIe,iridescence_fragment:kIe,bumpmap_pars_fragment:jIe,clipping_planes_fragment:PIe,clipping_planes_pars_fragment:RIe,clipping_planes_pars_vertex:DIe,clipping_planes_vertex:OIe,color_fragment:LIe,color_pars_fragment:IIe,color_pars_vertex:FIe,color_vertex:UIe,common:zIe,cube_uv_reflection_fragment:BIe,defaultnormal_vertex:$Ie,displacementmap_pars_vertex:HIe,displacementmap_vertex:VIe,emissivemap_fragment:GIe,emissivemap_pars_fragment:WIe,colorspace_fragment:qIe,colorspace_pars_fragment:KIe,envmap_fragment:XIe,envmap_common_pars_fragment:YIe,envmap_pars_fragment:QIe,envmap_pars_vertex:ZIe,envmap_physical_pars_fragment:u5e,envmap_vertex:JIe,fog_vertex:e5e,fog_pars_vertex:t5e,fog_fragment:n5e,fog_pars_fragment:r5e,gradientmap_pars_fragment:i5e,lightmap_fragment:a5e,lightmap_pars_fragment:s5e,lights_lambert_fragment:o5e,lights_lambert_pars_fragment:l5e,lights_pars_begin:c5e,lights_toon_fragment:d5e,lights_toon_pars_fragment:h5e,lights_phong_fragment:f5e,lights_phong_pars_fragment:m5e,lights_physical_fragment:p5e,lights_physical_pars_fragment:g5e,lights_fragment_begin:x5e,lights_fragment_maps:b5e,lights_fragment_end:y5e,logdepthbuf_fragment:v5e,logdepthbuf_pars_fragment:_5e,logdepthbuf_pars_vertex:w5e,logdepthbuf_vertex:S5e,map_fragment:M5e,map_pars_fragment:N5e,map_particle_fragment:E5e,map_particle_pars_fragment:A5e,metalnessmap_fragment:T5e,metalnessmap_pars_fragment:C5e,morphcolor_vertex:k5e,morphnormal_vertex:j5e,morphtarget_pars_vertex:P5e,morphtarget_vertex:R5e,normal_fragment_begin:D5e,normal_fragment_maps:O5e,normal_pars_fragment:L5e,normal_pars_vertex:I5e,normal_vertex:F5e,normalmap_pars_fragment:U5e,clearcoat_normal_fragment_begin:z5e,clearcoat_normal_fragment_maps:B5e,clearcoat_pars_fragment:$5e,iridescence_pars_fragment:H5e,opaque_fragment:V5e,packing:G5e,premultiplied_alpha_fragment:W5e,project_vertex:q5e,dithering_fragment:K5e,dithering_pars_fragment:X5e,roughnessmap_fragment:Y5e,roughnessmap_pars_fragment:Q5e,shadowmap_pars_fragment:Z5e,shadowmap_pars_vertex:J5e,shadowmap_vertex:eFe,shadowmask_pars_fragment:tFe,skinbase_vertex:nFe,skinning_pars_vertex:rFe,skinning_vertex:iFe,skinnormal_vertex:aFe,specularmap_fragment:sFe,specularmap_pars_fragment:oFe,tonemapping_fragment:lFe,tonemapping_pars_fragment:cFe,transmission_fragment:uFe,transmission_pars_fragment:dFe,uv_pars_fragment:hFe,uv_pars_vertex:fFe,uv_vertex:mFe,worldpos_vertex:pFe,background_vert:gFe,background_frag:xFe,backgroundCube_vert:bFe,backgroundCube_frag:yFe,cube_vert:vFe,cube_frag:_Fe,depth_vert:wFe,depth_frag:SFe,distanceRGBA_vert:MFe,distanceRGBA_frag:NFe,equirect_vert:EFe,equirect_frag:AFe,linedashed_vert:TFe,linedashed_frag:CFe,meshbasic_vert:kFe,meshbasic_frag:jFe,meshlambert_vert:PFe,meshlambert_frag:RFe,meshmatcap_vert:DFe,meshmatcap_frag:OFe,meshnormal_vert:LFe,meshnormal_frag:IFe,meshphong_vert:FFe,meshphong_frag:UFe,meshphysical_vert:zFe,meshphysical_frag:BFe,meshtoon_vert:$Fe,meshtoon_frag:HFe,points_vert:VFe,points_frag:GFe,shadow_vert:WFe,shadow_frag:qFe,sprite_vert:KFe,sprite_frag:XFe},Pt={common:{diffuse:{value:new Qt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Mn},alphaMap:{value:null},alphaMapTransform:{value:new Mn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Mn}},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 Mn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Mn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Mn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Mn},normalScale:{value:new cn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Mn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Mn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Mn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Mn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Qt(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 Qt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Mn},alphaTest:{value:0},uvTransform:{value:new Mn}},sprite:{diffuse:{value:new Qt(16777215)},opacity:{value:1},center:{value:new cn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Mn},alphaMap:{value:null},alphaMapTransform:{value:new Mn},alphaTest:{value:0}}},cs={basic:{uniforms:Fa([Pt.common,Pt.specularmap,Pt.envmap,Pt.aomap,Pt.lightmap,Pt.fog]),vertexShader:yn.meshbasic_vert,fragmentShader:yn.meshbasic_frag},lambert:{uniforms:Fa([Pt.common,Pt.specularmap,Pt.envmap,Pt.aomap,Pt.lightmap,Pt.emissivemap,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,Pt.fog,Pt.lights,{emissive:{value:new Qt(0)}}]),vertexShader:yn.meshlambert_vert,fragmentShader:yn.meshlambert_frag},phong:{uniforms:Fa([Pt.common,Pt.specularmap,Pt.envmap,Pt.aomap,Pt.lightmap,Pt.emissivemap,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,Pt.fog,Pt.lights,{emissive:{value:new Qt(0)},specular:{value:new Qt(1118481)},shininess:{value:30}}]),vertexShader:yn.meshphong_vert,fragmentShader:yn.meshphong_frag},standard:{uniforms:Fa([Pt.common,Pt.envmap,Pt.aomap,Pt.lightmap,Pt.emissivemap,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,Pt.roughnessmap,Pt.metalnessmap,Pt.fog,Pt.lights,{emissive:{value:new Qt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:yn.meshphysical_vert,fragmentShader:yn.meshphysical_frag},toon:{uniforms:Fa([Pt.common,Pt.aomap,Pt.lightmap,Pt.emissivemap,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,Pt.gradientmap,Pt.fog,Pt.lights,{emissive:{value:new Qt(0)}}]),vertexShader:yn.meshtoon_vert,fragmentShader:yn.meshtoon_frag},matcap:{uniforms:Fa([Pt.common,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,Pt.fog,{matcap:{value:null}}]),vertexShader:yn.meshmatcap_vert,fragmentShader:yn.meshmatcap_frag},points:{uniforms:Fa([Pt.points,Pt.fog]),vertexShader:yn.points_vert,fragmentShader:yn.points_frag},dashed:{uniforms:Fa([Pt.common,Pt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:yn.linedashed_vert,fragmentShader:yn.linedashed_frag},depth:{uniforms:Fa([Pt.common,Pt.displacementmap]),vertexShader:yn.depth_vert,fragmentShader:yn.depth_frag},normal:{uniforms:Fa([Pt.common,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,{opacity:{value:1}}]),vertexShader:yn.meshnormal_vert,fragmentShader:yn.meshnormal_frag},sprite:{uniforms:Fa([Pt.sprite,Pt.fog]),vertexShader:yn.sprite_vert,fragmentShader:yn.sprite_frag},background:{uniforms:{uvTransform:{value:new Mn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:yn.background_vert,fragmentShader:yn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:yn.backgroundCube_vert,fragmentShader:yn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:yn.cube_vert,fragmentShader:yn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:yn.equirect_vert,fragmentShader:yn.equirect_frag},distanceRGBA:{uniforms:Fa([Pt.common,Pt.displacementmap,{referencePosition:{value:new ze},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:yn.distanceRGBA_vert,fragmentShader:yn.distanceRGBA_frag},shadow:{uniforms:Fa([Pt.lights,Pt.fog,{color:{value:new Qt(0)},opacity:{value:1}}]),vertexShader:yn.shadow_vert,fragmentShader:yn.shadow_frag}};cs.physical={uniforms:Fa([cs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Mn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Mn},clearcoatNormalScale:{value:new cn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Mn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Mn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Mn},sheen:{value:0},sheenColor:{value:new Qt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Mn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Mn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Mn},transmissionSamplerSize:{value:new cn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Mn},attenuationDistance:{value:0},attenuationColor:{value:new Qt(0)},specularColor:{value:new Qt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Mn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Mn},anisotropyVector:{value:new cn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Mn}}]),vertexShader:yn.meshphysical_vert,fragmentShader:yn.meshphysical_frag};const i1={r:0,b:0,g:0};function YFe(t,e,n,r,i,a,o){const l=new Qt(0);let c=a===!0?0:1,u,d,f=null,m=0,g=null;function x(b,v){let M=!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),M=!0);const A=t.xr.getEnvironmentBlendMode();A==="additive"?r.buffers.color.setClear(0,0,0,1,o):A==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||M)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),S&&(S.isCubeTexture||S.mapping===UM)?(d===void 0&&(d=new Xo(new Ay(1,1,1),new Vd({name:"BackgroundCubeMaterial",uniforms:xg(cs.backgroundCube.uniforms),vertexShader:cs.backgroundCube.vertexShader,fragmentShader:cs.backgroundCube.fragmentShader,side:ms,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(E,k,C){this.matrixWorld.copyPosition(C.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=lr.getTransfer(S.colorSpace)!==Mr,(f!==S||m!==S.version||g!==t.toneMapping)&&(d.material.needsUpdate=!0,f=S,m=S.version,g=t.toneMapping),d.layers.enableAll(),b.unshift(d,d.geometry,d.material,0,0,null)):S&&S.isTexture&&(u===void 0&&(u=new Xo(new RO(2,2),new Vd({name:"BackgroundMaterial",uniforms:xg(cs.background.uniforms),vertexShader:cs.background.vertexShader,fragmentShader:cs.background.fragmentShader,side:Hd,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=lr.getTransfer(S.colorSpace)!==Mr,S.matrixAutoUpdate===!0&&S.updateMatrix(),u.material.uniforms.uvTransform.value.copy(S.matrix),(f!==S||m!==S.version||g!==t.toneMapping)&&(u.material.needsUpdate=!0,f=S,m=S.version,g=t.toneMapping),u.layers.enableAll(),b.unshift(u,u.geometry,u.material,0,0,null))}function y(b,v){b.getRGB(i1,RJ(t)),r.buffers.color.setClear(i1.r,i1.g,i1.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 QFe(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(D,K,Y,q,Z){let re=!1;if(o){const oe=y(q,Y,K);u!==oe&&(u=oe,g(u.object)),re=v(D,q,Y,Z),re&&M(D,q,Y,Z)}else{const oe=K.wireframe===!0;(u.geometry!==q.id||u.program!==Y.id||u.wireframe!==oe)&&(u.geometry=q.id,u.program=Y.id,u.wireframe=oe,re=!0)}Z!==null&&n.update(Z,t.ELEMENT_ARRAY_BUFFER),(re||d)&&(d=!1,R(D,K,Y,q),Z!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(Z).buffer))}function m(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function g(D){return r.isWebGL2?t.bindVertexArray(D):a.bindVertexArrayOES(D)}function x(D){return r.isWebGL2?t.deleteVertexArray(D):a.deleteVertexArrayOES(D)}function y(D,K,Y){const q=Y.wireframe===!0;let Z=l[D.id];Z===void 0&&(Z={},l[D.id]=Z);let re=Z[K.id];re===void 0&&(re={},Z[K.id]=re);let oe=re[q];return oe===void 0&&(oe=b(m()),re[q]=oe),oe}function b(D){const K=[],Y=[],q=[];for(let Z=0;Z<i;Z++)K[Z]=0,Y[Z]=0,q[Z]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:K,enabledAttributes:Y,attributeDivisors:q,object:D,attributes:{},index:null}}function v(D,K,Y,q){const Z=u.attributes,re=K.attributes;let oe=0;const B=Y.getAttributes();for(const G in B)if(B[G].location>=0){const te=Z[G];let ae=re[G];if(ae===void 0&&(G==="instanceMatrix"&&D.instanceMatrix&&(ae=D.instanceMatrix),G==="instanceColor"&&D.instanceColor&&(ae=D.instanceColor)),te===void 0||te.attribute!==ae||ae&&te.data!==ae.data)return!0;oe++}return u.attributesNum!==oe||u.index!==q}function M(D,K,Y,q){const Z={},re=K.attributes;let oe=0;const B=Y.getAttributes();for(const G in B)if(B[G].location>=0){let te=re[G];te===void 0&&(G==="instanceMatrix"&&D.instanceMatrix&&(te=D.instanceMatrix),G==="instanceColor"&&D.instanceColor&&(te=D.instanceColor));const ae={};ae.attribute=te,te&&te.data&&(ae.data=te.data),Z[G]=ae,oe++}u.attributes=Z,u.attributesNum=oe,u.index=q}function S(){const D=u.newAttributes;for(let K=0,Y=D.length;K<Y;K++)D[K]=0}function A(D){E(D,0)}function E(D,K){const Y=u.newAttributes,q=u.enabledAttributes,Z=u.attributeDivisors;Y[D]=1,q[D]===0&&(t.enableVertexAttribArray(D),q[D]=1),Z[D]!==K&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](D,K),Z[D]=K)}function k(){const D=u.newAttributes,K=u.enabledAttributes;for(let Y=0,q=K.length;Y<q;Y++)K[Y]!==D[Y]&&(t.disableVertexAttribArray(Y),K[Y]=0)}function C(D,K,Y,q,Z,re,oe){oe===!0?t.vertexAttribIPointer(D,K,Y,Z,re):t.vertexAttribPointer(D,K,Y,q,Z,re)}function R(D,K,Y,q){if(r.isWebGL2===!1&&(D.isInstancedMesh||q.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;S();const Z=q.attributes,re=Y.getAttributes(),oe=K.defaultAttributeValues;for(const B in re){const G=re[B];if(G.location>=0){let J=Z[B];if(J===void 0&&(B==="instanceMatrix"&&D.instanceMatrix&&(J=D.instanceMatrix),B==="instanceColor"&&D.instanceColor&&(J=D.instanceColor)),J!==void 0){const te=J.normalized,ae=J.itemSize,de=n.get(J);if(de===void 0)continue;const fe=de.buffer,Ae=de.type,ge=de.bytesPerElement,Me=r.isWebGL2===!0&&(Ae===t.INT||Ae===t.UNSIGNED_INT||J.gpuType===fJ);if(J.isInterleavedBufferAttribute){const je=J.data,ne=je.stride,Ke=J.offset;if(je.isInstancedInterleavedBuffer){for(let $=0;$<G.locationSize;$++)E(G.location+$,je.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=je.meshPerAttribute*je.count)}else for(let $=0;$<G.locationSize;$++)A(G.location+$);t.bindBuffer(t.ARRAY_BUFFER,fe);for(let $=0;$<G.locationSize;$++)C(G.location+$,ae/G.locationSize,Ae,te,ne*ge,(Ke+ae/G.locationSize*$)*ge,Me)}else{if(J.isInstancedBufferAttribute){for(let je=0;je<G.locationSize;je++)E(G.location+je,J.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let je=0;je<G.locationSize;je++)A(G.location+je);t.bindBuffer(t.ARRAY_BUFFER,fe);for(let je=0;je<G.locationSize;je++)C(G.location+je,ae/G.locationSize,Ae,te,ae*ge,ae/G.locationSize*je*ge,Me)}}else if(oe!==void 0){const te=oe[B];if(te!==void 0)switch(te.length){case 2:t.vertexAttrib2fv(G.location,te);break;case 3:t.vertexAttrib3fv(G.location,te);break;case 4:t.vertexAttrib4fv(G.location,te);break;default:t.vertexAttrib1fv(G.location,te)}}}}k()}function T(){L();for(const D in l){const K=l[D];for(const Y in K){const q=K[Y];for(const Z in q)x(q[Z].object),delete q[Z];delete K[Y]}delete l[D]}}function P(D){if(l[D.id]===void 0)return;const K=l[D.id];for(const Y in K){const q=K[Y];for(const Z in q)x(q[Z].object),delete q[Z];delete K[Y]}delete l[D.id]}function F(D){for(const K in l){const Y=l[K];if(Y[D.id]===void 0)continue;const q=Y[D.id];for(const Z in q)x(q[Z].object),delete q[Z];delete Y[D.id]}}function L(){X(),d=!0,u!==c&&(u=c,g(u.object))}function X(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:L,resetDefaultState:X,dispose:T,releaseStatesOfGeometry:P,releaseStatesOfProgram:F,initAttributes:S,enableAttribute:A,disableUnusedAttributes:k}}function ZFe(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 g,x;if(i)g=t,x="drawArraysInstanced";else if(g=e.get("ANGLE_instanced_arrays"),x="drawArraysInstancedANGLE",g===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}g[x](a,d,f,m),n.update(f,a,m)}function u(d,f,m){if(m===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let x=0;x<m;x++)this.render(d[x],f[x]);else{g.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 JFe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let l=n.precision!==void 0?n.precision:"highp";const c=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),g=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),M=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),S=m>0,A=o||e.has("OES_texture_float"),E=S&&A,k=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:g,maxCubemapSize:x,maxAttributes:y,maxVertexUniforms:b,maxVaryings:v,maxFragmentUniforms:M,vertexTextures:S,floatFragmentTextures:A,floatVertexTextures:E,maxSamples:k}}function eUe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new ad,l=new Mn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,m){const g=f.length!==0||m||r!==0||i;return i=m,r=f.length,g},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,g){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 M=a?0:r,S=M*4;let A=v.clippingState||null;c.value=A,A=d(x,m,S,g);for(let E=0;E!==S;++E)A[E]=n[E];v.clippingState=A,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=M}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,m,g,x){const y=f!==null?f.length:0;let b=null;if(y!==0){if(b=c.value,x!==!0||b===null){const v=g+y*4,M=m.matrixWorldInverse;l.getNormalMatrix(M),(b===null||b.length<v)&&(b=new Float32Array(v));for(let S=0,A=g;S!==y;++S,A+=4)o.copy(f[S]).applyMatrix4(M,l),o.normal.toArray(b,A),b[A+3]=o.constant}c.value=b,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,b}}function tUe(t){let e=new WeakMap;function n(o,l){return l===BP?o.mapping=mg:l===$P&&(o.mapping=pg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===BP||l===$P)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 fIe(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 nUe extends DJ{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 jp=4,h7=[.125,.215,.35,.446,.526,.582],zh=20,vk=new nUe,f7=new Qt;let _k=null,wk=0,Sk=0;const Lh=(1+Math.sqrt(5))/2,dp=1/Lh,m7=[new ze(1,1,1),new ze(-1,1,1),new ze(1,1,-1),new ze(-1,1,-1),new ze(0,Lh,dp),new ze(0,Lh,-dp),new ze(dp,0,Lh),new ze(-dp,0,Lh),new ze(Lh,dp,0),new ze(-Lh,dp,0)];class p7{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){_k=this._renderer.getRenderTarget(),wk=this._renderer.getActiveCubeFace(),Sk=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=b7(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=x7(),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(_k,wk,Sk),e.scissorTest=!1,a1(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===mg||e.mapping===pg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),_k=this._renderer.getRenderTarget(),wk=this._renderer.getActiveCubeFace(),Sk=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:go,minFilter:go,generateMipmaps:!1,type:C0,format:xo,colorSpace:cu,depthBuffer:!1},i=g7(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=g7(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=rUe(a)),this._blurMaterial=iUe(a,e,n)}return i}_compileMaterial(e){const n=new Xo(this._lodPlanes[0],e);this._renderer.compile(n,vk)}_sceneToCubeUV(e,n,r,i){const l=new Ds(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(f7),d.toneMapping=Td,d.autoClear=!1;const g=new kJ({name:"PMREM.Background",side:ms,depthWrite:!1,depthTest:!1}),x=new Xo(new Ay,g);let y=!1;const b=e.background;b?b.isColor&&(g.color.copy(b),e.background=null,y=!0):(g.color.copy(f7),y=!0);for(let v=0;v<6;v++){const M=v%3;M===0?(l.up.set(0,c[v],0),l.lookAt(u[v],0,0)):M===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;a1(i,M*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===mg||e.mapping===pg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=b7()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=x7());const a=i?this._cubemapMaterial:this._equirectMaterial,o=new Xo(this._lodPlanes[0],a),l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;a1(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,vk)}_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=m7[(i-1)%m7.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 Xo(this._lodPlanes[i],u),m=u.uniforms,g=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*g):2*Math.PI/(2*zh-1),y=a/x,b=isFinite(a)?1+Math.floor(d*y):zh;b>zh&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${zh}`);const v=[];let M=0;for(let C=0;C<zh;++C){const R=C/y,T=Math.exp(-R*R/2);v.push(T),C===0?M+=T:C<b&&(M+=2*T)}for(let C=0;C<v.length;C++)v[C]=v[C]/M;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 A=this._sizeLods[i],E=3*A*(i>S-jp?i-S+jp:0),k=4*(this._cubeSize-A);a1(n,E,k,3*A,2*A),c.setRenderTarget(n),c.render(f,vk)}}function rUe(t){const e=[],n=[],r=[];let i=t;const a=t-jp+1+h7.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-jp?c=h7[o-t+jp-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],g=6,x=6,y=3,b=2,v=1,M=new Float32Array(y*x*g),S=new Float32Array(b*x*g),A=new Float32Array(v*x*g);for(let k=0;k<g;k++){const C=k%3*2/3-1,R=k>2?0:-1,T=[C,R,0,C+2/3,R,0,C+2/3,R+1,0,C,R,0,C+2/3,R+1,0,C,R+1,0];M.set(T,y*x*k),S.set(m,b*x*k);const P=[k,k,k,k,k,k];A.set(P,v*x*k)}const E=new Ra;E.setAttribute("position",new $s(M,y)),E.setAttribute("uv",new $s(S,b)),E.setAttribute("faceIndex",new $s(A,v)),e.push(E),i>jp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function g7(t,e,n){const r=new Lf(t,e,n);return r.texture.mapping=UM,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function a1(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function iUe(t,e,n){const r=new Float32Array(zh),i=new ze(0,1,0);return new Vd({name:"SphericalGaussianBlur",defines:{n:zh,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:DO(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:Ad,depthTest:!1,depthWrite:!1})}function x7(){return new Vd({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:DO(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:Ad,depthTest:!1,depthWrite:!1})}function b7(){return new Vd({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:DO(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:Ad,depthTest:!1,depthWrite:!1})}function DO(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function aUe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===BP||c===$P,d=c===mg||c===pg;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new p7(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 p7(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 sUe(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 oUe(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 g=a.get(m);g&&(e.remove(g),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 g=f.morphAttributes;for(const x in g){const y=g[x];for(let b=0,v=y.length;b<v;b++)e.update(y[b],t.ARRAY_BUFFER)}}function u(f){const m=[],g=f.index,x=f.attributes.position;let y=0;if(g!==null){const M=g.array;y=g.version;for(let S=0,A=M.length;S<A;S+=3){const E=M[S+0],k=M[S+1],C=M[S+2];m.push(E,k,k,C,C,E)}}else if(x!==void 0){const M=x.array;y=x.version;for(let S=0,A=M.length/3-1;S<A;S+=3){const E=S+0,k=S+1,C=S+2;m.push(E,k,k,C,C,E)}}else return;const b=new(MJ(m)?PJ:jJ)(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 g=f.index;g!==null&&m.version<g.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function lUe(t,e,n,r){const i=r.isWebGL2;let a;function o(g){a=g}let l,c;function u(g){l=g.type,c=g.bytesPerElement}function d(g,x){t.drawElements(a,x,l,g*c),n.update(x,a,1)}function f(g,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,g*c,y),n.update(x,a,y)}function m(g,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(g[v]/c,x[v]);else{b.multiDrawElementsWEBGL(a,x,0,l,g,0,y);let v=0;for(let M=0;M<y;M++)v+=x[M];n.update(v,a,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=m}function cUe(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 uUe(t,e){return t[0]-e[0]}function dUe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function hUe(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,o=new ur,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 K=function(){X.dispose(),a.delete(d),d.removeEventListener("dispose",K)};var g=K;b!==void 0&&b.texture.dispose();const S=d.morphAttributes.position!==void 0,A=d.morphAttributes.normal!==void 0,E=d.morphAttributes.color!==void 0,k=d.morphAttributes.position||[],C=d.morphAttributes.normal||[],R=d.morphAttributes.color||[];let T=0;S===!0&&(T=1),A===!0&&(T=2),E===!0&&(T=3);let P=d.attributes.position.count*T,F=1;P>e.maxTextureSize&&(F=Math.ceil(P/e.maxTextureSize),P=e.maxTextureSize);const L=new Float32Array(P*F*4*y),X=new AJ(L,P,F,y);X.type=$c,X.needsUpdate=!0;const D=T*4;for(let Y=0;Y<y;Y++){const q=k[Y],Z=C[Y],re=R[Y],oe=P*F*4*Y;for(let B=0;B<q.count;B++){const G=B*D;S===!0&&(o.fromBufferAttribute(q,B),L[oe+G+0]=o.x,L[oe+G+1]=o.y,L[oe+G+2]=o.z,L[oe+G+3]=0),A===!0&&(o.fromBufferAttribute(Z,B),L[oe+G+4]=o.x,L[oe+G+5]=o.y,L[oe+G+6]=o.z,L[oe+G+7]=0),E===!0&&(o.fromBufferAttribute(re,B),L[oe+G+8]=o.x,L[oe+G+9]=o.y,L[oe+G+10]=o.z,L[oe+G+11]=re.itemSize===4?o.w:1)}}b={count:y,texture:X,size:new cn(P,F)},a.set(d,b),d.addEventListener("dispose",K)}let v=0;for(let S=0;S<m.length;S++)v+=m[S];const M=d.morphTargetsRelative?1:1-v;f.getUniforms().setValue(t,"morphTargetBaseInfluence",M),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 A=0;A<x;A++)y[A]=[A,0];r[d.id]=y}for(let A=0;A<x;A++){const E=y[A];E[0]=A,E[1]=m[A]}y.sort(dUe);for(let A=0;A<8;A++)A<x&&y[A][1]?(l[A][0]=y[A][0],l[A][1]=y[A][1]):(l[A][0]=Number.MAX_SAFE_INTEGER,l[A][1]=0);l.sort(uUe);const b=d.morphAttributes.position,v=d.morphAttributes.normal;let M=0;for(let A=0;A<8;A++){const E=l[A],k=E[0],C=E[1];k!==Number.MAX_SAFE_INTEGER&&C?(b&&d.getAttribute("morphTarget"+A)!==b[k]&&d.setAttribute("morphTarget"+A,b[k]),v&&d.getAttribute("morphNormal"+A)!==v[k]&&d.setAttribute("morphNormal"+A,v[k]),i[A]=C,M+=C):(b&&d.hasAttribute("morphTarget"+A)===!0&&d.deleteAttribute("morphTarget"+A),v&&d.hasAttribute("morphNormal"+A)===!0&&d.deleteAttribute("morphNormal"+A),i[A]=0)}const S=d.morphTargetsRelative?1:1-M;f.getUniforms().setValue(t,"morphTargetBaseInfluence",S),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function fUe(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 IJ extends ps{constructor(e,n,r,i,a,o,l,c,u,d){if(d=d!==void 0?d:uf,d!==uf&&d!==gg)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===uf&&(r=gd),r===void 0&&d===gg&&(r=cf),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:ha,this.minFilter=c!==void 0?c:ha,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 FJ=new ps,UJ=new IJ(1,1);UJ.compareFunction=wJ;const zJ=new AJ,BJ=new QLe,$J=new OJ,y7=[],v7=[],_7=new Float32Array(16),w7=new Float32Array(9),S7=new Float32Array(4);function Kg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=y7[i];if(a===void 0&&(a=new Float32Array(i),y7[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 Ci(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 ki(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function $M(t,e){let n=v7[e];n===void 0&&(n=new Int32Array(e),v7[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function mUe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function pUe(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(Ci(n,e))return;t.uniform2fv(this.addr,e),ki(n,e)}}function gUe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.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(Ci(n,e))return;t.uniform3fv(this.addr,e),ki(n,e)}}function xUe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||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(Ci(n,e))return;t.uniform4fv(this.addr,e),ki(n,e)}}function bUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ci(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),ki(n,e)}else{if(Ci(n,r))return;S7.set(r),t.uniformMatrix2fv(this.addr,!1,S7),ki(n,r)}}function yUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ci(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),ki(n,e)}else{if(Ci(n,r))return;w7.set(r),t.uniformMatrix3fv(this.addr,!1,w7),ki(n,r)}}function vUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ci(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),ki(n,e)}else{if(Ci(n,r))return;_7.set(r),t.uniformMatrix4fv(this.addr,!1,_7),ki(n,r)}}function _Ue(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function wUe(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(Ci(n,e))return;t.uniform2iv(this.addr,e),ki(n,e)}}function SUe(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(Ci(n,e))return;t.uniform3iv(this.addr,e),ki(n,e)}}function MUe(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(Ci(n,e))return;t.uniform4iv(this.addr,e),ki(n,e)}}function NUe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function EUe(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(Ci(n,e))return;t.uniform2uiv(this.addr,e),ki(n,e)}}function AUe(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(Ci(n,e))return;t.uniform3uiv(this.addr,e),ki(n,e)}}function TUe(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(Ci(n,e))return;t.uniform4uiv(this.addr,e),ki(n,e)}}function CUe(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?UJ:FJ;n.setTexture2D(e||a,i)}function kUe(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 jUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||$J,i)}function PUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||zJ,i)}function RUe(t){switch(t){case 5126:return mUe;case 35664:return pUe;case 35665:return gUe;case 35666:return xUe;case 35674:return bUe;case 35675:return yUe;case 35676:return vUe;case 5124:case 35670:return _Ue;case 35667:case 35671:return wUe;case 35668:case 35672:return SUe;case 35669:case 35673:return MUe;case 5125:return NUe;case 36294:return EUe;case 36295:return AUe;case 36296:return TUe;case 35678:case 36198:case 36298:case 36306:case 35682:return CUe;case 35679:case 36299:case 36307:return kUe;case 35680:case 36300:case 36308:case 36293:return jUe;case 36289:case 36303:case 36311:case 36292:return PUe}}function DUe(t,e){t.uniform1fv(this.addr,e)}function OUe(t,e){const n=Kg(e,this.size,2);t.uniform2fv(this.addr,n)}function LUe(t,e){const n=Kg(e,this.size,3);t.uniform3fv(this.addr,n)}function IUe(t,e){const n=Kg(e,this.size,4);t.uniform4fv(this.addr,n)}function FUe(t,e){const n=Kg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function UUe(t,e){const n=Kg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function zUe(t,e){const n=Kg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function BUe(t,e){t.uniform1iv(this.addr,e)}function $Ue(t,e){t.uniform2iv(this.addr,e)}function HUe(t,e){t.uniform3iv(this.addr,e)}function VUe(t,e){t.uniform4iv(this.addr,e)}function GUe(t,e){t.uniform1uiv(this.addr,e)}function WUe(t,e){t.uniform2uiv(this.addr,e)}function qUe(t,e){t.uniform3uiv(this.addr,e)}function KUe(t,e){t.uniform4uiv(this.addr,e)}function XUe(t,e,n){const r=this.cache,i=e.length,a=$M(n,i);Ci(r,a)||(t.uniform1iv(this.addr,a),ki(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||FJ,a[o])}function YUe(t,e,n){const r=this.cache,i=e.length,a=$M(n,i);Ci(r,a)||(t.uniform1iv(this.addr,a),ki(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||BJ,a[o])}function QUe(t,e,n){const r=this.cache,i=e.length,a=$M(n,i);Ci(r,a)||(t.uniform1iv(this.addr,a),ki(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||$J,a[o])}function ZUe(t,e,n){const r=this.cache,i=e.length,a=$M(n,i);Ci(r,a)||(t.uniform1iv(this.addr,a),ki(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||zJ,a[o])}function JUe(t){switch(t){case 5126:return DUe;case 35664:return OUe;case 35665:return LUe;case 35666:return IUe;case 35674:return FUe;case 35675:return UUe;case 35676:return zUe;case 5124:case 35670:return BUe;case 35667:case 35671:return $Ue;case 35668:case 35672:return HUe;case 35669:case 35673:return VUe;case 5125:return GUe;case 36294:return WUe;case 36295:return qUe;case 36296:return KUe;case 35678:case 36198:case 36298:case 36306:case 35682:return XUe;case 35679:case 36299:case 36307:return YUe;case 35680:case 36300:case 36308:case 36293:return QUe;case 36289:case 36303:case 36311:case 36292:return ZUe}}class eze{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=RUe(n.type)}}class tze{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=JUe(n.type)}}class nze{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 Mk=/(\w+)(\])?(\[|\.)?/g;function M7(t,e){t.seq.push(e),t.map[e.id]=e}function rze(t,e,n){const r=t.name,i=r.length;for(Mk.lastIndex=0;;){const a=Mk.exec(r),o=Mk.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){M7(n,u===void 0?new eze(l,t,e):new tze(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new nze(l),M7(n,f)),n=f}}}class Y1{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);rze(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 N7(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const ize=37297;let aze=0;function sze(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let o=i;o<a;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
- `)}function oze(t){const e=lr.getPrimaries(lr.workingColorSpace),n=lr.getPrimaries(t);let r;switch(e===n?r="":e===wS&&n===_S?r="LinearDisplayP3ToLinearSRGB":e===_S&&n===wS&&(r="LinearSRGBToLinearDisplayP3"),t){case cu:case zM:return[r,"LinearTransferOETF"];case fa:case CO:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function E7(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const a=/ERROR: 0:(\d+)/.exec(i);if(a){const o=parseInt(a[1]);return n.toUpperCase()+`
- `+i+`
- `+sze(t.getShaderSource(e),o)}else return i}function lze(t,e){const n=oze(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function cze(t,e){let n;switch(e){case lLe:n="Linear";break;case cLe:n="Reinhard";break;case uLe:n="OptimizedCineon";break;case dLe:n="ACESFilmic";break;case hLe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function uze(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(wb).join(`
- `)}function dze(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function hze(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 wb(t){return t!==""}function A7(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 T7(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const fze=/^[ \t]*#include +<([\w\d./]+)>/gm;function KP(t){return t.replace(fze,pze)}const mze=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function pze(t,e){let n=yn[e];if(n===void 0){const r=mze.get(e);if(r!==void 0)n=yn[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 KP(n)}const gze=/#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 C7(t){return t.replace(gze,xze)}function xze(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 k7(t){let e="precision "+t.precision+` float;
- precision `+t.precision+" int;";return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function bze(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===dJ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===LOe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Cc&&(e="SHADOWMAP_TYPE_VSM"),e}function yze(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case mg:case pg:e="ENVMAP_TYPE_CUBE";break;case UM:e="ENVMAP_TYPE_CUBE_UV";break}return e}function vze(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case pg:e="ENVMAP_MODE_REFRACTION";break}return e}function _ze(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case AO:e="ENVMAP_BLENDING_MULTIPLY";break;case sLe:e="ENVMAP_BLENDING_MIX";break;case oLe:e="ENVMAP_BLENDING_ADD";break}return e}function wze(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 Sze(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=bze(n),u=yze(n),d=vze(n),f=_ze(n),m=wze(n),g=n.isWebGL2?"":uze(n),x=dze(a),y=i.createProgram();let b,v,M=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(wb).join(`
- `),b.length>0&&(b+=`
- `),v=[g,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(wb).join(`
- `),v.length>0&&(v+=`
- `)):(b=[k7(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(wb).join(`
- `),v=[g,k7(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!==Td?"#define TONE_MAPPING":"",n.toneMapping!==Td?yn.tonemapping_pars_fragment:"",n.toneMapping!==Td?cze("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",yn.colorspace_pars_fragment,lze("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(wb).join(`
- `)),o=KP(o),o=A7(o,n),o=T7(o,n),l=KP(l),l=A7(l,n),l=T7(l,n),o=C7(o),l=C7(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(M=`#version 300 es
- `,b=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+b,v=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===KV?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===KV?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
- `)+`
- `+v);const S=M+b+o,A=M+v+l,E=N7(i,i.VERTEX_SHADER,S),k=N7(i,i.FRAGMENT_SHADER,A);i.attachShader(y,E),i.attachShader(y,k),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function C(F){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(y).trim(),X=i.getShaderInfoLog(E).trim(),D=i.getShaderInfoLog(k).trim();let K=!0,Y=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(K=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,E,k);else{const q=E7(i,E,"vertex"),Z=E7(i,k,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Program Info Log: `+L+`
- `+q+`
- `+Z)}else L!==""?console.warn("THREE.WebGLProgram: Program Info Log:",L):(X===""||D==="")&&(Y=!1);Y&&(F.diagnostics={runnable:K,programLog:L,vertexShader:{log:X,prefix:b},fragmentShader:{log:D,prefix:v}})}i.deleteShader(E),i.deleteShader(k),R=new Y1(i,y),T=hze(i,y)}let R;this.getUniforms=function(){return R===void 0&&C(this),R};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let P=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=i.getProgramParameter(y,ize)),P},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=aze++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=E,this.fragmentShader=k,this}let Mze=0;class Nze{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 Eze(e),n.set(e,r)),r}}class Eze{constructor(e){this.id=Mze++,this.code=e,this.usedTimes=0}}function Aze(t,e,n,r,i,a,o){const l=new TJ,c=new Nze,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,m=i.vertexTextures;let g=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(T){return T===0?"uv":`uv${T}`}function b(T,P,F,L,X){const D=L.fog,K=X.geometry,Y=T.isMeshStandardMaterial?L.environment:null,q=(T.isMeshStandardMaterial?n:e).get(T.envMap||Y),Z=q&&q.mapping===UM?q.image.height:null,re=x[T.type];T.precision!==null&&(g=i.getMaxPrecision(T.precision),g!==T.precision&&console.warn("THREE.WebGLProgram.getParameters:",T.precision,"not supported, using",g,"instead."));const oe=K.morphAttributes.position||K.morphAttributes.normal||K.morphAttributes.color,B=oe!==void 0?oe.length:0;let G=0;K.morphAttributes.position!==void 0&&(G=1),K.morphAttributes.normal!==void 0&&(G=2),K.morphAttributes.color!==void 0&&(G=3);let J,te,ae,de;if(re){const Zt=cs[re];J=Zt.vertexShader,te=Zt.fragmentShader}else J=T.vertexShader,te=T.fragmentShader,c.update(T),ae=c.getVertexShaderID(T),de=c.getFragmentShaderID(T);const fe=t.getRenderTarget(),Ae=X.isInstancedMesh===!0,ge=X.isBatchedMesh===!0,Me=!!T.map,je=!!T.matcap,ne=!!q,Ke=!!T.aoMap,$=!!T.lightMap,z=!!T.bumpMap,W=!!T.normalMap,U=!!T.displacementMap,V=!!T.emissiveMap,Q=!!T.metalnessMap,Ee=!!T.roughnessMap,Ce=T.anisotropy>0,Ne=T.clearcoat>0,H=T.iridescence>0,O=T.sheen>0,ie=T.transmission>0,ye=Ce&&!!T.anisotropyMap,_e=Ne&&!!T.clearcoatMap,le=Ne&&!!T.clearcoatNormalMap,ke=Ne&&!!T.clearcoatRoughnessMap,Oe=H&&!!T.iridescenceMap,Ze=H&&!!T.iridescenceThicknessMap,ht=O&&!!T.sheenColorMap,We=O&&!!T.sheenRoughnessMap,he=!!T.specularMap,rt=!!T.specularColorMap,qe=!!T.specularIntensityMap,Je=ie&&!!T.transmissionMap,ot=ie&&!!T.thicknessMap,se=!!T.gradientMap,$e=!!T.alphaMap,be=T.alphaTest>0,Fe=!!T.alphaHash,De=!!T.extensions,ve=!!K.attributes.uv1,He=!!K.attributes.uv2,dt=!!K.attributes.uv3;let kt=Td;return T.toneMapped&&(fe===null||fe.isXRRenderTarget===!0)&&(kt=t.toneMapping),{isWebGL2:d,shaderID:re,shaderType:T.type,shaderName:T.name,vertexShader:J,fragmentShader:te,defines:T.defines,customVertexShaderID:ae,customFragmentShaderID:de,isRawShaderMaterial:T.isRawShaderMaterial===!0,glslVersion:T.glslVersion,precision:g,batching:ge,instancing:Ae,instancingColor:Ae&&X.instanceColor!==null,supportsVertexTextures:m,outputColorSpace:fe===null?t.outputColorSpace:fe.isXRRenderTarget===!0?fe.texture.colorSpace:cu,map:Me,matcap:je,envMap:ne,envMapMode:ne&&q.mapping,envMapCubeUVHeight:Z,aoMap:Ke,lightMap:$,bumpMap:z,normalMap:W,displacementMap:m&&U,emissiveMap:V,normalMapObjectSpace:W&&T.normalMapType===MLe,normalMapTangentSpace:W&&T.normalMapType===_J,metalnessMap:Q,roughnessMap:Ee,anisotropy:Ce,anisotropyMap:ye,clearcoat:Ne,clearcoatMap:_e,clearcoatNormalMap:le,clearcoatRoughnessMap:ke,iridescence:H,iridescenceMap:Oe,iridescenceThicknessMap:Ze,sheen:O,sheenColorMap:ht,sheenRoughnessMap:We,specularMap:he,specularColorMap:rt,specularIntensityMap:qe,transmission:ie,transmissionMap:Je,thicknessMap:ot,gradientMap:se,opaque:T.transparent===!1&&T.blending===$p,alphaMap:$e,alphaTest:be,alphaHash:Fe,combine:T.combine,mapUv:Me&&y(T.map.channel),aoMapUv:Ke&&y(T.aoMap.channel),lightMapUv:$&&y(T.lightMap.channel),bumpMapUv:z&&y(T.bumpMap.channel),normalMapUv:W&&y(T.normalMap.channel),displacementMapUv:U&&y(T.displacementMap.channel),emissiveMapUv:V&&y(T.emissiveMap.channel),metalnessMapUv:Q&&y(T.metalnessMap.channel),roughnessMapUv:Ee&&y(T.roughnessMap.channel),anisotropyMapUv:ye&&y(T.anisotropyMap.channel),clearcoatMapUv:_e&&y(T.clearcoatMap.channel),clearcoatNormalMapUv:le&&y(T.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ke&&y(T.clearcoatRoughnessMap.channel),iridescenceMapUv:Oe&&y(T.iridescenceMap.channel),iridescenceThicknessMapUv:Ze&&y(T.iridescenceThicknessMap.channel),sheenColorMapUv:ht&&y(T.sheenColorMap.channel),sheenRoughnessMapUv:We&&y(T.sheenRoughnessMap.channel),specularMapUv:he&&y(T.specularMap.channel),specularColorMapUv:rt&&y(T.specularColorMap.channel),specularIntensityMapUv:qe&&y(T.specularIntensityMap.channel),transmissionMapUv:Je&&y(T.transmissionMap.channel),thicknessMapUv:ot&&y(T.thicknessMap.channel),alphaMapUv:$e&&y(T.alphaMap.channel),vertexTangents:!!K.attributes.tangent&&(W||Ce),vertexColors:T.vertexColors,vertexAlphas:T.vertexColors===!0&&!!K.attributes.color&&K.attributes.color.itemSize===4,vertexUv1s:ve,vertexUv2s:He,vertexUv3s:dt,pointsUvs:X.isPoints===!0&&!!K.attributes.uv&&(Me||$e),fog:!!D,useFog:T.fog===!0,fogExp2:D&&D.isFogExp2,flatShading:T.flatShading===!0,sizeAttenuation:T.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:X.isSkinnedMesh===!0,morphTargets:K.morphAttributes.position!==void 0,morphNormals:K.morphAttributes.normal!==void 0,morphColors:K.morphAttributes.color!==void 0,morphTargetsCount:B,morphTextureStride:G,numDirLights:P.directional.length,numPointLights:P.point.length,numSpotLights:P.spot.length,numSpotLightMaps:P.spotLightMap.length,numRectAreaLights:P.rectArea.length,numHemiLights:P.hemi.length,numDirLightShadows:P.directionalShadowMap.length,numPointLightShadows:P.pointShadowMap.length,numSpotLightShadows:P.spotShadowMap.length,numSpotLightShadowsWithMaps:P.numSpotLightShadowsWithMaps,numLightProbes:P.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:T.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:kt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:Me&&T.map.isVideoTexture===!0&&lr.getTransfer(T.map.colorSpace)===Mr,premultipliedAlpha:T.premultipliedAlpha,doubleSided:T.side===Lc,flipSided:T.side===ms,useDepthPacking:T.depthPacking>=0,depthPacking:T.depthPacking||0,index0AttributeName:T.index0AttributeName,extensionDerivatives:De&&T.extensions.derivatives===!0,extensionFragDepth:De&&T.extensions.fragDepth===!0,extensionDrawBuffers:De&&T.extensions.drawBuffers===!0,extensionShaderTextureLOD:De&&T.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:T.customProgramCacheKey()}}function v(T){const P=[];if(T.shaderID?P.push(T.shaderID):(P.push(T.customVertexShaderID),P.push(T.customFragmentShaderID)),T.defines!==void 0)for(const F in T.defines)P.push(F),P.push(T.defines[F]);return T.isRawShaderMaterial===!1&&(M(P,T),S(P,T),P.push(t.outputColorSpace)),P.push(T.customProgramCacheKey),P.join()}function M(T,P){T.push(P.precision),T.push(P.outputColorSpace),T.push(P.envMapMode),T.push(P.envMapCubeUVHeight),T.push(P.mapUv),T.push(P.alphaMapUv),T.push(P.lightMapUv),T.push(P.aoMapUv),T.push(P.bumpMapUv),T.push(P.normalMapUv),T.push(P.displacementMapUv),T.push(P.emissiveMapUv),T.push(P.metalnessMapUv),T.push(P.roughnessMapUv),T.push(P.anisotropyMapUv),T.push(P.clearcoatMapUv),T.push(P.clearcoatNormalMapUv),T.push(P.clearcoatRoughnessMapUv),T.push(P.iridescenceMapUv),T.push(P.iridescenceThicknessMapUv),T.push(P.sheenColorMapUv),T.push(P.sheenRoughnessMapUv),T.push(P.specularMapUv),T.push(P.specularColorMapUv),T.push(P.specularIntensityMapUv),T.push(P.transmissionMapUv),T.push(P.thicknessMapUv),T.push(P.combine),T.push(P.fogExp2),T.push(P.sizeAttenuation),T.push(P.morphTargetsCount),T.push(P.morphAttributeCount),T.push(P.numDirLights),T.push(P.numPointLights),T.push(P.numSpotLights),T.push(P.numSpotLightMaps),T.push(P.numHemiLights),T.push(P.numRectAreaLights),T.push(P.numDirLightShadows),T.push(P.numPointLightShadows),T.push(P.numSpotLightShadows),T.push(P.numSpotLightShadowsWithMaps),T.push(P.numLightProbes),T.push(P.shadowMapType),T.push(P.toneMapping),T.push(P.numClippingPlanes),T.push(P.numClipIntersection),T.push(P.depthPacking)}function S(T,P){l.disableAll(),P.isWebGL2&&l.enable(0),P.supportsVertexTextures&&l.enable(1),P.instancing&&l.enable(2),P.instancingColor&&l.enable(3),P.matcap&&l.enable(4),P.envMap&&l.enable(5),P.normalMapObjectSpace&&l.enable(6),P.normalMapTangentSpace&&l.enable(7),P.clearcoat&&l.enable(8),P.iridescence&&l.enable(9),P.alphaTest&&l.enable(10),P.vertexColors&&l.enable(11),P.vertexAlphas&&l.enable(12),P.vertexUv1s&&l.enable(13),P.vertexUv2s&&l.enable(14),P.vertexUv3s&&l.enable(15),P.vertexTangents&&l.enable(16),P.anisotropy&&l.enable(17),P.alphaHash&&l.enable(18),P.batching&&l.enable(19),T.push(l.mask),l.disableAll(),P.fog&&l.enable(0),P.useFog&&l.enable(1),P.flatShading&&l.enable(2),P.logarithmicDepthBuffer&&l.enable(3),P.skinning&&l.enable(4),P.morphTargets&&l.enable(5),P.morphNormals&&l.enable(6),P.morphColors&&l.enable(7),P.premultipliedAlpha&&l.enable(8),P.shadowMapEnabled&&l.enable(9),P.useLegacyLights&&l.enable(10),P.doubleSided&&l.enable(11),P.flipSided&&l.enable(12),P.useDepthPacking&&l.enable(13),P.dithering&&l.enable(14),P.transmission&&l.enable(15),P.sheen&&l.enable(16),P.opaque&&l.enable(17),P.pointsUvs&&l.enable(18),P.decodeVideoTexture&&l.enable(19),T.push(l.mask)}function A(T){const P=x[T.type];let F;if(P){const L=cs[P];F=PO.clone(L.uniforms)}else F=T.uniforms;return F}function E(T,P){let F;for(let L=0,X=u.length;L<X;L++){const D=u[L];if(D.cacheKey===P){F=D,++F.usedTimes;break}}return F===void 0&&(F=new Sze(t,P,T,a),u.push(F)),F}function k(T){if(--T.usedTimes===0){const P=u.indexOf(T);u[P]=u[u.length-1],u.pop(),T.destroy()}}function C(T){c.remove(T)}function R(){c.dispose()}return{getParameters:b,getProgramCacheKey:v,getUniforms:A,acquireProgram:E,releaseProgram:k,releaseShaderCache:C,programs:u,dispose:R}}function Tze(){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 Cze(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 j7(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 P7(){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,g,x,y,b){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:m,material:g,groupOrder:x,renderOrder:f.renderOrder,z:y,group:b},t[e]=v):(v.id=f.id,v.object=f,v.geometry=m,v.material=g,v.groupOrder=x,v.renderOrder=f.renderOrder,v.z=y,v.group=b),e++,v}function l(f,m,g,x,y,b){const v=o(f,m,g,x,y,b);g.transmission>0?r.push(v):g.transparent===!0?i.push(v):n.push(v)}function c(f,m,g,x,y,b){const v=o(f,m,g,x,y,b);g.transmission>0?r.unshift(v):g.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,m){n.length>1&&n.sort(f||Cze),r.length>1&&r.sort(m||j7),i.length>1&&i.sort(m||j7)}function d(){for(let f=e,m=t.length;f<m;f++){const g=t[f];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function kze(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new P7,t.set(r,[o])):i>=a.length?(o=new P7,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function jze(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new ze,color:new Qt};break;case"SpotLight":n={position:new ze,direction:new ze,color:new Qt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new ze,color:new Qt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new ze,skyColor:new Qt,groundColor:new Qt};break;case"RectAreaLight":n={color:new Qt,position:new ze,halfWidth:new ze,halfHeight:new ze};break}return t[e.id]=n,n}}}function Pze(){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 cn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new cn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new cn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let Rze=0;function Dze(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Oze(t,e){const n=new jze,r=Pze(),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 ze);const a=new ze,o=new vr,l=new vr;function c(d,f){let m=0,g=0,x=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let y=0,b=0,v=0,M=0,S=0,A=0,E=0,k=0,C=0,R=0,T=0;d.sort(Dze);const P=f===!0?Math.PI:1;for(let L=0,X=d.length;L<X;L++){const D=d[L],K=D.color,Y=D.intensity,q=D.distance,Z=D.shadow&&D.shadow.map?D.shadow.map.texture:null;if(D.isAmbientLight)m+=K.r*Y*P,g+=K.g*Y*P,x+=K.b*Y*P;else if(D.isLightProbe){for(let re=0;re<9;re++)i.probe[re].addScaledVector(D.sh.coefficients[re],Y);T++}else if(D.isDirectionalLight){const re=n.get(D);if(re.color.copy(D.color).multiplyScalar(D.intensity*P),D.castShadow){const oe=D.shadow,B=r.get(D);B.shadowBias=oe.bias,B.shadowNormalBias=oe.normalBias,B.shadowRadius=oe.radius,B.shadowMapSize=oe.mapSize,i.directionalShadow[y]=B,i.directionalShadowMap[y]=Z,i.directionalShadowMatrix[y]=D.shadow.matrix,A++}i.directional[y]=re,y++}else if(D.isSpotLight){const re=n.get(D);re.position.setFromMatrixPosition(D.matrixWorld),re.color.copy(K).multiplyScalar(Y*P),re.distance=q,re.coneCos=Math.cos(D.angle),re.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),re.decay=D.decay,i.spot[v]=re;const oe=D.shadow;if(D.map&&(i.spotLightMap[C]=D.map,C++,oe.updateMatrices(D),D.castShadow&&R++),i.spotLightMatrix[v]=oe.matrix,D.castShadow){const B=r.get(D);B.shadowBias=oe.bias,B.shadowNormalBias=oe.normalBias,B.shadowRadius=oe.radius,B.shadowMapSize=oe.mapSize,i.spotShadow[v]=B,i.spotShadowMap[v]=Z,k++}v++}else if(D.isRectAreaLight){const re=n.get(D);re.color.copy(K).multiplyScalar(Y),re.halfWidth.set(D.width*.5,0,0),re.halfHeight.set(0,D.height*.5,0),i.rectArea[M]=re,M++}else if(D.isPointLight){const re=n.get(D);if(re.color.copy(D.color).multiplyScalar(D.intensity*P),re.distance=D.distance,re.decay=D.decay,D.castShadow){const oe=D.shadow,B=r.get(D);B.shadowBias=oe.bias,B.shadowNormalBias=oe.normalBias,B.shadowRadius=oe.radius,B.shadowMapSize=oe.mapSize,B.shadowCameraNear=oe.camera.near,B.shadowCameraFar=oe.camera.far,i.pointShadow[b]=B,i.pointShadowMap[b]=Z,i.pointShadowMatrix[b]=D.shadow.matrix,E++}i.point[b]=re,b++}else if(D.isHemisphereLight){const re=n.get(D);re.skyColor.copy(D.color).multiplyScalar(Y*P),re.groundColor.copy(D.groundColor).multiplyScalar(Y*P),i.hemi[S]=re,S++}}M>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Pt.LTC_FLOAT_1,i.rectAreaLTC2=Pt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Pt.LTC_HALF_1,i.rectAreaLTC2=Pt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=m,i.ambient[1]=g,i.ambient[2]=x;const F=i.hash;(F.directionalLength!==y||F.pointLength!==b||F.spotLength!==v||F.rectAreaLength!==M||F.hemiLength!==S||F.numDirectionalShadows!==A||F.numPointShadows!==E||F.numSpotShadows!==k||F.numSpotMaps!==C||F.numLightProbes!==T)&&(i.directional.length=y,i.spot.length=v,i.rectArea.length=M,i.point.length=b,i.hemi.length=S,i.directionalShadow.length=A,i.directionalShadowMap.length=A,i.pointShadow.length=E,i.pointShadowMap.length=E,i.spotShadow.length=k,i.spotShadowMap.length=k,i.directionalShadowMatrix.length=A,i.pointShadowMatrix.length=E,i.spotLightMatrix.length=k+C-R,i.spotLightMap.length=C,i.numSpotLightShadowsWithMaps=R,i.numLightProbes=T,F.directionalLength=y,F.pointLength=b,F.spotLength=v,F.rectAreaLength=M,F.hemiLength=S,F.numDirectionalShadows=A,F.numPointShadows=E,F.numSpotShadows=k,F.numSpotMaps=C,F.numLightProbes=T,i.version=Rze++)}function u(d,f){let m=0,g=0,x=0,y=0,b=0;const v=f.matrixWorldInverse;for(let M=0,S=d.length;M<S;M++){const A=d[M];if(A.isDirectionalLight){const E=i.directional[m];E.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),E.direction.sub(a),E.direction.transformDirection(v),m++}else if(A.isSpotLight){const E=i.spot[x];E.position.setFromMatrixPosition(A.matrixWorld),E.position.applyMatrix4(v),E.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),E.direction.sub(a),E.direction.transformDirection(v),x++}else if(A.isRectAreaLight){const E=i.rectArea[y];E.position.setFromMatrixPosition(A.matrixWorld),E.position.applyMatrix4(v),l.identity(),o.copy(A.matrixWorld),o.premultiply(v),l.extractRotation(o),E.halfWidth.set(A.width*.5,0,0),E.halfHeight.set(0,A.height*.5,0),E.halfWidth.applyMatrix4(l),E.halfHeight.applyMatrix4(l),y++}else if(A.isPointLight){const E=i.point[g];E.position.setFromMatrixPosition(A.matrixWorld),E.position.applyMatrix4(v),g++}else if(A.isHemisphereLight){const E=i.hemi[b];E.direction.setFromMatrixPosition(A.matrixWorld),E.direction.transformDirection(v),b++}}}return{setup:c,setupView:u,state:i}}function R7(t,e){const n=new Oze(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 Lze(t,e){let n=new WeakMap;function r(a,o=0){const l=n.get(a);let c;return l===void 0?(c=new R7(t,e),n.set(a,[c])):o>=l.length?(c=new R7(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class Ize extends qg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=wLe,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 Fze extends qg{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 Uze=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,zze=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function Bze(t,e,n){let r=new BM;const i=new cn,a=new cn,o=new ur,l=new Ize({depthPacking:SLe}),c=new Fze,u={},d=n.maxTextureSize,f={[Hd]:ms,[ms]:Hd,[Lc]:Lc},m=new Vd({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new cn},radius:{value:4}},vertexShader:Uze,fragmentShader:zze}),g=m.clone();g.defines.HORIZONTAL_PASS=1;const x=new Ra;x.setAttribute("position",new $s(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Xo(x,m),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=dJ;let v=this.type;this.render=function(E,k,C){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||E.length===0)return;const R=t.getRenderTarget(),T=t.getActiveCubeFace(),P=t.getActiveMipmapLevel(),F=t.state;F.setBlending(Ad),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const L=v!==Cc&&this.type===Cc,X=v===Cc&&this.type!==Cc;for(let D=0,K=E.length;D<K;D++){const Y=E[D],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 Z=q.getFrameExtents();if(i.multiply(Z),a.copy(q.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Z.x),i.x=a.x*Z.x,q.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Z.y),i.y=a.y*Z.y,q.mapSize.y=a.y)),q.map===null||L===!0||X===!0){const oe=this.type!==Cc?{minFilter:ha,magFilter:ha}:{};q.map!==null&&q.map.dispose(),q.map=new Lf(i.x,i.y,oe),q.map.texture.name=Y.name+".shadowMap",q.camera.updateProjectionMatrix()}t.setRenderTarget(q.map),t.clear();const re=q.getViewportCount();for(let oe=0;oe<re;oe++){const B=q.getViewport(oe);o.set(a.x*B.x,a.y*B.y,a.x*B.z,a.y*B.w),F.viewport(o),q.updateMatrices(Y,oe),r=q.getFrustum(),A(k,C,q.camera,Y,this.type)}q.isPointLightShadow!==!0&&this.type===Cc&&M(q,C),q.needsUpdate=!1}v=this.type,b.needsUpdate=!1,t.setRenderTarget(R,T,P)};function M(E,k){const C=e.update(y);m.defines.VSM_SAMPLES!==E.blurSamples&&(m.defines.VSM_SAMPLES=E.blurSamples,g.defines.VSM_SAMPLES=E.blurSamples,m.needsUpdate=!0,g.needsUpdate=!0),E.mapPass===null&&(E.mapPass=new Lf(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(k,null,C,m,y,null),g.uniforms.shadow_pass.value=E.mapPass.texture,g.uniforms.resolution.value=E.mapSize,g.uniforms.radius.value=E.radius,t.setRenderTarget(E.map),t.clear(),t.renderBufferDirect(k,null,C,g,y,null)}function S(E,k,C,R){let T=null;const P=C.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(P!==void 0)T=P;else if(T=C.isPointLight===!0?c:l,t.localClippingEnabled&&k.clipShadows===!0&&Array.isArray(k.clippingPlanes)&&k.clippingPlanes.length!==0||k.displacementMap&&k.displacementScale!==0||k.alphaMap&&k.alphaTest>0||k.map&&k.alphaTest>0){const F=T.uuid,L=k.uuid;let X=u[F];X===void 0&&(X={},u[F]=X);let D=X[L];D===void 0&&(D=T.clone(),X[L]=D),T=D}if(T.visible=k.visible,T.wireframe=k.wireframe,R===Cc?T.side=k.shadowSide!==null?k.shadowSide:k.side:T.side=k.shadowSide!==null?k.shadowSide:f[k.side],T.alphaMap=k.alphaMap,T.alphaTest=k.alphaTest,T.map=k.map,T.clipShadows=k.clipShadows,T.clippingPlanes=k.clippingPlanes,T.clipIntersection=k.clipIntersection,T.displacementMap=k.displacementMap,T.displacementScale=k.displacementScale,T.displacementBias=k.displacementBias,T.wireframeLinewidth=k.wireframeLinewidth,T.linewidth=k.linewidth,C.isPointLight===!0&&T.isMeshDistanceMaterial===!0){const F=t.properties.get(T);F.light=C}return T}function A(E,k,C,R,T){if(E.visible===!1)return;if(E.layers.test(k.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&T===Cc)&&(!E.frustumCulled||r.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,E.matrixWorld);const L=e.update(E),X=E.material;if(Array.isArray(X)){const D=L.groups;for(let K=0,Y=D.length;K<Y;K++){const q=D[K],Z=X[q.materialIndex];if(Z&&Z.visible){const re=S(E,Z,R,T);E.onBeforeShadow(t,E,k,C,L,re,q),t.renderBufferDirect(C,null,L,re,E,q),E.onAfterShadow(t,E,k,C,L,re,q)}}}else if(X.visible){const D=S(E,X,R,T);E.onBeforeShadow(t,E,k,C,L,D,null),t.renderBufferDirect(C,null,L,D,E,null),E.onAfterShadow(t,E,k,C,L,D,null)}}const F=E.children;for(let L=0,X=F.length;L<X;L++)A(F[L],k,C,R,T)}}function $ze(t,e,n){const r=n.isWebGL2;function i(){let be=!1;const Fe=new ur;let De=null;const ve=new ur(0,0,0,0);return{setMask:function(He){De!==He&&!be&&(t.colorMask(He,He,He,He),De=He)},setLocked:function(He){be=He},setClear:function(He,dt,kt,jt,Zt){Zt===!0&&(He*=jt,dt*=jt,kt*=jt),Fe.set(He,dt,kt,jt),ve.equals(Fe)===!1&&(t.clearColor(He,dt,kt,jt),ve.copy(Fe))},reset:function(){be=!1,De=null,ve.set(-1,0,0,0)}}}function a(){let be=!1,Fe=null,De=null,ve=null;return{setTest:function(He){He?ge(t.DEPTH_TEST):Me(t.DEPTH_TEST)},setMask:function(He){Fe!==He&&!be&&(t.depthMask(He),Fe=He)},setFunc:function(He){if(De!==He){switch(He){case JOe:t.depthFunc(t.NEVER);break;case eLe:t.depthFunc(t.ALWAYS);break;case tLe:t.depthFunc(t.LESS);break;case yS:t.depthFunc(t.LEQUAL);break;case nLe:t.depthFunc(t.EQUAL);break;case rLe:t.depthFunc(t.GEQUAL);break;case iLe:t.depthFunc(t.GREATER);break;case aLe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}De=He}},setLocked:function(He){be=He},setClear:function(He){ve!==He&&(t.clearDepth(He),ve=He)},reset:function(){be=!1,Fe=null,De=null,ve=null}}}function o(){let be=!1,Fe=null,De=null,ve=null,He=null,dt=null,kt=null,jt=null,Zt=null;return{setTest:function(Rt){be||(Rt?ge(t.STENCIL_TEST):Me(t.STENCIL_TEST))},setMask:function(Rt){Fe!==Rt&&!be&&(t.stencilMask(Rt),Fe=Rt)},setFunc:function(Rt,nn,pt){(De!==Rt||ve!==nn||He!==pt)&&(t.stencilFunc(Rt,nn,pt),De=Rt,ve=nn,He=pt)},setOp:function(Rt,nn,pt){(dt!==Rt||kt!==nn||jt!==pt)&&(t.stencilOp(Rt,nn,pt),dt=Rt,kt=nn,jt=pt)},setLocked:function(Rt){be=Rt},setClear:function(Rt){Zt!==Rt&&(t.clearStencil(Rt),Zt=Rt)},reset:function(){be=!1,Fe=null,De=null,ve=null,He=null,dt=null,kt=null,jt=null,Zt=null}}}const l=new i,c=new a,u=new o,d=new WeakMap,f=new WeakMap;let m={},g={},x=new WeakMap,y=[],b=null,v=!1,M=null,S=null,A=null,E=null,k=null,C=null,R=null,T=new Qt(0,0,0),P=0,F=!1,L=null,X=null,D=null,K=null,Y=null;const q=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Z=!1,re=0;const oe=t.getParameter(t.VERSION);oe.indexOf("WebGL")!==-1?(re=parseFloat(/^WebGL (\d)/.exec(oe)[1]),Z=re>=1):oe.indexOf("OpenGL ES")!==-1&&(re=parseFloat(/^OpenGL ES (\d)/.exec(oe)[1]),Z=re>=2);let B=null,G={};const J=t.getParameter(t.SCISSOR_BOX),te=t.getParameter(t.VIEWPORT),ae=new ur().fromArray(J),de=new ur().fromArray(te);function fe(be,Fe,De,ve){const He=new Uint8Array(4),dt=t.createTexture();t.bindTexture(be,dt),t.texParameteri(be,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(be,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let kt=0;kt<De;kt++)r&&(be===t.TEXTURE_3D||be===t.TEXTURE_2D_ARRAY)?t.texImage3D(Fe,0,t.RGBA,1,1,ve,0,t.RGBA,t.UNSIGNED_BYTE,He):t.texImage2D(Fe+kt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,He);return dt}const Ae={};Ae[t.TEXTURE_2D]=fe(t.TEXTURE_2D,t.TEXTURE_2D,1),Ae[t.TEXTURE_CUBE_MAP]=fe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Ae[t.TEXTURE_2D_ARRAY]=fe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Ae[t.TEXTURE_3D]=fe(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),ge(t.DEPTH_TEST),c.setFunc(yS),V(!1),Q(pV),ge(t.CULL_FACE),W(Ad);function ge(be){m[be]!==!0&&(t.enable(be),m[be]=!0)}function Me(be){m[be]!==!1&&(t.disable(be),m[be]=!1)}function je(be,Fe){return g[be]!==Fe?(t.bindFramebuffer(be,Fe),g[be]=Fe,r&&(be===t.DRAW_FRAMEBUFFER&&(g[t.FRAMEBUFFER]=Fe),be===t.FRAMEBUFFER&&(g[t.DRAW_FRAMEBUFFER]=Fe)),!0):!1}function ne(be,Fe){let De=y,ve=!1;if(be)if(De=x.get(Fe),De===void 0&&(De=[],x.set(Fe,De)),be.isWebGLMultipleRenderTargets){const He=be.texture;if(De.length!==He.length||De[0]!==t.COLOR_ATTACHMENT0){for(let dt=0,kt=He.length;dt<kt;dt++)De[dt]=t.COLOR_ATTACHMENT0+dt;De.length=He.length,ve=!0}}else De[0]!==t.COLOR_ATTACHMENT0&&(De[0]=t.COLOR_ATTACHMENT0,ve=!0);else De[0]!==t.BACK&&(De[0]=t.BACK,ve=!0);ve&&(n.isWebGL2?t.drawBuffers(De):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(De))}function Ke(be){return b!==be?(t.useProgram(be),b=be,!0):!1}const $={[Uh]:t.FUNC_ADD,[FOe]:t.FUNC_SUBTRACT,[UOe]:t.FUNC_REVERSE_SUBTRACT};if(r)$[yV]=t.MIN,$[vV]=t.MAX;else{const be=e.get("EXT_blend_minmax");be!==null&&($[yV]=be.MIN_EXT,$[vV]=be.MAX_EXT)}const z={[zOe]:t.ZERO,[BOe]:t.ONE,[$Oe]:t.SRC_COLOR,[UP]:t.SRC_ALPHA,[KOe]:t.SRC_ALPHA_SATURATE,[WOe]:t.DST_COLOR,[VOe]:t.DST_ALPHA,[HOe]:t.ONE_MINUS_SRC_COLOR,[zP]:t.ONE_MINUS_SRC_ALPHA,[qOe]:t.ONE_MINUS_DST_COLOR,[GOe]:t.ONE_MINUS_DST_ALPHA,[XOe]:t.CONSTANT_COLOR,[YOe]:t.ONE_MINUS_CONSTANT_COLOR,[QOe]:t.CONSTANT_ALPHA,[ZOe]:t.ONE_MINUS_CONSTANT_ALPHA};function W(be,Fe,De,ve,He,dt,kt,jt,Zt,Rt){if(be===Ad){v===!0&&(Me(t.BLEND),v=!1);return}if(v===!1&&(ge(t.BLEND),v=!0),be!==IOe){if(be!==M||Rt!==F){if((S!==Uh||k!==Uh)&&(t.blendEquation(t.FUNC_ADD),S=Uh,k=Uh),Rt)switch(be){case $p:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case gV:t.blendFunc(t.ONE,t.ONE);break;case xV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case bV: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 $p:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case gV:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case xV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case bV:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",be);break}A=null,E=null,C=null,R=null,T.set(0,0,0),P=0,M=be,F=Rt}return}He=He||Fe,dt=dt||De,kt=kt||ve,(Fe!==S||He!==k)&&(t.blendEquationSeparate($[Fe],$[He]),S=Fe,k=He),(De!==A||ve!==E||dt!==C||kt!==R)&&(t.blendFuncSeparate(z[De],z[ve],z[dt],z[kt]),A=De,E=ve,C=dt,R=kt),(jt.equals(T)===!1||Zt!==P)&&(t.blendColor(jt.r,jt.g,jt.b,Zt),T.copy(jt),P=Zt),M=be,F=!1}function U(be,Fe){be.side===Lc?Me(t.CULL_FACE):ge(t.CULL_FACE);let De=be.side===ms;Fe&&(De=!De),V(De),be.blending===$p&&be.transparent===!1?W(Ad):W(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 ve=be.stencilWrite;u.setTest(ve),ve&&(u.setMask(be.stencilWriteMask),u.setFunc(be.stencilFunc,be.stencilRef,be.stencilFuncMask),u.setOp(be.stencilFail,be.stencilZFail,be.stencilZPass)),Ce(be.polygonOffset,be.polygonOffsetFactor,be.polygonOffsetUnits),be.alphaToCoverage===!0?ge(t.SAMPLE_ALPHA_TO_COVERAGE):Me(t.SAMPLE_ALPHA_TO_COVERAGE)}function V(be){L!==be&&(be?t.frontFace(t.CW):t.frontFace(t.CCW),L=be)}function Q(be){be!==DOe?(ge(t.CULL_FACE),be!==X&&(be===pV?t.cullFace(t.BACK):be===OOe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Me(t.CULL_FACE),X=be}function Ee(be){be!==D&&(Z&&t.lineWidth(be),D=be)}function Ce(be,Fe,De){be?(ge(t.POLYGON_OFFSET_FILL),(K!==Fe||Y!==De)&&(t.polygonOffset(Fe,De),K=Fe,Y=De)):Me(t.POLYGON_OFFSET_FILL)}function Ne(be){be?ge(t.SCISSOR_TEST):Me(t.SCISSOR_TEST)}function H(be){be===void 0&&(be=t.TEXTURE0+q-1),B!==be&&(t.activeTexture(be),B=be)}function O(be,Fe,De){De===void 0&&(B===null?De=t.TEXTURE0+q-1:De=B);let ve=G[De];ve===void 0&&(ve={type:void 0,texture:void 0},G[De]=ve),(ve.type!==be||ve.texture!==Fe)&&(B!==De&&(t.activeTexture(De),B=De),t.bindTexture(be,Fe||Ae[be]),ve.type=be,ve.texture=Fe)}function ie(){const be=G[B];be!==void 0&&be.type!==void 0&&(t.bindTexture(be.type,null),be.type=void 0,be.texture=void 0)}function ye(){try{t.compressedTexImage2D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function _e(){try{t.compressedTexImage3D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function le(){try{t.texSubImage2D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function ke(){try{t.texSubImage3D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function Oe(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function Ze(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function ht(){try{t.texStorage2D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function We(){try{t.texStorage3D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function he(){try{t.texImage2D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function rt(){try{t.texImage3D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function qe(be){ae.equals(be)===!1&&(t.scissor(be.x,be.y,be.z,be.w),ae.copy(be))}function Je(be){de.equals(be)===!1&&(t.viewport(be.x,be.y,be.z,be.w),de.copy(be))}function ot(be,Fe){let De=f.get(Fe);De===void 0&&(De=new WeakMap,f.set(Fe,De));let ve=De.get(be);ve===void 0&&(ve=t.getUniformBlockIndex(Fe,be.name),De.set(be,ve))}function se(be,Fe){const ve=f.get(Fe).get(be);d.get(Fe)!==ve&&(t.uniformBlockBinding(Fe,ve,be.__bindingPointIndex),d.set(Fe,ve))}function $e(){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={},B=null,G={},g={},x=new WeakMap,y=[],b=null,v=!1,M=null,S=null,A=null,E=null,k=null,C=null,R=null,T=new Qt(0,0,0),P=0,F=!1,L=null,X=null,D=null,K=null,Y=null,ae.set(0,0,t.canvas.width,t.canvas.height),de.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:ge,disable:Me,bindFramebuffer:je,drawBuffers:ne,useProgram:Ke,setBlending:W,setMaterial:U,setFlipSided:V,setCullFace:Q,setLineWidth:Ee,setPolygonOffset:Ce,setScissorTest:Ne,activeTexture:H,bindTexture:O,unbindTexture:ie,compressedTexImage2D:ye,compressedTexImage3D:_e,texImage2D:he,texImage3D:rt,updateUBOMapping:ot,uniformBlockBinding:se,texStorage2D:ht,texStorage3D:We,texSubImage2D:le,texSubImage3D:ke,compressedTexSubImage2D:Oe,compressedTexSubImage3D:Ze,scissor:qe,viewport:Je,reset:$e}}function Hze(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,g=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 M(H,O){return v?new OffscreenCanvas(H,O):MS("canvas")}function S(H,O,ie,ye){let _e=1;if((H.width>ye||H.height>ye)&&(_e=ye/Math.max(H.width,H.height)),_e<1||O===!0)if(typeof HTMLImageElement<"u"&&H instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&H instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&H instanceof ImageBitmap){const le=O?SS:Math.floor,ke=le(_e*H.width),Oe=le(_e*H.height);y===void 0&&(y=M(ke,Oe));const Ze=ie?M(ke,Oe):y;return Ze.width=ke,Ze.height=Oe,Ze.getContext("2d").drawImage(H,0,0,ke,Oe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+H.width+"x"+H.height+") to ("+ke+"x"+Oe+")."),Ze}else return"data"in H&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+H.width+"x"+H.height+")."),H;return H}function A(H){return qP(H.width)&&qP(H.height)}function E(H){return l?!1:H.wrapS!==Wo||H.wrapT!==Wo||H.minFilter!==ha&&H.minFilter!==go}function k(H,O){return H.generateMipmaps&&O&&H.minFilter!==ha&&H.minFilter!==go}function C(H){t.generateMipmap(H)}function R(H,O,ie,ye,_e=!1){if(l===!1)return O;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 le=O;if(O===t.RED&&(ie===t.FLOAT&&(le=t.R32F),ie===t.HALF_FLOAT&&(le=t.R16F),ie===t.UNSIGNED_BYTE&&(le=t.R8)),O===t.RED_INTEGER&&(ie===t.UNSIGNED_BYTE&&(le=t.R8UI),ie===t.UNSIGNED_SHORT&&(le=t.R16UI),ie===t.UNSIGNED_INT&&(le=t.R32UI),ie===t.BYTE&&(le=t.R8I),ie===t.SHORT&&(le=t.R16I),ie===t.INT&&(le=t.R32I)),O===t.RG&&(ie===t.FLOAT&&(le=t.RG32F),ie===t.HALF_FLOAT&&(le=t.RG16F),ie===t.UNSIGNED_BYTE&&(le=t.RG8)),O===t.RGBA){const ke=_e?vS:lr.getTransfer(ye);ie===t.FLOAT&&(le=t.RGBA32F),ie===t.HALF_FLOAT&&(le=t.RGBA16F),ie===t.UNSIGNED_BYTE&&(le=ke===Mr?t.SRGB8_ALPHA8:t.RGBA8),ie===t.UNSIGNED_SHORT_4_4_4_4&&(le=t.RGBA4),ie===t.UNSIGNED_SHORT_5_5_5_1&&(le=t.RGB5_A1)}return(le===t.R16F||le===t.R32F||le===t.RG16F||le===t.RG32F||le===t.RGBA16F||le===t.RGBA32F)&&e.get("EXT_color_buffer_float"),le}function T(H,O,ie){return k(H,ie)===!0||H.isFramebufferTexture&&H.minFilter!==ha&&H.minFilter!==go?Math.log2(Math.max(O.width,O.height))+1:H.mipmaps!==void 0&&H.mipmaps.length>0?H.mipmaps.length:H.isCompressedTexture&&Array.isArray(H.image)?O.mipmaps.length:1}function P(H){return H===ha||H===_V||H===QC?t.NEAREST:t.LINEAR}function F(H){const O=H.target;O.removeEventListener("dispose",F),X(O),O.isVideoTexture&&x.delete(O)}function L(H){const O=H.target;O.removeEventListener("dispose",L),K(O)}function X(H){const O=r.get(H);if(O.__webglInit===void 0)return;const ie=H.source,ye=b.get(ie);if(ye){const _e=ye[O.__cacheKey];_e.usedTimes--,_e.usedTimes===0&&D(H),Object.keys(ye).length===0&&b.delete(ie)}r.remove(H)}function D(H){const O=r.get(H);t.deleteTexture(O.__webglTexture);const ie=H.source,ye=b.get(ie);delete ye[O.__cacheKey],o.memory.textures--}function K(H){const O=H.texture,ie=r.get(H),ye=r.get(O);if(ye.__webglTexture!==void 0&&(t.deleteTexture(ye.__webglTexture),o.memory.textures--),H.depthTexture&&H.depthTexture.dispose(),H.isWebGLCubeRenderTarget)for(let _e=0;_e<6;_e++){if(Array.isArray(ie.__webglFramebuffer[_e]))for(let le=0;le<ie.__webglFramebuffer[_e].length;le++)t.deleteFramebuffer(ie.__webglFramebuffer[_e][le]);else t.deleteFramebuffer(ie.__webglFramebuffer[_e]);ie.__webglDepthbuffer&&t.deleteRenderbuffer(ie.__webglDepthbuffer[_e])}else{if(Array.isArray(ie.__webglFramebuffer))for(let _e=0;_e<ie.__webglFramebuffer.length;_e++)t.deleteFramebuffer(ie.__webglFramebuffer[_e]);else t.deleteFramebuffer(ie.__webglFramebuffer);if(ie.__webglDepthbuffer&&t.deleteRenderbuffer(ie.__webglDepthbuffer),ie.__webglMultisampledFramebuffer&&t.deleteFramebuffer(ie.__webglMultisampledFramebuffer),ie.__webglColorRenderbuffer)for(let _e=0;_e<ie.__webglColorRenderbuffer.length;_e++)ie.__webglColorRenderbuffer[_e]&&t.deleteRenderbuffer(ie.__webglColorRenderbuffer[_e]);ie.__webglDepthRenderbuffer&&t.deleteRenderbuffer(ie.__webglDepthRenderbuffer)}if(H.isWebGLMultipleRenderTargets)for(let _e=0,le=O.length;_e<le;_e++){const ke=r.get(O[_e]);ke.__webglTexture&&(t.deleteTexture(ke.__webglTexture),o.memory.textures--),r.remove(O[_e])}r.remove(O),r.remove(H)}let Y=0;function q(){Y=0}function Z(){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 re(H){const O=[];return O.push(H.wrapS),O.push(H.wrapT),O.push(H.wrapR||0),O.push(H.magFilter),O.push(H.minFilter),O.push(H.anisotropy),O.push(H.internalFormat),O.push(H.format),O.push(H.type),O.push(H.generateMipmaps),O.push(H.premultiplyAlpha),O.push(H.flipY),O.push(H.unpackAlignment),O.push(H.colorSpace),O.join()}function oe(H,O){const ie=r.get(H);if(H.isVideoTexture&&Ce(H),H.isRenderTargetTexture===!1&&H.version>0&&ie.__version!==H.version){const ye=H.image;if(ye===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ye.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ge(ie,H,O);return}}n.bindTexture(t.TEXTURE_2D,ie.__webglTexture,t.TEXTURE0+O)}function B(H,O){const ie=r.get(H);if(H.version>0&&ie.__version!==H.version){ge(ie,H,O);return}n.bindTexture(t.TEXTURE_2D_ARRAY,ie.__webglTexture,t.TEXTURE0+O)}function G(H,O){const ie=r.get(H);if(H.version>0&&ie.__version!==H.version){ge(ie,H,O);return}n.bindTexture(t.TEXTURE_3D,ie.__webglTexture,t.TEXTURE0+O)}function J(H,O){const ie=r.get(H);if(H.version>0&&ie.__version!==H.version){Me(ie,H,O);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ie.__webglTexture,t.TEXTURE0+O)}const te={[HP]:t.REPEAT,[Wo]:t.CLAMP_TO_EDGE,[VP]:t.MIRRORED_REPEAT},ae={[ha]:t.NEAREST,[_V]:t.NEAREST_MIPMAP_NEAREST,[QC]:t.NEAREST_MIPMAP_LINEAR,[go]:t.LINEAR,[fLe]:t.LINEAR_MIPMAP_NEAREST,[T0]:t.LINEAR_MIPMAP_LINEAR},de={[NLe]:t.NEVER,[jLe]:t.ALWAYS,[ELe]:t.LESS,[wJ]:t.LEQUAL,[ALe]:t.EQUAL,[kLe]:t.GEQUAL,[TLe]:t.GREATER,[CLe]:t.NOTEQUAL};function fe(H,O,ie){if(ie?(t.texParameteri(H,t.TEXTURE_WRAP_S,te[O.wrapS]),t.texParameteri(H,t.TEXTURE_WRAP_T,te[O.wrapT]),(H===t.TEXTURE_3D||H===t.TEXTURE_2D_ARRAY)&&t.texParameteri(H,t.TEXTURE_WRAP_R,te[O.wrapR]),t.texParameteri(H,t.TEXTURE_MAG_FILTER,ae[O.magFilter]),t.texParameteri(H,t.TEXTURE_MIN_FILTER,ae[O.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),(O.wrapS!==Wo||O.wrapT!==Wo)&&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,P(O.magFilter)),t.texParameteri(H,t.TEXTURE_MIN_FILTER,P(O.minFilter)),O.minFilter!==ha&&O.minFilter!==go&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),O.compareFunction&&(t.texParameteri(H,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(H,t.TEXTURE_COMPARE_FUNC,de[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ye=e.get("EXT_texture_filter_anisotropic");if(O.magFilter===ha||O.minFilter!==QC&&O.minFilter!==T0||O.type===$c&&e.has("OES_texture_float_linear")===!1||l===!1&&O.type===C0&&e.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(t.texParameterf(H,ye.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function Ae(H,O){let ie=!1;H.__webglInit===void 0&&(H.__webglInit=!0,O.addEventListener("dispose",F));const ye=O.source;let _e=b.get(ye);_e===void 0&&(_e={},b.set(ye,_e));const le=re(O);if(le!==H.__cacheKey){_e[le]===void 0&&(_e[le]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,ie=!0),_e[le].usedTimes++;const ke=_e[H.__cacheKey];ke!==void 0&&(_e[H.__cacheKey].usedTimes--,ke.usedTimes===0&&D(O)),H.__cacheKey=le,H.__webglTexture=_e[le].texture}return ie}function ge(H,O,ie){let ye=t.TEXTURE_2D;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(ye=t.TEXTURE_2D_ARRAY),O.isData3DTexture&&(ye=t.TEXTURE_3D);const _e=Ae(H,O),le=O.source;n.bindTexture(ye,H.__webglTexture,t.TEXTURE0+ie);const ke=r.get(le);if(le.version!==ke.__version||_e===!0){n.activeTexture(t.TEXTURE0+ie);const Oe=lr.getPrimaries(lr.workingColorSpace),Ze=O.colorSpace===bo?null:lr.getPrimaries(O.colorSpace),ht=O.colorSpace===bo||Oe===Ze?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ht);const We=E(O)&&A(O.image)===!1;let he=S(O.image,We,!1,d);he=Ne(O,he);const rt=A(he)||l,qe=a.convert(O.format,O.colorSpace);let Je=a.convert(O.type),ot=R(O.internalFormat,qe,Je,O.colorSpace,O.isVideoTexture);fe(ye,O,rt);let se;const $e=O.mipmaps,be=l&&O.isVideoTexture!==!0&&ot!==yJ,Fe=ke.__version===void 0||_e===!0,De=T(O,he,rt);if(O.isDepthTexture)ot=t.DEPTH_COMPONENT,l?O.type===$c?ot=t.DEPTH_COMPONENT32F:O.type===gd?ot=t.DEPTH_COMPONENT24:O.type===cf?ot=t.DEPTH24_STENCIL8:ot=t.DEPTH_COMPONENT16:O.type===$c&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===uf&&ot===t.DEPTH_COMPONENT&&O.type!==TO&&O.type!==gd&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=gd,Je=a.convert(O.type)),O.format===gg&&ot===t.DEPTH_COMPONENT&&(ot=t.DEPTH_STENCIL,O.type!==cf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=cf,Je=a.convert(O.type))),Fe&&(be?n.texStorage2D(t.TEXTURE_2D,1,ot,he.width,he.height):n.texImage2D(t.TEXTURE_2D,0,ot,he.width,he.height,0,qe,Je,null));else if(O.isDataTexture)if($e.length>0&&rt){be&&Fe&&n.texStorage2D(t.TEXTURE_2D,De,ot,$e[0].width,$e[0].height);for(let ve=0,He=$e.length;ve<He;ve++)se=$e[ve],be?n.texSubImage2D(t.TEXTURE_2D,ve,0,0,se.width,se.height,qe,Je,se.data):n.texImage2D(t.TEXTURE_2D,ve,ot,se.width,se.height,0,qe,Je,se.data);O.generateMipmaps=!1}else be?(Fe&&n.texStorage2D(t.TEXTURE_2D,De,ot,he.width,he.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,he.width,he.height,qe,Je,he.data)):n.texImage2D(t.TEXTURE_2D,0,ot,he.width,he.height,0,qe,Je,he.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){be&&Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,De,ot,$e[0].width,$e[0].height,he.depth);for(let ve=0,He=$e.length;ve<He;ve++)se=$e[ve],O.format!==xo?qe!==null?be?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,ve,0,0,0,se.width,se.height,he.depth,qe,se.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,ve,ot,se.width,se.height,he.depth,0,se.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):be?n.texSubImage3D(t.TEXTURE_2D_ARRAY,ve,0,0,0,se.width,se.height,he.depth,qe,Je,se.data):n.texImage3D(t.TEXTURE_2D_ARRAY,ve,ot,se.width,se.height,he.depth,0,qe,Je,se.data)}else{be&&Fe&&n.texStorage2D(t.TEXTURE_2D,De,ot,$e[0].width,$e[0].height);for(let ve=0,He=$e.length;ve<He;ve++)se=$e[ve],O.format!==xo?qe!==null?be?n.compressedTexSubImage2D(t.TEXTURE_2D,ve,0,0,se.width,se.height,qe,se.data):n.compressedTexImage2D(t.TEXTURE_2D,ve,ot,se.width,se.height,0,se.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):be?n.texSubImage2D(t.TEXTURE_2D,ve,0,0,se.width,se.height,qe,Je,se.data):n.texImage2D(t.TEXTURE_2D,ve,ot,se.width,se.height,0,qe,Je,se.data)}else if(O.isDataArrayTexture)be?(Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,De,ot,he.width,he.height,he.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,he.width,he.height,he.depth,qe,Je,he.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,ot,he.width,he.height,he.depth,0,qe,Je,he.data);else if(O.isData3DTexture)be?(Fe&&n.texStorage3D(t.TEXTURE_3D,De,ot,he.width,he.height,he.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,he.width,he.height,he.depth,qe,Je,he.data)):n.texImage3D(t.TEXTURE_3D,0,ot,he.width,he.height,he.depth,0,qe,Je,he.data);else if(O.isFramebufferTexture){if(Fe)if(be)n.texStorage2D(t.TEXTURE_2D,De,ot,he.width,he.height);else{let ve=he.width,He=he.height;for(let dt=0;dt<De;dt++)n.texImage2D(t.TEXTURE_2D,dt,ot,ve,He,0,qe,Je,null),ve>>=1,He>>=1}}else if($e.length>0&&rt){be&&Fe&&n.texStorage2D(t.TEXTURE_2D,De,ot,$e[0].width,$e[0].height);for(let ve=0,He=$e.length;ve<He;ve++)se=$e[ve],be?n.texSubImage2D(t.TEXTURE_2D,ve,0,0,qe,Je,se):n.texImage2D(t.TEXTURE_2D,ve,ot,qe,Je,se);O.generateMipmaps=!1}else be?(Fe&&n.texStorage2D(t.TEXTURE_2D,De,ot,he.width,he.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,qe,Je,he)):n.texImage2D(t.TEXTURE_2D,0,ot,qe,Je,he);k(O,rt)&&C(ye),ke.__version=le.version,O.onUpdate&&O.onUpdate(O)}H.__version=O.version}function Me(H,O,ie){if(O.image.length!==6)return;const ye=Ae(H,O),_e=O.source;n.bindTexture(t.TEXTURE_CUBE_MAP,H.__webglTexture,t.TEXTURE0+ie);const le=r.get(_e);if(_e.version!==le.__version||ye===!0){n.activeTexture(t.TEXTURE0+ie);const ke=lr.getPrimaries(lr.workingColorSpace),Oe=O.colorSpace===bo?null:lr.getPrimaries(O.colorSpace),Ze=O.colorSpace===bo||ke===Oe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ze);const ht=O.isCompressedTexture||O.image[0].isCompressedTexture,We=O.image[0]&&O.image[0].isDataTexture,he=[];for(let ve=0;ve<6;ve++)!ht&&!We?he[ve]=S(O.image[ve],!1,!0,u):he[ve]=We?O.image[ve].image:O.image[ve],he[ve]=Ne(O,he[ve]);const rt=he[0],qe=A(rt)||l,Je=a.convert(O.format,O.colorSpace),ot=a.convert(O.type),se=R(O.internalFormat,Je,ot,O.colorSpace),$e=l&&O.isVideoTexture!==!0,be=le.__version===void 0||ye===!0;let Fe=T(O,rt,qe);fe(t.TEXTURE_CUBE_MAP,O,qe);let De;if(ht){$e&&be&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Fe,se,rt.width,rt.height);for(let ve=0;ve<6;ve++){De=he[ve].mipmaps;for(let He=0;He<De.length;He++){const dt=De[He];O.format!==xo?Je!==null?$e?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,He,0,0,dt.width,dt.height,Je,dt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,He,se,dt.width,dt.height,0,dt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):$e?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,He,0,0,dt.width,dt.height,Je,ot,dt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,He,se,dt.width,dt.height,0,Je,ot,dt.data)}}}else{De=O.mipmaps,$e&&be&&(De.length>0&&Fe++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Fe,se,he[0].width,he[0].height));for(let ve=0;ve<6;ve++)if(We){$e?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,he[ve].width,he[ve].height,Je,ot,he[ve].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,se,he[ve].width,he[ve].height,0,Je,ot,he[ve].data);for(let He=0;He<De.length;He++){const kt=De[He].image[ve].image;$e?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,He+1,0,0,kt.width,kt.height,Je,ot,kt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,He+1,se,kt.width,kt.height,0,Je,ot,kt.data)}}else{$e?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,Je,ot,he[ve]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,se,Je,ot,he[ve]);for(let He=0;He<De.length;He++){const dt=De[He];$e?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,He+1,0,0,Je,ot,dt.image[ve]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,He+1,se,Je,ot,dt.image[ve])}}}k(O,qe)&&C(t.TEXTURE_CUBE_MAP),le.__version=_e.version,O.onUpdate&&O.onUpdate(O)}H.__version=O.version}function je(H,O,ie,ye,_e,le){const ke=a.convert(ie.format,ie.colorSpace),Oe=a.convert(ie.type),Ze=R(ie.internalFormat,ke,Oe,ie.colorSpace);if(!r.get(O).__hasExternalTextures){const We=Math.max(1,O.width>>le),he=Math.max(1,O.height>>le);_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?n.texImage3D(_e,le,Ze,We,he,O.depth,0,ke,Oe,null):n.texImage2D(_e,le,Ze,We,he,0,ke,Oe,null)}n.bindFramebuffer(t.FRAMEBUFFER,H),Ee(O)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ye,_e,r.get(ie).__webglTexture,0,Q(O)):(_e===t.TEXTURE_2D||_e>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ye,_e,r.get(ie).__webglTexture,le),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ne(H,O,ie){if(t.bindRenderbuffer(t.RENDERBUFFER,H),O.depthBuffer&&!O.stencilBuffer){let ye=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(ie||Ee(O)){const _e=O.depthTexture;_e&&_e.isDepthTexture&&(_e.type===$c?ye=t.DEPTH_COMPONENT32F:_e.type===gd&&(ye=t.DEPTH_COMPONENT24));const le=Q(O);Ee(O)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,le,ye,O.width,O.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,le,ye,O.width,O.height)}else t.renderbufferStorage(t.RENDERBUFFER,ye,O.width,O.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,H)}else if(O.depthBuffer&&O.stencilBuffer){const ye=Q(O);ie&&Ee(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ye,t.DEPTH24_STENCIL8,O.width,O.height):Ee(O)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ye,t.DEPTH24_STENCIL8,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,O.width,O.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,H)}else{const ye=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let _e=0;_e<ye.length;_e++){const le=ye[_e],ke=a.convert(le.format,le.colorSpace),Oe=a.convert(le.type),Ze=R(le.internalFormat,ke,Oe,le.colorSpace),ht=Q(O);ie&&Ee(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ht,Ze,O.width,O.height):Ee(O)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ht,Ze,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,Ze,O.width,O.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ke(H,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,H),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(O.depthTexture).__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),oe(O.depthTexture,0);const ye=r.get(O.depthTexture).__webglTexture,_e=Q(O);if(O.depthTexture.format===uf)Ee(O)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0);else if(O.depthTexture.format===gg)Ee(O)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0);else throw new Error("Unknown depthTexture format")}function $(H){const O=r.get(H),ie=H.isWebGLCubeRenderTarget===!0;if(H.depthTexture&&!O.__autoAllocateDepthBuffer){if(ie)throw new Error("target.depthTexture not supported in Cube render targets");Ke(O.__webglFramebuffer,H)}else if(ie){O.__webglDepthbuffer=[];for(let ye=0;ye<6;ye++)n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[ye]),O.__webglDepthbuffer[ye]=t.createRenderbuffer(),ne(O.__webglDepthbuffer[ye],H,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer=t.createRenderbuffer(),ne(O.__webglDepthbuffer,H,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function z(H,O,ie){const ye=r.get(H);O!==void 0&&je(ye.__webglFramebuffer,H,H.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ie!==void 0&&$(H)}function W(H){const O=H.texture,ie=r.get(H),ye=r.get(O);H.addEventListener("dispose",L),H.isWebGLMultipleRenderTargets!==!0&&(ye.__webglTexture===void 0&&(ye.__webglTexture=t.createTexture()),ye.__version=O.version,o.memory.textures++);const _e=H.isWebGLCubeRenderTarget===!0,le=H.isWebGLMultipleRenderTargets===!0,ke=A(H)||l;if(_e){ie.__webglFramebuffer=[];for(let Oe=0;Oe<6;Oe++)if(l&&O.mipmaps&&O.mipmaps.length>0){ie.__webglFramebuffer[Oe]=[];for(let Ze=0;Ze<O.mipmaps.length;Ze++)ie.__webglFramebuffer[Oe][Ze]=t.createFramebuffer()}else ie.__webglFramebuffer[Oe]=t.createFramebuffer()}else{if(l&&O.mipmaps&&O.mipmaps.length>0){ie.__webglFramebuffer=[];for(let Oe=0;Oe<O.mipmaps.length;Oe++)ie.__webglFramebuffer[Oe]=t.createFramebuffer()}else ie.__webglFramebuffer=t.createFramebuffer();if(le)if(i.drawBuffers){const Oe=H.texture;for(let Ze=0,ht=Oe.length;Ze<ht;Ze++){const We=r.get(Oe[Ze]);We.__webglTexture===void 0&&(We.__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&&Ee(H)===!1){const Oe=le?O:[O];ie.__webglMultisampledFramebuffer=t.createFramebuffer(),ie.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ie.__webglMultisampledFramebuffer);for(let Ze=0;Ze<Oe.length;Ze++){const ht=Oe[Ze];ie.__webglColorRenderbuffer[Ze]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ie.__webglColorRenderbuffer[Ze]);const We=a.convert(ht.format,ht.colorSpace),he=a.convert(ht.type),rt=R(ht.internalFormat,We,he,ht.colorSpace,H.isXRRenderTarget===!0),qe=Q(H);t.renderbufferStorageMultisample(t.RENDERBUFFER,qe,rt,H.width,H.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ze,t.RENDERBUFFER,ie.__webglColorRenderbuffer[Ze])}t.bindRenderbuffer(t.RENDERBUFFER,null),H.depthBuffer&&(ie.__webglDepthRenderbuffer=t.createRenderbuffer(),ne(ie.__webglDepthRenderbuffer,H,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(_e){n.bindTexture(t.TEXTURE_CUBE_MAP,ye.__webglTexture),fe(t.TEXTURE_CUBE_MAP,O,ke);for(let Oe=0;Oe<6;Oe++)if(l&&O.mipmaps&&O.mipmaps.length>0)for(let Ze=0;Ze<O.mipmaps.length;Ze++)je(ie.__webglFramebuffer[Oe][Ze],H,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ze);else je(ie.__webglFramebuffer[Oe],H,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,0);k(O,ke)&&C(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(le){const Oe=H.texture;for(let Ze=0,ht=Oe.length;Ze<ht;Ze++){const We=Oe[Ze],he=r.get(We);n.bindTexture(t.TEXTURE_2D,he.__webglTexture),fe(t.TEXTURE_2D,We,ke),je(ie.__webglFramebuffer,H,We,t.COLOR_ATTACHMENT0+Ze,t.TEXTURE_2D,0),k(We,ke)&&C(t.TEXTURE_2D)}n.unbindTexture()}else{let Oe=t.TEXTURE_2D;if((H.isWebGL3DRenderTarget||H.isWebGLArrayRenderTarget)&&(l?Oe=H.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Oe,ye.__webglTexture),fe(Oe,O,ke),l&&O.mipmaps&&O.mipmaps.length>0)for(let Ze=0;Ze<O.mipmaps.length;Ze++)je(ie.__webglFramebuffer[Ze],H,O,t.COLOR_ATTACHMENT0,Oe,Ze);else je(ie.__webglFramebuffer,H,O,t.COLOR_ATTACHMENT0,Oe,0);k(O,ke)&&C(Oe),n.unbindTexture()}H.depthBuffer&&$(H)}function U(H){const O=A(H)||l,ie=H.isWebGLMultipleRenderTargets===!0?H.texture:[H.texture];for(let ye=0,_e=ie.length;ye<_e;ye++){const le=ie[ye];if(k(le,O)){const ke=H.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Oe=r.get(le).__webglTexture;n.bindTexture(ke,Oe),C(ke),n.unbindTexture()}}}function V(H){if(l&&H.samples>0&&Ee(H)===!1){const O=H.isWebGLMultipleRenderTargets?H.texture:[H.texture],ie=H.width,ye=H.height;let _e=t.COLOR_BUFFER_BIT;const le=[],ke=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Oe=r.get(H),Ze=H.isWebGLMultipleRenderTargets===!0;if(Ze)for(let ht=0;ht<O.length;ht++)n.bindFramebuffer(t.FRAMEBUFFER,Oe.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ht,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Oe.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ht,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Oe.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Oe.__webglFramebuffer);for(let ht=0;ht<O.length;ht++){le.push(t.COLOR_ATTACHMENT0+ht),H.depthBuffer&&le.push(ke);const We=Oe.__ignoreDepthValues!==void 0?Oe.__ignoreDepthValues:!1;if(We===!1&&(H.depthBuffer&&(_e|=t.DEPTH_BUFFER_BIT),H.stencilBuffer&&(_e|=t.STENCIL_BUFFER_BIT)),Ze&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Oe.__webglColorRenderbuffer[ht]),We===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[ke]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[ke])),Ze){const he=r.get(O[ht]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,he,0)}t.blitFramebuffer(0,0,ie,ye,0,0,ie,ye,_e,t.NEAREST),g&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,le)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ze)for(let ht=0;ht<O.length;ht++){n.bindFramebuffer(t.FRAMEBUFFER,Oe.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ht,t.RENDERBUFFER,Oe.__webglColorRenderbuffer[ht]);const We=r.get(O[ht]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Oe.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ht,t.TEXTURE_2D,We,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Oe.__webglMultisampledFramebuffer)}}function Q(H){return Math.min(f,H.samples)}function Ee(H){const O=r.get(H);return l&&H.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function Ce(H){const O=o.render.frame;x.get(H)!==O&&(x.set(H,O),H.update())}function Ne(H,O){const ie=H.colorSpace,ye=H.format,_e=H.type;return H.isCompressedTexture===!0||H.isVideoTexture===!0||H.format===WP||ie!==cu&&ie!==bo&&(lr.getTransfer(ie)===Mr?l===!1?e.has("EXT_sRGB")===!0&&ye===xo?(H.format=WP,H.minFilter=go,H.generateMipmaps=!1):O=NJ.sRGBToLinear(O):(ye!==xo||_e!==Cd)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",ie)),O}this.allocateTextureUnit=Z,this.resetTextureUnits=q,this.setTexture2D=oe,this.setTexture2DArray=B,this.setTexture3D=G,this.setTextureCube=J,this.rebindTextures=z,this.setupRenderTarget=W,this.updateRenderTargetMipmap=U,this.updateMultisampleRenderTarget=V,this.setupDepthRenderbuffer=$,this.setupFrameBufferTexture=je,this.useMultisampledRTT=Ee}function Vze(t,e,n){const r=n.isWebGL2;function i(a,o=bo){let l;const c=lr.getTransfer(o);if(a===Cd)return t.UNSIGNED_BYTE;if(a===mJ)return t.UNSIGNED_SHORT_4_4_4_4;if(a===pJ)return t.UNSIGNED_SHORT_5_5_5_1;if(a===mLe)return t.BYTE;if(a===pLe)return t.SHORT;if(a===TO)return t.UNSIGNED_SHORT;if(a===fJ)return t.INT;if(a===gd)return t.UNSIGNED_INT;if(a===$c)return t.FLOAT;if(a===C0)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(a===gLe)return t.ALPHA;if(a===xo)return t.RGBA;if(a===xLe)return t.LUMINANCE;if(a===bLe)return t.LUMINANCE_ALPHA;if(a===uf)return t.DEPTH_COMPONENT;if(a===gg)return t.DEPTH_STENCIL;if(a===WP)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===yLe)return t.RED;if(a===gJ)return t.RED_INTEGER;if(a===vLe)return t.RG;if(a===xJ)return t.RG_INTEGER;if(a===bJ)return t.RGBA_INTEGER;if(a===ZC||a===JC||a===ek||a===tk)if(c===Mr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===ZC)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===JC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===ek)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===tk)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===ZC)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===JC)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===ek)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===tk)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===wV||a===SV||a===MV||a===NV)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===wV)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===SV)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===MV)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===NV)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===yJ)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===EV||a===AV)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===EV)return c===Mr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===AV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===TV||a===CV||a===kV||a===jV||a===PV||a===RV||a===DV||a===OV||a===LV||a===IV||a===FV||a===UV||a===zV||a===BV)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===TV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===CV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===kV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===jV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===PV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===RV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===DV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===OV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===LV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===IV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===FV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===UV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===zV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===BV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===nk||a===$V||a===HV)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===nk)return c===Mr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===$V)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===HV)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===_Le||a===VV||a===GV||a===WV)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===nk)return l.COMPRESSED_RED_RGTC1_EXT;if(a===VV)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===GV)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===WV)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===cf?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 Gze extends Ds{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Sb extends Va{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Wze={type:"move"};class Nk{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Sb,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 Sb,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ze,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ze),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Sb,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ze,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ze),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),g=.02,x=.005;u.inputState.pinching&&m>g+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=g-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(Wze)))}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 Sb;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class qze extends Xf{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,g=null,x=null;const y=n.getContextAttributes();let b=null,v=null;const M=[],S=[],A=new cn;let E=null;const k=new Ds;k.layers.enable(1),k.viewport=new ur;const C=new Ds;C.layers.enable(2),C.viewport=new ur;const R=[k,C],T=new Gze;T.layers.enable(1),T.layers.enable(2);let P=null,F=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let te=M[J];return te===void 0&&(te=new Nk,M[J]=te),te.getTargetRaySpace()},this.getControllerGrip=function(J){let te=M[J];return te===void 0&&(te=new Nk,M[J]=te),te.getGripSpace()},this.getHand=function(J){let te=M[J];return te===void 0&&(te=new Nk,M[J]=te),te.getHandSpace()};function L(J){const te=S.indexOf(J.inputSource);if(te===-1)return;const ae=M[te];ae!==void 0&&(ae.update(J.inputSource,J.frame,u||o),ae.dispatchEvent({type:J.type,data:J.inputSource}))}function X(){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",X),i.removeEventListener("inputsourceschange",D);for(let J=0;J<M.length;J++){const te=S[J];te!==null&&(S[J]=null,M[J].disconnect(te))}P=null,F=null,e.setRenderTarget(b),g=null,m=null,f=null,i=null,v=null,G.stop(),r.isPresenting=!1,e.setPixelRatio(E),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(J){a=J,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){l=J,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(J){u=J},this.getBaseLayer=function(){return m!==null?m:g},this.getBinding=function(){return f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(J){if(i=J,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",X),i.addEventListener("inputsourceschange",D),y.xrCompatible!==!0&&await n.makeXRCompatible(),E=e.getPixelRatio(),e.getSize(A),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const te={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:a};g=new XRWebGLLayer(i,n,te),i.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),v=new Lf(g.framebufferWidth,g.framebufferHeight,{format:xo,type:Cd,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let te=null,ae=null,de=null;y.depth&&(de=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,te=y.stencil?gg:uf,ae=y.stencil?cf:gd);const fe={colorFormat:n.RGBA8,depthFormat:de,scaleFactor:a};f=new XRWebGLBinding(i,n),m=f.createProjectionLayer(fe),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),v=new Lf(m.textureWidth,m.textureHeight,{format:xo,type:Cd,depthTexture:new IJ(m.textureWidth,m.textureHeight,ae,void 0,void 0,void 0,void 0,void 0,void 0,te),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});const Ae=e.properties.get(v);Ae.__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 D(J){for(let te=0;te<J.removed.length;te++){const ae=J.removed[te],de=S.indexOf(ae);de>=0&&(S[de]=null,M[de].disconnect(ae))}for(let te=0;te<J.added.length;te++){const ae=J.added[te];let de=S.indexOf(ae);if(de===-1){for(let Ae=0;Ae<M.length;Ae++)if(Ae>=S.length){S.push(ae),de=Ae;break}else if(S[Ae]===null){S[Ae]=ae,de=Ae;break}if(de===-1)break}const fe=M[de];fe&&fe.connect(ae)}}const K=new ze,Y=new ze;function q(J,te,ae){K.setFromMatrixPosition(te.matrixWorld),Y.setFromMatrixPosition(ae.matrixWorld);const de=K.distanceTo(Y),fe=te.projectionMatrix.elements,Ae=ae.projectionMatrix.elements,ge=fe[14]/(fe[10]-1),Me=fe[14]/(fe[10]+1),je=(fe[9]+1)/fe[5],ne=(fe[9]-1)/fe[5],Ke=(fe[8]-1)/fe[0],$=(Ae[8]+1)/Ae[0],z=ge*Ke,W=ge*$,U=de/(-Ke+$),V=U*-Ke;te.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(V),J.translateZ(U),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert();const Q=ge+U,Ee=Me+U,Ce=z-V,Ne=W+(de-V),H=je*Me/Ee*Q,O=ne*Me/Ee*Q;J.projectionMatrix.makePerspective(Ce,Ne,H,O,Q,Ee),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}function Z(J,te){te===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(te.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(i===null)return;T.near=C.near=k.near=J.near,T.far=C.far=k.far=J.far,(P!==T.near||F!==T.far)&&(i.updateRenderState({depthNear:T.near,depthFar:T.far}),P=T.near,F=T.far);const te=J.parent,ae=T.cameras;Z(T,te);for(let de=0;de<ae.length;de++)Z(ae[de],te);ae.length===2?q(T,k,C):T.projectionMatrix.copy(k.projectionMatrix),re(J,T,te)};function re(J,te,ae){ae===null?J.matrix.copy(te.matrixWorld):(J.matrix.copy(ae.matrixWorld),J.matrix.invert(),J.matrix.multiply(te.matrixWorld)),J.matrix.decompose(J.position,J.quaternion,J.scale),J.updateMatrixWorld(!0),J.projectionMatrix.copy(te.projectionMatrix),J.projectionMatrixInverse.copy(te.projectionMatrixInverse),J.isPerspectiveCamera&&(J.fov=j0*2*Math.atan(1/J.projectionMatrix.elements[5]),J.zoom=1)}this.getCamera=function(){return T},this.getFoveation=function(){if(!(m===null&&g===null))return c},this.setFoveation=function(J){c=J,m!==null&&(m.fixedFoveation=J),g!==null&&g.fixedFoveation!==void 0&&(g.fixedFoveation=J)};let oe=null;function B(J,te){if(d=te.getViewerPose(u||o),x=te,d!==null){const ae=d.views;g!==null&&(e.setRenderTargetFramebuffer(v,g.framebuffer),e.setRenderTarget(v));let de=!1;ae.length!==T.cameras.length&&(T.cameras.length=0,de=!0);for(let fe=0;fe<ae.length;fe++){const Ae=ae[fe];let ge=null;if(g!==null)ge=g.getViewport(Ae);else{const je=f.getViewSubImage(m,Ae);ge=je.viewport,fe===0&&(e.setRenderTargetTextures(v,je.colorTexture,m.ignoreDepthValues?void 0:je.depthStencilTexture),e.setRenderTarget(v))}let Me=R[fe];Me===void 0&&(Me=new Ds,Me.layers.enable(fe),Me.viewport=new ur,R[fe]=Me),Me.matrix.fromArray(Ae.transform.matrix),Me.matrix.decompose(Me.position,Me.quaternion,Me.scale),Me.projectionMatrix.fromArray(Ae.projectionMatrix),Me.projectionMatrixInverse.copy(Me.projectionMatrix).invert(),Me.viewport.set(ge.x,ge.y,ge.width,ge.height),fe===0&&(T.matrix.copy(Me.matrix),T.matrix.decompose(T.position,T.quaternion,T.scale)),de===!0&&T.cameras.push(Me)}}for(let ae=0;ae<M.length;ae++){const de=S[ae],fe=M[ae];de!==null&&fe!==void 0&&fe.update(de,te,u||o)}oe&&oe(J,te),te.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:te}),x=null}const G=new LJ;G.setAnimationLoop(B),this.setAnimationLoop=function(J){oe=J},this.dispose=function(){}}}function Kze(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,RJ(t)),v.isFog?(b.fogNear.value=v.near,b.fogFar.value=v.far):v.isFogExp2&&(b.fogDensity.value=v.density)}function i(b,v,M,S,A){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&&g(b,v,A)):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,M,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===ms&&(b.bumpScale.value*=-1)),v.normalMap&&(b.normalMap.value=v.normalMap,n(v.normalMap,b.normalMapTransform),b.normalScale.value.copy(v.normalScale),v.side===ms&&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 M=e.get(v).envMap;if(M&&(b.envMap.value=M,b.flipEnvMap.value=M.isCubeTexture&&M.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,M,S){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.size.value=v.size*M,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 g(b,v,M){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===ms&&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=M.texture,b.transmissionSamplerSize.value.set(M.width,M.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 M=e.get(v).light;b.referencePosition.value.setFromMatrixPosition(M.matrixWorld),b.nearDistance.value=M.shadow.camera.near,b.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function Xze(t,e,n,r){let i={},a={},o=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(M,S){const A=S.program;r.uniformBlockBinding(M,A)}function u(M,S){let A=i[M.id];A===void 0&&(x(M),A=d(M),i[M.id]=A,M.addEventListener("dispose",b));const E=S.program;r.updateUBOMapping(M,E);const k=e.render.frame;a[M.id]!==k&&(m(M),a[M.id]=k)}function d(M){const S=f();M.__bindingPointIndex=S;const A=t.createBuffer(),E=M.__size,k=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,E,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,S,A),A}function f(){for(let M=0;M<l;M++)if(o.indexOf(M)===-1)return o.push(M),M;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(M){const S=i[M.id],A=M.uniforms,E=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,S);for(let k=0,C=A.length;k<C;k++){const R=A[k];if(g(R,k,E)===!0){const T=R.__offset,P=Array.isArray(R.value)?R.value:[R.value];let F=0;for(let L=0;L<P.length;L++){const X=P[L],D=y(X);typeof X=="number"?(R.__data[0]=X,t.bufferSubData(t.UNIFORM_BUFFER,T+F,R.__data)):X.isMatrix3?(R.__data[0]=X.elements[0],R.__data[1]=X.elements[1],R.__data[2]=X.elements[2],R.__data[3]=X.elements[0],R.__data[4]=X.elements[3],R.__data[5]=X.elements[4],R.__data[6]=X.elements[5],R.__data[7]=X.elements[0],R.__data[8]=X.elements[6],R.__data[9]=X.elements[7],R.__data[10]=X.elements[8],R.__data[11]=X.elements[0]):(X.toArray(R.__data,F),F+=D.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,T,R.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function g(M,S,A){const E=M.value;if(A[S]===void 0){if(typeof E=="number")A[S]=E;else{const k=Array.isArray(E)?E:[E],C=[];for(let R=0;R<k.length;R++)C.push(k[R].clone());A[S]=C}return!0}else if(typeof E=="number"){if(A[S]!==E)return A[S]=E,!0}else{const k=Array.isArray(A[S])?A[S]:[A[S]],C=Array.isArray(E)?E:[E];for(let R=0;R<k.length;R++){const T=k[R];if(T.equals(C[R])===!1)return T.copy(C[R]),!0}}return!1}function x(M){const S=M.uniforms;let A=0;const E=16;let k=0;for(let C=0,R=S.length;C<R;C++){const T=S[C],P={boundary:0,storage:0},F=Array.isArray(T.value)?T.value:[T.value];for(let L=0,X=F.length;L<X;L++){const D=F[L],K=y(D);P.boundary+=K.boundary,P.storage+=K.storage}if(T.__data=new Float32Array(P.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=A,C>0){k=A%E;const L=E-k;k!==0&&L-P.boundary<0&&(A+=E-k,T.__offset=A)}A+=P.storage}return k=A%E,k>0&&(A+=E-k),M.__size=A,M.__cache={},this}function y(M){const S={boundary:0,storage:0};return typeof M=="number"?(S.boundary=4,S.storage=4):M.isVector2?(S.boundary=8,S.storage=8):M.isVector3||M.isColor?(S.boundary=16,S.storage=12):M.isVector4?(S.boundary=16,S.storage=16):M.isMatrix3?(S.boundary=48,S.storage=48):M.isMatrix4?(S.boundary=64,S.storage=64):M.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",M),S}function b(M){const S=M.target;S.removeEventListener("dispose",b);const A=o.indexOf(S.__bindingPointIndex);o.splice(A,1),t.deleteBuffer(i[S.id]),delete i[S.id],delete a[S.id]}function v(){for(const M in i)t.deleteBuffer(i[M]);o=[],i={},a={}}return{bind:c,update:u,dispose:v}}class XP{constructor(e={}){const{canvas:n=WLe(),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 g=new Uint32Array(4),x=new Int32Array(4);let y=null,b=null;const v=[],M=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=fa,this._useLegacyLights=!1,this.toneMapping=Td,this.toneMappingExposure=1;const S=this;let A=!1,E=0,k=0,C=null,R=-1,T=null;const P=new ur,F=new ur;let L=null;const X=new Qt(0);let D=0,K=n.width,Y=n.height,q=1,Z=null,re=null;const oe=new ur(0,0,K,Y),B=new ur(0,0,K,Y);let G=!1;const J=new BM;let te=!1,ae=!1,de=null;const fe=new vr,Ae=new cn,ge=new ze,Me={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function je(){return C===null?q:1}let ne=r;function Ke(ue,Be){for(let Ye=0;Ye<ue.length;Ye++){const Xe=ue[Ye],Qe=n.getContext(Xe,Be);if(Qe!==null)return Qe}return null}try{const ue={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${FM}`),n.addEventListener("webglcontextlost",$e,!1),n.addEventListener("webglcontextrestored",be,!1),n.addEventListener("webglcontextcreationerror",Fe,!1),ne===null){const Be=["webgl2","webgl","experimental-webgl"];if(S.isWebGL1Renderer===!0&&Be.shift(),ne=Ke(Be,ue),ne===null)throw Ke(Be)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&ne instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),ne.getShaderPrecisionFormat===void 0&&(ne.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(ue){throw console.error("THREE.WebGLRenderer: "+ue.message),ue}let $,z,W,U,V,Q,Ee,Ce,Ne,H,O,ie,ye,_e,le,ke,Oe,Ze,ht,We,he,rt,qe,Je;function ot(){$=new sUe(ne),z=new JFe(ne,$,e),$.init(z),rt=new Vze(ne,$,z),W=new $ze(ne,$,z),U=new cUe(ne),V=new Tze,Q=new Hze(ne,$,W,V,z,rt,U),Ee=new tUe(S),Ce=new aUe(S),Ne=new gIe(ne,z),qe=new QFe(ne,$,Ne,z),H=new oUe(ne,Ne,U,qe),O=new fUe(ne,H,Ne,U),ht=new hUe(ne,z,Q),ke=new eUe(V),ie=new Aze(S,Ee,Ce,$,z,qe,ke),ye=new Kze(S,V),_e=new kze,le=new Lze($,z),Ze=new YFe(S,Ee,Ce,W,O,m,c),Oe=new Bze(S,O,z),Je=new Xze(ne,U,z,W),We=new ZFe(ne,$,U,z),he=new lUe(ne,$,U,z),U.programs=ie.programs,S.capabilities=z,S.extensions=$,S.properties=V,S.renderLists=_e,S.shadowMap=Oe,S.state=W,S.info=U}ot();const se=new qze(S,ne);this.xr=se,this.getContext=function(){return ne},this.getContextAttributes=function(){return ne.getContextAttributes()},this.forceContextLoss=function(){const ue=$.get("WEBGL_lose_context");ue&&ue.loseContext()},this.forceContextRestore=function(){const ue=$.get("WEBGL_lose_context");ue&&ue.restoreContext()},this.getPixelRatio=function(){return q},this.setPixelRatio=function(ue){ue!==void 0&&(q=ue,this.setSize(K,Y,!1))},this.getSize=function(ue){return ue.set(K,Y)},this.setSize=function(ue,Be,Ye=!0){if(se.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}K=ue,Y=Be,n.width=Math.floor(ue*q),n.height=Math.floor(Be*q),Ye===!0&&(n.style.width=ue+"px",n.style.height=Be+"px"),this.setViewport(0,0,ue,Be)},this.getDrawingBufferSize=function(ue){return ue.set(K*q,Y*q).floor()},this.setDrawingBufferSize=function(ue,Be,Ye){K=ue,Y=Be,q=Ye,n.width=Math.floor(ue*Ye),n.height=Math.floor(Be*Ye),this.setViewport(0,0,ue,Be)},this.getCurrentViewport=function(ue){return ue.copy(P)},this.getViewport=function(ue){return ue.copy(oe)},this.setViewport=function(ue,Be,Ye,Xe){ue.isVector4?oe.set(ue.x,ue.y,ue.z,ue.w):oe.set(ue,Be,Ye,Xe),W.viewport(P.copy(oe).multiplyScalar(q).floor())},this.getScissor=function(ue){return ue.copy(B)},this.setScissor=function(ue,Be,Ye,Xe){ue.isVector4?B.set(ue.x,ue.y,ue.z,ue.w):B.set(ue,Be,Ye,Xe),W.scissor(F.copy(B).multiplyScalar(q).floor())},this.getScissorTest=function(){return G},this.setScissorTest=function(ue){W.setScissorTest(G=ue)},this.setOpaqueSort=function(ue){Z=ue},this.setTransparentSort=function(ue){re=ue},this.getClearColor=function(ue){return ue.copy(Ze.getClearColor())},this.setClearColor=function(){Ze.setClearColor.apply(Ze,arguments)},this.getClearAlpha=function(){return Ze.getClearAlpha()},this.setClearAlpha=function(){Ze.setClearAlpha.apply(Ze,arguments)},this.clear=function(ue=!0,Be=!0,Ye=!0){let Xe=0;if(ue){let Qe=!1;if(C!==null){const At=C.texture.format;Qe=At===bJ||At===xJ||At===gJ}if(Qe){const At=C.texture.type,ce=At===Cd||At===gd||At===TO||At===cf||At===mJ||At===pJ,we=Ze.getClearColor(),Ie=Ze.getClearAlpha(),Le=we.r,Re=we.g,ut=we.b;ce?(g[0]=Le,g[1]=Re,g[2]=ut,g[3]=Ie,ne.clearBufferuiv(ne.COLOR,0,g)):(x[0]=Le,x[1]=Re,x[2]=ut,x[3]=Ie,ne.clearBufferiv(ne.COLOR,0,x))}else Xe|=ne.COLOR_BUFFER_BIT}Be&&(Xe|=ne.DEPTH_BUFFER_BIT),Ye&&(Xe|=ne.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ne.clear(Xe)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",$e,!1),n.removeEventListener("webglcontextrestored",be,!1),n.removeEventListener("webglcontextcreationerror",Fe,!1),_e.dispose(),le.dispose(),V.dispose(),Ee.dispose(),Ce.dispose(),O.dispose(),qe.dispose(),Je.dispose(),ie.dispose(),se.dispose(),se.removeEventListener("sessionstart",Zt),se.removeEventListener("sessionend",Rt),de&&(de.dispose(),de=null),nn.stop()};function $e(ue){ue.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function be(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const ue=U.autoReset,Be=Oe.enabled,Ye=Oe.autoUpdate,Xe=Oe.needsUpdate,Qe=Oe.type;ot(),U.autoReset=ue,Oe.enabled=Be,Oe.autoUpdate=Ye,Oe.needsUpdate=Xe,Oe.type=Qe}function Fe(ue){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",ue.statusMessage)}function De(ue){const Be=ue.target;Be.removeEventListener("dispose",De),ve(Be)}function ve(ue){He(ue),V.remove(ue)}function He(ue){const Be=V.get(ue).programs;Be!==void 0&&(Be.forEach(function(Ye){ie.releaseProgram(Ye)}),ue.isShaderMaterial&&ie.releaseShaderCache(ue))}this.renderBufferDirect=function(ue,Be,Ye,Xe,Qe,At){Be===null&&(Be=Me);const ce=Qe.isMesh&&Qe.matrixWorld.determinant()<0,we=yt(ue,Be,Ye,Xe,Qe);W.setMaterial(Xe,ce);let Ie=Ye.index,Le=1;if(Xe.wireframe===!0){if(Ie=H.getWireframeAttribute(Ye),Ie===void 0)return;Le=2}const Re=Ye.drawRange,ut=Ye.attributes.position;let _t=Re.start*Le,Tt=(Re.start+Re.count)*Le;At!==null&&(_t=Math.max(_t,At.start*Le),Tt=Math.min(Tt,(At.start+At.count)*Le)),Ie!==null?(_t=Math.max(_t,0),Tt=Math.min(Tt,Ie.count)):ut!=null&&(_t=Math.max(_t,0),Tt=Math.min(Tt,ut.count));const St=Tt-_t;if(St<0||St===1/0)return;qe.setup(Qe,Xe,we,Ye,Ie);let vt,xe=We;if(Ie!==null&&(vt=Ne.get(Ie),xe=he,xe.setIndex(vt)),Qe.isMesh)Xe.wireframe===!0?(W.setLineWidth(Xe.wireframeLinewidth*je()),xe.setMode(ne.LINES)):xe.setMode(ne.TRIANGLES);else if(Qe.isLine){let st=Xe.linewidth;st===void 0&&(st=1),W.setLineWidth(st*je()),Qe.isLineSegments?xe.setMode(ne.LINES):Qe.isLineLoop?xe.setMode(ne.LINE_LOOP):xe.setMode(ne.LINE_STRIP)}else Qe.isPoints?xe.setMode(ne.POINTS):Qe.isSprite&&xe.setMode(ne.TRIANGLES);if(Qe.isBatchedMesh)xe.renderMultiDraw(Qe._multiDrawStarts,Qe._multiDrawCounts,Qe._multiDrawCount);else if(Qe.isInstancedMesh)xe.renderInstances(_t,St,Qe.count);else if(Ye.isInstancedBufferGeometry){const st=Ye._maxInstanceCount!==void 0?Ye._maxInstanceCount:1/0,Ht=Math.min(Ye.instanceCount,st);xe.renderInstances(_t,St,Ht)}else xe.render(_t,St)};function dt(ue,Be,Ye){ue.transparent===!0&&ue.side===Lc&&ue.forceSinglePass===!1?(ue.side=ms,ue.needsUpdate=!0,$r(ue,Be,Ye),ue.side=Hd,ue.needsUpdate=!0,$r(ue,Be,Ye),ue.side=Lc):$r(ue,Be,Ye)}this.compile=function(ue,Be,Ye=null){Ye===null&&(Ye=ue),b=le.get(Ye),b.init(),M.push(b),Ye.traverseVisible(function(Qe){Qe.isLight&&Qe.layers.test(Be.layers)&&(b.pushLight(Qe),Qe.castShadow&&b.pushShadow(Qe))}),ue!==Ye&&ue.traverseVisible(function(Qe){Qe.isLight&&Qe.layers.test(Be.layers)&&(b.pushLight(Qe),Qe.castShadow&&b.pushShadow(Qe))}),b.setupLights(S._useLegacyLights);const Xe=new Set;return ue.traverse(function(Qe){const At=Qe.material;if(At)if(Array.isArray(At))for(let ce=0;ce<At.length;ce++){const we=At[ce];dt(we,Ye,Qe),Xe.add(we)}else dt(At,Ye,Qe),Xe.add(At)}),M.pop(),b=null,Xe},this.compileAsync=function(ue,Be,Ye=null){const Xe=this.compile(ue,Be,Ye);return new Promise(Qe=>{function At(){if(Xe.forEach(function(ce){V.get(ce).currentProgram.isReady()&&Xe.delete(ce)}),Xe.size===0){Qe(ue);return}setTimeout(At,10)}$.get("KHR_parallel_shader_compile")!==null?At():setTimeout(At,10)})};let kt=null;function jt(ue){kt&&kt(ue)}function Zt(){nn.stop()}function Rt(){nn.start()}const nn=new LJ;nn.setAnimationLoop(jt),typeof self<"u"&&nn.setContext(self),this.setAnimationLoop=function(ue){kt=ue,se.setAnimationLoop(ue),ue===null?nn.stop():nn.start()},se.addEventListener("sessionstart",Zt),se.addEventListener("sessionend",Rt),this.render=function(ue,Be){if(Be!==void 0&&Be.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;ue.matrixWorldAutoUpdate===!0&&ue.updateMatrixWorld(),Be.parent===null&&Be.matrixWorldAutoUpdate===!0&&Be.updateMatrixWorld(),se.enabled===!0&&se.isPresenting===!0&&(se.cameraAutoUpdate===!0&&se.updateCamera(Be),Be=se.getCamera()),ue.isScene===!0&&ue.onBeforeRender(S,ue,Be,C),b=le.get(ue,M.length),b.init(),M.push(b),fe.multiplyMatrices(Be.projectionMatrix,Be.matrixWorldInverse),J.setFromProjectionMatrix(fe),ae=this.localClippingEnabled,te=ke.init(this.clippingPlanes,ae),y=_e.get(ue,v.length),y.init(),v.push(y),pt(ue,Be,0,S.sortObjects),y.finish(),S.sortObjects===!0&&y.sort(Z,re),this.info.render.frame++,te===!0&&ke.beginShadows();const Ye=b.state.shadowsArray;if(Oe.render(Ye,ue,Be),te===!0&&ke.endShadows(),this.info.autoReset===!0&&this.info.reset(),Ze.render(y,ue),b.setupLights(S._useLegacyLights),Be.isArrayCamera){const Xe=Be.cameras;for(let Qe=0,At=Xe.length;Qe<At;Qe++){const ce=Xe[Qe];$t(y,ue,ce,ce.viewport)}}else $t(y,ue,Be);C!==null&&(Q.updateMultisampleRenderTarget(C),Q.updateRenderTargetMipmap(C)),ue.isScene===!0&&ue.onAfterRender(S,ue,Be),qe.resetDefaultState(),R=-1,T=null,M.pop(),M.length>0?b=M[M.length-1]:b=null,v.pop(),v.length>0?y=v[v.length-1]:y=null};function pt(ue,Be,Ye,Xe){if(ue.visible===!1)return;if(ue.layers.test(Be.layers)){if(ue.isGroup)Ye=ue.renderOrder;else if(ue.isLOD)ue.autoUpdate===!0&&ue.update(Be);else if(ue.isLight)b.pushLight(ue),ue.castShadow&&b.pushShadow(ue);else if(ue.isSprite){if(!ue.frustumCulled||J.intersectsSprite(ue)){Xe&&ge.setFromMatrixPosition(ue.matrixWorld).applyMatrix4(fe);const ce=O.update(ue),we=ue.material;we.visible&&y.push(ue,ce,we,Ye,ge.z,null)}}else if((ue.isMesh||ue.isLine||ue.isPoints)&&(!ue.frustumCulled||J.intersectsObject(ue))){const ce=O.update(ue),we=ue.material;if(Xe&&(ue.boundingSphere!==void 0?(ue.boundingSphere===null&&ue.computeBoundingSphere(),ge.copy(ue.boundingSphere.center)):(ce.boundingSphere===null&&ce.computeBoundingSphere(),ge.copy(ce.boundingSphere.center)),ge.applyMatrix4(ue.matrixWorld).applyMatrix4(fe)),Array.isArray(we)){const Ie=ce.groups;for(let Le=0,Re=Ie.length;Le<Re;Le++){const ut=Ie[Le],_t=we[ut.materialIndex];_t&&_t.visible&&y.push(ue,ce,_t,Ye,ge.z,ut)}}else we.visible&&y.push(ue,ce,we,Ye,ge.z,null)}}const At=ue.children;for(let ce=0,we=At.length;ce<we;ce++)pt(At[ce],Be,Ye,Xe)}function $t(ue,Be,Ye,Xe){const Qe=ue.opaque,At=ue.transmissive,ce=ue.transparent;b.setupLightsView(Ye),te===!0&&ke.setGlobalState(S.clippingPlanes,Ye),At.length>0&&qt(Qe,At,Be,Ye),Xe&&W.viewport(P.copy(Xe)),Qe.length>0&&wt(Qe,Be,Ye),At.length>0&&wt(At,Be,Ye),ce.length>0&&wt(ce,Be,Ye),W.buffers.depth.setTest(!0),W.buffers.depth.setMask(!0),W.buffers.color.setMask(!0),W.setPolygonOffset(!1)}function qt(ue,Be,Ye,Xe){if((Ye.isScene===!0?Ye.overrideMaterial:null)!==null)return;const At=z.isWebGL2;de===null&&(de=new Lf(1,1,{generateMipmaps:!0,type:$.has("EXT_color_buffer_half_float")?C0:Cd,minFilter:T0,samples:At?4:0})),S.getDrawingBufferSize(Ae),At?de.setSize(Ae.x,Ae.y):de.setSize(SS(Ae.x),SS(Ae.y));const ce=S.getRenderTarget();S.setRenderTarget(de),S.getClearColor(X),D=S.getClearAlpha(),D<1&&S.setClearColor(16777215,.5),S.clear();const we=S.toneMapping;S.toneMapping=Td,wt(ue,Ye,Xe),Q.updateMultisampleRenderTarget(de),Q.updateRenderTargetMipmap(de);let Ie=!1;for(let Le=0,Re=Be.length;Le<Re;Le++){const ut=Be[Le],_t=ut.object,Tt=ut.geometry,St=ut.material,vt=ut.group;if(St.side===Lc&&_t.layers.test(Xe.layers)){const xe=St.side;St.side=ms,St.needsUpdate=!0,_r(_t,Ye,Xe,Tt,St,vt),St.side=xe,St.needsUpdate=!0,Ie=!0}}Ie===!0&&(Q.updateMultisampleRenderTarget(de),Q.updateRenderTargetMipmap(de)),S.setRenderTarget(ce),S.setClearColor(X,D),S.toneMapping=we}function wt(ue,Be,Ye){const Xe=Be.isScene===!0?Be.overrideMaterial:null;for(let Qe=0,At=ue.length;Qe<At;Qe++){const ce=ue[Qe],we=ce.object,Ie=ce.geometry,Le=Xe===null?ce.material:Xe,Re=ce.group;we.layers.test(Ye.layers)&&_r(we,Be,Ye,Ie,Le,Re)}}function _r(ue,Be,Ye,Xe,Qe,At){ue.onBeforeRender(S,Be,Ye,Xe,Qe,At),ue.modelViewMatrix.multiplyMatrices(Ye.matrixWorldInverse,ue.matrixWorld),ue.normalMatrix.getNormalMatrix(ue.modelViewMatrix),Qe.onBeforeRender(S,Be,Ye,Xe,ue,At),Qe.transparent===!0&&Qe.side===Lc&&Qe.forceSinglePass===!1?(Qe.side=ms,Qe.needsUpdate=!0,S.renderBufferDirect(Ye,Be,Xe,Qe,ue,At),Qe.side=Hd,Qe.needsUpdate=!0,S.renderBufferDirect(Ye,Be,Xe,Qe,ue,At),Qe.side=Lc):S.renderBufferDirect(Ye,Be,Xe,Qe,ue,At),ue.onAfterRender(S,Be,Ye,Xe,Qe,At)}function $r(ue,Be,Ye){Be.isScene!==!0&&(Be=Me);const Xe=V.get(ue),Qe=b.state.lights,At=b.state.shadowsArray,ce=Qe.state.version,we=ie.getParameters(ue,Qe.state,At,Be,Ye),Ie=ie.getProgramCacheKey(we);let Le=Xe.programs;Xe.environment=ue.isMeshStandardMaterial?Be.environment:null,Xe.fog=Be.fog,Xe.envMap=(ue.isMeshStandardMaterial?Ce:Ee).get(ue.envMap||Xe.environment),Le===void 0&&(ue.addEventListener("dispose",De),Le=new Map,Xe.programs=Le);let Re=Le.get(Ie);if(Re!==void 0){if(Xe.currentProgram===Re&&Xe.lightsStateVersion===ce)return hr(ue,we),Re}else we.uniforms=ie.getUniforms(ue),ue.onBuild(Ye,we,S),ue.onBeforeCompile(we,S),Re=ie.acquireProgram(we,Ie),Le.set(Ie,Re),Xe.uniforms=we.uniforms;const ut=Xe.uniforms;return(!ue.isShaderMaterial&&!ue.isRawShaderMaterial||ue.clipping===!0)&&(ut.clippingPlanes=ke.uniform),hr(ue,we),Xe.needsLights=wn(ue),Xe.lightsStateVersion=ce,Xe.needsLights&&(ut.ambientLightColor.value=Qe.state.ambient,ut.lightProbe.value=Qe.state.probe,ut.directionalLights.value=Qe.state.directional,ut.directionalLightShadows.value=Qe.state.directionalShadow,ut.spotLights.value=Qe.state.spot,ut.spotLightShadows.value=Qe.state.spotShadow,ut.rectAreaLights.value=Qe.state.rectArea,ut.ltc_1.value=Qe.state.rectAreaLTC1,ut.ltc_2.value=Qe.state.rectAreaLTC2,ut.pointLights.value=Qe.state.point,ut.pointLightShadows.value=Qe.state.pointShadow,ut.hemisphereLights.value=Qe.state.hemi,ut.directionalShadowMap.value=Qe.state.directionalShadowMap,ut.directionalShadowMatrix.value=Qe.state.directionalShadowMatrix,ut.spotShadowMap.value=Qe.state.spotShadowMap,ut.spotLightMatrix.value=Qe.state.spotLightMatrix,ut.spotLightMap.value=Qe.state.spotLightMap,ut.pointShadowMap.value=Qe.state.pointShadowMap,ut.pointShadowMatrix.value=Qe.state.pointShadowMatrix),Xe.currentProgram=Re,Xe.uniformsList=null,Re}function Tr(ue){if(ue.uniformsList===null){const Be=ue.currentProgram.getUniforms();ue.uniformsList=Y1.seqWithValue(Be.seq,ue.uniforms)}return ue.uniformsList}function hr(ue,Be){const Ye=V.get(ue);Ye.outputColorSpace=Be.outputColorSpace,Ye.batching=Be.batching,Ye.instancing=Be.instancing,Ye.instancingColor=Be.instancingColor,Ye.skinning=Be.skinning,Ye.morphTargets=Be.morphTargets,Ye.morphNormals=Be.morphNormals,Ye.morphColors=Be.morphColors,Ye.morphTargetsCount=Be.morphTargetsCount,Ye.numClippingPlanes=Be.numClippingPlanes,Ye.numIntersection=Be.numClipIntersection,Ye.vertexAlphas=Be.vertexAlphas,Ye.vertexTangents=Be.vertexTangents,Ye.toneMapping=Be.toneMapping}function yt(ue,Be,Ye,Xe,Qe){Be.isScene!==!0&&(Be=Me),Q.resetTextureUnits();const At=Be.fog,ce=Xe.isMeshStandardMaterial?Be.environment:null,we=C===null?S.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:cu,Ie=(Xe.isMeshStandardMaterial?Ce:Ee).get(Xe.envMap||ce),Le=Xe.vertexColors===!0&&!!Ye.attributes.color&&Ye.attributes.color.itemSize===4,Re=!!Ye.attributes.tangent&&(!!Xe.normalMap||Xe.anisotropy>0),ut=!!Ye.morphAttributes.position,_t=!!Ye.morphAttributes.normal,Tt=!!Ye.morphAttributes.color;let St=Td;Xe.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(St=S.toneMapping);const vt=Ye.morphAttributes.position||Ye.morphAttributes.normal||Ye.morphAttributes.color,xe=vt!==void 0?vt.length:0,st=V.get(Xe),Ht=b.state.lights;if(te===!0&&(ae===!0||ue!==T)){const ti=ue===T&&Xe.id===R;ke.setState(Xe,ue,ti)}let It=!1;Xe.version===st.__version?(st.needsLights&&st.lightsStateVersion!==Ht.state.version||st.outputColorSpace!==we||Qe.isBatchedMesh&&st.batching===!1||!Qe.isBatchedMesh&&st.batching===!0||Qe.isInstancedMesh&&st.instancing===!1||!Qe.isInstancedMesh&&st.instancing===!0||Qe.isSkinnedMesh&&st.skinning===!1||!Qe.isSkinnedMesh&&st.skinning===!0||Qe.isInstancedMesh&&st.instancingColor===!0&&Qe.instanceColor===null||Qe.isInstancedMesh&&st.instancingColor===!1&&Qe.instanceColor!==null||st.envMap!==Ie||Xe.fog===!0&&st.fog!==At||st.numClippingPlanes!==void 0&&(st.numClippingPlanes!==ke.numPlanes||st.numIntersection!==ke.numIntersection)||st.vertexAlphas!==Le||st.vertexTangents!==Re||st.morphTargets!==ut||st.morphNormals!==_t||st.morphColors!==Tt||st.toneMapping!==St||z.isWebGL2===!0&&st.morphTargetsCount!==xe)&&(It=!0):(It=!0,st.__version=Xe.version);let on=st.currentProgram;It===!0&&(on=$r(Xe,Be,Qe));let un=!1,Gt=!1,Wt=!1;const dn=on.getUniforms(),fn=st.uniforms;if(W.useProgram(on.program)&&(un=!0,Gt=!0,Wt=!0),Xe.id!==R&&(R=Xe.id,Gt=!0),un||T!==ue){dn.setValue(ne,"projectionMatrix",ue.projectionMatrix),dn.setValue(ne,"viewMatrix",ue.matrixWorldInverse);const ti=dn.map.cameraPosition;ti!==void 0&&ti.setValue(ne,ge.setFromMatrixPosition(ue.matrixWorld)),z.logarithmicDepthBuffer&&dn.setValue(ne,"logDepthBufFC",2/(Math.log(ue.far+1)/Math.LN2)),(Xe.isMeshPhongMaterial||Xe.isMeshToonMaterial||Xe.isMeshLambertMaterial||Xe.isMeshBasicMaterial||Xe.isMeshStandardMaterial||Xe.isShaderMaterial)&&dn.setValue(ne,"isOrthographic",ue.isOrthographicCamera===!0),T!==ue&&(T=ue,Gt=!0,Wt=!0)}if(Qe.isSkinnedMesh){dn.setOptional(ne,Qe,"bindMatrix"),dn.setOptional(ne,Qe,"bindMatrixInverse");const ti=Qe.skeleton;ti&&(z.floatVertexTextures?(ti.boneTexture===null&&ti.computeBoneTexture(),dn.setValue(ne,"boneTexture",ti.boneTexture,Q)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}Qe.isBatchedMesh&&(dn.setOptional(ne,Qe,"batchingTexture"),dn.setValue(ne,"batchingTexture",Qe._matricesTexture,Q));const Hr=Ye.morphAttributes;if((Hr.position!==void 0||Hr.normal!==void 0||Hr.color!==void 0&&z.isWebGL2===!0)&&ht.update(Qe,Ye,on),(Gt||st.receiveShadow!==Qe.receiveShadow)&&(st.receiveShadow=Qe.receiveShadow,dn.setValue(ne,"receiveShadow",Qe.receiveShadow)),Xe.isMeshGouraudMaterial&&Xe.envMap!==null&&(fn.envMap.value=Ie,fn.flipEnvMap.value=Ie.isCubeTexture&&Ie.isRenderTargetTexture===!1?-1:1),Gt&&(dn.setValue(ne,"toneMappingExposure",S.toneMappingExposure),st.needsLights&&en(fn,Wt),At&&Xe.fog===!0&&ye.refreshFogUniforms(fn,At),ye.refreshMaterialUniforms(fn,Xe,q,Y,de),Y1.upload(ne,Tr(st),fn,Q)),Xe.isShaderMaterial&&Xe.uniformsNeedUpdate===!0&&(Y1.upload(ne,Tr(st),fn,Q),Xe.uniformsNeedUpdate=!1),Xe.isSpriteMaterial&&dn.setValue(ne,"center",Qe.center),dn.setValue(ne,"modelViewMatrix",Qe.modelViewMatrix),dn.setValue(ne,"normalMatrix",Qe.normalMatrix),dn.setValue(ne,"modelMatrix",Qe.matrixWorld),Xe.isShaderMaterial||Xe.isRawShaderMaterial){const ti=Xe.uniformsGroups;for(let Wn=0,Po=ti.length;Wn<Po;Wn++)if(z.isWebGL2){const Xn=ti[Wn];Je.update(Xn,on),Je.bind(Xn,on)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return on}function en(ue,Be){ue.ambientLightColor.needsUpdate=Be,ue.lightProbe.needsUpdate=Be,ue.directionalLights.needsUpdate=Be,ue.directionalLightShadows.needsUpdate=Be,ue.pointLights.needsUpdate=Be,ue.pointLightShadows.needsUpdate=Be,ue.spotLights.needsUpdate=Be,ue.spotLightShadows.needsUpdate=Be,ue.rectAreaLights.needsUpdate=Be,ue.hemisphereLights.needsUpdate=Be}function wn(ue){return ue.isMeshLambertMaterial||ue.isMeshToonMaterial||ue.isMeshPhongMaterial||ue.isMeshStandardMaterial||ue.isShadowMaterial||ue.isShaderMaterial&&ue.lights===!0}this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(ue,Be,Ye){V.get(ue.texture).__webglTexture=Be,V.get(ue.depthTexture).__webglTexture=Ye;const Xe=V.get(ue);Xe.__hasExternalTextures=!0,Xe.__hasExternalTextures&&(Xe.__autoAllocateDepthBuffer=Ye===void 0,Xe.__autoAllocateDepthBuffer||$.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),Xe.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(ue,Be){const Ye=V.get(ue);Ye.__webglFramebuffer=Be,Ye.__useDefaultFramebuffer=Be===void 0},this.setRenderTarget=function(ue,Be=0,Ye=0){C=ue,E=Be,k=Ye;let Xe=!0,Qe=null,At=!1,ce=!1;if(ue){const Ie=V.get(ue);Ie.__useDefaultFramebuffer!==void 0?(W.bindFramebuffer(ne.FRAMEBUFFER,null),Xe=!1):Ie.__webglFramebuffer===void 0?Q.setupRenderTarget(ue):Ie.__hasExternalTextures&&Q.rebindTextures(ue,V.get(ue.texture).__webglTexture,V.get(ue.depthTexture).__webglTexture);const Le=ue.texture;(Le.isData3DTexture||Le.isDataArrayTexture||Le.isCompressedArrayTexture)&&(ce=!0);const Re=V.get(ue).__webglFramebuffer;ue.isWebGLCubeRenderTarget?(Array.isArray(Re[Be])?Qe=Re[Be][Ye]:Qe=Re[Be],At=!0):z.isWebGL2&&ue.samples>0&&Q.useMultisampledRTT(ue)===!1?Qe=V.get(ue).__webglMultisampledFramebuffer:Array.isArray(Re)?Qe=Re[Ye]:Qe=Re,P.copy(ue.viewport),F.copy(ue.scissor),L=ue.scissorTest}else P.copy(oe).multiplyScalar(q).floor(),F.copy(B).multiplyScalar(q).floor(),L=G;if(W.bindFramebuffer(ne.FRAMEBUFFER,Qe)&&z.drawBuffers&&Xe&&W.drawBuffers(ue,Qe),W.viewport(P),W.scissor(F),W.setScissorTest(L),At){const Ie=V.get(ue.texture);ne.framebufferTexture2D(ne.FRAMEBUFFER,ne.COLOR_ATTACHMENT0,ne.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Ie.__webglTexture,Ye)}else if(ce){const Ie=V.get(ue.texture),Le=Be||0;ne.framebufferTextureLayer(ne.FRAMEBUFFER,ne.COLOR_ATTACHMENT0,Ie.__webglTexture,Ye||0,Le)}R=-1},this.readRenderTargetPixels=function(ue,Be,Ye,Xe,Qe,At,ce){if(!(ue&&ue.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let we=V.get(ue).__webglFramebuffer;if(ue.isWebGLCubeRenderTarget&&ce!==void 0&&(we=we[ce]),we){W.bindFramebuffer(ne.FRAMEBUFFER,we);try{const Ie=ue.texture,Le=Ie.format,Re=Ie.type;if(Le!==xo&&rt.convert(Le)!==ne.getParameter(ne.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ut=Re===C0&&($.has("EXT_color_buffer_half_float")||z.isWebGL2&&$.has("EXT_color_buffer_float"));if(Re!==Cd&&rt.convert(Re)!==ne.getParameter(ne.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Re===$c&&(z.isWebGL2||$.has("OES_texture_float")||$.has("WEBGL_color_buffer_float")))&&!ut){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Be>=0&&Be<=ue.width-Xe&&Ye>=0&&Ye<=ue.height-Qe&&ne.readPixels(Be,Ye,Xe,Qe,rt.convert(Le),rt.convert(Re),At)}finally{const Ie=C!==null?V.get(C).__webglFramebuffer:null;W.bindFramebuffer(ne.FRAMEBUFFER,Ie)}}},this.copyFramebufferToTexture=function(ue,Be,Ye=0){const Xe=Math.pow(2,-Ye),Qe=Math.floor(Be.image.width*Xe),At=Math.floor(Be.image.height*Xe);Q.setTexture2D(Be,0),ne.copyTexSubImage2D(ne.TEXTURE_2D,Ye,0,0,ue.x,ue.y,Qe,At),W.unbindTexture()},this.copyTextureToTexture=function(ue,Be,Ye,Xe=0){const Qe=Be.image.width,At=Be.image.height,ce=rt.convert(Ye.format),we=rt.convert(Ye.type);Q.setTexture2D(Ye,0),ne.pixelStorei(ne.UNPACK_FLIP_Y_WEBGL,Ye.flipY),ne.pixelStorei(ne.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ye.premultiplyAlpha),ne.pixelStorei(ne.UNPACK_ALIGNMENT,Ye.unpackAlignment),Be.isDataTexture?ne.texSubImage2D(ne.TEXTURE_2D,Xe,ue.x,ue.y,Qe,At,ce,we,Be.image.data):Be.isCompressedTexture?ne.compressedTexSubImage2D(ne.TEXTURE_2D,Xe,ue.x,ue.y,Be.mipmaps[0].width,Be.mipmaps[0].height,ce,Be.mipmaps[0].data):ne.texSubImage2D(ne.TEXTURE_2D,Xe,ue.x,ue.y,ce,we,Be.image),Xe===0&&Ye.generateMipmaps&&ne.generateMipmap(ne.TEXTURE_2D),W.unbindTexture()},this.copyTextureToTexture3D=function(ue,Be,Ye,Xe,Qe=0){if(S.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const At=ue.max.x-ue.min.x+1,ce=ue.max.y-ue.min.y+1,we=ue.max.z-ue.min.z+1,Ie=rt.convert(Xe.format),Le=rt.convert(Xe.type);let Re;if(Xe.isData3DTexture)Q.setTexture3D(Xe,0),Re=ne.TEXTURE_3D;else if(Xe.isDataArrayTexture)Q.setTexture2DArray(Xe,0),Re=ne.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ne.pixelStorei(ne.UNPACK_FLIP_Y_WEBGL,Xe.flipY),ne.pixelStorei(ne.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Xe.premultiplyAlpha),ne.pixelStorei(ne.UNPACK_ALIGNMENT,Xe.unpackAlignment);const ut=ne.getParameter(ne.UNPACK_ROW_LENGTH),_t=ne.getParameter(ne.UNPACK_IMAGE_HEIGHT),Tt=ne.getParameter(ne.UNPACK_SKIP_PIXELS),St=ne.getParameter(ne.UNPACK_SKIP_ROWS),vt=ne.getParameter(ne.UNPACK_SKIP_IMAGES),xe=Ye.isCompressedTexture?Ye.mipmaps[0]:Ye.image;ne.pixelStorei(ne.UNPACK_ROW_LENGTH,xe.width),ne.pixelStorei(ne.UNPACK_IMAGE_HEIGHT,xe.height),ne.pixelStorei(ne.UNPACK_SKIP_PIXELS,ue.min.x),ne.pixelStorei(ne.UNPACK_SKIP_ROWS,ue.min.y),ne.pixelStorei(ne.UNPACK_SKIP_IMAGES,ue.min.z),Ye.isDataTexture||Ye.isData3DTexture?ne.texSubImage3D(Re,Qe,Be.x,Be.y,Be.z,At,ce,we,Ie,Le,xe.data):Ye.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ne.compressedTexSubImage3D(Re,Qe,Be.x,Be.y,Be.z,At,ce,we,Ie,xe.data)):ne.texSubImage3D(Re,Qe,Be.x,Be.y,Be.z,At,ce,we,Ie,Le,xe),ne.pixelStorei(ne.UNPACK_ROW_LENGTH,ut),ne.pixelStorei(ne.UNPACK_IMAGE_HEIGHT,_t),ne.pixelStorei(ne.UNPACK_SKIP_PIXELS,Tt),ne.pixelStorei(ne.UNPACK_SKIP_ROWS,St),ne.pixelStorei(ne.UNPACK_SKIP_IMAGES,vt),Qe===0&&Xe.generateMipmaps&&ne.generateMipmap(Re),W.unbindTexture()},this.initTexture=function(ue){ue.isCubeTexture?Q.setTextureCube(ue,0):ue.isData3DTexture?Q.setTexture3D(ue,0):ue.isDataArrayTexture||ue.isCompressedArrayTexture?Q.setTexture2DArray(ue,0):Q.setTexture2D(ue,0),W.unbindTexture()},this.resetState=function(){E=0,k=0,C=null,W.reset(),qe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Cl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===CO?"display-p3":"srgb",n.unpackColorSpace=lr.workingColorSpace===zM?"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===fa?df:vJ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===df?fa:cu}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 Yze extends XP{}Yze.prototype.isWebGL1Renderer=!0;class OO{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new Qt(e),this.near=n,this.far=r}clone(){return new OO(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Qze extends Va{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 Zze{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=GP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Xc()}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=Xc()),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=Xc()),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 La=new ze;class xd{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++)La.fromBufferAttribute(this,n),La.applyMatrix4(e),this.setXYZ(n,La.x,La.y,La.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)La.fromBufferAttribute(this,n),La.applyNormalMatrix(e),this.setXYZ(n,La.x,La.y,La.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)La.fromBufferAttribute(this,n),La.transformDirection(e),this.setXYZ(n,La.x,La.y,La.z);return this}setX(e,n){return this.normalized&&(n=or(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=or(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=or(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=or(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=Nl(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=Nl(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=Nl(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=Nl(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=or(n,this.array),r=or(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=or(n,this.array),r=or(r,this.array),i=or(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=or(n,this.array),r=or(r,this.array),i=or(i,this.array),a=or(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 $s(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 xd(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 Jze extends ps{constructor(e=null,n=1,r=1,i,a,o,l,c,u=ha,d=ha,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 eBe(t,e){return t.z-e.z}function tBe(t,e){return e.z-t.z}class nBe{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 hp="batchId",Qu=new vr,D7=new vr,rBe=new vr,O7=new vr,Ek=new BM,s1=new So,kh=new Pl,ub=new ze,Ak=new nBe,Na=new Xo,o1=[];function iBe(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 aBe extends Xo{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new Ra,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 Jze(n,e,e,xo,$c);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),g=new c.constructor(m,d,f);g.setUsage(c.usage),n.setAttribute(l,g)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new $s(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(hp,new $s(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(hp))throw new Error(`BatchedMesh: Geometry cannot use attribute "${hp}"`);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===hp)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 So);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,Qu),this.getBoundingBoxAt(i,s1).applyMatrix4(Qu),n.union(s1))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Pl);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,Qu),this.getBoundingSphereAt(i,kh).applyMatrix4(Qu),n.union(kh))}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,g=this._matricesTexture,x=this._matricesTexture.image.data;f.push(!0),m.push(!0);const y=this._geometryCount;this._geometryCount++,rBe.toArray(x,y*16),g.needsUpdate=!0,o.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new So,sphereInitialized:!1,sphere:new Pl});const b=this.geometry.getAttribute(hp);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 g in r.attributes){if(g===hp)continue;const x=n.getAttribute(g),y=r.getAttribute(g);iBe(x,y,c);const b=x.itemSize;for(let v=x.count,M=u;v<M;v++){const S=c+v;for(let A=0;A<b;A++)y.setComponent(S,A,0)}y.needsUpdate=!0}if(i){const g=l.indexStart;for(let x=0;x<o.count;x++)a.setX(g+x,c+o.getX(x));for(let x=o.count,y=l.indexCount;x<y;x++)a.setX(g+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(ub.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,s1),s1.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 g=f;l&&(g=l.getX(g)),ub.fromBufferAttribute(c,g),d=Math.max(d,a.center.distanceToSquared(ub))}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;Na.material=this.material,Na.geometry.index=c.index,Na.geometry.attributes=c.attributes,Na.geometry.boundingBox===null&&(Na.geometry.boundingBox=new So),Na.geometry.boundingSphere===null&&(Na.geometry.boundingSphere=new Pl);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=a[u];Na.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,Na.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,Na.geometry.boundingBox),this.getBoundingSphereAt(u,Na.geometry.boundingSphere),Na.raycast(e,o1);for(let f=0,m=o1.length;f<m;f++){const g=o1[f];g.object=this,g.batchId=u,n.push(g)}o1.length=0}Na.material=null,Na.geometry.index=null,Na.geometry.attributes={},Na.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&&(O7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),Ek.setFromProjectionMatrix(O7,e.isWebGPURenderer?k0:Cl));let g=0;if(this.sortObjects){D7.copy(this.matrixWorld).invert(),ub.setFromMatrixPosition(r.matrixWorld).applyMatrix4(D7);for(let b=0,v=c.length;b<v;b++)if(c[b]){this.getMatrixAt(b,Qu),this.getBoundingSphereAt(b,kh).applyMatrix4(Qu);let M=!1;if(m&&(M=!Ek.intersectsSphere(kh)),!M){const S=ub.distanceTo(kh.center);Ak.push(f[b],S)}}const x=Ak.list,y=this.customSort;y===null?x.sort(a.transparent?tBe:eBe):y.call(this,x,r);for(let b=0,v=x.length;b<v;b++){const M=x[b];u[g]=M.start*l,d[g]=M.count,g++}Ak.reset()}else for(let x=0,y=c.length;x<y;x++)if(c[x]){let b=!1;if(m&&(this.getMatrixAt(x,Qu),this.getBoundingSphereAt(x,kh).applyMatrix4(Qu),b=!Ek.intersectsSphere(kh)),!b){const v=f[x];u[g]=v.start*l,d[g]=v.count,g++}}this._multiDrawCount=g,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,o){this.onBeforeRender(e,null,i,a,o)}}class Ty extends qg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Qt(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 L7=new ze,I7=new ze,F7=new vr,Tk=new jO,l1=new Pl;class sBe extends Va{constructor(e=new Ra,n=new Ty){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++)L7.fromBufferAttribute(n,i-1),I7.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=L7.distanceTo(I7);e.setAttribute("lineDistance",new si(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(),l1.copy(r.boundingSphere),l1.applyMatrix4(i),l1.radius+=a,e.ray.intersectsSphere(l1)===!1)return;F7.copy(i).invert(),Tk.copy(e.ray).applyMatrix4(F7);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new ze,d=new ze,f=new ze,m=new ze,g=this.isLineSegments?2:1,x=r.index,b=r.attributes.position;if(x!==null){const v=Math.max(0,o.start),M=Math.min(x.count,o.start+o.count);for(let S=v,A=M-1;S<A;S+=g){const E=x.getX(S),k=x.getX(S+1);if(u.fromBufferAttribute(b,E),d.fromBufferAttribute(b,k),Tk.distanceSqToSegment(u,d,m,f)>c)continue;m.applyMatrix4(this.matrixWorld);const R=e.ray.origin.distanceTo(m);R<e.near||R>e.far||n.push({distance:R,point:f.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,o.start),M=Math.min(b.count,o.start+o.count);for(let S=v,A=M-1;S<A;S+=g){if(u.fromBufferAttribute(b,S),d.fromBufferAttribute(b,S+1),Tk.distanceSqToSegment(u,d,m,f)>c)continue;m.applyMatrix4(this.matrixWorld);const k=e.ray.origin.distanceTo(m);k<e.near||k>e.far||n.push({distance:k,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 U7=new ze,z7=new ze;class HM extends sBe{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)U7.fromBufferAttribute(n,i),z7.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+U7.distanceTo(z7);e.setAttribute("lineDistance",new si(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class oBe extends Ra{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new ze,a=new ze;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,g=f.count;for(let x=m,y=m+g;x<y;x+=3)for(let b=0;b<3;b++){const v=l.getX(x+b),M=l.getX(x+(b+1)%3);i.fromBufferAttribute(o,v),a.fromBufferAttribute(o,M),B7(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),B7(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new si(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function B7(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 lBe extends qg{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Qt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Qt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=_J,this.normalScale=new cn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=AO,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 cBe extends Ty{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 HJ extends Va{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Qt(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 Ck=new vr,$7=new ze,H7=new ze;class uBe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new cn(512,512),this.map=null,this.mapPass=null,this.matrix=new vr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new BM,this._frameExtents=new cn(1,1),this._viewportCount=1,this._viewports=[new ur(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;$7.setFromMatrixPosition(e.matrixWorld),n.position.copy($7),H7.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(H7),n.updateMatrixWorld(),Ck.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ck),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(Ck)}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 V7=new vr,db=new ze,kk=new ze;class dBe extends uBe{constructor(){super(new Ds(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new cn(4,2),this._viewportCount=6,this._viewports=[new ur(2,1,1,1),new ur(0,1,1,1),new ur(3,1,1,1),new ur(1,1,1,1),new ur(3,0,1,1),new ur(1,0,1,1)],this._cubeDirections=[new ze(1,0,0),new ze(-1,0,0),new ze(0,0,1),new ze(0,0,-1),new ze(0,1,0),new ze(0,-1,0)],this._cubeUps=[new ze(0,1,0),new ze(0,1,0),new ze(0,1,0),new ze(0,1,0),new ze(0,0,1),new ze(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()),db.setFromMatrixPosition(e.matrixWorld),r.position.copy(db),kk.copy(r.position),kk.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(kk),r.updateMatrixWorld(),i.makeTranslation(-db.x,-db.y,-db.z),V7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(V7)}}class hBe extends HJ{constructor(e,n,r=0,i=2){super(e,n),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new dBe}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,n){return super.copy(e,n),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class fBe extends HJ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class mBe extends Ra{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 YP extends Zze{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 G7{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(ma(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const W7=new ze,c1=new ze;class pBe{constructor(e=new ze,n=new ze){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){W7.subVectors(e,this.start),c1.subVectors(this.end,this.start);const r=c1.dot(c1);let a=c1.dot(W7)/r;return n&&(a=ma(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 gBe extends HM{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 Ra;i.setAttribute("position",new si(n,3)),i.setAttribute("color",new si(r,3));const a=new Ty({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new Qt,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:FM}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=FM);class Rl{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"),Rl.nextNameID=Rl.nextNameID||0,this.$name.id=`lil-gui-name-${++Rl.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 xBe extends Rl{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 QP(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 bBe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:QP,toHexString:QP},P0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},yBe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=P0.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 P0.toHexString(i)}},vBe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=P0.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 P0.toHexString(i)}},_Be=[bBe,P0,yBe,vBe];function wBe(t){return _Be.find(e=>e.match(t))}class SBe extends Rl{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=wBe(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=QP(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 jk extends Rl{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 MBe extends Rl{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 M=parseFloat(this.$input.value);isNaN(M)||(this._stepExplicit&&(M=this._snap(M)),this.setValue(this._clamp(M)))},r=M=>{const S=parseFloat(this.$input.value);isNaN(S)||(this._snapClampSetValue(S+M),this.$input.value=this.getValue())},i=M=>{M.key==="Enter"&&this.$input.blur(),M.code==="ArrowUp"&&(M.preventDefault(),r(this._step*this._arrowKeyMultiplier(M))),M.code==="ArrowDown"&&(M.preventDefault(),r(this._step*this._arrowKeyMultiplier(M)*-1))},a=M=>{this._inputFocused&&(M.preventDefault(),r(this._step*this._normalizeMouseWheel(M)))};let o=!1,l,c,u,d,f;const m=5,g=M=>{l=M.clientX,c=u=M.clientY,o=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",y)},x=M=>{if(o){const S=M.clientX-l,A=M.clientY-c;Math.abs(A)>m?(M.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(S)>m&&y()}if(!o){const S=M.clientY-u;f-=S*this._step*this._arrowKeyMultiplier(M),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=M.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",g),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,M,S,A,E)=>(v-M)/(S-M)*(E-A)+A,n=v=>{const M=this.$slider.getBoundingClientRect();let S=e(v,M.left,M.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 M=v.touches[0].clientX-l,S=v.touches[0].clientY-c;Math.abs(M)>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)},g=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(g,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 NBe extends Rl{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 EBe extends Rl{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 ABe=`.lil-gui {
- font-family: var(--font-family);
- font-size: var(--font-size);
- line-height: 1;
- font-weight: normal;
- font-style: normal;
- text-align: left;
- color: var(--text-color);
- user-select: none;
- -webkit-user-select: none;
- touch-action: manipulation;
- --background-color: #1f1f1f;
- --text-color: #ebebeb;
- --title-background-color: #111111;
- --title-text-color: #ebebeb;
- --widget-color: #424242;
- --hover-color: #4f4f4f;
- --focus-color: #595959;
- --number-color: #2cc9ff;
- --string-color: #a2db3c;
- --font-size: 11px;
- --input-font-size: 11px;
- --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
- --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
- --padding: 4px;
- --spacing: 4px;
- --widget-height: 20px;
- --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
- --name-width: 45%;
- --slider-knob-width: 2px;
- --slider-input-width: 27%;
- --color-input-width: 27%;
- --slider-input-min-width: 45px;
- --color-input-min-width: 45px;
- --folder-indent: 7px;
- --widget-padding: 0 0 0 3px;
- --widget-border-radius: 2px;
- --checkbox-size: calc(0.75 * var(--widget-height));
- --scrollbar-width: 5px;
- }
- .lil-gui, .lil-gui * {
- box-sizing: border-box;
- margin: 0;
- padding: 0;
- }
- .lil-gui.root {
- width: var(--width, 245px);
- display: flex;
- flex-direction: column;
- background: var(--background-color);
- }
- .lil-gui.root > .title {
- background: var(--title-background-color);
- color: var(--title-text-color);
- }
- .lil-gui.root > .children {
- overflow-x: hidden;
- overflow-y: auto;
- }
- .lil-gui.root > .children::-webkit-scrollbar {
- width: var(--scrollbar-width);
- height: var(--scrollbar-width);
- background: var(--background-color);
- }
- .lil-gui.root > .children::-webkit-scrollbar-thumb {
- border-radius: var(--scrollbar-width);
- background: var(--focus-color);
- }
- @media (pointer: coarse) {
- .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- }
- .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- .lil-gui.autoPlace {
- max-height: 100%;
- position: fixed;
- top: 0;
- right: 15px;
- z-index: 1001;
- }
- .lil-gui .controller {
- display: flex;
- align-items: center;
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- }
- .lil-gui .controller.disabled {
- opacity: 0.5;
- }
- .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
- pointer-events: none !important;
- }
- .lil-gui .controller > .name {
- min-width: var(--name-width);
- flex-shrink: 0;
- white-space: pre;
- padding-right: var(--spacing);
- line-height: var(--widget-height);
- }
- .lil-gui .controller .widget {
- position: relative;
- display: flex;
- align-items: center;
- width: 100%;
- min-height: var(--widget-height);
- }
- .lil-gui .controller.string input {
- color: var(--string-color);
- }
- .lil-gui .controller.boolean {
- cursor: pointer;
- }
- .lil-gui .controller.color .display {
- width: 100%;
- height: var(--widget-height);
- border-radius: var(--widget-border-radius);
- position: relative;
- }
- @media (hover: hover) {
- .lil-gui .controller.color .display:hover:before {
- content: " ";
- display: block;
- position: absolute;
- border-radius: var(--widget-border-radius);
- border: 1px solid #fff9;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- }
- }
- .lil-gui .controller.color input[type=color] {
- opacity: 0;
- width: 100%;
- height: 100%;
- cursor: pointer;
- }
- .lil-gui .controller.color input[type=text] {
- margin-left: var(--spacing);
- font-family: var(--font-family-mono);
- min-width: var(--color-input-min-width);
- width: var(--color-input-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.option select {
- opacity: 0;
- position: absolute;
- width: 100%;
- max-width: 100%;
- }
- .lil-gui .controller.option .display {
- position: relative;
- pointer-events: none;
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- line-height: var(--widget-height);
- max-width: 100%;
- overflow: hidden;
- word-break: break-all;
- padding-left: 0.55em;
- padding-right: 1.75em;
- background: var(--widget-color);
- }
- @media (hover: hover) {
- .lil-gui .controller.option .display.focus {
- background: var(--focus-color);
- }
- }
- .lil-gui .controller.option .display.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.option .display:after {
- font-family: "lil-gui";
- content: "↕";
- position: absolute;
- top: 0;
- right: 0;
- bottom: 0;
- padding-right: 0.375em;
- }
- .lil-gui .controller.option .widget,
- .lil-gui .controller.option select {
- cursor: pointer;
- }
- @media (hover: hover) {
- .lil-gui .controller.option .widget:hover .display {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number input {
- color: var(--number-color);
- }
- .lil-gui .controller.number.hasSlider input {
- margin-left: var(--spacing);
- width: var(--slider-input-width);
- min-width: var(--slider-input-min-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.number .slider {
- width: 100%;
- height: var(--widget-height);
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- padding-right: var(--slider-knob-width);
- overflow: hidden;
- cursor: ew-resize;
- touch-action: pan-y;
- }
- @media (hover: hover) {
- .lil-gui .controller.number .slider:hover {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number .slider.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.number .slider.active .fill {
- opacity: 0.95;
- }
- .lil-gui .controller.number .fill {
- height: 100%;
- border-right: var(--slider-knob-width) solid var(--number-color);
- box-sizing: content-box;
- }
- .lil-gui-dragging .lil-gui {
- --hover-color: var(--widget-color);
- }
- .lil-gui-dragging * {
- cursor: ew-resize !important;
- }
- .lil-gui-dragging.lil-gui-vertical * {
- cursor: ns-resize !important;
- }
- .lil-gui .title {
- height: var(--title-height);
- line-height: calc(var(--title-height) - 4px);
- font-weight: 600;
- padding: 0 var(--padding);
- -webkit-tap-highlight-color: transparent;
- cursor: pointer;
- outline: none;
- text-decoration-skip: objects;
- }
- .lil-gui .title:before {
- font-family: "lil-gui";
- content: "▾";
- padding-right: 2px;
- display: inline-block;
- }
- .lil-gui .title:active {
- background: var(--title-background-color);
- opacity: 0.75;
- }
- @media (hover: hover) {
- body:not(.lil-gui-dragging) .lil-gui .title:hover {
- background: var(--title-background-color);
- opacity: 0.85;
- }
- .lil-gui .title:focus {
- text-decoration: underline var(--focus-color);
- }
- }
- .lil-gui.root > .title:focus {
- text-decoration: none !important;
- }
- .lil-gui.closed > .title:before {
- content: "▸";
- }
- .lil-gui.closed > .children {
- transform: translateY(-7px);
- opacity: 0;
- }
- .lil-gui.closed:not(.transition) > .children {
- display: none;
- }
- .lil-gui.transition > .children {
- transition-duration: 300ms;
- transition-property: height, opacity, transform;
- transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
- overflow: hidden;
- pointer-events: none;
- }
- .lil-gui .children:empty:before {
- content: "Empty";
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- display: block;
- height: var(--widget-height);
- font-style: italic;
- line-height: var(--widget-height);
- opacity: 0.5;
- }
- .lil-gui.root > .children > .lil-gui > .title {
- border: 0 solid var(--widget-color);
- border-width: 1px 0;
- transition: border-color 300ms;
- }
- .lil-gui.root > .children > .lil-gui.closed > .title {
- border-bottom-color: transparent;
- }
- .lil-gui + .controller {
- border-top: 1px solid var(--widget-color);
- margin-top: 0;
- padding-top: var(--spacing);
- }
- .lil-gui .lil-gui .lil-gui > .title {
- border: none;
- }
- .lil-gui .lil-gui .lil-gui > .children {
- border: none;
- margin-left: var(--folder-indent);
- border-left: 2px solid var(--widget-color);
- }
- .lil-gui .lil-gui .controller {
- border: none;
- }
- .lil-gui label, .lil-gui input, .lil-gui button {
- -webkit-tap-highlight-color: transparent;
- }
- .lil-gui input {
- border: 0;
- outline: none;
- font-family: var(--font-family);
- font-size: var(--input-font-size);
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- background: var(--widget-color);
- color: var(--text-color);
- width: 100%;
- }
- @media (hover: hover) {
- .lil-gui input:hover {
- background: var(--hover-color);
- }
- .lil-gui input:active {
- background: var(--focus-color);
- }
- }
- .lil-gui input:disabled {
- opacity: 1;
- }
- .lil-gui input[type=text],
- .lil-gui input[type=number] {
- padding: var(--widget-padding);
- -moz-appearance: textfield;
- }
- .lil-gui input[type=text]:focus,
- .lil-gui input[type=number]:focus {
- background: var(--focus-color);
- }
- .lil-gui input[type=checkbox] {
- appearance: none;
- width: var(--checkbox-size);
- height: var(--checkbox-size);
- border-radius: var(--widget-border-radius);
- text-align: center;
- cursor: pointer;
- }
- .lil-gui input[type=checkbox]:checked:before {
- font-family: "lil-gui";
- content: "✓";
- font-size: var(--checkbox-size);
- line-height: var(--checkbox-size);
- }
- @media (hover: hover) {
- .lil-gui input[type=checkbox]:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button {
- outline: none;
- cursor: pointer;
- font-family: var(--font-family);
- font-size: var(--font-size);
- color: var(--text-color);
- width: 100%;
- height: var(--widget-height);
- text-transform: none;
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- border: none;
- }
- @media (hover: hover) {
- .lil-gui button:hover {
- background: var(--hover-color);
- }
- .lil-gui button:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button:active {
- background: var(--focus-color);
- }
- @font-face {
- font-family: "lil-gui";
- src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff");
- }`;function TBe(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 q7=!1;class NS{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"),!q7&&l&&(TBe(ABe),q7=!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 NBe(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new MBe(this,e,n,r,i,a);case"boolean":return new xBe(this,e,n);case"string":return new EBe(this,e,n);case"function":return new jk(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,o)}addColor(e,n,r=1){return new SBe(this,e,n,r)}addFolder(e){const n=new NS({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof jk||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 jk)){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 Pk(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 LO{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 LO(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 IO{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class K7 extends IO{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Zu extends IO{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class X7{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class ES{constructor(e){this.lines=[],this.preamble=new X7(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){const n=Array.isArray(e)?e:e.split(`
- `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((a=>a.comment))).thumbnails;for(const[a,o]of Object.entries(i))this.metadata.thumbnails[a]=o;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var r;const i=e.trim().split(";"),a=i[0],o=n&&i[1]||void 0,l=a.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),c=l.length?`${(r=l[0])===null||r===void 0?void 0:r.toLowerCase()}${l[1]}`:"",u=this.parseParams(l.slice(2));switch(c){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new K7(e,c,u,o);case"t0":return new Zu(e,c,o,0);case"t1":return new Zu(e,c,o,1);case"t2":return new Zu(e,c,o,2);case"t3":return new Zu(e,c,o,3);case"t4":return new Zu(e,c,o,4);case"t5":return new Zu(e,c,o,5);case"t6":return new Zu(e,c,o,6);case"t7":return new Zu(e,c,o,7);default:return new IO(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 K7){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 X7(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=LO.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}}}ES.prototype.parseGcode=ES.prototype.parseGCode;const Y7={type:"change"},Rk={type:"start"},Q7={type:"end"},u1=new jO,Z7=new ad,CBe=Math.cos(70*SJ.DEG2RAD);class kBe extends Xf{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new ze,this.cursor=new ze,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:Km.ROTATE,MIDDLE:Km.DOLLY,RIGHT:Km.PAN},this.touches={ONE:Xm.ROTATE,TWO:Xm.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(z){z.addEventListener("keydown",je),this._domElementKeyEvents=z},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",je),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(Y7),r.update(),a=i.NONE},this.update=(function(){const z=new ze,W=new If().setFromUnitVectors(e.up,new ze(0,1,0)),U=W.clone().invert(),V=new ze,Q=new If,Ee=new ze,Ce=2*Math.PI;return function(Ne=null){const H=r.object.position;z.copy(H).sub(r.target),z.applyQuaternion(W),l.setFromVector3(z),r.autoRotate&&a===i.NONE&&P((function(_e){return _e!==null?2*Math.PI/60*r.autoRotateSpeed*_e:2*Math.PI/60/60*r.autoRotateSpeed})(Ne)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let O=r.minAzimuthAngle,ie=r.maxAzimuthAngle;isFinite(O)&&isFinite(ie)&&(O<-Math.PI?O+=Ce:O>Math.PI&&(O-=Ce),ie<-Math.PI?ie+=Ce:ie>Math.PI&&(ie-=Ce),l.theta=O<=ie?Math.max(O,Math.min(ie,l.theta)):l.theta>(O+ie)/2?Math.max(O,l.theta):Math.min(ie,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&&k||r.object.isOrthographicCamera?l.radius=Z(l.radius):l.radius=Z(l.radius*u),z.setFromSpherical(l),z.applyQuaternion(U),H.copy(r.target).add(z),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 ye=!1;if(r.zoomToCursor&&k){let _e=null;if(r.object.isPerspectiveCamera){const le=z.length();_e=Z(le*u);const ke=le-_e;r.object.position.addScaledVector(A,ke),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const le=new ze(E.x,E.y,0);le.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ye=!0;const ke=new ze(E.x,E.y,0);ke.unproject(r.object),r.object.position.sub(ke).add(le),r.object.updateMatrixWorld(),_e=z.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;_e!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(_e).add(r.object.position):(u1.origin.copy(r.object.position),u1.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(u1.direction))<CBe?e.lookAt(r.target):(Z7.setFromNormalAndCoplanarPoint(r.object.up,r.target),u1.intersectPlane(Z7,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ye=!0);return u=1,k=!1,!!(ye||V.distanceToSquared(r.object.position)>o||8*(1-Q.dot(r.object.quaternion))>o||Ee.distanceToSquared(r.target)>0)&&(r.dispatchEvent(Y7),V.copy(r.object.position),Q.copy(r.object.quaternion),Ee.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",ne),r.domElement.removeEventListener("pointerdown",fe),r.domElement.removeEventListener("pointercancel",ge),r.domElement.removeEventListener("wheel",Me),r.domElement.removeEventListener("pointermove",Ae),r.domElement.removeEventListener("pointerup",ge),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",je),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 G7,c=new G7;let u=1;const d=new ze,f=new cn,m=new cn,g=new cn,x=new cn,y=new cn,b=new cn,v=new cn,M=new cn,S=new cn,A=new ze,E=new cn;let k=!1;const C=[],R={};function T(){return Math.pow(.95,r.zoomSpeed)}function P(z){c.theta-=z}function F(z){c.phi-=z}const L=(function(){const z=new ze;return function(W,U){z.setFromMatrixColumn(U,0),z.multiplyScalar(-W),d.add(z)}})(),X=(function(){const z=new ze;return function(W,U){r.screenSpacePanning===!0?z.setFromMatrixColumn(U,1):(z.setFromMatrixColumn(U,0),z.crossVectors(r.object.up,z)),z.multiplyScalar(W),d.add(z)}})(),D=(function(){const z=new ze;return function(W,U){const V=r.domElement;if(r.object.isPerspectiveCamera){const Q=r.object.position;z.copy(Q).sub(r.target);let Ee=z.length();Ee*=Math.tan(r.object.fov/2*Math.PI/180),L(2*W*Ee/V.clientHeight,r.object.matrix),X(2*U*Ee/V.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(L(W*(r.object.right-r.object.left)/r.object.zoom/V.clientWidth,r.object.matrix),X(U*(r.object.top-r.object.bottom)/r.object.zoom/V.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function K(z){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=z:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function Y(z){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=z:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function q(z){if(!r.zoomToCursor)return;k=!0;const W=r.domElement.getBoundingClientRect(),U=z.clientX-W.left,V=z.clientY-W.top,Q=W.width,Ee=W.height;E.x=U/Q*2-1,E.y=-V/Ee*2+1,A.set(E.x,E.y,1).unproject(r.object).sub(r.object.position).normalize()}function Z(z){return Math.max(r.minDistance,Math.min(r.maxDistance,z))}function re(z){f.set(z.clientX,z.clientY)}function oe(z){x.set(z.clientX,z.clientY)}function B(){if(C.length===1)f.set(C[0].pageX,C[0].pageY);else{const z=.5*(C[0].pageX+C[1].pageX),W=.5*(C[0].pageY+C[1].pageY);f.set(z,W)}}function G(){if(C.length===1)x.set(C[0].pageX,C[0].pageY);else{const z=.5*(C[0].pageX+C[1].pageX),W=.5*(C[0].pageY+C[1].pageY);x.set(z,W)}}function J(){const z=C[0].pageX-C[1].pageX,W=C[0].pageY-C[1].pageY,U=Math.sqrt(z*z+W*W);v.set(0,U)}function te(z){if(C.length==1)m.set(z.pageX,z.pageY);else{const U=$(z),V=.5*(z.pageX+U.x),Q=.5*(z.pageY+U.y);m.set(V,Q)}g.subVectors(m,f).multiplyScalar(r.rotateSpeed);const W=r.domElement;P(2*Math.PI*g.x/W.clientHeight),F(2*Math.PI*g.y/W.clientHeight),f.copy(m)}function ae(z){if(C.length===1)y.set(z.pageX,z.pageY);else{const W=$(z),U=.5*(z.pageX+W.x),V=.5*(z.pageY+W.y);y.set(U,V)}b.subVectors(y,x).multiplyScalar(r.panSpeed),D(b.x,b.y),x.copy(y)}function de(z){const W=$(z),U=z.pageX-W.x,V=z.pageY-W.y,Q=Math.sqrt(U*U+V*V);M.set(0,Q),S.set(0,Math.pow(M.y/v.y,r.zoomSpeed)),K(S.y),v.copy(M)}function fe(z){r.enabled!==!1&&(C.length===0&&(r.domElement.setPointerCapture(z.pointerId),r.domElement.addEventListener("pointermove",Ae),r.domElement.addEventListener("pointerup",ge)),(function(W){C.push(W)})(z),z.pointerType==="touch"?(function(W){switch(Ke(W),C.length){case 1:switch(r.touches.ONE){case Xm.ROTATE:if(r.enableRotate===!1)return;B(),a=i.TOUCH_ROTATE;break;case Xm.PAN:if(r.enablePan===!1)return;G(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case Xm.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&J(),r.enablePan&&G(),a=i.TOUCH_DOLLY_PAN;break;case Xm.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&J(),r.enableRotate&&B(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(Rk)})(z):(function(W){let U;switch(W.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 Km.DOLLY:if(r.enableZoom===!1)return;(function(V){q(V),v.set(V.clientX,V.clientY)})(W),a=i.DOLLY;break;case Km.ROTATE:if(W.ctrlKey||W.metaKey||W.shiftKey){if(r.enablePan===!1)return;oe(W),a=i.PAN}else{if(r.enableRotate===!1)return;re(W),a=i.ROTATE}break;case Km.PAN:if(W.ctrlKey||W.metaKey||W.shiftKey){if(r.enableRotate===!1)return;re(W),a=i.ROTATE}else{if(r.enablePan===!1)return;oe(W),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(Rk)})(z))}function Ae(z){r.enabled!==!1&&(z.pointerType==="touch"?(function(W){switch(Ke(W),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;te(W),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;ae(W),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(U){r.enableZoom&&de(U),r.enablePan&&ae(U)})(W),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(U){r.enableZoom&&de(U),r.enableRotate&&te(U)})(W),r.update();break;default:a=i.NONE}})(z):(function(W){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function(U){m.set(U.clientX,U.clientY),g.subVectors(m,f).multiplyScalar(r.rotateSpeed);const V=r.domElement;P(2*Math.PI*g.x/V.clientHeight),F(2*Math.PI*g.y/V.clientHeight),f.copy(m),r.update()})(W);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(U){M.set(U.clientX,U.clientY),S.subVectors(M,v),S.y>0?K(T()):S.y<0&&Y(T()),v.copy(M),r.update()})(W);break;case i.PAN:if(r.enablePan===!1)return;(function(U){y.set(U.clientX,U.clientY),b.subVectors(y,x).multiplyScalar(r.panSpeed),D(b.x,b.y),x.copy(y),r.update()})(W)}})(z))}function ge(z){(function(W){delete R[W.pointerId];for(let U=0;U<C.length;U++)if(C[U].pointerId==W.pointerId)return void C.splice(U,1)})(z),C.length===0&&(r.domElement.releasePointerCapture(z.pointerId),r.domElement.removeEventListener("pointermove",Ae),r.domElement.removeEventListener("pointerup",ge)),r.dispatchEvent(Q7),a=i.NONE}function Me(z){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(z.preventDefault(),r.dispatchEvent(Rk),(function(W){q(W),W.deltaY<0?Y(T()):W.deltaY>0&&K(T()),r.update()})(z),r.dispatchEvent(Q7))}function je(z){r.enabled!==!1&&r.enablePan!==!1&&(function(W){let U=!1;switch(W.code){case r.keys.UP:W.ctrlKey||W.metaKey||W.shiftKey?F(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(0,r.keyPanSpeed),U=!0;break;case r.keys.BOTTOM:W.ctrlKey||W.metaKey||W.shiftKey?F(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(0,-r.keyPanSpeed),U=!0;break;case r.keys.LEFT:W.ctrlKey||W.metaKey||W.shiftKey?P(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(r.keyPanSpeed,0),U=!0;break;case r.keys.RIGHT:W.ctrlKey||W.metaKey||W.shiftKey?P(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(-r.keyPanSpeed,0),U=!0}U&&(W.preventDefault(),r.update())})(z)}function ne(z){r.enabled!==!1&&z.preventDefault()}function Ke(z){let W=R[z.pointerId];W===void 0&&(W=new cn,R[z.pointerId]=W),W.set(z.pageX,z.pageY)}function $(z){const W=z.pointerId===C[0].pointerId?C[1]:C[0];return R[W.pointerId]}r.domElement.addEventListener("contextmenu",ne),r.domElement.addEventListener("pointerdown",fe),r.domElement.addEventListener("pointercancel",ge),r.domElement.addEventListener("wheel",Me,{passive:!1}),this.update()}}Pt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new cn(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},cs.line={uniforms:PO.merge([Pt.common,Pt.fog,Pt.line]),vertexShader:`
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- uniform float linewidth;
- uniform vec2 resolution;
- attribute vec3 instanceStart;
- attribute vec3 instanceEnd;
- attribute vec3 instanceColorStart;
- attribute vec3 instanceColorEnd;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #ifdef USE_DASH
- uniform float dashScale;
- attribute float instanceDistanceStart;
- attribute float instanceDistanceEnd;
- varying float vLineDistance;
- #endif
- void trimSegment( const in vec4 start, inout vec4 end ) {
- // trim end segment so it terminates between the camera plane and the near plane
- // conservative estimate of the near plane
- float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
- float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
- float nearEstimate = - 0.5 * b / a;
- float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
- end.xyz = mix( start.xyz, end.xyz, alpha );
- }
- void main() {
- #ifdef USE_COLOR
- vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
- #endif
- #ifdef USE_DASH
- vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
- vUv = uv;
- #endif
- float aspect = resolution.x / resolution.y;
- // camera space
- vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
- vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
- #ifdef WORLD_UNITS
- worldStart = start.xyz;
- worldEnd = end.xyz;
- #else
- vUv = uv;
- #endif
- // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
- // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
- // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
- // perhaps there is a more elegant solution -- WestLangley
- bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
- if ( perspective ) {
- if ( start.z < 0.0 && end.z >= 0.0 ) {
- trimSegment( start, end );
- } else if ( end.z < 0.0 && start.z >= 0.0 ) {
- trimSegment( end, start );
- }
- }
- // clip space
- vec4 clipStart = projectionMatrix * start;
- vec4 clipEnd = projectionMatrix * end;
- // ndc space
- vec3 ndcStart = clipStart.xyz / clipStart.w;
- vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
- // direction
- vec2 dir = ndcEnd.xy - ndcStart.xy;
- // account for clip-space aspect ratio
- dir.x *= aspect;
- dir = normalize( dir );
- #ifdef WORLD_UNITS
- // get the offset direction as perpendicular to the view vector
- vec3 worldDir = normalize( end.xyz - start.xyz );
- vec3 offset;
- if ( position.y < 0.5 ) {
- offset = normalize( cross( start.xyz, worldDir ) );
- } else {
- offset = normalize( cross( end.xyz, worldDir ) );
- }
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
- // don't extend the line if we're rendering dashes because we
- // won't be rendering the endcaps
- #ifndef USE_DASH
- // extend the line bounds to encompass endcaps
- start.xyz += - worldDir * linewidth * 0.5;
- end.xyz += worldDir * linewidth * 0.5;
- // shift the position of the quad so it hugs the forward edge of the line
- offset.xy -= dir * forwardOffset;
- offset.z += 0.5;
- #endif
- // endcaps
- if ( position.y > 1.0 || position.y < 0.0 ) {
- offset.xy += dir * 2.0 * forwardOffset;
- }
- // adjust for linewidth
- offset *= linewidth * 0.5;
- // set the world position
- worldPos = ( position.y < 0.5 ) ? start : end;
- worldPos.xyz += offset;
- // project the worldpos
- vec4 clip = projectionMatrix * worldPos;
- // shift the depth of the projected points so the line
- // segments overlap neatly
- vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
- clip.z = clipPose.z * clip.w;
- #else
- vec2 offset = vec2( dir.y, - dir.x );
- // undo aspect ratio adjustment
- dir.x /= aspect;
- offset.x /= aspect;
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- // endcaps
- if ( position.y < 0.0 ) {
- offset += - dir;
- } else if ( position.y > 1.0 ) {
- offset += dir;
- }
- // adjust for linewidth
- offset *= linewidth;
- // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
- offset /= resolution.y;
- // select end
- vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
- // back to clip space
- offset *= clip.w;
- clip.xy += offset;
- #endif
- gl_Position = clip;
- vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }
- `,fragmentShader:`
- uniform vec3 diffuse;
- uniform float opacity;
- uniform float linewidth;
- #ifdef USE_DASH
- uniform float dashOffset;
- uniform float dashSize;
- uniform float gapSize;
- #endif
- varying float vLineDistance;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #include <common>
- #include <color_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
- float mua;
- float mub;
- vec3 p13 = p1 - p3;
- vec3 p43 = p4 - p3;
- vec3 p21 = p2 - p1;
- float d1343 = dot( p13, p43 );
- float d4321 = dot( p43, p21 );
- float d1321 = dot( p13, p21 );
- float d4343 = dot( p43, p43 );
- float d2121 = dot( p21, p21 );
- float denom = d2121 * d4343 - d4321 * d4321;
- float numer = d1343 * d4321 - d1321 * d4343;
- mua = numer / denom;
- mua = clamp( mua, 0.0, 1.0 );
- mub = ( d1343 + d4321 * ( mua ) ) / d4343;
- mub = clamp( mub, 0.0, 1.0 );
- return vec2( mua, mub );
- }
- void main() {
- #include <clipping_planes_fragment>
- #ifdef USE_DASH
- if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
- if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
- #endif
- float alpha = opacity;
- #ifdef WORLD_UNITS
- // Find the closest points on the view ray and the line segment
- vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
- vec3 lineDir = worldEnd - worldStart;
- vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
- vec3 p1 = worldStart + lineDir * params.x;
- vec3 p2 = rayEnd * params.y;
- vec3 delta = p1 - p2;
- float len = length( delta );
- float norm = len / linewidth;
- #ifndef USE_DASH
- #ifdef USE_ALPHA_TO_COVERAGE
- float dnorm = fwidth( norm );
- alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
- #else
- if ( norm > 0.5 ) {
- discard;
- }
- #endif
- #endif
- #else
- #ifdef USE_ALPHA_TO_COVERAGE
- // artifacts appear on some hardware if a derivative is taken within a conditional
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- float dlen = fwidth( len2 );
- if ( abs( vUv.y ) > 1.0 ) {
- alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
- }
- #else
- if ( abs( vUv.y ) > 1.0 ) {
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- if ( len2 > 1.0 ) discard;
- }
- #endif
- #endif
- vec4 diffuseColor = vec4( diffuse, alpha );
- #include <logdepthbuf_fragment>
- #include <color_fragment>
- gl_FragColor = vec4( diffuseColor.rgb, alpha );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }
- `};class VJ extends Vd{constructor(e){super({type:"LineMaterial",uniforms:PO.clone(cs.line.uniforms),vertexShader:cs.line.vertexShader,fragmentShader:cs.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 J7=new So,d1=new ze;class GJ extends mBe{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 si([-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 si([-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 YP(n,6,1);return this.setAttribute("instanceStart",new xd(r,3,0)),this.setAttribute("instanceEnd",new xd(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 YP(n,6,1);return this.setAttribute("instanceColorStart",new xd(r,3,0)),this.setAttribute("instanceColorEnd",new xd(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 oBe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new So);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),J7.setFromBufferAttribute(n),this.boundingBox.union(J7))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Pl),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++)d1.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(d1)),d1.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(d1));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 e9=new ze,t9=new ze,oa=new ur,la=new ur,gl=new ur,Dk=new ze,Ok=new vr,ca=new pBe,n9=new ze,h1=new So,f1=new Pl,xl=new ur;let bl,Bh;function r9(t,e,n){return xl.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),xl.multiplyScalar(1/xl.w),xl.x=Bh/n.width,xl.y=Bh/n.height,xl.applyMatrix4(t.projectionMatrixInverse),xl.multiplyScalar(1/xl.w),Math.abs(Math.max(xl.x,xl.y))}class jBe extends Xo{constructor(e=new GJ,n=new VJ({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)e9.fromBufferAttribute(n,o),t9.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+e9.distanceTo(t9);const a=new YP(i,2,1);return e.setAttribute("instanceDistanceStart",new xd(a,1,0)),e.setAttribute("instanceDistanceEnd",new xd(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;bl=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;Bh=c.linewidth+a,l.boundingSphere===null&&l.computeBoundingSphere(),f1.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*Bh:u=r9(i,Math.max(i.near,f1.distanceToPoint(bl.origin)),c.resolution),f1.radius+=u,bl.intersectsSphere(f1)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),h1.copy(l.boundingBox).applyMatrix4(o),r?d=.5*Bh:d=r9(i,Math.max(i.near,h1.distanceToPoint(bl.origin)),c.resolution),h1.expandByScalar(d),bl.intersectsBox(h1)!==!1&&(r?(function(f,m){const g=f.matrixWorld,x=f.geometry,y=x.attributes.instanceStart,b=x.attributes.instanceEnd;for(let v=0,M=Math.min(x.instanceCount,y.count);v<M;v++){ca.start.fromBufferAttribute(y,v),ca.end.fromBufferAttribute(b,v),ca.applyMatrix4(g);const S=new ze,A=new ze;bl.distanceSqToSegment(ca.start,ca.end,A,S),A.distanceTo(S)<.5*Bh&&m.push({point:A,pointOnLine:S,distance:bl.origin.distanceTo(A),object:f,face:null,faceIndex:v,uv:null,uv1:null})}})(this,n):(function(f,m,g){const x=m.projectionMatrix,y=f.material.resolution,b=f.matrixWorld,v=f.geometry,M=v.attributes.instanceStart,S=v.attributes.instanceEnd,A=Math.min(v.instanceCount,M.count),E=-m.near;bl.at(1,gl),gl.w=1,gl.applyMatrix4(m.matrixWorldInverse),gl.applyMatrix4(x),gl.multiplyScalar(1/gl.w),gl.x*=y.x/2,gl.y*=y.y/2,gl.z=0,Dk.copy(gl),Ok.multiplyMatrices(m.matrixWorldInverse,b);for(let k=0,C=A;k<C;k++){if(oa.fromBufferAttribute(M,k),la.fromBufferAttribute(S,k),oa.w=1,la.w=1,oa.applyMatrix4(Ok),la.applyMatrix4(Ok),oa.z>E&&la.z>E)continue;if(oa.z>E){const L=oa.z-la.z,X=(oa.z-E)/L;oa.lerp(la,X)}else if(la.z>E){const L=la.z-oa.z,X=(la.z-E)/L;la.lerp(oa,X)}oa.applyMatrix4(x),la.applyMatrix4(x),oa.multiplyScalar(1/oa.w),la.multiplyScalar(1/la.w),oa.x*=y.x/2,oa.y*=y.y/2,la.x*=y.x/2,la.y*=y.y/2,ca.start.copy(oa),ca.start.z=0,ca.end.copy(la),ca.end.z=0;const R=ca.closestPointToPointParameter(Dk,!0);ca.at(R,n9);const T=SJ.lerp(oa.z,la.z,R),P=T>=-1&&T<=1,F=Dk.distanceTo(n9)<.5*Bh;if(P&&F){ca.start.fromBufferAttribute(M,k),ca.end.fromBufferAttribute(S,k),ca.start.applyMatrix4(b),ca.end.applyMatrix4(b);const L=new ze,X=new ze;bl.distanceSqToSegment(ca.start,ca.end,X,L),g.push({point:X,pointOnLine:L,distance:bl.origin.distanceTo(X),object:f,face:null,faceIndex:k,uv:null,uv1:null})}}})(this,i,n)))}}class PBe extends HM{constructor(e,n,r,i,a=4473924,o=8947848){a=new Qt(a),o=new Qt(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 g=m===0?a:o;g.toArray(u,d),d+=3,g.toArray(u,d),d+=3,g.toArray(u,d),d+=3,g.toArray(u,d),d+=3}for(let m=-1*r;m<=r;m+=i){c.push(-1*e,0,m,e,0,m);const g=m===0?a:o;g.toArray(u,d),d+=3,g.toArray(u,d),d+=3,g.toArray(u,d),d+=3,g.toArray(u,d),d+=3}const f=new Ra;f.setAttribute("position",new si(c,3)),f.setAttribute("color",new si(u,3)),super(f,new Ty({vertexColors:!0,toneMapped:!1}))}}function RBe(t,e,n,r){const i=(function(o,l,c){o*=.5,l*=.5,c*=.5;const u=new Ra,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 si(d,3)),u})(t,e,n),a=new HM(i,new cBe({color:new Qt(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var Ib=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 Ib.Panel("FPS","#0ff","#002")),c=n(new Ib.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new Ib.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}};Ib.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,g=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,g,x),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(f,m,g,x),{dom:y,update:function(v,M){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,g-o,x,f,m,g-o,x),b.fillRect(f+g-o,m,o,x),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(f+g-o,m,o,a((1-v/M)*x))}}};var DBe=Ib;class i9{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new NS,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 NS,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 OBe extends Ra{constructor(e=[new ze],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 ze,o=new ze,l=new cn,c=[],u=[],d=[],f=[];function m(g){const[x,y,b]=(function(v){const M=e[v],S=new ze,A=new ze,E=new ze,k=new ze;S.copy(M).sub(e[v-1]||M).normalize().add((e[v+1]||M).clone().sub(M).normalize()).normalize();let C=Number.MAX_VALUE;const R=Math.abs(S.x),T=Math.abs(S.y),P=Math.abs(S.z);return R<=C&&(C=R,A.set(1,0,0)),T<=C&&(C=T,A.set(0,1,0)),P<=C&&A.set(0,0,1),k.crossVectors(S,A).normalize(),A.crossVectors(S,k),E.crossVectors(S,A),[M,A,E]})(g);for(let v=0;v<=i;v++){const M=v/i*Math.PI*2,S=Math.sin(M),A=-Math.cos(M);o.x=A*y.x+S*b.x,o.y=A*y.y+S*b.y,o.z=A*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 g=0;g<e.length;g++)m(g);m(closed===!1?e.length-1:0),(function(){for(let g=0;g<e.length;g++)for(let x=0;x<=i;x++)l.x=g/e.length,l.y=x/i,d.push(l.x,l.y)})(),(function(){for(let g=1;g<e.length;g++)for(let x=1;x<=i;x++){const y=(i+1)*(g-1)+(x-1),b=(i+1)*g+(x-1),v=(i+1)*g+x,M=(i+1)*(g-1)+x;f.push(y,b,M),f.push(b,v,M)}})()})(),this.setIndex(f),this.setAttribute("position",new si(c,3)),this.setAttribute("normal",new si(u,3)),this.setAttribute("uv",new si(d,2))}}class Fb{static get initial(){const e=new Fb;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const Lk={h:0,s:0,l:0};class Vp{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=Fb.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=Vp.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new Qt(14737632),this._travelColor=new Qt(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 ES(this.minLayerThreshold),this.scene=new Qze,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new Qt(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 DBe:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new Qt(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new Qt(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new Qt(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[g,x]of Object.entries(e.toolColors))this._toolColors[parseInt(g)]=new Qt(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+FM),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 XP({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const g=document.getElementById(this.targetId);if(!g)throw new Error("Unable to find element "+this.targetId);this.renderer=new XP({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,g.appendChild(this.canvas)}this.camera=new Ds(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 OO(this._backgroundColor,m,f),this.resize(),this.controls=new kBe(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 Qt(r)}else this._extrusionColor=new Qt(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?Vp.defaultExtrusionColor:this._extrusionColor instanceof Qt?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:Vp.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new Qt(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new Qt(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new Qt(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new Qt(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 gBe(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 fBe(13421772,.3*Math.PI),n=new hBe(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 Sb;return n.name=e,n.quaternion.setFromEuler(new Ey(-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=Fb.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 Pk(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 g=m;this.state.t=g.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(m.gcode)>-1){const g=m,x={x:(n=g.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=g.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=g.params.z)!==null&&i!==void 0?i:this.state.z,r:(a=g.params.r)!==null&&a!==void 0?a:this.state.r,e:(o=g.params.e)!==null&&o!==void 0?o:this.state.e,i:(l=g.params.i)!==null&&l!==void 0?l:this.state.i,j:(c=g.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const y=((u=g.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(Lk),a=new Qt().setHSL(Lk.h,Lk.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 PBe(this.buildVolume.x,10,this.buildVolume.y,10));const e=RBe(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 ES(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=Fb.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 g=r.r,x=r.i,y=r.j;if(g){const K=d-l,Y=f-c,q=Math.sqrt(Math.pow(K/2,2)+Math.pow(Y/2,2));g=Math.max(g,q);const Z=Math.pow(K,2)+Math.pow(Y,2),re=Math.pow(g,2)-Z/4;let oe=Math.sqrt(re/Z);(a&&g<0||!a&&g>0)&&(oe=-oe),x=K/2+Y*oe,y=Y/2-K*oe}const b=l==d&&c==f,v=l+x,M=c+y,S=Math.sqrt(x*x+y*y),A=Math.atan2(-y,-x),E=Math.atan2(f-M,d-v);let k;b?k=2*Math.PI:(k=a?A-E:E-A,k<0&&(k+=2*Math.PI));let C=S*k/1.8;this.inches&&(C*=25),C<1&&(C=1);let R=k/C;R*=a?-1:1;const T=[];T.push({x:l,y:c,z:u});const P=(u-m)/C;let F=l,L=c,X=u,D=A;for(let K=0;K<C-1;K++)D+=R,F=v+S*Math.cos(D),L=M+S*Math.sin(D),X+=P,T.push({x:F,y:L,z:X});T.push({x:r.x,y:r.y,z:r.z});for(let K=0;K<T.length-1;K++)o.push(T[K].x,T[K].y,T[K].z,T[K+1].x,T[K+1].y,T[K+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new Ra;i.setAttribute("position",new si(e,3)),this.disposables.push(i);const a=new Ty({color:n});this.disposables.push(a);const o=new HM(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 ze(l[0],l[1],l[2]),u=new ze(l[3],l[4],l[5]),d=new ze(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 OBe(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 GJ;this.disposables.push(i);const a=new VJ({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const o=new jBe(i,a);(r=this.group)===null||r===void 0||r.add(o)}dispose(){this.disposables.forEach((e=>e.dispose())),this.disposables=[],this.controls.dispose(),this.renderer.dispose(),this.cancelAnimation()}cancelAnimation(){this.animationFrameId!==void 0&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0}_enableDropHandler(){console.warn("Drag and drop is deprecated as a library feature. See the demo how to implement your own."),this.canvas.addEventListener("dragover",(e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),this.canvas.classList.add("dragging")})),this.canvas.addEventListener("dragleave",(e=>{e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove("dragging")})),this.canvas.addEventListener("drop",(e=>Pk(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 lBe({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new aBe(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 Pk(this,void 0,void 0,(function*(){const i=e.getReader();let a,o="",l=0;do{console.debug("reading from stream"),a=yield i.read(),l+=(r=(n=a.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(c=a.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
- `),f=u.slice(0,d);this.parser.parseGCode(o+f),o=u.slice(d)}while(!a.done);var c;console.debug("read from stream",l)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new i9(this):typeof this.devMode=="object"&&(this.devGui=new i9(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())}}Vp.defaultExtrusionColor=new Qt("hotpink");function LBe({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,g]=w.useState(!1),[x,y]=w.useState(0),[b,v]=w.useState(0),M=w.useMemo(()=>JSON.stringify(n),[n]);w.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const E=i.current,k=E.parentElement?.getBoundingClientRect();k&&(E.width=k.width,E.height=k.height);const C=n&&n.length>1,R=n?.[0]||"#00ae42",T=new Vp({canvas:E,buildVolume:e,backgroundColor:1710618,extrusionColor:C?n:R,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=T,fetch(t).then(async F=>{if(!F.ok)throw F.status===404&&(await F.json().catch(()=>({}))).detail?.includes("sliced")?(g(!0),new Error("not_sliced")):new Error("Failed to load G-code");return F.text()}).then(F=>{const L=new Set,X=/^(\s*)T(\d+)(\s*;.*)?$/gim;let D;for(;(D=X.exec(F))!==null;){const oe=parseInt(D[2],10);oe<=15&&L.add(oe)}const K=new Map,Y=Array.from(L).sort((oe,B)=>oe-B);Y.forEach((oe,B)=>{K.set(oe,B%8)});const q=[];Y.forEach((oe,B)=>{const G=n?.[oe]||"#00ae42";q[B%8]=G});const Z=F.split(`
- `).map(oe=>{const B=oe.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(B){const G=parseInt(B[2],10);if(G>15)return`; FILTERED: ${oe.trim()}`;const J=K.get(G)??0;return`${B[1]}T${J}${B[3]||""}`}return oe}).join(`
- `);q.length>0&&(T.extrusionColor=q),T.processGCode(Z);const re=T.layers?.length||0;v(re),y(re),T.render(),u(!1)}).catch(F=>{F.message!=="not_sliced"&&f(F.message),u(!1)});const P=()=>{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",P),()=>{window.removeEventListener("resize",P),o.current&&cancelAnimationFrame(o.current),a.current&&(a.current.dispose(),a.current=null),l.current=!1}},[t,M]);const S=w.useCallback(E=>{if(!a.current)return;const k=Math.max(1,Math.min(E,b));y(k),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=k,a.current.render())})},[b]),A=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(mt,{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(lue,{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(nl,{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(vf,{className:"w-4 h-4"})}),s.jsx("input",{type:"range",min:1,max:b,value:x,onChange:A,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(Gs,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[x," / ",b]})]})})]})}function WJ({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(()=>{pe.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}${pe.getArchiveForSlicer(t,d)}`;Oc(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(Se,{variant:"secondary",size:"sm",onClick:u,children:[s.jsx(Lr,{className:"w-4 h-4"}),"Open in Slicer"]}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:n,children:s.jsx(Ut,{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(Os,{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(Lce,{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(mt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?s.jsx(ROe,{url:a.has_source?pe.getSource3mfDownloadUrl(t):pe.getArchiveDownload(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):r==="gcode"&&a?s.jsx(LBe,{gcodeUrl:pe.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 a9={"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 IBe(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,g=i/255;a===f?c=((m-g)/d+(m<g?6:0))/6:a===m?c=((g-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 bg(t){const e=t.replace("#","").toLowerCase().substring(0,6);return a9[e]?a9[e]:IBe(t)}function AS(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function Yi(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function Gd(t,e,n=40){const r=Yi(t),i=Yi(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 qJ(t,e,n,r){const i=String.fromCharCode(65+(t>=128?t-128:t));return n?`HT-${i}`:`AMS-${i} Slot ${e+1}`}function KJ(t,e,n){return t*4+e}function FBe(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 UBe(){const t=new Date;return t.setMinutes(t.getMinutes()+1),t.toISOString().slice(0,16)}function s9(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return new Date(t).getTime()>e}function FO(t){const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const a=AS(i.tray_color);e.push({type:i.tray_type,color:a,colorName:bg(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:qJ(n.id,i.id,r),globalTrayId:KJ(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=AS(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:bg(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e}function o9(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=FO(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()&&Yi(m.color)===Yi(l.color)),u=!c&&n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()&&Gd(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 zBe(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=AS(i.tray_color);e.push({type:i.tray_type,color:a,colorName:bg(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:qJ(n.id,i.id,r),globalTrayId:KJ(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=AS(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:bg(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e},[t])}function XJ(t,e,n){const r=zBe(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],A=r.find(E=>E.globalTrayId===S);if(A){const E=A.type?.toUpperCase()===u.type?.toUpperCase(),k=Yi(A.color)===Yi(u.color)||Gd(A.color,u.color);let C;return E&&k?C="match":E?C="type_only":C="mismatch",{...u,loaded:A,hasFilament:!0,typeMatch:E,colorMatch:k,status:C,isManual:!0}}}const f=r.find(S=>!c.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()&&Yi(S.color)===Yi(u.color)),m=!f&&r.find(S=>!c.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()&&Gd(S.color,u.color)),g=!f&&!m&&r.find(S=>!c.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()),x=f||m||g||void 0;x&&c.add(x.globalTrayId);const y=!!x,b=y,v=!!f||!!m;let M;return f||m?M="match":g?M="type_only":M="mismatch",{...u,loaded:x,hasFilament:y,typeMatch:b,colorMatch:v,status:M,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 BBe(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(),M=Yi(b.color)===Yi(u.color)||Gd(b.color,u.color);v&&M?r++:v?i++:a++;continue}}const f=e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()&&Yi(y.color)===Yi(u.color)),m=f?void 0:e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()&&Gd(y.color,u.color)),g=f||m?void 0:e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()),x=f??m??g;x&&o.add(x.globalTrayId),f||m?r++:g?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 $Be(t,e,n){if(!t?.filaments||t.filaments.length===0)return;const r=FO(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()&&Yi(x.color)===Yi(c.color)),f=d?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()&&Gd(x.color,c.color)),m=d||f?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()),g=d??f??m;g&&i.add(g.globalTrayId),a.push({slot_id:u,globalTrayId:g?.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 l9={useDefault:!0,manualMappings:{},autoConfigured:!1};function HBe(t,e,n,r,i,a){const o=Ole({queries:t.map(x=>({queryKey:["printer-status",x],queryFn:()=>pe.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(P=>P.id===x)?.name||`Printer ${x}`,A=FO(v),E=i[x]||l9,k=o9(n,v),C=E.useDefault?r:E.manualMappings,R=$Be(n,v,C),T=BBe(n?.filaments,A,C);return{printerId:x,printerName:S,status:v,isLoading:b?.isLoading??!1,loadedFilaments:A,autoMapping:k,finalMapping:R,matchStatus:T.status,exactMatches:T.exactMatches,typeOnlyMatches:T.typeOnlyMatches,missingTypes:T.missingTypes,totalSlots:T.totalSlots,config:E}}),[t,o,e,n,i,r]),c=o.some(x=>x.isLoading),u=(x,y)=>{a(b=>({...b,[x]:{...b[x]||l9,...y}}))},d=x=>{const y=l.find(M=>M.printerId===x);if(!y||!y.status||!n?.filaments)return;const b=o9(n,y.status);if(!b)return;const v={};b.forEach((M,S)=>{M!==-1&&(v[S+1]=M)}),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,g=l.every(x=>x.matchStatus!=="missing");return{printerResults:l,isLoading:c,perPrinterConfigs:i,updatePrinterConfig:u,autoConfigureAll:f,autoConfigurePrinter:d,getFinalMapping:m,allPrintersReady:g}}function VBe({printerResult:t,filamentReqs:e,onUpdateConfig:n}){const r=tn(),[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 pe.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,g=!1;if(f!==void 0)m=t.loadedFilaments.find(y=>y.globalTrayId===f),g=!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()&&Yi(S.color)===Yi(u.color)),v=b?void 0:t.loadedFilaments.find(S=>!y.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()&&Gd(S.color,u.color)),M=b||v?void 0:t.loadedFilaments.find(S=>!y.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase());m=b??v??M}let x="mismatch";if(m){const y=m.type?.toUpperCase()===u.type?.toUpperCase(),b=Yi(m.color)===Yi(u.color)||Gd(m.color,u.color);y&&b?x="match":y&&(x="type_only")}return{req:u,loaded:m,status:x,isManual:g}});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(yr,{className:`w-3 h-3 ${i?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),c.map(({req:u,loaded:d,status:f,isManual:m},g)=>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} - ${bg(u.color)}`,children:s.jsx(Fj,{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(xs,{className:"w-3 h-3 text-bambu-green"}):f==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(Cn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(Cn,{className:"w-3 h-3 text-orange-400"})})]},g))]})}function GBe({printers:t,selectedPrinterIds:e,onMultiSelect:n,isLoading:r=!1,allowMultiple:i=!1,showInactive:a=!1,printerMappingResults:o,filamentReqs:l,onAutoConfigurePrinter:c,onUpdatePrinterConfig:u}){const d=a?t:t.filter(S=>S.is_active),f=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(mt,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(d.length===0)return s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm mb-4",children:[s.jsx(ea,{className:"w-4 h-4"}),"No ",a?"":"active ","printers available"]});const m=S=>{i?e.includes(S)?n(e.filter(A=>A!==S)):n([...e,S]):n([S])},g=()=>{n(d.map(S=>S.id))},x=()=>{n([])},y=(S,A,E)=>{E.stopPropagation(),!(!c||!u)&&(A?c(S):u(S,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},b=S=>e.includes(S),v=e.length,M=S=>o?.find(A=>A.printerId===S);return s.jsxs("div",{className:"space-y-2 mb-6",children:[i&&d.length>1&&s.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray mb-2",children:[s.jsx("span",{children:v===0?"Select printers":`${v} printer${v!==1?"s":""} selected`}),s.jsxs("div",{className:"flex gap-2",children:[v<d.length&&s.jsx("button",{type:"button",onClick:g,className:"text-bambu-green hover:text-bambu-green/80 transition-colors",children:"Select all"}),v>0&&s.jsx("button",{type:"button",onClick:x,className:"text-bambu-gray hover:text-white transition-colors",children:"Clear"})]})]}),d.map(S=>{const A=b(S.id),E=M(S.id),k=E&&!E.config.useDefault;return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>m(S.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${A?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"} ${S.is_active?"":"opacity-60"}`,children:[s.jsx("div",{className:`p-2 rounded-lg ${A?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:s.jsx(Ir,{className:`w-5 h-5 ${A?"text-bambu-green":"text-bambu-gray"}`})}),s.jsxs("div",{className:"text-left flex-1",children:[s.jsxs("p",{className:"text-white font-medium",children:[S.name,!S.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:[S.model||"Unknown model"," • ",S.ip_address]})]}),i&&s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${A?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:A&&s.jsx(xs,{className:"w-3 h-3 text-white"})})]}),A&&f&&E&&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:C=>C.stopPropagation(),children:[s.jsx("input",{type:"checkbox",checked:k,onChange:C=>y(S.id,C.target.checked,C),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 ${E.matchStatus==="full"?"text-bambu-green":E.matchStatus==="partial"?"text-yellow-400":"text-orange-400"}`,children:["(",E.exactMatches,"/",E.totalSlots," matched)"]}),E.isLoading&&s.jsx(yr,{className:"w-3 h-3 text-bambu-gray animate-spin"}),k&&s.jsxs("button",{type:"button",onClick:C=>{C.stopPropagation(),c(S.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(Hhe,{className:"w-3 h-3"}),"Auto"]})]}),k&&s.jsx(VBe,{printerResult:E,filamentReqs:l.filaments,onUpdateConfig:C=>u(S.id,C)})]})]},S.id)}),v===0&&s.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[s.jsx(ea,{className:"w-3 h-3"}),"Select at least one printer"]})]})}function WBe({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(nl,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Select Plate to Print"}),!n&&s.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[s.jsx(Cn,{className:"w-3 h-3"}),"Selection required"]})]}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:t.map(i=>s.jsxs("button",{type:"button",onClick:()=>r(i.index),className:`flex items-center gap-2 p-2 rounded-lg border transition-colors text-left ${n===i.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[i.has_thumbnail&&i.thumbnail_url!=null?s.jsx("img",{src:i.thumbnail_url,alt:`Plate ${i.index}`,className:"w-10 h-10 rounded object-cover bg-bambu-dark-tertiary"}):s.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:s.jsx(nl,{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?` • ${FBe(i.print_time_seconds)}`:""]})]}),n===i.index&&s.jsx(xs,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},i.index))})]})}function qBe({printerId:t,filamentReqs:e,manualMappings:n,onManualMappingChange:r,defaultExpanded:i=!1}){const a=tn(),[o,l]=w.useState(!1),[c,u]=w.useState(i),{data:d}=ct({queryKey:["printer-status",t],queryFn:()=>pe.getPrinterStatus(t),enabled:!!t}),{loadedFilaments:f,filamentComparison:m,hasTypeMismatch:g,hasColorMismatch:x}=XJ(e,d,n);if(!(e?.filaments&&e.filaments.length>0)||!d)return null;const b=g?"#f97316":x?"#facc15":"#00ae42",v=(S,A)=>{if(S>0)if(A===""){const E={...n};delete E[S],r(E)}else r({...n,[S]:parseInt(A,10)})},M=async()=>{l(!0);try{await pe.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(Fj,{className:"w-4 h-4",fill:b,stroke:"none"}),s.jsx("span",{children:"Filament Mapping"}),g?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(Jc,{className:"w-4 h-4 ml-auto"}):s.jsx(Ji,{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:M,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(yr,{className:`w-3 h-3 ${o?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),m.map((S,A)=>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} - ${bg(S.color)}`,children:s.jsx(Fj,{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(xs,{className:"w-3 h-3 text-bambu-green"}):S.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(Cn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(Cn,{className:"w-3 h-3 text-orange-400"})})]},A)),g&&s.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]})]})}const KBe=[{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 XBe({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(F2,{className:"w-4 h-4"}),s.jsx("span",{children:"Print Options"}),r?s.jsx(Jc,{className:"w-4 h-4 ml-auto"}):s.jsx(Ji,{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:KBe.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 YBe({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(Gn,{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(Qr,{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(qW,{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:UBe(),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(uu,{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 fp={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},QBe={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function Wd({mode:t,archiveId:e,libraryFileId:n,archiveName:r,queueItem:i,onClose:a,onSuccess:o}){const l=tn(),{showToast:c}=$n(),u=!!n&&!e,[d,f]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[m,g]=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??fp.bed_levelling,flow_cali:i.flow_cali??fp.flow_cali,vibration_cali:i.vibration_cali??fp.vibration_cali,layer_inspect:i.layer_inspect??fp.layer_inspect,timelapse:i.timelapse??fp.timelapse}:fp),[b,v]=w.useState(()=>{if(t==="edit-queue-item"&&i){let H="asap";i.manual_start?H="manual":i.scheduled_time&&!s9(i.scheduled_time)&&(H="scheduled");let O="";return i.scheduled_time&&!s9(i.scheduled_time)&&(O=new Date(i.scheduled_time).toISOString().slice(0,16)),{scheduleType:H,scheduledTime:O,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return QBe}),[M,S]=w.useState(()=>{if(t==="edit-queue-item"&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){const H={};return i.ams_mapping.forEach((O,ie)=>{O!==-1&&(H[ie+1]=O)}),H}return{}}),[A,E]=w.useState({}),[k]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[C]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[R,T]=w.useState(!1),[P,F]=w.useState({current:0,total:0}),[L,X]=w.useState(new Set),D=d.length,K=d.length>0?d[0]:null,{data:Y}=ct({queryKey:["settings"],queryFn:pe.getSettings}),{data:q,isLoading:Z}=ct({queryKey:["printers"],queryFn:pe.getPrinters}),{data:re,isError:oe}=ct({queryKey:["archive-plates",e],queryFn:()=>pe.getArchivePlates(e),enabled:!!e&&!u,retry:!1}),{data:B}=ct({queryKey:["library-file-plates",n],queryFn:()=>pe.getLibraryFilePlates(n),enabled:u&&!!n}),G=u?B:re,{data:J,isError:te}=ct({queryKey:["archive-filaments",e,m],queryFn:()=>pe.getArchiveFilamentRequirements(e,m??void 0),enabled:!!e&&!u&&(m!==null||!G?.is_multi_plate),retry:!1}),{data:ae}=ct({queryKey:["library-file-filaments",n,m],queryFn:()=>pe.getLibraryFileFilamentRequirements(n,m??void 0),enabled:u&&!!n&&(m!==null||!G?.is_multi_plate)}),de=!u&&(oe||te),fe=u?ae:J,{data:Ae}=ct({queryKey:["printer-status",K],queryFn:()=>pe.getPrinterStatus(K),enabled:!!K}),{amsMapping:ge}=XJ(fe,Ae,M),Me=HBe(d,q,fe,M,A,E);w.useEffect(()=>{G?.plates?.length===1&&!m&&g(G.plates[0].index)},[G,m]),w.useEffect(()=>{if(t==="edit-queue-item")return;const H=q?.filter(O=>O.is_active)||[];H.length===1&&d.length===0&&f([H[0].id])},[t,q,d.length]),w.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(d.sort())!==JSON.stringify(k.sort())||m!==C)&&(S({}),E({}),X(new Set)):(S({}),E({}),X(new Set))},[t,d,m,k,C]),w.useEffect(()=>{if(!Y?.per_printer_mapping_expanded||d.length<=1)return;const H=d.filter(O=>{if(L.has(O))return!1;const ie=Me.printerResults.find(ye=>ye.printerId===O);return ie&&ie.status&&!ie.isLoading});H.length>0&&(X(O=>{const ie=new Set(O);return H.forEach(ye=>ie.add(ye)),ie}),H.forEach(O=>{Me.autoConfigurePrinter(O)}))},[Y?.per_printer_mapping_expanded,d,L,Me]),w.useEffect(()=>{const H=O=>{O.key==="Escape"&&!R&&a()};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[a,R]);const je=G?.is_multi_plate??!1,ne=G?.plates??[],Ke=ft({mutationFn:H=>pe.addToQueue(H)}),$=ft({mutationFn:H=>pe.updateQueueItem(i.id,H),onSuccess:()=>{l.invalidateQueries({queryKey:["queue"]}),c("Queue item updated"),o?.(),a()},onError:H=>{c(H.message||"Failed to update queue item","error")}}),z=async H=>{if(H?.preventDefault(),d.length===0){c("Please select at least one printer","error");return}T(!0),F({current:0,total:d.length});const O={success:0,failed:0,errors:[]},ie=_e=>{if(d.length>1){const le=A[_e];if(le&&!le.useDefault)return Me.getFinalMapping(_e)}return ge},ye=_e=>({printer_id:_e,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(_e),plate_id:m,scheduled_time:b.scheduleType==="scheduled"&&b.scheduledTime?new Date(b.scheduledTime).toISOString():void 0,...x});for(let _e=0;_e<d.length;_e++){const le=d[_e];F({current:_e+1,total:d.length});try{if(t==="reprint"){const ke=ie(le);u?await pe.printLibraryFile(n,le,{ams_mapping:ke,...x}):await pe.reprintArchive(e,le,{plate_id:m??void 0,ams_mapping:ke,...x})}else if(t==="edit-queue-item"&&_e===0){const ke=ie(le),Oe={printer_id:le,require_previous_success:b.requirePreviousSuccess,auto_off_after:b.autoOffAfter,manual_start:b.scheduleType==="manual",ams_mapping:ke,plate_id:m,scheduled_time:b.scheduleType==="scheduled"&&b.scheduledTime?new Date(b.scheduledTime).toISOString():null,...x};await $.mutateAsync(Oe)}else await Ke.mutateAsync(ye(le));O.success++}catch(ke){O.failed++;const Oe=q?.find(Ze=>Ze.id===le)?.name||`Printer ${le}`;O.errors.push(`${Oe}: ${ke.message}`)}}if(T(!1),O.failed===0){const _e=t==="reprint"?"sent to":t==="edit-queue-item"?"updated/queued for":"queued for";O.success===1?c(t==="edit-queue-item"?"Queue item updated":`Print ${_e} printer`):c(`Print ${_e} ${O.success} printers`),l.invalidateQueries({queryKey:["queue"]}),o?.(),a()}else O.success===0?c(`Failed: ${O.errors[0]}`,"error"):(c(`${O.success} succeeded, ${O.failed} failed`,"error"),l.invalidateQueries({queryKey:["queue"]}))},W=R||$.isPending,U=w.useMemo(()=>!(W||d.length===0||!u&&je&&!m),[d.length,je,m,W,u]),Q=(()=>{const H=d.length;return t==="reprint"?{title:u?"Print":"Re-print",icon:Ir,submitText:H>1?`Print to ${H} Printers`:"Print",submitIcon:Ir,loadingText:P.total>1?`Sending ${P.current}/${P.total}...`:"Sending..."}:t==="add-to-queue"?{title:"Schedule Print",icon:Qr,submitText:H>1?`Queue to ${H} Printers`:"Add to Queue",submitIcon:Qr,loadingText:P.total>1?`Adding ${P.current}/${P.total}...`:"Adding..."}:{title:"Edit Queue Item",icon:Ga,submitText:"Save",submitIcon:Ga,loadingText:P.total>1?`Saving ${P.current}/${P.total}...`:"Saving..."}})(),Ee=Q.icon,Ce=Q.submitIcon,Ne=K&&(u||(je?m!==null:!0));return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:R?void 0:a,children:s.jsx(Mt,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:H=>H.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(Ee,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:Q.title})]}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:a,disabled:R,children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:z,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(WBe,{plates:ne,isMultiPlate:je,selectedPlate:m,onSelect:g}),s.jsx(GBe,{printers:q||[],selectedPrinterIds:d,onMultiSelect:f,isLoading:Z,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:Me.printerResults,filamentReqs:fe,onAutoConfigurePrinter:Me.autoConfigurePrinter,onUpdatePrinterConfig:Me.updatePrinterConfig}),de&&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(ea,{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."})]}),Ne&&!de&&d.length===1&&s.jsx(qBe,{printerId:K,filamentReqs:fe,manualMappings:M,onManualMappingChange:S,defaultExpanded:Y?.per_printer_mapping_expanded??!1}),(t==="reprint"||D>0)&&s.jsx(XBe,{options:x,onChange:y}),t!=="reprint"&&s.jsx(YBe,{options:b,onChange:v}),$.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:$.error?.message||"Failed to complete operation"}),s.jsxs("div",{className:`flex gap-3 ${t==="reprint"?"":"pt-2"}`,children:[s.jsx(Se,{type:"button",variant:"secondary",onClick:a,className:"flex-1",disabled:R,children:"Cancel"}),s.jsx(Se,{type:"submit",disabled:!U,className:"flex-1",children:W?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),Q.loadingText]}):s.jsxs(s.Fragment,{children:[s.jsx(Ce,{className:"w-4 h-4"}),Q.submitText]})})]})]})]})})})}function ZBe({onClose:t,initialFiles:e}){const n=tn(),{showToast:r}=$n(),i=w.useRef(null),[a,o]=w.useState(()=>e?.filter(C=>C.name.endsWith(".3mf")).map(C=>({file:C,status:"pending"}))||[]),[l,c]=w.useState(!1),[u,d]=w.useState(),[f,m]=w.useState(null);w.useEffect(()=>{const C=R=>{R.key==="Escape"&&t()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[t]);const{data:g}=ct({queryKey:["printers"],queryFn:pe.getPrinters}),x=ft({mutationFn:C=>pe.uploadArchivesBulk(C,u),onSuccess:C=>{m(C),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),o(R=>R.map(T=>{const P=C.results.find(L=>L.filename===T.file.name),F=C.errors.find(L=>L.filename===T.file.name);return P?{...T,status:"success",archiveId:P.id}:F?{...T,status:"error",error:F.error}:T})),C.failed===0?r(`${C.uploaded} file${C.uploaded!==1?"s":""} uploaded`):C.uploaded===0?r(`Failed to upload ${C.failed} file${C.failed!==1?"s":""}`,"error"):r(`${C.uploaded} uploaded, ${C.failed} failed`,"warning")},onError:()=>{o(C=>C.map(R=>({...R,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),y=w.useCallback(C=>{C.preventDefault(),c(!0)},[]),b=w.useCallback(C=>{C.preventDefault(),c(!1)},[]),v=w.useCallback(C=>{C.preventDefault(),c(!1);const R=Array.from(C.dataTransfer.files).filter(T=>T.name.endsWith(".3mf"));R.length>0&&o(T=>[...T,...R.map(P=>({file:P,status:"pending"}))])},[]),M=w.useCallback(C=>{const R=Array.from(C.target.files||[]).filter(T=>T.name.endsWith(".3mf"));R.length>0&&o(T=>[...T,...R.map(P=>({file:P,status:"pending"}))]),i.current&&(i.current.value="")},[]),S=w.useCallback(C=>{o(R=>R.filter((T,P)=>P!==C))},[]),A=()=>{if(a.length===0)return;const C=a.filter(R=>R.status==="pending");C.length!==0&&(o(R=>R.map(T=>T.status==="pending"?{...T,status:"uploading"}:T)),x.mutate(C.map(R=>R.file)))},E=a.filter(C=>C.status==="pending").length,k=x.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(Mt,{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(Ut,{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:y,onDragLeave:b,onDrop:v,children:[s.jsx(bi,{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(Se,{variant:"secondary",onClick:()=>i.current?.click(),disabled:k,children:"Browse Files"}),s.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:M})]})}),s.jsxs("div",{className:"px-4 pb-4",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (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:u||"",onChange:C=>d(C.target.value?Number(C.target.value):void 0),disabled:k,children:[s.jsx("option",{value:"",children:"No printer"}),g?.map(C=>s.jsx("option",{value:C.id,children:C.name},C.id))]})]}),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((C,R)=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(C2,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"flex-1 text-white text-sm truncate",children:C.file.name}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[(C.file.size/(1024*1024)).toFixed(1)," MB"]}),C.status==="pending"&&s.jsx("button",{onClick:()=>S(R),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:k,children:s.jsx(Ut,{className:"w-4 h-4"})}),C.status==="uploading"&&s.jsx(mt,{className:"w-4 h-4 text-bambu-green animate-spin"}),C.status==="success"&&s.jsx(Dn,{className:"w-4 h-4 text-bambu-green"}),C.status==="error"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-red-400",children:C.error}),s.jsx(ea,{className:"w-4 h-4 text-red-400"})]})]},`${C.file.name}-${R}`))})}),f&&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:f.uploaded})," uploaded",f.failed>0&&s.jsxs(s.Fragment,{children:[", ",s.jsx("span",{className:"text-red-400",children:f.failed})," failed"]})]})})}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Se,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&s.jsx(Se,{onClick:A,disabled:E===0||k,className:"flex-1",children:k?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(bi,{className:"w-4 h-4"}),"Upload ",E>0&&`(${E})`]})})]})]})})})}const JBe=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],e8e=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function YJ({archive:t,onClose:e,existingTags:n=[]}){w.useEffect(()=>{const ae=de=>{de.key==="Escape"&&e()};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[e]);const r=tn(),[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,g]=w.useState(t.tags||""),[x,y]=w.useState(t.failure_reason||""),[b,v]=w.useState(t.status),[M,S]=w.useState(t.quantity??1),[A,E]=w.useState(t.photos||[]),[k,C]=w.useState(!1),[R,T]=w.useState(!1),P=w.useRef(null),F=w.useRef(null),L=w.useRef(null),{data:X}=ct({queryKey:["printers"],queryFn:pe.getPrinters}),{data:D}=ct({queryKey:["projects"],queryFn:()=>pe.getProjects()}),{data:K}=ct({queryKey:["archives"],queryFn:()=>pe.getArchives(void 0,1e3,0),enabled:n.length===0}),Y=n.length>0?n:[...new Set(K?.flatMap(ae=>ae.tags?.split(",").map(de=>de.trim())||[]).filter(Boolean)||[])].sort(),q=m.split(",").map(ae=>ae.trim()).filter(Boolean),Z=Y.filter(ae=>!q.includes(ae)),re=ae=>{if(!q.includes(ae)){const de=[...q,ae].join(", ");g(de)}L.current!==null&&clearTimeout(L.current),P.current?.focus()},oe=ae=>{const de=q.filter(fe=>fe!==ae).join(", ");g(de)},B=ft({mutationFn:ae=>pe.updateArchive(t.id,ae),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),G=async ae=>{const de=ae.target.files?.[0];if(de){C(!0);try{const fe=await pe.uploadArchivePhoto(t.id,de);E(fe.photos),r.invalidateQueries({queryKey:["archives"]})}catch(fe){console.error("Failed to upload photo:",fe)}finally{C(!1),F.current&&(F.current.value="")}}},J=async ae=>{try{const de=await pe.deleteArchivePhoto(t.id,ae);E(de.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(de){console.error("Failed to delete photo:",de)}},te=ae=>{ae.preventDefault();const de={print_name:i||void 0,printer_id:o,project_id:c,notes:d||void 0,tags:m||void 0,quantity:M};b!==t.status&&(de.status=b),b==="failed"||b==="aborted"?de.failure_reason=x||void 0:(t.status==="failed"||t.status==="aborted")&&(de.failure_reason=null),B.mutate(de)};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:ae=>ae.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(Ut,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:te,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:ae=>a(ae.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:ae=>l(ae.target.value?Number(ae.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"}),X?.map(ae=>s.jsx("option",{value:ae.id,children:ae.name},ae.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(ba,{className:"w-4 h-4 inline mr-1"}),"Project"]}),s.jsxs("select",{value:c??"",onChange:ae=>u(ae.target.value?Number(ae.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"}),D?.map(ae=>s.jsx("option",{value:ae.id,children:ae.name},ae.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Oue,{className:"w-4 h-4 inline mr-1"}),"Items Printed"]}),s.jsx("input",{type:"number",min:1,value:M,onChange:ae=>S(Math.max(1,parseInt(ae.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:ae=>f(ae.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.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),q.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:q.map(ae=>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(Zp,{className:"w-3 h-3"}),ae,s.jsx("button",{type:"button",onClick:()=>oe(ae),className:"ml-0.5 text-bambu-gray hover:text-white",children:s.jsx(Ut,{className:"w-3 h-3"})})]},ae))}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:P,type:"text",value:m,onChange:ae=>g(ae.target.value),onFocus:()=>{L.current!==null&&clearTimeout(L.current),T(!0)},onBlur:()=>{L.current=window.setTimeout(()=>T(!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:q.length>0?"Add more tags...":"Add tags..."}),R&&Z.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:Z.map(ae=>s.jsx("button",{type:"button",onClick:()=>re(ae),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:ae},ae))})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Status"}),s.jsx("select",{value:b,onChange:ae=>{v(ae.target.value),ae.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:e8e.map(ae=>s.jsx("option",{value:ae.value,children:ae.label},ae.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:ae=>y(ae.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..."}),JBe.map(ae=>s.jsx("option",{value:ae,children:ae},ae))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Xp,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[A.map(ae=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:pe.getArchivePhotoUrl(t.id,ae),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),s.jsx("button",{type:"button",onClick:()=>J(ae),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx(an,{className:"w-3 h-3 text-white"})})]},ae)),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:F,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:G,className:"hidden",disabled:k}),k?s.jsx(mt,{className:"w-6 h-6 text-bambu-gray animate-spin"}):s.jsx(Kn,{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(Se,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Se,{type:"submit",disabled:B.isPending,className:"flex-1",children:[s.jsx(ds,{className:"w-4 h-4"}),B.isPending?"Saving...":"Save"]})]})]})]})})}function QJ({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,g]=w.useState({});w.useEffect(()=>{const b=S=>{i.current&&!i.current.contains(S.target)&&r()},v=S=>{S.key==="Escape"&&r()},M=()=>{r()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",v),document.addEventListener("scroll",M,!0),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",v),document.removeEventListener("scroll",M,!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,M=window.innerHeight,S=8;let A=t,E=e;t+b.width>v-S&&(A=Math.max(S,v-b.width-S)),A<S&&(A=S),e+b.height>M-S&&(E=Math.max(S,M-b.height-S)),E<S&&(E=S);const k=180,C=v-A-b.width,R=A;f(C<k&&R>k),u({x:A,y:E,visible:!0})}},[t,e]);const x=(b,v)=>{l.current&&(clearTimeout(l.current),l.current=null);const M=v.getBoundingClientRect(),S=window.innerHeight,A=300,C=S-M.top-8<A&&M.top>A;g(R=>({...R,[b]:C?"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 M=b.submenu&&b.submenu.length>0;return s.jsxs("div",{className:"relative",onMouseEnter:S=>M&&x(v,S.currentTarget),onMouseLeave:()=>M&&y(),children:[s.jsxs("button",{onMouseEnter:S=>M&&x(v,S.currentTarget.parentElement),onClick:()=>{M?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"} ${M&&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}),M&&s.jsx(Gs,{className:"w-4 h-4 text-bambu-gray"})]}),M&&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,A)=>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]},A))})]},v)})})}function t8e({selectedIds:t,existingTags:e,onClose:n}){const r=tn(),{showToast:i}=$n(),[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=ft({mutationFn:async()=>{const y=Array.from(l);let b=0;for(const v of t)try{const M=await pe.getArchive(v),S=M.tags?M.tags.split(",").map(E=>E.trim()).filter(Boolean):[];let A;u==="add"?A=[...new Set([...S,...y])]:A=S.filter(E=>!l.has(E)),await pe.updateArchive(v,{tags:A.join(", ")}),b++}catch(M){throw console.error(`Failed to update archive ${v}:`,M),new Error(`Failed on archive ${v}: ${M instanceof Error?M.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})},g=()=>{a.trim()&&!l.has(a.trim())&&(c(y=>new Set([...y,a.trim()])),o(""))},x=y=>{y.key==="Enter"&&(y.preventDefault(),g())};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(Mt,{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(Zp,{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(Ut,{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(Se,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),s.jsx(Se,{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(Se,{size:"sm",variant:"secondary",onClick:g,disabled:!a.trim(),children:s.jsx(Kn,{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(Ut,{className:"w-3 h-3"})})]},y))})]})]}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Se,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Se,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Zp,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function n8e({selectedIds:t,onClose:e}){const n=tn(),{showToast:r}=$n(),{data:i,isLoading:a}=ct({queryKey:["projects"],queryFn:()=>pe.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=ft({mutationFn:async d=>(await pe.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=ft({mutationFn:async()=>{for(const d of t)await pe.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(Mt,{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(ba,{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(Ut,{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(mt,{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(qi,{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(mt,{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(ba,{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(mt,{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(Se,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function r8e(t,e){return new Date(t,e+1,0).getDate()}function i8e(t,e){return new Date(t,e,1).getDay()}const a8e=["January","February","March","April","May","June","July","August","September","October","November","December"],s8e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function o8e({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(k=>{const C=mi(k.completed_at||k.created_at)||new Date,R=`${C.getFullYear()}-${String(C.getMonth()+1).padStart(2,"0")}-${String(C.getDate()).padStart(2,"0")}`,T=E.get(R)||[];T.push(k),E.set(R,T)}),E},[t]),g=r8e(o,i),x=i8e(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())},M=[];for(let E=0;E<x;E++)M.push(null);for(let E=1;E<=g;E++)M.push(E);const S=c?m.get(c)||[]:[],A=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(vf,{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:[a8e[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(Gs,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:s8e.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:M.map((E,k)=>{if(E===null)return s.jsx("div",{className:"aspect-square"},`empty-${k}`);const C=`${o}-${String(i+1).padStart(2,"0")}-${String(E).padStart(2,"0")}`,R=m.get(C)||[],T=R.length>0,P=E===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),F=C===c,L=R.filter(D=>D.status==="completed").length,X=R.filter(D=>D.status==="failed").length;return s.jsxs("button",{onClick:()=>A(F?null:C),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${F?"bg-bambu-green text-white":P?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":T?"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 ${P&&!F?"text-bambu-green":""}`,children:E}),T&&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 ${X>0&&L===0?"bg-red-400":X>0?"bg-yellow-400":"bg-green-400"}`}),s.jsx("span",{className:"text-xs font-medium",children:R.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 k=new Date(E.completed_at||E.created_at);return k.getMonth()===i&&k.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 k=new Date(E.completed_at||E.created_at);return k.getMonth()===i&&k.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 k=new Date(E.completed_at||E.created_at);return k.getMonth()===i&&k.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 k=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 ${k?"":"hover:bg-bambu-dark-tertiary"}`,style:k?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,children:[E.thumbnail_path?s.jsx("img",{src:pe.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((C,R)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:C}},R))})]})]})]},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 ZJ({archiveId:t,archiveName:e,onClose:n}){const r=pe.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(Ut,{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(Se,{onClick:i,className:"w-full",children:[s.jsx(Jr,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function JJ({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 g=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",g),()=>window.removeEventListener("keydown",g)},[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=pe.getArchivePhotoUrl(t,u),f=()=>{const g=document.createElement("a");g.href=d,g.download=`${e}_photo_${a+1}.jpg`,g.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:g=>g.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(Se,{variant:"secondary",size:"sm",onClick:f,children:[s.jsx(Jr,{className:"w-4 h-4"}),"Download"]}),i&&s.jsx(Se,{variant:"secondary",size:"sm",onClick:m,className:"text-red-400 hover:text-red-300",children:s.jsx(an,{className:"w-4 h-4"})}),s.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ut,{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(g=>g-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(vf,{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(g=>g+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(Gs,{className:"w-8 h-8 text-white"})})]}),n.length>1&&s.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((g,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:pe.getArchivePhotoUrl(t,g),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},g))})]}),l&&s.jsx(Ln,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function da(t){this.content=t}da.prototype={constructor:da,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 da(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 da(n)},addToStart:function(t,e){return new da([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new da(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 da(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=da.from(t),t.size?new da(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=da.from(t),t.size?new da(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=da.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}};da.from=function(t){if(t instanceof da)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new da(e)};function eee(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=eee(i.content,a.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function tee(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=tee(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class Nt{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 Nt(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 Nt(r,i)}cutByIndex(e,n){return e==n?Nt.empty:e==0&&n==this.content.length?this:new Nt(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 Nt(i,a)}addToStart(e){return new Nt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Nt(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 eee(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return tee(this,e,n,r)}findIndex(e){if(e==0)return m1(0,e);if(e==this.size)return m1(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?m1(n+1,a):m1(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 Nt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Nt(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Nt.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 Nt(n||e,r)}static from(e){if(!e)return Nt.empty;if(e instanceof Nt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Nt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Nt.empty=new Nt([],0);const Ik={index:0,offset:0};function m1(t,e){return Ik.index=t,Ik.offset=e,Ik}function TS(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(!TS(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!TS(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let pr=class ZP{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&&TS(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 ZP.none;if(e instanceof ZP)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};pr.none=[];class CS extends Error{}class Lt{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=ree(this.content,e+this.openStart,n);return r&&new Lt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Lt(nee(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return Lt.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 Lt(Nt.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 Lt(e,r,i)}}Lt.empty=new Lt(Nt.empty,0,0);function nee(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||a.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,a.copy(nee(a.content,e-i-1,n-i-1)))}function ree(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=ree(o.content,e-a-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function l8e(t,e,n){if(n.openStart>t.depth)throw new CS("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new CS("Inconsistent open depths");return iee(t,e,n,0)}function iee(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=iee(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 ff(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=c8e(n,t);return ff(a,see(t,o,l,e,r))}else return ff(a,kS(t,e,r))}function aee(t,e){if(!e.type.compatibleContent(t.type))throw new CS("Cannot join "+e.type.name+" onto "+t.type.name)}function JP(t,e,n){let r=t.node(n);return aee(r,e.node(n)),r}function hf(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 Ub(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&&(hf(t.nodeAfter,r),a++));for(let l=a;l<o;l++)hf(i.child(l),r);e&&e.depth==n&&e.textOffset&&hf(e.nodeBefore,r)}function ff(t,e){return t.type.checkContent(e),t.copy(e)}function see(t,e,n,r,i){let a=t.depth>i&&JP(t,e,i+1),o=r.depth>i&&JP(n,r,i+1),l=[];return Ub(null,t,i,l),a&&o&&e.index(i)==n.index(i)?(aee(a,o),hf(ff(a,see(t,e,n,r,i+1)),l)):(a&&hf(ff(a,kS(t,e,i+1)),l),Ub(e,n,i,l),o&&hf(ff(o,kS(n,r,i+1)),l)),Ub(r,null,i,l),new Nt(l)}function kS(t,e,n){let r=[];if(Ub(null,t,n,r),t.depth>n){let i=JP(t,e,n+1);hf(ff(i,kS(t,e,n+1)),r)}return Ub(e,null,n,r),new Nt(r)}function c8e(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(Nt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class R0{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 pr.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 jS(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 R0(n,r,a)}static resolveCached(e,n){let r=c9.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 c9.set(e,r=new u8e);let i=r.elts[r.i]=R0.resolve(e,n);return r.i=(r.i+1)%d8e,i}}class u8e{constructor(){this.elts=[],this.i=0}}const d8e=12,c9=new WeakMap;class jS{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 h8e=Object.create(null);let kd=class eR{constructor(e,n,r,i=pr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||Nt.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&&TS(this.attrs,n||e.defaultAttrs||h8e)&&pr.sameSet(this.marks,r||pr.none)}copy(e=null){return e==this.content?this:new eR(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new eR(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 Lt.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 Lt(u,i.depth-o,a.depth-o)}replace(e,n,r){return l8e(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 R0.resolveCached(this,e)}resolveNoCache(e){return R0.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()+")"),oee(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=Nt.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=pr.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(!pr.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=Nt.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};kd.prototype.text=void 0;class PS extends kd{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):oee(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 PS(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new PS(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 oee(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Ff{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new f8e(e,n);if(r.next==null)return Ff.empty;let i=lee(r);r.next&&r.err("Unexpected trailing text");let a=v8e(y8e(i));return _8e(a,r),a}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let a=n;i&&a<r;a++)i=i.matchType(e.child(a).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function a(o,l){let c=o.matchFragment(e,r);if(c&&(!n||c.validEnd))return Nt.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(`
- `)}}Ff.empty=new Ff(!0);class f8e{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 lee(t){let e=[];do e.push(m8e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function m8e(t){let e=[];do e.push(p8e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function p8e(t){let e=b8e(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=g8e(t,e);else break;return e}function u9(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function g8e(t,e){let n=u9(t),r=n;return t.eat(",")&&(t.next!="}"?r=u9(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function x8e(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 b8e(t){if(t.eat("(")){let e=lee(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=x8e(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 y8e(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 cee(t,e){return e-t}function d9(t,e){let n=[];return r(e),n.sort(cee);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 v8e(t){let e=Object.create(null);return n(d9(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]);d9(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new Ff(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(cee);a.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return a}}function _8e(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],a=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:c,next:u}=i.next[l];o.push(c.name),a&&!(c.isText||c.hasRequiredAttrs())&&(a=!1),r.indexOf(u)==-1&&r.push(u)}a&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function uee(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 dee(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 hee(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 fee(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new S8e(t,r,e[r]);return n}let h9=class mee{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=fee(e,r.attrs),this.defaultAttrs=uee(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==Ff.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:dee(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new kd(this,this.computeAttrs(e),Nt.from(n),pr.setFrom(r))}createChecked(e=null,n,r){return n=Nt.from(n),this.checkContent(n),new kd(this,this.computeAttrs(e),n,pr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=Nt.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(Nt.empty,!0);return a?new kd(this,e,n.append(a),pr.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){hee(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:pr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,o)=>r[a]=new mee(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 w8e(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 S8e{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?w8e(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class VM{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=fee(e,i.attrs),this.excluded=null;let a=uee(this.attrs);this.instance=a?new pr(this,a):null}create(e=null){return!e&&this.instance?this.instance:new pr(this,dee(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,o)=>r[a]=new VM(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){hee(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class pee{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=da.from(e.nodes),n.marks=da.from(e.marks||{}),this.nodes=h9.compile(this.spec.nodes,this),this.marks=VM.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]=Ff.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?f9(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==""?[]:f9(this,o.split(" "))}this.nodeFromJSON=i=>kd.fromJSON(this,i),this.markFromJSON=i=>pr.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 h9){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 PS(r,r.defaultAttrs,e,pr.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 f9(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 M8e(t){return t.tag!=null}function N8e(t){return t.style!=null}let zb=class tR{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(M8e(i))this.tags.push(i);else if(N8e(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 p9(this,n,!1);return r.addAll(e,pr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new p9(this,n,!0);return r.addAll(e,pr.none,n.from,n.to),Lt.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(T8e(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=g9(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=g9(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new tR(e,tR.schemaRules(e)))}};const gee={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},E8e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},xee={ol:!0,ul:!0},D0=1,nR=2,Bb=4;function m9(t,e,n){return e!=null?(e?D0:0)|(e==="full"?nR:0):t&&t.whitespace=="pre"?D0|nR:n&~Bb}class p1{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=pr.none,this.match=a||(o&Bb?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Nt.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&D0)){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=Nt.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Nt.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&&!gee.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class p9{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=m9(null,n.preserveWhitespace,0)|(r?Bb:0);i?a=new p1(i.type,i.attrs,pr.none,!0,n.topMatch||i.type.contentMatch,o):r?a=new p1(null,null,pr.none,!0,null,o):a=new p1(e.schema.topNodeType,null,pr.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&nR?"full":this.localPreserveWS||(i.options&D0)>0,{schema:o}=this.parser;if(a==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(a)if(a==="full")r=r.replace(/\r\n?/g,`
- `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[c]&&this.insertNode(o.text(l[c]),n,!/\S/.test(l[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,a=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;xee.hasOwnProperty(o)&&this.parser.normalizeLists&&A8e(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:E8e.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(gee.hasOwnProperty(o))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),u=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=c&&c.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(a),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,c,u,c.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let a=this.parser.matchedStyles[i],o=r.getPropertyValue(a);if(o)for(let l=void 0;;){let c=this.parser.matchStyle(a,o,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(u=>!c.clearMark(u)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return n}addElementByRule(e,n,r,i){let a,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let c=this.enter(o,n.attrs||null,r,n.preserveWhitespace);c&&(a=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,r),this.findAround(e,c,!1)}a&&this.sync(l)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(o,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let o=this.open,l=0;o>=0;o--){let c=this.nodes[o],u=c.findWrapping(e);if(u&&(!i||i.length>u.length+l)&&(i=u,a=c,!u.length))break;if(c.solid){if(r)break;l+=2}}if(!i)return null;this.sync(a);for(let o=0;o<i.length;o++)n=this.enterInner(i[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(n=this.enterInner(a,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let a=this.top;a.match&&(a.match=a.match.matchType(e.type));let o=pr.none;for(let l of i.concat(e.marks))(a.type?a.type.allowsMarkType(l.type):x9(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=m9(e,a,o.options);o.options&Bb&&o.content.length==0&&(l|=Bb);let c=pr.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):x9(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new p1(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|=D0)}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 A8e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&xee.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function T8e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function g9(t){let e={};for(let n in t)e[n]=t[n];return e}function x9(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 Yf{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Fk(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}=Q1(Fk(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&&Q1(Fk(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return Q1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Yf(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=b9(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return b9(e.marks)}}function b9(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Fk(t){return t.document||window.document}const y9=new WeakMap;function C8e(t){let e=y9.get(t);return e===void 0&&y9.set(t,e=k8e(t)),e}function k8e(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 Q1(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=C8e(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:g,contentDOM:x}=Q1(t,m,n,r);if(c.appendChild(g),x){if(l)throw new RangeError("Multiple content holes");l=x}}}return{dom:c,contentDOM:l}}const bee=65535,yee=Math.pow(2,16);function j8e(t,e){return t+e*yee}function v9(t){return t&bee}function P8e(t){return(t-(t&bee))/yee}const vee=1,_ee=2,Z1=4,wee=8;class rR{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&wee)>0}get deletedBefore(){return(this.delInfo&(vee|Z1))>0}get deletedAfter(){return(this.delInfo&(_ee|Z1))>0}get deletedAcross(){return(this.delInfo&Z1)>0}}class Is{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Is.empty)return Is.empty}recover(e){let n=0,r=v9(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+P8e(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,g=c+i+(m<0?0:d);if(r)return g;let x=e==(n<0?c:f)?null:j8e(l/3,e-c),y=e==c?_ee:e==f?vee:Z1;return(n<0?e!=c:e!=f)&&(y|=wee),new rR(g,y,x)}i+=d-u}return r?e+i:new rR(e+i,0,null)}touches(e,n){let r=0,i=v9(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 Is(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Is.empty:new Is(e<0?[0,-e,0]:[0,0,e])}}Is.empty=new Is([]);class O0{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 O0(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 O0;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 rR(e,i,null)}}const Uk=Object.create(null);class Da{getMap(){return Is.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Uk[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 Uk)throw new RangeError("Duplicate use of step JSON ID "+e);return Uk[e]=n,n.prototype.jsonID=e,n}}class xi{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new xi(e,null)}static fail(e){return new xi(null,e)}static fromReplace(e,n,r,i){try{return xi.ok(e.replace(n,r,i))}catch(a){if(a instanceof CS)return xi.fail(a.message);throw a}}}function UO(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(UO(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return Nt.fromArray(r)}class bd extends Da{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 Lt(UO(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 xi.fromReplace(e,this.from,this.to,a)}invert(){return new Yo(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 bd(n.pos,r.pos,this.mark)}merge(e){return e instanceof bd&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new bd(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 bd(n.from,n.to,e.markFromJSON(n.mark))}}Da.jsonID("addMark",bd);class Yo extends Da{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 Lt(UO(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return xi.fromReplace(e,this.from,this.to,r)}invert(){return new bd(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 Yo(n.pos,r.pos,this.mark)}merge(e){return e instanceof Yo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Yo(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 Yo(n.from,n.to,e.markFromJSON(n.mark))}}Da.jsonID("removeMark",Yo);class yd extends Da{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return xi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return xi.fromReplace(e,this.pos,this.pos+1,new Lt(Nt.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 yd(this.pos,n.marks[i]);return new yd(this.pos,this.mark)}}return new Uf(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new yd(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 yd(n.pos,e.markFromJSON(n.mark))}}Da.jsonID("addNodeMark",yd);class Uf extends Da{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return xi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return xi.fromReplace(e,this.pos,this.pos+1,new Lt(Nt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new yd(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Uf(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 Uf(n.pos,e.markFromJSON(n.mark))}}Da.jsonID("removeNodeMark",Uf);class Ki extends Da{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&iR(e,this.from,this.to)?xi.fail("Structure replace would overwrite content"):xi.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Is([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ki(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 Ki(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ki)||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?Lt.empty:new Lt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ki(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?Lt.empty:new Lt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ki(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 Ki(n.from,n.to,Lt.fromJSON(e,n.slice),!!n.structure)}}Da.jsonID("replace",Ki);class Qi extends Da{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&&(iR(e,this.from,this.gapFrom)||iR(e,this.gapTo,this.to)))return xi.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return xi.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?xi.fromReplace(e,this.from,this.to,r):xi.fail("Content does not fit in gap")}getMap(){return new Is([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 Qi(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 Qi(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 Qi(n.from,n.to,n.gapFrom,n.gapTo,Lt.fromJSON(e,n.slice),n.insert,!!n.structure)}}Da.jsonID("replaceAround",Qi);function iR(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 R8e(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),g=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=g:i.push(o=new Yo(m,g,f[y])));l&&l.to==m?l.to=g:a.push(l=new bd(m,g,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function D8e(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 VM){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 g=0;g<i.length;g++){let x=i[g];x.step==a-1&&f.eq(i[g].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 Yo(o.from,o.to,o.style)))}function zO(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 Ki(l,d,Lt.empty));else{r=f;for(let m=0;m<u.marks.length;m++)n.allowsMarkType(u.marks[m].type)||t.step(new Yo(l,d,u.marks[m]));if(i&&u.isText&&n.whitespace!="pre"){let m,g=/\r?\n|\r/g,x;for(;m=g.exec(u.text);)x||(x=new Lt(Nt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new Ki(l+m.index,l+m.index+m[0].length,x))}}l=d}if(!r.validEnd){let c=r.fillBefore(Nt.empty,!0);t.replace(l,l,new Lt(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function O8e(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Xg(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||!O8e(o,l,c))break;l&&(i=1),c<o.childCount&&(a=1)}return null}function L8e(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=Nt.empty,f=0;for(let x=a,y=!1;x>n;x--)y||r.index(x)>0?(y=!0,d=Nt.from(r.node(x).copy(d)),f++):c--;let m=Nt.empty,g=0;for(let x=a,y=!1;x>n;x--)y||i.after(x+1)<i.end(x)?(y=!0,m=Nt.from(i.node(x).copy(m)),g++):u++;t.step(new Qi(c,u,o,l,new Lt(d.append(m),f,g),d.size-f,!0))}function BO(t,e,n=null,r=t){let i=I8e(t,e),a=i&&F8e(r,e);return a?i.map(_9).concat({type:e,attrs:n}).concat(a.map(_9)):null}function _9(t){return{type:t,attrs:null}}function I8e(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 F8e(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 U8e(t,e,n){let r=Nt.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=Nt.from(n[o].type.create(n[o].attrs,r))}let i=e.start,a=e.end;t.step(new Qi(i,a,i,a,new Lt(r,0,0),n.length,!0))}function z8e(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)&&B8e(t.doc,t.mapping.slice(a).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let g=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);g&&!x?u=!1:!g&&x&&(u=!0)}u===!1&&Mee(t,o,l,a),zO(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 Qi(f,m,f+1,m-1,new Lt(Nt.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&See(t,o,l,a),!1}})}function See(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 Mee(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+a);t.replaceWith(o,o+1,e.type.schema.text(`
- `))}})}function B8e(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function $8e(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 Qi(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Lt(Nt.from(o),0,0),1,!0))}function Yc(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 g=f.content.cutByIndex(m,f.childCount),x=r&&r[d+1];x&&(g=g.replaceChild(0,x.type.create(x.attrs)));let y=r&&r[d]||f;if(!f.canReplace(m+1,f.childCount)||!y.type.validContent(g))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 H8e(t,e,n=1,r){let i=t.doc.resolve(e),a=Nt.empty,o=Nt.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){a=Nt.from(i.node(l).copy(a));let d=r&&r[u];o=Nt.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new Ki(e,e,new Lt(a.append(o),n,n),!0))}function th(t,e){let n=t.resolve(e),r=n.index();return Nee(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function V8e(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 Nee(t,e){return!!(t&&e&&!t.isLeaf&&V8e(t,e))}function GM(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&&Nee(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 G8e(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);Mee(t,d.node(),d.before(),l)}o.inlineContent&&zO(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 Ki(u,c.map(e+n,-1),Lt.empty,!0)),r===!0){let d=t.doc.resolve(u);See(t,d.node(),d.before(),t.steps.length)}return t}function W8e(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 Eee(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 WM(t,e,n=e,r=Lt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return Aee(i,a,r)?new Ki(e,n,r):new q8e(i,a,r).fit()}function Aee(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class q8e{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Nt.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=Nt.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 Lt(a,o,l);return e>-1?new Qi(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Ki(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=zk(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(Nt.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=zk(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Lt(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=zk(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Lt(Mb(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Lt(Mb(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 g=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(Tee(y.mark(m.allowedMarks(y.marks)),u==1?c:0,u==l.childCount?g:-1)))}let x=u==l.childCount;x||(g=-1),this.placed=Nb(this.placed,n,Nt.from(d)),this.frontier[n].match=f,x&&g<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,b=l;y<g;y++){let v=b.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),b=v.content}this.unplaced=x?e==0?Lt.empty:new Lt(Mb(o.content,e-1,1),e-1,g<0?o.openEnd:e-1):new Lt(Mb(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||!Bk(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=Bk(e,n,i,r,a);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=Bk(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=Nb(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=Nb(this.placed,this.depth,Nt.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Nt.empty,!0);n.childCount&&(this.placed=Nb(this.placed,this.frontier.length,n))}}function Mb(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Mb(t.firstChild.content,e-1,n)))}function Nb(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Nb(t.lastChild.content,e-1,n)))}function zk(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Tee(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Tee(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(Nt.empty,!0)))),t.copy(r)}function Bk(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&&!K8e(n,a.content,o)?l:null}function K8e(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function X8e(t){return t.spec.defining||t.spec.definingForContent}function Y8e(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(Aee(i,a,r))return t.step(new Ki(e,n,r));let o=kee(i,a);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let m=i.depth,g=i.pos-1;m>0;m--,g--){let x=i.node(m).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;o.indexOf(m)>-1?l=m:i.before(m)==g&&o.splice(1,0,-m)}let c=o.indexOf(l),u=[],d=r.openStart;for(let m=r.content,g=0;;g++){let x=m.firstChild;if(u.push(x),g==r.openStart)break;m=x.content}for(let m=d-1;m>=0;m--){let g=u[m],x=X8e(g.type);if(x&&!g.sameMarkup(i.node(Math.abs(l)-1)))d=m;else if(x||!g.type.isTextblock)break}for(let m=r.openStart;m>=0;m--){let g=(m+d+1)%(r.openStart+1),x=u[g];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 M=i.node(b-1),S=i.index(b-1);if(M.canReplaceWith(S,S,x.type,x.marks))return t.replace(i.before(b),v?a.after(b):n,new Lt(Cee(r.content,0,r.openStart,g),g,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 g=o[m];g<0||(e=i.before(g),n=a.after(g))}}function Cee(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(Cee(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(Nt.empty,!0))}return t}function Q8e(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=W8e(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Lt(Nt.from(r),0,0))}function Z8e(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=kee(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 kee(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 Gp extends Da{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 xi.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 xi.fromReplace(e,this.pos,this.pos+1,new Lt(Nt.from(i),0,n.isLeaf?0:1))}getMap(){return Is.empty}invert(e){return new Gp(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 Gp(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 Gp(n.pos,n.attr,n.value)}}Da.jsonID("attr",Gp);class L0 extends Da{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 xi.ok(r)}getMap(){return Is.empty}invert(e){return new L0(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 L0(n.attr,n.value)}}Da.jsonID("docAttr",L0);let yg=class extends Error{};yg=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};yg.prototype=Object.create(Error.prototype);yg.prototype.constructor=yg;yg.prototype.name="TransformError";class jee{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new O0}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new yg(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=Lt.empty){let i=WM(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Lt(Nt.from(r),0,0))}delete(e,n){return this.replace(e,n,Lt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Y8e(this,e,n,r),this}replaceRangeWith(e,n,r){return Q8e(this,e,n,r),this}deleteRange(e,n){return Z8e(this,e,n),this}lift(e,n){return L8e(this,e,n),this}join(e,n=1){return G8e(this,e,n),this}wrap(e,n){return U8e(this,e,n),this}setBlockType(e,n=e,r,i=null){return z8e(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return $8e(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Gp(e,n,r)),this}setDocAttribute(e,n){return this.step(new L0(e,n)),this}addNodeMark(e,n){return this.step(new yd(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 pr)n.isInSet(r.marks)&&this.step(new Uf(e,n));else{let i=r.marks,a,o=[];for(;a=n.isInSet(i);)o.push(new Uf(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 H8e(this,e,n,r),this}addMark(e,n,r){return R8e(this,e,n,r),this}removeMark(e,n,r){return D8e(this,e,n,r),this}clearIncompatible(e,n,r){return zO(this,e,n,r),this}}const $k=Object.create(null);class _n{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new J8e(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=Lt.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?Lt.empty:n),l==0&&M9(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),M9(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new sn(e):wp(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?wp(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):wp(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 Hs(e.node(0))}static atStart(e){return wp(e,e,0,0,1)||new Hs(e)}static atEnd(e){return wp(e,e,e.content.size,e.childCount,-1)||new Hs(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=$k[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 $k)throw new RangeError("Duplicate use of selection JSON ID "+e);return $k[e]=n,n.prototype.jsonID=e,n}getBookmark(){return sn.between(this.$anchor,this.$head).getBookmark()}}_n.prototype.visible=!0;class J8e{constructor(e,n){this.$from=e,this.$to=n}}let w9=!1;function S9(t){!w9&&!t.parent.inlineContent&&(w9=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class sn extends _n{constructor(e,n=e){S9(e),S9(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 _n.near(r);let i=e.resolve(n.map(this.anchor));return new sn(i.parent.inlineContent?i:r,r)}replace(e,n=Lt.empty){if(super.replace(e,n),n==Lt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof sn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new qM(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 sn(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=_n.findFrom(n,r,!0)||_n.findFrom(n,-r,!0);if(a)n=a.$head;else return _n.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(_n.findFrom(e,-r,!0)||_n.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new sn(e,n)}}_n.jsonID("text",sn);class qM{constructor(e,n){this.anchor=e,this.head=n}map(e){return new qM(e.map(this.anchor),e.map(this.head))}resolve(e){return sn.between(e.resolve(this.anchor),e.resolve(this.head))}}class Yt extends _n{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?_n.near(a):new Yt(a)}content(){return new Lt(Nt.from(this.node),0,0)}eq(e){return e instanceof Yt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new $O(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Yt(e.resolve(n.anchor))}static create(e,n){return new Yt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Yt.prototype.visible=!1;_n.jsonID("node",Yt);class $O{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new qM(r,r):new $O(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Yt.isSelectable(r)?new Yt(n):_n.near(n)}}class Hs extends _n{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Lt.empty){if(n==Lt.empty){e.delete(0,e.doc.content.size);let r=_n.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Hs(e)}map(e){return new Hs(e)}eq(e){return e instanceof Hs}getBookmark(){return e6e}}_n.jsonID("all",Hs);const e6e={map(){return this},resolve(t){return new Hs(t)}};function wp(t,e,n,r,i,a=!1){if(e.inlineContent)return sn.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&&Yt.isSelectable(l))return Yt.create(t,n-(i<0?l.nodeSize:0))}else{let c=wp(t,l,n+i,i<0?l.childCount:0,i,a);if(c)return c}n+=l.nodeSize*i}return null}function M9(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Ki||i instanceof Qi))return;let a=t.mapping.maps[r],o;a.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(_n.near(t.doc.resolve(o),n))}const N9=1,g1=2,E9=4;class t6e extends jee{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|N9)&~g1,this.storedMarks=null,this}get selectionSet(){return(this.updated&N9)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=g1,this}ensureMarks(e){return pr.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&g1)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~g1,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)||pr.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(_n.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|=E9,this}get scrolledIntoView(){return(this.updated&E9)>0}}function A9(t,e){return!e||!t?t:t.bind(e)}class Eb{constructor(e,n,r){this.name=e,this.init=A9(n.init,r),this.apply=A9(n.apply,r)}}const n6e=[new Eb("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Eb("selection",{init(t,e){return t.selection||_n.atStart(e.doc)},apply(t){return t.selection}}),new Eb("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Eb("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Hk{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=n6e.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 Eb(r.key,r.spec.state,r))})}}class Pp{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 Pp(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 t6e(this)}static create(e){let n=new Hk(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Pp(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 Hk(this.schema,e.plugins),r=n.fields,i=new Pp(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 Hk(e.schema,e.plugins),a=new Pp(i);return i.fields.forEach(o=>{if(o.name=="doc")a.doc=kd.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=_n.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 Pee(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Pee(i,e,{})),n[r]=i}return n}class Br{constructor(e){this.spec=e,this.props={},e.props&&Pee(e.props,this,this.props),this.key=e.key?e.key.key:Ree("plugin")}getState(e){return e[this.key]}}const Vk=Object.create(null);function Ree(t){return t in Vk?t+"$"+ ++Vk[t]:(Vk[t]=0,t+"$")}class Li{constructor(e="key"){this.key=Ree(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const HO=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Dee(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Oee=(t,e,n)=>{let r=Dee(t,n);if(!r)return!1;let i=VO(r);if(!i){let o=r.blockRange(),l=o&&Xg(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let a=i.nodeBefore;if(Vee(t,i,e,-1))return!0;if(r.parent.content.size==0&&(vg(a,"end")||Yt.isSelectable(a)))for(let o=r.depth;;o--){let l=WM(t.doc,r.before(o),r.after(o),Lt.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(vg(a,"end")?_n.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):Yt.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},r6e=(t,e,n)=>{let r=Dee(t,n);if(!r)return!1;let i=VO(r);return i?Lee(t,i,e):!1},i6e=(t,e,n)=>{let r=Fee(t,n);if(!r)return!1;let i=GO(r);return i?Lee(t,i,e):!1};function Lee(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=WM(t.doc,a,c,Lt.empty);if(!u||u.from!=a||u instanceof Ki&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(sn.create(d.doc,a)),n(d.scrollIntoView())}return!0}function vg(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 Iee=(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=VO(r)}let o=a&&a.nodeBefore;return!o||!Yt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Yt.create(t.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function VO(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 Fee(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Uee=(t,e,n)=>{let r=Fee(t,n);if(!r)return!1;let i=GO(r);if(!i)return!1;let a=i.nodeAfter;if(Vee(t,i,e,1))return!0;if(r.parent.content.size==0&&(vg(a,"start")||Yt.isSelectable(a))){let o=WM(t.doc,r.before(),r.after(),Lt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(vg(a,"start")?_n.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):Yt.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},zee=(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=GO(r)}let o=a&&a.nodeAfter;return!o||!Yt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Yt.create(t.doc,a.pos)).scrollIntoView()),!0)};function GO(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 a6e=(t,e)=>{let n=t.selection,r=n instanceof Yt,i;if(r){if(n.node.isTextblock||!th(t.doc,n.from))return!1;i=n.from}else if(i=GM(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(Yt.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},s6e=(t,e)=>{let n=t.selection,r;if(n instanceof Yt){if(n.node.isTextblock||!th(t.doc,n.to))return!1;r=n.to}else if(r=GM(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},o6e=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&Xg(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},Bee=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
- `).scrollIntoView()),!0)};function WO(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 l6e=(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=WO(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(_n.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},$ee=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Hs||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=WO(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(sn.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Hee=(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(Yc(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Xg(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function c6e(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Yt&&e.selection.node.isBlock)return!r.parentOffset||!Yc(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 g=r.depth;;g--)if(r.node(g).isBlock){c=r.end(g)==r.pos+(r.depth-g),u=r.start(g)==r.pos-(r.depth-g),l=WO(r.node(g-1).contentMatchAt(r.indexAfter(g-1))),a.unshift(c&&l?{type:l}:null),o=g;break}else{if(g==1)return!1;a.unshift(null)}let d=e.tr;(e.selection instanceof sn||e.selection instanceof Hs)&&d.deleteSelection();let f=d.mapping.map(r.pos),m=Yc(d.doc,f,a.length,a);if(m||(a[0]=l?{type:l}:null,m=Yc(d.doc,f,a.length,a)),!m)return!1;if(d.split(f,a.length,a),!c&&u&&r.node(o).type!=l){let g=d.mapping.map(r.before(o)),x=d.doc.resolve(g);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 u6e=c6e(),d6e=(t,e)=>{let{$from:n,to:r}=t.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),e&&e(t.tr.setSelection(Yt.create(t.doc,i))),!0)};function h6e(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||th(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Vee(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,o,l,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&h6e(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 g=e.pos+a.nodeSize,x=Nt.empty;for(let v=o.length-1;v>=0;v--)x=Nt.from(o[v].create(null,x));x=Nt.from(i.copy(x));let y=t.tr.step(new Qi(e.pos-1,g,e.pos,g,new Lt(x,1,0),o.length,!0)),b=y.doc.resolve(g+2*o.length);b.nodeAfter&&b.nodeAfter.type==i.type&&th(y.doc,b.pos)&&y.join(b.pos),n(y.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:_n.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),m=f&&Xg(f);if(m!=null&&m>=e.depth)return n&&n(t.tr.lift(f,m).scrollIntoView()),!0;if(u&&vg(a,"start",!0)&&vg(i,"end")){let g=i,x=[];for(;x.push(g),!g.isTextblock;)g=g.lastChild;let y=a,b=1;for(;!y.isTextblock;y=y.firstChild)b++;if(g.canReplace(g.childCount,g.childCount,y.content)){if(n){let v=Nt.empty;for(let S=x.length-1;S>=0;S--)v=Nt.from(x[S].copy(v));let M=t.tr.step(new Qi(e.pos-x.length,e.pos+a.nodeSize,e.pos+b,e.pos+a.nodeSize-b,new Lt(v,x.length,0),0,!0));n(M.scrollIntoView())}return!0}}return!1}function Gee(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(sn.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const f6e=Gee(-1),m6e=Gee(1);function p6e(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),l=o&&BO(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function T9(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 qO(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}qO(HO,Oee,Iee);qO(HO,Uee,zee);qO(Bee,$ee,Hee,u6e);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function g6e(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 x6e(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function x6e(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 jS(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new jS(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=BO(a,n,r,e);return l?(t&&b6e(t,e,l,i,n),!0):!1}function b6e(t,e,n,r,i){let a=Nt.empty;for(let d=n.length-1;d>=0;d--)a=Nt.from(n[d].type.create(n[d].attrs,a));t.step(new Qi(e.start-(r?2:0),e.end,e.start,e.end,new Lt(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&&Yc(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function y6e(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?v6e(e,n,t,a):_6e(e,n,a):!0:!1}}function v6e(t,e,n,r){let i=t.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new Qi(a-1,o,a,o,new Lt(Nt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new jS(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=Xg(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return th(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function _6e(t,e,n){let r=t.tr,i=n.parent;for(let g=n.end,x=n.endIndex-1,y=n.startIndex;x>y;x--)g-=i.child(x).nodeSize,r.delete(g-1,g+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?Nt.empty:Nt.from(i))))return!1;let f=a.pos,m=f+o.nodeSize;return r.step(new Qi(f-(l?1:0),m+(c?1:0),f+1,m-1,new Lt((l?Nt.empty:Nt.from(i.copy(Nt.empty))).append(c?Nt.empty:Nt.from(i.copy(Nt.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function w6e(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=Nt.from(u?t.create():null),f=new Lt(Nt.from(t.create(null,Nt.from(l.type.create(null,d)))),u?3:1,0),m=a.start,g=a.end;n(e.tr.step(new Qi(m-(u?3:1),g,m,g,f,1,!0)).scrollIntoView())}return!0}}const pa=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},_g=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let aR=null;const jc=function(t,e,n){let r=aR||(aR=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},S6e=function(){aR=null},zf=function(t,e,n,r){return n&&(C9(t,e,n,r,-1)||C9(t,e,n,r,1))},M6e=/^(img|br|input|textarea|hr)$/i;function C9(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:yo(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Cy(t)||M6e.test(t.nodeName)||t.contentEditable=="false")return!1;e=pa(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?yo(t):0}else return!1}}function yo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function N6e(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=yo(t)}else if(t.parentNode&&!Cy(t))e=pa(t),t=t.parentNode;else return null}}function E6e(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&&!Cy(t))e=pa(t)+1,t=t.parentNode;else return null}}function A6e(t,e,n){for(let r=e==0,i=e==yo(t);r||i;){if(t==n)return!0;let a=pa(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==yo(t)}}function Cy(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 KM=function(t){return t.focusNode&&zf(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function $h(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function T6e(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function C6e(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(yo(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(yo(r.startContainer),r.startOffset)}}}const $l=typeof navigator<"u"?navigator:null,k9=typeof document<"u"?document:null,nh=$l&&$l.userAgent||"",sR=/Edge\/(\d+)/.exec(nh),Wee=/MSIE \d/.exec(nh),oR=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nh),gs=!!(Wee||oR||sR),jd=Wee?document.documentMode:oR?+oR[1]:sR?+sR[1]:0,Mo=!gs&&/gecko\/(\d+)/i.test(nh);Mo&&+(/Firefox\/(\d+)/.exec(nh)||[0,0])[1];const lR=!gs&&/Chrome\/(\d+)/.exec(nh),ka=!!lR,qee=lR?+lR[1]:0,Ka=!gs&&!!$l&&/Apple Computer/.test($l.vendor),wg=Ka&&(/Mobile\/\w+/.test(nh)||!!$l&&$l.maxTouchPoints>2),fo=wg||($l?/Mac/.test($l.platform):!1),k6e=$l?/Win/.test($l.platform):!1,Hc=/Android \d/.test(nh),ky=!!k9&&"webkitFontSmoothing"in k9.documentElement.style,j6e=ky?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function P6e(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 Nc(t,e){return typeof t=="number"?t:t[e]}function R6e(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 j9(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=_g(o);continue}let l=o,c=l==a.body,u=c?P6e(a):R6e(l),d=0,f=0;if(e.top<u.top+Nc(r,"top")?f=-(u.top-e.top+Nc(i,"top")):e.bottom>u.bottom-Nc(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+Nc(i,"top")-u.top:e.bottom-u.bottom+Nc(i,"bottom")),e.left<u.left+Nc(r,"left")?d=-(u.left-e.left+Nc(i,"left")):e.right>u.right-Nc(r,"right")&&(d=e.right-u.right+Nc(i,"right")),d||f)if(c)a.defaultView.scrollBy(d,f);else{let g=l.scrollLeft,x=l.scrollTop;f&&(l.scrollTop+=f),d&&(l.scrollLeft+=d);let y=l.scrollLeft-g,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:_g(o)}}function D6e(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:Kee(t.dom)}}function Kee(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=_g(r));return e}function O6e({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Xee(n,r==0?0:r-e)}function Xee(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 mp=null;function L6e(t){if(t.setActive)return t.setActive();if(mp)return t.focus(mp);let e=Kee(t);t.focus(mp==null?{get preventScroll(){return mp={preventScroll:!0},!0}}:void 0),mp||(mp=!1,Xee(e,0))}function Yee(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=jc(d).getClientRects();else continue;for(let g=0;g<m.length;g++){let x=m[g];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?I6e(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:Yee(n,i)}function I6e(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=td(r,1);if(a.top!=a.bottom&&KO(e,a))return{node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function KO(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function F6e(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function U6e(t,e,n){let{node:r,offset:i}=Yee(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 z6e(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 Qee(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(KO(e,u))return Qee(o,e,u)}}if((a=(a+1)%r)==i)break}return t}function B6e(t,e){let n=t.dom.ownerDocument,r,i=0,a=C6e(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(!KO(e,u)||(o=Qee(t.dom,e,u),!o))return null}if(Ka)for(let u=o;r&&u;u=_g(u))u.draggable&&(r=void 0);if(o=F6e(o,e),r){if(Mo&&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;ky&&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=z6e(t,r,i,e))}l==null&&(l=U6e(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function P9(t){return t.top<t.bottom||t.left<t.right}function td(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(P9(r))return r}return Array.prototype.find.call(n,P9)||t.getBoundingClientRect()}const $6e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Zee(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),o=ky||Mo;if(r.nodeType==3)if(o&&($6e.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=td(jc(r,i,i),n);if(Mo&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=td(jc(r,i-1,i-1),-1);if(u.top==c.top){let d=td(jc(r,i,i+1),-1);if(d.top!=c.top)return hb(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++,hb(td(jc(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==yo(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return Gk(c.getBoundingClientRect(),!1)}if(a==null&&i<yo(r)){let c=r.childNodes[i];if(c.nodeType==1)return Gk(c.getBoundingClientRect(),!0)}return Gk(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==yo(r))){let c=r.childNodes[i-1],u=c.nodeType==3?jc(c,yo(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return hb(td(u,1),!1)}if(a==null&&i<yo(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?jc(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return hb(td(u,-1),!0)}return hb(td(r.nodeType==3?jc(r):r,-n),n>=0)}function hb(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 Gk(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 Jee(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 H6e(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Jee(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=Zee(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=jc(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 V6e=/[\u0590-\u08ac]/;function G6e(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?!V6e.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?a:o:Jee(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),m=l.caretBidiLevel;l.modify("move",n,"character");let g=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:y}=t.domSelectionRange(),b=x&&!g.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 R9=null,D9=null,O9=!1;function W6e(t,e,n){return R9==e&&D9==n?O9:(R9=e,D9=n,O9=n=="up"||n=="down"?H6e(t,e,n):G6e(t,e,n))}const No=0,L9=1,Qh=2,Hl=3;class jy{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=No,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>pa(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 tte){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 ete&&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?pa(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?pa(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=pa(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=pa(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 g=0,x=0;g<this.children.length;g++){let y=this.children[g],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((Mo||Ka)&&e==n){let{node:g,offset:x}=l;if(g.nodeType==3){if(f=!!(x&&g.nodeValue[x-1]==`
- `),f&&x==g.nodeValue.length)for(let y=g,b;y;y=y.parentNode){if(b=y.nextSibling){b.nodeName=="BR"&&(l=c={node:b.parentNode,offset:pa(b)+1});break}let v=y.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let y=g.childNodes[x-1];f=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(Mo&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let g=d.focusNode.childNodes[d.focusOffset];g&&g.contentEditable=="false"&&(i=!0)}if(!(i||f&&Ka)&&zf(l.node,l.offset,d.anchorNode,d.anchorOffset)&&zf(c.node,c.offset,d.focusNode,d.focusOffset))return;let m=!1;if((u.extend||e==n)&&!(f&&Mo)){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 g=document.createRange();g.setEnd(c.node,c.offset),g.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(g)}}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?Qh:L9,e==l&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=Hl:a.markDirty(e-l,n-l);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?Qh:Hl}r=o}this.dirty=Qh}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Qh:L9;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class ete extends jy{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==No&&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 q6e extends jy{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 Bf extends jy{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=Yf.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Bf(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Hl||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Hl&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=No){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=No}}slice(e,n,r){let i=Bf.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=uR(a,n,o,r)),e>0&&(a=uR(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 Pd extends jy{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}=Yf.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=ite(d,r,n),u?c=new K6e(e,n,r,i,d,f||null,m,u,a,o+1):n.isText?new XM(e,n,r,i,d,m,a):new Pd(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=()=>Nt.empty)}return e}matchesNode(e,n,r){return this.dirty==No&&e.eq(this.node)&&RS(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 Y6e(this,o&&o.node,e);J6e(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?pr.none:this.node.child(d).marks,r,e),c.placeWidget(u,e,i)},(u,d,f,m)=>{c.syncToMarks(u.marks,r,e);let g;c.findNodeMatch(u,d,f,m)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(g=c.findIndexWithChild(a.node))>-1&&c.updateNodeAt(u,d,f,g,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==Qh)&&(o&&this.protectLocalComposition(e,o),nte(this.contentDOM,this.children,e),wg&&e$e(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof sn)||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=t$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 q6e(this,a,n,i);e.input.compositionNodes.push(o),this.children=uR(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==Hl||!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=No}updateOuterDeco(e){if(RS(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=rte(this.dom,this.nodeDOM,cR(this.outerDeco,this.node,n),cR(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function I9(t,e,n,r,i){ite(r,e,t);let a=new Pd(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class XM extends Pd{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==Hl||this.dirty!=No&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=No||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=No,!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 XM(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=Hl)}get domAtom(){return!1}isText(e){return this.node.text==e}}class tte extends jy{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==No&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class K6e extends Pd{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==Hl)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let a=this.spec.update(e,n,r);return a&&this.updateInner(e,n,r,i),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function nte(t,e,n){let r=t.firstChild,i=!1;for(let a=0;a<e.length;a++){let o=e[a],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=F9(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof Bf){let c=r?r.previousSibling:t.lastChild;nte(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=F9(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const $b=function(t){t&&(this.nodeName=t)};$b.prototype=Object.create(null);const Zh=[new $b];function cR(t,e,n){if(t.length==0)return Zh;let r=n?Zh[0]:new $b,i=[r];for(let a=0;a<t.length;a++){let o=t[a].type.attrs;if(o){o.nodeName&&i.push(r=new $b(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new $b(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 rte(t,e,n,r){if(n==Zh&&r==Zh)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=Zh[0]),i=c}X6e(i,l||Zh[0],o)}return i}function X6e(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 ite(t,e,n){return rte(t,t,Zh,cR(e,n,t.nodeType!=1))}function RS(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 F9(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Y6e{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Q6e(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=No,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=Bf.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==Hl&&o.dom==o.contentDOM&&(o.dirty=Qh),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 Pd){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!=Hl&&RS(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=Qh,f.updateChildren(i,o+1),f.dirty=No),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)||!RS(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Pd.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=Pd.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 ete(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 Bf;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof XM)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ka||ka)&&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 tte(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 Q6e(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 Bf)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 Z6e(t,e){return t.type.side-e.type.side}function J6e(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(Z6e);for(let b=0;b<f.length;b++)n(f[b],u,!!c)}else n(d,u,!!c);let m,g;if(c)g=-1,m=c,c=null;else if(u<t.childCount)g=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,g=-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),g),a=x}}function e$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 t$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 uR(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 XO(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(KM(n)){for(c=o;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Yt.isSelectable(f)&&i.parent&&!(f.isInline&&A6e(n.focusNode,n.focusOffset,i.dom))){let m=i.posBefore;u=new Yt(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 g=0;g<n.rangeCount;g++){let x=n.getRangeAt(g);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=YO(t,d,l,f)}return u}function ate(t){return t.editable?t.hasFocus():ote(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Qc(t,e=!1){let n=t.state.selection;if(ste(t,n),!!ate(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ka){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&zf(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)r$e(t);else{let{anchor:r,head:i}=n,a,o;U9&&!(n instanceof sn)&&(n.$from.parent.inlineContent||(a=z9(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=z9(t,n.to))),t.docView.setSelection(r,i,t,e),U9&&(a&&B9(a),o&&B9(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&n$e(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const U9=Ka||ka&&qee<63;function z9(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(Ka&&i&&i.contentEditable=="false")return Wk(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return Wk(i);if(a)return Wk(a)}}function Wk(t){return t.contentEditable="true",Ka&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function B9(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function n$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(()=>{(!ate(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function r$e(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,pa(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&gs&&jd<=11&&(n.disabled=!0,n.disabled=!1)}function ste(t,e){if(e instanceof Yt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&($9(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else $9(t)}function $9(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function YO(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||sn.between(e,n,r)}function H9(t){return t.editable&&!t.hasFocus()?!1:ote(t)}function ote(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 i$e(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return zf(e.node,e.offset,n.anchorNode,n.anchorOffset)}function dR(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&&_n.findFrom(a,e)}function sd(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function V9(t,e,n){let r=t.state.selection;if(r instanceof sn)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 sd(t,new sn(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=dR(t.state,e);return i&&i instanceof Yt?sd(t,i):!1}else if(!(fo&&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?Yt.isSelectable(a)?sd(t,new Yt(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):ky?sd(t,new sn(t.state.doc.resolve(e<0?l:l+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Yt&&r.node.isInline)return sd(t,new sn(e>0?r.$to:r.$from));{let i=dR(t.state,e);return i?sd(t,i):!1}}}function DS(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Hb(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function pp(t,e){return e<0?a$e(t):s$e(t)}function a$e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,o=!1;for(Mo&&n.nodeType==1&&r<DS(n)&&Hb(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Hb(l,-1))i=n,a=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(lte(n))break;{let l=n.previousSibling;for(;l&&Hb(l,-1);)i=n.parentNode,a=pa(l),l=l.previousSibling;if(l)n=l,r=DS(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?hR(t,n,r):i&&hR(t,i,a)}function s$e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=DS(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Hb(l,1))a=n,o=++r;else break}else{if(lte(n))break;{let l=n.nextSibling;for(;l&&Hb(l,1);)a=l.parentNode,o=pa(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=DS(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&hR(t,a,o)}function lte(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function o$e(t,e){for(;t&&e==t.childNodes.length&&!Cy(t);)e=pa(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 l$e(t,e){for(;t&&!e&&!Cy(t);)e=pa(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 hR(t,e,n){if(e.nodeType!=3){let a,o;(o=o$e(e,n))?(e=o,n=0):(a=l$e(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(KM(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&&Qc(t)},50)}function G9(t,e){let n=t.state.doc.resolve(e);if(!(ka||k6e)&&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 W9(t,e,n){let r=t.state.selection;if(r instanceof sn&&!r.empty||n.indexOf("s")>-1||fo&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=dR(t.state,e);if(o&&o instanceof Yt)return sd(t,o)}if(!i.parent.inlineContent){let o=e<0?i:a,l=r instanceof Hs?_n.near(o,e):_n.findFrom(o,e);return l?sd(t,l):!1}return!1}function q9(t,e){if(!(t.state.selection instanceof sn))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 K9(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function c$e(t){if(!Ka||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;K9(t,r,"true"),setTimeout(()=>K9(t,r,"false"),20)}return!1}function u$e(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function d$e(t,e){let n=e.keyCode,r=u$e(e);if(n==8||fo&&n==72&&r=="c")return q9(t,-1)||pp(t,-1);if(n==46&&!e.shiftKey||fo&&n==68&&r=="c")return q9(t,1)||pp(t,1);if(n==13||n==27)return!0;if(n==37||fo&&n==66&&r=="c"){let i=n==37?G9(t,t.state.selection.from)=="ltr"?-1:1:-1;return V9(t,i,r)||pp(t,i)}else if(n==39||fo&&n==70&&r=="c"){let i=n==39?G9(t,t.state.selection.from)=="ltr"?1:-1:1;return V9(t,i,r)||pp(t,i)}else{if(n==38||fo&&n==80&&r=="c")return W9(t,-1,r)||pp(t,-1);if(n==40||fo&&n==78&&r=="c")return c$e(t)||W9(t,1,r)||pp(t,1);if(r==(fo?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function QO(t,e){t.someProp("transformCopied",g=>{e=g(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 g=r.firstChild;n.push(g.type.name,g.attrs!=g.type.defaultAttrs?g.attrs:null),r=g.content}let o=t.someProp("clipboardSerializer")||Yf.fromSchema(t.state.schema),l=mte(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=fte[u.nodeName.toLowerCase()]);){for(let g=d.length-1;g>=0;g--){let x=l.createElement(d[g]);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",g=>g(e,t))||e.content.textBetween(0,e.content.size,`
- `);return{dom:c,text:m,slice:e}}function cte(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 Lt(Nt.from(t.state.schema.text(e.replace(/\r\n?/g,`
- `))),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:g}=t.state,x=Yf.fromSchema(g);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let b=o.appendChild(document.createElement("p"));y&&b.appendChild(x.serializeNode(g.text(y,m)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=p$e(n),ky&&g$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")||zb.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(m){return m.nodeName=="BR"&&!m.nextSibling&&m.parentNode&&!h$e.test(m.parentNode.nodeName)?{ignore:!0}:null}})),d)l=x$e(X9(l,+d[1],+d[2]),d[4]);else if(l=Lt.maxOpen(f$e(l.content,i),!0),l.openStart||l.openEnd){let f=0,m=0;for(let g=l.content.firstChild;f<l.openStart&&!g.type.spec.isolating;f++,g=g.firstChild);for(let g=l.content.lastChild;m<l.openEnd&&!g.type.spec.isolating;m++,g=g.lastChild);l=X9(l,f,m)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const h$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 f$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&&dte(c,a,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=hte(o[o.length-1],a.length));let d=ute(l,c);o.push(d),i=i.matchType(d.type),a=c}}),o)return Nt.from(o)}return t}function ute(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Nt.from(t));return t}function dte(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=dte(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(Nt.from(ute(n,t,i+1))))}}function hte(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,hte(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(Nt.empty,!0);return t.copy(n.append(r))}function fR(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=fR(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(Nt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function X9(t,e,n){return e<t.openStart&&(t=new Lt(fR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Lt(fR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const fte={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 Y9=null;function mte(){return Y9||(Y9=document.implementation.createHTMLDocument("title"))}let qk=null;function m$e(t){let e=window.trustedTypes;return e?(qk||(qk=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),qk.createHTML(t)):t}function p$e(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=mte().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&fte[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=m$e(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function g$e(t){let e=t.querySelectorAll(ka?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function x$e(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart: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=Nt.from(c.create(r[l+1],i)),a++,o++}return new Lt(i,a,o)}const Xa={},Ya={},b$e={touchstart:!0,touchmove:!0};class y$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 v$e(t){for(let e in Xa){let n=Xa[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{w$e(t,r)&&!ZO(t,r)&&(t.editable||!(r.type in Ya))&&n(t,r)},b$e[e]?{passive:!0}:void 0)}Ka&&t.dom.addEventListener("input",()=>null),mR(t)}function vd(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function _$e(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function mR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>ZO(t,r))})}function ZO(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function w$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 S$e(t,e){!ZO(t,e)&&Xa[e.type]&&(t.editable||!(e.type in Ya))&&Xa[e.type](t,e)}Ya.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!gte(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Hc&&ka&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),wg&&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,$h(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||d$e(t,n)?n.preventDefault():vd(t,"key")};Ya.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ya.keypress=(t,e)=>{let n=e;if(gte(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||fo&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof sn)||!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 YM(t){return{left:t.clientX,top:t.clientY}}function M$e(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function JO(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 Wp(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 N$e(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Yt.isSelectable(r)?(Wp(t,new Yt(n)),!0):!1}function E$e(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Yt&&(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(Yt.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?(Wp(t,Yt.create(t.state.doc,i)),!0):!1}function A$e(t,e,n,r,i){return JO(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?E$e(t,n):N$e(t,n))}function T$e(t,e,n,r){return JO(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function C$e(t,e,n,r){return JO(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||k$e(t,n,r)}function k$e(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Wp(t,sn.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)Wp(t,sn.create(r,l+1,l+1+o.content.size));else if(Yt.isSelectable(o))Wp(t,Yt.create(r,l));else continue;return!0}}function eL(t){return OS(t)}const pte=fo?"metaKey":"ctrlKey";Xa.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=eL(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&M$e(n,t.input.lastClick)&&!n[pte]&&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(YM(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new j$e(t,o,n,!!r)):(a=="doubleClick"?T$e:C$e)(t,o.pos,o.inside,n)?n.preventDefault():vd(t,"pointer"))};class j$e{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[pte],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 Yt&&u.from<=o&&u.to>o)&&(this.mightDrag={node:a,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Mo&&!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)),vd(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(()=>Qc(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(YM(e))),this.updateAllowDefault(e),this.allowDefault||!n?vd(this.view,"pointer"):A$e(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ka&&this.mightDrag&&!this.mightDrag.node.isAtom||ka&&!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)?(Wp(this.view,_n.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):vd(this.view,"pointer")}move(e){this.updateAllowDefault(e),vd(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)}}Xa.touchstart=t=>{t.input.lastTouch=Date.now(),eL(t),vd(t,"pointer")};Xa.touchmove=t=>{t.input.lastTouch=Date.now(),vd(t,"pointer")};Xa.contextmenu=t=>eL(t);function gte(t,e){return t.composing?!0:Ka&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const P$e=Hc?5e3:-1;Ya.compositionstart=Ya.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof sn&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),OS(t,!0),t.markCursor=null;else if(OS(t,!e.selection.empty),Mo&&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}xte(t,P$e)};Ya.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++,xte(t,20))};function xte(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>OS(t),e))}function bte(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=D$e());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function R$e(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=N6e(e.focusNode,e.focusOffset),r=E6e(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 D$e(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function OS(t,e=!1){if(!(Hc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),bte(t),e||t.docView&&t.docView.dirty){let n=XO(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 O$e(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const I0=gs&&jd<15||wg&&j6e<604;Xa.copy=Ya.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=I0?null:n.clipboardData,o=r.content(),{dom:l,text:c}=QO(t,o);a?(n.preventDefault(),a.clearData(),a.setData("text/html",l.innerHTML),a.setData("text/plain",c)):O$e(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function L$e(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function I$e(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?F0(t,r.value,null,i,e):F0(t,r.textContent,r.innerHTML,i,e)},50)}function F0(t,e,n,r,i){let a=cte(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||Lt.empty)))return!0;if(!a)return!1;let o=L$e(a),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(a);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function yte(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," "):""}Ya.paste=(t,e)=>{let n=e;if(t.composing&&!Hc)return;let r=I0?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&F0(t,yte(r),r.getData("text/html"),i,n)?n.preventDefault():I$e(t,n)};class vte{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const F$e=fo?"altKey":"ctrlKey";function _te(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[F$e]}Xa.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(YM(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Yt?i.to-1:i.to))){if(r&&r.mightDrag)o=Yt.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=Yt.create(t.state.doc,f.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:u,slice:d}=QO(t,l);(!n.dataTransfer.files.length||!ka||qee>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(I0?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",I0||n.dataTransfer.setData("text/plain",u),t.dragging=new vte(d,_te(t,n),o)};Xa.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ya.dragover=Ya.dragenter=(t,e)=>e.preventDefault();Ya.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(YM(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=cte(t,yte(n.dataTransfer),I0?null:n.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&_te(t,n));if(t.someProp("handleDrop",x=>x(t,n,o||Lt.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let c=o?Eee(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 g=u.doc.resolve(d);if(f&&Yt.isSelectable(o.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new Yt(g));else{let x=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((y,b,v,M)=>x=M),u.setSelection(YO(t,g,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};Xa.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())&&Qc(t)},20))};Xa.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)};Xa.beforeinput=(t,e)=>{if(ka&&Hc&&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,$h(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 Ya)Xa[t]=Ya[t];function U0(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 LS{constructor(e,n){this.toDOM=e,this.spec=n||mf,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 $a(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof LS&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&U0(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Rd{constructor(e,n){this.attrs=e,this.spec=n||mf}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 $a(a,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Rd&&U0(this.attrs,e.attrs)&&U0(this.spec,e.spec)}static is(e){return e.type instanceof Rd}destroy(){}}class tL{constructor(e,n){this.attrs=e,this.spec=n||mf}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 $a(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 tL&&U0(this.attrs,e.attrs)&&U0(this.spec,e.spec)}destroy(){}}class $a{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new $a(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 $a(e,e,new LS(n,r))}static inline(e,n,r,i){return new $a(e,n,new Rd(r,i))}static node(e,n,r,i){return new $a(e,n,new tL(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Rd}get widget(){return this.type instanceof LS}}const Sp=[],mf={};class Or{constructor(e,n){this.local=e.length?e:Sp,this.children=n.length?n:Sp}static create(e,n){return n.length?IS(n,e,0,mf):Aa}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==Aa||e.maps.length==0?this:this.mapInner(e,n,0,0,r||mf)}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?U$e(this.children,o||[],e,n,r,i,a):o?new Or(o.sort(pf),Sp):Aa}add(e,n){return n.length?this==Aa?Or.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=Ste(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,IS(d,l,u+1,mf)),a+=3}});let o=wte(a?Mte(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new Or(o.length?this.local.concat(o).sort(pf):this.local,i||this.children)}remove(e){return e.length==0||this==Aa?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!=Aa?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 Or(i,r):Aa}forChild(e,n){if(this==Aa)return this;if(n.isLeaf)return Or.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 Rd){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 Or(i.sort(pf),Sp);return r?new hd([l,r]):l}return r||Aa}eq(e){if(this==e)return!0;if(!(e instanceof Or)||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 nL(this.localsInner(e))}localsInner(e){if(this==Aa)return Sp;if(e.inlineContent||!this.local.some(Rd.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Rd||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Or.empty=new Or([],[]);Or.removeOverlap=nL;const Aa=Or.empty;class hd{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,mf));return hd.from(r)}forChild(e,n){if(n.isLeaf)return Or.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=Aa&&(a instanceof hd?r=r.concat(a.members):r.push(a))}return hd.from(r)}eq(e){if(!(e instanceof hd)||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?nL(r?n:n.sort(pf)):Sp}static from(e){switch(e.length){case 0:return Aa;case 1:return e[0];default:return new hd(e.every(n=>n instanceof Or)?e:e.reduce((n,r)=>n.concat(r instanceof Or?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function U$e(t,e,n,r,i,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,g,x,y)=>{let b=y-x-(g-m);for(let v=0;v<l.length;v+=3){let M=l[v+1];if(M<0||m>M+d-f)continue;let S=l[v]+d-f;g>=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),g=m-i,{index:x,offset:y}=r.content.findIndex(f),b=r.maybeChild(x);if(b&&y==f&&y+b.nodeSize==g){let v=l[u+2].mapInner(n,b,d+1,t[u]+a+1,o);v!=Aa?(l[u]=f,l[u+1]=g,l[u+2]=v):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=z$e(l,t,e,n,i,a,o),d=IS(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 g=d.children[f];for(;m<l.length&&l[m]<g;)m+=3;l.splice(m,0,d.children[f],d.children[f+1],d.children[f+2])}}return new Or(e.sort(pf),l)}function wte(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 $a(i.from+e,i.to+e,i.type))}return n}function z$e(t,e,n,r,i,a,o){function l(c,u){for(let d=0;d<c.local.length;d++){let f=c.local[d].map(r,i,u);f?n.push(f):o.onRemove&&o.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)l(c.children[d+2],c.children[d]+u+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&l(t[c+2],e[c]+a+1);return n}function Ste(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 Mte(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function IS(t,e,n,r){let i=[],a=!1;e.forEach((l,c)=>{let u=Ste(t,l,c+n);if(u){a=!0;let d=IS(u,l,n+c+1,r);d!=Aa&&i.push(c,c+l.nodeSize,d)}});let o=wte(a?Mte(t):t,-n).sort(pf);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 Or(o,i):Aa}function pf(t,e){return t.from-e.from||t.to-e.to}function nL(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),Q9(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),Q9(e,i,r.copy(a.from,r.to)));break}}}return e}function Q9(t,e,n){for(;e<t.length&&pf(n,t[e])>0;)e++;t.splice(e,0,n)}function Kk(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Aa&&e.push(r)}),t.cursorWrapper&&e.push(Or.create(t.state.doc,[t.cursorWrapper.deco])),hd.from(e)}const B$e={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},$$e=gs&&jd<=11;class H$e{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class V$e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new H$e,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);gs&&jd<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),$$e&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,B$e)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(H9(this.view)){if(this.suppressingSelectionUpdates)return Qc(this.view);if(gs&&jd<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&zf(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=_g(a))n.add(a);for(let a=e.anchorNode;a;a=_g(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)&&H9(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(Mo&&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 g=m.parentNode;g&&g.nodeName=="LI"&&(!f||q$e(e,f)!=g)&&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&&KM(r)&&(u=XO(e))&&u.eq(_n.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Qc(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,o),G$e(e)),this.handleDOMChange(a,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Qc(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(gs&&jd<=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?pa(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=a&&a.parentNode==e.target?pa(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 Z9=new WeakMap,J9=!1;function G$e(t){if(!Z9.has(t)&&(Z9.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Mo,J9)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."),J9=!0}}function eG(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return zf(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function W$e(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return eG(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?eG(t,n):null}function q$e(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function K$e(t,e,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:l}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:c.anchorOffset}],KM(c)||u.push({node:c.focusNode,offset:c.focusOffset})),ka&&t.input.lastKeyCode===8)for(let b=a;b>i;b--){let v=r.childNodes[b-1],M=v.pmViewDesc;if(v.nodeName=="BR"&&!M){a=b;break}if(!M||M.size)break}let f=t.state.doc,m=t.someProp("domParser")||zb.fromSchema(t.state.schema),g=f.resolve(o),x=null,y=m.parse(r,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:i,to:a,preserveWhitespace:g.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:X$e,context:g});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 X$e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ka&&/^(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||Ka&&/^(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 Y$e=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Q$e(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let C=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,R=XO(t,C);if(R&&!t.state.selection.eq(R)){if(ka&&Hc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",P=>P(t,$h(13,"Enter"))))return;let T=t.state.tr.setSelection(R);C=="pointer"?T.setMeta("pointer",!0):C=="key"&&T.scrollIntoView(),a&&T.setMeta("composition",a),t.dispatch(T)}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=K$e(t,e,n),d=t.state.doc,f=d.slice(u.from,u.to),m,g;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(m=t.state.selection.to,g="end"):(m=t.state.selection.from,g="start"),t.input.lastKeyCode=null;let x=eHe(f.content,u.doc.content,u.from,m,g);if(x&&t.input.domChangeCount++,(wg&&t.input.lastIOSEnter>Date.now()-225||Hc)&&i.some(C=>C.nodeType==1&&!Y$e.test(C.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",C=>C(t,$h(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof sn&&!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 C=tG(t,t.state.doc,u.sel);if(C&&!C.eq(t.state.selection)){let R=t.state.tr.setSelection(C);a&&R.setMeta("composition",a),t.dispatch(R)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof sn&&(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)),gs&&jd<=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),M=y.sameParent(b)&&y.parent.inlineContent&&v.end()>=x.endA;if((wg&&t.input.lastIOSEnter>Date.now()-225&&(!M||i.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!M&&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",C=>C(t,$h(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&J$e(d,x.start,x.endA,y,b)&&t.someProp("handleKeyDown",C=>C(t,$h(8,"Backspace")))){Hc&&ka&&t.domObserver.suppressSelectionUpdates();return}ka&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),Hc&&!M&&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(C){return C(t,$h(13,"Enter"))})},20));let S=x.start,A=x.endA,E=C=>{let R=C||t.state.tr.replace(S,A,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let T=tG(t,R.doc,u.sel);T&&!(ka&&t.composing&&T.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(T.head==S||T.head==R.mapping.map(A)-1)||gs&&T.empty&&T.head==S)&&R.setSelection(T)}return a&&R.setMeta("composition",a),R.scrollIntoView()},k;if(M)if(y.pos==b.pos){gs&&jd<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Qc(t),20));let C=E(t.state.tr.delete(S,A)),R=d.resolve(x.start).marksAcross(d.resolve(x.endA));R&&C.ensureMarks(R),t.dispatch(C)}else if(x.endA==x.endB&&(k=Z$e(y.parent.content.cut(y.parentOffset,b.parentOffset),v.parent.content.cut(v.parentOffset,x.endA-v.start())))){let C=E(t.state.tr);k.type=="add"?C.addMark(S,A,k.mark):C.removeMark(S,A,k.mark),t.dispatch(C)}else if(y.parent.child(y.index()).isText&&y.index()==b.index()-(b.textOffset?0:1)){let C=y.parent.textBetween(y.parentOffset,b.parentOffset),R=()=>E(t.state.tr.insertText(C,S,A));t.someProp("handleTextInput",T=>T(t,S,A,C,R))||t.dispatch(R())}else t.dispatch(E());else t.dispatch(E())}function tG(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:YO(t,e.resolve(n.anchor),e.resolve(n.head))}function Z$e(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=r,o,l,c;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<n.length;d++)a=n[d].removeFromSet(a);if(i.length==1&&a.length==0)l=i[0],o="add",c=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&a.length==1)l=a[0],o="remove",c=d=>d.mark(l.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(c(e.child(d)));if(Nt.from(u).eq(t))return{mark:l,type:o}}function J$e(t,e,n,r,i){if(n-e<=i.pos-r.pos||Xk(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(Xk(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Xk(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Xk(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 eHe(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&&nG(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&&nG(t.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-l),l=a}return{start:a,endA:o,endB:l}}function nG(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 Nte{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 y$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(oG),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=aG(this),iG(this),this.nodeViews=sG(this),this.docView=I9(this.state.doc,rG(this),Kk(this),this.dom,this),this.domObserver=new V$e(this,(r,i,a,o)=>Q$e(this,r,i,a,o)),this.domObserver.start(),v$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&&mR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(oG),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,a=!1,o=!1;e.storedMarks&&this.composing&&(bte(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let g=sG(this);nHe(g,this.nodeViews)&&(this.nodeViews=g,a=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&mR(this),this.editable=aG(this),iG(this);let c=Kk(this),u=rG(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&&D6e(this);if(o){this.domObserver.stop();let g=f&&(gs||ka)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&tHe(i.selection,e.selection);if(f){let x=ka?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=R$e(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=I9(e.doc,u,c,this.dom,this)),x&&!this.trackWrites&&(g=!0)}g||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&i$e(this))?Qc(this,g):(ste(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&&O6e(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 Yt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&j9(this,n.getBoundingClientRect(),e)}else j9(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 vte(e.slice,e.move,i<0?void 0:Yt.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(gs){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&&L6e(this.dom),Qc(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 B6e(this,e)}coordsAtPos(e,n=1){return Zee(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 W6e(this,n||this.state,e)}pasteHTML(e,n){return F0(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return F0(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return QO(this,e)}destroy(){this.docView&&(_$e(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Kk(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,S6e())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return S$e(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ka&&this.root.nodeType===11&&T6e(this.dom.ownerDocument)==this.dom&&W$e(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Nte.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function rG(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"),[$a.node(0,t.state.doc.content.size,e)]}function iG(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:$a.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function aG(t){return!t.someProp("editable",e=>e(t.state)===!1)}function tHe(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 sG(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 nHe(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 oG(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 qd={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:"'"},FS={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},rHe=typeof navigator<"u"&&/Mac/.test(navigator.platform),iHe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ga=0;ga<10;ga++)qd[48+ga]=qd[96+ga]=String(ga);for(var ga=1;ga<=24;ga++)qd[ga+111]="F"+ga;for(var ga=65;ga<=90;ga++)qd[ga]=String.fromCharCode(ga+32),FS[ga]=String.fromCharCode(ga);for(var Yk in qd)FS.hasOwnProperty(Yk)||(FS[Yk]=qd[Yk]);function aHe(t){var e=rHe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||iHe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?FS:qd)[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 sHe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),oHe=typeof navigator<"u"&&/Win/.test(navigator.platform);function lHe(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))sHe?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 cHe(t){let e=Object.create(null);for(let n in t)e[lHe(n)]=t[n];return e}function Qk(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 uHe(t){return new Br({props:{handleKeyDown:Ete(t)}})}function Ete(t){let e=cHe(t);return function(n,r){let i=aHe(r),a,o=e[Qk(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Qk(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(oHe&&r.ctrlKey&&r.altKey)&&(a=qd[r.keyCode])&&a!=i){let l=e[Qk(a,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var dHe=Object.defineProperty,rL=(t,e)=>{for(var n in e)dHe(t,n,{get:e[n],enumerable:!0})};function QM(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 ZM=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:QM({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(...u)=>c(...u)(o)]))}};return o}},Ate={};rL(Ate,{blur:()=>hHe,clearContent:()=>fHe,clearNodes:()=>mHe,command:()=>pHe,createParagraphNear:()=>gHe,cut:()=>xHe,deleteCurrentNode:()=>bHe,deleteNode:()=>yHe,deleteRange:()=>vHe,deleteSelection:()=>_He,enter:()=>wHe,exitCode:()=>SHe,extendMarkRange:()=>MHe,first:()=>NHe,focus:()=>AHe,forEach:()=>THe,insertContent:()=>CHe,insertContentAt:()=>PHe,joinBackward:()=>OHe,joinDown:()=>DHe,joinForward:()=>LHe,joinItemBackward:()=>IHe,joinItemForward:()=>FHe,joinTextblockBackward:()=>UHe,joinTextblockForward:()=>zHe,joinUp:()=>RHe,keyboardShortcut:()=>$He,lift:()=>HHe,liftEmptyBlock:()=>VHe,liftListItem:()=>GHe,newlineInCode:()=>WHe,resetAttributes:()=>qHe,scrollIntoView:()=>KHe,selectAll:()=>XHe,selectNodeBackward:()=>YHe,selectNodeForward:()=>QHe,selectParentNode:()=>ZHe,selectTextblockEnd:()=>JHe,selectTextblockStart:()=>eVe,setContent:()=>tVe,setMark:()=>yVe,setMeta:()=>vVe,setNode:()=>_Ve,setNodeSelection:()=>wVe,setTextDirection:()=>SVe,setTextSelection:()=>MVe,sinkListItem:()=>NVe,splitBlock:()=>EVe,splitListItem:()=>AVe,toggleList:()=>TVe,toggleMark:()=>CVe,toggleNode:()=>kVe,toggleWrap:()=>jVe,undoInputRule:()=>PVe,unsetAllMarks:()=>RVe,unsetMark:()=>DVe,unsetTextDirection:()=>OVe,updateAttributes:()=>LVe,wrapIn:()=>IVe,wrapInList:()=>FVe});var hHe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),fHe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),mHe=()=>({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)),g=f.blockRange(m);if(!g)return;const x=Xg(g);if(l.type.isTextblock){const{defaultType:y}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(g.start,y)}(x||x===0)&&e.lift(g,x)})}),!0},pHe=t=>e=>t(e),gHe=()=>({state:t,dispatch:e})=>$ee(t,e),xHe=(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 sn(r.doc.resolve(Math.max(o-1,0)))),!0},bHe=()=>({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 _i(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 yHe=t=>({tr:e,state:n,dispatch:r})=>{const i=_i(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},vHe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},_He=()=>({state:t,dispatch:e})=>HO(t,e),wHe=()=>({commands:t})=>t.keyboardShortcut("Enter"),SHe=()=>({state:t,dispatch:e})=>l6e(t,e);function iL(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function US(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:iL(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Tte(t,e,n={}){return t.find(r=>r.type===e&&US(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function lG(t,e,n={}){return!!Tte(t,e,n)}function aL(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),!Tte([...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&&lG([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&lG([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function pu(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 MHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=pu(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=aL(c,a,e);if(f&&f.from<=u&&f.to>=d){const m=sn.create(o,f.from,f.to);n.setSelection(m)}}return!0},NHe=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 Cte(t){return t instanceof sn}function Jh(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function kte(t,e=null){if(!e)return null;const n=_n.atStart(t),r=_n.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?sn.create(t,Jh(0,i,a),Jh(t.content.size,i,a)):sn.create(t,Jh(e,i,a),Jh(e,i,a))}function EHe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function sL(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var AHe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const o=()=>{(sL()||EHe())&&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&&!Cte(n.state.selection))return o(),!0;const l=kte(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},THe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),CHe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),jte=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&&jte(r)}return t};function x1(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 jte(n)}function z0(t,e,n){if(t instanceof kd||t instanceof Nt)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 Nt.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),z0("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new pee({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?zb.fromSchema(c).parseSlice(x1(t),n.parseOptions):zb.fromSchema(c).parse(x1(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const a=zb.fromSchema(e);return n.slice?a.parseSlice(x1(t),n.parseOptions).content:a.parse(x1(t),n.parseOptions)}return z0("",e,n)}function kHe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Ki||i instanceof Qi))return;const a=t.mapping.maps[r];let o=0;a.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(_n.near(t.doc.resolve(o),n))}var jHe=t=>!("type"in t),PHe=(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{z0(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(b){c(b)}try{l=z0(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,g=!0;if((jHe(l)?l:[l]).forEach(b=>{b.check(),m=m?b.isText&&b.marks.length===0:!1,g=g?b.isBlock:!1}),d===f&&g){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 Nt){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(),M=b.parentOffset===0,S=v.isText||v.isTextblock,A=v.content.size>0;M&&S&&A&&(d=Math.max(0,d-1)),r.replaceWith(d,f,y)}n.updateSelection&&kHe(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},RHe=()=>({state:t,dispatch:e})=>a6e(t,e),DHe=()=>({state:t,dispatch:e})=>s6e(t,e),OHe=()=>({state:t,dispatch:e})=>Oee(t,e),LHe=()=>({state:t,dispatch:e})=>Uee(t,e),IHe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=GM(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},FHe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=GM(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},UHe=()=>({state:t,dispatch:e})=>r6e(t,e),zHe=()=>({state:t,dispatch:e})=>i6e(t,e);function Pte(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function BHe(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))sL()||Pte()?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 $He=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=BHe(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 Kd(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,o=e?_i(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(f,m)=>{if(f.isText)return;const g=Math.max(r,m),x=Math.min(i,m+f.nodeSize);l.push({node:f,from:g,to:x})});const c=i-r,u=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>US(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,m)=>f+m.to-m.from,0)>=c}var HHe=(t,e={})=>({state:n,dispatch:r})=>{const i=_i(t,n.schema);return Kd(n,i,e)?o6e(n,r):!1},VHe=()=>({state:t,dispatch:e})=>Hee(t,e),GHe=t=>({state:e,dispatch:n})=>{const r=_i(t,e.schema);return y6e(r)(e,n)},WHe=()=>({state:t,dispatch:e})=>Bee(t,e);function JM(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function cG(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 qHe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=JM(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=_i(t,r.schema)),l==="mark"&&(o=pu(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,cG(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(cG(m.attrs,e))))})})}),c},KHe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),XHe=()=>({tr:t,dispatch:e})=>{if(e){const n=new Hs(t.doc);t.setSelection(n)}return!0},YHe=()=>({state:t,dispatch:e})=>Iee(t,e),QHe=()=>({state:t,dispatch:e})=>zee(t,e),ZHe=()=>({state:t,dispatch:e})=>d6e(t,e),JHe=()=>({state:t,dispatch:e})=>m6e(t,e),eVe=()=>({state:t,dispatch:e})=>f6e(t,e);function pR(t,e,n={},r={}){return z0(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var tVe=(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=pR(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 Rte(t,e){const n=pu(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 Dte(t,e){const n=new jee(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function nVe(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 rVe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function iVe(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 eN(t){return e=>iVe(e.$from,t)}function Xt(t,e,n){return t.config[e]===void 0&&t.parent?Xt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Xt(t.parent,e,n):null}):t.config[e]}function oL(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Xt(e,"addExtensions",n);return r?[e,...oL(r())]:e}).flat(10)}function lL(t,e){const n=Yf.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Ote(t){return typeof t=="function"}function Zn(t,e=void 0,...n){return Ote(t)?e?t.bind(e)(...n):t(...n):t}function aVe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Sg(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 Lte(t){const e=[],{nodeExtensions:n,markExtensions:r}=Sg(t),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:i},c=Xt(o,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([m,g])=>{e.push({type:f,name:m,attribute:{...a,...g}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},c=Xt(o,"addAttributes",l);if(!c)return;const u=c();Object.entries(u).forEach(([d,f])=>{const 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 ei(...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(g=>g.trim());u.set(f,m)}),l.forEach(d=>{const[f,m]=d.split(":").map(g=>g.trim());u.set(f,m)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=a}),r},{})}function zS(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)=>ei(n,r),{})}function sVe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function uG(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):sVe(n.getAttribute(o.name));return l==null?a:{...a,[o.name]:l}},{});return{...r,...i}}}}function dG(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&aVe(n)?!1:n!=null))}function hG(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 oVe(t,e){var n;const r=Lte(t),{nodeExtensions:i,markExtensions:a}=Sg(t),o=(n=i.find(u=>Xt(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(v=>v.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},m=t.reduce((v,M)=>{const S=Xt(M,"extendNodeSchema",f);return{...v,...S?S(u):{}}},{}),g=dG({...m,content:Zn(Xt(u,"content",f)),marks:Zn(Xt(u,"marks",f)),group:Zn(Xt(u,"group",f)),inline:Zn(Xt(u,"inline",f)),atom:Zn(Xt(u,"atom",f)),selectable:Zn(Xt(u,"selectable",f)),draggable:Zn(Xt(u,"draggable",f)),code:Zn(Xt(u,"code",f)),whitespace:Zn(Xt(u,"whitespace",f)),linebreakReplacement:Zn(Xt(u,"linebreakReplacement",f)),defining:Zn(Xt(u,"defining",f)),isolating:Zn(Xt(u,"isolating",f)),attrs:Object.fromEntries(d.map(hG))}),x=Zn(Xt(u,"parseHTML",f));x&&(g.parseDOM=x.map(v=>uG(v,d)));const y=Xt(u,"renderHTML",f);y&&(g.toDOM=v=>y({node:v,HTMLAttributes:zS(v,d)}));const b=Xt(u,"renderText",f);return b&&(g.toText=b),[u.name,g]})),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 M=Xt(v,"extendMarkSchema",f);return{...b,...M?M(u):{}}},{}),g=dG({...m,inclusive:Zn(Xt(u,"inclusive",f)),excludes:Zn(Xt(u,"excludes",f)),group:Zn(Xt(u,"group",f)),spanning:Zn(Xt(u,"spanning",f)),code:Zn(Xt(u,"code",f)),attrs:Object.fromEntries(d.map(hG))}),x=Zn(Xt(u,"parseHTML",f));x&&(g.parseDOM=x.map(b=>uG(b,d)));const y=Xt(u,"renderHTML",f);return y&&(g.toDOM=b=>y({mark:b,HTMLAttributes:zS(b,d)})),[u.name,g]}));return new pee({topNode:o,nodes:l,marks:c})}function lVe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function cL(t){return t.sort((n,r)=>{const i=Xt(n,"priority")||100,a=Xt(r,"priority")||100;return i>a?-1:i<a?1:0})}function Ite(t){const e=cL(oL(t)),n=lVe(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 Fte(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
- `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,f)=>{var m;c.isBlock&&u>r&&(l+=a);const g=o?.[c.type.name];if(g)return d&&(l+=g({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 cVe(t,e){const n={from:0,to:t.content.size};return Fte(t,n,e)}function Ute(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function uVe(t,e){const n=_i(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 zte(t,e){const n=JM(typeof e=="string"?e:e.name,t.schema);return n==="node"?uVe(t,e):n==="mark"?Rte(t,e):{}}function dVe(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function hVe(t){const e=dVe(t);return e.length===1?e:e.filter((n,r)=>!e.filter((a,o)=>o!==r).some(a=>n.oldRange.from>=a.oldRange.from&&n.oldRange.to<=a.oldRange.to&&n.newRange.from>=a.newRange.from&&n.newRange.to<=a.newRange.to))}function Bte(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}})})}),hVe(r)}function uL(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),o=aL(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 fVe=(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 Zk(t,e){return e.nodes[t]||e.marks[t]||null}function J1(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 mVe=(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 gR(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?pu(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>US(f.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:f,$to:m})=>{const g=f.pos,x=m.pos;t.doc.nodesBetween(g,x,(y,b)=>{if(!y.isText&&!y.marks.length)return;const v=Math.max(g,b),M=Math.min(x,b+y.nodeSize),S=M-v;o+=S,l.push(...y.marks.map(A=>({mark:A,from:v,to:M})))})}),o===0)return!1;const c=l.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>US(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 pVe(t,e,n={}){if(!e)return Kd(t,null,n)||gR(t,null,n);const r=JM(e,t.schema);return r==="node"?Kd(t,e,n):r==="mark"?gR(t,e,n):!1}var gVe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=eN(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)},xVe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function fG(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function mG(t,e){const{nodeExtensions:n}=Sg(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=Zn(Xt(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function tN(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&&(tN(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function $te(t){return t instanceof Yt}function bVe(t,e,n){var r;const{selection:i}=e;let a=null;if(Cte(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 g=!m||m.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(y=>y.type.excludes(n));u=g&&x}return!u}),u})}var yVe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:o,ranges:l}=a,c=pu(t,r.schema);if(i)if(o){const u=Rte(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,g)=>{const x=Math.max(g,d),y=Math.min(g+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 bVe(r,n,c)},vVe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),_Ve=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=_i(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})=>T9(a,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>T9(a,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},wVe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Jh(t,0,r.content.size),a=Yt.create(r,i);e.setSelection(a)}return!0},SVe=(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},MVe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,o=sn.atStart(r).from,l=sn.atEnd(r).to,c=Jh(i,o,l),u=Jh(a,o,l),d=sn.create(r,c,u);e.setSelection(d)}return!0},NVe=t=>({state:e,dispatch:n})=>{const r=_i(t,e.schema);return w6e(r)(e,n)};function pG(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 EVe=({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=J1(u,l.node().type.name,l.node().attrs);if(a instanceof Yt&&a.node.isBlock)return!l.parentOffset||!Yc(o,l.pos)?!1:(r&&(t&&pG(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:nVe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let g=f&&m?[{type:m,attrs:d}]:void 0,x=Yc(e.doc,e.mapping.map(l.pos),1,g);if(!g&&!x&&Yc(e.doc,e.mapping.map(l.pos),1,m?[{type:m}]:void 0)&&(x=!0,g=m?[{type:m,attrs:d}]:void 0),r){if(x&&(a instanceof sn&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,g),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&&pG(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},AVe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var o;const l=_i(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=Nt.empty;const M=c.index(-1)?1:c.index(-2)?2:3;for(let R=c.depth-M;R>=c.depth-3;R-=1)v=Nt.from(c.node(R).copy(v));const S=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A={...J1(m,c.node().type.name,c.node().attrs),...e},E=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(A))||void 0;v=v.append(Nt.from(l.createAndFill(null,E)||void 0));const k=c.before(c.depth-(M-1));n.replace(k,c.after(-S),new Lt(v,4-M,0));let C=-1;n.doc.nodesBetween(k,n.doc.content.size,(R,T)=>{if(C>-1)return!1;R.isTextblock&&R.content.size===0&&(C=T+1)}),C>-1&&n.setSelection(sn.near(n.doc.resolve(C))),n.scrollIntoView()}return!0}const g=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,x={...J1(m,f.type.name,f.attrs),...e},y={...J1(m,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const b=g?[{type:l,attrs:x},{type:g,attrs:y}]:[{type:l,attrs:x}];if(!Yc(n.doc,c.pos,2))return!1;if(i){const{selection:v,storedMarks:M}=r,{splittableMarks:S}=a.extensionManager,A=M||v.$to.parentOffset&&v.$from.marks();if(n.split(c.pos,2,b).scrollIntoView(),!A||!i)return!0;const E=A.filter(k=>S.includes(k.type.name));n.ensureMarks(E)}return!0},Jk=(t,e)=>{const n=eN(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&&th(t.doc,n.pos)&&t.join(n.pos),!0},ej=(t,e)=>{const n=eN(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&&th(t.doc,r)&&t.join(r),!0},TVe=(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,g=_i(t,o.schema),x=_i(e,o.schema),{selection:y,storedMarks:b}=o,{$from:v,$to:M}=y,S=v.blockRange(M),A=b||y.$to.parentOffset&&y.$from.marks();if(!S)return!1;const E=eN(k=>mG(k.type.name,f))(y);if(S.depth>=1&&E&&S.depth-E.depth<=1){if(E.node.type===g)return u.liftListItem(x);if(mG(E.node.type.name,f)&&g.validContent(E.node.content)&&l)return c().command(()=>(a.setNodeMarkup(E.pos,g),!0)).command(()=>Jk(a,g)).command(()=>ej(a,g)).run()}return!n||!A||!l?c().command(()=>d().wrapInList(g,r)?!0:u.clearNodes()).wrapInList(g,r).command(()=>Jk(a,g)).command(()=>ej(a,g)).run():c().command(()=>{const k=d().wrapInList(g,r),C=A.filter(R=>m.includes(R.type.name));return a.ensureMarks(C),k?!0:u.clearNodes()}).wrapInList(g,r).command(()=>Jk(a,g)).command(()=>ej(a,g)).run()},CVe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,o=pu(t,r.schema);return gR(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,e)},kVe=(t,e,n={})=>({state:r,commands:i})=>{const a=_i(t,r.schema),o=_i(e,r.schema),l=Kd(r,a,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),l?i.setNode(o,c):i.setNode(a,{...c,...n})},jVe=(t,e={})=>({state:n,commands:r})=>{const i=_i(t,n.schema);return Kd(n,i,e)?r.lift(i):r.wrapIn(i,e)},PVe=()=>({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},RVe=()=>({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},DVe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=pu(t,r.schema),{$from:u,empty:d,ranges:f}=l;if(!i)return!0;if(d&&o){let{from:m,to:g}=l;const x=(a=u.marks().find(b=>b.type===c))==null?void 0:a.attrs,y=aL(u,c,x);y&&(m=y.from,g=y.to),n.removeMark(m,g,c)}else f.forEach(m=>{n.removeMark(m.$from.pos,m.$to.pos,c)});return n.removeStoredMark(c),!0},OVe=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},LVe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=JM(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=_i(t,r.schema)),l==="mark"&&(o=pu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let m,g,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,g=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,g=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(M=>{if(o===M.type&&(c=!0,i)){const S=Math.max(v,d),A=Math.min(v+b.nodeSize,f);n.addMark(S,A,o.create({...M.attrs,...e}))}}))}),g&&(m!==void 0&&i&&n.setNodeMarkup(m,void 0,{...g.attrs,...e}),o&&g.marks.length&&g.marks.forEach(b=>{o===b.type&&i&&n.addMark(x,y,o.create({...b.attrs,...e}))}))}),c},IVe=(t,e={})=>({state:n,dispatch:r})=>{const i=_i(t,n.schema);return p6e(i,e)(n,r)},FVe=(t,e={})=>({state:n,dispatch:r})=>{const i=_i(t,n.schema);return g6e(i,e)(n,r)},UVe=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={}}},nN=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},zVe=(t,e)=>{if(iL(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 b1(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=mVe(u)+a;return o.forEach(m=>{if(d)return;const g=zVe(f,m.find);if(!g)return;const x=c.state.tr,y=QM({state:c.state,transaction:x}),b={from:r-(g[0].length-a.length),to:i},{commands:v,chain:M,can:S}=new ZM({editor:n,state:y});m.handler({state:y,range:b,match:g,commands:v,chain:M,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 BVe(t){const{editor:e,rules:n}=t,r=new Br({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=lL(Nt.from(d),o.schema);const{from:f}=c,m=f+d.length;b1({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 b1({editor:e,from:a,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&b1({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?b1({editor:e,from:o.pos,to:o.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function $Ve(t){return Object.prototype.toString.call(t).slice(8,-1)}function y1(t){return $Ve(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Hte(t,e){const n={...t};return y1(t)&&y1(e)&&Object.keys(e).forEach(r=>{y1(e[r])&&y1(t[r])?n[r]=Hte(t[r],e[r]):n[r]=e[r]}),n}var dL=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{...Zn(Xt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Zn(Xt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Hte(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}},rh=class Vte extends dL{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Vte(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 HVe(t){return typeof t=="number"}var VVe=class{constructor(t){this.find=t.find,this.handler=t.handler}},GVe=(t,e,n)=>{if(iL(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 WVe(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new ZM({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(g,x)=>{var y,b,v,M,S;if((b=(y=g.type)==null?void 0:y.spec)!=null&&b.code||!(g.isText||g.isTextblock||g.isInline))return;const A=(S=(M=(v=g.content)==null?void 0:v.size)!=null?M:g.nodeSize)!=null?S:0,E=Math.max(r,x),k=Math.min(i,x+A);if(E>=k)return;const C=g.isText?g.text||"":g.textBetween(E-x,k-x,void 0,"");GVe(C,a.find,o).forEach(T=>{if(T.index===void 0)return;const P=E+T.index+1,F=P+T[0].length,L={from:n.tr.mapping.map(P),to:n.tr.mapping.map(F)},X=a.handler({state:n,range:L,match:T,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});f.push(X)})}),f.every(g=>g!==null)}var v1=null,qVe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function KVe(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:g,pasteEvt:x})=>{const y=d.tr,b=QM({state:d,transaction:y});if(!(!WVe({editor:e,state:b,from:Math.max(f-1,0),to:m.b-1,rule:g,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 Br({view(f){const m=x=>{var y;r=(y=f.dom.parentElement)!=null&&y.contains(x.target)?f.dom.parentElement:null,r&&(v1=e)},g=()=>{v1&&(v1=null)};return window.addEventListener("dragstart",m),window.addEventListener("dragend",g),{destroy(){window.removeEventListener("dragstart",m),window.removeEventListener("dragend",g)}}},props:{handleDOMEvents:{drop:(f,m)=>{if(a=r===f.dom.parentElement,l=m,!a){const g=v1;g?.isEditable&&setTimeout(()=>{const x=g.state.selection;x&&g.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(f,m)=>{var g;const x=(g=m.clipboardData)==null?void 0:g.getData("text/html");return o=m,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(f,m,g)=>{const x=f[0],y=x.getMeta("uiEvent")==="paste"&&!i,b=x.getMeta("uiEvent")==="drop"&&!a,v=x.getMeta("applyPasteRules"),M=!!v;if(!y&&!b&&!M)return;if(M){let{text:E}=v;typeof E=="string"?E=E:E=lL(Nt.from(E),g.schema);const{from:k}=v,C=k+E.length,R=qVe(E);return c({rule:d,state:g,from:k,to:{b:C},pasteEvt:R})}const S=m.doc.content.findDiffStart(g.doc.content),A=m.doc.content.findDiffEnd(g.doc.content);if(!(!HVe(S)||!A||S===A.b))return c({rule:d,state:g,from:S,to:A,pasteEvt:o})}}))}var rN=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Ite(t),this.schema=oVe(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:Zk(e.name,this.schema)},r=Xt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return cL([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Zk(r.name,this.schema)},a=[],o=Xt(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&Xt(r,"exitable",i)&&(l.ArrowRight=()=>rh.handleExit({editor:t,mark:r})),o){const m=Object.fromEntries(Object.entries(o()).map(([g,x])=>[g,()=>x({editor:t})]));l={...l,...m}}const c=uHe(l);a.push(c);const u=Xt(r,"addInputRules",i);if(fG(r,t.options.enableInputRules)&&u){const m=u();if(m&&m.length){const g=BVe({editor:t,rules:m}),x=Array.isArray(g)?g:[g];a.push(...x)}}const d=Xt(r,"addPasteRules",i);if(fG(r,t.options.enablePasteRules)&&d){const m=d();if(m&&m.length){const g=KVe({editor:t,rules:m});a.push(...g)}}const f=Xt(r,"addProseMirrorPlugins",i);if(f){const m=f();a.push(...m)}return a})}get attributes(){return Lte(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Sg(this.extensions);return Object.fromEntries(e.filter(n=>!!Xt(n,"addNodeView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:_i(n.name,this.schema)},a=Xt(n,"addNodeView",i);if(!a)return[];const o=a();if(!o)return[];const l=(c,u,d,f,m)=>{const g=zS(c,r);return o({node:c,view:u,getPos:d,decorations:f,innerDecorations:m,editor:t,extension:n,HTMLAttributes:g})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=Sg(this.extensions);return Object.fromEntries(e.filter(n=>!!Xt(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:pu(n.name,this.schema)},a=Xt(n,"addMarkView",i);if(!a)return[];const o=(l,c,u)=>{const d=zS(l,r);return a()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{c7e(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:Zk(e.name,this.schema)};e.type==="mark"&&((n=Zn(Xt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Xt(e,"onBeforeCreate",r),a=Xt(e,"onCreate",r),o=Xt(e,"onUpdate",r),l=Xt(e,"onSelectionUpdate",r),c=Xt(e,"onTransaction",r),u=Xt(e,"onFocus",r),d=Xt(e,"onBlur",r),f=Xt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};rN.resolve=Ite;rN.sort=cL;rN.flatten=oL;var XVe={};rL(XVe,{ClipboardTextSerializer:()=>Wte,Commands:()=>qte,Delete:()=>Kte,Drop:()=>Xte,Editable:()=>Yte,FocusEvents:()=>Zte,Keymap:()=>Jte,Paste:()=>ene,Tabindex:()=>tne,TextDirection:()=>nne,focusEventsPluginKey:()=>Qte});var dr=class Gte extends dL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Gte(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Wte=dr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Br({key:new Li("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=Ute(n);return Fte(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),qte=dr.create({name:"commands",addCommands(){return{...Ate}}}),Kte=dr.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=Dte(t.before,[t,...e]);Bte(d).forEach(g=>{d.mapping.mapResult(g.oldRange.from).deletedAfter&&d.mapping.mapResult(g.oldRange.to).deletedBefore&&d.before.nodesBetween(g.oldRange.from,g.oldRange.to,(x,y)=>{const b=y+x.nodeSize-2,v=g.oldRange.from<=y&&b<=g.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:g.oldRange,newRange:g.newRange,partial:!v,editor:this.editor,transaction:t,combinedTransform:d})})});const m=d.mapping;d.steps.forEach((g,x)=>{var y,b;if(g instanceof Yo){const v=m.slice(x).map(g.from,-1),M=m.slice(x).map(g.to),S=m.invert().map(v,-1),A=m.invert().map(M),E=(y=d.doc.nodeAt(v-1))==null?void 0:y.marks.some(C=>C.eq(g.mark)),k=(b=d.doc.nodeAt(M))==null?void 0:b.marks.some(C=>C.eq(g.mark));this.editor.emit("delete",{type:"mark",mark:g.mark,from:g.from,to:g.to,deletedRange:{from:S,to:A},newRange:{from:v,to:M},partial:!!(k||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()}}),Xte=dr.create({name:"drop",addProseMirrorPlugins(){return[new Br({key:new Li("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Yte=dr.create({name:"editable",addProseMirrorPlugins(){return[new Br({key:new Li("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Qte=new Li("focusEvents"),Zte=dr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Br({key:Qte,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}}}})]}}),Jte=dr.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:g}=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:_n.atStart(u).from===m;return!d||!g.type.isTextblock||g.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 sL()||Pte()?a:i},addProseMirrorPlugins(){return[new Br({key:new Li("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=_n.atStart(e.doc).from,u=_n.atEnd(e.doc).to;if(a||!(o===c&&l===u)||!tN(n.doc))return;const m=n.tr,g=QM({state:n,transaction:m}),{commands:x}=new ZM({editor:this.editor,state:g});if(x.clearNodes(),!!m.steps.length)return m}})]}}),ene=dr.create({name:"paste",addProseMirrorPlugins(){return[new Br({key:new Li("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),tne=dr.create({name:"tabindex",addProseMirrorPlugins(){return[new Br({key:new Li("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),nne=dr.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Sg(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 Br({key:new Li("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),YVe=class Mp{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 Mp(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 Mp(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 Mp(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 Mp(l,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new Mp(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)}},QVe=`.ProseMirror {
- position: relative;
- }
- .ProseMirror {
- word-wrap: break-word;
- white-space: pre-wrap;
- white-space: break-spaces;
- -webkit-font-variant-ligatures: none;
- font-variant-ligatures: none;
- font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
- }
- .ProseMirror [contenteditable="false"] {
- white-space: normal;
- }
- .ProseMirror [contenteditable="false"] [contenteditable="true"] {
- white-space: pre-wrap;
- }
- .ProseMirror pre {
- white-space: pre-wrap;
- }
- img.ProseMirror-separator {
- display: inline !important;
- border: none !important;
- margin: 0 !important;
- width: 0 !important;
- height: 0 !important;
- }
- .ProseMirror-gapcursor {
- display: none;
- pointer-events: none;
- position: absolute;
- margin: 0;
- }
- .ProseMirror-gapcursor:after {
- content: "";
- display: block;
- position: absolute;
- top: -2px;
- width: 20px;
- border-top: 1px solid black;
- animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
- }
- @keyframes ProseMirror-cursor-blink {
- to {
- visibility: hidden;
- }
- }
- .ProseMirror-hideselection *::selection {
- background: transparent;
- }
- .ProseMirror-hideselection *::-moz-selection {
- background: transparent;
- }
- .ProseMirror-hideselection * {
- caret-color: transparent;
- }
- .ProseMirror-focused .ProseMirror-gapcursor {
- display: block;
- }`;function ZVe(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 JVe=class extends UVe{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=kte(e,this.options.autofocus);this.editorState=Pp.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=ZVe(QVe,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=Ote(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?[Yte,Wte.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),qte,Zte,Jte,tne,Xte,ene,Kte,nne.configure({direction:this.options.textDirection})].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i?.type));this.extensionManager=new rN(r,this)}createCommandManager(){this.commandManager=new ZM({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=pR(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=pR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new Nte(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 zte(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return pVe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return lL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return cVe(this.state.doc,{blockSeparator:e,textSerializers:{...Ute(this.schema),...n}})}get isEmpty(){return tN(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 YVe(e,this)}get $doc(){return this.$pos(0)}};function Mg(t){return new nN({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Zn(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(uL(n.from,n.to,e.doc).filter(g=>g.mark.type.excluded.find(y=>y===t.type&&y!==g.mark.type)).filter(g=>g.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 rne(t){return new nN({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Zn(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 xR(t){return new nN({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=Zn(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 Ng(t){return new nN({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=Zn(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&BO(c,t.type,a);if(!u)return null;if(o.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:m}=e,{splittableMarks:g}=t.editor.extensionManager,x=m||f.$to.parentOffset&&f.$from.marks();if(x){const y=x.filter(b=>g.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&&th(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var e7e=t=>"touches"in t,t7e=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,e7e(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 n7e(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Yt){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 r7e={};rL(r7e,{createAtomBlockMarkdownSpec:()=>i7e,createBlockMarkdownSpec:()=>a7e,createInlineMarkdownSpec:()=>l7e,parseAttributes:()=>hL,parseIndentedBlocks:()=>bR,renderNestedMarkdownContent:()=>mL,serializeAttributes:()=>fL});function hL(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,u=>(n.push(u),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const u=i.map(d=>d.trim().slice(1));e.class=u.join(" ")}const a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(e.id=a[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,u,d])=>{var f;const m=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),g=n[m];g&&(e[u]=g.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 fL(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 i7e(t){const{nodeName:e,name:n,parseAttributes:r=hL,serializeAttributes:i=fL,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"),g=(f=d.match(m))==null?void 0:f.index;return g!==void 0?g:-1},tokenize(d,f,m){const g=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(g);if(!x)return;const y=x[1]||"",b=r(y);if(!o.find(M=>!(M in b)))return{type:e,raw:x[0],attributes:b}}},renderMarkdown:d=>{const f=u(d.attrs||{}),m=i(f),g=m?` {${m}}`:"";return`:::${c}${g} :::`}}}function a7e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=hL,serializeAttributes:a=fL,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const m={};return c.forEach(g=>{g in f&&(m[g]=f[g])}),m};return{parseMarkdown:(f,m)=>{let g;if(r){const y=r(f);g=typeof y=="string"?[{type:"text",text:y}]:y}else l==="block"?g=m.parseChildren(f.tokens||[]):g=m.parseInline(f.tokens||[]);const x={...o,...f.attributes};return m.createNode(e,x,g)},markdownTokenizer:{name:e,level:"block",start(f){var m;const g=new RegExp(`^:::${u}`,"m"),x=(m=f.match(g))==null?void 0:m.index;return x!==void 0?x:-1},tokenize(f,m,g){var x;const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),b=f.match(y);if(!b)return;const[v,M=""]=b,S=i(M);let A=1;const E=v.length;let k="";const C=/^:::([\w-]*)(\s.*)?/gm,R=f.slice(E);for(C.lastIndex=0;;){const T=C.exec(R);if(T===null)break;const P=T.index,F=T[1];if(!((x=T[2])!=null&&x.endsWith(":::"))){if(F)A+=1;else if(A-=1,A===0){const L=R.slice(0,P);k=L.trim();const X=f.slice(0,E+P+T[0].length);let D=[];if(k)if(l==="block")for(D=g.blockTokens(L),D.forEach(K=>{K.text&&(!K.tokens||K.tokens.length===0)&&(K.tokens=g.inlineTokens(K.text))});D.length>0;){const K=D[D.length-1];if(K.type==="paragraph"&&(!K.text||K.text.trim()===""))D.pop();else break}else D=g.inlineTokens(k);return{type:e,raw:X,attributes:S,content:k,tokens:D}}}}}},renderMarkdown:(f,m)=>{const g=d(f.attrs||{}),x=a(g),y=x?` {${x}}`:"",b=m.renderChildren(f.content||[],`
- `);return`:::${u}${y}
- ${b}
- :::`}}}function s7e(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 o7e(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function l7e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=s7e,serializeAttributes:a=o7e,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=m=>{if(!c)return m;const g={};return c.forEach(x=>{x in m&&(g[x]=m[x])}),g},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(m,g)=>{const x={...o,...m.attributes};if(l)return g.createNode(e,x);const y=r?r(m):m.content||"";return y?g.createNode(e,x,[g.createTextNode(y)]):g.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(m){const g=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),x=m.match(g),y=x?.index;return y!==void 0?y:-1},tokenize(m,g,x){const y=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),b=m.match(y);if(!b)return;let v="",M="";if(l){const[,A]=b;M=A}else{const[,A,E]=b;M=A,v=E||""}const S=i(M.trim());return{type:e,raw:b[0],content:v.trim(),attributes:S}}},renderMarkdown:m=>{let g="";r?g=r(m):m.content&&m.content.length>0&&(g=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}]${g}[/${u}]`}}}function bR(t,e,n){var r,i,a,o;const l=t.split(`
- `),c=[];let u="",d=0;const f=e.baseIndentSize||2;for(;d<l.length;){const m=l[d],g=m.match(e.itemPattern);if(!g){if(c.length>0)break;if(m.trim()===""){d+=1,u=`${u}${m}
- `;continue}else return}const x=e.extractItemData(g),{indentLevel:y,mainContent:b}=x;u=`${u}${m}
- `;const v=[b];for(d+=1;d<l.length;){const E=l[d];if(E.trim()===""){const C=l.slice(d+1).findIndex(P=>P.trim()!=="");if(C===-1)break;if((((i=(r=l[d+1+C].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>y){v.push(E),u=`${u}${E}
- `,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}
- `,d+=1;else break}let M;const S=v.slice(1);if(S.length>0){const E=S.map(k=>k.slice(y+f)).join(`
- `);E.trim()&&(e.customNestedParser?M=e.customNestedParser(E):M=n.blockTokens(E))}const A=e.createToken(x,M);c.push(A)}if(c.length!==0)return{items:c,raw:u}}function mL(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...o]=t.content,l=e.renderChildren([a]),c=[`${i}${l}`];return o&&o.length>0&&o.forEach(u=>{const d=e.renderChildren([u]);if(d){const f=d.split(`
- `).map(m=>m?e.indent(m):"").join(`
- `);c.push(f)}}),c.join(`
- `)}function c7e(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(g=>{if(g!==o)return!1;f=g}),!f)return;let m=!1;if(Object.keys(n).forEach(g=>{n[g]!==f.attrs[g]&&(m=!0)}),m){const g=t.type.create({...t.attrs,...n});a.removeMark(u,d,t.type),a.addMark(u,d,g)}}),a.docChanged&&e.view.dispatch(a)}var vs=class ine extends dL{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new ine(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function $f(t){return new VVe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=Zn(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(uL(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 tj,gG;function u7e(){return gG||(gG=1,tj=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;for(i of e.entries())if(!t(i[1],n.get(i[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(e[i]!==n[i])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(a=Object.keys(e),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!(o==="_owner"&&e.$$typeof)&&!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}),tj}var d7e=u7e();const h7e=Co(d7e);var f7e=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},m7e=({contentComponent:t})=>{const e=UR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function p7e(){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]:ole.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 g7e=class extends jr.Component{constructor(t){var e;super(t),this.editorContentRef=jr.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(t.view.dom),t.setOptions({element:e}),t.contentComponent=p7e(),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:f7e(e,this.editorContentRef),...n}),t?.contentComponent&&s.jsx(m7e,{contentComponent:t.contentComponent})]})}},x7e=w.forwardRef((t,e)=>{const n=jr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return jr.createElement(g7e,{key:n,innerRef:e,...t})}),b7e=jr.memo(x7e),y7e=typeof window<"u"?w.useLayoutEffect:w.useEffect,v7e=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 _7e(t){var e;const[n]=w.useState(()=>new v7e(t.editor)),r=Kq.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:h7e);return y7e(()=>n.watch(t.editor),[t.editor,n]),w.useDebugValue(r),r}var w7e=!1,yR=typeof window>"u",S7e=yR||!!(typeof window<"u"&&window.next),M7e=class ane{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?yR||S7e?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 JVe(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?ane.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 N7e(t={},e=[]){const n=w.useRef(t);n.current=t;const[r]=w.useState(()=>new M7e(n)),i=UR.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return w.useDebugValue(i),w.useEffect(r.onRender(e)),_7e({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var E7e=w.createContext({editor:null});E7e.Consumer;var A7e=w.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),T7e=()=>w.useContext(A7e);jr.forwardRef((t,e)=>{const{onDragStart:n}=T7e(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});jr.createContext({markViewContentRef:()=>{}});var BS=(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]},C7e=/^\s*>\s$/,k7e=vs.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return BS("blockquote",{...ei(this.options.HTMLAttributes,t),children:BS("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const l=e.renderChildren([i]).split(`
- `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
- `))}),r.join(`
- ${n}
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Ng({find:C7e,type:this.type})]}}),j7e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,P7e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,R7e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,D7e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,O7e=rh.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 BS("strong",{...ei(this.options.HTMLAttributes,t),children:BS("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[Mg({find:j7e,type:this.type}),Mg({find:R7e,type:this.type})]},addPasteRules(){return[$f({find:P7e,type:this.type}),$f({find:D7e,type:this.type})]}}),L7e=/(^|[^`])`([^`]+)`(?!`)$/,I7e=/(^|[^`])`([^`]+)`(?!`)/g,F7e=rh.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",ei(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[Mg({find:L7e,type:this.type})]},addPasteRules(){return[$f({find:I7e,type:this.type})]}}),nj=4,U7e=/^```([a-z]+)?[\s\n]$/,z7e=/^~~~([a-z]+)?[\s\n]$/,B7e=vs.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:nj,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",ei(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(`
- `):r=`\`\`\`${i}
- \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:nj,{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,g=r.doc.textBetween(u,d,`
- `,`
- `).split(`
- `).map(x=>l+x).join(`
- `);return c.replaceWith(u,d,r.schema.text(g)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:nj,{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(),g=r.doc.textBetween(d,f,`
- `,`
- `).split(`
- `);let x=0,y=0;const b=u-d;for(let k=0;k<g.length;k+=1){if(y+g[k].length>=b){x=k;break}y+=g[k].length+1}const M=((c=g[x].match(/^ */))==null?void 0:c[0])||"",S=Math.min(M.length,n);if(S===0)return!0;let A=d;for(let k=0;k<x;k+=1)A+=g[k].length+1;return l.delete(A,A+S),u-A<=S&&l.setSelection(sn.create(l.doc,A)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,m=r.doc.textBetween(c,u,`
- `,`
- `).split(`
- `).map(g=>{var x;const y=((x=g.match(/^ */))==null?void 0:x[0])||"",b=Math.min(y.length,n);return g.slice(b)}).join(`
- `);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(`
- `);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(_n.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[xR({find:U7e,type:this.type,getAttributes:t=>({language:t[1]})}),xR({find:z7e,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Br({key:new Li("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,a=i?.mode;if(!n||!a)return!1;const{tr:o,schema:l}=t.state,c=l.text(n.replace(/\r\n?/g,`
- `));return o.replaceSelectionWith(this.type.create({language:a},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(sn.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),$7e=vs.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),H7e=vs.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",ei(this.options.HTMLAttributes,t)]},renderText(){return`
- `},renderMarkdown:()=>`
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:a}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,c=a||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&o){const f=c.filter(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()}}}),V7e=vs.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]}`,ei(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=>xR({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),G7e=vs.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",ei(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!n7e(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return $te(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(sn.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(Yt.create(o.doc,c.pos)):o.setSelection(sn.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(sn.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[rne({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),W7e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,q7e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,K7e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,X7e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Y7e=rh.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",ei(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[Mg({find:W7e,type:this.type}),Mg({find:K7e,type:this.type})]},addPasteRules(){return[$f({find:q7e,type:this.type}),$f({find:X7e,type:this.type})]}});const Q7e="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Z7e="ελ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",vR="numeric",_R="ascii",wR="alpha",Vb="asciinumeric",Ab="alphanumeric",SR="domain",sne="emoji",J7e="scheme",e9e="slashscheme",rj="whitespace";function t9e(t,e){return t in e||(e[t]=[]),e[t]}function ef(t,e,n){e[vR]&&(e[Vb]=!0,e[Ab]=!0),e[_R]&&(e[Vb]=!0,e[wR]=!0),e[Vb]&&(e[Ab]=!0),e[wR]&&(e[Ab]=!0),e[Ab]&&(e[SR]=!0),e[sne]&&(e[SR]=!0);for(const r in e){const i=t9e(r,n);i.indexOf(t)<0&&i.push(t)}}function n9e(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function us(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}us.groups={};us.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||us.groups;let i;return e&&e.j?i=e:(i=new us(e),n&&r&&ef(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||us.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 us,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new us,a){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(n9e(o.t,r),n);ef(a,c,r)}else n&&ef(a,n,r);o.t=a}return i.j[t]=o,o}};const xn=(t,e,n,r,i)=>t.ta(e,n,r,i),Wr=(t,e,n,r,i)=>t.tr(e,n,r,i),xG=(t,e,n,r,i)=>t.ts(e,n,r,i),Ct=(t,e,n,r,i)=>t.tt(e,n,r,i),kc="WORD",MR="UWORD",one="ASCIINUMERICAL",lne="ALPHANUMERICAL",B0="LOCALHOST",NR="TLD",ER="UTLD",ew="SCHEME",Np="SLASH_SCHEME",pL="NUM",AR="WS",gL="NL",Gb="OPENBRACE",Wb="CLOSEBRACE",$S="OPENBRACKET",HS="CLOSEBRACKET",VS="OPENPAREN",GS="CLOSEPAREN",WS="OPENANGLEBRACKET",qS="CLOSEANGLEBRACKET",KS="FULLWIDTHLEFTPAREN",XS="FULLWIDTHRIGHTPAREN",YS="LEFTCORNERBRACKET",QS="RIGHTCORNERBRACKET",ZS="LEFTWHITECORNERBRACKET",JS="RIGHTWHITECORNERBRACKET",e2="FULLWIDTHLESSTHAN",t2="FULLWIDTHGREATERTHAN",n2="AMPERSAND",r2="APOSTROPHE",i2="ASTERISK",od="AT",a2="BACKSLASH",s2="BACKTICK",o2="CARET",fd="COLON",xL="COMMA",l2="DOLLAR",yl="DOT",c2="EQUALS",bL="EXCLAMATION",co="HYPHEN",qb="PERCENT",u2="PIPE",d2="PLUS",h2="POUND",Kb="QUERY",yL="QUOTE",cne="FULLWIDTHMIDDLEDOT",vL="SEMI",vl="SLASH",Xb="TILDE",f2="UNDERSCORE",une="EMOJI",m2="SYM";var dne=Object.freeze({__proto__:null,ALPHANUMERICAL:lne,AMPERSAND:n2,APOSTROPHE:r2,ASCIINUMERICAL:one,ASTERISK:i2,AT:od,BACKSLASH:a2,BACKTICK:s2,CARET:o2,CLOSEANGLEBRACKET:qS,CLOSEBRACE:Wb,CLOSEBRACKET:HS,CLOSEPAREN:GS,COLON:fd,COMMA:xL,DOLLAR:l2,DOT:yl,EMOJI:une,EQUALS:c2,EXCLAMATION:bL,FULLWIDTHGREATERTHAN:t2,FULLWIDTHLEFTPAREN:KS,FULLWIDTHLESSTHAN:e2,FULLWIDTHMIDDLEDOT:cne,FULLWIDTHRIGHTPAREN:XS,HYPHEN:co,LEFTCORNERBRACKET:YS,LEFTWHITECORNERBRACKET:ZS,LOCALHOST:B0,NL:gL,NUM:pL,OPENANGLEBRACKET:WS,OPENBRACE:Gb,OPENBRACKET:$S,OPENPAREN:VS,PERCENT:qb,PIPE:u2,PLUS:d2,POUND:h2,QUERY:Kb,QUOTE:yL,RIGHTCORNERBRACKET:QS,RIGHTWHITECORNERBRACKET:JS,SCHEME:ew,SEMI:vL,SLASH:vl,SLASH_SCHEME:Np,SYM:m2,TILDE:Xb,TLD:NR,UNDERSCORE:f2,UTLD:ER,UWORD:MR,WORD:kc,WS:AR});const Ec=/[a-z]/,fb=new RegExp("\\p{L}","u"),ij=new RegExp("\\p{Emoji}","u"),Ac=/\d/,aj=/\s/,bG="\r",sj=`
- `,r9e="️",i9e="",oj="";let _1=null,w1=null;function a9e(t=[]){const e={};us.groups=e;const n=new us;_1==null&&(_1=yG(Q7e)),w1==null&&(w1=yG(Z7e)),Ct(n,"'",r2),Ct(n,"{",Gb),Ct(n,"}",Wb),Ct(n,"[",$S),Ct(n,"]",HS),Ct(n,"(",VS),Ct(n,")",GS),Ct(n,"<",WS),Ct(n,">",qS),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,"*",i2),Ct(n,"@",od),Ct(n,"`",s2),Ct(n,"^",o2),Ct(n,":",fd),Ct(n,",",xL),Ct(n,"$",l2),Ct(n,".",yl),Ct(n,"=",c2),Ct(n,"!",bL),Ct(n,"-",co),Ct(n,"%",qb),Ct(n,"|",u2),Ct(n,"+",d2),Ct(n,"#",h2),Ct(n,"?",Kb),Ct(n,'"',yL),Ct(n,"/",vl),Ct(n,";",vL),Ct(n,"~",Xb),Ct(n,"_",f2),Ct(n,"\\",a2),Ct(n,"・",cne);const r=Wr(n,Ac,pL,{[vR]:!0});Wr(r,Ac,r);const i=Wr(r,Ec,one,{[Vb]:!0}),a=Wr(r,fb,lne,{[Ab]:!0}),o=Wr(n,Ec,kc,{[_R]:!0});Wr(o,Ac,i),Wr(o,Ec,o),Wr(i,Ac,i),Wr(i,Ec,i);const l=Wr(n,fb,MR,{[wR]:!0});Wr(l,Ec),Wr(l,Ac,a),Wr(l,fb,l),Wr(a,Ac,a),Wr(a,Ec),Wr(a,fb,a);const c=Ct(n,sj,gL,{[rj]:!0}),u=Ct(n,bG,AR,{[rj]:!0}),d=Wr(n,aj,AR,{[rj]:!0});Ct(n,oj,d),Ct(u,sj,c),Ct(u,oj,d),Wr(u,aj,d),Ct(d,bG),Ct(d,sj),Wr(d,aj,d),Ct(d,oj,d);const f=Wr(n,ij,une,{[sne]:!0});Ct(f,"#"),Wr(f,ij,f),Ct(f,r9e,f);const m=Ct(f,i9e);Ct(m,"#"),Wr(m,ij,f);const g=[[Ec,o],[Ac,i]],x=[[Ec,null],[fb,l],[Ac,a]];for(let y=0;y<_1.length;y++)Ju(n,_1[y],NR,kc,g);for(let y=0;y<w1.length;y++)Ju(n,w1[y],ER,MR,x);ef(NR,{tld:!0,ascii:!0},e),ef(ER,{utld:!0,alpha:!0},e),Ju(n,"file",ew,kc,g),Ju(n,"mailto",ew,kc,g),Ju(n,"http",Np,kc,g),Ju(n,"https",Np,kc,g),Ju(n,"ftp",Np,kc,g),Ju(n,"ftps",Np,kc,g),ef(ew,{scheme:!0,ascii:!0},e),ef(Np,{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],M=t[y][1]?{[J7e]:!0}:{[e9e]:!0};b.indexOf("-")>=0?M[SR]=!0:Ec.test(b)?Ac.test(b)?M[Vb]=!0:M[_R]=!0:M[vR]=!0,xG(n,b,b,M)}return xG(n,"localhost",B0,{ascii:!0}),n.jd=new us(m2),{start:n,tokens:Object.assign({groups:e},dne)}}function hne(t,e){const n=s9e(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 s9e(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 Ju(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 us(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new us(n),a.jr=i.slice(),t.j[e[o-1]]=a,a}function yG(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 $0={defaultProtocol:"http",events:null,format:vG,formatHref:vG,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function _L(t,e=null){let n=Object.assign({},$0);t&&(n=Object.assign(n,t instanceof _L?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}_L.prototype={o:$0,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]:$0[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 vG(t){return t}function fne(t,e){this.t="token",this.v=t,this.tk=e}fne.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=$0.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 iN(t,e){class n extends fne{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 _G=iN("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),wG=iN("text"),o9e=iN("nl"),S1=iN("url",{isLink:!0,toHref(t=$0.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==B0&&t[1].t===fd}}),so=t=>new us(t);function l9e({groups:t}){const e=t.domain.concat([n2,i2,od,a2,s2,o2,l2,c2,co,pL,qb,u2,d2,h2,vl,m2,Xb,f2]),n=[r2,fd,xL,yl,bL,qb,Kb,yL,vL,WS,qS,Gb,Wb,HS,$S,VS,GS,KS,XS,YS,QS,ZS,JS,e2,t2],r=[n2,r2,i2,a2,s2,o2,l2,c2,co,Gb,Wb,qb,u2,d2,h2,Kb,vl,m2,Xb,f2],i=so(),a=Ct(i,Xb);xn(a,r,a),xn(a,t.domain,a);const o=so(),l=so(),c=so();xn(i,t.domain,o),xn(i,t.scheme,l),xn(i,t.slashscheme,c),xn(o,r,a),xn(o,t.domain,o);const u=Ct(o,od);Ct(a,od,u),Ct(l,od,u),Ct(c,od,u);const d=Ct(a,yl);xn(d,r,a),xn(d,t.domain,a);const f=so();xn(u,t.domain,f),xn(f,t.domain,f);const m=Ct(f,yl);xn(m,t.domain,f);const g=so(_G);xn(m,t.tld,g),xn(m,t.utld,g),Ct(u,B0,g);const x=Ct(f,co);Ct(x,co,x),xn(x,t.domain,f),xn(g,t.domain,f),Ct(g,yl,m),Ct(g,co,x);const y=Ct(g,fd);xn(y,t.numeric,_G);const b=Ct(o,co),v=Ct(o,yl);Ct(b,co,b),xn(b,t.domain,o),xn(v,r,a),xn(v,t.domain,o);const M=so(S1);xn(v,t.tld,M),xn(v,t.utld,M),xn(M,t.domain,o),xn(M,r,a),Ct(M,yl,v),Ct(M,co,b),Ct(M,od,u);const S=Ct(M,fd),A=so(S1);xn(S,t.numeric,A);const E=so(S1),k=so();xn(E,e,E),xn(E,n,k),xn(k,e,E),xn(k,n,k),Ct(M,vl,E),Ct(A,vl,E);const C=Ct(l,fd),R=Ct(c,fd),T=Ct(R,vl),P=Ct(T,vl);xn(l,t.domain,o),Ct(l,yl,v),Ct(l,co,b),xn(c,t.domain,o),Ct(c,yl,v),Ct(c,co,b),xn(C,t.domain,E),Ct(C,vl,E),Ct(C,Kb,E),xn(P,t.domain,E),xn(P,e,E),Ct(P,vl,E);const F=[[Gb,Wb],[$S,HS],[VS,GS],[WS,qS],[KS,XS],[YS,QS],[ZS,JS],[e2,t2]];for(let L=0;L<F.length;L++){const[X,D]=F[L],K=Ct(E,X);Ct(k,X,K),Ct(K,D,E);const Y=so(S1);xn(K,e,Y);const q=so();xn(K,n),xn(Y,e,Y),xn(Y,n,q),xn(q,e,Y),xn(q,n,q),Ct(Y,D,E),Ct(q,D,E)}return Ct(i,B0,M),Ct(i,gL,o9e),{start:i,tokens:dne}}function c9e(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(lj(wG,e,o)),o=[]),i-=m,d-=m;const g=f.t,x=n.slice(i-d,i);a.push(lj(g,e,x))}}return o.length>0&&a.push(lj(wG,e,o)),a}function lj(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 u9e=typeof console<"u"&&console&&console.warn||(()=>{}),d9e="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Nr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function h9e(){return us.groups={},Nr.scanner=null,Nr.parser=null,Nr.tokenQueue=[],Nr.pluginQueue=[],Nr.customSchemes=[],Nr.initialized=!1,Nr}function SG(t,e=!1){if(Nr.initialized&&u9e(`linkifyjs: already initialized - will not register custom scheme "${t}" ${d9e}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
- 1. Must only contain digits, lowercase ASCII letters or "-"
- 2. Cannot start or end with "-"
- 3. "-" cannot repeat`);Nr.customSchemes.push([t,e])}function f9e(){Nr.scanner=a9e(Nr.customSchemes);for(let t=0;t<Nr.tokenQueue.length;t++)Nr.tokenQueue[t][1]({scanner:Nr.scanner});Nr.parser=l9e(Nr.scanner.tokens);for(let t=0;t<Nr.pluginQueue.length;t++)Nr.pluginQueue[t][1]({scanner:Nr.scanner,parser:Nr.parser});return Nr.initialized=!0,Nr}function wL(t){return Nr.initialized||f9e(),c9e(Nr.parser.start,t,hne(Nr.scanner.start,t))}wL.scan=hne;function mne(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 _L(n),i=wL(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 SL="[\0- -\u2029 ]",m9e=new RegExp(SL),p9e=new RegExp(`${SL}$`),g9e=new RegExp(SL,"g");function x9e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function b9e(t){return new Br({key:new Li("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=Dte(n.doc,[...e]);if(Bte(l).forEach(({newRange:u})=>{const d=rVe(r.doc,u,g=>g.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 g=r.doc.textBetween(u.from,u.to," "," ");if(!p9e.test(g))return;f=d[0],m=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&m){const g=m.split(m9e).filter(Boolean);if(g.length<=0)return!1;const x=g[g.length-1],y=f.pos+m.lastIndexOf(x);if(!x)return!1;const b=wL(x).map(v=>v.toObject(t.defaultProtocol));if(!x9e(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=>{uL(v.from,v.to,r.doc).some(M=>M.mark.type===t.type)||o.addMark(v.from,v.to,t.type.create({href:v.href}))})}}),!!o.steps.length)return o}})}function y9e(t){return new Br({key:new Li("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=zte(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 v9e(t){return new Br({key:new Li("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=mne(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 jh(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(g9e,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var pne=rh.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"){SG(t);return}SG(t.scheme,t.optionalSlashes)})},onDestroy(){h9e()},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)=>!!jh(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=>!!jh(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=>!!jh(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ei(this.options.HTMLAttributes,t),0]:["a",ei(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=>!!jh(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=>!!jh(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[$f({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=mne(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!jh(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(b9e({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!jh(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(y9e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(v9e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),_9e=pne,w9e=Object.defineProperty,S9e=(t,e)=>{for(var n in e)w9e(t,n,{get:e[n],enumerable:!0})},M9e="listItem",MG="textStyle",NG=/^\s*([-+*])\s$/,gne=vs.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",ei(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(M9e,this.editor.getAttributes(MG)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Ng({find:NG,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ng({find:NG,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(MG),editor:this.editor})),[t]}}),xne=vs.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",ei(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)=>mL(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)}}}),N9e={};S9e(N9e,{findListItemPos:()=>Py,getNextListDepth:()=>ML,handleBackspace:()=>TR,handleDelete:()=>CR,hasListBefore:()=>bne,hasListItemAfter:()=>E9e,hasListItemBefore:()=>yne,listItemHasSubList:()=>vne,nextListIsDeeper:()=>_ne,nextListIsHigher:()=>wne});var Py=(t,e)=>{const{$from:n}=e.selection,r=_i(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}},ML=(t,e)=>{const n=Py(t,e);if(!n)return!1;const[,r]=fVe(e,t,n.$pos.pos+4);return r},bne=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),a=t.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},yne=(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)},vne=(t,e,n)=>{if(!n)return!1;const r=_i(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},TR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Kd(t.state,e)&&bne(t.state,e,n)){const{$anchor:l}=t.state.selection,c=t.state.doc.resolve(l.before()-1),u=[];c.node().descendants((m,g)=>{m.type.name===e&&u.push({node:m,pos:g})});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(!Kd(t.state,e)||!xVe(t.state))return!1;const r=Py(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=vne(e,t.state,a);return yne(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},_ne=(t,e)=>{const n=ML(t,e),r=Py(t,e);return!r||!n?!1:n>r.depth},wne=(t,e)=>{const n=ML(t,e),r=Py(t,e);return!r||!n?!1:n<r.depth},CR=(t,e)=>{if(!Kd(t.state,e)||!gVe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:_ne(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():wne(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},E9e=(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)},Sne=dr.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&&CR(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&&CR(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&&TR(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&&TR(t,n,r)&&(e=!0)}),e}}}}),EG=/^(\s*)(\d+)\.\s+(.*)$/,A9e=/^\s/;function T9e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(EG);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 g=t[f];if(g.match(EG))break;if(g.trim()==="")m.push(g),d+=`
- `,f+=1;else if(g.match(A9e))m.push(g),d+=`
- ${g.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:m.join(`
- `)}),r=f,n=f}return[e,r]}function Mne(t,e,n){var r;const i=[];let a=0;for(;a<t.length;){const o=t[a];if(o.indent===e){const l=o.content.split(`
- `),c=((r=l[0])==null?void 0:r.trim())||"",u=[];c&&u.push({type:"paragraph",raw:c,tokens:n.inlineTokens(c)});const d=l.slice(1).join(`
- `).trim();if(d){const g=n.blockTokens(d);u.push(...g)}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 g=Math.min(...m.map(y=>y.indent)),x=Mne(m,g,n);u.push({type:"list",ordered:!0,start:m[0].number,items:x,raw:m.map(y=>y.raw).join(`
- `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),a=f}else a+=1}return i}function C9e(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 k9e="listItem",AG="textStyle",TG=/^(\d+)\.\s$/,Nne=vs.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",ei(this.options.HTMLAttributes,n),0]:["ol",ei(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?C9e(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split(`
- `),[a,o]=T9e(i);if(a.length===0)return;const l=Mne(a,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:l,raw:i.slice(0,o).join(`
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(k9e,this.editor.getAttributes(AG)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Ng({find:TG,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=Ng({find:TG,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(AG)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),j9e=/^\s*(\[([( |x])?\])\s$/,P9e=vs.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",ei(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 mL(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 g=n();if(typeof g!="number")return!1;const x=m.doc.nodeAt(g);return m.setNodeMarkup(g,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[Ng({find:j9e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),R9e=vs.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",ei(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=a=>{const o=bR(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=bR(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()}}});dr.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(gne.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(xne.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Sne.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Nne.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(P9e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(R9e.configure(this.options.taskList)),t}});var D9e=vs.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",ei(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()}}}),O9e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,L9e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,I9e=rh.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",ei(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[Mg({find:O9e,type:this.type})]},addPasteRules(){return[$f({find:L9e,type:this.type})]}}),F9e=vs.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Ene=rh.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",ei(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()}}}),U9e=Ene;function z9e(t={}){return new Br({view(e){return new B9e(e,t)}})}class B9e{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 g=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(g){let x=g.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,g=f.height/c.offsetHeight;u=f.left-c.scrollLeft*m,d=f.top-c.scrollTop*g}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=Eee(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 Xr extends _n{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Xr.valid(r)?new Xr(r):_n.near(r)}content(){return Lt.empty}eq(e){return e instanceof Xr&&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 Xr(e.resolve(n.pos))}getBookmark(){return new NL(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!$9e(e)||!H9e(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&&Xr.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(Xr.valid(c))return c}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Yt.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(Xr.valid(l))return l}return null}}}Xr.prototype.visible=!1;Xr.findFrom=Xr.findGapCursorFrom;_n.jsonID("gapcursor",Xr);class NL{constructor(e){this.pos=e}map(e){return new NL(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Xr.valid(n)?new Xr(n):_n.near(n)}}function Ane(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function $9e(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||Ane(i.type))return!0;if(i.inlineContent)return!1}}return!0}function H9e(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||Ane(i.type))return!0;if(i.inlineContent)return!1}}return!0}function V9e(){return new Br({props:{decorations:K9e,createSelectionBetween(t,e,n){return e.pos==n.pos&&Xr.valid(n)?new Xr(n):null},handleClick:W9e,handleKeyDown:G9e,handleDOMEvents:{beforeinput:q9e}}})}const G9e=Ete({ArrowLeft:M1("horiz",-1),ArrowRight:M1("horiz",1),ArrowUp:M1("vert",-1),ArrowDown:M1("vert",1)});function M1(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 sn){if(!a.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=Xr.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new Xr(u))),!0):!1}}function W9e(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Xr.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Yt.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Xr(r))),!0)}function q9e(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Xr))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=Nt.empty;for(let o=r.length-1;o>=0;o--)i=Nt.from(r[o].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new Lt(i,0,0));return a.setSelection(sn.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function K9e(t){if(!(t.selection instanceof Xr))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Or.create(t.doc,[$a.widget(t.selection.head,e,{key:"gapcursor"})])}var p2=200,Zi=function(){};Zi.prototype.append=function(e){return e.length?(e=Zi.from(e),!this.length&&e||e.length<p2&&this.leafAppend(e)||this.length<p2&&e.leafPrepend(this)||this.appendInner(e)):this};Zi.prototype.prepend=function(e){return e.length?Zi.from(e).append(this):this};Zi.prototype.appendInner=function(e){return new X9e(this,e)};Zi.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Zi.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Zi.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Zi.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)};Zi.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};Zi.from=function(e){return e instanceof Zi?e:e&&e.length?new Tne(e):Zi.empty};var Tne=(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<=p2)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=p2)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})(Zi);Zi.empty=new Tne([]);var X9e=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,a,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(a,l),o)===!1||a>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,a)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(a,l)-l,o+l)===!1||a<l&&this.left.forEachInvertedInner(r,Math.min(i,l),a,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var a=this.left.length;return i<=a?this.left.slice(r,i):r>=a?this.right.slice(r-a,i-a):this.left.slice(r,a).append(this.right.slice(0,i-a))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Zi);const Y9e=500;class qo{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 _l(f.map));let g=f.step.map(i.slice(a)),x;g&&o.maybeStep(g).doc&&(x=o.mapping.maps[o.mapping.maps.length-1],u.push(new _l(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 qo(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 _l(e.mapping.maps[d],f,n),g;(g=c&&c.merge(m))&&(m=g,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>Z9e&&(l=Q9e(l,u),o-=u),new qo(l.append(a),o)}remapping(e,n){let r=new O0;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 qo(this.items.append(e.map(n=>new _l(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 g=a.getMirror(--c);if(g==null)return;o=Math.min(o,g);let x=a.maps[g];if(m.step){let y=e.steps[g].invert(e.docs[g]),b=m.selection&&m.selection.map(a.slice(c+1,g));b&&l++,r.push(new _l(x,y,b))}else r.push(new _l(x))},i);let u=[];for(let m=n;m<o;m++)u.push(new _l(a.maps[m]));let d=this.items.slice(0,i).append(u).append(r),f=new qo(d,l);return f.emptyItemCount()>Y9e&&(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 _l(u.invert(),c,d),m,g=i.length-1;(m=i.length&&i[g].merge(f))?i[g]=m:i.push(f)}}else o.map&&r--},this.items.length,0),new qo(Zi.from(i.reverse()),a)}}qo.empty=new qo(Zi.empty,0);function Q9e(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class _l{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 _l(n.getMap().invert(),n,this.selection)}}}class ld{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const Z9e=20;function J9e(t,e,n,r){let i=n.getMeta(gf),a;if(i)return i.historyState;n.getMeta(nGe)&&(t=new ld(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(gf))return o.getMeta(gf).redo?new ld(t.done.addTransform(n,void 0,r,tw(e)),t.undone,CG(n.mapping.maps),t.prevTime,t.prevComposition):new ld(t.done,t.undone.addTransform(n,void 0,r,tw(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||!eGe(n,t.prevRanges)),u=o?cj(t.prevRanges,n.mapping):CG(n.mapping.maps);return new ld(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,tw(e)),qo.empty,u,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new ld(t.done.rebased(n,a),t.undone.rebased(n,a),cj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new ld(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),cj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function eGe(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 CG(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 cj(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 tGe(t,e,n){let r=tw(e),i=gf.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 ld(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(o).setMeta(gf,{redo:n,historyState:c})}let uj=!1,kG=null;function tw(t){let e=t.plugins;if(kG!=e){uj=!1,kG=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){uj=!0;break}}return uj}const gf=new Li("history"),nGe=new Li("closeHistory");function rGe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Br({key:gf,state:{init(){return new ld(qo.empty,qo.empty,null,0,-1)},apply(e,n,r){return J9e(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?kne:r=="historyRedo"?jne:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Cne(t,e){return(n,r)=>{let i=gf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=tGe(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const kne=Cne(!1,!0),jne=Cne(!0,!0);dr.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 Br({key:new Li("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 iGe=dr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[z9e(this.options)]}});dr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Br({key:new Li("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return Or.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($a.node(u,u+c.nodeSize,{class:this.options.className}))}),Or.create(t,a)}}})]}});var aGe=dr.create({name:"gapCursor",addProseMirrorPlugins(){return[V9e()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Zn(Xt(t,"allowGapCursor",n)))!=null?e:null}}});dr.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Br({key:new Li("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&&tN(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=$a.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}),Or.create(t,i)}}})]}});dr.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Br({key:new Li("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||$te(n.selection)||t.view.dragging?null:Or.create(n.doc,[$a.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function jG({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var sGe=dr.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Li(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 Br({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!jG({node:o,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const o=i.doc.lastChild;return!jG({node:o,types:r})}}})]}}),oGe=dr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>kne(t,e),redo:()=>({state:t,dispatch:e})=>jne(t,e)}},addProseMirrorPlugins(){return[rGe(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()}}}),lGe=dr.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(O7e.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(k7e.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(gne.configure(this.options.bulletList)),this.options.code!==!1&&i.push(F7e.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(B7e.configure(this.options.codeBlock)),this.options.document!==!1&&i.push($7e.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(iGe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(aGe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(H7e.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(V7e.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(oGe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(G7e.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(Y7e.configure(this.options.italic)),this.options.listItem!==!1&&i.push(xne.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Sne.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(pne.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Nne.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(D9e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(I9e.configure(this.options.strike)),this.options.text!==!1&&i.push(F9e.configure(this.options.text)),this.options.underline!==!1&&i.push(Ene.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(sGe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),cGe=lGe,uGe=dr.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")}}}),dGe=uGe,hGe=20,Pne=(t,e=0)=>{const n=[];return!t.children.length||e>hGe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Pne(r,e+1))}),n},fGe=t=>{if(!t.children.length)return;const e=Pne(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}`)})},Rne=rh.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&fGe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",ei(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}}}}),mGe=dr.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()}}}),Dne=dr.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()}}}),pGe=dr.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()}}}),gGe=dr.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()}}}),xGe=dr.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()}}});dr.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(mGe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Dne.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(pGe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(gGe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(xGe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Rne.configure(this.options.textStyle)),t}});var bGe=Dne,yGe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,vGe=vs.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",ei(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,a,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",c=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",u=(o=(a=t.attrs)==null?void 0:a.title)!=null?o:"";return u?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o})=>{const l=document.createElement("img");Object.entries(o).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,f);break}}),l.src=o.src;const c=new t7e({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[rne({find:yGe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),_Ge=vGe;function kR({content:t,onChange:e,placeholder:n}){const r=N7e({extensions:[cGe.configure({heading:!1,codeBlock:!1,code:!1}),U9e,_9e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),dGe.configure({types:["paragraph"]}),Rne,bGe,_Ge.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(nce,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:s.jsx(Gue,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:s.jsx(Phe,{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(O2,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:s.jsx(KW,{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(Mhe,{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(vhe,{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(whe,{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(Y0,{className:"w-4 h-4"})}),r.isActive("link")&&s.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:s.jsx(aD,{className:"w-4 h-4"})})]}),s.jsx(b7e,{editor:r})]})}function One({archiveId:t,archiveName:e,onClose:n}){const r=tn(),[i,a]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState({}),{data:d,isLoading:f,error:m}=ct({queryKey:["archive-project-page",t],queryFn:()=>pe.getArchiveProjectPage(t)}),g=ft({mutationFn:E=>pe.updateArchiveProjectPage(t,E),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),u({})}});w.useEffect(()=>{const E=k=>{k.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=()=>{g.mutate(c)},v=()=>{a(!1),u({})},M=E=>{const k=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],C=new DOMParser().parseFromString(E,"text/html"),R=T=>{if(T.nodeType===Node.TEXT_NODE)return T.textContent||"";if(T.nodeType===Node.ELEMENT_NODE){const P=T,F=P.tagName.toLowerCase();if(!k.includes(F))return Array.from(P.childNodes).map(R).join("");let L="";if(F==="a"&&P.getAttribute("href")){const D=P.getAttribute("href");D?.toLowerCase().startsWith("http")&&(L=` href="${D}" target="_blank" rel="noopener noreferrer"`)}if(F==="img"){const D=P.getAttribute("src");if(!D?.toLowerCase().startsWith("http"))return"";L=` src="${D}" style="max-width: 100%; height: auto;"`}const X=Array.from(P.childNodes).map(R).join("");return["br","img"].includes(F)?`<${F}${L} />`:`<${F}${L}>${X}</${F}>`}return""};return Array.from(C.body.childNodes).map(R).join("")},S=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),A=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:A,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(za,{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(Se,{variant:"ghost",size:"sm",onClick:y,children:[s.jsx(wf,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&s.jsxs(s.Fragment,{children:[s.jsx(Se,{variant:"ghost",size:"sm",onClick:v,children:"Cancel"}),s.jsxs(Se,{variant:"primary",size:"sm",onClick:b,disabled:g.isPending,children:[s.jsx(ds,{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(Ut,{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(za,{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(Gj,{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(Gj,{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(Lr,{className:"w-3 h-3"})})]}),d.creation_date&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(Qr,{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(za,{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(za,{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(kR,{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:M(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(kR,{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:M(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(X0,{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,k)=>s.jsx("button",{onClick:()=>l(k),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(Lr,{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(vf,{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(Gs,{className:"w-6 h-6 text-white"})}),s.jsx("button",{onClick:()=>l(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:s.jsx(Ut,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",x.length]})]})]})}const wGe=[.25,.5,.75,1,1.5,2,3,4];function gp(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function SGe({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=$n(),a=w.useRef(null),o=w.useRef(null),[l,c]=w.useState(!1),[u,d]=w.useState(0),[f,m]=w.useState(0),[g,x]=w.useState(0),[y,b]=w.useState(0),[v,M]=w.useState(1),[S,A]=w.useState(null),[E,k]=w.useState(null),[C,R]=w.useState(.8),[T,P]=w.useState(!1),{data:F,isLoading:L}=ct({queryKey:["timelapse-info",t],queryFn:()=>pe.getTimelapseInfo(t)}),{data:X}=ct({queryKey:["timelapse-thumbnails",t],queryFn:()=>pe.getTimelapseThumbnails(t,15)}),D=ft({mutationFn:()=>pe.processTimelapse(t,{trimStart:g,trimEnd:y,speed:v,saveMode:"replace"},S||void 0),onSuccess:B=>{i(B.message,"success"),r?.(),n()},onError:B=>{i(B.message||"Processing failed","error")}});w.useEffect(()=>{F?.duration&&y===0&&b(F.duration)},[F?.duration,y]),w.useEffect(()=>{const B=G=>{G.key==="Escape"&&n()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[n]),w.useEffect(()=>{const B=a.current;if(!B)return;const G=()=>{const de=B.currentTime;d(de),de>=y&&(B.currentTime=g)},J=()=>{m(B.duration),y===0&&b(B.duration)},te=()=>c(!0),ae=()=>c(!1);return B.addEventListener("timeupdate",G),B.addEventListener("durationchange",J),B.addEventListener("play",te),B.addEventListener("pause",ae),()=>{B.removeEventListener("timeupdate",G),B.removeEventListener("durationchange",J),B.removeEventListener("play",te),B.removeEventListener("pause",ae)}},[g,y]),w.useEffect(()=>{const B=o.current,G=a.current;!B||!G||!E||(B.currentTime=G.currentTime,B.playbackRate=G.playbackRate,l&&!T?B.play().catch(()=>{}):B.pause())},[l,E,T]),w.useEffect(()=>{o.current&&(o.current.volume=T?0:C)},[C,T]),w.useEffect(()=>{a.current&&(a.current.playbackRate=v),o.current&&(o.current.playbackRate=v)},[v]);const K=w.useCallback(()=>{const B=a.current;B&&(l?B.pause():(B.currentTime<g&&(B.currentTime=g),B.play()))},[l,g]),Y=B=>{const G=a.current;G&&(G.currentTime=Math.max(g,Math.min(y,B)))},q=B=>{const G=B.target.files?.[0];G&&(E&&URL.revokeObjectURL(E),A(G),k(URL.createObjectURL(G)))},Z=()=>{E&&URL.revokeObjectURL(E),A(null),k(null)};w.useEffect(()=>()=>{E&&URL.revokeObjectURL(E)},[E]);const re=y-g,oe=re/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(mt,{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(Sd,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Se,{variant:"primary",size:"sm",onClick:()=>D.mutate(),disabled:D.isPending,children:D.isPending?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(ds,{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(Ut,{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:K,muted:!!E}),!l&&s.jsx("button",{onClick:K,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(rl,{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(Yde,{className:"w-4 h-4"}),s.jsx("span",{children:"Trim"}),s.jsxs("span",{className:"ml-auto",children:[gp(g)," - ",gp(y)," (",gp(re),")"]})]}),s.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 flex",children:X?.thumbnails.map((B,G)=>s.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${B})`}},G))}),s.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${g/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:`${g/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:g,onChange:B=>{const G=parseFloat(B.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:B=>{const G=parseFloat(B.target.value);G>g+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:B=>Y(parseFloat(B.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),s.jsx("div",{className:"flex items-center justify-center gap-2",children:s.jsx("button",{onClick:K,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(rD,{className:"w-5 h-5 text-white"}):s.jsx(rl,{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(j2,{className:"w-4 h-4"}),s.jsx("span",{children:"Speed"}),s.jsxs("span",{className:"ml-auto",children:[v,"x (output: ",gp(oe),")"]})]}),s.jsx("div",{className:"flex gap-1",children:wGe.map(B=>s.jsxs("button",{onClick:()=>M(B),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${v===B?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[B,"x"]},B))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(Vj,{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(Vj,{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:()=>P(!T),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:T?s.jsx(Bhe,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(Uhe,{className:"w-4 h-4 text-bambu-green"})}),s.jsx("input",{type:"range",min:0,max:1,step:.1,value:C,onChange:B=>R(parseFloat(B.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),s.jsx("button",{onClick:Z,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:s.jsx(an,{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(bi,{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:"})," ",gp(f)," @ ",F?.width,"x",F?.height]}),s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Output:"})," ",gp(oe)," @ ",v,"x speed",S&&" + music overlay"]})]})]}),D.isPending&&s.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[s.jsx(mt,{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 MGe=[.25,.5,.75,1,1.5,2,3,4];function Lne({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),[g,x]=w.useState(0),[y,b]=w.useState(!1);w.useEffect(()=>{const C=o.current;C&&(C.playbackRate=u)},[u]),w.useEffect(()=>{const C=R=>{R.key==="Escape"&&i()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[i]),w.useEffect(()=>{const C=o.current;if(!C)return;const R=()=>m(C.currentTime),T=()=>x(C.duration),P=()=>c(!0),F=()=>c(!1);return C.addEventListener("timeupdate",R),C.addEventListener("durationchange",T),C.addEventListener("play",P),C.addEventListener("pause",F),()=>{C.removeEventListener("timeupdate",R),C.removeEventListener("durationchange",T),C.removeEventListener("play",P),C.removeEventListener("pause",F)}},[]);const v=()=>{const C=o.current;C&&(l?C.pause():C.play())},M=C=>{const R=o.current;R&&(R.currentTime=parseFloat(C.target.value))},S=()=>{const C=o.current;C&&(C.currentTime=Math.max(0,C.currentTime-5))},A=()=>{const C=o.current;C&&(C.currentTime=Math.min(g,C.currentTime+5))},E=C=>{const R=Math.floor(C/60),T=Math.floor(C%60);return`${R}:${T.toString().padStart(2,"0")}`},k=()=>{const C=document.createElement("a");C.href=t,C.download=n,C.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(Sd,{className:"w-5 h-5 text-bambu-green"}),e]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>b(!0),children:[s.jsx(Ga,{className:"w-4 h-4"}),"Edit"]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:k,children:[s.jsx(Jr,{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(Ut,{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:g||100,value:f,onChange:M,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),s.jsx("span",{className:"text-xs text-bambu-gray w-12",children:E(g)})]}),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(ohe,{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(rD,{className:"w-5 h-5 text-white"}):s.jsx(rl,{className:"w-5 h-5 text-white"})}),s.jsx("button",{onClick:A,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:s.jsx(mw,{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:MGe.map(C=>s.jsxs("button",{onClick:()=>d(C),className:`px-2 py-1 text-xs rounded transition-colors ${u===C?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[C,"x"]},C))})]})]})]})]})]}),y&&r&&s.jsx(SGe,{archiveId:r,timelapseSrc:t,onClose:()=>b(!1),onSave:a})]})}function NGe({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}=ct({queryKey:["archive-comparison",t],queryFn:()=>pe.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(Ut,{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(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?s.jsxs("div",{className:"text-center py-12 text-red-400",children:[s.jsx(Cn,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),s.jsx("p",{children:"Failed to load comparison"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?s.jsx(EGe,{comparison:n}):null}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx(Se,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function EGe({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-bambu-green":e.status==="failed"?"text-red-400":"text-bambu-gray"}`,children:e.status})]},e.id))]})}),s.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>s.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[s.jsx("td",{className:"py-2 pr-4 text-sm",children:s.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&s.jsx(Cn,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),s.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>s.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??s.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&s.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&s.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[s.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[s.jsx(Cn,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),s.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>s.jsxs("li",{children:[s.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&s.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[s.jsx(xs,{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 AGe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function TGe(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 CGe({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,g]=w.useState(t.project_id),[x,y]=w.useState(!1);return s.jsx(Mt,{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(nf,{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:AGe(t.file_size)}),s.jsx("span",{children:"·"}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Gn,{className:"w-3 h-3"}),TGe(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(Jc,{className:"w-5 h-5"}):s.jsx(Ji,{className:"w-5 h-5"})}),s.jsx(Se,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:m||void 0}),disabled:i,children:i?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(Ha,{className:"w-4 h-4"}),"Archive"]})}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:()=>y(!0),disabled:a,children:a?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(an,{className:"w-4 h-4 text-red-400"})})]})]}),x&&s.jsx(Ln,{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=>g(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 kGe(){const t=tn(),{showToast:e}=$n(),[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}=ct({queryKey:["pending-uploads"],queryFn:yp.list,refetchInterval:1e4}),{data:m}=ct({queryKey:["projects"],queryFn:()=>pe.getProjects()}),g=ft({mutationFn:({id:v,data:M})=>yp.archive(v,M),onMutate:({id:v})=>{l(M=>new Set(M).add(v))},onSettled:(v,M,{id:S})=>{l(A=>{const E=new Set(A);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=ft({mutationFn:v=>yp.discard(v),onMutate:v=>{u(M=>new Set(M).add(v))},onSettled:(v,M,S)=>{u(A=>{const E=new Set(A);return E.delete(S),E})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:v=>{e(v.message||"Failed to discard","error")}}),y=ft({mutationFn:yp.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=ft({mutationFn:yp.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(Mt,{children:s.jsx(Et,{className:"py-8 flex justify-center",children:s.jsx(mt,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:s.jsxs("div",{className:"mb-6",children:[s.jsxs(Mt,{className:"border-l-4 border-l-yellow-500",children:[s.jsx(mr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(bi,{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(Se,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:y.isPending,children:y.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(Ha,{className:"w-4 h-4"}),"Archive All"]})}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:()=>a(!0),disabled:b.isPending,children:b.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(an,{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(CGe,{upload:v,projects:m||[],onArchive:(M,S)=>g.mutate({id:M,data:S}),onDiscard:M=>x.mutate(M),isArchiving:o.has(v.id),isDiscarding:c.has(v.id)},v.id))})]})]}),n&&s.jsx(Ln,{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(Ln,{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 g2(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function mb(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function Hh(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function jGe({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=tn(),{showToast:u}=$n(),d=cq(),[f,m]=w.useState(!1),[g,x]=w.useState(!1),[y,b]=w.useState(!1),[v,M]=w.useState(!1),[S,A]=w.useState(!1),[E,k]=w.useState(!1),[C,R]=w.useState([]),[T,P]=w.useState(!1),[F,L]=w.useState(!1),[X,D]=w.useState(!1),[K,Y]=w.useState(!1),[q,Z]=w.useState(!1),[re,oe]=w.useState(!1),[B,G]=w.useState(null),J=w.useRef(null),te=w.useRef(null),ae=ft({mutationFn:V=>pe.uploadSource3mf(t.id,V),onSuccess:V=>{c.invalidateQueries({queryKey:["archives"]}),u(`Source 3MF attached: ${V.filename}`)},onError:V=>{u(V.message||"Failed to upload source 3MF","error")}}),de=ft({mutationFn:()=>pe.deleteSource3mf(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Source 3MF removed")},onError:V=>{u(V.message||"Failed to remove source 3MF","error")}}),fe=ft({mutationFn:V=>pe.uploadF3d(t.id,V),onSuccess:V=>{c.invalidateQueries({queryKey:["archives"]}),u(`F3D attached: ${V.filename}`)},onError:V=>{u(V.message||"Failed to upload F3D","error")}}),Ae=ft({mutationFn:()=>pe.deleteF3d(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("F3D removed")},onError:V=>{u(V.message||"Failed to remove F3D","error")}}),ge=ft({mutationFn:()=>pe.scanArchiveTimelapse(t.id),onSuccess:V=>{V.status==="attached"?(c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${V.filename}`)):V.status==="exists"?u("Timelapse already attached"):V.status==="not_found"&&V.available_files&&V.available_files.length>0?(R(V.available_files),k(!0)):u(V.message||"No matching timelapse found","warning")},onError:V=>{u(V.message||"Failed to scan for timelapse","error")}}),Me=ft({mutationFn:V=>pe.selectArchiveTimelapse(t.id,V),onSuccess:V=>{c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${V.filename}`),k(!1),R([])},onError:V=>{u(V.message||"Failed to attach timelapse","error")}}),je=ft({mutationFn:()=>pe.deleteArchive(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Archive deleted")},onError:()=>{u("Failed to delete archive","error")}}),ne=ft({mutationFn:()=>pe.toggleFavorite(t.id),onSuccess:V=>{c.invalidateQueries({queryKey:["archives"]}),u(V.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:Ke}=ct({queryKey:["archive-folders",t.id],queryFn:()=>pe.getLibraryFoldersByArchive(t.id)}),$=ft({mutationFn:V=>pe.updateArchive(t.id,{project_id:V}),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),c.invalidateQueries({queryKey:["projects"]}),u("Project updated")},onError:()=>{u("Failed to update project","error")}}),z=V=>{V.preventDefault(),G({x:V.clientX,y:V.clientY})},U=[...Hh(t.filename)?[{label:"Print",icon:s.jsx(Ir,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:"Schedule",icon:s.jsx(Qr,{className:"w-4 h-4"}),onClick:()=>Y(!0)},{label:"Open in Bambu Studio",icon:s.jsx(Lr,{className:"w-4 h-4"}),onClick:()=>{const V=t.print_name||t.filename||"model",Q=`${window.location.origin}${pe.getArchiveForSlicer(t.id,V)}`;Oc(Q)}}]:[{label:"Slice",icon:s.jsx(Lr,{className:"w-4 h-4"}),onClick:()=>{const V=t.print_name||t.filename||"model",Q=`${window.location.origin}${pe.getArchiveForSlicer(t.id,V)}`;Oc(Q)}}],{label:"View on MakerWorld",icon:s.jsx(Md,{className:"w-4 h-4"}),onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:s.jsx(Os,{className:"w-4 h-4"}),onClick:()=>m(!0)},{label:"View Timelapse",icon:s.jsx(Sd,{className:"w-4 h-4"}),onClick:()=>A(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(JW,{className:"w-4 h-4"}),onClick:()=>ge.mutate(),disabled:!t.printer_id||!!t.timelapse_path||ge.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(uw,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const V=document.createElement("a");V.href=pe.getSource3mfDownloadUrl(t.id),V.download=`${t.print_name||t.filename}_source.3mf`,V.click()}else J.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(bi,{className:"w-4 h-4"}),onClick:()=>J.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(an,{className:"w-4 h-4"}),onClick:()=>Z(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(Os,{className:"w-4 h-4"}),onClick:()=>te.current?.click()},...t.f3d_path?[{label:"Download F3D",icon:s.jsx(Jr,{className:"w-4 h-4"}),onClick:()=>{const V=document.createElement("a");V.href=pe.getF3dDownloadUrl(t.id),V.download=`${t.print_name||t.filename}.f3d`,V.click()}},{label:"Remove F3D",icon:s.jsx(an,{className:"w-4 h-4"}),onClick:()=>oe(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx(Jr,{className:"w-4 h-4"}),onClick:()=>{const V=document.createElement("a");V.href=pe.getArchiveDownload(t.id),V.download=`${t.print_name||t.filename}.3mf`,V.click()}},{label:"Copy Download Link",icon:s.jsx(Jo,{className:"w-4 h-4"}),onClick:()=>{const V=`${window.location.origin}${pe.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(V).then(()=>{u("Link copied to clipboard")}).catch(()=>{u("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(ZW,{className:"w-4 h-4"}),onClick:()=>P(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(Xp,{className:"w-4 h-4"}),onClick:()=>L(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(za,{className:"w-4 h-4"}),onClick:()=>D(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(Sf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>ne.mutate()},{label:"Edit",icon:s.jsx(Ga,{className:"w-4 h-4"}),onClick:()=>M(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(ba,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(ba,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const V=[];if(t.project_id&&V.push({label:"Remove from Project",icon:s.jsx(Ut,{className:"w-4 h-4"}),onClick:()=>$.mutate(null)}),!a)V.push({label:"Loading...",icon:s.jsx(mt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const Q=a.filter(Ee=>Ee.status==="active");Q.length===0?V.push({label:"No projects available",icon:s.jsx(ba,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):Q.forEach(Ee=>{V.push({label:Ee.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Ee.color||"#888"}}),onClick:()=>$.mutate(Ee.id),disabled:t.project_id===Ee.id})})}return V})()},{label:n?"Deselect":"Select",icon:n?s.jsx(eu,{className:"w-4 h-4"}):s.jsx(Ol,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(an,{className:"w-4 h-4"}),onClick:()=>b(!0),danger:!0}];return s.jsxs(Mt,{"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:z,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:V=>{V.stopPropagation(),r(t.id)},children:n?s.jsx(eu,{className:"w-5 h-5 text-bambu-green"}):s.jsx(Ol,{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:pe.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(X0,{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:V=>{V.stopPropagation();const Q=V.currentTarget.getBoundingClientRect();G({x:Q.left,y:Q.bottom+4})},title:"Right-click for more options",children:s.jsx(wd,{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:V=>{V.stopPropagation(),ne.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:s.jsx(Sf,{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-red-500/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(Jo,{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:V=>{V.stopPropagation();const Q=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Ee=`${window.location.origin}${pe.getSource3mfForSlicer(t.id,Q)}`;Oc(Ee)},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:s.jsx(uw,{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:V=>{V.stopPropagation(),window.location.href=pe.getF3dDownloadUrl(t.id)},title:"Download Fusion 360 design file",children:s.jsx(Os,{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:V=>{V.stopPropagation(),A(!0)},title:"View timelapse",children:s.jsx(Sd,{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:V=>{V.stopPropagation(),L(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[s.jsx(Xp,{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})]}),Ke&&Ke.length>0&&s.jsx(ls,{to:`/files?folder=${Ke[0].id}`,className:"absolute bottom-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:V=>V.stopPropagation(),title:`Open folder: ${Ke[0].name}`,style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:s.jsx(el,{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 ${Hh(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:Hh(t.filename)?"Sliced file - ready to print":"Source file only - no AMS mapping available",children:Hh(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(V=>V.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(V=>V.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: ${mb(t.print_time_seconds||0)}
- Actual: ${mb(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${mb(t.actual_time_seconds)}`:`Estimated: ${mb(t.print_time_seconds||0)}`,children:[s.jsx(Gn,{className:"w-3 h-3"}),mb(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(Dl,{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(nl,{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(Os,{className:"w-3 h-3"}),t.object_count," object",t.object_count>1?"s":""]}),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((V,Q)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:V},title:V},Q))})]})]}),(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(tq,{className:"w-3 h-3"})}),t.tags?.split(",").map((V,Q)=>s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:V.trim()},Q))]}),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:eg(t.created_at,l)}),s.jsx("span",{children:g2(t.file_size)})]}),s.jsxs("div",{className:"flex gap-1 mt-3",children:[Hh(t.filename)?s.jsxs(s.Fragment,{children:[s.jsxs(Se,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>x(!0),children:[s.jsx(Ir,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Reprint"})]}),s.jsx(Se,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const V=t.print_name||t.filename||"model",Q=`${window.location.origin}${pe.getArchiveForSlicer(t.id,V)}`;Oc(Q)},title:"Open in Bambu Studio",children:s.jsx(Lr,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):s.jsxs(Se,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const V=t.print_name||t.filename||"model",Q=`${window.location.origin}${pe.getArchiveForSlicer(t.id,V)}`;Oc(Q)},title:"Open in Bambu Studio to slice",children:[s.jsx(Lr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Slice"})]}),s.jsx(Se,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url,title:t.makerworld_url?`MakerWorld: ${t.designer||"View project"}`:"Not from MakerWorld",children:s.jsx(Md,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),s.jsx(Se,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>m(!0),title:"3D Preview",children:s.jsx(Os,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Se,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const V=document.createElement("a");V.href=pe.getArchiveDownload(t.id),V.download=`${t.print_name||t.filename}.3mf`,V.click()},title:"Download",children:s.jsx(Jr,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Se,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>M(!0),title:"Edit",children:s.jsx(Ga,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Se,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>b(!0),title:"Delete",children:s.jsx(an,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),v&&s.jsx(YJ,{archive:t,onClose:()=>M(!1)}),f&&s.jsx(WJ,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>m(!1)}),g&&s.jsx(Wd,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>x(!1)}),y&&s.jsx(Ln,{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:()=>{je.mutate(),b(!1)},onCancel:()=>b(!1)}),q&&s.jsx(Ln,{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:()=>{de.mutate(),Z(!1)},onCancel:()=>Z(!1)}),re&&s.jsx(Ln,{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:()=>{Ae.mutate(),oe(!1)},onCancel:()=>oe(!1)}),B&&s.jsx(QJ,{x:B.x,y:B.y,items:U,onClose:()=>G(null)}),S&&t.timelapse_path&&s.jsx(Lne,{src:pe.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>A(!1),onEdit:()=>{c.invalidateQueries({queryKey:["archives"]}),A(!1)}}),E&&C.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:()=>{k(!1),R([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:C.map(V=>s.jsxs("button",{onClick:()=>Me.mutate(V.name),disabled:Me.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50",children:[s.jsx(Sd,{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:V.name}),s.jsxs("p",{className:"text-sm text-gray-400",children:[g2(V.size),V.mtime&&` • ${eg(V.mtime,l)}`]})]})]},V.name))}),s.jsx("div",{className:"p-4 border-t border-gray-700",children:s.jsx(Se,{variant:"secondary",onClick:()=>{k(!1),R([])},className:"w-full",children:"Cancel"})})]})}),T&&s.jsx(ZJ,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>P(!1)}),F&&t.photos&&t.photos.length>0&&s.jsx(JJ,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>L(!1),onDelete:async V=>{try{await pe.deleteArchivePhoto(t.id,V),c.invalidateQueries({queryKey:["archives"]}),u("Photo deleted")}catch{u("Failed to delete photo","error")}}}),X&&s.jsx(One,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>D(!1)}),K&&s.jsx(Wd,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>Y(!1)}),s.jsx("input",{ref:J,type:"file",accept:".3mf",className:"hidden",onChange:V=>{const Q=V.target.files?.[0];Q&&ae.mutate(Q),V.target.value=""}}),s.jsx("input",{ref:te,type:"file",accept:".f3d",className:"hidden",onChange:V=>{const Q=V.target.files?.[0];Q&&fe.mutate(Q),V.target.value=""}})]})}function PGe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o}){const l=tn(),{showToast:c}=$n(),[u,d]=w.useState(!1),[f,m]=w.useState(!1),[g,x]=w.useState(!1),[y,b]=w.useState(!1),[v,M]=w.useState(!1),[S,A]=w.useState(!1),[E,k]=w.useState(!1),[C,R]=w.useState([]),[T,P]=w.useState(!1),[F,L]=w.useState(!1),[X,D]=w.useState(!1),[K,Y]=w.useState(!1),[q,Z]=w.useState(!1),[re,oe]=w.useState(null),B=w.useRef(null),G=w.useRef(null),J=ft({mutationFn:W=>pe.uploadSource3mf(t.id,W),onSuccess:W=>{l.invalidateQueries({queryKey:["archives"]}),c(`Source 3MF attached: ${W.filename}`)},onError:W=>{c(W.message||"Failed to upload source 3MF","error")}}),te=ft({mutationFn:()=>pe.deleteSource3mf(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Source 3MF removed")},onError:W=>{c(W.message||"Failed to remove source 3MF","error")}}),ae=ft({mutationFn:W=>pe.uploadF3d(t.id,W),onSuccess:W=>{l.invalidateQueries({queryKey:["archives"]}),c(`F3D attached: ${W.filename}`)},onError:W=>{c(W.message||"Failed to upload F3D","error")}}),de=ft({mutationFn:()=>pe.deleteF3d(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("F3D removed")},onError:W=>{c(W.message||"Failed to remove F3D","error")}}),fe=ft({mutationFn:()=>pe.scanArchiveTimelapse(t.id),onSuccess:W=>{W.status==="attached"?(l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${W.filename}`)):W.status==="exists"?c("Timelapse already attached"):W.status==="not_found"&&W.available_files&&W.available_files.length>0?(R(W.available_files),k(!0)):c(W.message||"No matching timelapse found","warning")},onError:W=>{c(W.message||"Failed to scan for timelapse","error")}}),Ae=ft({mutationFn:W=>pe.selectArchiveTimelapse(t.id,W),onSuccess:W=>{l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${W.filename}`),k(!1),R([])},onError:W=>{c(W.message||"Failed to attach timelapse","error")}}),ge=ft({mutationFn:()=>pe.deleteArchive(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Archive deleted")},onError:()=>{c("Failed to delete archive","error")}}),Me=ft({mutationFn:()=>pe.toggleFavorite(t.id),onSuccess:W=>{l.invalidateQueries({queryKey:["archives"]}),c(W.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:je}=ct({queryKey:["archive-folders",t.id],queryFn:()=>pe.getLibraryFoldersByArchive(t.id)}),ne=ft({mutationFn:W=>pe.updateArchive(t.id,{project_id:W}),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),l.invalidateQueries({queryKey:["projects"]}),c("Project updated")},onError:()=>{c("Failed to update project","error")}}),Ke=W=>{W.preventDefault(),oe({x:W.clientX,y:W.clientY})},z=[...Hh(t.filename)?[{label:"Print",icon:s.jsx(Ir,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:"Schedule",icon:s.jsx(Qr,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:"Open in Bambu Studio",icon:s.jsx(Lr,{className:"w-4 h-4"}),onClick:()=>{const W=t.print_name||t.filename||"model",U=`${window.location.origin}${pe.getArchiveForSlicer(t.id,W)}`;Oc(U)}}]:[{label:"Slice",icon:s.jsx(Lr,{className:"w-4 h-4"}),onClick:()=>{const W=t.print_name||t.filename||"model",U=`${window.location.origin}${pe.getArchiveForSlicer(t.id,W)}`;Oc(U)}}],{label:"View on MakerWorld",icon:s.jsx(Md,{className:"w-4 h-4"}),onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:s.jsx(Os,{className:"w-4 h-4"}),onClick:()=>M(!0)},{label:"View Timelapse",icon:s.jsx(Sd,{className:"w-4 h-4"}),onClick:()=>A(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(JW,{className:"w-4 h-4"}),onClick:()=>fe.mutate(),disabled:!t.printer_id||!!t.timelapse_path||fe.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(uw,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const W=document.createElement("a");W.href=pe.getSource3mfDownloadUrl(t.id),W.download=`${t.print_name||t.filename}_source.3mf`,W.click()}else B.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(bi,{className:"w-4 h-4"}),onClick:()=>B.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(an,{className:"w-4 h-4"}),onClick:()=>Y(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(Os,{className:"w-4 h-4"}),onClick:()=>G.current?.click()},...t.f3d_path?[{label:"Download F3D",icon:s.jsx(Jr,{className:"w-4 h-4"}),onClick:()=>{const W=document.createElement("a");W.href=pe.getF3dDownloadUrl(t.id),W.download=`${t.print_name||t.filename}.f3d`,W.click()}},{label:"Remove F3D",icon:s.jsx(an,{className:"w-4 h-4"}),onClick:()=>Z(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx(Jr,{className:"w-4 h-4"}),onClick:()=>{const W=document.createElement("a");W.href=pe.getArchiveDownload(t.id),W.download=`${t.print_name||t.filename}.3mf`,W.click()}},{label:"Copy Download Link",icon:s.jsx(Jo,{className:"w-4 h-4"}),onClick:()=>{const W=`${window.location.origin}${pe.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(W).then(()=>{c("Link copied to clipboard")}).catch(()=>{c("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(ZW,{className:"w-4 h-4"}),onClick:()=>P(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(Xp,{className:"w-4 h-4"}),onClick:()=>L(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(za,{className:"w-4 h-4"}),onClick:()=>D(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(Sf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>Me.mutate()},{label:"Edit",icon:s.jsx(Ga,{className:"w-4 h-4"}),onClick:()=>d(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(ba,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(ba,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const W=[];if(t.project_id&&W.push({label:"Remove from Project",icon:s.jsx(Ut,{className:"w-4 h-4"}),onClick:()=>ne.mutate(null)}),!a)W.push({label:"Loading...",icon:s.jsx(mt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const U=a.filter(V=>V.status==="active");U.length===0?W.push({label:"No projects available",icon:s.jsx(ba,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):U.forEach(V=>{W.push({label:V.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:V.color||"#888"}}),onClick:()=>ne.mutate(V.id),disabled:t.project_id===V.id})})}return W})()},{label:n?"Deselect":"Select",icon:n?s.jsx(eu,{className:"w-4 h-4"}):s.jsx(Ol,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(an,{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:Ke,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(eu,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Ol,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?s.jsx("img",{src:pe.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(X0,{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(Sd,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),je&&je.length>0&&s.jsx(ls,{to:`/files?folder=${je[0].id}`,className:"flex-shrink-0",title:`Open folder: ${je[0].name}`,onClick:W=>W.stopPropagation(),children:s.jsx(el,{className:"w-3.5 h-3.5 text-yellow-400"})})]}),t.filament_type&&s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[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((W,U)=>s.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:W},title:W},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:Jp(t.created_at)}),s.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:g2(t.file_size)}),s.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[s.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>{const W=t.print_name||t.filename||"model",U=`${window.location.origin}${pe.getArchiveForSlicer(t.id,W)}`;Oc(U)},title:"Open in Bambu Studio",children:s.jsx(Lr,{className:"w-4 h-4"})}),t.makerworld_url&&s.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>window.open(t.makerworld_url,"_blank"),title:"MakerWorld",children:s.jsx(Md,{className:"w-4 h-4"})}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>{const W=document.createElement("a");W.href=pe.getArchiveDownload(t.id),W.download=`${t.print_name||t.filename}.3mf`,W.click()},title:"Download",children:s.jsx(Jr,{className:"w-4 h-4"})}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>d(!0),title:"Edit",children:s.jsx(Ga,{className:"w-4 h-4"})}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>m(!0),title:"Delete",children:s.jsx(an,{className:"w-4 h-4 text-red-400"})}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:W=>{const U=W.currentTarget.getBoundingClientRect();oe({x:U.left,y:U.bottom+4})},title:"More options",children:s.jsx(wd,{className:"w-4 h-4"})})]})]}),u&&s.jsx(YJ,{archive:t,onClose:()=>d(!1)}),v&&s.jsx(WJ,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>M(!1)}),g&&s.jsx(Wd,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>x(!1)}),f&&s.jsx(Ln,{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:()=>{ge.mutate(),m(!1)},onCancel:()=>m(!1)}),K&&s.jsx(Ln,{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:()=>{te.mutate(),Y(!1)},onCancel:()=>Y(!1)}),q&&s.jsx(Ln,{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:()=>{de.mutate(),Z(!1)},onCancel:()=>Z(!1)}),re&&s.jsx(QJ,{x:re.x,y:re.y,items:z,onClose:()=>oe(null)}),S&&t.timelapse_path&&s.jsx(Lne,{src:pe.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>A(!1),onEdit:()=>{l.invalidateQueries({queryKey:["archives"]}),A(!1)}}),E&&C.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:()=>{k(!1),R([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:C.map(W=>s.jsxs("button",{onClick:()=>Ae.mutate(W.name),disabled:Ae.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:W.name}),s.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[s.jsx("span",{children:g2(W.size)}),W.mtime&&s.jsx("span",{children:Jp(W.mtime)})]})]},W.name))})]})}),T&&s.jsx(ZJ,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>P(!1)}),F&&t.photos&&s.jsx(JJ,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>L(!1),onDelete:async W=>{try{await pe.deleteArchivePhoto(t.id,W),l.invalidateQueries({queryKey:["archives"]}),c("Photo deleted")}catch{c("Failed to delete photo","error")}}}),X&&s.jsx(One,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>D(!1)}),y&&s.jsx(Wd,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1)}),s.jsx("input",{ref:B,type:"file",accept:".3mf",className:"hidden",onChange:W=>{const U=W.target.files?.[0];U&&J.mutate(U),W.target.value=""}}),s.jsx("input",{ref:G,type:"file",accept:".f3d",className:"hidden",onChange:W=>{const U=W.target.files?.[0];U&&ae.mutate(U),W.target.value=""}})]})}const RGe=[{id:"all",label:"All Archives",icon:s.jsx(el,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:s.jsx(Gn,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:s.jsx(Qr,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:s.jsx(Qr,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:s.jsx(Sf,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:s.jsx(ea,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:s.jsx(Jo,{className:"w-4 h-4"})}];function DGe(){const t=tn(),{showToast:e}=$n(),n=w.useRef(null),[r,i]=w.useState(""),[a,o]=w.useState(()=>{const se=localStorage.getItem("archiveFilterPrinter");return se?Number(se):null}),[l,c]=w.useState(()=>localStorage.getItem("archiveFilterMaterial")),[u,d]=w.useState(()=>{const se=localStorage.getItem("archiveFilterColors");return se?new Set(JSON.parse(se)):new Set}),[f,m]=w.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[g,x]=w.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[y,b]=w.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[v,M]=w.useState(()=>localStorage.getItem("archiveFilterTag")),[S,A]=w.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[E,k]=w.useState(!1),[C,R]=w.useState([]),[T,P]=w.useState(!1),[F,L]=w.useState(new Set),[X,D]=w.useState(!1),[K,Y]=w.useState(!1),[q,Z]=w.useState(!1),[re,oe]=w.useState(!1),[B,G]=w.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[J,te]=w.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[ae,de]=w.useState(()=>localStorage.getItem("archiveCollection")||"all"),[fe,Ae]=w.useState(!1),[ge,Me]=w.useState(!1),[je,ne]=w.useState(!1),[Ke,$]=w.useState(null);w.useEffect(()=>{if(Ke){const se=setTimeout(()=>{const be=document.querySelector(`[data-archive-id="${Ke}"]`);be&&be.scrollIntoView({behavior:"smooth",block:"center"})},100),$e=setTimeout(()=>$(null),5e3);return()=>{clearTimeout(se),clearTimeout($e)}}},[Ke]);const{data:z,isLoading:W}=ct({queryKey:["archives",a],queryFn:()=>pe.getArchives(a||void 0)}),{data:U}=ct({queryKey:["printers"],queryFn:pe.getPrinters}),{data:V}=ct({queryKey:["projects"],queryFn:()=>pe.getProjects()}),{data:Q}=ct({queryKey:["settings"],queryFn:pe.getSettings}),Ee=Q?.time_format||"system",Ce=ft({mutationFn:async se=>(await Promise.all(se.map($e=>pe.deleteArchive($e))),se.length),onSuccess:se=>{t.invalidateQueries({queryKey:["archives"]}),L(new Set),e(`${se} archive${se!==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",g.toString())},[g]),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",B)},[B]),w.useEffect(()=>{localStorage.setItem("archiveSortBy",J)},[J]),w.useEffect(()=>{localStorage.setItem("archiveCollection",ae)},[ae]);const Ne=new Map(U?.map(se=>[se.id,se.name])||[]),H=[...new Set(z?.flatMap(se=>se.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),O=[...new Set(z?.flatMap(se=>se.filament_color?.split(",")||[]).filter(Boolean)||[])],ie=[...new Set(z?.flatMap(se=>se.tags?.split(",").map($e=>$e.trim())||[]).filter(Boolean)||[])].sort(),ye=z?.filter(se=>{const $e=new Date,be=mi(se.created_at)||new Date(0);let Fe=!0;switch(ae){case"recent":Fe=$e.getTime()-be.getTime()<1440*60*1e3;break;case"this-week":Fe=$e.getTime()-be.getTime()<10080*60*1e3;break;case"this-month":Fe=be.getMonth()===$e.getMonth()&&be.getFullYear()===$e.getFullYear();break;case"favorites":Fe=se.is_favorite===!0;break;case"failed":Fe=se.status==="failed"||se.status==="aborted";break;case"duplicates":Fe=se.duplicate_count>0;break}const De=(se.print_name||se.filename).toLowerCase().includes(r.toLowerCase()),ve=!l||se.filament_type?.split(", ").includes(l),He=se.filament_color?.split(",")||[],dt=u.size===0||(f==="or"?He.some($t=>u.has($t)):[...u].every($t=>He.includes($t))),kt=ae==="favorites"||!g||se.is_favorite,jt=ae==="failed"||!y||se.status!=="failed"&&se.status!=="aborted",Zt=se.tags?.split(",").map($t=>$t.trim())||[],Rt=!v||Zt.includes(v),nn=Hh(se.filename);return Fe&&De&&ve&&dt&&kt&&jt&&Rt&&(S==="all"||S==="gcode"&&nn||S==="source"&&!nn)}).sort((se,$e)=>{switch(J){case"date-desc":return(mi($e.created_at)?.getTime()||0)-(mi(se.created_at)?.getTime()||0);case"date-asc":return(mi(se.created_at)?.getTime()||0)-(mi($e.created_at)?.getTime()||0);case"name-asc":return(se.print_name||se.filename).localeCompare($e.print_name||$e.filename);case"name-desc":return($e.print_name||$e.filename).localeCompare(se.print_name||se.filename);case"size-desc":return $e.file_size-se.file_size;case"size-asc":return se.file_size-$e.file_size;default:return 0}}),_e=X||F.size>0,le=se=>{L($e=>{const be=new Set($e);return be.has(se)?be.delete(se):be.add(se),be})},ke=()=>{ye&&L(new Set(ye.map(se=>se.id)))},Oe=()=>{L(new Set),D(!1)},Ze=se=>{d($e=>{const be=new Set($e);return be.has(se)?be.delete(se):be.add(se),be})},ht=()=>{d(new Set)},We=()=>{i(""),o(null),c(null),x(!1),b(!1),M(null),A("all")},he=r||a||l||g||y||v||S!=="all",rt=w.useCallback(se=>{se.preventDefault(),se.dataTransfer.types.includes("Files")&&P(!0)},[]),qe=w.useCallback(se=>{se.preventDefault(),se.currentTarget===se.target&&P(!1)},[]),Je=w.useCallback(se=>{se.preventDefault(),P(!1);const $e=Array.from(se.dataTransfer.files).filter(be=>be.name.endsWith(".3mf"));$e.length>0?(R($e),k(!0)):se.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),ot=w.useCallback(se=>{const $e=se.target;if($e.tagName==="INPUT"||$e.tagName==="TEXTAREA"||$e.isContentEditable){se.key==="Escape"&&$e.blur();return}switch(se.key){case"/":se.preventDefault(),n.current?.focus();break;case"u":case"U":!se.metaKey&&!se.ctrlKey&&(se.preventDefault(),k(!0));break;case"Escape":_e&&Oe();break}},[_e]);return w.useEffect(()=>(document.addEventListener("keydown",ot),()=>document.removeEventListener("keydown",ot)),[ot]),s.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:rt,onDragLeave:qe,onDrop:Je,children:[T&&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(bi,{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"})]})}),_e&&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(Se,{variant:"secondary",size:"sm",onClick:Oe,children:[s.jsx(Ut,{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(Se,{variant:"secondary",size:"sm",onClick:ke,children:"Select All"}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>Z(!0),children:[s.jsx(Zp,{className:"w-4 h-4"}),"Tags"]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>oe(!0),children:[s.jsx(ba,{className:"w-4 h-4"}),"Project"]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>{const se=Array.from(F);Promise.all(se.map($e=>pe.toggleFavorite($e))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${se.length} archive${se.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[s.jsx(Sf,{className:"w-4 h-4"}),"Favorite"]}),s.jsxs(Se,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>Y(!0),children:[s.jsx(an,{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:ae,onChange:se=>de(se.target.value),children:RGe.map(se=>s.jsx("option",{value:se.id,children:se.label},se.id))})]}),s.jsxs("p",{className:"text-bambu-gray",children:[ye?.length||0," of ",z?.length||0," prints"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsxs(Se,{variant:"secondary",onClick:()=>Ae(!fe),disabled:ge,children:[ge?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(dw,{className:"w-4 h-4"}),"Export"]}),fe&&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()=>{Ae(!1),Me(!0);try{const{blob:se,filename:$e}=await pe.exportArchives({format:"csv",printerId:a||void 0,status:ae==="failed"?"failed":void 0,search:r||void 0}),be=URL.createObjectURL(se),Fe=document.createElement("a");Fe.href=be,Fe.download=$e,Fe.click(),URL.revokeObjectURL(be),e("Export downloaded")}catch{e("Export failed","error")}finally{Me(!1)}},children:[s.jsx(za,{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()=>{Ae(!1),Me(!0);try{const{blob:se,filename:$e}=await pe.exportArchives({format:"xlsx",printerId:a||void 0,status:ae==="failed"?"failed":void 0,search:r||void 0}),be=URL.createObjectURL(se),Fe=document.createElement("a");Fe.href=be,Fe.download=$e,Fe.click(),URL.revokeObjectURL(be),e("Export downloaded")}catch{e("Export failed","error")}finally{Me(!1)}},children:[s.jsx(dw,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),F.size>=2&&F.size<=5&&s.jsxs(Se,{variant:"secondary",onClick:()=>ne(!0),children:[s.jsx(Rp,{className:"w-4 h-4"}),"Compare (",F.size,")"]}),!_e&&s.jsxs(Se,{variant:"secondary",onClick:()=>D(!0),children:[s.jsx(eu,{className:"w-4 h-4"}),"Select"]}),s.jsxs(Se,{onClick:()=>k(!0),children:[s.jsx(bi,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),s.jsx(Mt,{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(xa,{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:se=>i(se.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(k2,{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:se=>o(se.target.value?Number(se.target.value):null),children:[s.jsx("option",{value:"",children:"All Printers"}),U?.map(se=>s.jsx("option",{value:se.id,children:se.name},se.id))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(Dl,{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:se=>c(se.target.value||null),children:[s.jsx("option",{value:"",children:"All Materials"}),H.map(se=>s.jsx("option",{value:se,children:se},se))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(uw,{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:se=>A(se.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(!g),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${g?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:g?"Show all":"Show favorites only",children:[s.jsx(Sf,{className:`w-4 h-4 ${g?"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(ea,{className:"w-4 h-4 "}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),ie.length>0&&s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(Zp,{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:se=>M(se.target.value||null),children:[s.jsx("option",{value:"",children:"All Tags"}),ie.map(se=>s.jsx("option",{value:se,children:se},se))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx($W,{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:J,onChange:se=>te(se.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 ${B==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>G("grid"),title:"Grid view",children:s.jsx(D2,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${B==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>G("list"),title:"List view",children:s.jsx(O2,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${B==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>G("calendar"),title:"Calendar view",children:s.jsx(fce,{className:"w-4 h-4"})})]})]}),he&&s.jsxs(Se,{variant:"ghost",size:"sm",onClick:We,className:"text-bambu-gray hover:text-white",children:[s.jsx(Ut,{className:"w-4 h-4"}),"Reset"]})]}),O.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(se=>se==="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:O.map(se=>s.jsx("button",{onClick:()=>Ze(se),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(se)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:se},title:se},se))}),u.size>0&&s.jsxs("button",{onClick:ht,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[s.jsx(Ut,{className:"w-3 h-3"}),"Clear"]})]})]})}),s.jsx(kGe,{}),W?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):ye?.length===0?s.jsx(Mt,{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"})]})}):B==="calendar"?s.jsx(Mt,{className:"p-6",children:s.jsx(o8e,{archives:ye||[],onArchiveClick:se=>{i(""),G("grid"),$(se.id)},highlightedArchiveId:Ke})}):B==="grid"?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:ye?.map(se=>s.jsx(jGe,{archive:se,printerName:se.printer_id?Ne.get(se.printer_id)||"Unknown":"No Printer",isSelected:F.has(se.id),onSelect:le,selectionMode:_e,projects:V,isHighlighted:se.id===Ke,timeFormat:Ee},se.id))}):B==="list"?s.jsx(Mt,{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"})]}),ye?.map(se=>s.jsx(PGe,{archive:se,printerName:se.printer_id?Ne.get(se.printer_id)||"Unknown":"No Printer",isSelected:F.has(se.id),onSelect:le,selectionMode:_e,projects:V,isHighlighted:se.id===Ke},se.id))]})}):null,E&&s.jsx(ZBe,{onClose:()=>{k(!1),R([])},initialFiles:C}),K&&s.jsx(Ln,{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:()=>{Ce.mutate(Array.from(F)),Y(!1)},onCancel:()=>Y(!1)}),q&&s.jsx(t8e,{selectedIds:Array.from(F),existingTags:ie,onClose:()=>Z(!1)}),re&&s.jsx(n8e,{selectedIds:Array.from(F),onClose:()=>oe(!1)}),je&&F.size>=2&&F.size<=5&&s.jsx(NGe,{archiveIds:Array.from(F),onClose:()=>{ne(!1),L(new Set),D(!1)}})]})}function OGe(){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 aN=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Yg(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function EL(t){return"nodeType"in t}function _s(t){var e,n;return t?Yg(t)?t:EL(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function AL(t){const{Document:e}=_s(t);return t instanceof e}function Ry(t){return Yg(t)?!1:t instanceof _s(t).HTMLElement}function Ine(t){return t instanceof _s(t).SVGElement}function Qg(t){return t?Yg(t)?t.document:EL(t)?AL(t)?t:Ry(t)||Ine(t)?t.ownerDocument:document:document:document}const Vl=aN?w.useLayoutEffect:w.useEffect;function TL(t){const e=w.useRef(t);return Vl(()=>{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 LGe(){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 H0(t,e){e===void 0&&(e=[t]);const n=w.useRef(t);return Vl(()=>{n.current!==t&&(n.current=t)},e),n}function Dy(t,e){const n=w.useRef();return w.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function x2(t){const e=TL(t),n=w.useRef(null),r=w.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function jR(t){const e=w.useRef();return w.useEffect(()=>{e.current=t},[t]),e.current}let dj={};function Oy(t,e){return w.useMemo(()=>{if(e)return e;const n=dj[t]==null?0:dj[t]+1;return dj[t]=n,t+"-"+n},[t,e])}function Fne(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 qp=Fne(1),V0=Fne(-1);function IGe(t){return"clientX"in t&&"clientY"in t}function CL(t){if(!t)return!1;const{KeyboardEvent:e}=_s(t.target);return e&&t instanceof e}function FGe(t){if(!t)return!1;const{TouchEvent:e}=_s(t.target);return e&&t instanceof e}function PR(t){if(FGe(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 IGe(t)?{x:t.clientX,y:t.clientY}:null}const Eg=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[Eg.Translate.toString(t),Eg.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),PG="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function UGe(t){return t.matches(PG)?t:t.querySelector(PG)}const zGe={display:"none"};function BGe(t){let{id:e,value:n}=t;return jr.createElement("div",{id:e,style:zGe},n)}function $Ge(t){let{id:e,announcement:n,ariaLiveType:r="assertive"}=t;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return jr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function HGe(){const[t,e]=w.useState("");return{announce:w.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const Une=w.createContext(null);function VGe(t){const e=w.useContext(Une);w.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function GGe(){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 WGe={draggable:`
- To pick up a draggable item, press the space bar.
- While dragging, use the arrow keys to move the item.
- Press space again to drop the item in its new position, or press escape to cancel.
- `},qGe={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 KGe(t){let{announcements:e=qGe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=WGe}=t;const{announce:a,announcement:o}=HGe(),l=Oy("DndLiveRegion"),[c,u]=w.useState(!1);if(w.useEffect(()=>{u(!0)},[]),VGe(w.useMemo(()=>({onDragStart(f){let{active:m}=f;a(e.onDragStart({active:m}))},onDragMove(f){let{active:m,over:g}=f;e.onDragMove&&a(e.onDragMove({active:m,over:g}))},onDragOver(f){let{active:m,over:g}=f;a(e.onDragOver({active:m,over:g}))},onDragEnd(f){let{active:m,over:g}=f;a(e.onDragEnd({active:m,over:g}))},onDragCancel(f){let{active:m,over:g}=f;a(e.onDragCancel({active:m,over:g}))}}),[a,e])),!c)return null;const d=jr.createElement(jr.Fragment,null,jr.createElement(BGe,{id:r,value:i.draggable}),jr.createElement($Ge,{id:l,announcement:o}));return n?Ic.createPortal(d,n):d}var Ei;(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"})(Ei||(Ei={}));function b2(){}function y2(t,e){return w.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function zne(){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 al=Object.freeze({x:0,y:0});function Bne(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function $ne(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function XGe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function RG(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 Hne(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function DG(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 Vne=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=DG(e,e.left,e.top),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=Bne(DG(c),i);a.push({id:l,data:{droppableContainer:o,value:u}})}}return a.sort($ne)},YGe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=RG(e),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=RG(c),d=i.reduce((m,g,x)=>m+Bne(u[x],g),0),f=Number((d/4).toFixed(4));a.push({id:l,data:{droppableContainer:o,value:f}})}}return a.sort($ne)};function QGe(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 ZGe=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=QGe(l,e);c>0&&i.push({id:o,data:{droppableContainer:a,value:c}})}}return i.sort(XGe)};function JGe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function Gne(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:al}function eWe(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 tWe=eWe(1);function nWe(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 rWe(t,e,n){const r=nWe(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 iWe={ignoreTransform:!1};function Zg(t,e){e===void 0&&(e=iWe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=_s(t).getComputedStyle(t);u&&(n=rWe(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 OG(t){return Zg(t,{ignoreTransform:!0})}function aWe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function sWe(t,e){return e===void 0&&(e=_s(t).getComputedStyle(t)),e.position==="fixed"}function oWe(t,e){e===void 0&&(e=_s(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 sN(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(AL(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Ry(i)||Ine(i)||n.includes(i))return n;const a=_s(t).getComputedStyle(i);return i!==t&&oWe(i,a)&&n.push(i),sWe(i,a)?n:r(i.parentNode)}return t?r(t):n}function Wne(t){const[e]=sN(t,1);return e??null}function hj(t){return!aN||!t?null:Yg(t)?t:EL(t)?AL(t)||t===Qg(t).scrollingElement?window:Ry(t)?t:null:null}function qne(t){return Yg(t)?t.scrollX:t.scrollLeft}function Kne(t){return Yg(t)?t.scrollY:t.scrollTop}function RR(t){return{x:qne(t),y:Kne(t)}}var Wi;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Wi||(Wi={}));function Xne(t){return!aN||!t?!1:t===document.scrollingElement}function Yne(t){const e={x:0,y:0},n=Xne(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 lWe={x:.2,y:.2};function cWe(t,e,n,r,i){let{top:a,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=lWe);const{isTop:u,isBottom:d,isLeft:f,isRight:m}=Yne(t),g={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?(g.y=Wi.Backward,x.y=r*Math.abs((e.top+y.height-a)/y.height)):!d&&c>=e.bottom-y.height&&(g.y=Wi.Forward,x.y=r*Math.abs((e.bottom-y.height-c)/y.height)),!m&&l>=e.right-y.width?(g.x=Wi.Forward,x.x=r*Math.abs((e.right-y.width-l)/y.width)):!f&&o<=e.left+y.width&&(g.x=Wi.Backward,x.x=r*Math.abs((e.left+y.width-o)/y.width)),{direction:g,speed:x}}function uWe(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 Qne(t){return t.reduce((e,n)=>qp(e,RR(n)),al)}function dWe(t){return t.reduce((e,n)=>e+qne(n),0)}function hWe(t){return t.reduce((e,n)=>e+Kne(n),0)}function fWe(t,e){if(e===void 0&&(e=Zg),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);Wne(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const mWe=[["x",["left","right"],dWe],["y",["top","bottom"],hWe]];class kL{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=sN(n),i=Qne(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,o,l]of mWe)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 Yb{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 pWe(t){const{EventTarget:e}=_s(t);return t instanceof e?t:Qg(t)}function fj(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 mo;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(mo||(mo={}));function LG(t){t.preventDefault()}function gWe(t){t.stopPropagation()}var On;(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"})(On||(On={}));const Zne={start:[On.Space,On.Enter],cancel:[On.Esc],end:[On.Space,On.Enter,On.Tab]},xWe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case On.Right:return{...n,x:n.x+25};case On.Left:return{...n,x:n.x-25};case On.Down:return{...n,y:n.y+25};case On.Up:return{...n,y:n.y-25}}};class oN{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 Yb(Qg(n)),this.windowListeners=new Yb(_s(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(mo.Resize,this.handleCancel),this.windowListeners.add(mo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(mo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&fWe(r),n(al)}handleKeyDown(e){if(CL(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=Zne,coordinateGetter:o=xWe,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}:al;this.referenceCoordinates||(this.referenceCoordinates=d);const f=o(e,{active:n,context:r.current,currentCoordinates:d});if(f){const m=V0(f,d),g={x:0,y:0},{scrollableAncestors:x}=r.current;for(const y of x){const b=e.code,{isTop:v,isRight:M,isLeft:S,isBottom:A,maxScroll:E,minScroll:k}=Yne(y),C=uWe(y),R={x:Math.min(b===On.Right?C.right-C.width/2:C.right,Math.max(b===On.Right?C.left:C.left+C.width/2,f.x)),y:Math.min(b===On.Down?C.bottom-C.height/2:C.bottom,Math.max(b===On.Down?C.top:C.top+C.height/2,f.y))},T=b===On.Right&&!M||b===On.Left&&!S,P=b===On.Down&&!A||b===On.Up&&!v;if(T&&R.x!==f.x){const F=y.scrollLeft+m.x,L=b===On.Right&&F<=E.x||b===On.Left&&F>=k.x;if(L&&!m.y){y.scrollTo({left:F,behavior:l});return}L?g.x=y.scrollLeft-F:g.x=b===On.Right?y.scrollLeft-E.x:y.scrollLeft-k.x,g.x&&y.scrollBy({left:-g.x,behavior:l});break}else if(P&&R.y!==f.y){const F=y.scrollTop+m.y,L=b===On.Down&&F<=E.y||b===On.Up&&F>=k.y;if(L&&!m.x){y.scrollTo({top:F,behavior:l});return}L?g.y=y.scrollTop-F:g.y=b===On.Down?y.scrollTop-E.y:y.scrollTop-k.y,g.y&&y.scrollBy({top:-g.y,behavior:l});break}}this.handleMove(e,qp(V0(f,this.referenceCoordinates),g))}}}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()}}oN.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Zne,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 IG(t){return!!(t&&"distance"in t)}function FG(t){return!!(t&&"delay"in t)}class jL{constructor(e,n,r){var i;r===void 0&&(r=pWe(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=Qg(o),this.documentListeners=new Yb(this.document),this.listeners=new Yb(r),this.windowListeners=new Yb(_s(o)),this.initialCoordinates=(i=PR(a))!=null?i:al,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(mo.Resize,this.handleCancel),this.windowListeners.add(mo.DragStart,LG),this.windowListeners.add(mo.VisibilityChange,this.handleCancel),this.windowListeners.add(mo.ContextMenu,LG),this.documentListeners.add(mo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(FG(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(IG(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(mo.Click,gWe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(mo.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=PR(e))!=null?n:al,u=V0(i,c);if(!r&&l){if(IG(l)){if(l.tolerance!=null&&fj(u,l.tolerance))return this.handleCancel();if(fj(u,l.distance))return this.handleStart()}if(FG(l)&&fj(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===On.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const bWe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class lN extends jL{constructor(e){const{event:n}=e,r=Qg(n.target);super(e,bWe,r)}}lN.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 yWe={move:{name:"mousemove"},end:{name:"mouseup"}};var DR;(function(t){t[t.RightClick=2]="RightClick"})(DR||(DR={}));class vWe extends jL{constructor(e){super(e,yWe,Qg(e.event.target))}}vWe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===DR.RightClick?!1:(r?.({event:n}),!0)}}];const mj={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class _We extends jL{constructor(e){super(e,mj)}static setup(){return window.addEventListener(mj.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(mj.move.name,e)};function e(){}}}_We.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 Qb;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(Qb||(Qb={}));var v2;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(v2||(v2={}));function wWe(t){let{acceleration:e,activator:n=Qb.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:l=v2.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:m}=t;const g=MWe({delta:f,disabled:!a}),[x,y]=LGe(),b=w.useRef({x:0,y:0}),v=w.useRef({x:0,y:0}),M=w.useMemo(()=>{switch(n){case Qb.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Qb.DraggableRect:return i}},[n,i,c]),S=w.useRef(null),A=w.useCallback(()=>{const k=S.current;if(!k)return;const C=b.current.x*v.current.x,R=b.current.y*v.current.y;k.scrollBy(C,R)},[]),E=w.useMemo(()=>l===v2.TreeOrder?[...u].reverse():u,[l,u]);w.useEffect(()=>{if(!a||!u.length||!M){y();return}for(const k of E){if(r?.(k)===!1)continue;const C=u.indexOf(k),R=d[C];if(!R)continue;const{direction:T,speed:P}=cWe(k,R,M,e,m);for(const F of["x","y"])g[F][T[F]]||(P[F]=0,T[F]=0);if(P.x>0||P.y>0){y(),S.current=k,x(A,o),b.current=P,v.current=T;return}}b.current={x:0,y:0},v.current={x:0,y:0},y()},[e,A,r,y,a,o,JSON.stringify(M),JSON.stringify(g),x,u,E,d,JSON.stringify(m)])}const SWe={x:{[Wi.Backward]:!1,[Wi.Forward]:!1},y:{[Wi.Backward]:!1,[Wi.Forward]:!1}};function MWe(t){let{delta:e,disabled:n}=t;const r=jR(e);return Dy(i=>{if(n||!r||!i)return SWe;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Wi.Backward]:i.x[Wi.Backward]||a.x===-1,[Wi.Forward]:i.x[Wi.Forward]||a.x===1},y:{[Wi.Backward]:i.y[Wi.Backward]||a.y===-1,[Wi.Forward]:i.y[Wi.Forward]||a.y===1}}},[n,e,r])}function NWe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Dy(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function EWe(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 G0;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(G0||(G0={}));var OR;(function(t){t.Optimized="optimized"})(OR||(OR={}));const UG=new Map;function AWe(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=H0(f),g=w.useCallback(function(v){v===void 0&&(v=[]),!m.current&&o(M=>M===null?v:M.concat(v.filter(S=>!M.includes(S))))},[m]),x=w.useRef(null),y=Dy(v=>{if(f&&!n)return UG;if(!v||v===UG||d.current!==t||a!=null){const M=new Map;for(let S of t){if(!S)continue;if(a&&a.length>0&&!a.includes(S.id)&&S.rect.current){M.set(S.id,S.rect.current);continue}const A=S.node.current,E=A?new kL(c(A),A):null;S.rect.current=E,E&&M.set(S.id,E)}return M}return v},[t,a,n,f,c]);return w.useEffect(()=>{d.current=t},[t]),w.useEffect(()=>{f||g()},[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(()=>{g(),x.current=null},l))},[l,f,g,...r]),{droppableRects:y,measureDroppableContainers:g,measuringScheduled:a!=null};function b(){switch(u){case G0.Always:return!1;case G0.BeforeDragging:return n;default:return!n}}}function Jne(t,e){return Dy(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function TWe(t,e){return Jne(t,e)}function CWe(t){let{callback:e,disabled:n}=t;const r=TL(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 cN(t){let{callback:e,disabled:n}=t;const r=TL(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 kWe(t){return new kL(Zg(t),t)}function zG(t,e,n){e===void 0&&(e=kWe);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=CWe({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=cN({callback:a});return Vl(()=>{a(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function jWe(t){const e=Jne(t);return Gne(t,e)}const BG=[];function PWe(t){const e=w.useRef(t),n=Dy(r=>t?r&&r!==BG&&t&&e.current&&t.parentNode===e.current.parentNode?r:sN(t):BG,[t]);return w.useEffect(()=>{e.current=t},[t]),n}function RWe(t){const[e,n]=w.useState(null),r=w.useRef(t),i=w.useCallback(a=>{const o=hj(a.target);o&&n(l=>l?(l.set(o,RR(o)),new Map(l)):null)},[]);return w.useEffect(()=>{const a=r.current;if(t!==a){o(a);const l=t.map(c=>{const u=hj(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,RR(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=hj(c);u?.removeEventListener("scroll",i)})}},[i,t]),w.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,o)=>qp(a,o),al):Qne(t):al,[t,e])}function $G(t,e){e===void 0&&(e=[]);const n=w.useRef(null);return w.useEffect(()=>{n.current=null},e),w.useEffect(()=>{const r=t!==al;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?V0(t,n.current):al}function DWe(t){w.useEffect(()=>{if(!aN)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 OWe(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 ere(t){return w.useMemo(()=>t?aWe(t):null,[t])}const HG=[];function LWe(t,e){e===void 0&&(e=Zg);const[n]=t,r=ere(n?_s(n):null),[i,a]=w.useState(HG);function o(){a(()=>t.length?t.map(c=>Xne(c)?r:new kL(e(c),c)):HG)}const l=cN({callback:o});return Vl(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function IWe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return Ry(e)?e:t}function FWe(t){let{measure:e}=t;const[n,r]=w.useState(null),i=w.useCallback(u=>{for(const{target:d}of u)if(Ry(d)){r(f=>{const m=e(d);return f?{...f,width:m.width,height:m.height}:m});break}},[e]),a=cN({callback:i}),o=w.useCallback(u=>{const d=IWe(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[l,c]=x2(o);return w.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const UWe=[{sensor:lN,options:{}},{sensor:oN,options:{}}],zWe={current:{}},nw={draggable:{measure:OG},droppable:{measure:OG,strategy:G0.WhileDragging,frequency:OR.Optimized},dragOverlay:{measure:Zg}};class Zb 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 BWe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Zb,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:b2},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:nw,measureDroppableContainers:b2,windowRect:null,measuringScheduled:!1},$We={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:b2,draggableNodes:new Map,over:null,measureDroppableContainers:b2},uN=w.createContext($We),tre=w.createContext(BWe);function HWe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Zb}}}function VWe(t,e){switch(e.type){case Ei.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Ei.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 Ei.DragEnd:case Ei.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ei.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new Zb(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case Ei.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 Zb(t.droppable.containers);return o.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case Ei.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new Zb(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function GWe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=w.useContext(uN),a=jR(r),o=jR(n?.id);return w.useEffect(()=>{if(!e&&!r&&a&&o!=null){if(!CL(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=UGe(d);if(f){f.focus();break}}})}},[r,e,i,o,a]),null}function WWe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function qWe(t){return w.useMemo(()=>({draggable:{...nw.draggable,...t?.draggable},droppable:{...nw.droppable,...t?.droppable},dragOverlay:{...nw.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function KWe(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;Vl(()=>{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=Gne(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=Wne(u);m&&m.scrollBy({top:f.y,left:f.x})}},[e,o,l,r,n])}const nre=w.createContext({...al,scaleX:1,scaleY:1});var cd;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(cd||(cd={}));const rre=w.memo(function(e){var n,r,i,a;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=UWe,collisionDetection:f=ZGe,measuring:m,modifiers:g,...x}=e;const y=w.useReducer(VWe,void 0,HWe),[b,v]=y,[M,S]=GGe(),[A,E]=w.useState(cd.Uninitialized),k=A===cd.Initialized,{draggable:{active:C,nodes:R,translate:T},droppable:{containers:P}}=b,F=C!=null?R.get(C):null,L=w.useRef({initial:null,translated:null}),X=w.useMemo(()=>{var Fe;return C!=null?{id:C,data:(Fe=F?.data)!=null?Fe:zWe,rect:L}:null},[C,F]),D=w.useRef(null),[K,Y]=w.useState(null),[q,Z]=w.useState(null),re=H0(x,Object.values(x)),oe=Oy("DndDescribedBy",o),B=w.useMemo(()=>P.getEnabled(),[P]),G=qWe(m),{droppableRects:J,measureDroppableContainers:te,measuringScheduled:ae}=AWe(B,{dragging:k,dependencies:[T.x,T.y],config:G.droppable}),de=NWe(R,C),fe=w.useMemo(()=>q?PR(q):null,[q]),Ae=be(),ge=TWe(de,G.draggable.measure);KWe({activeNode:C!=null?R.get(C):null,config:Ae.layoutShiftCompensation,initialRect:ge,measure:G.draggable.measure});const Me=zG(de,G.draggable.measure,ge),je=zG(de?de.parentElement:null),ne=w.useRef({activatorEvent:null,active:null,activeNode:de,collisionRect:null,collisions:null,droppableRects:J,draggableNodes:R,draggingNode:null,draggingNodeRect:null,droppableContainers:P,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ke=P.getNodeFor((n=ne.current.over)==null?void 0:n.id),$=FWe({measure:G.dragOverlay.measure}),z=(r=$.nodeRef.current)!=null?r:de,W=k?(i=$.rect)!=null?i:Me:null,U=!!($.nodeRef.current&&$.rect),V=jWe(U?null:Me),Q=ere(z?_s(z):null),Ee=PWe(k?Ke??de:null),Ce=LWe(Ee),Ne=WWe(g,{transform:{x:T.x-V.x,y:T.y-V.y,scaleX:1,scaleY:1},activatorEvent:q,active:X,activeNodeRect:Me,containerNodeRect:je,draggingNodeRect:W,over:ne.current.over,overlayNodeRect:$.rect,scrollableAncestors:Ee,scrollableAncestorRects:Ce,windowRect:Q}),H=fe?qp(fe,T):null,O=RWe(Ee),ie=$G(O),ye=$G(O,[Me]),_e=qp(Ne,ie),le=W?tWe(W,Ne):null,ke=X&&le?f({active:X,collisionRect:le,droppableRects:J,droppableContainers:B,pointerCoordinates:H}):null,Oe=Hne(ke,"id"),[Ze,ht]=w.useState(null),We=U?Ne:qp(Ne,ye),he=JGe(We,(a=Ze?.rect)!=null?a:null,Me),rt=w.useRef(null),qe=w.useCallback((Fe,De)=>{let{sensor:ve,options:He}=De;if(D.current==null)return;const dt=R.get(D.current);if(!dt)return;const kt=Fe.nativeEvent,jt=new ve({active:D.current,activeNode:dt,event:kt,options:He,context:ne,onAbort(Rt){if(!R.get(Rt))return;const{onDragAbort:pt}=re.current,$t={id:Rt};pt?.($t),M({type:"onDragAbort",event:$t})},onPending(Rt,nn,pt,$t){if(!R.get(Rt))return;const{onDragPending:wt}=re.current,_r={id:Rt,constraint:nn,initialCoordinates:pt,offset:$t};wt?.(_r),M({type:"onDragPending",event:_r})},onStart(Rt){const nn=D.current;if(nn==null)return;const pt=R.get(nn);if(!pt)return;const{onDragStart:$t}=re.current,qt={activatorEvent:kt,active:{id:nn,data:pt.data,rect:L}};Ic.unstable_batchedUpdates(()=>{$t?.(qt),E(cd.Initializing),v({type:Ei.DragStart,initialCoordinates:Rt,active:nn}),M({type:"onDragStart",event:qt}),Y(rt.current),Z(kt)})},onMove(Rt){v({type:Ei.DragMove,coordinates:Rt})},onEnd:Zt(Ei.DragEnd),onCancel:Zt(Ei.DragCancel)});rt.current=jt;function Zt(Rt){return async function(){const{active:pt,collisions:$t,over:qt,scrollAdjustedTranslate:wt}=ne.current;let _r=null;if(pt&&wt){const{cancelDrop:$r}=re.current;_r={activatorEvent:kt,active:pt,collisions:$t,delta:wt,over:qt},Rt===Ei.DragEnd&&typeof $r=="function"&&await Promise.resolve($r(_r))&&(Rt=Ei.DragCancel)}D.current=null,Ic.unstable_batchedUpdates(()=>{v({type:Rt}),E(cd.Uninitialized),ht(null),Y(null),Z(null),rt.current=null;const $r=Rt===Ei.DragEnd?"onDragEnd":"onDragCancel";if(_r){const Tr=re.current[$r];Tr?.(_r),M({type:$r,event:_r})}})}}},[R]),Je=w.useCallback((Fe,De)=>(ve,He)=>{const dt=ve.nativeEvent,kt=R.get(He);if(D.current!==null||!kt||dt.dndKit||dt.defaultPrevented)return;const jt={active:kt};Fe(ve,De.options,jt)===!0&&(dt.dndKit={capturedBy:De.sensor},D.current=He,qe(ve,De))},[R,qe]),ot=EWe(d,Je);DWe(d),Vl(()=>{Me&&A===cd.Initializing&&E(cd.Initialized)},[Me,A]),w.useEffect(()=>{const{onDragMove:Fe}=re.current,{active:De,activatorEvent:ve,collisions:He,over:dt}=ne.current;if(!De||!ve)return;const kt={active:De,activatorEvent:ve,collisions:He,delta:{x:_e.x,y:_e.y},over:dt};Ic.unstable_batchedUpdates(()=>{Fe?.(kt),M({type:"onDragMove",event:kt})})},[_e.x,_e.y]),w.useEffect(()=>{const{active:Fe,activatorEvent:De,collisions:ve,droppableContainers:He,scrollAdjustedTranslate:dt}=ne.current;if(!Fe||D.current==null||!De||!dt)return;const{onDragOver:kt}=re.current,jt=He.get(Oe),Zt=jt&&jt.rect.current?{id:jt.id,rect:jt.rect.current,data:jt.data,disabled:jt.disabled}:null,Rt={active:Fe,activatorEvent:De,collisions:ve,delta:{x:dt.x,y:dt.y},over:Zt};Ic.unstable_batchedUpdates(()=>{ht(Zt),kt?.(Rt),M({type:"onDragOver",event:Rt})})},[Oe]),Vl(()=>{ne.current={activatorEvent:q,active:X,activeNode:de,collisionRect:le,collisions:ke,droppableRects:J,draggableNodes:R,draggingNode:z,draggingNodeRect:W,droppableContainers:P,over:Ze,scrollableAncestors:Ee,scrollAdjustedTranslate:_e},L.current={initial:W,translated:le}},[X,de,ke,le,R,z,W,J,P,Ze,Ee,_e]),wWe({...Ae,delta:T,draggingRect:le,pointerCoordinates:H,scrollableAncestors:Ee,scrollableAncestorRects:Ce});const se=w.useMemo(()=>({active:X,activeNode:de,activeNodeRect:Me,activatorEvent:q,collisions:ke,containerNodeRect:je,dragOverlay:$,draggableNodes:R,droppableContainers:P,droppableRects:J,over:Ze,measureDroppableContainers:te,scrollableAncestors:Ee,scrollableAncestorRects:Ce,measuringConfiguration:G,measuringScheduled:ae,windowRect:Q}),[X,de,Me,q,ke,je,$,R,P,J,Ze,te,Ee,Ce,G,ae,Q]),$e=w.useMemo(()=>({activatorEvent:q,activators:ot,active:X,activeNodeRect:Me,ariaDescribedById:{draggable:oe},dispatch:v,draggableNodes:R,over:Ze,measureDroppableContainers:te}),[q,ot,X,Me,v,oe,R,Ze,te]);return jr.createElement(Une.Provider,{value:S},jr.createElement(uN.Provider,{value:$e},jr.createElement(tre.Provider,{value:se},jr.createElement(nre.Provider,{value:he},u)),jr.createElement(GWe,{disabled:l?.restoreFocus===!1})),jr.createElement(KGe,{...l,hiddenTextDescribedById:oe}));function be(){const Fe=K?.autoScrollEnabled===!1,De=typeof c=="object"?c.enabled===!1:c===!1,ve=k&&!Fe&&!De;return typeof c=="object"?{...c,enabled:ve}:{enabled:ve}}}),XWe=w.createContext(null),VG="button",YWe="Draggable";function QWe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=Oy(YWe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:m}=w.useContext(uN),{role:g=VG,roleDescription:x="draggable",tabIndex:y=0}=i??{},b=c?.id===e,v=w.useContext(b?nre:XWe),[M,S]=x2(),[A,E]=x2(),k=OWe(o,e),C=H0(n);Vl(()=>(f.set(e,{id:e,key:a,node:M,activatorNode:A,data:C}),()=>{const T=f.get(e);T&&T.key===a&&f.delete(e)}),[f,e]);const R=w.useMemo(()=>({role:g,tabIndex:y,"aria-disabled":r,"aria-pressed":b&&g===VG?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,g,y,b,x,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:R,isDragging:b,listeners:r?void 0:k,node:M,over:m,setNodeRef:S,setActivatorNodeRef:E,transform:v}}function ZWe(){return w.useContext(tre)}const JWe="Droppable",eqe={timeout:25};function tqe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=Oy(JWe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=w.useContext(uN),d=w.useRef({disabled:n}),f=w.useRef(!1),m=w.useRef(null),g=w.useRef(null),{disabled:x,updateMeasurementsFor:y,timeout:b}={...eqe,...i},v=H0(y??r),M=w.useCallback(()=>{if(!f.current){f.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),g.current=null},b)},[b]),S=cN({callback:M,disabled:x||!o}),A=w.useCallback((R,T)=>{S&&(T&&(S.unobserve(T),f.current=!1),R&&S.observe(R))},[S]),[E,k]=x2(A),C=H0(e);return w.useEffect(()=>{!S||!E.current||(S.disconnect(),f.current=!1,S.observe(E.current))},[E,S]),w.useEffect(()=>(l({type:Ei.RegisterDroppable,element:{id:r,key:a,disabled:n,node:E,rect:m,data:C}}),()=>l({type:Ei.UnregisterDroppable,key:a,id:r})),[r]),w.useEffect(()=>{n!==d.current.disabled&&(l({type:Ei.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:k}}function dN(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function nqe(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function N1(t){return t!==null&&t>=0}function rqe(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 iqe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const PL=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=dN(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}},E1={scaleX:1,scaleY:1},aqe=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,...E1}:null}const c=sqe(a,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...E1}:i<n&&i>=o?{x:0,y:l.height+c,...E1}:{x:0,y:0,...E1}};function sqe(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 ire="Sortable",are=jr.createContext({activeIndex:-1,containerId:ire,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:PL,disabled:{draggable:!1,droppable:!1}});function sre(t){let{children:e,id:n,items:r,strategy:i=PL,disabled:a=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=ZWe(),f=Oy(ire,n),m=l.rect!==null,g=w.useMemo(()=>r.map(k=>typeof k=="object"&&"id"in k?k.id:k),[r]),x=o!=null,y=o?g.indexOf(o.id):-1,b=u?g.indexOf(u.id):-1,v=w.useRef(g),M=!rqe(g,v.current),S=b!==-1&&y===-1||M,A=iqe(a);Vl(()=>{M&&x&&d(g)},[M,g,x,d]),w.useEffect(()=>{v.current=g},[g]);const E=w.useMemo(()=>({activeIndex:y,containerId:f,disabled:A,disableTransforms:S,items:g,overIndex:b,useDragOverlay:m,sortedRects:nqe(g,c),strategy:i}),[y,f,A.draggable,A.droppable,S,g,b,c,m,i]);return jr.createElement(are.Provider,{value:E},e)}const oqe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return dN(n,r,i).indexOf(e)},lqe=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},cqe={duration:200,easing:"ease"},ore="transform",uqe=Eg.Transition.toString({property:ore,duration:0,easing:"linear"}),dqe={roleDescription:"sortable"};function hqe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,o]=w.useState(null),l=w.useRef(n);return Vl(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=Zg(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 lre(t){let{animateLayoutChanges:e=lqe,attributes:n,disabled:r,data:i,getNewIndex:a=oqe,id:o,strategy:l,resizeObserverConfig:c,transition:u=cqe}=t;const{items:d,containerId:f,activeIndex:m,disabled:g,disableTransforms:x,sortedRects:y,overIndex:b,useDragOverlay:v,strategy:M}=w.useContext(are),S=fqe(r,g),A=d.indexOf(o),E=w.useMemo(()=>({sortable:{containerId:f,index:A,items:d},...i}),[f,i,A,d]),k=w.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:C,node:R,isOver:T,setNodeRef:P}=tqe({id:o,data:E,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...c}}),{active:F,activatorEvent:L,activeNodeRect:X,attributes:D,setNodeRef:K,listeners:Y,isDragging:q,over:Z,setActivatorNodeRef:re,transform:oe}=QWe({id:o,data:E,attributes:{...dqe,...n},disabled:S.draggable}),B=OGe(P,K),G=!!F,J=G&&!x&&N1(m)&&N1(b),te=!v&&q,ae=te&&J?oe:null,fe=J?ae??(l??M)({rects:y,activeNodeRect:X,activeIndex:m,overIndex:b,index:A}):null,Ae=N1(m)&&N1(b)?a({id:o,items:d,activeIndex:m,overIndex:b}):A,ge=F?.id,Me=w.useRef({activeId:ge,items:d,newIndex:Ae,containerId:f}),je=d!==Me.current.items,ne=e({active:F,containerId:f,isDragging:q,isSorting:G,id:o,index:A,items:d,newIndex:Me.current.newIndex,previousItems:Me.current.items,previousContainerId:Me.current.containerId,transition:u,wasDragging:Me.current.activeId!=null}),Ke=hqe({disabled:!ne,index:A,node:R,rect:C});return w.useEffect(()=>{G&&Me.current.newIndex!==Ae&&(Me.current.newIndex=Ae),f!==Me.current.containerId&&(Me.current.containerId=f),d!==Me.current.items&&(Me.current.items=d)},[G,Ae,f,d]),w.useEffect(()=>{if(ge===Me.current.activeId)return;if(ge!=null&&Me.current.activeId==null){Me.current.activeId=ge;return}const z=setTimeout(()=>{Me.current.activeId=ge},50);return()=>clearTimeout(z)},[ge]),{active:F,activeIndex:m,attributes:D,data:E,rect:C,index:A,newIndex:Ae,items:d,isOver:T,isSorting:G,isDragging:q,listeners:Y,node:R,overIndex:b,over:Z,setNodeRef:B,setActivatorNodeRef:re,setDroppableNodeRef:P,setDraggableNodeRef:K,transform:Ke??fe,transition:$()};function $(){if(Ke||je&&Me.current.newIndex===A)return uqe;if(!(te&&!CL(L)||!u)&&(G||ne))return Eg.Transition.toString({...u,property:ore})}}function fqe(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 _2(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 mqe=[On.Down,On.Right,On.Up,On.Left],cre=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:l}}=e;if(mqe.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 On.Down:r.top<m.top&&c.push(f);break;case On.Up:r.top>m.top&&c.push(f);break;case On.Left:r.left>m.left&&c.push(f);break;case On.Right:r.left<m.left&&c.push(f);break}});const u=YGe({collisionRect:r,droppableRects:i,droppableContainers:c});let d=Hne(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),g=m?i.get(m.id):null,x=m?.node.current;if(x&&g&&f&&m){const b=sN(x).some((k,C)=>l[C]!==k),v=ure(f,m),M=pqe(f,m),S=b||!v?{x:0,y:0}:{x:M?r.width-g.width:0,y:M?r.height-g.height:0},A={x:g.left,y:g.top};return S.x&&S.y?A:V0(A,S)}}}};function ure(t,e){return!_2(t)||!_2(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function pqe(t,e){return!_2(t)||!_2(e)||!ure(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function dre(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 gqe(t,e="system"){if(!t)return"ASAP";const n=mi(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`:eg(t,e)}function xqe({status:t}){const e={pending:{icon:Gn,color:"text-yellow-400 bg-yellow-400/10 border-yellow-400/20",label:"Pending"},printing:{icon:rl,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:Dn,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:qi,color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},skipped:{icon:mw,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Ut,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 pj({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:o,onStart:l,timeFormat:c="system"}){const{attributes:u,listeners:d,setNodeRef:f,transform:m,transition:g,isDragging:x}=lre({id:t.id,disabled:t.status!=="pending"}),y={transform:Eg.Transform.toString(m),transition:g},b=t.status==="printing",v=t.status==="pending",M=["completed","failed","skipped","cancelled"].includes(t.status);return s.jsx("div",{ref:f,style:y,className:`
- group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
- transition-all duration-200 hover:border-bambu-dark-tertiary/80
- ${x?"opacity-50 scale-[1.02] shadow-xl z-50":""}
- ${b?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
- `,children:s.jsxs("div",{className:"flex items-center gap-4 p-4",children:[v?s.jsx("div",{...u,...d,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(Qp,{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:pe.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?s.jsx("img",{src:pe.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(nl,{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(ls,{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(Lr,{className:"w-3.5 h-3.5"})}):t.library_file_id?s.jsx(ls,{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(Lr,{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?"text-orange-400":""}`,children:[s.jsx(Ir,{className:"w-3.5 h-3.5"}),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(md,{className:"w-3.5 h-3.5"}),dre(t.print_time_seconds)]}),v&&!t.manual_start&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Gn,{className:"w-3.5 h-3.5"}),gqe(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(qW,{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(uu,{className:"w-3 h-3"}),"Auto power off"]})]}),b&&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(ea,{className:"w-3 h-3"}),t.error_message]})]}),s.jsx(xqe,{status:t.status}),s.jsxs("div",{className:"flex items-center gap-1",children:[b&&s.jsx(Se,{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(kce,{className:"w-4 h-4"})}),v&&s.jsxs(s.Fragment,{children:[t.manual_start&&s.jsx(Se,{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(rl,{className:"w-4 h-4"})}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:s.jsx(Ga,{className:"w-4 h-4"})}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Ut,{className:"w-4 h-4"})})]}),M&&s.jsxs(s.Fragment,{children:[s.jsx(Se,{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(yr,{className:"w-4 h-4"})}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:s.jsx(an,{className:"w-4 h-4"})})]})]})]})})}function bqe(){const t=tn(),{showToast:e}=$n(),[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,g]=w.useState(null),[x,y]=w.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[b,v]=w.useState(()=>{const J=localStorage.getItem("queue.historySortAsc");return J!==null?J==="true":!1}),[M,S]=w.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[A,E]=w.useState(()=>{const J=localStorage.getItem("queue.pendingSortAsc");return J!==null?J==="true":!0});w.useEffect(()=>{localStorage.setItem("queue.historySortBy",x)},[x]),w.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(b))},[b]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",M)},[M]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(A))},[A]);const k=zne(y2(lN,{activationConstraint:{distance:8}}),y2(oN,{coordinateGetter:cre})),{data:C}=ct({queryKey:["settings"],queryFn:pe.getSettings}),R=C?.time_format||"system",{data:T,isLoading:P}=ct({queryKey:["queue",n,i],queryFn:()=>pe.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:F}=ct({queryKey:["printers"],queryFn:()=>pe.getPrinters()}),L=ft({mutationFn:J=>pe.cancelQueueItem(J),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),X=ft({mutationFn:J=>pe.removeFromQueue(J),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),D=ft({mutationFn:J=>pe.stopQueueItem(J),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),K=ft({mutationFn:J=>pe.startQueueItem(J),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print released to queue")},onError:()=>e("Failed to start print","error")}),Y=ft({mutationFn:J=>pe.reorderQueue(J),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),q=ft({mutationFn:async()=>{const J=T?.filter(te=>["completed","failed","skipped","cancelled"].includes(te.status))||[];for(const te of J)await pe.removeFromQueue(te.id);return J.length},onSuccess:J=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${J} history item${J!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),Z=w.useMemo(()=>{const J=T?.filter(ae=>ae.status==="pending")||[],te=ae=>{if(!ae.scheduled_time)return 0;const de=new Date(ae.scheduled_time).getTime(),fe=Date.now()+4320*60*60*1e3;return de>fe?0:de};return[...J].sort((ae,de)=>{let fe;if(M==="name"){const Ae=ae.archive_name||ae.library_file_name||"",ge=de.archive_name||de.library_file_name||"";fe=Ae.localeCompare(ge)}else M==="printer"?fe=(ae.printer_name||"").localeCompare(de.printer_name||""):M==="time"?fe=te(ae)-te(de):fe=ae.position-de.position;return A?fe:-fe})},[T,M,A]),re=T?.filter(J=>J.status==="printing")||[],oe=w.useMemo(()=>[...T?.filter(te=>["completed","failed","skipped","cancelled"].includes(te.status))||[]].sort((te,ae)=>{let de;if(x==="name"){const fe=te.archive_name||te.library_file_name||"",Ae=ae.archive_name||ae.library_file_name||"";de=fe.localeCompare(Ae)}else x==="printer"?de=(te.printer_name||"").localeCompare(ae.printer_name||""):de=new Date(ae.completed_at||ae.created_at).getTime()-new Date(te.completed_at||te.created_at).getTime();return b?-de:de}),[T,x,b]),B=w.useMemo(()=>Z.reduce((J,te)=>J+(te.print_time_seconds||0),0),[Z]),G=J=>{const{active:te,over:ae}=J;if(!ae||te.id===ae.id)return;const de=Z.findIndex(Ae=>Ae.id===te.id),fe=Z.findIndex(Ae=>Ae.id===ae.id);if(de!==-1&&fe!==-1){const ge=dN(Z,de,fe).map((Me,je)=>({id:Me.id,position:je+1}));Y.mutate(ge)}};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(KW,{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(Mt,{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(rl,{className:"w-5 h-5 text-blue-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:re.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),s.jsx(Mt,{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(Gn,{className:"w-5 h-5 text-yellow-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:Z.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),s.jsx(Mt,{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(md,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:dre(B)}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),s.jsx(Mt,{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(Dn,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:oe.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:J=>{const te=J.target.value;r(te==="unassigned"?-1:te===""?null:Number(te))},children:[s.jsx("option",{value:"",children:"All Printers"}),s.jsx("option",{value:"unassigned",children:"Unassigned"}),F?.map(J=>s.jsx("option",{value:J.id,children:J.name},J.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:J=>a(J.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"}),oe.length>0&&s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>l(!0),children:[s.jsx(an,{className:"w-4 h-4"}),"Clear History"]})]}),P?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):T?.length===0?s.jsxs(Mt,{className:"p-12 text-center border-dashed",children:[s.jsx(Qr,{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:[re.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:re.map(J=>s.jsx(pj,{item:J,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>g({type:"stop",item:J}),onRequeue:()=>{},onStart:()=>{},timeFormat:R},J.id))})]}),Z.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(Gn,{className:"w-5 h-5 text-yellow-400"}),"Queued",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Z.length," item",Z.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:M,onChange:J=>S(J.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(Se,{variant:"ghost",size:"sm",onClick:()=>E(!A),title:A?"Ascending":"Descending",className:"px-2",children:A?s.jsx(Kp,{className:"w-4 h-4"}):s.jsx(i0,{className:"w-4 h-4"})})]})]}),s.jsx(rre,{sensors:k,collisionDetection:Vne,onDragEnd:G,children:s.jsx(sre,{items:Z.map(J=>J.id),strategy:aqe,children:s.jsx("div",{className:"space-y-3",children:Z.map((J,te)=>s.jsx(pj,{item:J,position:te+1,onEdit:()=>u(J),onCancel:()=>g({type:"cancel",item:J}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>K.mutate(J.id),timeFormat:R},J.id))})})})]}),oe.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(Dn,{className:"w-5 h-5 text-bambu-gray"}),"History",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",oe.length," item",oe.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:x,onChange:J=>y(J.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(Se,{variant:"ghost",size:"sm",onClick:()=>v(!b),title:b?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:b?s.jsx(Kp,{className:"w-4 h-4"}):s.jsx(i0,{className:"w-4 h-4"})})]})]}),s.jsx("div",{className:"space-y-3",children:oe.slice(0,20).map((J,te)=>s.jsx(pj,{item:J,position:te+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>g({type:"remove",item:J}),onStop:()=>{},onRequeue:()=>f(J),onStart:()=>{},timeFormat:R},J.id))})]})]}),c&&s.jsx(Wd,{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(Wd,{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(Ln,{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"?L.mutate(m.item.id):m.type==="stop"?D.mutate(m.item.id):X.mutate(m.item.id),g(null)},onCancel:()=>g(null)}),o&&s.jsx(Ln,{title:"Clear History",message:`Are you sure you want to remove all ${oe.length} item${oe.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{q.mutate(),l(!1)},onCancel:()=>l(!1)})]})}function yqe({printDates:t,months:e=3}){const n=w.useRef(null),[r,i]=w.useState(0);w.useEffect(()=>{const M=n.current;if(!M)return;const S=new ResizeObserver(A=>{const E=A[0]?.contentRect.width||0;i(E)});return S.observe(M),()=>S.disconnect()},[]);const{weeks:a,monthLabels:o,printCounts:l}=w.useMemo(()=>{const M={};t.forEach(F=>{const L=F.split("T")[0];M[L]=(M[L]||0)+1});const S=new Date,A=new Date(S);A.setMonth(A.getMonth()-e),A.setDate(A.getDate()-A.getDay());const E=[],k=[];let C=[],R=-1;const T=new Date(A);let P=0;for(;T<=S;)T.getDay()===0&&C.length>0&&(E.push(C),C=[],P++),T.getMonth()!==R&&(k.push({month:T.toLocaleDateString("en-US",{month:"short"}),weekIndex:P}),R=T.getMonth()),C.push(new Date(T)),T.setDate(T.getDate()+1);return C.length>0&&E.push(C),{weeks:E,monthLabels:k,printCounts:M}},[t,e]),c=Math.max(1,...Object.values(l)),u=M=>{if(M===0)return"bg-bambu-dark";const S=M/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,g=2,x=r-m-16,y=f>0?Math.floor((x-(f-1)*g)/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:M,weekIndex:S},A)=>s.jsx("div",{className:"text-bambu-gray",style:{fontSize:v,marginLeft:A===0?0:`${(S-(o[A-1]?.weekIndex||0))*(b+g)-24}px`},children:M},A))}),s.jsxs("div",{className:"flex",style:{gap:g},children:[s.jsx("div",{className:"flex flex-col",style:{gap:g,marginRight:4,width:m},children:d.map((M,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:M},M))}),a.map((M,S)=>s.jsx("div",{className:"flex flex-col",style:{gap:g},children:[0,1,2,3,4,5,6].map(A=>{const E=M.find(T=>T.getDay()===A);if(!E)return s.jsx("div",{style:{width:b,height:b}},A);const k=E.toISOString().split("T")[0],C=l[k]||0,R=k===new Date().toISOString().split("T")[0];return s.jsx("div",{className:`rounded-sm ${u(C)} ${R?"ring-1 ring-white":""}`,style:{width:b,height:b},title:`${E.toLocaleDateString()}: ${C} print${C!==1?"s":""}`},A)})},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:g},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 A1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function vqe(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 _qe({archives:t,currency:e="$"}){const[n,r]=w.useState("30d"),i=w.useMemo(()=>{const m=vqe(n);return t.filter(g=>(mi(g.completed_at||g.created_at)||new Date(0))>=m)},[t,n]),a=w.useMemo(()=>{const m=new Map;return i.forEach(g=>{const x=mi(g.completed_at||g.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+=g.filament_used_grams||0,b.cost+=g.cost||0,b.prints+=1,m.set(y,b)}),Array.from(m.values()).sort((g,x)=>g.date.localeCompare(x.date)).map(g=>({...g,dateLabel:new Date(g.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(g=>{const x=mi(g.completed_at||g.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+=g.filament_used_grams||0,v.cost+=g.cost||0,v.prints+=1,m.set(b,v)}),Array.from(m.values()).sort((g,x)=>g.week.localeCompare(x.week)).map(g=>({date:g.week,dateLabel:`Week of ${new Date(g.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...g}))},[i,a,n]),l=w.useMemo(()=>{const m=new Map;return i.forEach(g=>{const y=(g.filament_type||"Unknown").split(", ");y.forEach(b=>{const v=(g.filament_used_grams||0)/y.length;m.set(b,(m.get(b)||0)+v)})}),Array.from(m.entries()).map(([g,x])=>({name:g,value:Math.round(x)})).sort((g,x)=>x.value-g.value)},[i]),c=w.useMemo(()=>{const m=new Date,g=[];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"}),M=t.filter(S=>{const A=mi(S.completed_at||S.created_at)||new Date(0);return A>=y&&A<=b});g.push({month:v,filament:Math.round(M.reduce((S,A)=>S+(A.filament_used_grams||0),0)),cost:M.reduce((S,A)=>S+(A.cost||0),0),prints:M.length})}return g},[t]),u=n==="7d"||n==="30d"?a:o,d=i.reduce((m,g)=>m+(g.filament_used_grams||0),0),f=i.reduce((m,g)=>m+(g.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(F1,{width:"100%",height:250,children:s.jsxs(bke,{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(lS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(uS,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),s.jsx(dS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(z1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:m=>[`${m.toFixed(0)}g`,"Filament"]}),s.jsx(cZ,{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(F1,{width:160,height:160,children:s.jsxs(gke,{children:[s.jsx(RQ,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((m,g)=>s.jsx(wy,{fill:A1[g%A1.length]},`cell-${g}`))}),s.jsx(z1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:m=>[`${m}g`,"Usage"]})]})}),s.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((m,g)=>{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:A1[g%A1.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(F1,{width:"100%",height:200,children:s.jsxs(ike,{data:c,children:[s.jsx(lS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(uS,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),s.jsx(dS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(z1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(m,g)=>[g==="filament"?`${m}g`:g==="cost"?`${e}${m.toFixed(2)}`:m,g==="filament"?"Filament":g==="cost"?"Cost":"Prints"]}),s.jsx(OD,{}),s.jsx(UQ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function wqe({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}=lre({id:t}),g={transform:Eg.Transform.toString(d),transition:f,opacity:m?.5:1};return r?null:s.jsxs("div",{ref:u,style:{...g,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(Qp,{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(YW,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):s.jsx(XW,{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(T2,{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 Sqe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:a}){const o=()=>{const A={};return t.forEach(E=>{A[E.id]=E.defaultSize||4}),A},[l,c]=w.useState(()=>{const A=localStorage.getItem(e);if(A)try{const E=JSON.parse(A);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 A=()=>d(E=>!E);return window.addEventListener("toggle-hidden-panel",A),()=>window.removeEventListener("toggle-hidden-panel",A)},[]),w.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),w.useEffect(()=>{const E=t.map(k=>k.id).filter(k=>!l.order.includes(k));E.length>0&&c(k=>({...k,order:[...k.order,...E]}))},[t,l.order]);const f=zne(y2(lN,{activationConstraint:{distance:8}}),y2(oN,{coordinateGetter:cre})),m=A=>{const{active:E,over:k}=A;k&&E.id!==k.id&&c(C=>{const R=C.order.indexOf(E.id),T=C.order.indexOf(k.id);return{...C,order:dN(C.order,R,T)}})},g=A=>{c(E=>({...E,hidden:E.hidden.includes(A)?E.hidden.filter(k=>k!==A):[...E.hidden,A]}))},x=A=>{c(E=>{const k=E.sizes[A]||4,C=k===1?2:k===2?4:1;return{...E,sizes:{...E.sizes,[A]:C}}})},y=()=>{const A={order:t.map(E=>E.id),hidden:t.filter(E=>E.defaultVisible===!1).map(E=>E.id),sizes:o()};c(A),i?.()},b=l.order.map(A=>t.find(E=>E.id===A)).filter(Boolean),v=b.filter(A=>!l.hidden.includes(A.id)),M=b.filter(A=>l.hidden.includes(A.id)),S=a?.({hiddenCount:M.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(Se,{variant:"secondary",size:"sm",onClick:y,children:[s.jsx(Vf,{className:"w-4 h-4"}),"Reset Layout"]}),M.length>0&&s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[s.jsx(_f,{className:"w-4 h-4"}),M.length," Hidden"]})]}),u&&M.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:M.map(A=>s.jsxs("button",{onClick:()=>g(A.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(_f,{className:"w-3 h-3"}),A.title]},A.id))})]}),s.jsx(rre,{sensors:f,collisionDetection:Vne,onDragEnd:m,children:s.jsx(sre,{items:v.map(A=>A.id),strategy:PL,children:s.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(A=>s.jsx(wqe,{id:A.id,title:A.title,component:A.component,isHidden:l.hidden.includes(A.id),size:l.sizes[A.id]||2,onToggleVisibility:()=>g(A.id),onToggleSize:()=>x(A.id)},A.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(Se,{className:"mt-4",onClick:y,children:"Reset Layout"})]})]})}function Mqe({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(Dl,{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(Gn,{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(Dl,{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(Uj,{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(Mf,{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(Uj,{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 Nqe({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(Dn,{className:"w-4 h-4 text-bambu-green 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(qi,{className:"w-4 h-4 text-red-400 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 Eqe({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,g=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(nq,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{children:"100% = perfect estimate"})]}),g.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:g.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-bambu-green":y>105?"text-blue-400":"text-orange-400"}`,children:[y.toFixed(0),"%"]})]},x))})]})]})}function Aqe({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 Tqe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return s.jsx(yqe,{printDates:t,months:n})}function Cqe({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(Ir,{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 kqe({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(_qe,{archives:t,currency:e})}function jqe({size:t=1}){const{data:e,isLoading:n}=ct({queryKey:["failureAnalysis"],queryFn:()=>pe.getFailureAnalysis({days:30})});if(n)return s.jsx("div",{className:"flex justify-center py-4",children:s.jsx(mt,{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(Cn,{className:`w-5 h-5 ${e.failure_rate>20?"text-red-400":e.failure_rate>10?"text-yellow-400":"text-bambu-green"}`}),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(iq,{className:`w-4 h-4 ${e.trend[e.trend.length-1].failure_rate<e.trend[e.trend.length-2].failure_rate?"text-bambu-green":"text-red-400"}`}),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 Pqe(){const{showToast:t}=$n(),[e,n]=w.useState(!1),[r,i]=w.useState(!1),[a,o]=w.useState(0),[l,c]=w.useState(0);w.useEffect(()=>{const S=()=>{try{const E=localStorage.getItem("bambusy-dashboard-layout");if(E){const k=JSON.parse(E);c(k.hidden?.length||0)}}catch{c(0)}};S(),window.addEventListener("storage",S);const A=setInterval(S,500);return()=>{window.removeEventListener("storage",S),clearInterval(A)}},[a]);const{data:u,isLoading:d}=ct({queryKey:["archiveStats"],queryFn:pe.getArchiveStats}),{data:f}=ct({queryKey:["printers"],queryFn:pe.getPrinters}),{data:m}=ct({queryKey:["archives"],queryFn:()=>pe.getArchives(void 0,void 0,1e3,0)}),{data:g}=ct({queryKey:["settings"],queryFn:pe.getSettings}),x=async S=>{i(!1),n(!0);try{const{blob:A,filename:E}=await pe.exportStats({format:S,days:90}),k=URL.createObjectURL(A),C=document.createElement("a");C.href=k,C.download=E,C.click(),URL.revokeObjectURL(k),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},y=g?.currency||"$",b=new Map(f?.map(S=>[String(S.id),S.name])||[]),v=m?.map(S=>S.created_at)||[];if(d)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 M=[{id:"quick-stats",title:"Quick Stats",component:s.jsx(Mqe,{stats:u,currency:y}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:S=>s.jsx(Nqe,{stats:u,printerMap:b,size:S}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:S=>s.jsx(Eqe,{stats:u,printerMap:b,size:S}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:S=>s.jsx(Aqe,{stats:u,size:S}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:S=>s.jsx(jqe,{size:S}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:S=>s.jsx(Tqe,{printDates:v,size:S}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:s.jsx(Cqe,{stats:u,printerMap:b}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:s.jsx(kqe,{archives:m||[],currency:y}),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(Se,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[s.jsx(_f,{className:"w-4 h-4"}),l," Hidden"]}),s.jsxs(Se,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),o(S=>S+1),t("Layout reset")},children:[s.jsx(Vf,{className:"w-4 h-4"}),"Reset Layout"]}),s.jsxs("div",{className:"relative",children:[s.jsxs(Se,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(dw,{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:()=>x("csv"),children:[s.jsx(za,{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:()=>x("xlsx"),children:[s.jsx(dw,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),s.jsx(Sqe,{widgets:M,storageKey:"bambusy-dashboard-layout",hideControls:!0},a)]})}function Rqe({plug:t,onEdit:e}){const n=tn(),{showToast:r}=$n(),[i,a]=w.useState(!1),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,f]=w.useState(!1),{data:m,isLoading:g}=ct({queryKey:["smart-plug-status",t.id],queryFn:()=>pe.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:x}=ct({queryKey:["printers"],queryFn:pe.getPrinters}),y=x?.find(R=>R.id===t.printer_id),b=ft({mutationFn:R=>pe.controlSmartPlug(t.id,R),onMutate:async R=>{await n.cancelQueries({queryKey:["smart-plug-status",t.id]});const T=n.getQueryData(["smart-plug-status",t.id]),P=R==="on"?"ON":R==="off"||m?.state==="ON"?"OFF":"ON";return n.setQueryData(["smart-plug-status",t.id],F=>({...F,state:P})),{previousStatus:T}},onError:(R,T,P)=>{P?.previousStatus&&n.setQueryData(["smart-plug-status",t.id],P.previousStatus),r(`Failed to turn ${T} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{n.invalidateQueries({queryKey:["smart-plug-status",t.id]}),n.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),v=ft({mutationFn:R=>pe.updateSmartPlug(t.id,R),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),M=ft({mutationFn:()=>pe.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),S=m?.state==="ON",A=m?.reachable??!1,E=b.isPending,C=(()=>{if(t.plug_type!=="tasmota"||!t.ip_address)return null;const R=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${R}/`:`http://${R}/`})();return s.jsxs(s.Fragment,{children:[s.jsx(Mt,{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 ${A?S?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="homeassistant"?s.jsx(R2,{className:`w-5 h-5 ${A?S?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):s.jsx(Us,{className:`w-5 h-5 ${A?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:[g?s.jsx(mt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):A?s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(Dp,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:S?"text-bambu-green":"text-bambu-gray",children:m?.state||"Unknown"})]}):s.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[s.jsx(Pg,{className:"w-4 h-4"}),s.jsx("span",{children:"Offline"})]}),C&&s.jsxs("a",{href:C,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2 py-0.5 bg-bambu-dark hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white text-xs rounded-full transition-colors",title:"Open plug admin page",children:[s.jsx(Lr,{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(tf,{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(Qr,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),s.jsxs("div",{className:"flex gap-2 mb-3",children:[s.jsxs(Se,{size:"sm",variant:S?"primary":"secondary",disabled:!A||E,onClick:()=>l(!0),className:"flex-1",children:[E?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(uu,{className:"w-4 h-4"}),"On"]}),s.jsxs(Se,{size:"sm",variant:S?"secondary":"primary",disabled:!A||E,onClick:()=>u(!0),className:"flex-1",children:[E?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(I2,{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(Dd,{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(D2,{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:R=>v.mutate({show_in_switchbar:R.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:R=>v.mutate({enabled:R.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:R=>v.mutate({auto_on:R.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:R=>v.mutate({auto_off:R.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(Gn,{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(U2,{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:R=>v.mutate({off_delay_minutes:parseInt(R.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:R=>v.mutate({off_temp_threshold:parseInt(R.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(Se,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(L2,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Se,{size:"sm",variant:"secondary",onClick:()=>a(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(an,{className:"w-4 h-4"})})]})]})]})}),i&&s.jsx(Ln,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{M.mutate(),a(!1)},onCancel:()=>a(!1)}),o&&s.jsx(Ln,{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(Ln,{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 Dqe({plug:t,onClose:e}){const n=tn(),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,g]=w.useState(t?.password||""),[x,y]=w.useState(t?.ha_entity_id||""),[b,v]=w.useState(t?.ha_power_entity||""),[M,S]=w.useState(t?.ha_energy_today_entity||""),[A,E]=w.useState(t?.ha_energy_total_entity||""),[k,C]=w.useState(""),[R,T]=w.useState(""),[P,F]=w.useState(!1),L=w.useRef(null),[X,D]=w.useState(""),[K,Y]=w.useState(!1),q=w.useRef(null),[Z,re]=w.useState(""),[oe,B]=w.useState(!1),G=w.useRef(null),[J,te]=w.useState(""),[ae,de]=w.useState(!1),fe=w.useRef(null),[Ae,ge]=w.useState(t?.printer_id||null),[Me,je]=w.useState(null),[ne,Ke]=w.useState(null),[$,z]=w.useState(t?.power_alert_enabled||!1),[W,U]=w.useState(t?.power_alert_high?.toString()||""),[V,Q]=w.useState(t?.power_alert_low?.toString()||""),[Ee,Ce]=w.useState(t?.schedule_enabled||!1),[Ne,H]=w.useState(t?.schedule_on_time||""),[O,ie]=w.useState(t?.schedule_off_time||""),[ye,_e]=w.useState(t?.show_in_switchbar||!1),[le,ke]=w.useState(!1),[Oe,Ze]=w.useState({scanned:0,total:0}),[ht,We]=w.useState([]),he=w.useRef(null),{data:rt}=ct({queryKey:["printers"],queryFn:pe.getPrinters}),{data:qe}=ct({queryKey:["smart-plugs"],queryFn:pe.getSmartPlugs}),{data:Je}=ct({queryKey:["settings"],queryFn:pe.getSettings}),ot=!!(Je?.ha_enabled&&Je?.ha_url&&Je?.ha_token);w.useEffect(()=>{const pt=setTimeout(()=>{T(k)},300);return()=>clearTimeout(pt)},[k]),w.useEffect(()=>{const pt=$t=>{L.current&&!L.current.contains($t.target)&&F(!1),q.current&&!q.current.contains($t.target)&&Y(!1),G.current&&!G.current.contains($t.target)&&B(!1),fe.current&&!fe.current.contains($t.target)&&de(!1)};return document.addEventListener("mousedown",pt),()=>document.removeEventListener("mousedown",pt)},[]);const{data:se,isLoading:$e,error:be}=ct({queryKey:["ha-entities",R],queryFn:()=>pe.getHAEntities(R||void 0),enabled:i==="homeassistant"&&ot,retry:!1,staleTime:0}),{data:Fe}=ct({queryKey:["ha-sensor-entities"],queryFn:pe.getHASensorEntities,enabled:i==="homeassistant"&&ot,retry:!1,staleTime:0});w.useEffect(()=>{const pt=$t=>{$t.key==="Escape"&&e()};return window.addEventListener("keydown",pt),()=>{window.removeEventListener("keydown",pt),he.current&&clearInterval(he.current)}},[e]);const De=async()=>{ke(!0),We([]),Ze({scanned:0,total:0}),Ke(null);try{await pe.startTasmotaScan();const pt=async()=>{try{const $t=await pe.getTasmotaScanStatus();Ze({scanned:$t.scanned,total:$t.total});const qt=await pe.getDiscoveredTasmotaDevices();We(qt),$t.running||(ke(!1),he.current&&(clearInterval(he.current),he.current=null))}catch($t){console.error("Polling error:",$t)}};await pt(),he.current=setInterval(pt,500)}catch(pt){ke(!1);const $t=pt instanceof Error?pt.message:typeof pt=="string"?pt:JSON.stringify(pt);Ke($t||"Failed to start scan")}},ve=async()=>{try{await pe.stopTasmotaScan()}catch{}ke(!1),he.current&&(clearInterval(he.current),he.current=null)},He=pt=>{u(pt.ip_address),l(pt.name),je(null)},dt=ft({mutationFn:()=>pe.testSmartPlugConnection(c,d||null,m||null),onSuccess:pt=>{je(pt),Ke(null),!o&&pt.device_name&&l(pt.device_name)},onError:pt=>{je(null),Ke(pt.message)}}),kt=ft({mutationFn:pt=>pe.createSmartPlug(pt),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:pt=>{Ke(pt.message)}}),jt=ft({mutationFn:pt=>pe.updateSmartPlug(t.id,pt),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:pt=>{Ke(pt.message)}}),Zt=rt?.filter(pt=>!qe?.some(qt=>qt.printer_id===pt.id&&qt.id!==t?.id)),Rt=pt=>{if(pt.preventDefault(),Ke(null),!o.trim()){Ke("Name is required");return}if(i==="tasmota"&&!c.trim()){Ke("IP address is required for Tasmota plugs");return}if(i==="homeassistant"&&!x){Ke("Entity is required for Home Assistant plugs");return}const $t={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"&&M||null,ha_energy_total_entity:i==="homeassistant"&&A||null,username:i==="tasmota"&&d.trim()||null,password:i==="tasmota"&&m.trim()||null,printer_id:Ae,power_alert_enabled:$,power_alert_high:W?parseFloat(W):null,power_alert_low:V?parseFloat(V):null,schedule_enabled:Ee,schedule_on_time:Ne||null,schedule_off_time:O||null,show_in_switchbar:ye};r?jt.mutate($t):kt.mutate($t)},nn=kt.isPending||jt.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:pt=>pt.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(Ut,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:Rt,className:"p-6 space-y-4 overflow-y-auto",children:[ne&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:ne}),!r&&s.jsxs("div",{className:"flex gap-2 mb-2",children:[s.jsxs("button",{type:"button",onClick:()=>{a("tasmota"),je(null),Ke(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(Us,{className:"w-4 h-4"}),"Tasmota"]}),s.jsxs("button",{type:"button",onClick:()=>{a("homeassistant"),je(null),Ke(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(R2,{className:"w-4 h-4"}),"Home Assistant"]})]}),!r&&i==="tasmota"&&s.jsxs("div",{className:"space-y-3",children:[le?s.jsxs(Se,{type:"button",variant:"secondary",onClick:ve,className:"w-full",children:[s.jsx(Ut,{className:"w-4 h-4"}),"Stop Scanning"]}):s.jsxs(Se,{type:"button",variant:"primary",onClick:De,className:"w-full",children:[s.jsx(xa,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),le&&Oe.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:[Oe.scanned," / ",Oe.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:`${Oe.scanned/Oe.total*100}%`}})})]}),ht.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",ht.length," device(s) - click to select:"]}),s.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:ht.map(pt=>s.jsxs("button",{type:"button",onClick:()=>He(pt),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(Us,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:pt.name}),s.jsx("p",{className:"text-xs text-bambu-gray",children:pt.ip_address})]})]}),pt.state&&s.jsxs("span",{className:`flex items-center gap-1 text-xs ${pt.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[s.jsx(uu,{className:"w-3 h-3"}),pt.state]})]},pt.ip_address))})]}),!le&&ht.length===0&&Oe.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:[!ot&&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..."})})]})]}),ot&&s.jsxs(s.Fragment,{children:[$e&&s.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[s.jsx(mt,{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 pt=qe?.filter(wt=>wt.ha_entity_id&&wt.id!==t?.id).map(wt=>wt.ha_entity_id)||[],$t=(se||[]).filter(wt=>!pt.includes(wt.entity_id)),qt=se?.find(wt=>wt.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(xa,{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:P?k:qt?`${qt.friendly_name} (${qt.entity_id})`:"",onChange:wt=>{C(wt.target.value),P||F(!0)},onFocus:()=>{F(!0),C("")},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&&!P&&s.jsx("button",{type:"button",onClick:()=>{y(""),C("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Ut,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),$e&&s.jsx(mt,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),P&&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:[$e&&s.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Loading..."]}),!$e&&$t.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:R?`No entities found matching "${R}"`:"No entities available"}),!$e&&$t.map(wt=>s.jsxs("button",{type:"button",onClick:()=>{y(wt.entity_id),F(!1),C(""),o||l(wt.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${wt.entity_id===x?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:wt.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[s.jsx("span",{children:wt.entity_id}),s.jsx("span",{className:wt.state==="on"?"text-bambu-green":"",children:wt.state})]})]},wt.entity_id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:R?`Searching all entities (${$t.length} found)`:`Showing switch, light, input_boolean (${$t.length} available)`})]})})(),x&&Fe&&Fe.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 pt=Fe.filter(wt=>wt.unit_of_measurement==="W"||wt.unit_of_measurement==="kW"||wt.unit_of_measurement==="mW"),$t=X?pt.filter(wt=>wt.entity_id.toLowerCase().includes(X.toLowerCase())||wt.friendly_name.toLowerCase().includes(X.toLowerCase())):pt,qt=Fe.find(wt=>wt.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(xa,{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:K?X:qt?`${qt.friendly_name} (${qt.state} ${qt.unit_of_measurement})`:"",onChange:wt=>{D(wt.target.value),K||Y(!0)},onFocus:()=>{Y(!0),D("")},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&&!K&&s.jsx("button",{type:"button",onClick:()=>{v(""),D("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Ut,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),K&&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),D("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),$t.map(wt=>s.jsxs("button",{type:"button",onClick:()=>{v(wt.entity_id),Y(!1),D("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${wt.entity_id===b?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:wt.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[wt.entity_id," • ",wt.state," ",wt.unit_of_measurement]})]},wt.entity_id)),$t.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const pt=Fe.filter(wt=>wt.unit_of_measurement==="kWh"||wt.unit_of_measurement==="Wh"||wt.unit_of_measurement==="MWh"),$t=Z?pt.filter(wt=>wt.entity_id.toLowerCase().includes(Z.toLowerCase())||wt.friendly_name.toLowerCase().includes(Z.toLowerCase())):pt,qt=Fe.find(wt=>wt.entity_id===M);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(xa,{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:oe?Z:qt?`${qt.friendly_name} (${qt.state} ${qt.unit_of_measurement})`:"",onChange:wt=>{re(wt.target.value),oe||B(!0)},onFocus:()=>{B(!0),re("")},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"}),M&&!oe&&s.jsx("button",{type:"button",onClick:()=>{S(""),re("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Ut,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),oe&&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(""),B(!1),re("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),$t.map(wt=>s.jsxs("button",{type:"button",onClick:()=>{S(wt.entity_id),B(!1),re("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${wt.entity_id===M?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:wt.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[wt.entity_id," • ",wt.state," ",wt.unit_of_measurement]})]},wt.entity_id)),$t.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const pt=Fe.filter(wt=>wt.unit_of_measurement==="kWh"||wt.unit_of_measurement==="Wh"||wt.unit_of_measurement==="MWh"),$t=J?pt.filter(wt=>wt.entity_id.toLowerCase().includes(J.toLowerCase())||wt.friendly_name.toLowerCase().includes(J.toLowerCase())):pt,qt=Fe.find(wt=>wt.entity_id===A);return s.jsxs("div",{ref:fe,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(xa,{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:ae?J:qt?`${qt.friendly_name} (${qt.state} ${qt.unit_of_measurement})`:"",onChange:wt=>{te(wt.target.value),ae||de(!0)},onFocus:()=>{de(!0),te("")},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"}),A&&!ae&&s.jsx("button",{type:"button",onClick:()=>{E(""),te("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Ut,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),ae&&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(""),de(!1),te("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),$t.map(wt=>s.jsxs("button",{type:"button",onClick:()=>{E(wt.entity_id),de(!1),te("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${wt.entity_id===A?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:wt.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[wt.entity_id," • ",wt.state," ",wt.unit_of_measurement]})]},wt.entity_id)),$t.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:pt=>{u(pt.target.value),je(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(Se,{type:"button",variant:"secondary",onClick:()=>dt.mutate(),disabled:!c.trim()||dt.isPending,children:[dt.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Dp,{className:"w-4 h-4"}),"Test"]})]})]}),i==="tasmota"&&Me&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${Me.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:Me.success?s.jsxs(s.Fragment,{children:[s.jsx(Dn,{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:[Me.device_name&&`Device: ${Me.device_name} - `,"State: ",Me.state]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Pg,{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:pt=>l(pt.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:pt=>f(pt.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:pt=>g(pt.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:Ae??"",onChange:pt=>ge(pt.target.value?Number(pt.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)"}),Zt?.map(pt=>s.jsx("option",{value:pt.id,children:pt.name},pt.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(tf,{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:$,onChange:pt=>z(pt.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:"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:W,onChange:pt=>U(pt.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:V,onChange:pt=>Q(pt.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(Gn,{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:Ee,onChange:pt=>Ce(pt.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"})]})]}),Ee&&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:Ne,onChange:pt=>H(pt.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:O,onChange:pt=>ie(pt.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(D2,{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:ye,onChange:pt=>_e(pt.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(Se,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Se,{type:"submit",disabled:nn,className:"flex-1",children:[nn?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(ds,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Vn({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 Oqe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function Lqe({provider:t,onEdit:e}){const n=tn(),[r,i]=w.useState(!1),[a,o]=w.useState(!1),[l,c]=w.useState(null),{data:u}=ct({queryKey:["printers"],queryFn:pe.getPrinters}),d=u?.find(y=>y.id===t.printer_id),f=ft({mutationFn:y=>pe.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=ft({mutationFn:()=>pe.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=ft({mutationFn:()=>pe.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(Mt,{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(tf,{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:Oqe[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-bambu-green hidden sm:inline",children:["Last: ",Jp(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(mi(t.last_error_at)?.getTime()||0)>(mi(t.last_success)?.getTime()||0))&&s.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"}),s.jsx(Vn,{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_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(fw,{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(Qr,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),s.jsx("div",{className:"mb-3",children:s.jsxs(Se,{size:"sm",variant:"secondary",disabled:g.isPending,onClick:()=>{c(null),g.mutate()},className:"w-full",children:[g.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(iD,{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(Dn,{className:"w-4 h-4"}):s.jsx(qi,{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(Dd,{className:"w-4 h-4"}),"Event Settings"]}),a?s.jsx(Jc,{className:"w-4 h-4"}):s.jsx(Ji,{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(Vn,{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(Vn,{checked:t.on_print_start,onChange:y=>f.mutate({on_print_start:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),s.jsx(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(fw,{className:"w-4 h-4 text-purple-400"}),s.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),s.jsx(Vn,{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(Gn,{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(Qr,{className:"w-4 h-4 text-emerald-400"}),s.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),s.jsx(Vn,{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(Gn,{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(Se,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(L2,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Se,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(an,{className:"w-4 h-4"})})]})]})]})}),r&&s.jsx(Ln,{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 GG=[{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 Iqe({provider:t,onClose:e}){const n=tn(),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,g]=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),[M,S]=w.useState(t?.daily_digest_time||"08:00"),[A,E]=w.useState(t?.on_print_start??!1),[k,C]=w.useState(t?.on_print_complete??!0),[R,T]=w.useState(t?.on_print_failed??!0),[P,F]=w.useState(t?.on_print_stopped??!0),[L,X]=w.useState(t?.on_print_progress??!1),[D,K]=w.useState(t?.on_printer_offline??!1),[Y,q]=w.useState(t?.on_printer_error??!1),[Z,re]=w.useState(t?.on_filament_low??!1),[oe,B]=w.useState(t?.on_maintenance_due??!1),[G,J]=w.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([U,V])=>[U,String(V)])):{}),[te,ae]=w.useState(null),[de,fe]=w.useState(null),{data:Ae}=ct({queryKey:["printers"],queryFn:pe.getPrinters});w.useEffect(()=>{const U=V=>{V.key==="Escape"&&e()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const ge=ft({mutationFn:()=>pe.testNotificationConfig({provider_type:o,config:G}),onSuccess:U=>{ae(U),fe(null)},onError:U=>{ae({success:!1,message:U.message})}}),Me=ft({mutationFn:U=>pe.createNotificationProvider(U),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:U=>{fe(U.message)}}),je=ft({mutationFn:U=>pe.updateNotificationProvider(t.id,U),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:U=>{fe(U.message)}}),ne=U=>{if(U.preventDefault(),fe(null),!i.trim()){fe("Name is required");return}const V=z(o);for(const Ee of V)if(!G[Ee.key]?.trim()){fe(`${Ee.label} is required`);return}const Q={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?M:null,on_print_start:A,on_print_complete:k,on_print_failed:R,on_print_stopped:P,on_print_progress:L,on_printer_offline:D,on_printer_error:Y,on_filament_low:Z,on_maintenance_due:oe};r?je.mutate(Q):Me.mutate(Q)},Ke=Me.isPending||je.isPending,$=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:V=>V.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:V=>V.payload_format!=="slack"}];default:return[]}},z=U=>$(U).filter(V=>V.required),W=$(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(Ut,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:ne,className:"p-6 space-y-4",children:[de&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:de}),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),J({}),ae(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:GG.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:GG.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"}),W.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:V=>{J({...G,[U.key]:V.target.value}),ae(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(V=>s.jsx("option",{value:V.value,children:V.label},V.value))}):s.jsx("input",{type:U.type,value:G[U.key]||"",onChange:V=>{J({...G,[U.key]:V.target.value}),ae(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(Se,{type:"button",variant:"secondary",onClick:()=>{ae(null),ge.mutate()},disabled:ge.isPending||!G[z(o)[0]?.key],className:"flex-1",children:[ge.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(iD,{className:"w-4 h-4"}),"Test Configuration"]})}),te&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${te.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:te.success?s.jsxs(s.Fragment,{children:[s.jsx(Dn,{className:"w-5 h-5"}),s.jsx("span",{children:te.message})]}):s.jsxs(s.Fragment,{children:[s.jsx(qi,{className:"w-5 h-5"}),s.jsx("span",{children:te.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"}),Ae?.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(Vn,{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=>g(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(Vn,{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:M,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(Vn,{checked:A,onChange:E})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Complete"}),s.jsx(Vn,{checked:k,onChange:C})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Failed"}),s.jsx(Vn,{checked:R,onChange:T})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Stopped"}),s.jsx(Vn,{checked:P,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(Vn,{checked:L,onChange:X})]})]})]}),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(Vn,{checked:D,onChange:K})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Error"}),s.jsx(Vn,{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(Vn,{checked:Z,onChange:re})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),s.jsx(Vn,{checked:oe,onChange:B})]})]})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Se,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Se,{type:"submit",disabled:Ke,className:"flex-1",children:[Ke?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(ds,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Fqe({template:t,onClose:e}){const n=tn(),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}=ct({queryKey:["template-variables"],queryFn:pe.getTemplateVariables}),g=m?.find(E=>E.event_type===t.event_type),{data:x,isLoading:y}=ct({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>pe.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});w.useEffect(()=>{const E=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[e]);const b=ft({mutationFn:E=>pe.updateNotificationTemplate(t.id,E),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:E=>{u(E.message)}}),v=ft({mutationFn:()=>pe.resetNotificationTemplate(t.id),onSuccess:E=>{a(E.title_template),l(E.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:E=>{u(E.message)}}),M=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 k=r.current;if(!k)return;const C=k.selectionStart,R=k.selectionEnd,T=o,P=T.substring(0,C),F=T.substring(R),L=P+`{${E}}`+F;l(L),setTimeout(()=>{k.focus();const X=C+E.length+2;k.setSelectionRange(X,X)},0)},A=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(Ut,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("form",{onSubmit:M,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..."})]}),g&&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:g.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(Kn,{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(_f,{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(mt,{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(Se,{type:"button",variant:"ghost",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-orange-400 hover:text-orange-300",children:[v.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(Vf,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Se,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsxs(Se,{onClick:M,disabled:b.isPending||!A,children:[b.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(ds,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const Uqe={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"},zqe={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 Bqe({onClose:t}){const e=tn(),{showToast:n}=$n(),[r,i]=w.useState(7),[a,o]=w.useState(null),[l,c]=w.useState(!1),{data:u}=ct({queryKey:["settings"],queryFn:pe.getSettings}),d=u?.time_format||"system",{data:f,isLoading:m,refetch:g,isRefetching:x}=ct({queryKey:["notification-logs",r,l],queryFn:()=>pe.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:y}=ct({queryKey:["notification-log-stats",r],queryFn:()=>pe.getNotificationLogStats(r)}),b=ft({mutationFn:()=>pe.clearNotificationLogs(30),onSuccess:M=>{n(M.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:M=>{n(`Failed to clear logs: ${M.message}`,"error")}}),v=M=>{const S=mi(M);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()+" "+lfe(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(hw,{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(Dn,{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(qi,{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:M=>i(Number(M.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:M=>c(M.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(Se,{size:"sm",variant:"secondary",onClick:()=>g(),disabled:x,children:[x?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(yr,{className:"w-4 h-4"}),"Refresh"]}),s.jsxs(Se,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-red-400 hover:text-red-300",children:[b.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(an,{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(mt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):f&&f.length>0?s.jsx("div",{className:"space-y-2",children:f.map(M=>s.jsx($qe,{log:M,isExpanded:a===M.id,onToggle:()=>o(a===M.id?null:M.id),formatDate:v,formatFullDate:S=>eg(S,d)},M.id))}):s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(hw,{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 $qe({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(Dn,{className:"w-4 h-4 text-bambu-green shrink-0"}):s.jsx(qi,{className:"w-4 h-4 text-red-400 shrink-0"}),s.jsx("span",{className:`text-xs font-medium ${zqe[t.event_type]||"text-bambu-gray"}`,children:Uqe[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(Jc,{className:"w-4 h-4 text-bambu-gray shrink-0"}):s.jsx(Ji,{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)]})]})]})]})}const T1=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:s.jsx(F2,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:s.jsx(tf,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:s.jsx(za,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:s.jsx(Us,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"external_links",labelKey:"backup.categories.externalLinks",defaultLabel:"External Links",icon:s.jsx(Y0,{className:"w-4 h-4"}),default:!0,description:"Sidebar links to external services"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:s.jsx(Ir,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:s.jsx(nD,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:s.jsx(Od,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:s.jsx(Ha,{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(ba,{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(bi,{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(Gh,{className:"w-4 h-4"}),default:!1,description:"Webhook API keys (new keys generated on import)"}];function Hqe({onClose:t,onExport:e}){const{t:n}=Tg(),[r,i]=w.useState(()=>{const x={};return T1.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={};T1.forEach(y=>{x[y.id]=!0}),i(x)},f=()=>{const x={};T1.forEach(y=>{x[y.id]=!1}),i(x)},m=Object.values(r).filter(Boolean).length,g=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(Mt,{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(Jr,{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(Ut,{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:T1.map(x=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[x.id]?"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],onChange:()=>u(x.id),disabled:l,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]?"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.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(Ha,{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(Gh,{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(Vn,{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(Cn,{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(Se,{variant:"secondary",onClick:t,disabled:l,children:n("common.cancel",{defaultValue:"Cancel"})}),s.jsx(Se,{onClick:g,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(mt,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):s.jsxs(s.Fragment,{children:[s.jsx(Jr,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const WG={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 Vqe({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),g=w.useRef(null);w.useEffect(()=>{const A=E=>{E.key==="Escape"&&r!=="restoring"&&(r==="result"&&u?.success&&n(),t())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t,n,r,u]);const x=A=>{const E=A.target.files?.[0];E&&c(E)},y=async()=>{if(l){i("restoring");try{const A=await e(l,a);d(A),i("result")}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},b=()=>{u?.success&&n(),t()},v=A=>{m(E=>{const k=new Set(E);return k.has(A)?k.delete(A):k.add(A),k})},M=u?.restored?Object.values(u.restored).reduce((A,E)=>A+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:A=>{A.target===A.currentTarget&&r!=="restoring"&&t()},children:s.jsx(Mt,{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(Dn,{className:"w-5 h-5"}):r==="result"&&!u?.success?s.jsx(Cn,{className:"w-5 h-5"}):s.jsx(bi,{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(Ut,{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:g,type:"file",accept:".json,.zip",className:"hidden",onChange:x}),s.jsx("button",{type:"button",onClick:()=>g.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(Dn,{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(bi,{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(Cn,{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(yr,{className:"w-4 h-4 text-orange-400"}):s.jsx(mw,{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(Vn,{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(Cn,{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(Se,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),s.jsxs(Se,{type:"button",onClick:y,disabled:!l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[s.jsx(bi,{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(mt,{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:M}),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(([,A])=>A>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(Dn,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),s.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,A])=>A>0).map(([A,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:WG[A]||A}),s.jsx("span",{className:"text-bambu-green font-medium",children:E})]},A)),(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(([,A])=>A>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(mw,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),s.jsx("div",{className:"space-y-1",children:Object.entries(u.skipped).filter(([,A])=>A>0).map(([A,E])=>{const k=u.skipped_details?.[A]||[],C=f.has(A);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>k.length>0&&v(A),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${k.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[s.jsxs("span",{className:"text-white flex items-center gap-2",children:[WG[A]||A,k.length>0&&(C?s.jsx(Jc,{className:"w-3 h-3"}):s.jsx(Ji,{className:"w-3 h-3"}))]}),s.jsx("span",{className:"text-yellow-500 font-medium",children:E})]}),C&&k.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:[k.slice(0,10).map((R,T)=>s.jsx("div",{children:R},T)),k.length>10&&s.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",k.length-10," more"]})]})]},A)})})]}),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(Cn,{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((A,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:A.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:A.key}),s.jsx("button",{onClick:()=>navigator.clipboard.writeText(A.key),className:"text-xs text-bambu-gray hover:text-white px-2 py-1 rounded bg-bambu-dark-tertiary",children:"Copy"})]})]},E))})]})]}),M===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(Se,{onClick:b,children:"Close"})})]})]})})})}async function Gqe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function Wqe(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 qqe(){const t=tn(),[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),[g,x]=w.useState(!1),{data:y,isLoading:b}=ct({queryKey:["spoolman-settings"],queryFn:Gqe}),{data:v,isLoading:M,refetch:S}=ct({queryKey:["spoolman-status"],queryFn:pe.getSpoolmanStatus,refetchInterval:3e4}),{data:A}=ct({queryKey:["printers"],queryFn:pe.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 K=setTimeout(()=>{E.mutate()},500);return()=>clearTimeout(K)}},[e,r,a,f]);const E=ft({mutationFn:()=>Wqe({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)}}),k=ft({mutationFn:pe.connectSpoolman,onSuccess:()=>{S()}}),C=ft({mutationFn:pe.disconnectSpoolman,onSuccess:()=>{S()}}),R=ft({mutationFn:pe.syncAllPrintersAms,onSuccess:D=>{D.success}}),T=ft({mutationFn:D=>pe.syncPrinterAms(D),onSuccess:D=>{D.success}}),P=()=>{u==="all"?R.mutate():T.mutate(u)},F=R.isPending||T.isPending,L=u==="all"?R.data:T.data,X=u==="all"?R.isSuccess:T.isSuccess;return b?s.jsxs(Mt,{children:[s.jsx(mr,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Yp,{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(mt,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):s.jsxs(Mt,{children:[s.jsx(mr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Yp,{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(mt,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&s.jsx(xs,{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(tl,{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:D=>n(D.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:D=>i(D.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:D=>o(D.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:"}),M?s.jsx(mt,{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(xs,{className:"w-4 h-4"}),"Connected"]}):s.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[s.jsx(Ut,{className:"w-4 h-4"}),"Disconnected"]})]}),s.jsx("div",{className:"flex gap-2",children:v?.connected?s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>C.mutate(),disabled:C.isPending,children:[C.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Que,{className:"w-4 h-4"}),"Disconnect"]}):s.jsxs(Se,{size:"sm",onClick:()=>k.mutate(),disabled:k.isPending||!r,children:[k.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(kl,{className:"w-4 h-4"}),"Connect"]})})]}),k.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:k.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:D=>d(D.target.value==="all"?"all":Number(D.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"}),A?.map(D=>s.jsx("option",{value:D.id,children:D.name},D.id))]}),s.jsx(Ji,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:P,disabled:F,children:[F?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(yr,{className:"w-4 h-4"}),"Sync"]})]})]}),X&&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(Cn,{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(!g),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:g?"Show less":"Show all"})]}),s.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(g?L.skipped:L.skipped.slice(0,5)).map((D,K)=>s.jsxs("li",{className:"flex items-center gap-2",children:[D.color&&s.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${D.color}`}}),s.jsx("span",{children:D.location}),s.jsxs("span",{className:"text-amber-300/60",children:["- ",D.reason]})]},K)),!g&&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((D,K)=>s.jsx("li",{children:D},K))})]})]})]})]})]})}function Kqe({link:t,onClose:e}){const n=tn(),{mode:r}=Xd(),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,g]=w.useState(!!t?.custom_icon),[x,y]=w.useState(t?.custom_icon?pe.getExternalLinkIconUrl(t.id):null),[b,v]=w.useState(null),[M,S]=w.useState(null);w.useEffect(()=>{const F=L=>{L.key==="Escape"&&e()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[e]);const A=ft({mutationFn:async F=>{const L=await pe.createExternalLink(F);return b?await pe.uploadExternalLinkIcon(L.id,b):L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{S(F.message)}}),E=ft({mutationFn:async F=>{let L=await pe.updateExternalLink(t.id,F);return b?L=await pe.uploadExternalLinkIcon(t.id,b):!m&&t?.custom_icon&&(L=await pe.deleteExternalLinkIcon(t.id)),L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{S(F.message)}}),k=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),g(!0);const D=new FileReader;D.onload=K=>{y(K.target?.result)},D.readAsDataURL(L)}},C=()=>{v(null),y(null),g(!1),a.current&&(a.current.value="")},R=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):A.mutate(L)},T=A.isPending||E.isPending,P=z2(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(P,{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(Ut,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:R,className:"p-6 space-y-4",children:[M&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:M}),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:k}),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:C,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:s.jsx(an,{className:"w-4 h-4"})})]}):s.jsxs(Se,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[s.jsx(bi,{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(nfe,{value:d,onChange:f})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Se,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Se,{type:"submit",disabled:T,className:"flex-1",children:[T?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(ds,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function Xqe(){const t=tn(),[e,n]=w.useState(!1),[r,i]=w.useState(null),[a,o]=w.useState(null),[l,c]=w.useState(null),{data:u,isLoading:d}=ct({queryKey:["external-links"],queryFn:pe.getExternalLinks}),f=ft({mutationFn:M=>pe.deleteExternalLink(M),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=ft({mutationFn:M=>pe.reorderExternalLinks(M),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),g=(M,S)=>{c(S),M.dataTransfer.effectAllowed="move"},x=M=>{M.preventDefault(),M.dataTransfer.dropEffect="move"},y=(M,S)=>{if(M.preventDefault(),l===null||l===S||!u)return;const A=u.map(R=>R.id),E=A.indexOf(l),k=A.indexOf(S);if(E===-1||k===-1)return;const C=[...A];C.splice(E,1),C.splice(k,0,l),m.mutate(C),c(null)},b=M=>{o(M)},v=()=>{a&&(f.mutate(a.id),o(null))};return s.jsxs(s.Fragment,{children:[s.jsxs(Mt,{children:[s.jsx(mr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(kl,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),s.jsxs(Se,{size:"sm",onClick:()=>n(!0),children:[s.jsx(Kn,{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(mt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?s.jsx("div",{className:"space-y-2",children:u.map(M=>{const S=z2(M.icon);return s.jsxs("div",{draggable:!0,onDragStart:A=>g(A,M.id),onDragOver:x,onDrop:A=>y(A,M.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${l===M.id?"opacity-50":""}`,children:[s.jsx(Qp,{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:M.name}),s.jsx(Lr,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),s.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:M.url})]}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.jsx("button",{onClick:()=>i(M),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Edit",children:s.jsx(Ga,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>b(M),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(an,{className:"w-4 h-4"})})]})]},M.id)})}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(kl,{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(Kqe,{link:r,onClose:()=>{n(!1),i(null)}}),a&&s.jsx(Ln,{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 Yqe(){const t=tn(),{showToast:e}=$n(),[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,g]=w.useState(null),{data:x,isLoading:y}=ct({queryKey:["virtual-printer-settings"],queryFn:R1.getSettings,refetchInterval:1e4}),{data:b}=ct({queryKey:["virtual-printer-models"],queryFn:R1.getModels});w.useEffect(()=>{if(x){r(x.enabled);let R=x.mode==="queue"?"review":x.mode;R!=="immediate"&&R!=="review"&&R!=="print_queue"&&(R="immediate"),l(R),u(x.model)}},[x]);const v=ft({mutationFn:R=>R1.updateSettings(R),onSuccess:()=>{t.invalidateQueries({queryKey:["virtual-printer-settings"]}),e("Virtual printer settings updated"),g(null)},onError:R=>{if(e(R.message||"Failed to update settings","error"),x){r(x.enabled);const T=x.mode==="queue"?"review":x.mode;l(T==="print_queue"||T==="review"?T:"immediate"),u(x.model)}g(null)}}),M=()=>{const R=!n;if(R&&!i&&!x?.access_code_set){e("Please set an access code first","error");return}r(R),g("toggle"),v.mutate({enabled:R,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}g("accessCode"),v.mutate({access_code:i}),a("")},A=R=>{l(R),g("mode"),v.mutate({mode:R})},E=R=>{u(R),g("model"),v.mutate({model:R})};if(y)return s.jsx(Mt,{children:s.jsx(Et,{className:"py-8 flex justify-center",children:s.jsx(mt,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const k=x?.status,C=k?.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(Mt,{children:[s.jsx(mr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ir,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Virtual Printer"})]}),k&&s.jsxs("div",{className:`flex items-center gap-2 text-sm ${C?"text-green-400":"text-bambu-gray"}`,children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${C?"bg-green-400 animate-pulse":"bg-gray-500"}`}),C?"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:C?'Visible as "Bambuddy" in slicer discovery':"Not visible to slicers"})]}),s.jsx("button",{onClick:M,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:R=>E(R.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(([,R],[,T])=>R.localeCompare(T)).map(([R,T])=>s.jsx("option",{value:R,children:T},R))}),s.jsx(Ji,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),n&&C&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[s.jsx(tl,{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(xs,{className:"w-4 h-4"}),"Access code is set"]}):s.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[s.jsx(Cn,{className:"w-4 h-4"}),"No access code set - required to enable"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx("input",{type:d?"text":"password",value:i,onChange:R=>a(R.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(T2,{className:"w-4 h-4"}):s.jsx(_f,{className:"w-4 h-4"})})]}),s.jsx(Se,{onClick:S,disabled:!i||m==="accessCode",variant:"primary",children:m==="accessCode"?s.jsx(mt,{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:()=>A("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:()=>A("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:()=>A("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(Mt,{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(Cn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"text-white font-medium mb-2",children:"Setup Required"}),s.jsx("p",{className:"text-bambu-gray mb-3",children:"The virtual printer feature requires additional system configuration before it will work. This includes port forwarding, firewall rules, and platform-specific settings."}),s.jsxs("a",{href:"https://wiki.bambuddy.cool/features/virtual-printer/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-yellow-500/20 border border-yellow-500/50 rounded-md text-yellow-400 hover:bg-yellow-500/30 transition-colors",children:[s.jsx(Lr,{className:"w-4 h-4"}),"Read the setup guide before enabling"]})]})]})})}),s.jsx(Mt,{children:s.jsx(Et,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(tl,{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'})]})]})]})})}),k&&C&&s.jsxs(Mt,{children:[s.jsx(mr,{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:k.name})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Model"}),s.jsx("div",{className:"text-white",children:k.model_name||k.model})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Serial Number"}),s.jsx("div",{className:"text-white font-mono",children:k.serial})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Mode"}),s.jsx("div",{className:"text-white capitalize",children:k.mode})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Pending Files"}),s.jsx("div",{className:"text-white",children:k.pending_files})]})]})})]})]})]})}const Qqe={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 Zqe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function Tb(t,e,n=0){if(n>5)return"...";if(e.$ref)return Tb(t,Zqe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const a=Tb(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?[Tb(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,a]of Object.entries(e.properties))r[i]=Tb(t,a,n+1);return r}return{};default:return null}}function Jqe({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),[g,x]=w.useState(!1),[y,b]=w.useState(!1);w.useEffect(()=>{if(a&&n.parameters){const R={};for(const T of n.parameters)T.schema?.default!==void 0&&(R[T.name]=String(T.schema.default));c(T=>({...R,...T}))}},[a,n.parameters]),w.useEffect(()=>{if(a&&n.requestBody?.content?.["application/json"]?.schema&&!u){const R=n.requestBody.content["application/json"].schema,T=Tb(r,R);d(JSON.stringify(T,null,2))}},[a,n.requestBody,r,u]);const M=(()=>{const R=[];for(const T of n.parameters||[])if(T.in==="path"||T.required){const P=l[T.name];(P===void 0||P==="")&&R.push(T.name)}return R})(),S=async()=>{if(M.length>0){m({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${M.join(", ")}`,duration:0});return}x(!0),m(null);try{let R=t;const T=new URLSearchParams;for(const oe of n.parameters||[]){const B=l[oe.name];B!==void 0&&B!==""&&(oe.in==="path"?R=R.replace(`{${oe.name}}`,encodeURIComponent(B)):oe.in==="query"&&T.append(oe.name,B))}const P=T.toString(),F=`${R}${P?`?${P}`:""}`,L={"Content-Type":"application/json"};i&&(L["X-API-Key"]=i);const X={method:e.toUpperCase(),headers:L};["post","put","patch"].includes(e)&&u&&(X.body=u);const D=performance.now(),K=await fetch(F,X),Y=Math.round(performance.now()-D),q={};K.headers.forEach((oe,B)=>{q[B]=oe});let Z;K.headers.get("content-type")?.includes("application/json")?Z=await K.json():Z=await K.text(),m({status:K.status,statusText:K.statusText,headers:q,body:Z,duration:Y})}catch(R){m({status:0,statusText:"Network Error",headers:{},body:R instanceof Error?R.message:"Unknown error",duration:0})}finally{x(!1)}},A=async()=>{if(f){const R=typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2);try{await navigator.clipboard.writeText(R),b(!0),setTimeout(()=>b(!1),2e3)}catch{const T=document.createElement("textarea");T.value=R,T.style.position="fixed",T.style.left="-999999px",document.body.appendChild(T),T.select(),document.execCommand("copy"),document.body.removeChild(T),b(!0),setTimeout(()=>b(!1),2e3)}}},E=(n.parameters||[]).filter(R=>R.in==="path"),k=(n.parameters||[]).filter(R=>R.in==="query"),C=["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(Ji,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):s.jsx(Gs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${Qqe[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(R=>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:[R.name,R.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),s.jsx("input",{type:"text",value:l[R.name]||"",onChange:T=>c(P=>({...P,[R.name]:T.target.value})),placeholder:R.description||R.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},R.name))})]}),k.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:k.map(R=>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:[R.name,R.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),R.schema?.enum?s.jsxs("select",{value:l[R.name]||"",onChange:T=>c(P=>({...P,[R.name]:T.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 --"}),R.schema.enum.map(T=>s.jsx("option",{value:T,children:T},T))]}):s.jsx("input",{type:"text",value:l[R.name]||"",onChange:T=>c(P=>({...P,[R.name]:T.target.value})),placeholder:R.description||R.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},R.name))})]}),C&&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:R=>d(R.target.value),rows:8,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono focus:border-bambu-green focus:outline-none resize-y",placeholder:"JSON request body..."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Se,{onClick:S,disabled:g,children:[g?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(rl,{className:"w-4 h-4"}),"Execute"]}),M.length>0&&s.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[s.jsx(ea,{className:"w-3 h-3"}),"Fill in: ",M.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(Se,{variant:"secondary",size:"sm",onClick:A,children:y?s.jsx(Dn,{className:"w-3 h-3 text-green-400"}):s.jsx(Jo,{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 eKe({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 M=await v.json();n(M)}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(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(a||!e)return s.jsx(Mt,{children:s.jsx(Et,{className:"py-8",children:s.jsxs("div",{className:"text-center text-red-400",children:[s.jsx(ea,{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[M,S]of Object.entries(v)){if(M==="parameters")continue;const A=S.tags||["Other"];for(const E of A)f[E]||(f[E]=[]),f[E].push({path:b,method:M,spec:S})}const m=Object.entries(f).map(([b,v])=>{if(!u)return{tag:b,endpoints:v};const M=v.filter(({path:S,method:A,spec:E})=>{const k=u.toLowerCase();return S.toLowerCase().includes(k)||A.toLowerCase().includes(k)||(E.summary?.toLowerCase()||"").includes(k)||(E.description?.toLowerCase()||"").includes(k)});return{tag:b,endpoints:M}}).filter(({endpoints:b})=>b.length>0).sort((b,v)=>b.tag.localeCompare(v.tag)),g=b=>{c(v=>{const M=new Set(v);return M.has(b)?M.delete(b):M.add(b),M})},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(Se,{variant:"secondary",size:"sm",onClick:x,children:"Expand All"}),s.jsx(Se,{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(Lr,{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(Mt,{children:[s.jsx("button",{onClick:()=>g(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(Ji,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(Gs,{className:"w-5 h-5 text-bambu-gray"}),s.jsx("h3",{className:"text-base font-semibold text-white capitalize",children: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:M,method:S,spec:A})=>s.jsx(Jqe,{path:M,method:S,spec:A,schema:e,apiKey:t},`${S}-${M}`))})]},b))})]})}const tKe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users"];function nKe(){const t=tn(),e=ol(),[n,r]=wW(),{t:i,i18n:a}=Tg(),{showToast:o,showPersistentToast:l,dismissToast:c}=$n(),{authEnabled:u,user:d,refreshAuth:f}=Yd(),{mode:m,darkStyle:g,darkBackground:x,darkAccent:y,lightStyle:b,lightBackground:v,lightAccent:M,setDarkStyle:S,setDarkBackground:A,setDarkAccent:E,setLightStyle:k,setLightBackground:C,setLightAccent:R}=Xd(),[T,P]=w.useState(null),[F,L]=w.useState(!1),[X,D]=w.useState(null),[K,Y]=w.useState(!1),[q,Z]=w.useState(null),[re,oe]=w.useState(null),[B,G]=w.useState(!1),[J,te]=w.useState(dq()),ae=n.get("tab"),de=ae&&tKe.includes(ae)?ae:"general",[fe,Ae]=w.useState(de),ge=xe=>{Ae(xe),xe==="general"?n.delete("tab"):n.set("tab",xe),r(n,{replace:!0})},[Me,je]=w.useState(!1),[ne,Ke]=w.useState(""),[$,z]=w.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[W,U]=w.useState(null),[V,Q]=w.useState(null),[Ee,Ce]=w.useState(""),[Ne,H]=w.useState(!1),[O,ie]=w.useState(!1),[ye,_e]=w.useState(null),[le,ke]=w.useState(!1),[Oe,Ze]=w.useState(!1),[ht,We]=w.useState(!1),[he,rt]=w.useState(!1),[qe,Je]=w.useState(!1),[ot,se]=w.useState(null),[$e,be]=w.useState(!1),Fe=xe=>{te(xe),sfe(xe)},De=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:ve,isLoading:He}=ct({queryKey:["settings"],queryFn:pe.getSettings}),{data:dt,isLoading:kt}=ct({queryKey:["smart-plugs"],queryFn:pe.getSmartPlugs}),{data:jt,isLoading:Zt}=ct({queryKey:["smart-plugs-energy",dt?.map(xe=>xe.id)],queryFn:async()=>{if(!dt||dt.length===0)return null;const xe=await Promise.all(dt.filter(Gt=>Gt.enabled).map(async Gt=>{try{const Wt=await pe.getSmartPlugStatus(Gt.id);return{plug:Gt,status:Wt}}catch{return{plug:Gt,status:null}}}));let st=0,Ht=0,It=0,on=0,un=0;for(const{status:Gt}of xe)Gt?.reachable&&Gt.energy&&(un++,Gt.energy.power!=null&&(st+=Gt.energy.power),Gt.energy.today!=null&&(Ht+=Gt.energy.today),Gt.energy.yesterday!=null&&(It+=Gt.energy.yesterday),Gt.energy.total!=null&&(on+=Gt.energy.total));return{totalPower:st,totalToday:Ht,totalYesterday:It,totalLifetime:on,reachableCount:un,totalPlugs:dt.filter(Gt=>Gt.enabled).length}},enabled:fe==="plugs"&&!!dt&&dt.length>0,refetchInterval:fe==="plugs"?1e4:!1}),{data:Rt,isLoading:nn}=ct({queryKey:["notification-providers"],queryFn:pe.getNotificationProviders}),{data:pt,isLoading:$t}=ct({queryKey:["api-keys"],queryFn:pe.getAPIKeys}),qt=ft({mutationFn:xe=>pe.createAPIKey(xe),onSuccess:xe=>{U(xe.key||null),je(!1),Ke(""),t.invalidateQueries({queryKey:["api-keys"]}),o("API key created")},onError:xe=>{o(`Failed to create API key: ${xe.message}`,"error")}}),wt=ft({mutationFn:xe=>pe.deleteAPIKey(xe),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o("API key deleted")},onError:xe=>{o(`Failed to delete API key: ${xe.message}`,"error")}}),{data:_r}=ct({queryKey:["printers"],queryFn:pe.getPrinters}),{data:$r,isLoading:Tr}=ct({queryKey:["notification-templates"],queryFn:pe.getNotificationTemplates}),{data:hr}=ct({queryKey:["virtual-printer-settings"],queryFn:R1.getSettings,refetchInterval:1e4}),yt=hr?.status?.running??!1,{data:en}=ct({queryKey:["ffmpeg-status"],queryFn:pe.checkFfmpeg}),{data:wn}=ct({queryKey:["version"],queryFn:pe.getVersion}),{data:ue,refetch:Be,isRefetching:Ye}=ct({queryKey:["updateCheck"],queryFn:pe.checkForUpdates,staleTime:300*1e3}),{data:Xe,refetch:Qe}=ct({queryKey:["updateStatus"],queryFn:pe.getUpdateStatus,refetchInterval:xe=>{const st=xe.state.data;return st?.status==="downloading"||st?.status==="installing"?1e3:!1}}),{data:At}=ct({queryKey:["mqtt-status"],queryFn:pe.getMQTTStatus,refetchInterval:fe==="network"?5e3:!1}),ce=ft({mutationFn:pe.applyUpdate,onSuccess:xe=>{xe.is_docker?o(xe.message,"error"):Qe()}}),[we,Ie]=w.useState(null),Le=ft({mutationFn:pe.testAllNotificationProviders,onSuccess:xe=>{Ie(xe),t.invalidateQueries({queryKey:["notification-providers"]}),xe.failed===0?o(`All ${xe.tested} providers tested successfully!`,"success"):o(`${xe.success}/${xe.tested} providers succeeded`,xe.failed>0?"error":"success")},onError:xe=>{o(`Failed to test providers: ${xe.message}`,"error")}}),Re=ft({mutationFn:async xe=>{if(!dt)return{success:0,failed:0};const st=dt.filter(It=>It.enabled),Ht=await Promise.all(st.map(async It=>{try{return await pe.controlSmartPlug(It.id,xe),{success:!0}}catch{return{success:!1}}}));return{success:Ht.filter(It=>It.success).length,failed:Ht.filter(It=>!It.success).length}},onSuccess:(xe,st)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),xe.failed===0?o(`All ${xe.success} plugs turned ${st}`,"success"):o(`${xe.success} plugs turned ${st}, ${xe.failed} failed`,"error")},onError:xe=>{o(`Failed: ${xe.message}`,"error")}}),ut=w.useRef(null),_t=w.useRef(!1),Tt=w.useRef(!0);w.useEffect(()=>{if(ve&&!T){const xe={...ve,external_url:ve.external_url||window.location.origin};P(xe),setTimeout(()=>{Tt.current=!1},100)}},[ve,T]);const St=ft({mutationFn:pe.updateSettings,onSuccess:xe=>{t.setQueryData(["settings"],xe),P(xe),t.invalidateQueries({queryKey:["archiveStats"]}),o("Settings saved","success")},onError:xe=>{o(`Failed to save: ${xe.message}`,"error")},onSettled:()=>{_t.current=!1}});w.useEffect(()=>{if(!(Tt.current||!T||!ve||!(ve.auto_archive!==T.auto_archive||ve.save_thumbnails!==T.save_thumbnails||ve.capture_finish_photo!==T.capture_finish_photo||ve.default_filament_cost!==T.default_filament_cost||ve.currency!==T.currency||ve.energy_cost_per_kwh!==T.energy_cost_per_kwh||ve.energy_tracking_mode!==T.energy_tracking_mode||ve.check_updates!==T.check_updates||ve.notification_language!==T.notification_language||ve.telemetry_enabled!==T.telemetry_enabled||ve.ams_humidity_good!==T.ams_humidity_good||ve.ams_humidity_fair!==T.ams_humidity_fair||ve.ams_temp_good!==T.ams_temp_good||ve.ams_temp_fair!==T.ams_temp_fair||ve.ams_history_retention_days!==T.ams_history_retention_days||ve.per_printer_mapping_expanded!==T.per_printer_mapping_expanded||ve.date_format!==T.date_format||ve.time_format!==T.time_format||ve.default_printer_id!==T.default_printer_id||ve.ftp_retry_enabled!==T.ftp_retry_enabled||ve.ftp_retry_count!==T.ftp_retry_count||ve.ftp_retry_delay!==T.ftp_retry_delay||ve.ftp_timeout!==T.ftp_timeout||ve.mqtt_enabled!==T.mqtt_enabled||ve.mqtt_broker!==T.mqtt_broker||ve.mqtt_port!==T.mqtt_port||ve.mqtt_username!==T.mqtt_username||ve.mqtt_password!==T.mqtt_password||ve.mqtt_topic_prefix!==T.mqtt_topic_prefix||ve.mqtt_use_tls!==T.mqtt_use_tls||ve.external_url!==T.external_url||ve.ha_enabled!==T.ha_enabled||ve.ha_url!==T.ha_url||ve.ha_token!==T.ha_token||(ve.library_archive_mode??"ask")!==(T.library_archive_mode??"ask")||Number(ve.library_disk_warning_gb??5)!==Number(T.library_disk_warning_gb??5)||(ve.camera_view_mode??"window")!==(T.camera_view_mode??"window")))&&!_t.current)return ut.current&&clearTimeout(ut.current),ut.current=setTimeout(()=>{if(_t.current)return;_t.current=!0;const st={auto_archive:T.auto_archive,save_thumbnails:T.save_thumbnails,capture_finish_photo:T.capture_finish_photo,default_filament_cost:T.default_filament_cost,currency:T.currency,energy_cost_per_kwh:T.energy_cost_per_kwh,energy_tracking_mode:T.energy_tracking_mode,check_updates:T.check_updates,notification_language:T.notification_language,telemetry_enabled:T.telemetry_enabled,ams_humidity_good:T.ams_humidity_good,ams_humidity_fair:T.ams_humidity_fair,ams_temp_good:T.ams_temp_good,ams_temp_fair:T.ams_temp_fair,ams_history_retention_days:T.ams_history_retention_days,per_printer_mapping_expanded:T.per_printer_mapping_expanded,date_format:T.date_format,time_format:T.time_format,default_printer_id:T.default_printer_id,ftp_retry_enabled:T.ftp_retry_enabled,ftp_retry_count:T.ftp_retry_count,ftp_retry_delay:T.ftp_retry_delay,ftp_timeout:T.ftp_timeout,mqtt_enabled:T.mqtt_enabled,mqtt_broker:T.mqtt_broker,mqtt_port:T.mqtt_port,mqtt_username:T.mqtt_username,mqtt_password:T.mqtt_password,mqtt_topic_prefix:T.mqtt_topic_prefix,mqtt_use_tls:T.mqtt_use_tls,external_url:T.external_url,ha_enabled:T.ha_enabled,ha_url:T.ha_url,ha_token:T.ha_token,library_archive_mode:T.library_archive_mode,library_disk_warning_gb:T.library_disk_warning_gb,camera_view_mode:T.camera_view_mode};St.mutate(st)},500),()=>{ut.current&&clearTimeout(ut.current)}},[T,ve,St]);const vt=w.useCallback((xe,st)=>{P(Ht=>Ht?{...Ht,[xe]:st}:null)},[]);return He||!T?s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(mt,{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:()=>ge("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${fe==="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:()=>ge("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${fe==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Us,{className:"w-4 h-4"}),"Smart Plugs",dt&&dt.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:dt.length})]}),s.jsxs("button",{onClick:()=>ge("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${fe==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(tf,{className:"w-4 h-4"}),"Notifications",Rt&&Rt.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Rt.length})]}),s.jsxs("button",{onClick:()=>ge("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${fe==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(qce,{className:"w-4 h-4"}),"Filament"]}),s.jsxs("button",{onClick:()=>ge("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${fe==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Dp,{className:"w-4 h-4"}),"Network",s.jsx("span",{className:`w-2 h-2 rounded-full ${At?.enabled?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>ge("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${fe==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Gh,{className:"w-4 h-4"}),"API Keys",pt&&pt.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:pt.length})]}),s.jsxs("button",{onClick:()=>ge("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${fe==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Ir,{className:"w-4 h-4"}),"Virtual Printer",s.jsx("span",{className:`w-2 h-2 rounded-full ${yt?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>ge("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${fe==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Wh,{className:"w-4 h-4"}),"Users",u&&s.jsx("span",{className:`w-2 h-2 rounded-full ${u?"bg-green-400":"bg-gray-500"}`})]})]}),fe==="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(Mt,{children:[s.jsx(mr,{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(Md,{className:"w-4 h-4 inline mr-1"}),i("settings.language")]}),s.jsx("select",{value:a.language,onChange:xe=>a.changeLanguage(xe.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:GU.map(xe=>s.jsxs("option",{value:xe.code,children:[xe.nativeName," (",xe.name,")"]},xe.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:J,onChange:xe=>Fe(xe.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:s0.map(xe=>s.jsx("option",{value:xe.to,children:i(xe.labelKey)},xe.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:T.date_format||"system",onChange:xe=>vt("date_format",xe.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:T.time_format||"system",onChange:xe=>vt("time_format",xe.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:T.default_printer_id??"",onChange:xe=>vt("default_printer_id",xe.target.value?Number(xe.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)"}),_r?.map(xe=>s.jsx("option",{value:xe.id,children:xe.name},xe.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(Se,{variant:"secondary",size:"sm",onClick:De,children:[s.jsx(Vf,{className:"w-4 h-4"}),"Reset"]})]})]})]}),s.jsxs(Mt,{children:[s.jsx(mr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(nD,{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 ${m==="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",m==="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:x,onChange:xe=>{A(xe.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:y,onChange:xe=>{E(xe.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:g,onChange:xe=>{S(xe.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 ${m==="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",m==="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:v,onChange:xe=>{C(xe.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:M,onChange:xe=>{R(xe.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:b,onChange:xe=>{k(xe.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(Mt,{children:[s.jsx(mr,{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:T.auto_archive,onChange:xe=>vt("auto_archive",xe.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:T.save_thumbnails,onChange:xe=>vt("save_thumbnails",xe.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:T.capture_finish_photo,onChange:xe=>vt("capture_finish_photo",xe.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"})]})]}),T.capture_finish_photo&&en&&!en.installed&&s.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[s.jsx(Cn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),s.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",s.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",s.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]})]}),s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[s.jsxs(Mt,{children:[s.jsx(mr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(sD,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),s.jsx(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:T.camera_view_mode??"window",onChange:xe=>vt("camera_view_mode",xe.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:T.camera_view_mode==="embedded"?"Camera opens in a resizable overlay on the main screen":"Camera opens in a separate browser window"})]})})]}),s.jsxs(Mt,{children:[s.jsx(mr,{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:T.default_filament_cost,onChange:xe=>vt("default_filament_cost",parseFloat(xe.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:T.currency,onChange:xe=>vt("currency",xe.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:T.energy_cost_per_kwh,onChange:xe=>vt("energy_cost_per_kwh",parseFloat(xe.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:T.energy_tracking_mode||"total",onChange:xe=>vt("energy_tracking_mode",xe.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:T.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),s.jsxs(Mt,{children:[s.jsx(mr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(za,{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:T.library_archive_mode??"ask",onChange:xe=>vt("library_archive_mode",xe.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:T.library_disk_warning_gb??5,onChange:xe=>vt("library_disk_warning_gb",parseFloat(xe.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(Xqe,{}),s.jsxs(Mt,{children:[s.jsx(mr,{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:T.check_updates,onChange:xe=>vt("check_updates",xe.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.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-white",children:i("settings.telemetry")}),s.jsxs("button",{onClick:()=>We(!0),className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs bg-bambu-dark rounded-full text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary transition-colors",children:[s.jsx(tl,{className:"w-3 h-3"}),i("settings.telemetryLearnMore")]})]}),s.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.telemetryDescription")})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.telemetry_enabled,onChange:xe=>vt("telemetry_enabled",xe.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",wn?.version||"..."]})]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>Be(),disabled:Ye,children:[Ye?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(yr,{className:"w-4 h-4"}),"Check now"]})]}),ue?.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",ue.latest_version]}),ue.release_name&&ue.release_name!==ue.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:ue.release_name})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[ue.release_notes&&s.jsx("button",{onClick:()=>rt(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),ue.release_url&&s.jsx("a",{href:ue.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:s.jsx(Lr,{className:"w-4 h-4"})})]})]}),Xe?.status==="downloading"||Xe?.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(mt,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{children:Xe.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:`${Xe.progress}%`}})})]}):Xe?.status==="complete"?s.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:Xe.message}):Xe?.status==="error"?s.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:Xe.error||Xe.message}):ue?.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(Se,{className:"mt-3",onClick:()=>ce.mutate(),disabled:ce.isPending,children:[ce.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Jr,{className:"w-4 h-4"}),"Install Update"]})]}):ue?.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: ",ue.error]}):ue&&!ue.update_available?s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),s.jsxs(Mt,{children:[s.jsx(mr,{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:"Backup Data"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Export settings, providers, printers, and more"})]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>ke(!0),children:[s.jsx(Jr,{className:"w-4 h-4"}),"Export"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Restore Backup"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Import settings from a backup file with duplicate handling options"})]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>Ze(!0),children:[s.jsx(bi,{className:"w-4 h-4"}),"Restore"]})]}),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",{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(Se,{variant:"secondary",size:"sm",onClick:()=>H(!0),children:[s.jsx(an,{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(Se,{variant:"secondary",size:"sm",onClick:()=>ie(!0),children:[s.jsx(an,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),fe==="network"&&T&&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(Mt,{children:[s.jsx(mr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Md,{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:T.external_url??"",onChange:xe=>vt("external_url",xe.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(Mt,{children:[s.jsx(mr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(yr,{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:T.ftp_retry_enabled??!0,onChange:xe=>vt("ftp_retry_enabled",xe.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"})]})]}),T.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:T.ftp_retry_count??3,onChange:xe=>vt("ftp_retry_count",Math.min(10,Math.max(1,parseInt(xe.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:T.ftp_retry_delay??2,onChange:xe=>vt("ftp_retry_delay",Math.min(30,Math.max(1,parseInt(xe.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:T.ftp_timeout??30,onChange:xe=>vt("ftp_timeout",Math.min(120,Math.max(10,parseInt(xe.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(Mt,{children:[s.jsx(mr,{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(R2,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),T.ha_enabled&&ot&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${ot.success?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${ot.success?"text-green-400":"text-red-400"}`,children:ot.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:T.ha_enabled??!1,onChange:xe=>vt("ha_enabled",xe.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"})]})]}),T.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:T.ha_url??"",onChange:xe=>vt("ha_url",xe.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:T.ha_token??"",onChange:xe=>vt("ha_token",xe.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"})]}),T.ha_url&&T.ha_token&&s.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:s.jsxs(Se,{variant:"secondary",size:"sm",disabled:$e,onClick:async()=>{be(!0),se(null);try{const xe=await pe.testHAConnection(T.ha_url,T.ha_token);se(xe)}catch(xe){se({success:!1,message:null,error:xe instanceof Error?xe.message:"Unknown error"})}finally{be(!1)}},children:[$e?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Dp,{className:"w-4 h-4"}),"Test Connection"]})})]})]})]}),s.jsxs(Mt,{children:[s.jsx(mr,{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(Dp,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),At?.enabled&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${At.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${At.connected?"text-green-400":"text-red-400"}`,children:At.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:T.mqtt_enabled??!1,onChange:xe=>vt("mqtt_enabled",xe.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"})]})]}),T.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:T.mqtt_broker??"",onChange:xe=>vt("mqtt_broker",xe.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:T.mqtt_port??1883,onChange:xe=>vt("mqtt_port",Math.min(65535,Math.max(1,parseInt(xe.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:T.mqtt_use_tls??!1,onChange:xe=>{const st=xe.target.checked;vt("mqtt_use_tls",st);const Ht=T.mqtt_port??1883;st&&Ht===1883?vt("mqtt_port",8883):!st&&Ht===8883&&vt("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:T.mqtt_username??"",onChange:xe=>vt("mqtt_username",xe.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:T.mqtt_password??"",onChange:xe=>vt("mqtt_password",xe.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:T.mqtt_topic_prefix??"bambuddy",onChange:xe=>vt("mqtt_topic_prefix",xe.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: ",T.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),At&&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 ${At.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:"text-bambu-gray",children:At.connected?s.jsxs(s.Fragment,{children:["Connected to ",s.jsxs("span",{className:"text-white",children:[At.broker,":",At.port]})]}):"Not connected"})]})})]})]})]})]})]}),ot&&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:[ot.success?s.jsx(Dn,{className:"w-8 h-8 text-green-400"}):s.jsx(qi,{className:"w-8 h-8 text-red-400"}),s.jsx("h3",{className:"text-lg font-medium text-white",children:ot.success?"Connection Successful":"Connection Failed"})]}),s.jsx("p",{className:"text-bambu-gray mb-6",children:ot.success?ot.message||"Successfully connected to Home Assistant.":ot.error||"Failed to connect to Home Assistant."}),s.jsx("div",{className:"flex justify-end",children:s.jsx(Se,{variant:"primary",onClick:()=>se(null),children:"OK"})})]})}),fe==="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(Us,{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:[dt&&dt.filter(xe=>xe.enabled).length>1&&s.jsxs(s.Fragment,{children:[s.jsxs(Se,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>_e("on"),disabled:Re.isPending,title:"Turn all plugs on",children:[Re.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(uu,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),s.jsxs(Se,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>_e("off"),disabled:Re.isPending,title:"Turn all plugs off",children:[Re.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(I2,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),s.jsxs(Se,{className:"whitespace-nowrap",onClick:()=>{D(null),L(!0)},children:[s.jsx(Kn,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),dt&&dt.length>0&&s.jsxs(Mt,{className:"mb-6",children:[s.jsx(mr,{children:s.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[s.jsx(Mf,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",Zt&&s.jsx(mt,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),s.jsx(Et,{children:jt?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(Mf,{className:"w-3 h-3"}),"Current Power"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[jt.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:[jt.reachableCount,"/",jt.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(Qr,{className:"w-3 h-3"}),"Today"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[jt.totalToday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),T&&T.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(jt.totalToday*T.energy_cost_per_kwh).toFixed(2)," ",T.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(aq,{className:"w-3 h-3"}),"Yesterday"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[jt.totalYesterday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),T&&T.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(jt.totalYesterday*T.energy_cost_per_kwh).toFixed(2)," ",T.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(Uj,{className:"w-3 h-3"}),"Total"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[jt.totalLifetime.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),T&&T.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(jt.totalLifetime*T.energy_cost_per_kwh).toFixed(2)," ",T.currency]})]})]}):Zt?null:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),kt?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):dt&&dt.length>0?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:dt.map(xe=>s.jsx(Rqe,{plug:xe,onEdit:st=>{D(st),L(!0)}},xe.id))}):s.jsx(Mt,{children:s.jsx(Et,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Us,{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(Se,{onClick:()=>{D(null),L(!0)},children:[s.jsx(Kn,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),fe==="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(tf,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Se,{size:"sm",variant:"secondary",onClick:()=>G(!0),children:[s.jsx(hw,{className:"w-4 h-4"}),"Log"]}),Rt&&Rt.length>0&&s.jsxs(Se,{size:"sm",variant:"secondary",onClick:()=>{Ie(null),Le.mutate()},disabled:Le.isPending,children:[Le.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(iD,{className:"w-4 h-4"}),"Test All"]}),s.jsxs(Se,{size:"sm",onClick:()=>{Z(null),Y(!0)},children:[s.jsx(Kn,{className:"w-4 h-4"}),"Add"]})]})]}),s.jsx(Mt,{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:T.notification_language||"en",onChange:xe=>vt("notification_language",xe.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:GU.map(xe=>s.jsx("option",{value:xe.code,children:xe.nativeName},xe.code))})]})})}),we&&s.jsx(Mt,{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:()=>Ie(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(Dn,{className:"w-4 h-4"}),we.success," passed"]}),we.failed>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(qi,{className:"w-4 h-4"}),we.failed," failed"]})]}),we.results.filter(xe=>!xe.success).length>0&&s.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:we.results.filter(xe=>!xe.success).map(xe=>s.jsxs("div",{className:"text-xs text-red-400",children:[s.jsxs("span",{className:"font-medium",children:[xe.provider_name,":"]})," ",xe.message]},xe.provider_id))})]})}),nn?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(mt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Rt&&Rt.length>0?s.jsx("div",{className:"space-y-3",children:Rt.map(xe=>s.jsx(Lqe,{provider:xe,onEdit:st=>{Z(st),Y(!0)}},xe.id))}):s.jsx(Mt,{children:s.jsx(Et,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(tf,{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(Se,{size:"sm",onClick:()=>{Z(null),Y(!0)},children:[s.jsx(Kn,{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(za,{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."}),Tr?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(mt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):$r&&$r.length>0?s.jsx("div",{className:"space-y-2",children:$r.map(xe=>s.jsx(Mt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>oe(xe),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:xe.name}),s.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:xe.title_template})]}),s.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:st=>{st.stopPropagation(),oe(xe)},children:s.jsx(L2,{className:"w-4 h-4 text-bambu-gray"})})]})})},xe.id))}):s.jsx(Mt,{children:s.jsx(Et,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(za,{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."})]})})})]})]}),fe==="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(Gh,{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(Se,{size:"sm",onClick:()=>je(!0),className:"flex-shrink-0",children:[s.jsx(Kn,{className:"w-4 h-4"}),"Create Key"]})]}),W&&s.jsx(Mt,{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(Dn,{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:W}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(W);else{const xe=document.createElement("textarea");xe.value=W,xe.style.position="fixed",xe.style.left="-999999px",document.body.appendChild(xe),xe.select(),document.execCommand("copy"),document.body.removeChild(xe)}o("Key copied to clipboard")}catch{o("Failed to copy key","error")}},children:s.jsx(Jo,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex gap-2 mt-3",children:[s.jsx(Se,{variant:"secondary",size:"sm",onClick:()=>{Ce(W),o("Key added to API Browser")},children:"Use in API Browser"}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:()=>U(null),children:"Dismiss"})]})]})]})})}),Me&&s.jsxs(Mt,{className:"mb-6",children:[s.jsx(mr,{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:ne,onChange:xe=>Ke(xe.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:$.can_read_status,onChange:xe=>z(st=>({...st,can_read_status:xe.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:$.can_queue,onChange:xe=>z(st=>({...st,can_queue:xe.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:$.can_control_printer,onChange:xe=>z(st=>({...st,can_control_printer:xe.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(Se,{onClick:()=>qt.mutate({name:ne||"Unnamed Key",...$}),disabled:qt.isPending,children:[qt.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(Kn,{className:"w-4 h-4"}),"Create Key"]}),s.jsx(Se,{variant:"secondary",onClick:()=>je(!1),children:"Cancel"})]})]})]}),$t?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):pt&&pt.length>0?s.jsx("div",{className:"space-y-3",children:pt.map(xe=>s.jsx(Mt,{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(Gh,{className:`w-5 h-5 ${xe.enabled?"text-bambu-green":"text-bambu-gray"}`}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:xe.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[xe.key_prefix,"••••••••",xe.last_used&&` · Last used: ${Jp(xe.last_used)}`]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex gap-1 text-xs",children:[xe.can_read_status&&s.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),xe.can_queue&&s.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),xe.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(Se,{variant:"secondary",size:"sm",onClick:()=>Q(xe.id),children:s.jsx(an,{className:"w-4 h-4 text-red-400"})})]})]})})},xe.id))}):s.jsx(Mt,{children:s.jsx(Et,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Gh,{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(Se,{onClick:()=>je(!0),children:[s.jsx(Kn,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),s.jsxs(Mt,{className:"mt-6",children:[s.jsx(mr,{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(Md,{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(Mt,{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:Ee,onChange:xe=>Ce(xe.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(eKe,{apiKey:Ee})]})]}),fe==="virtual-printer"&&s.jsx(Yqe,{}),fe==="filament"&&T&&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(Mt,{children:[s.jsx(mr,{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(tD,{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:T.ams_humidity_good??40,onChange:xe=>vt("ams_humidity_good",parseInt(xe.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:T.ams_humidity_fair??60,onChange:xe=>vt("ams_humidity_fair",parseInt(xe.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(U2,{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:T.ams_temp_good??28,onChange:xe=>vt("ams_temp_good",parseFloat(xe.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:T.ams_temp_fair??35,onChange:xe=>vt("ams_temp_fair",parseFloat(xe.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(Yp,{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:T.ams_history_retention_days??30,onChange:xe=>vt("ams_history_retention_days",parseInt(xe.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(Ir,{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:T.per_printer_mapping_expanded??!1,onChange:xe=>vt("per_printer_mapping_expanded",xe.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(qqe,{})})]}),V!==null&&s.jsx(Ln,{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:()=>{wt.mutate(V),Q(null)},onCancel:()=>Q(null)}),F&&s.jsx(Dqe,{plug:X,onClose:()=>{L(!1),D(null)}}),K&&s.jsx(Iqe,{provider:q,onClose:()=>{Y(!1),Z(null)}}),re&&s.jsx(Fqe,{template:re,onClose:()=>oe(null)}),B&&s.jsx(Bqe,{onClose:()=>G(!1)}),Ne&&s.jsx(Ln,{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()=>{H(!1);try{const xe=await pe.clearNotificationLogs(30);o(xe.message,"success")}catch{o("Failed to clear logs","error")}},onCancel:()=>H(!1)}),O&&s.jsx(Ln,{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:()=>{ie(!1),localStorage.clear(),o("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>ie(!1)}),ye&&s.jsx(Ln,{title:`Turn All Plugs ${ye==="on"?"On":"Off"}`,message:`This will turn ${ye==="on"?"ON":"OFF"} all ${dt?.filter(xe=>xe.enabled).length||0} enabled smart plugs. ${ye==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${ye==="on"?"On":"Off"}`,variant:ye==="off"?"danger":"warning",onConfirm:()=>{const xe=ye;_e(null),Re.mutate(xe)},onCancel:()=>_e(null)}),le&&s.jsx(Hqe,{onClose:()=>ke(!1),onExport:async xe=>{ke(!1);const st="backup-progress",Ht=xe.archives;Ht&&l(st,i("backup.preparing",{defaultValue:"Preparing backup..."}),"loading");try{const{blob:It,filename:on}=await pe.exportBackup(xe);Ht&&c(st);const un=URL.createObjectURL(It),Gt=document.createElement("a");Gt.href=un,Gt.download=on,Gt.click(),URL.revokeObjectURL(un),o(i("backup.downloaded",{defaultValue:"Backup downloaded"}),"success")}catch{Ht&&c(st),o(i("backup.failed",{defaultValue:"Failed to create backup"}),"error")}}}),Oe&&s.jsx(Vqe,{onClose:()=>Ze(!1),onRestore:async(xe,st)=>await pe.importBackup(xe,st),onSuccess:()=>{P(null),Tt.current=!0,t.resetQueries({queryKey:["settings"]}),t.invalidateQueries({queryKey:["notification-providers"]}),t.invalidateQueries({queryKey:["notification-templates"]}),t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["external-links"]}),t.invalidateQueries({queryKey:["printers"]}),t.invalidateQueries({queryKey:["filaments"]}),t.invalidateQueries({queryKey:["maintenance-types"]}),t.invalidateQueries({queryKey:["api-keys"]})}}),ht&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>We(!1),children:s.jsxs(Mt,{className:"w-full max-w-lg",onClick:xe=>xe.stopPropagation(),children:[s.jsxs(mr,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(P1,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.telemetryInfoTitle")})]}),s.jsx("button",{onClick:()=>We(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs(Et,{className:"space-y-4",children:[s.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.telemetryInfoIntro")}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-white font-medium",children:i("settings.telemetryInfoCollected")}),s.jsxs("ul",{className:"space-y-2 text-sm",children:[s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Dn,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:i("settings.telemetryInfoItem1")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Dn,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:i("settings.telemetryInfoItem2")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Dn,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:i("settings.telemetryInfoItem3")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Dn,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:i("settings.telemetryInfoItem4")})]})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-white font-medium",children:i("settings.telemetryInfoNotCollected")}),s.jsxs("ul",{className:"space-y-2 text-sm",children:[s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(qi,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:i("settings.telemetryInfoNotItem1")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(qi,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:i("settings.telemetryInfoNotItem2")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(qi,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:i("settings.telemetryInfoNotItem3")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(qi,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:i("settings.telemetryInfoNotItem4")})]})]})]}),s.jsx("p",{className:"text-bambu-gray text-xs border-t border-bambu-dark-tertiary pt-4",children:i("settings.telemetryInfoFooter")}),s.jsx(Se,{onClick:()=>We(!1),className:"w-full",children:i("common.close")})]})]})}),he&&ue?.release_notes&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>rt(!1),children:s.jsxs(Mt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:xe=>xe.stopPropagation(),children:[s.jsxs(mr,{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",ue.latest_version]}),ue.release_name&&ue.release_name!==ue.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray",children:ue.release_name})]}),s.jsx("button",{onClick:()=>rt(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(Ut,{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:ue.release_notes})}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[ue.release_url&&s.jsx("a",{href:ue.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:s.jsxs(Se,{variant:"secondary",className:"w-full",children:[s.jsx(Lr,{className:"w-4 h-4"}),"View on GitHub"]})}),s.jsx(Se,{onClick:()=>rt(!1),className:"flex-1",children:"Close"})]})]})}),fe==="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(Wh,{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(Mt,{children:s.jsx(Et,{className:"py-6",children:u?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(kA,{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."})]})]}),d&&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:d.username}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Role: ",s.jsx("span",{className:"capitalize",children:d.role})]})]}),s.jsx("div",{className:`px-3 py-1 rounded-full text-xs font-medium ${d.role==="admin"?"bg-purple-500/20 text-purple-300":"bg-blue-500/20 text-blue-300"}`,children:d.role==="admin"?"Admin":"User"})]})}),s.jsxs("div",{className:"pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[s.jsxs(Se,{onClick:()=>e("/users"),className:"w-full",variant:"secondary",children:[s.jsx(Wh,{className:"w-4 h-4"}),"Manage Users"]}),d?.role==="admin"&&s.jsxs(Se,{onClick:()=>Je(!0),className:"w-full",variant:"secondary",children:[s.jsx(dz,{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 ${u?"bg-green-500/20":"bg-gray-500/20"}`,children:u?s.jsx(kA,{className:"w-6 h-6 text-green-400"}):s.jsx(dz,{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(Dn,{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(Dn,{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(Dn,{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(Se,{type:"button",onClick:xe=>{xe.preventDefault(),e("/setup")},className:"w-full",children:[s.jsx(kA,{className:"w-4 h-4"}),"Activate Authentication"]})]})]})})})]}),u&&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(P1,{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(Mt,{children:[s.jsx(mr,{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(P1,{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(Dn,{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(Dn,{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(Dn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Access all system features"})]})]})})]}),s.jsxs(Mt,{children:[s.jsx(mr,{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(Wh,{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(Dn,{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(Dn,{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(Dn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage filament"})]})]})})]})]})]})]}),qe&&s.jsx(Ln,{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 pe.disableAuth(),o("Authentication disabled successfully","success"),await f(),Je(!1),window.location.href="/"}catch(xe){const st=xe instanceof Error?xe.message:"Failed to disable authentication";o(st,"error")}},onCancel:()=>Je(!1)})]})}const hre=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},rKe=t=>t.startsWith("HH")?"HF":"S",iKe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},LR=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 gj({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){const l=rKe(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(eu,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Ol,{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:hre(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(tq,{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(Jo,{className:"w-4 h-4"})})]})}function xj({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}=$n(),[f,m]=w.useState(t?.name||""),[g,x]=w.useState(t?.k_value?hre(t.k_value):"0.020"),[y,b]=w.useState(t?.filament_id||""),[v,M]=w.useState(t?.nozzle_id?iKe(t.nozzle_id):"HH00"),[S,A]=w.useState(t?.nozzle_diameter||n),[E,k]=w.useState(t?[t.extruder_id]:i?[0,1]:[0]),[C,R]=w.useState(!1),[T,P]=w.useState({current:0,total:0}),[F,L]=w.useState(a),X=jr.useMemo(()=>{const oe=new Map;for(const B of r)if(B.filament_id&&!oe.has(B.filament_id)){const G=LR(B.name||"");oe.set(B.filament_id,{id:B.filament_id,name:G||B.filament_id})}return Array.from(oe.values()).sort((B,G)=>B.name.localeCompare(G.name))},[r]),D=ft({mutationFn:oe=>(console.log("[KProfile] Calling API..."),pe.setKProfile(e,oe)),onSuccess:oe=>{if(console.log("[KProfile] Save success:",oe),d("K-profile saved"),u&&F!==a){let B;F===""&&o?B=o:t&&t.slot_id>0?B=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:B=`name_${f}_${y}`,u(B,F)}R(!0),setTimeout(()=>{R(!1),c()},2500)},onError:oe=>{console.error("[KProfile] Save error:",oe),d(oe.message,"error"),R(!1)}}),K=ft({mutationFn:oe=>(console.log("[KProfile] Deleting profile..."),pe.deleteKProfile(e,oe)),onSuccess:oe=>{console.log("[KProfile] Delete success:",oe),d("K-profile deleted"),R(!0),setTimeout(()=>{R(!1),l()},4e3)},onError:oe=>{console.error("[KProfile] Delete error:",oe),d(oe.message,"error"),R(!1)}}),[Y,q]=w.useState(!1),Z=()=>{t&&K.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})},re=async oe=>{if(oe.preventDefault(),i&&!t&&E.length===0){d("Please select at least one extruder","error");return}const B=parseFloat(g).toFixed(6),G=`${v}-${S}`;if(t||E.length===1){const te={name:f,k_value:B,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:",te),D.mutate(te);return}R(!0),P({current:1,total:E.length});const J=E.map(te=>({name:f,k_value:B,filament_id:y,nozzle_id:G,nozzle_diameter:S,extruder_id:te,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${J.length} profiles in batch:`,J);try{if(await pe.setKProfilesBatch(e,J),d(`K-profile saved to ${E.length} extruders`),u&&F){const te=`name_${f}_${y}`;u(te,F)}}catch(te){console.error("[KProfile] Failed to save batch:",te),d("Failed to save K-profiles","error"),R(!1),P({current:0,total:0});return}P({current:E.length,total:E.length}),setTimeout(()=>{R(!1),P({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(Mt,{className:"w-full max-w-md relative",children:[C&&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(mt,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:T.total>1?`Saving to extruder ${T.current}/${T.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:C,children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:re,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:oe=>m(oe.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:g,onChange:oe=>{const B=oe.target.value;(B===""||/^\d*\.?\d*$/.test(B))&&x(B)},onBlur:oe=>{const B=parseFloat(oe.target.value);isNaN(B)||x((Math.trunc(B*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:oe=>{const B=oe.target.value;if(b(B),!t&&B&&!f){const G=X.find(J=>J.id===B);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:X.find(oe=>oe.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&X.map(oe=>s.jsx("option",{value:oe.id,children:oe.name},oe.id))]}),!t&&X.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:oe=>{const B=oe.target.value;if(M(B),!t&&y&&!f){const G=X.find(J=>J.id===y);G&&m(`${B==="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:oe=>A(oe.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:oe=>{oe.target.checked?k([...E,1]):k(E.filter(B=>B!==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:oe=>{oe.target.checked?k([...E,0]):k(E.filter(B=>B!==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:oe=>L(oe.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(Se,{type:"button",variant:"secondary",onClick:()=>q(!0),disabled:K.isPending||C,className:"text-red-500 hover:bg-red-500/10",children:K.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(an,{className:"w-4 h-4"})}),s.jsx(Se,{type:"button",variant:"secondary",onClick:l,disabled:C,className:"flex-1",children:"Cancel"}),s.jsxs(Se,{type:"submit",disabled:D.isPending||C,className:"flex-1",children:[D.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(j2,{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(Mt,{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(an,{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(Se,{variant:"secondary",onClick:()=>q(!1),className:"flex-1",children:"Cancel"}),s.jsxs(Se,{onClick:()=>{q(!1),Z()},disabled:K.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[K.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(an,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const C1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function aKe(){const{showToast:t}=$n(),[e,n]=w.useState(null),[r,i]=w.useState(()=>localStorage.getItem(C1.NOZZLE_DIAMETER)||"0.4"),[a,o]=w.useState(null),[l,c]=w.useState(!1),[u,d]=w.useState(null),[f,m]=w.useState(""),[g,x]=w.useState("all"),[y,b]=w.useState("all"),[v,M]=w.useState(()=>localStorage.getItem(C1.SORT_OPTION)||"name"),[S,A]=w.useState(!1),[E,k]=w.useState(new Set),[C,R]=w.useState(!1),[T,P]=w.useState(!1),F=w.useCallback(U=>`${U.slot_id}_${U.extruder_id}`,[]);w.useEffect(()=>{localStorage.setItem(C1.NOZZLE_DIAMETER,r)},[r]),w.useEffect(()=>{localStorage.setItem(C1.SORT_OPTION,v)},[v]);const{data:L,isLoading:X}=ct({queryKey:["printers"],queryFn:pe.getPrinters}),{data:D,isLoading:K,isFetching:Y,error:q,refetch:Z}=ct({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const U=await pe.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:re}=ct({queryKey:["kprofiles",e,"0.4"],queryFn:()=>pe.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:oe,refetch:B}=ct({queryKey:["kprofile-notes",e],queryFn:()=>pe.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),G=q?.message?.includes("not connected");w.useEffect(()=>{if(!e&&L&&L.length>0){const U=L.find(V=>V.is_active);U&&n(U.id)}},[e,L]),w.useEffect(()=>{if(e){const U=setTimeout(()=>{Z()},150);return()=>clearTimeout(U)}},[e,r]);const J=L?.filter(U=>U.is_active)||[],te=jr.useMemo(()=>D?.profiles?D.profiles.filter(V=>{const Q=f.toLowerCase(),Ee=!Q||V.name.toLowerCase().includes(Q)||V.filament_id.toLowerCase().includes(Q),Ce=g==="all"||g==="left"&&V.extruder_id===1||g==="right"&&V.extruder_id===0,Ne=y==="all"||y==="hf"&&V.nozzle_id.startsWith("HH")||y==="s"&&V.nozzle_id.startsWith("HS");return Ee&&Ce&&Ne}).sort((V,Q)=>{switch(v){case"k_value":return parseFloat(V.k_value)-parseFloat(Q.k_value);case"filament":return LR(V.name).localeCompare(LR(Q.name));case"name":default:return V.name.localeCompare(Q.name)}}):[],[D?.profiles,f,g,y,v]),ae=L?.find(U=>U.id===e),de=ae?.nozzle_count===2;w.useEffect(()=>{const U=V=>{V.target instanceof HTMLInputElement||V.target instanceof HTMLTextAreaElement||V.target instanceof HTMLSelectElement||a||l||u||(V.key==="r"||V.key==="R"?(V.preventDefault(),Z()):V.key==="n"||V.key==="N"?(V.preventDefault(),c(!0)):V.key==="Escape"&&S&&(V.preventDefault(),A(!1),k(new Set)))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[a,l,u,S,Z]);const fe=w.useCallback(()=>{if(!D?.profiles||D.profiles.length===0){t("No profiles to export","error");return}const U={version:1,exported_at:new Date().toISOString(),printer:ae?.name||"Unknown",nozzle_diameter:r,profiles:D.profiles.map(Ce=>({name:Ce.name,k_value:Ce.k_value,filament_id:Ce.filament_id,nozzle_id:Ce.nozzle_id,nozzle_diameter:Ce.nozzle_diameter,extruder_id:Ce.extruder_id}))},V=new Blob([JSON.stringify(U,null,2)],{type:"application/json"}),Q=URL.createObjectURL(V),Ee=document.createElement("a");Ee.href=Q,Ee.download=`kprofiles_${ae?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Ee),Ee.click(),document.body.removeChild(Ee),URL.revokeObjectURL(Q),t(`Exported ${D.profiles.length} profiles`)},[D?.profiles,ae,r,t]),Ae=w.useCallback(()=>{const U=document.createElement("input");U.type="file",U.accept=".json",U.onchange=async V=>{const Q=V.target.files?.[0];if(Q)try{const Ee=await Q.text(),Ce=JSON.parse(Ee);if(!Ce.profiles||!Array.isArray(Ce.profiles)){t("Invalid file format","error");return}let Ne=0;for(const H of Ce.profiles)if(!(!H.name||!H.k_value||!H.filament_id))try{await pe.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}),Ne++,await new Promise(O=>setTimeout(O,500))}catch(O){console.error("Failed to import profile:",H.name,O)}t(`Imported ${Ne} of ${Ce.profiles.length} profiles`),Z()}catch(Ee){console.error("Import error:",Ee),t("Failed to parse import file","error")}},U.click()},[e,r,t,Z]),ge=w.useCallback(U=>{k(V=>{const Q=new Set(V);return Q.has(U)?Q.delete(U):Q.add(U),Q})},[]),Me=w.useCallback(()=>{k(new Set(te.map(U=>F(U))))},[te,F]),je=w.useCallback(()=>{E.size!==0&&R(!0)},[E.size]),ne=w.useCallback(async()=>{const U=te.filter(Q=>E.has(F(Q)));P(!0);let V=0;for(const Q of U)try{await pe.deleteKProfile(e,{slot_id:Q.slot_id,extruder_id:Q.extruder_id,nozzle_id:Q.nozzle_id,nozzle_diameter:Q.nozzle_diameter,filament_id:Q.filament_id,setting_id:Q.setting_id}),V++,await new Promise(Ee=>setTimeout(Ee,300))}catch(Ee){console.error("Failed to delete profile:",Q.name,Ee)}t(`Deleted ${V} profiles`),P(!1),R(!1),A(!1),k(new Set),Z()},[e,E,te,t,Z,F]),Ke=w.useCallback(U=>{const V=[];return U.setting_id&&V.push(U.setting_id),V.push(`slot_${U.slot_id}_${U.filament_id}_${U.extruder_id}`),V.push(`name_${U.name}_${U.filament_id}`),V},[]),$=w.useCallback(async(U,V)=>{if(e)try{await pe.setKProfileNote(e,U,V),B()}catch(Q){console.error("Failed to save note:",Q),t("Failed to save note","error")}},[e,B,t]),z=w.useCallback(U=>{if(!oe?.notes)return{note:"",key:null};const V=Ke(U);for(const Q of V)if(oe.notes[Q])return{note:oe.notes[Q],key:Q};return{note:"",key:null}},[oe,Ke]),W=w.useCallback(U=>z(U).note,[z]);return X?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!L||L.length===0?s.jsx(Mt,{children:s.jsxs(Et,{className:"py-12 text-center",children:[s.jsx(ea,{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"})]})}):J.length===0?s.jsx(Mt,{children:s.jsxs(Et,{className:"py-12 text-center",children:[s.jsx(Ir,{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&&!K&&s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[s.jsx(mt,{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:J.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(Se,{variant:"secondary",onClick:()=>Z(),disabled:Y,children:[s.jsx(yr,{className:`w-4 h-4 ${Y?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Se,{onClick:()=>c(!0),children:[s.jsx(Kn,{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(xa,{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"})]}),de&&s.jsx("div",{className:"w-36",children:s.jsxs("select",{value:g,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=>M(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(Se,{variant:"secondary",onClick:fe,disabled:!D?.profiles?.length,title:"Export profiles to JSON",children:[s.jsx(Jr,{className:"w-4 h-4"}),"Export"]}),s.jsxs(Se,{variant:"secondary",onClick:Ae,title:"Import profiles from JSON",children:[s.jsx(bi,{className:"w-4 h-4"}),"Import"]}),s.jsx("div",{className:"flex-1"}),S?s.jsxs(s.Fragment,{children:[s.jsxs(Se,{variant:"secondary",onClick:Me,title:"Select all visible profiles",children:[s.jsx(eu,{className:"w-4 h-4"}),"Select All"]}),s.jsxs(Se,{variant:"secondary",onClick:je,disabled:E.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${E.size} selected profiles`,children:[s.jsx(an,{className:"w-4 h-4"}),"Delete (",E.size,")"]}),s.jsxs(Se,{variant:"secondary",onClick:()=>{A(!1),k(new Set)},children:[s.jsx(Ut,{className:"w-4 h-4"}),"Cancel"]})]}):s.jsxs(Se,{variant:"secondary",onClick:()=>A(!0),disabled:!te.length,title:"Enter selection mode for bulk delete",children:[s.jsx(eu,{className:"w-4 h-4"}),"Select"]})]}),K?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):G?s.jsx(Mt,{children:s.jsxs(Et,{className:"py-12 text-center",children:[s.jsx(Pg,{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(Se,{variant:"secondary",onClick:()=>Z(),children:[s.jsx(yr,{className:"w-4 h-4"}),"Retry"]})]})}):te.length>0?de?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:te.filter(U=>U.extruder_id===1).map(U=>s.jsx(gj,{profile:U,onEdit:()=>o(U),onCopy:()=>d(U),selectionMode:S,isSelected:E.has(F(U)),onToggleSelect:()=>ge(F(U)),note:W(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:te.filter(U=>U.extruder_id===0).map(U=>s.jsx(gj,{profile:U,onEdit:()=>o(U),onCopy:()=>d(U),selectionMode:S,isSelected:E.has(F(U)),onToggleSelect:()=>ge(F(U)),note:W(U)},F(U)))})]})]}):s.jsx("div",{className:"space-y-1",children:te.map(U=>s.jsx(gj,{profile:U,onEdit:()=>o(U),onCopy:()=>d(U),selectionMode:S,isSelected:E.has(F(U)),onToggleSelect:()=>ge(F(U)),note:W(U)},F(U)))}):f||g!=="all"||y!=="all"?s.jsx(Mt,{children:s.jsxs(Et,{className:"py-12 text-center",children:[s.jsx(xa,{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(Mt,{children:s.jsxs(Et,{className:"py-12 text-center",children:[s.jsx(j2,{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(Se,{onClick:()=>c(!0),children:[s.jsx(Kn,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:U,key:V}=z(a);return s.jsx(xj,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:re?.profiles||D?.profiles,isDualNozzle:de,initialNote:U,initialNoteKey:V,onSaveNote:$,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),o(null),Z()},onSave:()=>{o(null),Z()}})})(),l&&e&&s.jsx(xj,{printerId:e,nozzleDiameter:r,existingProfiles:re?.profiles||D?.profiles,isDualNozzle:de,onSaveNote:$,onClose:()=>{c(!1),Z()},onSave:()=>{c(!1),Z()}}),u&&e&&s.jsx(xj,{printerId:e,nozzleDiameter:r,existingProfiles:re?.profiles||D?.profiles,isDualNozzle:de,onSaveNote:$,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),Z()},onSave:()=>{d(null),Z()}}),C&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(Mt,{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(an,{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(Se,{variant:"secondary",onClick:()=>R(!1),disabled:T,className:"flex-1",children:"Cancel"}),s.jsxs(Se,{onClick:ne,disabled:T,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[T?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(an,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function RL(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 W0(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function sKe(t){const e=mi(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 oKe({onSuccess:t}){const{showToast:e}=$n(),[n,r]=w.useState("email"),[i,a]=w.useState(""),[o,l]=w.useState(""),[c,u]=w.useState(""),[d,f]=w.useState(""),[m,g]=w.useState("global"),x=ft({mutationFn:()=>pe.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=ft({mutationFn:()=>pe.cloudVerify(i,c),onSuccess:S=>{S.success?(e("Logged in successfully"),t()):e(S.message,"error")},onError:S=>e(S.message,"error")}),b=ft({mutationFn:()=>pe.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()},M=x.isPending||y.isPending||b.isPending;return s.jsx(Mt,{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(A2,{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=>g(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(Se,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),s.jsxs(Se,{type:"submit",disabled:M,className:"flex-1",children:[M?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(hz,{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(Gh,{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(hz,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function xp({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(Ji,{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 lKe(){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(Kp,{className:"w-5 h-5"})}):null}function bj({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o}){const l=RL(t.name),c=W0(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(Jo,{className:"w-4 h-4"})})]})}function IR(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(`
- `)){const i=t.replace(/\\n/g,`
- `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
- `);if(i.length>1)return`"""
- `+i.map(a=>n+" "+a).join(`
- `)+`
- `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
- `+t.map(i=>n+" "+IR(i,e+1)).join(`,
- `)+`
- `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
- `+r.map(([a,o])=>n+" "+JSON.stringify(a)+": "+IR(o,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function cKe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:a}=$n(),o=tn(),[l,c]=w.useState(!1),{data:u,isLoading:d}=ct({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>pe.getCloudSettingDetail(t.setting_id)}),f=ft({mutationFn:()=>pe.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),o.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:x=>a(x.message,"error")}),m=W0(t.setting_id),g=RL(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(Mt,{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"]}),g.printer&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"•"}),s.jsx("span",{children:g.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(Ut,{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(mt,{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:IR(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(Cn,{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(Se,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),s.jsxs(Se,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(an,{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(Se,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),s.jsxs(Se,{variant:"secondary",onClick:r,children:[s.jsx(Jo,{className:"w-4 h-4"}),"Duplicate"]}),m&&s.jsxs(s.Fragment,{children:[s.jsxs(Se,{variant:"secondary",onClick:i,disabled:d||!u,children:[s.jsx(Ga,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Se,{variant:"danger",onClick:()=>c(!0),children:s.jsx(an,{className:"w-4 h-4"})})]})]})})]})})})}function fre(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function mre(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function uKe({onClose:t,onApply:e}){const{showToast:n}=$n(),[r,i]=w.useState(fre),[a,o]=w.useState("all"),[l,c]=w.useState(null),[u,d]=w.useState(""),[f,m]=w.useState(""),[g,x]=w.useState("{}"),[y,b]=w.useState(null),[v,M]=w.useState(null),S=a==="all"?r:r.filter(L=>L.type===a),A=L=>{i(L),mre(L)},E=L=>{const X=r.filter(D=>D.id!==L);A(X),M(null),n("Template deleted")},k=L=>{c(L.id),d(L.name),m(L.description),x(JSON.stringify(L.settings,null,2)),b(null)},C=()=>{if(!(!l||!u.trim()))try{const L=JSON.parse(g),X=r.map(D=>D.id===l?{...D,name:u.trim(),description:f.trim(),settings:L}:D);A(X),c(null),n("Template updated")}catch(L){b(L.message)}},R=()=>{c(null),d(""),m(""),x("{}"),b(null)},T=L=>{const X=r.map(D=>D.id===L?{...D,showInModal:!D.showInModal}:D);A(X)},P={filament:{label:"Filament",icon:eD,color:"text-amber-400"},print:{label:"Process",icon:Dd,color:"text-blue-400"},printer:{label:"Printer",icon:Ir,color:"text-purple-400"}},F=v?r.find(L=>L.id===v):null;return w.useEffect(()=>{const L=X=>{X.key==="Escape"&&(v?M(null):l?R():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(Mt,{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(Cn,{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(Se,{variant:"secondary",onClick:()=>M(null),className:"flex-1",children:"Cancel"}),s.jsxs(Se,{onClick:()=>E(v),className:"flex-1 bg-red-500 hover:bg-red-600",children:[s.jsx(an,{className:"w-4 h-4"}),"Delete"]})]})]})})}),s.jsx(Mt,{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(a0,{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(Ut,{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":P[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(a0,{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 X=P[L.type],D=X.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:K=>d(K.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:K=>m(K.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:g,onChange:K=>{x(K.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(Se,{size:"sm",onClick:C,disabled:!u.trim(),children:[s.jsx(ds,{className:"w-4 h-4"}),"Save"]}),s.jsx(Se,{size:"sm",variant:"secondary",onClick:R,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(D,{className:`w-5 h-5 ${X.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:()=>T(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(_f,{className:"w-4 h-4"}):s.jsx(T2,{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:()=>k(L),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:s.jsx(Ga,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>M(L.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:s.jsx(an,{className:"w-4 h-4"})})]},L.id)})})})]})})]})}function pre({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[a,o]=w.useState("changes"),[l,c]=w.useState(""),u=w.useMemo(()=>{const g=new Set([...Object.keys(e),...Object.keys(n)]),x=[];for(const y of g){if(y==="inherits"||y==="version")continue;const b=e[y],v=n[y],M=y in e,S=y in n;let A;!M&&S?A="added":M&&!S?A="removed":JSON.stringify(b)!==JSON.stringify(v)?A="changed":A="same",x.push({key:y,left:b,right:v,status:A})}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 g=[...u];if(a==="changes"&&(g=g.filter(x=>x.status!=="same")),l){const x=l.toLowerCase();g=g.filter(y=>y.key.toLowerCase().includes(x)||String(y.left).toLowerCase().includes(x)||String(y.right).toLowerCase().includes(x))}return g},[u,a,l]),f=w.useMemo(()=>({added:u.filter(g=>g.status==="added").length,removed:u.filter(g=>g.status==="removed").length,changed:u.filter(g=>g.status==="changed").length,same:u.filter(g=>g.status==="same").length}),[u]),m=g=>{if(g===void 0)return"—";if(g===null)return"null";if(Array.isArray(g))return g.length===0?"[]":g.length===1?String(g[0]):g.join(", ");if(typeof g=="object")return JSON.stringify(g);const x=String(g);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 g=x=>{x.key==="Escape"&&t()};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsx(Mt,{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(Rp,{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(Ut,{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(Kn,{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(Hj,{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(Ij,{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(CA,{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(xa,{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:g=>c(g.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(CA,{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(g=>{const x={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[g.status],y={added:s.jsx(Kn,{className:"w-3.5 h-3.5 text-green-400"}),removed:s.jsx(Hj,{className:"w-3.5 h-3.5 text-red-400"}),changed:s.jsx(Ij,{className:"w-3.5 h-3.5 text-amber-400"}),same:s.jsx(CA,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[g.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:g.key})]})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${g.status==="removed"?"text-red-300":g.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(g.left)})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${g.status==="added"?"text-green-300":g.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(g.right)})})]},g.key)})})]})})]})})})}function dKe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=$n(),i=tn(),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,g]=w.useState(e?.base_id||""),[x,y]=w.useState(""),[b,v]=w.useState(e?.setting||{inherits:""}),[M,S]=w.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[A,E]=w.useState(null),[k,C]=w.useState(""),[R,T]=w.useState(!1),[P,F]=w.useState(""),[L,X]=w.useState(!1),[D,K]=w.useState(fre),[Y,q]=w.useState(!1),[Z,re]=w.useState(""),[oe,B]=w.useState(""),[G,J]=w.useState(!0),[te,ae]=w.useState(null),[de,fe]=w.useState(!1),Ae=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),ge=w.useMemo(()=>Ae.filter(he=>W0(he.setting_id)),[Ae]),{data:Me}=ct({queryKey:["cloudFields",c],queryFn:()=>pe.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:je}=ct({queryKey:["allPresetDetails",c,ge.map(he=>he.setting_id).join(",")],queryFn:async()=>{const he={};for(let qe=0;qe<ge.length;qe+=5){const Je=ge.slice(qe,qe+5);(await Promise.all(Je.map(async se=>{try{const $e=await pe.getCloudSettingDetail(se.setting_id);return{id:se.setting_id,detail:$e}}catch{return null}}))).forEach(se=>{se&&(he[se.id]=se.detail)})}return he},enabled:ge.length>0,staleTime:1e3*60*10}),{data:ne,isLoading:Ke}=ct({queryKey:["cloudSettingDetail",m],queryFn:()=>pe.getCloudSettingDetail(m),enabled:!!m});w.useEffect(()=>{o!=="json"&&S(JSON.stringify(b,null,2))},[b,o]);const $=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(rt=>!W0(rt.setting_id)).sort((rt,qe)=>rt.name.localeCompare(qe.name)),[n,c]);w.useEffect(()=>{if(!m)return;const he=$.find(rt=>rt.setting_id===m);he&&(y(he.name),a||(v({inherits:he.name}),S(JSON.stringify({inherits:he.name},null,2))))},[m,$,a]);const z=w.useMemo(()=>{const he=Me?.fields||[],rt=new Set(he.map(se=>se.key)),qe=new Set,Je=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);je&&Object.values(je).forEach(se=>{se?.setting&&Object.keys(se.setting).forEach($e=>{!rt.has($e)&&!Je.has($e)&&qe.add($e)})}),Object.keys(b).forEach(se=>{!rt.has(se)&&!Je.has(se)&&qe.add(se)});const ot=Array.from(qe).sort().map(se=>({key:se,label:se.replace(/_/g," ").replace(/\b\w/g,$e=>$e.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...he,...ot]},[Me,je,b]),W=z.filter(he=>he.label.toLowerCase().includes(k.toLowerCase())||he.key.toLowerCase().includes(k.toLowerCase())),U=()=>{if(P.trim()){const he=P.trim().toLowerCase().replace(/\s+/g,"_");V(he,""),F(""),X(!1),r(`Field "${he}" added`)}},V=(he,rt)=>{v(qe=>{const Je={...qe};return rt===""||rt===void 0?delete Je[he]:Je[he]=rt,Je})},Q=he=>{v(rt=>({...rt,...he.settings})),ae(he.name),r("Template applied")},Ee=()=>{if(!Z.trim())return;const he={...b};if(delete he.inherits,Object.keys(he).length===0){r("No overrides to save","error");return}const rt={id:Date.now().toString(),name:Z.trim(),description:oe.trim()||"Custom template",type:c,settings:he,showInModal:G},qe=[...D,rt];K(qe),mre(qe),q(!1),re(""),B(""),J(!0),r("Template saved")},Ce=w.useMemo(()=>D.filter(he=>he.type===c&&he.showInModal),[c,D]),Ne=he=>{S(he);try{const rt=JSON.parse(he);v(rt),E(null)}catch(rt){E(rt.message)}},H=he=>{he.preventDefault(),T(!1);const rt=he.dataTransfer.files[0];if(rt&&rt.name.endsWith(".json")){const qe=new FileReader;qe.onload=Je=>{try{const ot=Je.target?.result,se=JSON.parse(ot),$e=se.setting||se;v(be=>({...be,...$e})),S(JSON.stringify({...b,...$e},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},qe.readAsText(rt)}},O=ft({mutationFn:()=>{const he={...b},rt=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";he[rt]=`"${d}"`;const qe={type:c,name:d,base_id:m,setting:he};return pe.createCloudSetting(qe)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:he=>r(he.message,"error")}),ie=ft({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return pe.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:he=>r(he.message,"error")}),ye=a?ie:O,_e=ne?.setting?.inherits,le=_e?$.find(he=>he.name===_e):void 0,{data:ke}=ct({queryKey:["cloudSettingDetail",le?.setting_id],queryFn:()=>pe.getCloudSettingDetail(le.setting_id),enabled:!!le?.setting_id}),Oe=w.useMemo(()=>{const he=ke?.setting||{},rt=ne?.setting||{},qe=m&&je?.[m]?.setting?je[m].setting:{};return{...he,...rt,...qe}},[m,ne,ke,je]),Ze=he=>{if(he==null)return"";if(Array.isArray(he)){const rt=[...new Set(he.map(qe=>String(qe)))];return rt.length===1?rt[0]:he.join(", ")}return String(he)},ht=he=>{const rt=b[he.key],qe=Oe[he.key],Je=Ze(qe),ot=Ke?"Loading...":Je||"",se="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(he.type==="boolean"){const $e=rt==="1"||rt===void 0&&qe==="1";return s.jsx("button",{type:"button",onClick:()=>V(he.key,rt==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${$e?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${$e?"translate-x-3.5":"translate-x-0.5"}`})})}return he.type==="select"?s.jsxs("select",{value:rt||"",onChange:$e=>V(he.key,$e.target.value),className:se,children:[s.jsx("option",{value:"",children:ot}),he.options?.map($e=>s.jsx("option",{value:$e.value,children:$e.label},$e.value))]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:he.type==="number"?"number":"text",value:rt!==void 0?String(rt):"",onChange:$e=>V(he.key,$e.target.value),step:he.step,min:he.min,max:he.max,placeholder:ot,className:se}),he.unit&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:he.unit})]})},We=w.useMemo(()=>ne?.setting?ne.setting:{},[ne]);return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:he=>{he.preventDefault(),T(!0)},onDragLeave:()=>T(!1),onDrop:H,children:[de&&m&&s.jsx(pre,{onClose:()=>fe(!1),leftPreset:We,rightPreset:b,leftLabel:`Base: ${x||m}`,rightLabel:`Current: ${d||"New Preset"}`}),s.jsx(Mt,{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:()=>fe(!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(Rp,{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(Ut,{className:"w-5 h-5"})})]})]}),R&&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(bi,{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:he=>{u(he.target.value),g("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[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:he=>g(he.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..."}),$.map(he=>s.jsx("option",{value:he.setting_id,children:he.name},he.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:he=>f(he.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",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(xs,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",s.jsx("span",{className:"text-white",children:x}),Ke&&s.jsx(mt,{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(fz,{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(O2,{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(VW,{className:"w-4 h-4"}),"JSON",A&&s.jsx(ea,{className:"w-3 h-3 text-red-400"})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("button",{onClick:()=>{const he={name:d,type:c,base_id:m,setting:b},rt=new Blob([JSON.stringify(he,null,2)],{type:"application/json"}),qe=URL.createObjectURL(rt),Je=document.createElement("a");Je.href=qe,Je.download=`${d||"preset"}.json`,document.body.appendChild(Je),Je.click(),document.body.removeChild(Je),URL.revokeObjectURL(qe),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(Jr,{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(bi,{className:"w-4 h-4"}),"Import"]}),s.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:he=>{const rt=he.target.files?.[0];if(rt){const qe=new FileReader;qe.onload=Je=>{try{const ot=JSON.parse(Je.target?.result),se=ot.setting||ot;v($e=>({...$e,...se})),r("File imported")}catch{r("Invalid JSON","error")}},qe.readAsText(rt)}}})]}),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(a0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(b).filter(he=>he!=="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(ds,{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:Z,onChange:he=>re(he.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:oe,onChange:he=>B(he.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(Se,{size:"sm",onClick:Ee,disabled:!Z.trim(),children:[s.jsx(ds,{className:"w-3 h-3"}),"Save"]}),s.jsx(Se,{size:"sm",variant:"secondary",onClick:()=>q(!1),children:"Cancel"})]}),s.jsxs("button",{onClick:()=>J(!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(_f,{className:"w-3.5 h-3.5"}):s.jsx(T2,{className:"w-3.5 h-3.5"}),G?"Show in modals":"Hidden in modals"]})]})]}),te&&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(xs,{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:te})]}),s.jsx("button",{onClick:()=>ae(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:s.jsx(Ut,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Ce.map(he=>s.jsxs("button",{onClick:()=>Q(he),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:he.name}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:he.description})]},he.id)),Ce.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:z.slice(0,10).map(he=>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:he.label}),s.jsx("div",{className:"w-48",children:ht(he)})]},he.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(([he])=>he!=="inherits").map(([he,rt])=>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:[he,": ",String(rt).slice(0,20),s.jsx("button",{onClick:()=>V(he,void 0),className:"hover:text-white",children:s.jsx(Ut,{className:"w-3 h-3"})})]},he))})]})]}),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:je?`${z.length} fields`:"Loading..."})]}),s.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[s.jsx(xa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:k,onChange:he=>C(he.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:[W.filter(he=>!(he.key in b)).map(he=>{const rt=Oe[he.key],qe=Ze(rt);return s.jsxs("div",{onClick:()=>{v(Je=>({...Je,[he.key]:qe||""}))},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:he.label}),s.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:he.key})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[qe&&s.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:qe,children:[qe.slice(0,20),qe.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(Kn,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},he.key)}),W.filter(he=>!(he.key in b)).length===0&&s.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:k?"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:P,onChange:he=>F(he.target.value),onKeyDown:he=>he.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(Se,{size:"sm",onClick:U,disabled:!P.trim(),children:s.jsx(Kn,{className:"w-4 h-4"})}),s.jsx(Se,{size:"sm",variant:"secondary",onClick:()=>{X(!1),F("")},children:s.jsx(Ut,{className:"w-4 h-4"})})]}):s.jsxs("button",{onClick:()=>X(!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(Kn,{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(he=>he!=="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(([he])=>he!=="inherits").map(([he,rt])=>{const qe=z.find(Je=>Je.key===he);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:qe?.label||he}),s.jsx("p",{className:"text-xs text-bambu-gray-dark",children:he})]}),s.jsx("button",{onClick:()=>V(he,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(Ut,{className:"w-4 h-4"})})]}),qe?ht(qe):s.jsx("input",{type:"text",value:String(rt),onChange:Je=>V(he,Je.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"})]},he)}),Object.keys(b).filter(he=>he!=="inherits").length===0&&s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(fz,{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(he=>he!=="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(ds,{className:"w-4 h-4"}),"Save as template"]})})]})]}),o==="json"&&s.jsxs("div",{className:"space-y-2",children:[A&&s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(ea,{className:"w-4 h-4"}),A]}),s.jsx("textarea",{value:M,onChange:he=>Ne(he.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 ${A?"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(Se,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsxs(Se,{onClick:()=>ye.mutate(),disabled:ye.isPending||!d.trim()||!a&&!m||!!A,className:"flex-1",children:[ye.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):a?s.jsx(ds,{className:"w-4 h-4"}):s.jsx(Kn,{className:"w-4 h-4"}),a?"Save":e?"Duplicate":"Create"]})]})]})})]})}function hKe({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"),[g,x]=w.useState("all"),[y,b]=w.useState("all"),[v,M]=w.useState("all"),[S,A]=w.useState(null),[E,k]=w.useState(!1),[C,R]=w.useState(!1),[T,P]=w.useState(null),[F,L]=w.useState(null),[X,D]=w.useState(null),[K,Y]=w.useState(!1),[q,Z]=w.useState([null,null]),[re,oe]=w.useState(!1),[B,G]=w.useState(null),J=tn(),te=w.useMemo(()=>[...t.filament.map(W=>({...W,type:"filament"})),...t.printer.map(W=>({...W,type:"printer"})),...t.process.map(W=>({...W,type:"process"}))].map(W=>({...W,meta:RL(W.name)})),[t]),ae=w.useMemo(()=>{const z=new Set,W=new Set,U=new Set;return te.forEach(V=>{V.meta.nozzle&&z.add(V.meta.nozzle),V.meta.filamentType&&W.add(V.meta.filamentType),V.meta.layerHeight&&U.add(V.meta.layerHeight)}),{printers:i.map(V=>({id:V.id.toString(),name:V.name})),nozzles:Array.from(z).sort((V,Q)=>parseFloat(V)-parseFloat(Q)),filaments:Array.from(W).sort(),layerHeights:Array.from(U).sort((V,Q)=>parseFloat(V)-parseFloat(Q))}},[te,i]),de=w.useMemo(()=>f==="all"?null:i.find(W=>W.id.toString()===f)?.model||null,[f,i]),fe=w.useMemo(()=>te.filter(z=>l==="all"||z.type===l).filter(z=>{if(u==="all")return!0;const W=W0(z.setting_id);return u==="custom"?W:!W}).filter(z=>{if(f==="all"||!de)return!0;const W=z.meta.printer?.toLowerCase()||"",U=de.toLowerCase();return W.includes(U)||U.includes(W)}).filter(z=>g==="all"||z.meta.nozzle===g).filter(z=>y==="all"||z.meta.filamentType===y).filter(z=>v==="all"||z.meta.layerHeight===v).filter(z=>a===""||z.name.toLowerCase().includes(a.toLowerCase())).sort((z,W)=>z.name.localeCompare(W.name)),[te,l,u,f,de,g,y,v,a]),Ae=z=>{if(K){const W=q[0]?.setting_id===z.setting_id,U=q[1]?.setting_id===z.setting_id;if(W)Z([q[1],null]);else if(U)Z([q[0],null]);else if(!q[0])Z([z,null]);else if(q[1]){if(q[0].type!==z.type)return;Z([q[0],z])}else{if(q[0].type!==z.type)return;Z([q[0],z])}}else A(z)},ge=z=>{if(q[0]?.setting_id===z.setting_id)return 0;if(q[1]?.setting_id===z.setting_id)return 1},Me=async z=>{try{const W=await pe.getCloudSettingDetail(z.setting_id),U=z.type==="process"?"print":z.type;P({type:U,name:z.name,base_id:W.base_id||"GFSA00",setting:W.setting||{}}),A(null)}catch(W){console.error("Failed to fetch preset details for duplication:",W)}},je=async z=>{try{J.removeQueries({queryKey:["cloudSettingDetail",z.setting_id]});const W=await pe.getCloudSettingDetail(z.setting_id),U=z.type==="process"?"print":z.type;L({type:U,name:z.name,base_id:W.base_id||"GFSA00",setting:W.setting||{},setting_id:z.setting_id}),A(null)}catch(W){console.error("Failed to fetch preset details for editing:",W)}},ne=()=>{c("all"),d("all"),m("all"),x("all"),b("all"),M("all"),o("")},Ke=l!=="all"||u!=="all"||f!=="all"||g!=="all"||y!=="all"||v!=="all"||a!=="",$=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(xa,{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:z=>o(z.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(Se,{variant:K?"primary":"secondary",onClick:()=>{K?(Y(!1),Z([null,null])):Y(!0)},children:[s.jsx(Rp,{className:"w-4 h-4"}),K?"Cancel":"Compare"]}),s.jsxs(Se,{variant:"secondary",onClick:()=>R(!0),children:[s.jsx(a0,{className:"w-4 h-4"}),"Templates"]}),s.jsxs(Se,{variant:"secondary",onClick:n,disabled:r,children:[s.jsx(yr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Se,{onClick:()=>k(!0),children:[s.jsx(Kn,{className:"w-4 h-4"}),"New Preset"]})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(k2,{className:"w-4 h-4 text-bambu-gray"}),s.jsx(xp,{label:"Type",value:l,options:[{value:"all",label:"All",count:$},{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:z=>c(z)}),s.jsx(xp,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:z=>d(z)}),ae.printers.length>0&&s.jsx(xp,{label:"Printer",value:f,options:[{value:"all",label:"All"},...ae.printers.map(z=>({value:z.id,label:z.name}))],onChange:m}),ae.nozzles.length>0&&s.jsx(xp,{label:"Nozzle",value:g,options:[{value:"all",label:"All"},...ae.nozzles.map(z=>({value:z,label:z}))],onChange:x}),ae.filaments.length>0&&(l==="all"||l==="filament")&&s.jsx(xp,{label:"Filament",value:y,options:[{value:"all",label:"All"},...ae.filaments.map(z=>({value:z,label:z}))],onChange:b}),ae.layerHeights.length>0&&(l==="all"||l==="process")&&s.jsx(xp,{label:"Layer",value:v,options:[{value:"all",label:"All"},...ae.layerHeights.map(z=>({value:z,label:z}))],onChange:M}),Ke&&s.jsx("button",{onClick:ne,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),K&&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(Rp,{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(Ij,{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(Se,{size:"sm",onClick:async()=>{try{const[z,W]=await Promise.all([pe.getCloudSettingDetail(q[0].setting_id),pe.getCloudSettingDetail(q[1].setting_id)]);G([z.setting||{},W.setting||{}]),oe(!0)}catch{}},children:[s.jsx(Rp,{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(Gn,{className:"w-3 h-3"}),"Last synced: ",sKe(e.toISOString())]}),s.jsxs("span",{children:["Showing ",fe.length," of ",$," 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)"})]})]}),fe.length===0?s.jsxs("div",{className:"text-center py-16",children:[s.jsx(nl,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),s.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),Ke&&s.jsx("button",{onClick:ne,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(eD,{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:["(",fe.filter(z=>z.type==="filament").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[fe.filter(z=>z.type==="filament").map(z=>s.jsx(bj,{setting:z,onClick:()=>Ae(z),onDuplicate:()=>Me(z),compareMode:K,isCompareSelected:ge(z)!==void 0,compareIndex:ge(z),compareDisabled:K&&!!q[0]&&q[0].type!==z.type},z.setting_id)),fe.filter(z=>z.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(Dd,{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:["(",fe.filter(z=>z.type==="process").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[fe.filter(z=>z.type==="process").map(z=>s.jsx(bj,{setting:z,onClick:()=>Ae(z),onDuplicate:()=>Me(z),compareMode:K,isCompareSelected:ge(z)!==void 0,compareIndex:ge(z),compareDisabled:K&&!!q[0]&&q[0].type!==z.type},z.setting_id)),fe.filter(z=>z.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(Ir,{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:["(",fe.filter(z=>z.type==="printer").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[fe.filter(z=>z.type==="printer").map(z=>s.jsx(bj,{setting:z,onClick:()=>Ae(z),onDuplicate:()=>Me(z),compareMode:K,isCompareSelected:ge(z)!==void 0,compareIndex:ge(z),compareDisabled:K&&!!q[0]&&q[0].type!==z.type},z.setting_id)),fe.filter(z=>z.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(cKe,{setting:S,onClose:()=>A(null),onDeleted:()=>A(null),onDuplicate:()=>Me(S),onEdit:()=>je(S)}),(E||T||F||X)&&s.jsx(dKe,{onClose:()=>{k(!1),P(null),L(null),D(null)},initialData:F||T||(X?{type:X.type,name:"",base_id:"",setting:X.setting}:void 0),allPresets:t}),C&&s.jsx(uKe,{onClose:()=>R(!1),onApply:z=>{D({type:z.type,setting:z.settings}),R(!1)}}),re&&B&&q[0]&&q[1]&&s.jsx(pre,{onClose:()=>{oe(!1),G(null)},leftPreset:B[0],rightPreset:B[1],leftLabel:q[0].name,rightLabel:q[1].name})]})}function fKe(){const t=tn(),{showToast:e}=$n(),[n,r]=w.useState("cloud"),[i,a]=w.useState(),{data:o,isLoading:l}=ct({queryKey:["cloudStatus"],queryFn:pe.getCloudStatus}),{data:c=[]}=ct({queryKey:["printers"],queryFn:pe.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:m}=ct({queryKey:["cloudSettings"],queryFn:()=>pe.getCloudSettings(),enabled:!!o?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{m&&a(new Date(m))},[m]);const g=ft({mutationFn:pe.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(mt,{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(A2,{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(j2,{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(Se,{variant:"secondary",size:"sm",onClick:()=>g.mutate(),disabled:g.isPending,children:[s.jsx($j,{className:"w-4 h-4"}),"Logout"]})]}),o?.is_authenticated?d?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?s.jsx(hKe,{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(Se,{onClick:()=>f(),children:"Retry"})]}):s.jsx(oKe,{onSuccess:x})]}),n==="kprofiles"&&s.jsx(aKe,{}),s.jsx(lKe,{})]})}const Cb={Droplet:eD,Flame:mue,Ruler:Wde,Sparkles:a0,Square:Ol,Cable:dce,Wrench:Od,Calendar:Qr,Timer:md,Cog:Bce,Fan:GW,Zap:Mf,Wind:sq,Thermometer:U2,Layers:nl,Box:Os,Target:nq,RefreshCw:yr,Settings:F2,Filter:k2,CircleDot:Tce};function Jb(t){return t&&Cb[t]||Od}function bp(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 yj(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 mKe(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 pKe({item:t,onPerform:e,onToggle:n}){const r=Jb(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 ${bp(Math.abs(f),"days")}`:t.is_warning?`Due in ${bp(f,"days")}`:`${bp(f,"days")} left`}else return t.is_due?`Overdue by ${bp(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${bp(t.hours_until_due,"hours")}`:`${bp(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(Qr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const f=t.maintenance_type_wiki_url||mKe(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(Lr,{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(Cn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&s.jsx(Gn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&s.jsx(xs,{className:"w-3 h-3"}),d()]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(Vn,{checked:t.enabled,onChange:f=>n(t.id,f)}),s.jsxs(Se,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[s.jsx(Vf,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function gKe({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((g,x)=>g.is_due&&!x.is_due?-1:!g.is_due&&x.is_due?1:g.is_warning&&!x.is_warning?-1:!g.is_warning&&x.is_warning?1:g.maintenance_type_id-x.maintenance_type_id),f=d.find(g=>g.enabled&&(g.is_due||g.is_warning)),m=()=>{const g=parseFloat(c);!isNaN(g)&&g>=0&&(r(t.printer_id,g),l(!1))};return s.jsxs(Mt,{className:"overflow-hidden",children:[s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),s.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&s.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[s.jsx(Cn,{className:"w-3 h-3"}),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(Gn,{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(xs,{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(Jc,{className:"w-4 h-4"}):s.jsx(Ji,{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(md,{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:g=>u(g.target.value),onKeyDown:g=>{g.key==="Enter"&&m(),g.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(Se,{size:"sm",onClick:m,children:"Save"}),s.jsx(Se,{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(wf,{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 g=Jb(f.maintenance_type_icon);return s.jsx(g,{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(g=>s.jsx(pKe,{item:g,onPerform:e,onToggle:n},g.id))})})]})}function xKe({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,g]=w.useState("hours"),[x,y]=w.useState(!1),[b,v]=w.useState(""),[M,S]=w.useState("100"),[A,E]=w.useState("hours"),[k,C]=w.useState("Wrench"),[R,T]=w.useState(""),[P,F]=w.useState(new Set),[L,X]=w.useState(null),D=w.useMemo(()=>t?t.map(U=>({id:U.printer_id,name:U.printer_name})):[],[t]),K=U=>t?t.filter(V=>V.maintenance_items.some(Q=>Q.maintenance_type_id===U)).map(V=>({printerId:V.printer_id,printerName:V.printer_name,itemId:V.maintenance_items.find(Q=>Q.maintenance_type_id===U)?.id})):[],Y=U=>{if(!t)return[];const V=new Set(K(U).map(Q=>Q.printerId));return D.filter(Q=>!V.has(Q.id))},[q,Z]=w.useState(null),[re,oe]=w.useState(""),[B,G]=w.useState(""),[J,te]=w.useState("hours"),[ae,de]=w.useState("Wrench"),[fe,Ae]=w.useState(""),ge=U=>{Z(U),oe(U.name),G(U.default_interval_hours.toString()),te(U.interval_type||"hours"),de(U.icon||"Wrench"),Ae(U.wiki_url||"")},Me=()=>{q&&re.trim()&&parseFloat(B)>0&&(i(q.id,{name:re.trim(),default_interval_hours:parseFloat(B),interval_type:J,icon:ae,wiki_url:fe.trim()||null}),Z(null))},je=(U,V,Q)=>{const Ee=parseFloat(d);if(!isNaN(Ee)&&Ee>0){const Ce=Math.abs(Ee-V)<.01?null:Ee;n(U,{custom_interval_hours:Ce,custom_interval_type:m!==Q?m:null})}u(null)},ne=U=>{U.preventDefault(),b.trim()&&parseFloat(M)>0&&P.size>0&&(r({name:b.trim(),default_interval_hours:parseFloat(M),interval_type:A,icon:k,wiki_url:R.trim()||null},Array.from(P)),v(""),S("100"),E("hours"),T(""),F(new Set),y(!1))},Ke=U=>{F(V=>{const Q=new Set(V);return Q.has(U)?Q.delete(U):Q.add(U),Q})},$=t?.map(U=>({printerId:U.printer_id,printerName:U.printer_name,items:U.maintenance_items.sort((V,Q)=>V.maintenance_type_id-Q.maintenance_type_id)})).sort((U,V)=>U.printerName.localeCompare(V.printerName))||[],z=e.filter(U=>U.is_system),W=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(Se,{onClick:()=>y(!x),children:[s.jsx(Kn,{className:"w-4 h-4"}),"Add Custom Type"]})]}),x&&s.jsx(Mt,{className:"mb-6",children:s.jsx(Et,{className:"py-4",children:s.jsxs("form",{onSubmit:ne,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:A,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 (",A==="days"?"days":"hours",")"]}),s.jsx("input",{type:"number",value:M,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(Cb).map(U=>{const V=Cb[U];return s.jsx("button",{type:"button",onClick:()=>C(U),className:`p-2 rounded-lg transition-colors ${k===U?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:s.jsx(V,{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:R,onChange:U=>T(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:D.map(U=>s.jsx("button",{type:"button",onClick:()=>Ke(U.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${P.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))}),P.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(Se,{type:"button",variant:"secondary",onClick:()=>{y(!1),F(new Set)},children:"Cancel"}),s.jsx(Se,{type:"submit",disabled:!b.trim()||P.size===0,children:"Add Type"})]})]})})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[z.map(U=>{const V=Jb(U.icon),Q=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(V,{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:[Q==="days"?s.jsx(Qr,{className:"w-3 h-3"}):s.jsx(md,{className:"w-3 h-3"}),yj(U.default_interval_hours,Q)]})]})]})},U.id)}),W.map(U=>{const V=Jb(U.icon),Q=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:re,onChange:O=>oe(O.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Name",autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{value:J,onChange:O=>te(O.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:B,onChange:O=>G(O.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(Cb).map(O=>{const ie=Cb[O];return s.jsx("button",{type:"button",onClick:()=>de(O),className:`p-1.5 rounded transition-colors ${ae===O?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s.jsx(ie,{className:"w-3.5 h-3.5"})},O)})}),s.jsx("input",{type:"url",value:fe,onChange:O=>Ae(O.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Documentation link (optional)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Se,{size:"sm",onClick:Me,disabled:!re.trim(),children:"Save"}),s.jsx(Se,{size:"sm",variant:"secondary",onClick:()=>Z(null),children:"Cancel"})]})]})},U.id);const Ce=K(U.id),Ne=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(V,{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:[Q==="days"?s.jsx(Qr,{className:"w-3 h-3"}):s.jsx(md,{className:"w-3 h-3"}),yj(U.default_interval_hours,Q)]})]}),s.jsxs("button",{onClick:()=>X(H?null:U.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${Ce.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:`${Ce.length} printer(s) assigned - click to manage`,children:[s.jsx(Ir,{className:"w-3 h-3"}),s.jsx("span",{className:"text-xs font-medium",children:Ce.length}),s.jsx(Ji,{className:`w-3 h-3 transition-transform ${H?"rotate-180":""}`})]}),s.jsx("button",{onClick:()=>ge(U),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:s.jsx(wf,{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(an,{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:"}),Ce.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:Ce.map(O=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[O.printerName,s.jsx("button",{onClick:()=>O.itemId&&l(O.itemId),className:"hover:text-red-400 ml-1",title:"Remove from this printer",children:"×"})]},O.printerId))}),Ne.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:"}),Ne.map(O=>s.jsxs("button",{onClick:()=>o(O.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:["+ ",O.name]},O.id))]})]})]},U.id)})]})]}),$.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:$.map(U=>s.jsx(Mt,{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(V=>{const Q=Jb(V.maintenance_type_icon),Ee=e.find(ie=>ie.id===V.maintenance_type_id),Ce=Ee?.default_interval_hours||V.interval_hours,Ne=Ee?.interval_type||"hours",H=V.interval_type||"hours",O=c===V.id;return s.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[s.jsx(Q,{className:"w-4 h-4 text-bambu-gray shrink-0"}),s.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:V.maintenance_type_name}),O?s.jsxs("div",{className:"flex items-center gap-1",children:[m==="days"?s.jsx(Qr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):s.jsx(md,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),s.jsxs("select",{value:m,onChange:ie=>g(ie.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:ie=>f(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"&&je(V.id,Ce,Ne),ie.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(Se,{size:"sm",onClick:()=>je(V.id,Ce,Ne),children:"OK"})]}):s.jsxs("button",{onClick:()=>{u(V.id),f(V.interval_hours.toString()),g(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(Qr,{className:"w-3 h-3"}):s.jsx(md,{className:"w-3 h-3"}),yj(V.interval_hours,H),s.jsx(wf,{className:"w-3 h-3 text-bambu-gray"})]})]},V.id)})})]})},U.printerId))})]}),$.length===0&&s.jsx(Mt,{children:s.jsxs(Et,{className:"text-center py-12",children:[s.jsx(Gn,{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 bKe(){const t=tn(),{showToast:e}=$n(),[n,r]=w.useState("status"),{data:i,isLoading:a}=ct({queryKey:["maintenanceOverview"],queryFn:pe.getMaintenanceOverview}),{data:o}=ct({queryKey:["maintenanceTypes"],queryFn:pe.getMaintenanceTypes}),l=ft({mutationFn:({id:S,notes:A})=>pe.performMaintenance(S,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:S=>{e(S.message,"error")}}),c=ft({mutationFn:({id:S,data:A})=>pe.updateMaintenanceItem(S,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:S=>{e(S.message,"error")}}),u=ft({mutationFn:({id:S,data:A})=>pe.updateMaintenanceType(S,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:S=>{e(S.message,"error")}}),d=ft({mutationFn:pe.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:S=>{e(S.message,"error")}}),f=ft({mutationFn:({printerId:S,hours:A})=>pe.setPrinterHours(S,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:S=>{e(S.message,"error")}}),m=ft({mutationFn:({printerId:S,typeId:A})=>pe.assignMaintenanceType(S,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer assigned")},onError:S=>{e(S.message,"error")}}),g=ft({mutationFn:pe.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer removed")},onError:S=>{e(S.message,"error")}}),x=S=>{l.mutate({id:S})},y=(S,A)=>{c.mutate({id:S,data:{enabled:A}})},b=(S,A)=>{f.mutate({printerId:S,hours:A})};if(a)return s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})});const v=i?.reduce((S,A)=>S+A.due_count,0)||0,M=i?.reduce((S,A)=>S+A.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&&M>0&&" · ",M>0&&s.jsxs("span",{className:"text-amber-400",children:[M," due soon"]}),v===0&&M===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,A)=>{const E=S.due_count*10+S.warning_count,k=A.due_count*10+A.warning_count;return E!==k?k-E:S.printer_name.localeCompare(A.printer_name)}).map(S=>s.jsx(gKe,{overview:S,onPerform:x,onToggle:y,onSetHours:b},S.printer_id)):s.jsx(Mt,{children:s.jsxs(Et,{className:"text-center py-16",children:[s.jsx(Od,{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(xKe,{overview:i,types:o||[],onUpdateInterval:(S,A)=>c.mutate({id:S,data:A}),onAddType:async(S,A)=>{const E=await pe.createMaintenanceType(S);for(const k of A)await pe.assignMaintenanceType(k,E.id);t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onUpdateType:(S,A)=>u.mutate({id:S,data:A}),onDeleteType:S=>d.mutate(S),onAssignType:(S,A)=>m.mutate({printerId:S,typeId:A}),onRemoveItem:S=>g.mutate(S)})]})}const qG=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function gre({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||qG[0]),[d,f]=w.useState(t?.target_count?.toString()||""),[m,g]=w.useState(t?.target_parts_count?.toString()||""),[x,y]=w.useState(t?.status||"active"),[b,v]=w.useState(t?.tags||""),[M,S]=w.useState(t?.due_date?.split("T")[0]||""),[A,E]=w.useState(t?.priority||"normal"),k=C=>{C.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:M||void 0,priority:A,...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:k,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:C=>a(C.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"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:C=>l(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 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:qG.map(C=>s.jsx("button",{type:"button",onClick:()=>u(C),className:`w-8 h-8 rounded-full transition-transform ${c===C?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:C}},C))})]}),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:C=>f(C.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"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:C=>g(C.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"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:C=>v(C.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"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:M,onChange:C=>S(C.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:A,onChange:C=>E(C.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:C=>y(C.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(Se,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Se,{type:"submit",disabled:!i.trim()||r,children:r?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function yKe({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:E2,color:"text-bambu-green",bg:"bg-bambu-green/10"}:l?{icon:Ha,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:Gn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:ba,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),g=[...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 g.length===0&&y.length===0?null:s.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[g.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(wd,{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(wf,{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(an,{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(Ha,{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(Cn,{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(Gn,{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:pe.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(Dl,{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(Cn,{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(nl,{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(Dl,{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(Cn,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.failed_count})]}),t.queue_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-400",title:"In queue",children:[s.jsx(Bj,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.queue_count})]})]}),s.jsx(Gs,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function vKe(){const t=ol(),e=tn(),{showToast:n}=$n(),[r,i]=w.useState(!1),[a,o]=w.useState(),[l,c]=w.useState("active"),[u,d]=w.useState(null),{data:f,isLoading:m}=ct({queryKey:["projects",l==="all"?void 0:l],queryFn:()=>pe.getProjects(l==="all"?void 0:l)}),g=ft({mutationFn:k=>pe.createProject(k),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),n("Project created","success")},onError:k=>{n(k.message,"error")}}),x=ft({mutationFn:({id:k,data:C})=>pe.updateProject(k,C),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),o(void 0),n("Project updated","success")},onError:k=>{n(k.message,"error")}}),y=ft({mutationFn:k=>pe.deleteProject(k),onSuccess:()=>{d(null),n("Project deleted","success"),setTimeout(()=>window.location.reload(),100)},onError:k=>{d(null),n(k.message,"error")}}),b=k=>{a?x.mutate({id:a.id,data:k}):g.mutate(k)},v=k=>{o(k),i(!0)},M=k=>{t(`/projects/${k.id}`)},S=k=>{d(k)},A=()=>{u!==null&&y.mutate(u)},E=f?.reduce((k,C)=>(k[C.status]=(k[C.status]||0)+1,k.all=(k.all||0)+1,k),{})||{};return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[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(ba,{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(Se,{onClick:()=>i(!0),className:"sm:w-auto w-full",children:[s.jsx(Kn,{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:Gn},{key:"completed",label:"Completed",icon:E2},{key:"archived",label:"Archived",icon:Ha},{key:"all",label:"All",icon:ba}].map(({key:k,label:C,icon:R})=>s.jsxs("button",{onClick:()=>c(k),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${l===k?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[s.jsx(R,{className:"w-4 h-4"}),s.jsx("span",{children:C}),E[k]>0&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${l===k?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:E[k]})]},k))}),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(mt,{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(ba,{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(Se,{onClick:()=>i(!0),children:[s.jsx(Kn,{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(k=>s.jsx(yKe,{project:k,onClick:()=>M(k),onEdit:()=>v(k),onDelete:()=>S(k.id)},k.id))}),u!==null&&s.jsx(Ln,{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:A,onCancel:()=>d(null)}),r&&s.jsx(gre,{project:a,onClose:()=>{i(!1),o(void 0)},onSave:b,isLoading:g.isPending||x.isPending})]})}function _Ke(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 wKe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function SKe({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 KG({icon:t,label:e,value:n,subValue:r,hint:i,color:a="text-bambu-gray"}){return s.jsx(Mt,{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 MKe({archives:t}){return t.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Dl,{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(ls,{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:pe.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(Dl,{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(qi,{className:"w-8 h-8 text-white"})}),e.status==="completed"&&s.jsx("div",{className:"absolute top-1 right-1",children:s.jsx(Dn,{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 NKe({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(Cn,{className:"w-3 h-3"}),r]})}function EKe(t){return t?Jp(t,{year:"numeric",month:"short",day:"numeric"}):""}function vj(t){if(!t)return null;const e=mi(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 AKe(){const{id:t}=HR(),e=ol(),n=tn(),{showToast:r}=$n(),[i,a]=w.useState(!1),[o,l]=w.useState(!1),[c,u]=w.useState(""),d=parseInt(t||"0",10),{data:f,isLoading:m,error:g}=ct({queryKey:["project",d],queryFn:()=>pe.getProject(d),enabled:d>0}),{data:x,isLoading:y}=ct({queryKey:["project-archives",d],queryFn:()=>pe.getProjectArchives(d),enabled:d>0}),{data:b,isLoading:v}=ct({queryKey:["project-bom",d],queryFn:()=>pe.getProjectBOM(d),enabled:d>0}),{data:M,isLoading:S}=ct({queryKey:["project-timeline",d],queryFn:()=>pe.getProjectTimeline(d,20),enabled:d>0}),{data:A}=ct({queryKey:["settings"],queryFn:pe.getSettings}),{data:E}=ct({queryKey:["project-folders",d],queryFn:()=>pe.getLibraryFoldersByProject(d),enabled:d>0}),k=A?.currency||"$",C=A?.time_format||"system",R=ft({mutationFn:Q=>pe.updateProject(d,Q),onSuccess:()=>{n.invalidateQueries({queryKey:["project",d]}),n.invalidateQueries({queryKey:["projects"]}),a(!1),l(!1),r("Project updated","success")},onError:Q=>{r(Q.message,"error")}}),T=()=>{u(f?.notes||""),l(!0)},P=()=>{R.mutate({notes:c})},F=()=>{l(!1),u("")},[L,X]=w.useState(""),[D,K]=w.useState(1),[Y,q]=w.useState(""),[Z,re]=w.useState(""),[oe,B]=w.useState(""),[G,J]=w.useState(!1),[te,ae]=w.useState(!1),[de,fe]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),Ae=ft({mutationFn:Q=>pe.createBOMItem(d,Q),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),X(""),K(1),q(""),re(""),B(""),J(!1),r("Part added","success")},onError:Q=>r(Q.message,"error")}),ge=ft({mutationFn:({itemId:Q,data:Ee})=>pe.updateBOMItem(d,Q,Ee),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]})},onError:Q=>r(Q.message,"error")}),Me=ft({mutationFn:Q=>pe.deleteBOMItem(d,Q),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),r("Part removed","success")},onError:Q=>r(Q.message,"error")}),je=Q=>{Q.preventDefault(),L.trim()&&Ae.mutate({name:L.trim(),quantity_needed:D,unit_price:Y?parseFloat(Y):void 0,sourcing_url:Z.trim()||void 0,remarks:oe.trim()||void 0})},ne=Q=>{const Ee=Q.is_complete?0:Q.quantity_needed;ge.mutate({itemId:Q.id,data:{quantity_acquired:Ee}})},Ke=(Q,Ee)=>{fe({isOpen:!0,title:"Delete Part",message:`Are you sure you want to delete "${Ee}"?`,onConfirm:()=>{fe(Ce=>({...Ce,isOpen:!1})),Me.mutate(Q)}})},$=ft({mutationFn:()=>pe.createTemplateFromProject(d),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r("Template created","success")},onError:Q=>r(Q.message,"error")}),z=Q=>eg(Q,C,{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(mt,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(g||!f)return s.jsxs("div",{className:"text-center py-24",children:[s.jsx("p",{className:"text-bambu-gray",children:g?`Error: ${g.message}`:"Project not found"}),s.jsx(Se,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:"Back to Projects"})]});const W=f.stats,U=W?.progress_percent??0,V=W?.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(ls,{to:"/projects",className:"hover:text-white transition-colors",children:"Projects"}),s.jsx(Gs,{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(BW,{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(SKe,{status:f.status})]}),s.jsxs(Se,{onClick:()=>a(!0),children:[s.jsx(wf,{className:"w-4 h-4 mr-2"}),"Edit"]})]}),(f.target_count||f.target_parts_count)&&s.jsx(Mt,{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:[W?.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(U,100)}%`,backgroundColor:U>=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:[U.toFixed(0),"% complete"]}),W?.remaining_prints!=null&&W.remaining_prints>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[W.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:[W?.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(V,100)}%`,backgroundColor:V>=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:[V.toFixed(0),"% complete"]}),W?.remaining_parts!=null&&W.remaining_parts>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[W.remaining_parts," remaining"]})]})]})]})}),W&&s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(Mt,{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(Dl,{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:[W.total_archives," ",s.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:"total"})]}),W.failed_prints>0&&s.jsxs("p",{className:"text-sm text-red-400",children:[W.failed_prints," failed"]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[W.completed_prints," parts printed"]})]})]})})}),s.jsx(KG,{icon:Gn,label:"Print Time",value:_Ke(W.total_print_time_hours),color:"text-yellow-400"}),s.jsx(KG,{icon:Ir,label:"Filament Used",value:wKe(W.total_filament_grams),color:"text-purple-400"})]}),W&&(W.estimated_cost>0||f.budget)&&s.jsx(Mt,{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:[k,W.estimated_cost.toFixed(2)]})]}),W.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:[W.total_energy_kwh.toFixed(2)," kWh",W.total_energy_cost>0&&s.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",k,W.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:[k,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-W.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[k,(f.budget-W.estimated_cost).toFixed(2)]})]})]})]})]})}),f.children&&f.children.length>0&&s.jsx(Mt,{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(vue,{className:"w-5 h-5"}),"Sub-projects (",f.children.length,")"]}),s.jsx("div",{className:"space-y-2",children:f.children.map(Q=>s.jsxs(ls,{to:`/projects/${Q.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:Q.color||"#6b7280"}}),s.jsx("span",{className:"text-white",children:Q.name}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Q.status==="completed"?"bg-bambu-green/20 text-bambu-green":Q.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:Q.status})]}),Q.progress_percent!==null&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[Q.progress_percent.toFixed(0),"%"]})]},Q.id))})]})}),f.parent_id&&f.parent_name&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(nl,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-bambu-gray",children:"Part of:"}),s.jsx(ls,{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(NKe,{priority:f.priority})]}),f.due_date&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qr,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-white",children:EKe(f.due_date)}),vj(f.due_date)&&s.jsxs("span",{className:`text-xs ${vj(f.due_date).color}`,children:["(",vj(f.due_date).label,")"]})]}),f.tags&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Zp,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:f.tags.split(",").map((Q,Ee)=>s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:Q.trim()},Ee))})]})]}),s.jsx(Mt,{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(za,{className:"w-5 h-5"}),"Notes"]}),o?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Se,{variant:"secondary",size:"sm",onClick:F,disabled:R.isPending,children:[s.jsx(Ut,{className:"w-4 h-4 mr-1"}),"Cancel"]}),s.jsxs(Se,{size:"sm",onClick:P,disabled:R.isPending,children:[R.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin mr-1"}):s.jsx(ds,{className:"w-4 h-4 mr-1"}),"Save"]})]}):s.jsxs(Se,{variant:"secondary",size:"sm",onClick:T,children:[s.jsx(wf,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),o?s.jsx(kR,{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(Mt,{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(el,{className:"w-5 h-5"}),"Files"]})}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[s.jsx(ls,{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(Q=>s.jsxs(ls,{to:`/files?folder=${Q.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(el,{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:Q.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[Q.file_count," file",Q.file_count!==1?"s":""]})]})]}),s.jsx(Gs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},Q.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(Mt,{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(eq,{className:"w-5 h-5"}),"Bill of Materials",W&&W.bom_total_items>0&&s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",W.bom_completed_items,"/",W.bom_total_items," acquired)"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[b&&b.some(Q=>Q.is_complete)&&s.jsx("button",{onClick:()=>ae(!te),className:`text-xs px-2 py-1 rounded transition-colors ${te?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:te?"Show all":"Hide done"}),!G&&s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>J(!0),children:[s.jsx(Kn,{className:"w-4 h-4 mr-1"}),"Add Part"]})]})]}),G&&s.jsxs("form",{onSubmit:je,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:Q=>X(Q.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:D,onChange:Q=>K(parseInt(Q.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:Q=>q(Q.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 (${k})`})]})]}),s.jsx("input",{type:"url",value:Z,onChange:Q=>re(Q.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:oe,onChange:Q=>B(Q.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(Se,{type:"button",variant:"secondary",size:"sm",onClick:()=>J(!1),children:"Cancel"}),s.jsx(Se,{type:"submit",size:"sm",disabled:!L.trim()||Ae.isPending,children:Ae.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):"Add Part"})]})]}),v?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(mt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):b&&b.length>0?s.jsxs("div",{className:"space-y-2",children:[b.filter(Q=>!te||!Q.is_complete).map(Q=>s.jsx("div",{className:`p-3 rounded-lg transition-colors ${Q.is_complete?"bg-bambu-green/10":"bg-bambu-dark"}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>ne(Q),disabled:ge.isPending,className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${Q.is_complete?"bg-bambu-green border-bambu-green text-white":"border-bambu-gray hover:border-bambu-green"}`,children:Q.is_complete&&s.jsx(Dn,{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 ${Q.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[Q.name,s.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",Q.quantity_needed]})]}),Q.unit_price!==null&&s.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[k,(Q.unit_price*Q.quantity_needed).toFixed(2)]})]}),s.jsx("button",{onClick:()=>Ke(Q.id,Q.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(an,{className:"w-4 h-4"})})]}),Q.sourcing_url&&s.jsxs("a",{href:Q.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:Ee=>Ee.stopPropagation(),children:[s.jsx(Lr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:(()=>{try{return new URL(Q.sourcing_url).hostname.replace("www.","")}catch{return Q.sourcing_url}})()})]}),Q.remarks&&s.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:Q.remarks})]})]})},Q.id)),b.some(Q=>Q.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:[k,b.reduce((Q,Ee)=>Q+(Ee.unit_price||0)*Ee.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(Mt,{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(hw,{className:"w-5 h-5"}),"Activity Timeline"]})}),S?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(mt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):M&&M.length>0?s.jsx("div",{className:"space-y-3",children:M.slice(0,10).map((Q,Ee)=>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 ${Q.event_type==="print_completed"?"bg-bambu-green/20 text-bambu-green":Q.event_type==="print_failed"?"bg-red-500/20 text-red-400":Q.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[Q.event_type==="print_completed"&&s.jsx(Dn,{className:"w-4 h-4"}),Q.event_type==="print_failed"&&s.jsx(qi,{className:"w-4 h-4"}),Q.event_type==="print_started"&&s.jsx(Ir,{className:"w-4 h-4"}),Q.event_type==="queued"&&s.jsx(Bj,{className:"w-4 h-4"}),Q.event_type==="project_created"&&s.jsx(Kn,{className:"w-4 h-4"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white",children:Q.title}),Q.description&&s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:Q.description}),s.jsx("p",{className:"text-xs text-bambu-gray/70",children:z(Q.timestamp)})]})]},Ee))}):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(Se,{variant:"secondary",size:"sm",onClick:()=>$.mutate(),disabled:$.isPending,children:[$.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(Jo,{className:"w-4 h-4 mr-2"}),"Save as Template"]})}),W&&(W.queued_prints>0||W.in_progress_prints>0)&&s.jsx(Mt,{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(Bj,{className:"w-5 h-5"}),"Queue"]}),s.jsx(ls,{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:[W.in_progress_prints>0&&s.jsxs("span",{className:"text-yellow-400",children:[W.in_progress_prints," printing"]}),W.queued_prints>0&&s.jsxs("span",{className:"text-bambu-gray",children:[W.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(Dl,{className:"w-5 h-5"}),"Prints (",x?.length||0,")"]})}),y?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(mt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):s.jsx(MKe,{archives:x||[]})]}),i&&s.jsx(gre,{project:{...f,archive_count:W?.total_archives||0,total_items:W?.total_items||0,completed_count:W?.completed_prints||0,failed_count:W?.failed_prints||0,queue_count:W?.queued_prints||0,progress_percent:W?.progress_percent||null,archives:[]},onClose:()=>a(!1),onSave:Q=>R.mutate(Q),isLoading:R.isPending}),de.isOpen&&s.jsx(Ln,{title:de.title,message:de.message,confirmText:"Delete",variant:"danger",onConfirm:de.onConfirm,onCancel:()=>fe(Q=>({...Q,isOpen:!1}))})]})}function Ep(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 TKe(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 CKe({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(Se,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Se,{type:"submit",disabled:!i.trim()||r,children:r?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):"Create"})]})]})]})})}function kKe({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(Se,{type:"button",variant:"secondary",onClick:n,children:"Cancel"}),s.jsx(Se,{type:"submit",disabled:!a.trim()||a.trim()===e||i,children:i?s.jsx(mt,{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 g of d)m.push({id:g.id,name:g.name,depth:f}),g.children.length>0&&m.push(...c(g.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(el,{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(Se,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),s.jsx(Se,{onClick:()=>i(o),disabled:a,children:a?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):"Move"})]})]})]})})}function PKe({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}=ct({queryKey:["projects"],queryFn:()=>pe.getProjects()}),{data:u}=ct({queryKey:["archives-for-link"],queryFn:()=>pe.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(kl,{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(Ut,{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(HW,{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(Ha,{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(g=>s.jsxs("button",{onClick:()=>l(g.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===g.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:g.color||"#00ae42"}}),s.jsx("span",{className:"truncate",children:g.name})]},g.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:"No projects found"}):u&&u.length>0?u.map(g=>s.jsxs("button",{onClick:()=>l(g.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===g.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[s.jsx(nf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:g.print_name||g.filename})]},g.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(Se,{variant:"danger",onClick:f,disabled:r,children:[s.jsx(aD,{className:"w-4 h-4 mr-2"}),"Unlink"]}),s.jsxs("div",{className:`flex gap-2 ${m?"":"ml-auto"}`,children:[s.jsx(Se,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Se,{onClick:d,disabled:!o||r,children:r?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):"Link"})]})]})]})})}function RKe({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=w.useRef(null),m=R=>{R.preventDefault(),o(!0)},g=R=>{R.preventDefault(),o(!1)},x=R=>{R.preventDefault(),o(!1);const T=Array.from(R.dataTransfer.files);b(T)},y=R=>{R.target.files&&b(Array.from(R.target.files))},b=R=>{const T=R.map(P=>({file:P,status:"pending",isZip:P.name.toLowerCase().endsWith(".zip")}));i(P=>[...P,...T])},v=R=>{i(T=>T.filter((P,F)=>F!==R))},M=r.some(R=>R.isZip&&R.status==="pending"),S=async()=>{if(r.length!==0){c(!0);for(let R=0;R<r.length;R++)if(r[R].status==="pending"){i(T=>T.map((P,F)=>F===R?{...P,status:"uploading"}:P));try{if(r[R].isZip){const T=await pe.extractZipFile(r[R].file,t,u);i(P=>P.map((F,L)=>L===R?{...F,status:T.errors.length>0&&T.extracted===0?"error":"success",extractedCount:T.extracted,error:T.errors.length>0?`${T.errors.length} files failed`:void 0}:F))}else await pe.uploadLibraryFile(r[R].file,t),i(T=>T.map((P,F)=>F===R?{...P,status:"success"}:P))}catch(T){i(P=>P.map((F,L)=>L===R?{...F,status:"error",error:T instanceof Error?T.message:"Upload failed"}:F))}}c(!1),n(),e()}},A=r.filter(R=>R.status==="pending").length,E=r.filter(R=>R.status==="success").length,k=r.filter(R=>R.status==="error").length,C=r.length>0&&A===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(Ut,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{onDragOver:m,onDragLeave:g,onDrop:x,onClick:()=>f.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(bi,{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:"ZIP files will be automatically extracted"})]}),s.jsx("input",{ref:f,type:"file",multiple:!0,accept:"*/*,.zip",className:"hidden",onChange:y}),M&&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(Ha,{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"})]})]})]})}),r.length>0&&s.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:r.map((R,T)=>s.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[R.isZip?s.jsx(Ha,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):s.jsx(C2,{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:()=>v(T),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Ut,{className:"w-4 h-4 text-bambu-gray"})}),R.status==="uploading"&&s.jsx(mt,{className:"w-4 h-4 text-bambu-green animate-spin"}),R.status==="success"&&s.jsx(Dn,{className:"w-4 h-4 text-green-500"}),R.status==="error"&&s.jsx("span",{title:R.error,children:s.jsx(qi,{className:"w-4 h-4 text-red-500"})})]},T))}),C&&s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:["Upload complete: ",E," succeeded",k>0&&s.jsxs("span",{className:"text-red-400",children:[", ",k," failed"]})]})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[s.jsx(Se,{variant:"secondary",onClick:e,children:C?"Close":"Cancel"}),!C&&s.jsx(Se,{onClick:S,disabled:A===0||l,children:l?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 mr-2 animate-spin"}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(bi,{className:"w-4 h-4 mr-2"}),"Upload ",A>0?`(${A})`:""]})})]})]})})}function xre({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o=0}){const[l,c]=w.useState(!0),[u,d]=w.useState(!1),f=t.children.length>0,m=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:[f?s.jsx("button",{onClick:g=>{g.stopPropagation(),c(!l)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Gs,{className:`w-3.5 h-3.5 transition-transform ${l?"rotate-90":""}`})}):s.jsx("div",{className:"w-4.5"}),s.jsx(el,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),s.jsx("span",{className:"text-sm truncate flex-1",children:t.name}),m&&s.jsxs("button",{onClick:g=>{g.stopPropagation(),i(t)},className:"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(kl,{className:"w-3 h-3"}),t.project_name?s.jsx(HW,{className:"w-3 h-3"}):s.jsx(Ha,{className:"w-3 h-3"})]}),t.file_count>0&&s.jsx("span",{className:"text-xs text-bambu-gray",children:t.file_count}),!m&&s.jsx("button",{onClick:g=>{g.stopPropagation(),i(t)},className:"p-1 rounded hover:bg-bambu-dark-tertiary",title:"Link to project or archive",children:s.jsx(kl,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),s.jsx("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:g=>g.stopPropagation(),children:s.jsxs("div",{className:"relative",children:[s.jsx("button",{onClick:()=>d(!u),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:s.jsx(wd,{className:"w-3.5 h-3.5 text-bambu-gray"})}),u&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>d(!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),d(!1)},children:[s.jsx(Ga,{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),d(!1)},children:[s.jsx(kl,{className:"w-3.5 h-3.5"}),m?"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),d(!1)},children:[s.jsx(an,{className:"w-3.5 h-3.5"}),"Delete"]})]})]})]})})]}),f&&l&&s.jsx("div",{children:t.children.map(g=>s.jsx(xre,{folder:g,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o+1},g.id))})]})}function FR(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function DKe({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:pe.getLibraryFileThumbnailUrl(t.id),alt:t.filename,className:"w-full h-full object-cover"}):s.jsx(nf,{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:Ep(t.file_size)}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Gn,{className:"w-3 h-3"}),TKe(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(wd,{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&&FR(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(Ir,{className:"w-3.5 h-3.5"}),"Print"]}),a&&FR(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(Gn,{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(Jr,{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(Ga,{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(an,{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 OKe(){const t=tn(),{showToast:e}=$n(),[n]=wW(),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),[g,x]=w.useState(!1),[y,b]=w.useState(null),[v,M]=w.useState(null),[S,A]=w.useState(null),[E,k]=w.useState(null),[C,R]=w.useState(null),[T,P]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[F,L]=w.useState(""),[X,D]=w.useState("all"),[K,Y]=w.useState("date"),[q,Z]=w.useState("desc");w.useEffect(()=>{const le=n.get("folder");if(le){const ke=parseInt(le,10);o(ke)}},[n]);const{data:re}=ct({queryKey:["settings"],queryFn:()=>pe.getSettings()}),{data:oe,isLoading:B}=ct({queryKey:["library-folders"],queryFn:()=>pe.getLibraryFolders()}),{data:G,isLoading:J}=ct({queryKey:["library-files",a],queryFn:()=>pe.getLibraryFiles(a,a===null)}),{data:te}=ct({queryKey:["library-stats"],queryFn:()=>pe.getLibraryStats()}),ae=w.useMemo(()=>{if(!G)return[];const le=new Set(G.map(ke=>ke.file_type));return Array.from(le).sort()},[G]),de=w.useMemo(()=>{if(!G)return[];let le=[...G];if(F.trim()){const ke=F.toLowerCase();le=le.filter(Oe=>Oe.filename.toLowerCase().includes(ke)||Oe.print_name&&Oe.print_name.toLowerCase().includes(ke))}return X!=="all"&&(le=le.filter(ke=>ke.file_type===X)),le.sort((ke,Oe)=>{let Ze=0;switch(K){case"name":Ze=(ke.print_name||ke.filename).localeCompare(Oe.print_name||Oe.filename);break;case"date":Ze=new Date(ke.created_at).getTime()-new Date(Oe.created_at).getTime();break;case"size":Ze=ke.file_size-Oe.file_size;break;case"type":Ze=ke.file_type.localeCompare(Oe.file_type);break;case"prints":Ze=ke.print_count-Oe.print_count;break}return q==="asc"?Ze:-Ze}),le},[G,F,X,K,q]),fe=w.useMemo(()=>{if(!te||!re)return!1;const le=(re.library_disk_warning_gb||5)*1024*1024*1024;return te.disk_free_bytes<le},[te,re]),Ae=ft({mutationFn:le=>pe.createLibraryFolder(le),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),d(!1),e("Folder created","success")},onError:le=>e(le.message,"error")}),ge=ft({mutationFn:le=>pe.deleteLibraryFolder(le),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-stats"]}),a===v?.id&&o(null),M(null),e("Folder deleted","success")},onError:le=>{M(null),e(le.message,"error")}}),Me=ft({mutationFn:le=>pe.deleteLibraryFile(le),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),c(le=>le.filter(ke=>ke!==v?.id)),M(null),e("File deleted","success")},onError:le=>{M(null),e(le.message,"error")}}),je=ft({mutationFn:le=>pe.bulkDeleteLibrary(le,[]),onSuccess:(le,ke)=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),e(`Deleted ${ke.length} files`,"success"),c([]),M(null)},onError:le=>{M(null),e(le.message,"error")}}),ne=ft({mutationFn:({fileIds:le,folderId:ke})=>pe.moveLibraryFiles(le,ke),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),c([]),m(!1),e("Files moved","success")},onError:le=>e(le.message,"error")}),Ke=ft({mutationFn:({id:le,data:ke})=>pe.updateLibraryFolder(le,ke),onSuccess:(le,ke)=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["project-folders"]}),t.invalidateQueries({queryKey:["archive-folders"]}),b(null);const Oe=ke.data.project_id===0&&ke.data.archive_id===0;e(Oe?"Folder unlinked":"Folder linked","success")},onError:le=>e(le.message,"error")}),$=ft({mutationFn:le=>pe.addLibraryFilesToQueue(le),onSuccess:le=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["queue"]}),t.invalidateQueries({queryKey:["archives"]}),c([]),le.added.length>0&&le.errors.length===0?e(`Added ${le.added.length} file${le.added.length>1?"s":""} to queue`,"success"):le.added.length>0&&le.errors.length>0?e(`Added ${le.added.length} file${le.added.length>1?"s":""}, ${le.errors.length} failed`,"success"):e(`Failed to add files: ${le.errors[0]?.error||"Unknown error"}`,"error")},onError:le=>e(le.message,"error")}),z=ft({mutationFn:({id:le,filename:ke})=>pe.updateLibraryFile(le,{filename:ke}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),R(null),e("File renamed","success")},onError:le=>{R(null),e(le.message,"error")}}),W=ft({mutationFn:({id:le,name:ke})=>pe.updateLibraryFolder(le,{name:ke}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),R(null),e("Folder renamed","success")},onError:le=>{R(null),e(le.message,"error")}}),U=w.useCallback(le=>{const ke=le.toLowerCase();return ke.endsWith(".gcode")||ke.includes(".gcode.")},[]),V=w.useMemo(()=>G?G.filter(le=>l.includes(le.id)&&U(le.filename)):[],[G,l,U]),Q=w.useCallback(le=>{c(ke=>ke.includes(le)?ke.filter(Oe=>Oe!==le):[...ke,le])},[]),Ee=w.useCallback(()=>{de.length>0&&c(de.map(le=>le.id))},[de]),Ce=w.useCallback(()=>{c([])},[]),Ne=()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]})},H=le=>{window.open(pe.getLibraryFileDownloadUrl(le),"_blank")},O=()=>{v&&(v.type==="file"?Me.mutate(v.id):v.type==="folder"?ge.mutate(v.id):v.type==="bulk"&&je.mutate(l))},ie=ge.isPending||Me.isPending||je.isPending,ye=le=>{P(le),localStorage.setItem("library-view-mode",le)},_e=B||J;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(el,{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 ${T==="grid"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"Grid view",children:s.jsx(D2,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>ye("list"),className:`p-1.5 rounded transition-colors ${T==="list"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"List view",children:s.jsx(O2,{className:"w-4 h-4"})})]}),s.jsxs(Se,{variant:"secondary",onClick:()=>d(!0),children:[s.jsx(bue,{className:"w-4 h-4 mr-2"}),"New Folder"]}),s.jsxs(Se,{onClick:()=>x(!0),children:[s.jsx(bi,{className:"w-4 h-4 mr-2"}),"Upload"]})]})]}),fe&&te&&re&&s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[s.jsx(Cn,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-amber-500 font-medium",children:"Low disk space warning"}),s.jsxs("p",{className:"text-xs text-amber-500/80",children:["Only ",Ep(te.disk_free_bytes)," free of ",Ep(te.disk_total_bytes)," total. Threshold is set to ",re.library_disk_warning_gb," GB in settings."]})]})]}),te&&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(C2,{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:te.total_files})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(el,{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:te.total_folders})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(P2,{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:Ep(te.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 ${fe?"text-amber-500":"text-white"}`,children:Ep(te.disk_free_bytes)})]})]}),s.jsxs("div",{className:"flex-1 flex gap-6 min-h-0",children:[s.jsxs("div",{className:"w-64 flex-shrink-0 bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden flex flex-col",children:[s.jsx("div",{className:"p-3 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-sm font-medium text-white",children:"Folders"})}),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(nf,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm",children:"All Files"})]}),oe?.map(le=>s.jsx(xre,{folder:le,selectedFolderId:a,onSelect:o,onDelete:ke=>M({type:"folder",id:ke}),onLink:b,onRename:ke=>R({type:"folder",id:ke.id,name:ke.name})},le.id))]})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[G&&G.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(xa,{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:F,onChange:le=>L(le.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(k2,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("select",{value:X,onChange:le=>D(le.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"}),ae.map(le=>s.jsx("option",{value:le,children:le.toUpperCase()},le))]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:K,onChange:le=>Y(le.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:()=>Z(le=>le==="asc"?"desc":"asc"),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:q==="asc"?"Ascending":"Descending",children:q==="asc"?s.jsx(Zle,{className:"w-4 h-4 text-white"}):s.jsx(Wle,{className:"w-4 h-4 text-white"})})]}),(F||X!=="all")&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[de.length," of ",G.length," files"]})]}),de.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===de.length&&l.length>0?s.jsxs(Se,{variant:"secondary",size:"sm",onClick:Ce,children:[s.jsx(Ol,{className:"w-4 h-4 mr-1"}),"Deselect All"]}):s.jsxs(Se,{variant:"secondary",size:"sm",onClick:Ee,children:[s.jsx(eu,{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"}),V.length===1&&s.jsxs(Se,{variant:"primary",size:"sm",onClick:()=>k(V[0]),children:[s.jsx(rl,{className:"w-4 h-4 mr-1"}),"Print"]}),V.length>0&&s.jsxs(Se,{variant:V.length===1?"secondary":"primary",size:"sm",onClick:()=>$.mutate(V.map(le=>le.id)),disabled:$.isPending,children:[s.jsx(Gn,{className:"w-4 h-4 mr-1"}),$.isPending?"Adding...":`Add to Queue${V.length<l.length?` (${V.length})`:""}`]}),s.jsxs(Se,{variant:"secondary",size:"sm",onClick:()=>m(!0),children:[s.jsx(Ede,{className:"w-4 h-4 mr-1"}),"Move"]}),s.jsxs(Se,{variant:"danger",size:"sm",onClick:()=>{l.length===1?M({type:"file",id:l[0]}):M({type:"bulk",id:0,count:l.length})},children:[s.jsx(an,{className:"w-4 h-4 mr-1"}),"Delete"]}),s.jsx(Se,{variant:"secondary",size:"sm",onClick:Ce,children:"Clear"})]})]}),_e?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(mt,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading files..."})]})}):G?.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(nf,{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(Se,{onClick:()=>x(!0),children:[s.jsx(Kn,{className:"w-4 h-4 mr-2"}),"Upload Files"]})]}):de.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(xa,{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(Se,{variant:"secondary",onClick:()=>{L(""),D("all")},children:"Clear filters"})]}):T==="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:de.map(le=>s.jsx(DKe,{file:le,isSelected:l.includes(le.id),onSelect:Q,onDelete:ke=>M({type:"file",id:ke}),onDownload:H,onAddToQueue:ke=>$.mutate([ke]),onPrint:A,onRename:ke=>R({type:"file",id:ke.id,name:ke.filename})},le.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",{})]}),de.map(le=>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(le.id)?"bg-bambu-green/10":""}`,onClick:()=>Q(le.id),children:[s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${l.includes(le.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:l.includes(le.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:le.thumbnail_path?s.jsx("img",{src:pe.getLibraryFileThumbnailUrl(le.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(nf,{className:"w-5 h-5 text-bambu-gray/50"})})}),le.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:pe.getLibraryFileThumbnailUrl(le.id),alt:le.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:le.print_name||le.filename})})]}),s.jsx("div",{children:s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${le.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":le.file_type==="gcode"?"bg-blue-500/20 text-blue-400":le.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:le.file_type.toUpperCase()})}),s.jsx("div",{className:"text-sm text-bambu-gray",children:Ep(le.file_size)}),s.jsx("div",{className:"text-sm text-bambu-gray",children:le.print_count>0?`${le.print_count}x`:"-"}),s.jsxs("div",{className:"flex items-center gap-1",onClick:ke=>ke.stopPropagation(),children:[FR(le.filename)&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>A(le),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green transition-colors",title:"Print",children:s.jsx(Ir,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>$.mutate([le.id]),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Add to Queue",disabled:$.isPending,children:s.jsx(Gn,{className:"w-4 h-4"})})]}),s.jsx("button",{onClick:()=>H(le.id),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Download",children:s.jsx(Jr,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>R({type:"file",id:le.id,name:le.filename}),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Rename",children:s.jsx(Ga,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>M({type:"file",id:le.id}),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",title:"Delete",children:s.jsx(an,{className:"w-4 h-4"})})]})]},le.id))]})})]})]}),u&&s.jsx(CKe,{parentId:a,onClose:()=>d(!1),onSave:le=>Ae.mutate(le),isLoading:Ae.isPending}),f&&oe&&s.jsx(jKe,{folders:oe,selectedFiles:l,currentFolderId:a,onClose:()=>m(!1),onMove:le=>ne.mutate({fileIds:l,folderId:le}),isLoading:ne.isPending}),g&&s.jsx(RKe,{folderId:a,onClose:()=>x(!1),onUploadComplete:Ne}),y&&s.jsx(PKe,{folder:y,onClose:()=>b(null),onLink:le=>Ke.mutate({id:y.id,data:le}),isLoading:Ke.isPending}),v&&s.jsx(Ln,{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:ie,loadingText:"Deleting...",onConfirm:O,onCancel:()=>M(null)}),S&&s.jsx(Wd,{mode:"reprint",libraryFileId:S.id,archiveName:S.print_name||S.filename,onClose:()=>A(null),onSuccess:()=>{A(null),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["archives"]})}}),E&&s.jsx(Wd,{mode:"reprint",libraryFileId:E.id,archiveName:E.print_name||E.filename,onClose:()=>k(null),onSuccess:()=>{k(null),c([]),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["archives"]})}}),C&&s.jsx(kKe,{type:C.type,currentName:C.name,onClose:()=>R(null),onSave:le=>{C.type==="file"?z.mutate({id:C.id,filename:le}):W.mutate({id:C.id,name:le})},isLoading:z.isPending||W.isPending})]})}const _j=5,LKe=2e3,IKe=3e4,FKe=5e3;function UKe(){const{printerId:t}=HR(),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,g]=w.useState(!1),[x,y]=w.useState(0),[b,v]=w.useState(!1),[M,S]=w.useState(0),[A,E]=w.useState(1),[k,C]=w.useState({x:0,y:0}),[R,T]=w.useState(!1),[P,F]=w.useState({x:0,y:0}),L=w.useRef(null),X=w.useRef(null),D=w.useRef(null),K=w.useRef(null),Y=w.useRef(null),{data:q}=ct({queryKey:["printer",e],queryFn:()=>pe.getPrinter(e),enabled:e>0});w.useEffect(()=>(q&&(document.title=`${q.name} - Camera`),()=>{document.title="Bambuddy"}),[q]);const Z=w.useRef(!1);w.useEffect(()=>{const z=`/api/v1/printers/${e}/camera/stop`;Z.current=!1;const W=()=>{e>0&&!Z.current&&(Z.current=!0,navigator.sendBeacon(z))},U=()=>{W()};window.addEventListener("beforeunload",U);const V=L.current;return()=>{window.removeEventListener("beforeunload",U),V&&(V.src=""),W()}},[e]),w.useEffect(()=>{if(o&&!d){const W=setTimeout(()=>{l(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(W)}},[n,o,c,d]),w.useEffect(()=>{const z=()=>{const W=!!document.fullscreenElement;g(W),E(1),C({x:0,y:0}),n==="stream"&&!d&&(L.current&&(L.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 W=()=>{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",W),()=>{clearTimeout(z),window.removeEventListener("resize",W)}},[]),w.useEffect(()=>()=>{D.current&&clearTimeout(D.current),K.current&&clearInterval(K.current),Y.current&&clearInterval(Y.current)},[]);const re=w.useCallback(()=>{if(x>=_j){v(!1),a(!0);return}const z=Math.min(LKe*Math.pow(2,x),IKe);v(!0),S(Math.ceil(z/1e3)),K.current=setInterval(()=>{S(W=>W<=1?(K.current&&clearInterval(K.current),0):W-1)},1e3),D.current=setTimeout(()=>{y(W=>W+1),v(!1),l(!0),a(!1),L.current&&(L.current.src=""),u(Date.now())},z)},[x]);w.useEffect(()=>{if(n!=="stream"||o||b||d){Y.current&&(clearInterval(Y.current),Y.current=null);return}return Y.current=setInterval(async()=>{try{const z=await fetch(`/api/v1/printers/${e}/camera/status`);if(z.ok){const W=await z.json();(W.stalled||!W.active&&!i)&&(console.log(`Stream issue detected: stalled=${W.stalled}, active=${W.active}, reconnecting...`),Y.current&&(clearInterval(Y.current),Y.current=null),l(!1),re())}}catch{}},FKe),()=>{Y.current&&(clearInterval(Y.current),Y.current=null)}},[n,o,i,b,d,e,re]);const oe=()=>{l(!1),n==="stream"&&x<_j?re():a(!0)},B=()=>{if(l(!1),a(!1),y(0),v(!1),D.current&&clearTimeout(D.current),K.current&&clearInterval(K.current),L.current&&!localStorage.getItem("cameraWindowState")){const z=L.current,W=z.naturalWidth,U=z.naturalHeight;if(W>0&&U>0){const Ee=window.outerWidth-window.innerWidth,Ce=window.outerHeight-window.innerHeight,Ne=W+16+Ee,H=U+45+16+Ce;try{window.resizeTo(Ne,H)}catch{}}}},G=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},J=z=>{n===z||d||(f(!0),l(!0),a(!1),y(0),v(!1),E(1),C({x:0,y:0}),D.current&&clearTimeout(D.current),K.current&&clearInterval(K.current),L.current&&(L.current.src=""),n==="stream"&&G(),setTimeout(()=>{r(z),u(Date.now()),f(!1)},100))},te=()=>{d||(f(!0),l(!0),a(!1),y(0),v(!1),D.current&&clearTimeout(D.current),K.current&&clearInterval(K.current),L.current&&(L.current.src=""),n==="stream"&&G(),setTimeout(()=>{u(Date.now()),f(!1)},100))},ae=()=>{X.current&&(document.fullscreenElement?document.exitFullscreen():X.current.requestFullscreen())},de=()=>{E(z=>Math.min(z+.5,4))},fe=()=>{E(z=>{const W=Math.max(z-.5,1);return W===1&&C({x:0,y:0}),W})},Ae=z=>{z.preventDefault(),z.deltaY<0?de():fe()},ge=z=>{A>1&&(z.preventDefault(),T(!0),F({x:z.clientX-k.x,y:z.clientY-k.y}))},Me=z=>{if(R&&A>1){const W=z.clientX-P.x,U=z.clientY-P.y,V=(A-1)*200;C({x:Math.max(-V,Math.min(V,W)),y:Math.max(-V,Math.min(V,U))})}},je=()=>{T(!1)},ne=()=>{E(1),C({x:0,y:0})},Ke=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,$=o||d||b;return e?s.jsxs("div",{ref:X,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(Xp,{className:"w-4 h-4"}),q?.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:()=>J("stream"),disabled:$,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:()=>J("snapshot"),disabled:$,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:te,disabled:$,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:s.jsx(yr,{className:`w-4 h-4 text-bambu-gray ${$?"animate-spin":""}`})}),s.jsx("button",{onClick:ae,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:m?"Exit fullscreen":"Fullscreen",children:m?s.jsx(QW,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(mde,{className:"w-4 h-4 text-bambu-gray"})})]})]}),s.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:Ae,onMouseMove:Me,onMouseUp:je,onMouseLeave:je,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(yr,{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(Pg,{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 ",M,"s... (attempt ",x+1,"/",_j,")"]}),s.jsx("button",{onClick:te,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(Cn,{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:te,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),s.jsx("img",{ref:L,src:Ke,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${A}) translate(${k.x/A}px, ${k.y/A}px)`,cursor:A>1?R?"grabbing":"grab":"default"},onError:Ke?oe:void 0,onLoad:Ke?B:void 0,onMouseDown:ge,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:A<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:s.jsx(lD,{className:"w-4 h-4 text-white"})}),s.jsxs("button",{onClick:ne,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:"Reset zoom",children:[Math.round(A*100),"%"]}),s.jsx("button",{onClick:de,disabled:A>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:s.jsx(oD,{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 zKe(){const{id:t}=HR(),{mode:e}=Xd(),{data:n,isLoading:r,error:i}=ct({queryKey:["external-link",t],queryFn:()=>pe.getExternalLink(Number(t)),enabled:!!t});return r?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(mt,{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(Cn,{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 XG=["DEBUG","INFO","WARNING","ERROR"],wj={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},BKe={DEBUG:N2,INFO:tl,WARNING:Cn,ERROR:ea};function $Ke(){const t=tn(),[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),g=w.useRef(null),{data:x,isLoading:y,refetch:b}=ct({queryKey:["application-logs",l,a],queryFn:()=>Op.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=ft({mutationFn:()=>Op.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});w.useEffect(()=>{e&&g.current&&x?.entries&&(g.current.scrollTop=g.current.scrollHeight)},[x?.entries,e]);const M=C=>{i(R=>{const T=new Set(R);return T.has(C)?T.delete(C):T.add(C),T})},S=C=>{const R=C.split(" ");return R.length>=2?R[1]:C},A=w.useMemo(()=>x?.entries??[],[x?.entries]),E=w.useMemo(()=>[...A].reverse(),[A]),k=({level:C})=>{const R=BKe[C]||tl;return s.jsx(R,{className:`w-3.5 h-3.5 ${wj[C]||"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(N2,{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(Jc,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(Ji,{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:C=>{C.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(Ol,{className:"w-4 h-4"}),"Stop"]}):s.jsxs("button",{onClick:C=>{C.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(rl,{className:"w-4 h-4"}),"Start"]}),s.jsxs("button",{onClick:()=>v.mutate(),disabled:v.isPending||A.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:[s.jsx(an,{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(yr,{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:C=>n(C.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(xa,{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:C=>o(C.target.value),className:"w-full pl-8 pr-8 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),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(Ut,{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"}),XG.map((C,R)=>s.jsx("button",{onClick:()=>c(C),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${R===XG.length-1?"rounded-r":""} ${l===C?`${wj[C]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:C},C))]})]})]}),s.jsx("div",{ref:g,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:A.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((C,R)=>{const T=r.has(R),P=C.message.includes(`
- `);return s.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${T?"bg-bambu-dark-secondary/30":""}`,onClick:()=>P&&M(R),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(C.timestamp)}),s.jsx("span",{className:"shrink-0",children:s.jsx(k,{level:C.level})}),s.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:C.logger_name,children:["[",C.logger_name,"]"]}),s.jsx("span",{className:`flex-1 ${wj[C.level]||"text-white/80"} ${!T&&P?"truncate":""}`,children:T?s.jsx("pre",{className:"whitespace-pre-wrap break-all",children:C.message}):C.message.split(`
- `)[0]}),P&&s.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:T?s.jsx(Jc,{className:"w-3.5 h-3.5"}):s.jsx(Ji,{className:"w-3.5 h-3.5"})})]})},R)})})}),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 HKe(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 qr({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 YG({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 ed({title:t,icon:e,children:n}){return s.jsxs(Mt,{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 VKe(){const{t}=Tg(),e=tn(),[n,r]=w.useState(null),[i,a]=w.useState(!1),[o,l]=w.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:f}=ct({queryKey:["systemInfo"],queryFn:pe.getSystemInfo,refetchInterval:3e4}),{data:m}=ct({queryKey:["debugLogging"],queryFn:Op.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:g}=ct({queryKey:["settings"],queryFn:pe.getSettings}),{data:x}=ct({queryKey:["library-stats"],queryFn:pe.getLibraryStats}),y=g?.time_format||"system",b=async()=>{l(!0);try{const A=await Op.setDebugLogging(!m?.enabled);e.setQueryData(["debugLogging"],A)}catch(A){console.error("Failed to toggle debug logging:",A)}finally{l(!1)}},v=async()=>{r(null),a(!0);try{await Op.downloadSupportBundle()}catch(A){r(A instanceof Error?A.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(mt,{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 M=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(yr,{className:`w-4 h-4 ${f?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),s.jsx(ed,{title:t("system.application","Application"),icon:Ph,children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(qr,{icon:Ph,label:t("system.version","Version"),value:`v${c.app.version}`}),s.jsx(qr,{icon:Gn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),s.jsx(qr,{icon:Ph,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),s.jsx(ed,{title:t("support.title","Support & Troubleshooting"),icon:Iue,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(N2,{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(mt,{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(Jr,{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(mt,{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($Ke,{})]})}),s.jsxs(ed,{title:t("system.database","Database"),icon:Yp,children:[s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[s.jsx(qr,{icon:Ha,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),s.jsx(qr,{icon:E2,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),s.jsx(qr,{icon:qi,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),s.jsx(qr,{icon:mt,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(qr,{icon:Ir,label:t("system.printers","Printers"),value:c.database.printers}),s.jsx(qr,{icon:nD,label:t("system.filaments","Filaments"),value:c.database.filaments}),s.jsx(qr,{icon:ba,label:t("system.projects","Projects"),value:c.database.projects}),s.jsx(qr,{icon:Us,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(qr,{icon:Gn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),s.jsx(qr,{icon:Ha,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),s.jsxs(ed,{title:t("system.connectedPrinters","Connected Printers"),icon:Ir,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(A=>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:A.name})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[s.jsx("span",{children:A.model}),s.jsx("span",{className:`px-2 py-0.5 rounded ${A.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":A.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:A.state})]})]},A.id))}):s.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),s.jsx(ed,{title:t("system.storage","Storage"),icon:P2,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(YG,{percent:c.storage.disk_percent_used,color:M}),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(qr,{icon:Ha,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),s.jsx(qr,{icon:Yp,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),x&&s.jsx(qr,{icon:el,label:t("system.fileManagerStorage","File Manager"),value:HKe(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(ed,{title:t("system.memory","Memory"),icon:gde,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(YG,{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(ed,{title:t("system.cpu","CPU"),icon:Xv,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(qr,{icon:Xv,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),s.jsx(qr,{icon:Xv,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),s.jsx(ed,{title:t("system.systemDetails","System Details"),icon:Ph,children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(qr,{icon:Ph,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),s.jsx(qr,{icon:Xv,label:t("system.architecture","Architecture"),value:c.system.architecture}),s.jsx(qr,{icon:Ph,label:t("system.python","Python"),value:c.system.python_version}),s.jsx(qr,{icon:Gn,label:t("system.bootTime","Boot Time"),value:eg(c.system.boot_time,y)})]})})]})}function GKe(){const t=ol(),{login:e}=Yd(),{showToast:n}=$n(),{mode:r}=Xd(),[i,a]=w.useState(""),[o,l]=w.useState(""),c=ft({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 WKe(){const t=ol(),{showToast:e}=$n(),{mode:n}=Xd(),{refreshAuth:r}=Yd(),[i,a]=w.useState(!1),[o,l]=w.useState(""),[c,u]=w.useState(""),[d,f]=w.useState(""),m=ft({mutationFn:()=>pe.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")}}),g=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:g,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(tl,{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 qKe(){const t=ol(),{user:e}=Yd(),{showToast:n}=$n(),r=tn(),[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=k=>{k.key==="Escape"&&i&&(a(!1),f({username:"",password:"",role:"user"}))};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[i]);const{data:m=[],isLoading:g}=ct({queryKey:["users"],queryFn:()=>pe.getUsers()}),x=ft({mutationFn:E=>pe.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=ft({mutationFn:({id:E,data:k})=>pe.updateUser(E,k),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),l(null),f({username:"",password:"",role:"user"}),n("User updated successfully")},onError:E=>{n(E.message,"error")}}),b=ft({mutationFn:E=>pe.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)},M=E=>{const k={username:d.username||void 0,password:d.password||void 0,role:d.role};k.password||delete k.password,y.mutate({id:E,data:k})},S=E=>{u(E)},A=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(Mt,{children:s.jsx(Et,{className:"py-6",children:s.jsxs("div",{className:"flex items-center gap-3 text-red-400",children:[s.jsx(P1,{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(BW,{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(Wh,{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(Se,{onClick:()=>{a(!0),f({username:"",password:"",role:"user"})},children:[s.jsx(Kn,{className:"w-4 h-4"}),"Create User"]})]}),g?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(mt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsx(Mt,{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:k=>f({...d,username:k.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:k=>f({...d,role:k.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(Se,{size:"sm",onClick:()=>M(E.id),disabled:y.isPending,children:[y.isPending?s.jsx(mt,{className:"w-4 h-4 animate-spin"}):s.jsx(ds,{className:"w-4 h-4"}),"Save"]}),s.jsx(Se,{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(Se,{size:"sm",variant:"ghost",onClick:()=>A(E),children:[s.jsx(L2,{className:"w-4 h-4"}),"Edit"]}),E.id!==e?.id&&s.jsxs(Se,{size:"sm",variant:"ghost",onClick:()=>S(E.id),children:[s.jsx(an,{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(Mt,{className:"w-full max-w-md",onClick:E=>E.stopPropagation(),children:[s.jsx(mr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Wh,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Create User"})]}),s.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:s.jsx(Ut,{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(Se,{variant:"secondary",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:"Cancel"}),s.jsx(Se,{onClick:v,disabled:x.isPending||!d.username||!d.password,children:x.isPending?s.jsxs(s.Fragment,{children:[s.jsx(mt,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Kn,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),c!==null&&s.jsx(Ln,{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 KKe(){const t=w.useRef(null),e=w.useRef(null),n=tn(),[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 M=()=>{const S=u.current.shift();S?requestAnimationFrame(()=>{f.current(S),u.current.length>0?setTimeout(M,16):d.current=!1}):d.current=!1};M()},[]),g=w.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const S=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,A=new WebSocket(S);let E=null;A.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),E=window.setInterval(()=>{A.readyState===WebSocket.OPEN&&A.send(JSON.stringify({type:"ping"}))},3e4)},A.onmessage=k=>{try{const C=JSON.parse(k.data);C.type==="printer_status"&&C.printer_id!==void 0&&C.data?f.current(C):(u.current.push(C),m())}catch{}},A.onclose=k=>{console.log("[WebSocket] Closed",k.code,k.reason),E&&(clearInterval(E),E=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{g()},3e3)},A.onerror=k=>{console.error("[WebSocket] Error",k),A.close()},t.current=A},[m]),x=w.useCallback((M,S)=>{const A=l.current.get(M)||{};l.current.set(M,{...A,...S}),c.current||(c.current=window.setTimeout(()=>{const E=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{E.forEach((k,C)=>{n.setQueryData(["printerStatus",C],R=>{const T={...R,...k};return T.wifi_signal==null&&R?.wifi_signal!=null&&(T.wifi_signal=R.wifi_signal),T})})})},100))},[n]),y=w.useCallback(M=>{a.current.add(M),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const S=Array.from(a.current);a.current.clear(),o.current=null;let A=0;S.forEach(E=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[E]})})},A),A+=500})},3e3)},[n]),b=w.useCallback(M=>{switch(M.type){case"printer_status":M.printer_id!==void 0&&M.data&&x(M.printer_id,M.data);break;case"print_start":M.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",M.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}},[n,y,x]);w.useEffect(()=>{f.current=b},[b]),w.useEffect(()=>(g(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[g]);const v=w.useCallback(M=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(M))},[]);return{isConnected:r,sendMessage:v}}const XKe=new jle({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function YKe({children:t}){return KKe(),s.jsx(s.Fragment,{children:t})}function QKe({children:t}){const{authEnabled:e,loading:n,user:r}=Yd();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?s.jsx(ow,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function ZKe({children:t}){const{authEnabled:e,loading:n,user:r}=Yd();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?r.role!=="admin"?s.jsx(ow,{to:"/",replace:!0}):s.jsx(s.Fragment,{children:t}):s.jsx(ow,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function JKe({children:t}){const{authEnabled:e,loading:n}=Yd();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?s.jsx(ow,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function eXe(){return s.jsx(Zhe,{children:s.jsx(dfe,{children:s.jsx(Ple,{client:XKe,children:s.jsx(rfe,{children:s.jsx(Zoe,{children:s.jsxs(Toe,{children:[s.jsx($i,{path:"/setup",element:s.jsx(JKe,{children:s.jsx(WKe,{})})}),s.jsx($i,{path:"/login",element:s.jsx(GKe,{})}),s.jsx($i,{path:"/camera/:printerId",element:s.jsx(UKe,{})}),s.jsxs($i,{element:s.jsx(QKe,{children:s.jsx(YKe,{children:s.jsx(ofe,{})})}),children:[s.jsx($i,{index:!0,element:s.jsx(Wke,{})}),s.jsx($i,{path:"archives",element:s.jsx(DGe,{})}),s.jsx($i,{path:"queue",element:s.jsx(bqe,{})}),s.jsx($i,{path:"stats",element:s.jsx(Pqe,{})}),s.jsx($i,{path:"profiles",element:s.jsx(fKe,{})}),s.jsx($i,{path:"maintenance",element:s.jsx(bKe,{})}),s.jsx($i,{path:"projects",element:s.jsx(vKe,{})}),s.jsx($i,{path:"projects/:id",element:s.jsx(AKe,{})}),s.jsx($i,{path:"files",element:s.jsx(OKe,{})}),s.jsx($i,{path:"settings",element:s.jsx(ZKe,{children:s.jsx(nKe,{})})}),s.jsx($i,{path:"users",element:s.jsx(qKe,{})}),s.jsx($i,{path:"system",element:s.jsx(VKe,{})}),s.jsx($i,{path:"external/:id",element:s.jsx(zKe,{})})]})]})})})})})})}Pae.createRoot(document.getElementById("root")).render(s.jsx(w.StrictMode,{children:s.jsx(eXe,{})}));
|