1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424 |
- var test=function(ar,X,M,q,Wp){"use strict";var HF=Object.defineProperty;var TM=Object.getOwnPropertySymbols;var $F=Object.prototype.hasOwnProperty,qF=Object.prototype.propertyIsEnumerable;var fx=Math.pow,EM=(ar,X,M)=>X in ar?HF(ar,X,{enumerable:!0,configurable:!0,writable:!0,value:M}):ar[X]=M,CM=(ar,X)=>{for(var M in X||(X={}))$F.call(X,M)&&EM(ar,M,X[M]);if(TM)for(var M of TM(X))qF.call(X,M)&&EM(ar,M,X[M]);return ar};var Qe=(ar,X,M)=>new Promise((q,Wp)=>{var jp=wa=>{try{Qa(M.next(wa))}catch(sh){Wp(sh)}},tc=wa=>{try{Qa(M.throw(wa))}catch(sh){Wp(sh)}},Qa=wa=>wa.done?q(wa.value):Promise.resolve(wa.value).then(jp,tc);Qa((M=M.apply(ar,X)).next())});var jp=document.createElement("style");jp.textContent=`.heading[data-v-2e0ffbfe]{font-size:1.5em;margin-bottom:12px}.card[data-v-2e0ffbfe]{background:#fff;color:#000;background-image:linear-gradient(48deg,#fff 0%,#e5efe9 100%);border-top-right-radius:16px;border-bottom-left-radius:16px;box-shadow:-20px 20px 35px 1px #0a31562e;display:flex;flex-direction:column;padding:32px;margin:40px;max-width:400px;width:100%}.content-wrapper[data-v-2e0ffbfe]{font-size:1.1em;margin-bottom:44px}.content-wrapper[data-v-2e0ffbfe]:last-child{margin-bottom:0}.button[data-v-2e0ffbfe]{align-items:center;background:#e5efe9;border:1px solid #5a72b5;border-radius:4px;color:#121943;cursor:pointer;display:flex;font-size:1em;font-weight:700;height:40px;justify-content:center;width:180px}.button[data-v-2e0ffbfe]:focus{border:2px solid transparent;box-shadow:0 0 0 2px #121943;outline:solid 4px transparent}.link[data-v-2e0ffbfe]{color:#121943}.link[data-v-2e0ffbfe]:focus{box-shadow:0 0 0 2px #121943}.input-wrapper[data-v-2e0ffbfe]{display:flex;flex-direction:column}.input-wrapper .label[data-v-2e0ffbfe]{align-items:baseline;display:flex;font-weight:700;justify-content:space-between;margin-bottom:8px}.input-wrapper .optional[data-v-2e0ffbfe]{color:#5a72b5;font-size:.9em}.input-wrapper .input[data-v-2e0ffbfe]{border:1px solid #5a72b5;border-radius:4px;height:40px;padding:8px}code[data-v-2e0ffbfe]{background:#e5efe9;border:1px solid #5a72b5;border-radius:4px;padding:2px 4px}.modal-header[data-v-2e0ffbfe]{align-items:baseline;display:flex;justify-content:space-between}.close[data-v-2e0ffbfe]{background:none;border:none;cursor:pointer;display:flex;height:16px;text-decoration:none;width:16px}.close svg[data-v-2e0ffbfe]{width:16px}.modal-wrapper[data-v-2e0ffbfe]{align-items:center;background:rgba(0,0,0,.7);display:flex;justify-content:center;inset:0;position:fixed}#modal[data-v-2e0ffbfe]{transition:opacity .25s ease-in-out}#modal .modal-body[data-v-2e0ffbfe]{max-width:830px;opacity:1;transform:translateY(-100px);transition:opacity .25s ease-in-out;width:100%;z-index:1}.outside-trigger[data-v-2e0ffbfe]{cursor:default;inset:0;position:fixed}.button__link[data-v-2e0ffbfe]{text-decoration:none}.button[data-v-2e0ffbfe]{background-color:#4caf50;border:none;color:#fff;text-align:center;text-decoration:none;display:inline-block;font-size:16px;margin:4px 2px;-webkit-transition-duration:.4s;transition-duration:.4s;cursor:pointer}.button1[data-v-2e0ffbfe]{background-color:#fff;color:#000;border:2px solid #4CAF50}.button1[data-v-2e0ffbfe]:hover{background-color:#4caf50;color:#fff}.button2[data-v-2e0ffbfe]{background-color:#fff;color:#000;border:2px solid #008CBA}.button2[data-v-2e0ffbfe]:hover{background-color:#008cba;color:#fff}.btn_box[data-v-2e0ffbfe]{width:100%;display:flex;justify-items:center;justify-content:start;align-items:start}.heading[data-v-6c1067c7]{font-size:1.5em;margin-bottom:12px}.btn[data-v-6c1067c7]{height:40px;width:100px;text-align:center;line-height:40px;font-size:16px;font-weight:700}.btn2[data-v-6c1067c7]{background-color:#008cba;color:#fff;border-top-right-radius:4px;border-top-left-radius:4px}.card[data-v-6c1067c7]{background:#fff;color:#000;background-image:linear-gradient(48deg,#fff 0%,#e5efe9 100%);border-top-right-radius:16px;border-bottom-left-radius:16px;box-shadow:-20px 20px 35px 1px #0a31562e;display:flex;flex-direction:column;padding:32px;margin:40px;max-width:400px;width:100%;height:600px}.content-wrapper[data-v-6c1067c7]{font-size:1.1em;margin-bottom:44px}.content-wrapper[data-v-6c1067c7]:last-child{margin-bottom:0}.button[data-v-6c1067c7]{align-items:center;background:#e5efe9;border:1px solid #5a72b5;border-radius:4px;color:#121943;cursor:pointer;display:flex;font-size:1em;font-weight:700;height:40px;justify-content:center;width:180px}.button[data-v-6c1067c7]:focus{border:2px solid transparent;box-shadow:0 0 0 2px #121943;outline:solid 4px transparent}.link[data-v-6c1067c7]{color:#121943}.link[data-v-6c1067c7]:focus{box-shadow:0 0 0 2px #121943}.input-wrapper[data-v-6c1067c7]{display:flex;flex-direction:column}.input-wrapper .label[data-v-6c1067c7]{align-items:baseline;display:flex;font-weight:700;justify-content:space-between;margin-bottom:8px}.input-wrapper .optional[data-v-6c1067c7]{color:#5a72b5;font-size:.9em}.input-wrapper .input[data-v-6c1067c7]{border:1px solid #5a72b5;border-radius:4px;height:40px;padding:8px}code[data-v-6c1067c7]{background:#e5efe9;border:1px solid #5a72b5;border-radius:4px;padding:2px 4px}.modal-header[data-v-6c1067c7]{align-items:baseline;display:flex;justify-content:space-between}.close[data-v-6c1067c7]{background:none;border:none;cursor:pointer;display:flex;height:16px;text-decoration:none;width:16px}.close svg[data-v-6c1067c7]{width:16px}.modal-wrapper[data-v-6c1067c7]{align-items:center;background:rgba(0,0,0,.7);display:flex;justify-content:center;inset:0;position:fixed}#modal[data-v-6c1067c7]{transition:opacity .25s ease-in-out}#modal .modal-body[data-v-6c1067c7]{max-width:830px;opacity:1;transform:translateY(-100px);transition:opacity .25s ease-in-out;width:100%;z-index:1}.outside-trigger[data-v-6c1067c7]{cursor:default;inset:0;position:fixed}.button__link[data-v-6c1067c7]{text-decoration:none}.button[data-v-6c1067c7]{background-color:#4caf50;border:none;color:#fff;text-align:center;text-decoration:none;display:inline-block;font-size:16px;margin:4px 2px;-webkit-transition-duration:.4s;transition-duration:.4s;cursor:pointer}.button1[data-v-6c1067c7]{background-color:#fff;color:#000;border:2px solid #4CAF50}.button1[data-v-6c1067c7]:hover{background-color:#4caf50;color:#fff}.button2[data-v-6c1067c7]{background-color:#fff;color:#000;border:2px solid #008CBA}.button2[data-v-6c1067c7]:hover{background-color:#008cba;color:#fff}.btn_box[data-v-6c1067c7]{width:100%;display:flex;justify-items:center;justify-content:start;align-items:start}.textBox[data-v-6c1067c7]{position:absolute;top:30%;left:42%;background-image:linear-gradient(48deg,#fff 0%,#e5efe9 100%);color:#000;padding:10px 15px}.textBox .header[data-v-6c1067c7]{display:flex;justify-content:space-between;align-items:center}.textBox textarea[data-v-6c1067c7]{color:#000;background-color:#ccc;border:1px solid #5a72b5;border-radius:8px;margin-top:10px;font-size:var(--mx-font-size);padding:5px}.textBox .btnBox[data-v-6c1067c7]{display:flex;justify-content:flex-end}.textBox .btnBox button[data-v-6c1067c7]{background-color:#fff;color:#000;border:2px solid #008CBA;border-radius:5px;padding:5px;margin-top:10px}.textBox .btnBox button[data-v-6c1067c7]:hover{background-color:#008cba;color:#fff}
- `,document.head.appendChild(jp);const tc=q.ref(!1),Qa=q.ref(!1),wa=e=>{tc.value=!0,Qa.value=!1,ch.value=Object.assign(ch.value,e||{})},sh=e=>{Qa.value=!0,tc.value=!1,ch.value=Object.assign(ch.value,e||{})},lh=()=>{tc.value=!1,Qa.value=!1},DM={title:"Modal",text:"",oncancel:lh,onsubmit:lh,ongetallentity:lh,ondrawline:lh,docommand:e=>{}},ch=q.ref(DM),PM=q.ref(!1),mx=q.ref(""),Hp=q.ref("");document.addEventListener("mouseup",function(){Hp.value=document.getSelection().toString(),Hp.value===""&&(Hp.value=mx.value)});function SM(){return Qe(this,null,function*(){try{yield navigator.clipboard.writeText(Hp.value)}catch(e){console.error("Failed to copy: ",e)}})}const $p=()=>({isModalVisible:tc,isToolsVisible:Qa,isDialogVisible:PM,showModal:wa,showTools:sh,hideModal:lh,modalOptions:ch,excelText:mx,copyTextToClipboard:SM}),LM={key:0,class:"modal-wrapper",id:"modal"},IM={class:"modal-body card"},RM={class:"modal-header"},kM={class:"heading"},zM={style:{"overflow-y":"auto",height:"500px"}},FM={class:"btn_box"},BM={class:"btn_box"},OM={class:"btn_box"},NM={class:"btn_box"},UM={class:"btn_box"},VM={class:"btn_box"},GM={class:"btn_box"},WM={class:"btn_box"},jM={class:"btn_box"},HM={class:"btn_box"},$M={class:"btn_box"},qM={class:"btn_box"},XM={class:"btn_box"},ZM={class:"btn_box"},YM={class:"btn_box"},KM={class:"btn_box"},JM={class:"btn_box"},QM=q.defineComponent({__name:"Modal",setup(e){const{isModalVisible:t,hideModal:i,modalOptions:l}=$p();return(c,h)=>(q.openBlock(),q.createBlock(q.Teleport,{to:"body"},[q.unref(t)?(q.openBlock(),q.createElementBlock("div",LM,[q.createElementVNode("div",IM,[q.createElementVNode("div",RM,[q.createElementVNode("h2",kM,q.toDisplayString(q.unref(l).title),1),q.createElementVNode("a",{href:"#!",onClick:h[0]||(h[0]=(...f)=>q.unref(i)&&q.unref(i)(...f)),role:"button",class:"close","aria-label":"close this modal"},h[68]||(h[68]=[q.createElementVNode("svg",{viewBox:"0 0 24 24"},[q.createElementVNode("path",{d:"M24 20.188l-8.315-8.209 8.2-8.282-3.697-3.697-8.212 8.318-8.31-8.203-3.666 3.666 8.321 8.24-8.206 8.313 3.666 3.666 8.237-8.318 8.285 8.203z"})],-1)]))]),q.createElementVNode("div",zM,[q.createElementVNode("div",FM,[q.createElementVNode("button",{class:"button button2",onClick:h[1]||(h[1]=f=>q.unref(l).docommand("Mx_Open_DemoCode"))},"下载开Demo代码"),q.createElementVNode("button",{class:"button button2",onClick:h[2]||(h[2]=f=>q.unref(l).docommand("Mx_Open_DevInstall"))},"下载开发包"),q.createElementVNode("button",{class:"button button2",onClick:h[3]||(h[3]=(...f)=>q.unref(l).ondrawline&&q.unref(l).ondrawline(...f))},"调用画圆线命令"),q.createElementVNode("button",{class:"button button2",onClick:h[4]||(h[4]=f=>q.unref(l).docommand("MxTest_DrawLine"))},"交互画直线")]),q.createElementVNode("div",BM,[q.createElementVNode("button",{class:"button button2",onClick:h[5]||(h[5]=f=>q.unref(l).docommand("MxTest_AddLayer"))},"添加图层"),q.createElementVNode("button",{class:"button button2",onClick:h[6]||(h[6]=f=>q.unref(l).docommand("MxTest_GetAllLayer"))},"得到所有图层"),q.createElementVNode("button",{class:"button button2",onClick:h[7]||(h[7]=f=>q.unref(l).docommand("MxTest_GetAllTextStyle"))},"得到所有文字样式"),q.createElementVNode("button",{class:"button button2",onClick:h[8]||(h[8]=f=>q.unref(l).docommand("MxTest_GetAllBlock"))},"得到所有图块")]),q.createElementVNode("div",OM,[q.createElementVNode("button",{class:"button button2",onClick:h[9]||(h[9]=f=>q.unref(l).docommand("MxTest_GetAllLinetype"))},"得到所有线型"),q.createElementVNode("button",{class:"button button2",onClick:h[10]||(h[10]=f=>q.unref(l).docommand("MxTest_WritexData"))},"写扩展数据"),q.createElementVNode("button",{class:"button button2",onClick:h[11]||(h[11]=f=>q.unref(l).docommand("MxTest_ReadxData"))},"读扩展数据"),q.createElementVNode("button",{class:"button button2",onClick:h[12]||(h[12]=f=>q.unref(l).docommand("MxTest_InsertBlock"))},"测试插入一个图块")]),q.createElementVNode("div",NM,[q.createElementVNode("button",{class:"button button2",onClick:h[13]||(h[13]=f=>q.unref(l).docommand("Mx_Test_DrawLine"))},"绘直线"),q.createElementVNode("button",{class:"button button2",onClick:h[14]||(h[14]=f=>q.unref(l).docommand("Mx_Test_DrawArc"))},"绘圆弧"),q.createElementVNode("button",{class:"button button2",onClick:h[15]||(h[15]=f=>q.unref(l).docommand("Mx_Test_DrawCircle"))},"绘圆"),q.createElementVNode("button",{class:"button button2",onClick:h[16]||(h[16]=f=>q.unref(l).docommand("Mx_Test_DrawPolyline"))},"绘PL线")]),q.createElementVNode("div",UM,[q.createElementVNode("button",{class:"button button2",onClick:h[17]||(h[17]=f=>q.unref(l).docommand("Mx_Test_DrawHatch"))},"绘填充"),q.createElementVNode("button",{class:"button button2",onClick:h[18]||(h[18]=f=>q.unref(l).docommand("Mx_Test_DrawText"))},"绘文字"),q.createElementVNode("button",{class:"button button2",onClick:h[19]||(h[19]=f=>q.unref(l).docommand("Mx_Test_Ellipse"))},"绘椭圆"),q.createElementVNode("button",{class:"button button2",onClick:h[20]||(h[20]=f=>q.unref(l).docommand("Mx_Test_EllipseArc"))},"绘椭圆弧")]),q.createElementVNode("div",VM,[q.createElementVNode("button",{class:"button button2",onClick:h[21]||(h[21]=f=>q.unref(l).docommand("Mx_Test_MText"))},"绘制多行文字"),q.createElementVNode("button",{class:"button button2",onClick:h[22]||(h[22]=f=>q.unref(l).docommand("Mx_Test_DrawTable"))},"绘制表格"),q.createElementVNode("button",{class:"button button2",onClick:h[23]||(h[23]=f=>q.unref(l).docommand("Mx_Test_QRCode"))},"绘制二维码"),q.createElementVNode("button",{class:"button button2",onClick:h[24]||(h[24]=f=>q.unref(l).docommand("MxTest_InsertStamp"))},"插入图章")]),q.createElementVNode("div",GM,[q.createElementVNode("button",{class:"button button2",onClick:h[25]||(h[25]=(...f)=>q.unref(l).ongetallentity&&q.unref(l).ongetallentity(...f))},"得到所有对象"),q.createElementVNode("button",{class:"button button2",onClick:h[26]||(h[26]=f=>q.unref(l).docommand("MxTest_SelectEntity"))},"交互选择对象"),q.createElementVNode("button",{class:"button button2",onClick:h[27]||(h[27]=f=>q.unref(l).docommand("Mx_Export_MxWeb"))},"保存mxweb到服务器"),q.createElementVNode("button",{class:"button button2",onClick:h[28]||(h[28]=f=>q.unref(l).docommand("MxTest_GetSysVars"))},"得到系统变量")]),q.createElementVNode("div",WM,[q.createElementVNode("button",{class:"button button2",onClick:h[29]||(h[29]=f=>q.unref(l).docommand("MxTest_NewFile"))},"新建图纸"),q.createElementVNode("button",{class:"button button2",onClick:h[30]||(h[30]=f=>q.unref(l).docommand("Mx_ViewBackgroundColor"))},"白色背景色"),q.createElementVNode("button",{class:"button button2",onClick:h[31]||(h[31]=f=>q.unref(l).docommand("MxTest_FindText"))},"文字查找定位"),q.createElementVNode("button",{class:"button button2",onClick:h[32]||(h[32]=f=>q.unref(l).docommand("MxTest_SelectEntitysToBlock"))},"选择实体做块")]),q.createElementVNode("div",jM,[q.createElementVNode("button",{class:"button button2",onClick:h[33]||(h[33]=f=>q.unref(l).docommand("Mx_Test_Text"))},"绘制单行文字"),q.createElementVNode("button",{class:"button button2",onClick:h[34]||(h[34]=f=>q.unref(l).docommand("MxTest_DrawHatchFormPoint"))},"选点填充"),q.createElementVNode("button",{class:"button button2",onClick:h[35]||(h[35]=f=>q.unref(l).docommand("Mx_TestExProp"))},"设置扩展属性"),q.createElementVNode("button",{class:"button button2",onClick:h[36]||(h[36]=f=>q.unref(l).docommand("Mx_Test_DimAligned"))},"绘制对齐标注")]),q.createElementVNode("div",HM,[q.createElementVNode("button",{class:"button button2",onClick:h[37]||(h[37]=f=>q.unref(l).docommand("Mx_Test_DrawDimRotated"))},"绘性线标注"),q.createElementVNode("button",{class:"button button2",onClick:h[38]||(h[38]=f=>q.unref(l).docommand("Mx_Test_DrawDimAngular"))},"角度标注"),q.createElementVNode("button",{class:"button button2",onClick:h[39]||(h[39]=f=>q.unref(l).docommand("MxTest_LineTypeTest"))},"修改对象线型"),q.createElementVNode("button",{class:"button button2",onClick:h[40]||(h[40]=f=>q.unref(l).docommand("Mx_SelectEntitHideLayer"))},"选择隐藏对象层")]),q.createElementVNode("div",$M,[q.createElementVNode("button",{class:"button button2",onClick:h[41]||(h[41]=f=>q.unref(l).docommand("MxTest_TestAddCurrentSelect"))},"添加到当前选择"),q.createElementVNode("button",{class:"button button2",onClick:h[42]||(h[42]=f=>q.unref(l).docommand("MxTest_TestSetViewAngle"))},"视区旋转"),q.createElementVNode("button",{class:"button button2",onClick:h[43]||(h[43]=f=>q.unref(l).docommand("MxTest_WriteXRecord"))},"写扩展记录"),q.createElementVNode("button",{class:"button button2",onClick:h[44]||(h[44]=f=>q.unref(l).docommand("MxTest_GetNamedObjectsDictionary"))},"得到命名字典")]),q.createElementVNode("div",qM,[q.createElementVNode("button",{class:"button button2",onClick:h[45]||(h[45]=f=>q.unref(l).docommand("MxTest_AddTextStyleTable"))},"添加文字样式"),q.createElementVNode("button",{class:"button button2",onClick:h[46]||(h[46]=f=>q.unref(l).docommand("MxTest_DrawCustomEntity"))},"绘自定义实体"),q.createElementVNode("button",{class:"button button2",onClick:h[47]||(h[47]=f=>q.unref(l).docommand("Mx_Test_ChangeColor"))},"修改对象颜色"),q.createElementVNode("button",{class:"button button2",onClick:h[48]||(h[48]=f=>q.unref(l).docommand("Mx_Test_ChangeVisible"))},"修改对象不可见")]),q.createElementVNode("div",XM,[q.createElementVNode("button",{class:"button button2",onClick:h[49]||(h[49]=f=>q.unref(l).docommand("Mx_Test_ChangeEntityLayer"))},"修改对象层"),q.createElementVNode("button",{class:"button button2",onClick:h[50]||(h[50]=f=>q.unref(l).docommand("Mx_ChaneEntityDrawOrder"))},"修改对象显示顺序"),q.createElementVNode("button",{class:"button button2",onClick:h[51]||(h[51]=f=>q.unref(l).docommand("Mx_Export_Pdf"))},"指定范围输出pdf"),q.createElementVNode("button",{class:"button button2",onClick:h[52]||(h[52]=f=>q.unref(l).docommand("Mx_Test_DrawImage"))},"绘制image")]),q.createElementVNode("div",ZM,[q.createElementVNode("button",{class:"button button2",onClick:h[53]||(h[53]=f=>q.unref(l).docommand("MxTest_GetObjectExDictionaryData"))},"读取对象扩展字典"),q.createElementVNode("button",{class:"button button2",onClick:h[54]||(h[54]=f=>q.unref(l).docommand("Mx_Test_Draw3DPolyline"))},"绘制3DPolyline"),q.createElementVNode("button",{class:"button button2",onClick:h[55]||(h[55]=f=>q.unref(l).docommand("MxTest_LineText"))},"绘线文本自定义实体"),q.createElementVNode("button",{class:"button button2",onClick:h[56]||(h[56]=f=>q.unref(l).docommand("Mx_Test_IntersectWith"))},"计算交点")]),q.createElementVNode("div",YM,[q.createElementVNode("button",{class:"button button2",onClick:h[57]||(h[57]=f=>q.unref(l).docommand("Mx_Test_TrueText"))},"修改文字样式"),q.createElementVNode("button",{class:"button button2",onClick:h[58]||(h[58]=f=>q.unref(l).docommand("Mx_Test_OffsetIn_DrawLine"))},"偏移输入画线"),q.createElementVNode("button",{class:"button button2",onClick:h[59]||(h[59]=f=>q.unref(l).docommand("Mx_Test_CreateGroup"))},"创建组"),q.createElementVNode("button",{class:"button button2",onClick:h[60]||(h[60]=f=>q.unref(l).docommand("Mx_ScreenToJpg"))},"屏幕截图jpg")]),q.createElementVNode("div",KM,[q.createElementVNode("button",{class:"button button2",onClick:h[61]||(h[61]=f=>q.unref(l).docommand("Mx_Test_GetText"))},"获取图纸相同文字"),q.createElementVNode("button",{class:"button button2",onClick:h[62]||(h[62]=f=>q.unref(l).docommand("Mx_Cut_Dwg"))},"指定范围输出dwg"),q.createElementVNode("button",{class:"button button2",onClick:h[63]||(h[63]=f=>q.unref(l).docommand("Mx_Test_DrawMarkCircle"))},"测试绘制标记圆"),q.createElementVNode("button",{class:"button button2",onClick:h[64]||(h[64]=f=>q.unref(l).docommand("Mx_Test_Wipeout"))},"测试Wipeout")]),q.createElementVNode("div",JM,[q.createElementVNode("button",{class:"button button2",onClick:h[65]||(h[65]=f=>q.unref(l).docommand("MxTest_SelectEntitysToSpatialFilterBlock"))},"创建剪切块"),q.createElementVNode("button",{class:"button button2",onClick:h[66]||(h[66]=f=>q.unref(l).docommand("Mx_Test_DrawDimRotatedTol"))},"公差标注"),q.createElementVNode("button",{class:"button button2",onClick:h[67]||(h[67]=f=>q.unref(l).docommand("MxTest_ModifyAllEntityColor"))},"改所有对象颜色")])])])])):q.createCommentVNode("",!0)]))}}),XF="",ty=(e,t)=>{const i=e.__vccOpts||e;for(const[l,c]of t)i[l]=c;return i},e2=ty(QM,[["__scopeId","data-v-2e0ffbfe"],["__file","Modal.vue"]]),t2={key:0,class:"modal-wrapper",id:"modal"},n2={class:"modal-body card"},i2={class:"modal-header"},r2={class:"heading"},o2={style:{"border-bottom":"2px solid #008CBA","margin-bottom":"8px"}},a2=["onClick"],s2={style:{"overflow-y":"auto",height:"500px"}},l2={class:"btn_box"},c2={class:"btn_box"},u2={class:"btn_box"},h2={class:"btn_box"},d2={class:"btn_box"},p2={style:{"overflow-y":"auto",height:"500px"}},f2={class:"btn_box"},m2={class:"btn_box"},g2={class:"btn_box"},y2={class:"btn_box"},_2={class:"btn_box"},v2={class:"btn_box"},x2={style:{"overflow-y":"auto",height:"500px"}},b2={class:"btn_box"},w2={class:"btn_box"},M2={class:"btn_box"},T2={class:"btn_box"},E2={class:"btn_box"},C2={class:"btn_box"},A2={style:{"overflow-y":"auto",height:"500px"}},D2={class:"btn_box"},P2={class:"btn_box"},S2={class:"btn_box"},L2={class:"btn_box"},I2={style:{"overflow-y":"auto",height:"500px"}},R2={class:"btn_box"},k2={class:"btn_box"},z2={class:"btn_box"},F2={style:{"overflow-y":"auto",height:"500px"}},B2={class:"btn_box"},O2={class:"btn_box"},N2={class:"header"},U2={class:"btnBox"},V2=q.defineComponent({__name:"Tools",setup(e){const{isToolsVisible:t,hideModal:i,modalOptions:l,isDialogVisible:c,excelText:h,copyTextToClipboard:f}=$p(),r=q.reactive([{name:"修改工具",id:"fit"},{name:"文字工具",id:"text"},{name:"绘图工具",id:"draw"},{name:"块工具",id:"block"},{name:"测量工具",id:"count"},{name:"标注工具",id:"dimension"}]),v=q.ref("fit"),{store:x}=MxPluginContext,{setCommandFocus:w}=x.useFocus(),b=q.ref(null),A=L=>{const P=b.value,R=L.clientX-P.offsetLeft,F=L.clientY-P.offsetTop,V=j=>{P.style.left=j.clientX-R+"px",P.style.top=j.clientY-F+"px"};document.addEventListener("mousemove",V),document.addEventListener("mouseup",()=>{document.removeEventListener("mousemove",V)})};return(L,P)=>(q.openBlock(),q.createBlock(q.Teleport,{to:"body"},[q.unref(t)?(q.openBlock(),q.createElementBlock("div",t2,[q.createElementVNode("div",n2,[q.createElementVNode("div",i2,[q.createElementVNode("h2",r2,q.toDisplayString(q.unref(l).title),1),q.createElementVNode("a",{href:"#!",onClick:P[0]||(P[0]=(...R)=>q.unref(i)&&q.unref(i)(...R)),role:"button",class:"close","aria-label":"close this modal"},P[101]||(P[101]=[q.createElementVNode("svg",{viewBox:"0 0 24 24"},[q.createElementVNode("path",{d:"M24 20.188l-8.315-8.209 8.2-8.282-3.697-3.697-8.212 8.318-8.31-8.203-3.666 3.666 8.321 8.24-8.206 8.313 3.666 3.666 8.237-8.318 8.285 8.203z"})],-1)]))]),q.createElementVNode("div",o2,[(q.openBlock(!0),q.createElementBlock(q.Fragment,null,q.renderList(r,R=>(q.openBlock(),q.createElementBlock("button",{key:R.id,onClick:()=>{v.value=R.id},class:q.normalizeClass(v.value===R.id?"btn btn2":"btn")},q.toDisplayString(R.name),11,a2))),128))]),q.withDirectives(q.createElementVNode("div",s2,[q.createElementVNode("div",l2,[q.createElementVNode("button",{class:"button button2",onClick:P[1]||(P[1]=R=>q.unref(l).docommand("Mx_Multicopy"))},"多重复制"),q.createElementVNode("button",{class:"button button2",onClick:P[2]||(P[2]=R=>q.unref(l).docommand("Mx_ArcToCircle"))},"弧转圆"),q.createElementVNode("button",{class:"button button2",onClick:P[3]||(P[3]=R=>q.unref(l).docommand("Mx_CopyRotation"))},"复制旋转"),q.createElementVNode("button",{class:"button button2",onClick:P[4]||(P[4]=R=>q.unref(l).docommand("Mx_CricleTotoll"))},"圆转多边")]),q.createElementVNode("div",c2,[q.createElementVNode("button",{class:"button button2",onClick:P[5]||(P[5]=R=>q.unref(l).docommand("Mx_ChangeColor"))},"修改颜色"),q.createElementVNode("button",{class:"button button2",onClick:P[6]||(P[6]=R=>q.unref(l).docommand("Mx_ArcToAngle"))},"圆弧切角"),q.createElementVNode("button",{class:"button button2",onClick:P[7]||(P[7]=R=>q.unref(l).docommand("Mx_TemHiding"))},"临时隐藏"),q.createElementVNode("button",{class:"button button2",onClick:P[8]||(P[8]=R=>q.unref(l).docommand("Mx_BoxDel"))},"方框删除")]),q.createElementVNode("div",u2,[q.createElementVNode("button",{class:"button button2",onClick:P[9]||(P[9]=R=>q.unref(l).docommand("Mx_AngleCopy"))},"角度复制"),q.createElementVNode("button",{class:"button button2",onClick:P[10]||(P[10]=R=>q.unref(l).docommand("Mx_VertexRep"))},"顶点复制"),q.createElementVNode("button",{class:"button button2",onClick:P[11]||(P[11]=R=>q.unref(l).docommand("Mx_IntersectBreak"))},"交点打断"),q.createElementVNode("button",{class:"button button2",onClick:P[12]||(P[12]=R=>q.unref(l).docommand("Mx_DoubleOff"))},"双向偏移")]),q.createElementVNode("div",h2,[q.createElementVNode("button",{class:"button button2",onClick:P[13]||(P[13]=R=>q.unref(l).docommand("Mx_EitCircle"))},"改圆大小"),q.createElementVNode("button",{class:"button button2",onClick:P[14]||(P[14]=R=>q.unref(l).docommand("Mx_LayerTypeScale"))},"线型比例"),q.createElementVNode("button",{class:"button button2",onClick:P[15]||(P[15]=R=>q.unref(l).docommand("Mx_Telescoping"))},"伸缩"),q.createElementVNode("button",{class:"button button2",onClick:P[16]||(P[16]=R=>q.unref(l).docommand("Mx_ArcOrder"))},"按弧阵列")]),q.createElementVNode("div",d2,[q.createElementVNode("button",{class:"button button2",onClick:P[17]||(P[17]=R=>q.unref(l).docommand("Mx_PlRoundCorners"))},"pl圆角"),q.createElementVNode("button",{class:"button button2",onClick:P[18]||(P[18]=R=>q.unref(l).docommand("Mx_PlReverse"))},"pl线反向"),q.createElementVNode("button",{class:"button button2",onClick:P[19]||(P[19]=R=>q.unref(l).docommand("Mx_TestGetAllLineByLayer"))},"得到所有直线对象"),q.createElementVNode("button",{class:"button button2",onClick:P[20]||(P[20]=R=>q.unref(l).docommand("Mx_Bisection"))},"等分")]),q.createElementVNode("div",null,[q.createElementVNode("button",{class:"button button2",onClick:P[21]||(P[21]=R=>q.unref(l).docommand("Mx_RectangularScaling"))},"矩形缩放"),q.createElementVNode("button",{class:"button button2",onClick:P[22]||(P[22]=R=>q.unref(l).docommand("Mx_Interrupt"))},"打断")])],512),[[q.vShow,v.value==="fit"]]),q.withDirectives(q.createElementVNode("div",p2,[q.createElementVNode("div",f2,[q.createElementVNode("button",{class:"button button2",onClick:P[23]||(P[23]=R=>q.unref(l).docommand("Mx_DrawStart"))},"星形"),q.createElementVNode("button",{class:"button button2",onClick:P[24]||(P[24]=R=>q.unref(l).docommand("Mx_ConcavoVex"))},"凹凸线"),q.createElementVNode("button",{class:"button button2",onClick:P[25]||(P[25]=R=>q.unref(l).docommand("Mx_ZigzagLine"))},"锯齿线"),q.createElementVNode("button",{class:"button button2",onClick:P[26]||(P[26]=R=>q.unref(l).docommand("Mx_CenterRect"))},"中心矩形")]),q.createElementVNode("div",m2,[q.createElementVNode("button",{class:"button button2",onClick:P[27]||(P[27]=R=>q.unref(l).docommand("Mx_BreakLine"))},"折断线"),q.createElementVNode("button",{class:"button button2",onClick:P[28]||(P[28]=R=>q.unref(l).docommand("Mx_CCLine"))},"圆中心线"),q.createElementVNode("button",{class:"button button2",onClick:P[29]||(P[29]=R=>q.unref(l).docommand("Mx_Piping"))},"管道"),q.createElementVNode("button",{class:"button button2",onClick:P[30]||(P[30]=R=>q.unref(l).docommand("Mx_CutPipeline"))},"剖管符")]),q.createElementVNode("div",g2,[q.createElementVNode("button",{class:"button button2",onClick:P[31]||(P[31]=R=>q.unref(l).docommand("Mx_PerpLine"))},"中垂线"),q.createElementVNode("button",{class:"button button2",onClick:P[32]||(P[32]=R=>q.unref(l).docommand("Mx_StairLine"))},"楼梯"),q.createElementVNode("button",{class:"button button2",onClick:P[33]||(P[33]=R=>q.unref(l).docommand("Mx_SolidCircle"))},"实心圆"),q.createElementVNode("button",{class:"button button2",onClick:P[34]||(P[34]=R=>q.unref(l).docommand("Mx_CottonInsulation"))},"保温棉")]),q.createElementVNode("div",y2,[q.createElementVNode("button",{class:"button button2",onClick:P[35]||(P[35]=R=>q.unref(l).docommand("Mx_CenterLine"))},"中心线"),q.createElementVNode("button",{class:"button button2",onClick:P[36]||(P[36]=R=>q.unref(l).docommand("Mx_DoHole"))},"开洞"),q.createElementVNode("button",{class:"button button2",onClick:P[37]||(P[37]=R=>q.unref(l).docommand("Mx_Compass"))},"指北针"),q.createElementVNode("button",{class:"button button2",onClick:P[38]||(P[38]=R=>q.unref(l).docommand("Mx_MassegeBox"))},"消息框")]),q.createElementVNode("div",_2,[q.createElementVNode("button",{class:"button button2",onClick:P[39]||(P[39]=R=>q.unref(l).docommand("Mx_DatumSymbol"))},"基准符"),q.createElementVNode("button",{class:"button button2",onClick:P[40]||(P[40]=R=>q.unref(l).docommand("Mx_WelLine"))},"焊缝线"),q.createElementVNode("button",{class:"button button2",onClick:P[41]||(P[41]=R=>q.unref(l).docommand("Mx_ConcentricCircles"))},"同心圆"),q.createElementVNode("button",{class:"button button2",onClick:P[42]||(P[42]=R=>q.unref(l).docommand("Mx_Gear"))},"齿轮")]),q.createElementVNode("div",v2,[q.createElementVNode("button",{class:"button button2",onClick:P[43]||(P[43]=R=>q.unref(l).docommand("Mx_BlkCenterLine"))},"块中心线")])],512),[[q.vShow,v.value==="draw"]]),q.withDirectives(q.createElementVNode("div",x2,[q.createElementVNode("div",b2,[q.createElementVNode("button",{class:"button button2",onClick:P[44]||(P[44]=R=>q.unref(l).docommand("Mx_AlignByLine"))},"按线对齐"),q.createElementVNode("button",{class:"button button2",onClick:P[45]||(P[45]=R=>q.unref(l).docommand("Mx_TextHeight"))},"改字高"),q.createElementVNode("button",{class:"button button2",onClick:P[46]||(P[46]=R=>q.unref(l).docommand("Mx_TextWidth"))},"改字宽"),q.createElementVNode("button",{class:"button button2",onClick:P[47]||(P[47]=R=>q.unref(l).docommand("Mx_BrushCon"))},"刷内容")]),q.createElementVNode("div",w2,[q.createElementVNode("button",{class:"button button2",onClick:P[48]||(P[48]=R=>q.unref(l).docommand("Mx_ReplaceCon"))},"换内容"),q.createElementVNode("button",{class:"button button2",onClick:P[49]||(P[49]=R=>q.unref(l).docommand("Mx_AlignLeft"))},"左右对齐"),q.createElementVNode("button",{class:"button button2",onClick:P[50]||(P[50]=R=>q.unref(l).docommand("Mx_AlignUp"))},"上下对齐"),q.createElementVNode("button",{class:"button button2",onClick:P[51]||(P[51]=R=>q.unref(l).docommand("Mx_TextReversal"))},"文字反转")]),q.createElementVNode("div",M2,[q.createElementVNode("button",{class:"button button2",onClick:P[52]||(P[52]=R=>q.unref(l).docommand("Mx_TextTraming"))},"文字加框"),q.createElementVNode("button",{class:"button button2",onClick:P[53]||(P[53]=R=>q.unref(l).docommand("Mx_Underline"))},"下划线"),q.createElementVNode("button",{class:"button button2",onClick:P[54]||(P[54]=R=>q.unref(l).docommand("Mx_TitleLine"))},"图名线"),q.createElementVNode("button",{class:"button button2",onClick:P[55]||(P[55]=R=>q.unref(l).docommand("Mx_Case"))},"大小写")]),q.createElementVNode("div",T2,[q.createElementVNode("button",{class:"button button2",onClick:P[56]||(P[56]=R=>q.unref(l).docommand("Mx_NumSum"))},"数字求和"),q.createElementVNode("button",{class:"button button2",onClick:P[57]||(P[57]=R=>q.unref(l).docommand("Mx_SSWords"))},"选特定字"),q.createElementVNode("button",{class:"button button2",onClick:P[58]||(P[58]=R=>q.unref(l).docommand("Mx_Prefix"))},"前后缀"),q.createElementVNode("button",{class:"button button2",onClick:P[59]||(P[59]=R=>q.unref(l).docommand("Mx_ConnectText"))},"连接文字")]),q.createElementVNode("div",E2,[q.createElementVNode("button",{class:"button button2",onClick:P[60]||(P[60]=R=>q.unref(l).docommand("Mx_TextTrim"))},"去空格"),q.createElementVNode("button",{class:"button button2",onClick:P[61]||(P[61]=R=>q.unref(l).docommand("Mx_VerticalText"))},"文字竖向"),q.createElementVNode("button",{class:"button button2",onClick:P[62]||(P[62]=R=>q.unref(l).docommand("Mx_AlignByArc"))},"按弧对齐"),q.createElementVNode("button",{class:"button button2",onClick:P[63]||(P[63]=R=>q.unref(l).docommand("Mx_EditTextStyle"))},"修改全局文字样式")]),q.createElementVNode("div",C2,[q.createElementVNode("button",{class:"button button2",onClick:P[64]||(P[64]=R=>q.unref(l).docommand("Mx_ExtractText"))},"提取文字")])],512),[[q.vShow,v.value==="text"]]),q.withDirectives(q.createElementVNode("div",A2,[q.createElementVNode("div",D2,[q.createElementVNode("button",{class:"button button2",onClick:P[65]||(P[65]=R=>q.unref(l).docommand("Mx_ChangeBN"))},"改块名"),q.createElementVNode("button",{class:"button button2",onClick:P[66]||(P[66]=R=>q.unref(l).docommand("Mx_BushBlk"))},"刷块"),q.createElementVNode("button",{class:"button button2",onClick:P[67]||(P[67]=R=>q.unref(l).docommand("Mx_ConBlk"))},"块连线"),q.createElementVNode("button",{class:"button button2",onClick:P[68]||(P[68]=R=>q.unref(l).docommand("Mx_BlkCenterLine"))},"块中心线")]),q.createElementVNode("div",P2,[q.createElementVNode("button",{class:"button button2",onClick:P[69]||(P[69]=R=>q.unref(l).docommand("Mx_BlkPt"))},"改块基点"),q.createElementVNode("button",{class:"button button2",onClick:P[70]||(P[70]=R=>q.unref(l).docommand("Mx_BlkColor"))},"改块颜色"),q.createElementVNode("button",{class:"button button2",onClick:P[71]||(P[71]=R=>q.unref(l).docommand("Mx_BlkRotate"))},"多块旋转"),q.createElementVNode("button",{class:"button button2",onClick:P[72]||(P[72]=R=>q.unref(l).docommand("Mx_BlkScale"))},"多块缩放")]),q.createElementVNode("div",S2,[q.createElementVNode("button",{class:"button button2",onClick:P[73]||(P[73]=R=>q.unref(l).docommand("Mx_BlkAngle"))},"刷块角度"),q.createElementVNode("button",{class:"button button2",onClick:P[74]||(P[74]=R=>q.unref(l).docommand("Mx_BlkSelect"))},"按块选择"),q.createElementVNode("button",{class:"button button2",onClick:P[75]||(P[75]=R=>q.unref(l).docommand("Mx_BlkAllSelect"))},"按块全选"),q.createElementVNode("button",{class:"button button2",onClick:P[76]||(P[76]=R=>q.unref(l).docommand("Mx_SSBlk"))},"统计单块")]),q.createElementVNode("div",L2,[q.createElementVNode("button",{class:"button button2",onClick:P[77]||(P[77]=R=>q.unref(l).docommand("Mx_SMBlk"))},"统计多块"),q.createElementVNode("button",{class:"button button2",onClick:P[78]||(P[78]=R=>q.unref(l).docommand("Mx_BlkLayer"))},"修改块图层")])],512),[[q.vShow,v.value==="block"]]),q.withDirectives(q.createElementVNode("div",I2,[q.createElementVNode("div",R2,[q.createElementVNode("button",{class:"button button2",onClick:P[79]||(P[79]=R=>q.unref(l).docommand("Mx_StaLength"))},"长度"),q.createElementVNode("button",{class:"button button2",onClick:P[80]||(P[80]=R=>q.unref(l).docommand("Mx_StaArea"))},"统计面积"),q.createElementVNode("button",{class:"button button2",onClick:P[81]||(P[81]=R=>q.unref(l).docommand("Mx_Elevation"))},"智能标高"),q.createElementVNode("button",{class:"button button2",onClick:P[82]||(P[82]=R=>q.unref(l).docommand("Mx_Area"))},"面积")]),q.createElementVNode("div",k2,[q.createElementVNode("button",{class:"button button2",onClick:P[83]||(P[83]=R=>q.unref(l).docommand("Mx_ReactArea"))},"矩形面积"),q.createElementVNode("button",{class:"button button2",onClick:P[84]||(P[84]=R=>q.unref(l).docommand("Mx_DistFromPointToLine"))},"点到直线的距离"),q.createElementVNode("button",{class:"button button2",onClick:P[85]||(P[85]=R=>q.unref(l).docommand("Mx_ArcLength"))},"弧长"),q.createElementVNode("button",{class:"button button2",onClick:P[86]||(P[86]=R=>q.unref(l).docommand("Mx_MeasuringCircle"))},"测量圆")]),q.createElementVNode("div",z2,[q.createElementVNode("button",{class:"button button2",onClick:P[87]||(P[87]=R=>q.unref(l).docommand("Mx_ContinueMeasurement"))},"连续测量"),q.createElementVNode("button",{class:"button button2",onClick:P[88]||(P[88]=R=>q.unref(l).docommand("Mx_CountList"))},"查看分段长度"),q.createElementVNode("button",{class:"button button2",onClick:P[89]||(P[89]=R=>q.unref(l).docommand("Mx_AreaArc"))},"面积含弧线")])],512),[[q.vShow,v.value==="count"]]),q.withDirectives(q.createElementVNode("div",F2,[q.createElementVNode("div",B2,[q.createElementVNode("button",{class:"button button2",onClick:P[90]||(P[90]=R=>q.unref(l).docommand("Mx_Approval"))},"审图标注"),q.createElementVNode("button",{class:"button button2",onClick:P[91]||(P[91]=R=>q.unref(l).docommand("Mx_AnnotatedRectangle"))},"矩形标注"),q.createElementVNode("button",{class:"button button2",onClick:P[92]||(P[92]=R=>q.unref(l).docommand("Mx_Roughness"))},"粗糙度标注"),q.createElementVNode("button",{class:"button button2",onClick:P[93]||(P[93]=R=>q.unref(l).docommand("Mx_CoordAnnotation"))},"坐标标注")]),q.createElementVNode("div",O2,[q.createElementVNode("button",{class:"button button2",onClick:P[94]||(P[94]=R=>q.unref(l).docommand("Mx_StandardSlope"))},"标斜率"),q.createElementVNode("button",{class:"button button2",onClick:P[95]||(P[95]=R=>q.unref(l).docommand("Mx_Alignment"))},"对齐"),q.createElementVNode("button",{class:"button button2",onClick:P[96]||(P[96]=R=>q.unref(l).docommand("Mx_Enlarge"))},"局部放大")])],512),[[q.vShow,v.value==="dimension"]])])])):q.createCommentVNode("",!0),q.unref(c)?(q.openBlock(),q.createElementBlock("div",{key:1,class:"textBox",ref_key:"model",ref:b,onMousedown:A},[q.createElementVNode("div",N2,[P[103]||(P[103]=q.createElementVNode("span",null,"选择的文字",-1)),q.createElementVNode("a",{href:"#!",onClick:P[97]||(P[97]=R=>c.value=!1),role:"button",class:"close","aria-label":"close this modal"},P[102]||(P[102]=[q.createElementVNode("svg",{viewBox:"0 0 24 24"},[q.createElementVNode("path",{d:"M24 20.188l-8.315-8.209 8.2-8.282-3.697-3.697-8.212 8.318-8.31-8.203-3.666 3.666 8.321 8.24-8.206 8.313 3.666 3.666 8.237-8.318 8.285 8.203z"})],-1)]))]),q.createElementVNode("textarea",{rows:"20",cols:"50",onFocus:P[98]||(P[98]=()=>q.unref(w)(!1)),onBlur:P[99]||(P[99]=()=>q.unref(w)(!0))}," "+q.toDisplayString(q.unref(h)),33),q.createElementVNode("div",U2,[q.createElementVNode("button",{onClick:P[100]||(P[100]=(...R)=>q.unref(f)&&q.unref(f)(...R))},"复制到剪贴板")])],544)):q.createCommentVNode("",!0)]))}}),ZF="",G2=ty(V2,[["__scopeId","data-v-6c1067c7"],["__file","Tools.vue"]]),W2=ty(q.defineComponent({__name:"Test",setup(e){return(t,i)=>(q.openBlock(),q.createElementBlock("div",null,[q.createVNode(e2),q.createVNode(G2)]))}}),[["__file","Test.vue"]]),j2={init(){X.MxFun.setPostMessageToParentFrameFunction(function(e){top.postMessage(e,"*")}),window.addEventListener("message",function(e){e.data.type==="sendStringToExecute"?X.MxFun.sendStringToExecute(e.data.cmd,e.data):(console.log("mx:unprocessed message:"),console.log(e.data))},!1)}};function H2(){j2.init()}function $2(){return Qe(this,null,function*(){const e=new X.MrxDbgUiPrPoint;e.setMessage(`
- 指定第一点:`),e.go(t=>{if(t!=0)return;const i=e.value();let l=new X.MxDbLeadComment;l.point1=i.clone(),l.textHeight=X.MxFun.screenCoordLong2Doc(50),l.text="测试Test1",l.textWidth=X.MxFun.screenCoordLong2Doc(300),l.fixedSize=!0,l.fixedSize&&(l.textHeight=50,l.textWidth=250),l.color=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();const c=new X.McEdGetPointWorldDrawObject;c.setDraw((h,f)=>{l.point2=h,f.drawCustomEntity(l)}),e.setBasePt(i),e.setUseBasePt(!0),e.setUserDraw(c),e.setMessage(`
- 指定第二点:`),e.go(h=>{if(h!=0){console.log(h);return}const f=e.value();l.point2=f,X.MxFun.addToCurrentSpace(l)})})})}function q2(){X.MxFun.getCurrentDraw().createCanvasImageData(e=>{const t=window.open();t!=null&&(t.document.write('<img src="'+e+'"/>'),setTimeout(()=>{t.print()},300))},{width:349,height:536})}function X2(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();const t=new X.MrxDbgUiPrPoint,i=X.MxFun.getCurrentDraw(),l=new X.McEdGetPointWorldDrawObject,c=new X.MxDbRectBoxLeadComment;c.color=e.getHex(),c.color==0&&(c.color=65793),c.radius=X.MxFun.screenCoordLong2Doc(8),c.setLineWidth(3),c.setLineWidthByPixels(!0),t.setMessage(`
- 云线框起始点:`),t.go(h=>{h==X.MrxDbgUiPrBaseReturn.kOk&&(c.point1=t.value(),l.setDraw(f=>{c.point2=f,l.drawCustomEntity(c)}),t.setUserDraw(l),t.setMessage(`
- 云线框结束点:`),t.go(f=>{f==X.MrxDbgUiPrBaseReturn.kOk&&(c.point2=t.value(),l.setDraw(r=>{c.point3=r,l.drawCustomEntity(c)}),c.text="审图批注XXXXXXXXXX",c.textWidth=X.MxFun.screenCoordLong2Doc(200),c.textHeight=X.MxFun.screenCoordLong2Doc(50),c.fixedSize=!0,c.fixedSize&&(c.textHeight=20,c.textWidth=230),t.setMessage(`
- 审图标注点:`),t.go(r=>{r==X.MrxDbgUiPrBaseReturn.kOk&&(c.point3=t.value(),i.addMxEntity(c))}))}))})})}function ny(e,t){let i=X.MxFun.screenCoordLong2World(t?e:e-e/3);return i=X.MxFun.worldCoordLong2Doc(i),i}function Z2(){const e=new X.McEdGetPointWorldDrawObject,t=new X.MxDbArrow,i=X.MxFun.getCurrentDraw(),l=new X.MrxDbgUiPrPoint;l.setUserDraw(e),t.setLineWidth(10),t.innerOffset=ny(10),t.outerOffset=ny(22),t.topOffset=ny(36),t.color=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor(),l.go(()=>{t.startPoint=l.value(),e.setDraw(c=>{t.endPoint=c,e.drawCustomEntity(t)}),l.go(c=>Qe(this,null,function*(){t.endPoint=l.value(),i.addMxEntity(t)}))})}function Y2(){const e=new X.MrxDbgUiPrPoint,t=X.MxFun.getCurrentDraw(),i=new X.McEdGetPointWorldDrawObject,l=X.MxFun.screenCoordLong2Doc(16);e.setMessage(`
- 点击开启绘制云线:`),e.go(()=>{let c=e.value();const h=new X.MxDbCloudLine;h.setRadius(l),h.addPoint(c),h.color=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor(),i.setDraw(f=>{c.distanceTo(f)>l&&(c=f.clone(),h.addPoint(f,!0)),i.drawCustomEntity(h)}),e.setUserDraw(i),e.setMessage(`
- 再次点击结束绘制云线:`),e.go(()=>{t.addMxEntity(h)})})}let qp="";function K2(){qp=X.MxFun.getCurrentDraw().saveMxEntityToJson(),console.log(qp)}function J2(){return Qe(this,null,function*(){if(qp.length==0)return;let e=X.MxFun.getCurrentDraw();yield e.loadMxEntityFromJson(qp,["models/svg/mark.svg"]),e.updateDisplay()})}function Q2(){const e=new X.MrxDbgUiPrPoint;e.setMessage(`
- 指定第一点:`),e.go(t=>{if(t!=0)return;const i=e.value();let l=new X.MxDbArea;l.addPoint(i),l.color=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();const c=new X.McEdGetPointWorldDrawObject;c.setDraw((h,f)=>{let r=l.clone();r.addPoint(h),c.drawCustomEntity(r)}),e.setUserDraw(c),e.setMessage(`
- 指定下一点:`),e.goWhile(h=>{if(h==0){const f=e.value();l.addPoint(f)}},h=>{l.isFill=!0,l.fillOpacity=.7,l.fillColor=6697540,X.MxFun.getCurrentDraw().addMxEntity(l)})})}function eT(){X.MxFun.addCommand("BR_Comment",$2),X.MxFun.addCommand("BR_CheckDraw",X2),X.MxFun.addCommand("BR_Arrow",Z2),X.MxFun.addCommand("BR_CloudLine",Y2),X.MxFun.addCommand("BR_Print",q2),X.MxFun.addCommand("BR_SaveAllMxEntity",K2),X.MxFun.addCommand("BR_LoadAllMxEntity",J2),X.MxFun.addCommand("BR_Area",Q2)}function tT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.addLayer("LineLayer"),e.drawLayer="LineLayer",e.drawLine(0,0,100,0),e.drawLine(200,0,300,100),e.addLinetype("MyLineType","6,-10"),e.drawLinetype="MyLineType",e.drawLine(0,30,100,30),e.drawLine(200,30,300,130),e.drawColor=new M.McCmColor(0,0,255),e.drawLine(0,60,100,60),e.drawLine(200,60,300,160),e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=4,e.drawLine(0,90,100,90),e.drawLine(200,90,300,190),e.addLinetype("MyLineType2","10,-2,3,-2"),e.drawLinetype="MyLineType2",e.drawColor=new M.McCmColor(255,0,0),e.drawLine(0,120,100,120),e.drawLine(200,120,300,220),e.addTextStyle("MyLineTypeTextStyle","txt.shx","hztxt.shx",1),e.addLinetypeEx("MyLineType3",'(12.7,("T=MxDraw","S=2.54","L=-5.08","R=0.0","X=-2.54","Y=-1.27"),-10.08)',"MyLineTypeTextStyle"),e.drawLinetype="MyLineType3",e.drawLineWidth=0,e.drawLine(350,120,600,120),e.drawColorIndex=0,e.drawLineWidth=4,e.drawLine(350,220,600,220),e.zoomAll(),e.updateDisplay()}function nT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.addLayer("ArcLayer"),e.drawLayer="ArcLayer",e.drawArc(0,1e3,100,30,200),e.addLinetype("ArcLineType","30,-5,7,-7"),e.drawLinetype="ArcLineType",e.drawColor=new M.McCmColor(255,25,0),e.drawArc(300,1e3,100,30,200),e.drawLineWidth=15,e.drawColorIndex=255,e.drawArc(600,1e3,100,30,200),e.drawArc2(800,1e3,900,1200,1e3,900),e.drawLinetype="",e.drawLineWidth=40,e.drawArc3(1200,1e3,1400,1e3,.6),e.zoomAll(),e.regen(),e.updateDisplay()}function iT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.addLayer("CircleLayer"),e.drawLayer="CircleLayer",e.drawCircle(0,800,120),e.addLinetype("CircleLineType","30,-5,7,-7"),e.drawLinetype="CircleLineType",e.drawColor=new M.McCmColor(0,25,255),e.drawCircle(300,800,120),e.addLinetype("CircleLineType","30,-5,7,-7"),e.drawLinetype="CircleLineType",e.drawLineWidth=40,e.drawCircle(600,800,120),e.zoomAll(),e.regen(),e.updateDisplay()}function rT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.addLayer("PolylineLayer"),e.drawLayer="PolylineLayer",e.pathMoveTo(0,300),e.pathLineTo(100,300),e.pathLineTo(100,400),e.pathLineTo(0,400),e.pathMakeClosed(),e.drawPathToPolyline(),e.pathMoveTo(200,300),e.pathLineTo(300,300),e.pathLineTo(300,400),e.pathLineTo(200,400),e.pathMakeClosed(),e.addLinetype("MyLineType3","30,-10"),e.drawLinetype="MyLineType3",e.drawColorIndex=255,e.drawLineWidth=5,e.drawPathToPolyline(),e.pathMoveTo(400,300),e.pathLineTo(500,300),e.pathLineTo(500,400),e.pathLineTo(400,400),e.pathMakeClosed(),e.drawLinetype="",e.drawColor=new M.McCmColor(0,25,255),e.drawLineWidth=10,e.drawPathToPolyline(),e.pathMoveTo(400,300),e.pathLineTo(500,300),e.pathLineTo(500,400),e.pathLineTo(400,400),e.pathMakeClosed(),e.drawLinetype="",e.drawColor=new M.McCmColor(255,25,0),e.drawLineWidth=10,e.drawPathToPolyline(),e.pathMoveTo(600,300),e.pathLineTo(700,300),e.pathLineTo(700,400),e.pathLineTo(600,400),e.drawLinetype="",e.drawColor=new M.McCmColor(0,255,0),e.drawLineWidth=10,e.drawPathToPolyline(),e.pathMoveTo(800,300),e.pathLineTo(900,300),e.pathLineTo(900,400),e.pathMakeClosed(),e.drawLinetype="",e.drawColor=new M.McCmColor(25,255,0),e.drawLineWidth=10,e.drawPathToPolyline(),e.pathMoveToEx(1e3,300,10,10,0),e.pathLineToEx(1e3,500,30,0,0),e.pathLineTo(1e3,580),e.drawPathToPolyline(),e.pathMoveToEx(1200,300,10,10,0),e.pathLineToEx(1200,500,30,0,0),e.pathLineTo(1200,580),e.drawColor=new M.McCmColor(25,255,0),e.drawLinetype="MyLineType3",e.drawPathToPolyline(),e.pathMoveToEx(1400,300,10,10,-.34),e.pathLineToEx(1400,500,30,0,.34),e.pathLineTo(1400,600),e.drawColor=new M.McCmColor(255,255,25),e.drawLinetype="MyLineType3",e.drawPathToPolyline(),e.zoomAll(),e.regen(),e.updateDisplay()}function oT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.addLayer("HatchLayer"),e.drawLayer="HatchLayer",e.pathMoveToEx(200,3300,0,0,.3),e.pathLineTo(300,3300),e.pathLineTo(300,3400),e.pathLineTo(200,3300),e.drawColor=new M.McCmColor(25,255,0),e.drawPathToHatch(1),e.pathMoveTo(150,3300),e.pathLineTo(250,3300),e.pathLineTo(250,3400),e.pathLineTo(150,3300),e.drawColor=new M.McCmColor(255,0,0),e.drawPathToHatch(1),e.pathMoveToEx(440,3310,0,0,0),e.pathLineTo(480,3310),e.pathLineTo(480,3360),e.pathLineTo(450,3340),e.pathMakeExclude(!0),e.pathMoveToEx(400,3300,0,0,.3),e.pathLineTo(500,3300),e.pathLineTo(500,3400),e.pathLineTo(400,3300),e.drawColor=new M.McCmColor(255,25,0),e.drawPathToHatch(1),e.addPatternDefinition("MyHatchPattern1","((45, 0,0, 0,0.125))"),e.drawPatternDefinition="MyHatchPattern1",e.pathMoveToEx(600,3300,0,0,.3),e.pathLineTo(700,3300),e.pathLineTo(700,3400),e.pathLineTo(600,3300),e.drawPathToHatch(100),e.addPatternDefinition("MyHatchPattern2","((45, 0,0, 0,0.25) (45, 0.176776695,0, 0,0.25, 0.125,-0.0625))"),e.drawPatternDefinition="MyHatchPattern2",e.pathMoveToEx(800,3300,0,0,.3),e.pathLineTo(900,3300),e.pathLineTo(900,3400),e.pathLineTo(800,3300),e.drawPathToHatch(100),e.zoomAll(),e.regen(),e.updateDisplay()}function aT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.addLayer("TextLayer"),e.drawLayer="TextLayer",e.drawText(0,1900,"绘图控件文字测试",100,0,0,1),e.drawColor=new M.McCmColor(255,25,0),e.drawText(3e3,2100,"绘图控件文字测试",100,-20,2,1),e.addTextStyle("MyTextStyle","italicc.shx","gbcbig.shx",.7),e.drawTextStyle="MyTextStyle",e.drawColor=new M.McCmColor(255,0,0),e.drawText(0,3e3,"绘图控件文字测试",100,0,0,1),e.AddTureTypeTextStyle("MyTrueTypeTextStyle"),e.drawTextStyle="MyTrueTypeTextStyle",e.drawColor=new M.McCmColor(200,255,50),e.drawText(0,3500,"绘图控件TrueType文字测试",100,0,0,1),e.zoomAll(),e.regen(),e.updateDisplay()}function sT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile(),M.MxCpp.App.loadFonts([],[],["syadobe","simsun"],()=>{e.AddTureTypeTextStyle("ht_style","syadobe"),e.AddTureTypeTextStyle("st_style","simsun"),e.drawTextStyle="ht_style",e.drawColor=new M.McCmColor(200,255,50);let i=e.drawText(0,3500,"绘图控件TrueType文字测试",100,0,0,1).getMcDbEntity();i&&(i.textStyle="st_style"),e.zoomAll(),e.regen(),e.updateDisplay()})}function lT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.addLayer("LineLayer"),e.drawLayer="LineLayer",e.drawEllipse(0,1400,100,0,.7),e.addLinetype("MyEllipseType","6,-10"),e.drawLinetype="MyEllipseType",e.drawColor=new M.McCmColor(200,0,0),e.drawEllipse(200,1400,80,30,.5),e.zoomAll(),e.regen(),e.updateDisplay()}function cT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.drawLineWidth=0,e.addLayer("EllipseArcLayer"),e.drawLayer="EllipseArcLayer",e.drawEllipseArc(0,1600,80,30,.4,30,200),e.addLinetype("MyEllipseArcType","6,-10"),e.drawLinetype="MyEllipseArcType",e.drawColor=new M.McCmColor(200,200,0),e.drawEllipseArc(200,1600,-80,30,.5,60,300),e.drawLinetype="",e.zoomAll(),e.regen(),e.updateDisplay()}function uT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.addLayer("MtextLayer"),e.drawLayer="MtextLayer",e.drawTextStyle="",e.drawMText(0,-100,"控件:\\P多行文字测试",50,400,0,1),e.zoomAll(),e.regen(),e.updateDisplay()}function hT(e){if(!e||!e.param)return;let t=M.MxCpp.getCurrentMxCAD();t.newFile(),t.drawColorIndex=0,t.drawLinetype="",t.drawLineWidth=0,t.addLayer("LineLayer"),t.drawLayer="LineLayer",t.drawLine(e.param.x1,e.param.y1,e.param.x2,e.param.y2),t.zoomAll(),t.updateDisplay(),X.MxFun.postMessageToParentFrame({cmd:"Mx_ParamDrawLine",message:"ok"})}function dT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile(),e.drawText(350831.77,1940511845e-2,"1.034",10,0,M.McDb.TextHorzMode.kTextLeft,M.McDb.TextVertMode.kTextVertMid),e.zoomAll(),e.regen(100)}function pT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile(),e.addDimStyle("MyDimStyle","41,0.18,141,0.09,40,200","77,1,271,3","",""),e.drawDimStyle="MyDimStyle",e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.drawDimAligned(0,4e3,300,4500,150,4600),e.zoomAll(),e.updateDisplay()}function fT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile();let t=e.addTextStyle("我的标注字体","complex.shx","gbcbig.shx",1);e.addDimStyle("MyDimStyle","41,0.18,141,0.09,40,200","77,1,271,3","",`340,${t.id}`),e.drawDimStyle="MyDimStyle",e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.drawDimRotated(0,7e3,600,7e3,250,7050,0),e.drawDimRotated(0,7200,0,7600,150,7300,.771),e.zoomAll(),e.updateDisplay()}function mT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile();let t=e.addTextStyle("我的标注字体","complex.shx","gbcbig.shx",1);e.addDimStyle("MyDimStyle","41,0.18,141,0.09,40,200","77,1,271,3",'3,"DN%%c<>"',`340,${t.id}`),e.drawDimStyle="MyDimStyle",e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0;let i=e.drawDimRotated(0,7e3,600,7e3,250,7050,0).getMcDbDimension();i&&(i.setDimVarInt(71,1),i.setDimVarInt(272,1),i.setDimVarDouble(146,.5),i.setDimVarDouble(48,5.5),i.setDimVarDouble(47,2.5),i.recomputeDimBlock()),e.zoomAll(),e.updateDisplay()}function gT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile(),e.addDimStyle("MyDimStyle2","41,0.18,141,0.09,40,200","77,1,271,3","",""),e.drawDimStyle="MyDimStyle2",e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.drawDimAngular(500,5e3,0,5500,1e3,5500,500,5500),e.zoomAll(),e.updateDisplay()}function yT(){X.MxFun.addCommand("Mx_Test_DrawLine",tT),X.MxFun.addCommand("Mx_Test_DrawArc",nT),X.MxFun.addCommand("Mx_Test_DrawCircle",iT),X.MxFun.addCommand("Mx_Test_DrawPolyline",rT),X.MxFun.addCommand("Mx_Test_DrawHatch",oT),X.MxFun.addCommand("Mx_Test_DrawText",aT),X.MxFun.addCommand("Mx_Test_Ellipse",lT),X.MxFun.addCommand("Mx_Test_EllipseArc",cT),X.MxFun.addCommand("Mx_Test_MText",uT),X.MxFun.addCommand("Mx_Test_Text",dT),X.MxFun.addCommand("Mx_ParamDrawLine",hT),X.MxFun.addCommand("Mx_Test_DimAligned",pT),X.MxFun.addCommand("Mx_Test_DrawDimRotated",fT),X.MxFun.addCommand("Mx_Test_DrawDimRotatedTol",mT),X.MxFun.addCommand("Mx_Test_DrawDimAngular",gT),X.MxFun.addCommand("Mx_Test_TrueText",sT)}Number.EPSILON===void 0&&(Number.EPSILON=Math.pow(2,-52)),Number.isInteger===void 0&&(Number.isInteger=function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e}),Math.sign===void 0&&(Math.sign=function(e){return e<0?-1:e>0?1:+e}),"name"in Function.prototype||Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),Object.assign===void 0&&(Object.assign=function(e){if(e==null)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),i=1;i<arguments.length;i++){var l=arguments[i];if(l!=null)for(var c in l)Object.prototype.hasOwnProperty.call(l,c)&&(t[c]=l[c])}return t});var _T="113",vT=0,gx=1,xT=2,yx=1,bT=2,uh=3,nc=0,tr=1,hh=2,_x=1,vx=0,wT=1,ic=2,es=0,dh=1,xx=2,bx=3,wx=4,MT=5,rc=100,TT=101,ET=102,Tx=103,Ex=104,CT=200,AT=201,DT=202,PT=203,Cx=204,Ax=205,ST=206,LT=207,IT=208,RT=209,kT=210,zT=0,FT=1,BT=2,iy=3,OT=4,NT=5,UT=6,VT=7,Xp=0,GT=1,WT=2,Zp=0,ry=1,jT=2,HT=3,$T=4,qT=5,oy=300,ay=301,sy=302,Dx=303,ly=304,Px=305,ph=306,cy=307,Zs=1e3,Mr=1001,fh=1002,Ui=1003,Yp=1004,Kp=1005,$i=1006,uy=1007,oc=1008,Jp=1009,XT=1010,ZT=1011,Qp=1012,YT=1013,Sx=1014,mh=1015,hy=1016,KT=1017,JT=1018,QT=1019,ef=1020,eE=1021,Ma=1022,Ao=1023,tE=1024,nE=1025,iE=Ao,ac=1026,gh=1027,rE=1028,oE=1029,aE=1030,sE=1031,lE=1032,cE=1033,Lx=33776,Ix=33777,Rx=33778,kx=33779,zx=35840,Fx=35841,Bx=35842,Ox=35843,uE=36196,hE=37808,dE=37809,pE=37810,fE=37811,mE=37812,gE=37813,yE=37814,_E=37815,vE=37816,xE=37817,bE=37818,wE=37819,ME=37820,TE=37821,EE=2200,CE=2201,AE=2202,yh=2300,sc=2301,dy=2302,lc=2400,cc=2401,tf=2402,DE=0,PE=1,Nx=2,io=3e3,_h=3001,Ux=3007,py=3002,SE=3003,Vx=3004,Gx=3005,Wx=3006,LE=3200,IE=3201,Ys=0,RE=1,fy=7680,kE=519,nf=35044,vh=35048;function Ta(){}Object.assign(Ta.prototype,{addEventListener:function(e,t){this._listeners===void 0&&(this._listeners={});var i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)},hasEventListener:function(e,t){if(this._listeners===void 0)return!1;var i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1},removeEventListener:function(e,t){if(this._listeners!==void 0){var i=this._listeners,l=i[e];if(l!==void 0){var c=l.indexOf(t);c!==-1&&l.splice(c,1)}}},dispatchEvent:function(e){if(this._listeners!==void 0){var t=this._listeners,i=t[e.type];if(i!==void 0){e.target=this;for(var l=i.slice(0),c=0,h=l.length;c<h;c++)l[c].call(this,e)}}}});for(var sr=[],xh=0;xh<256;xh++)sr[xh]=(xh<16?"0":"")+xh.toString(16);var jn={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0,l=Math.random()*4294967295|0,c=sr[e&255]+sr[e>>8&255]+sr[e>>16&255]+sr[e>>24&255]+"-"+sr[t&255]+sr[t>>8&255]+"-"+sr[t>>16&15|64]+sr[t>>24&255]+"-"+sr[i&63|128]+sr[i>>8&255]+"-"+sr[i>>16&255]+sr[i>>24&255]+sr[l&255]+sr[l>>8&255]+sr[l>>16&255]+sr[l>>24&255];return c.toUpperCase()},clamp:function(e,t,i){return Math.max(t,Math.min(i,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,i,l,c){return l+(e-t)*(c-l)/(i-t)},lerp:function(e,t,i){return(1-i)*e+i*t},smoothstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t),e*e*(3-2*e))},smootherstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t),e*e*e*(e*(e*6-15)+10))},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*jn.DEG2RAD},radToDeg:function(e){return e*jn.RAD2DEG},isPowerOfTwo:function(e){return(e&e-1)===0&&e!==0},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,i,l,c){var h=Math.cos,f=Math.sin,r=h(i/2),v=f(i/2),x=h((t+l)/2),w=f((t+l)/2),b=h((t-l)/2),A=f((t-l)/2),L=h((l-t)/2),P=f((l-t)/2);c==="XYX"?e.set(r*w,v*b,v*A,r*x):c==="YZY"?e.set(v*A,r*w,v*b,r*x):c==="ZXZ"?e.set(v*b,v*A,r*w,r*x):c==="XZX"?e.set(r*w,v*P,v*L,r*x):c==="YXY"?e.set(v*L,r*w,v*P,r*x):c==="ZYZ"?e.set(v*P,v*L,r*w,r*x):console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order.")}};function Lt(e,t){this.x=e||0,this.y=t||0}Object.defineProperties(Lt.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(Lt.prototype,{isVector2:!0,set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return t!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return t!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},applyMatrix3:function(e){var t=this.x,i=this.y,l=e.elements;return this.x=l[0]*t+l[3]*i+l[6],this.y=l[1]*t+l[4]*i+l[7],this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this},clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},cross:function(e){return this.x*e.y-this.y*e.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var e=Math.atan2(this.y,this.x);return e<0&&(e+=2*Math.PI),e},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y;return t*t+i*i},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return t===void 0&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromBufferAttribute:function(e,t,i){return i!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){var i=Math.cos(t),l=Math.sin(t),c=this.x-e.x,h=this.y-e.y;return this.x=c*i-h*l+e.x,this.y=c*l+h*i+e.y,this}});function pr(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}Object.assign(pr.prototype,{isMatrix3:!0,set:function(e,t,i,l,c,h,f,r,v){var x=this.elements;return x[0]=e,x[1]=l,x[2]=f,x[3]=t,x[4]=c,x[5]=r,x[6]=i,x[7]=h,x[8]=v,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return new this.constructor().fromArray(this.elements)},copy:function(e){var t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},multiply:function(e){return this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var i=e.elements,l=t.elements,c=this.elements,h=i[0],f=i[3],r=i[6],v=i[1],x=i[4],w=i[7],b=i[2],A=i[5],L=i[8],P=l[0],R=l[3],F=l[6],V=l[1],j=l[4],J=l[7],ne=l[2],H=l[5],Q=l[8];return c[0]=h*P+f*V+r*ne,c[3]=h*R+f*j+r*H,c[6]=h*F+f*J+r*Q,c[1]=v*P+x*V+w*ne,c[4]=v*R+x*j+w*H,c[7]=v*F+x*J+w*Q,c[2]=b*P+A*V+L*ne,c[5]=b*R+A*j+L*H,c[8]=b*F+A*J+L*Q,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this},determinant:function(){var e=this.elements,t=e[0],i=e[1],l=e[2],c=e[3],h=e[4],f=e[5],r=e[6],v=e[7],x=e[8];return t*h*x-t*f*v-i*c*x+i*f*r+l*c*v-l*h*r},getInverse:function(e,t){e&&e.isMatrix4&&console.error("THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument.");var i=e.elements,l=this.elements,c=i[0],h=i[1],f=i[2],r=i[3],v=i[4],x=i[5],w=i[6],b=i[7],A=i[8],L=A*v-x*b,P=x*w-A*r,R=b*r-v*w,F=c*L+h*P+f*R;if(F===0){var V="THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0";if(t===!0)throw new Error(V);return console.warn(V),this.identity()}var j=1/F;return l[0]=L*j,l[1]=(f*b-A*h)*j,l[2]=(x*h-f*v)*j,l[3]=P*j,l[4]=(A*c-f*w)*j,l[5]=(f*r-x*c)*j,l[6]=R*j,l[7]=(h*w-b*c)*j,l[8]=(v*c-h*r)*j,this},transpose:function(){var e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this},getNormalMatrix:function(e){return this.setFromMatrix4(e).getInverse(this).transpose()},transposeIntoArray:function(e){var t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this},setUvTransform:function(e,t,i,l,c,h,f){var r=Math.cos(c),v=Math.sin(c);this.set(i*r,i*v,-i*(r*h+v*f)+h+e,-l*v,l*r,-l*(-v*h+r*f)+f+t,0,0,1)},scale:function(e,t){var i=this.elements;return i[0]*=e,i[3]*=e,i[6]*=e,i[1]*=t,i[4]*=t,i[7]*=t,this},rotate:function(e){var t=Math.cos(e),i=Math.sin(e),l=this.elements,c=l[0],h=l[3],f=l[6],r=l[1],v=l[4],x=l[7];return l[0]=t*c+i*r,l[3]=t*h+i*v,l[6]=t*f+i*x,l[1]=-i*c+t*r,l[4]=-i*h+t*v,l[7]=-i*f+t*x,this},translate:function(e,t){var i=this.elements;return i[0]+=e*i[2],i[3]+=e*i[5],i[6]+=e*i[8],i[1]+=t*i[2],i[4]+=t*i[5],i[7]+=t*i[8],this},equals:function(e){for(var t=this.elements,i=e.elements,l=0;l<9;l++)if(t[l]!==i[l])return!1;return!0},fromArray:function(e,t){t===void 0&&(t=0);for(var i=0;i<9;i++)this.elements[i]=e[i+t];return this},toArray:function(e,t){e===void 0&&(e=[]),t===void 0&&(t=0);var i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}});var uc,Ks={getDataURL:function(e){var t;if(typeof HTMLCanvasElement=="undefined")return e.src;if(e instanceof HTMLCanvasElement)t=e;else{uc===void 0&&(uc=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),uc.width=e.width,uc.height=e.height;var i=uc.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=uc}return t.width>2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}},zE=0;function mi(e,t,i,l,c,h,f,r,v,x){Object.defineProperty(this,"id",{value:zE++}),this.uuid=jn.generateUUID(),this.name="",this.image=e!==void 0?e:mi.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=t!==void 0?t:mi.DEFAULT_MAPPING,this.wrapS=i!==void 0?i:Mr,this.wrapT=l!==void 0?l:Mr,this.magFilter=c!==void 0?c:$i,this.minFilter=h!==void 0?h:oc,this.anisotropy=v!==void 0?v:1,this.format=f!==void 0?f:Ao,this.internalFormat=null,this.type=r!==void 0?r:Jp,this.offset=new Lt(0,0),this.repeat=new Lt(1,1),this.center=new Lt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new pr,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=x!==void 0?x:io,this.version=0,this.onUpdate=null}mi.DEFAULT_IMAGE=void 0,mi.DEFAULT_MAPPING=oy,mi.prototype=Object.assign(Object.create(Ta.prototype),{constructor:mi,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,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.encoding=e.encoding,this},toJSON:function(e){var t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];var i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,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,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(this.image!==void 0){var l=this.image;if(l.uuid===void 0&&(l.uuid=jn.generateUUID()),!t&&e.images[l.uuid]===void 0){var c;if(Array.isArray(l)){c=[];for(var h=0,f=l.length;h<f;h++)c.push(Ks.getDataURL(l[h]))}else c=Ks.getDataURL(l);e.images[l.uuid]={uuid:l.uuid,url:c}}i.image=l.uuid}return t||(e.textures[this.uuid]=i),i},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(e){if(this.mapping!==oy)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Zs:e.x=e.x-Math.floor(e.x);break;case Mr:e.x=e.x<0?0:1;break;case fh: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 Zs:e.y=e.y-Math.floor(e.y);break;case Mr:e.y=e.y<0?0:1;break;case fh: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}}),Object.defineProperty(mi.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}});function gi(e,t,i,l){this.x=e||0,this.y=t||0,this.z=i||0,this.w=l!==void 0?l:1}Object.defineProperties(gi.prototype,{width:{get:function(){return this.z},set:function(e){this.z=e}},height:{get:function(){return this.w},set:function(e){this.w=e}}}),Object.assign(gi.prototype,{isVector4:!0,set:function(e,t,i,l){return this.x=e,this.y=t,this.z=i,this.w=l,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(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:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(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:function(e,t){return t!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return t!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var t=this.x,i=this.y,l=this.z,c=this.w,h=e.elements;return this.x=h[0]*t+h[4]*i+h[8]*l+h[12]*c,this.y=h[1]*t+h[5]*i+h[9]*l+h[13]*c,this.z=h[2]*t+h[6]*i+h[10]*l+h[14]*c,this.w=h[3]*t+h[7]*i+h[11]*l+h[15]*c,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,i,l,c,h=.01,f=.1,r=e.elements,v=r[0],x=r[4],w=r[8],b=r[1],A=r[5],L=r[9],P=r[2],R=r[6],F=r[10];if(Math.abs(x-b)<h&&Math.abs(w-P)<h&&Math.abs(L-R)<h){if(Math.abs(x+b)<f&&Math.abs(w+P)<f&&Math.abs(L+R)<f&&Math.abs(v+A+F-3)<f)return this.set(1,0,0,0),this;t=Math.PI;var V=(v+1)/2,j=(A+1)/2,J=(F+1)/2,ne=(x+b)/4,H=(w+P)/4,Q=(L+R)/4;return V>j&&V>J?V<h?(i=0,l=.707106781,c=.707106781):(i=Math.sqrt(V),l=ne/i,c=H/i):j>J?j<h?(i=.707106781,l=0,c=.707106781):(l=Math.sqrt(j),i=ne/l,c=Q/l):J<h?(i=.707106781,l=.707106781,c=0):(c=Math.sqrt(J),i=H/c,l=Q/c),this.set(i,l,c,t),this}var ae=Math.sqrt((R-L)*(R-L)+(w-P)*(w-P)+(b-x)*(b-x));return Math.abs(ae)<.001&&(ae=1),this.x=(R-L)/ae,this.y=(w-P)/ae,this.z=(b-x)/ae,this.w=Math.acos((v+A+F-1)/2),this},min:function(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:function(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:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this},clampScalar:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this},clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},floor:function(){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:function(){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:function(){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:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},fromArray:function(e,t){return t===void 0&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this},toArray:function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e},fromBufferAttribute:function(e,t,i){return i!==void 0&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}});function Tr(e,t,i){this.width=e,this.height=t,this.scissor=new gi(0,0,e,t),this.scissorTest=!1,this.viewport=new gi(0,0,e,t),i=i||{},this.texture=new mi(void 0,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.image={},this.texture.image.width=e,this.texture.image.height=t,this.texture.generateMipmaps=i.generateMipmaps!==void 0?i.generateMipmaps:!1,this.texture.minFilter=i.minFilter!==void 0?i.minFilter:$i,this.depthBuffer=i.depthBuffer!==void 0?i.depthBuffer:!0,this.stencilBuffer=i.stencilBuffer!==void 0?i.stencilBuffer:!0,this.depthTexture=i.depthTexture!==void 0?i.depthTexture:null}Tr.prototype=Object.assign(Object.create(Ta.prototype),{constructor:Tr,isWebGLRenderTarget:!0,setSize:function(e,t){(this.width!==e||this.height!==t)&&(this.width=e,this.height=t,this.texture.image.width=e,this.texture.image.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});function jx(e,t,i){Tr.call(this,e,t,i),this.samples=4}jx.prototype=Object.assign(Object.create(Tr.prototype),{constructor:jx,isWebGLMultisampleRenderTarget:!0,copy:function(e){return Tr.prototype.copy.call(this,e),this.samples=e.samples,this}});function Nr(e,t,i,l){this._x=e||0,this._y=t||0,this._z=i||0,this._w=l!==void 0?l:1}Object.assign(Nr,{slerp:function(e,t,i,l){return i.copy(e).slerp(t,l)},slerpFlat:function(e,t,i,l,c,h,f){var r=i[l+0],v=i[l+1],x=i[l+2],w=i[l+3],b=c[h+0],A=c[h+1],L=c[h+2],P=c[h+3];if(w!==P||r!==b||v!==A||x!==L){var R=1-f,F=r*b+v*A+x*L+w*P,V=F>=0?1:-1,j=1-F*F;if(j>Number.EPSILON){var J=Math.sqrt(j),ne=Math.atan2(J,F*V);R=Math.sin(R*ne)/J,f=Math.sin(f*ne)/J}var H=f*V;if(r=r*R+b*H,v=v*R+A*H,x=x*R+L*H,w=w*R+P*H,R===1-f){var Q=1/Math.sqrt(r*r+v*v+x*x+w*w);r*=Q,v*=Q,x*=Q,w*=Q}}e[t]=r,e[t+1]=v,e[t+2]=x,e[t+3]=w}}),Object.defineProperties(Nr.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this._onChangeCallback()}}}),Object.assign(Nr.prototype,{isQuaternion:!0,set:function(e,t,i,l){return this._x=e,this._y=t,this._z=i,this._w=l,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this},setFromEuler:function(e,t){if(!(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var i=e._x,l=e._y,c=e._z,h=e.order,f=Math.cos,r=Math.sin,v=f(i/2),x=f(l/2),w=f(c/2),b=r(i/2),A=r(l/2),L=r(c/2);return h==="XYZ"?(this._x=b*x*w+v*A*L,this._y=v*A*w-b*x*L,this._z=v*x*L+b*A*w,this._w=v*x*w-b*A*L):h==="YXZ"?(this._x=b*x*w+v*A*L,this._y=v*A*w-b*x*L,this._z=v*x*L-b*A*w,this._w=v*x*w+b*A*L):h==="ZXY"?(this._x=b*x*w-v*A*L,this._y=v*A*w+b*x*L,this._z=v*x*L+b*A*w,this._w=v*x*w-b*A*L):h==="ZYX"?(this._x=b*x*w-v*A*L,this._y=v*A*w+b*x*L,this._z=v*x*L-b*A*w,this._w=v*x*w+b*A*L):h==="YZX"?(this._x=b*x*w+v*A*L,this._y=v*A*w+b*x*L,this._z=v*x*L-b*A*w,this._w=v*x*w-b*A*L):h==="XZY"&&(this._x=b*x*w-v*A*L,this._y=v*A*w-b*x*L,this._z=v*x*L+b*A*w,this._w=v*x*w+b*A*L),t!==!1&&this._onChangeCallback(),this},setFromAxisAngle:function(e,t){var i=t/2,l=Math.sin(i);return this._x=e.x*l,this._y=e.y*l,this._z=e.z*l,this._w=Math.cos(i),this._onChangeCallback(),this},setFromRotationMatrix:function(e){var t=e.elements,i=t[0],l=t[4],c=t[8],h=t[1],f=t[5],r=t[9],v=t[2],x=t[6],w=t[10],b=i+f+w,A;return b>0?(A=.5/Math.sqrt(b+1),this._w=.25/A,this._x=(x-r)*A,this._y=(c-v)*A,this._z=(h-l)*A):i>f&&i>w?(A=2*Math.sqrt(1+i-f-w),this._w=(x-r)/A,this._x=.25*A,this._y=(l+h)/A,this._z=(c+v)/A):f>w?(A=2*Math.sqrt(1+f-i-w),this._w=(c-v)/A,this._x=(l+h)/A,this._y=.25*A,this._z=(r+x)/A):(A=2*Math.sqrt(1+w-i-f),this._w=(h-l)/A,this._x=(c+v)/A,this._y=(r+x)/A,this._z=.25*A),this._onChangeCallback(),this},setFromUnitVectors:function(e,t){var i=1e-6,l=e.dot(t)+1;return l<i?(l=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=l):(this._x=0,this._y=-e.z,this._z=e.y,this._w=l)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=l),this.normalize()},angleTo:function(e){return 2*Math.acos(Math.abs(jn.clamp(this.dot(e),-1,1)))},rotateTowards:function(e,t){var i=this.angleTo(e);if(i===0)return this;var l=Math.min(1,t/i);return this.slerp(e,l),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var 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:function(e,t){return t!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var i=e._x,l=e._y,c=e._z,h=e._w,f=t._x,r=t._y,v=t._z,x=t._w;return this._x=i*x+h*f+l*v-c*r,this._y=l*x+h*r+c*f-i*v,this._z=c*x+h*v+i*r-l*f,this._w=h*x-i*f-l*r-c*v,this._onChangeCallback(),this},slerp:function(e,t){if(t===0)return this;if(t===1)return this.copy(e);var i=this._x,l=this._y,c=this._z,h=this._w,f=h*e._w+i*e._x+l*e._y+c*e._z;if(f<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,f=-f):this.copy(e),f>=1)return this._w=h,this._x=i,this._y=l,this._z=c,this;var r=1-f*f;if(r<=Number.EPSILON){var v=1-t;return this._w=v*h+t*this._w,this._x=v*i+t*this._x,this._y=v*l+t*this._y,this._z=v*c+t*this._z,this.normalize(),this._onChangeCallback(),this}var x=Math.sqrt(r),w=Math.atan2(x,f),b=Math.sin((1-t)*w)/x,A=Math.sin(t*w)/x;return this._w=h*b+this._w*A,this._x=i*b+this._x*A,this._y=l*b+this._y*A,this._z=c*b+this._z*A,this._onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return t===void 0&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this},toArray:function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},_onChange:function(e){return this._onChangeCallback=e,this},_onChangeCallback:function(){}});var my=new Pe,Hx=new Nr;function Pe(e,t,i){this.x=e||0,this.y=t||0,this.z=i||0}Object.assign(Pe.prototype,{isVector3:!0,set:function(e,t,i){return this.x=e,this.y=t,this.z=i,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(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:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return t!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return t!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return t!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:function(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Hx.setFromEuler(e))},applyAxisAngle:function(e,t){return this.applyQuaternion(Hx.setFromAxisAngle(e,t))},applyMatrix3:function(e){var t=this.x,i=this.y,l=this.z,c=e.elements;return this.x=c[0]*t+c[3]*i+c[6]*l,this.y=c[1]*t+c[4]*i+c[7]*l,this.z=c[2]*t+c[5]*i+c[8]*l,this},applyNormalMatrix:function(e){return this.applyMatrix3(e).normalize()},applyMatrix4:function(e){var t=this.x,i=this.y,l=this.z,c=e.elements,h=1/(c[3]*t+c[7]*i+c[11]*l+c[15]);return this.x=(c[0]*t+c[4]*i+c[8]*l+c[12])*h,this.y=(c[1]*t+c[5]*i+c[9]*l+c[13])*h,this.z=(c[2]*t+c[6]*i+c[10]*l+c[14])*h,this},applyQuaternion:function(e){var t=this.x,i=this.y,l=this.z,c=e.x,h=e.y,f=e.z,r=e.w,v=r*t+h*l-f*i,x=r*i+f*t-c*l,w=r*l+c*i-h*t,b=-c*t-h*i-f*l;return this.x=v*r+b*-c+x*-f-w*-h,this.y=x*r+b*-h+w*-c-v*-f,this.z=w*r+b*-f+v*-h-x*-c,this},project:function(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)},unproject:function(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)},transformDirection:function(e){var t=this.x,i=this.y,l=this.z,c=e.elements;return this.x=c[0]*t+c[4]*i+c[8]*l,this.y=c[1]*t+c[5]*i+c[9]*l,this.z=c[2]*t+c[6]*i+c[10]*l,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(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:function(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:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this},clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e)},cross:function(e,t){return t!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)},crossVectors:function(e,t){var i=e.x,l=e.y,c=e.z,h=t.x,f=t.y,r=t.z;return this.x=l*r-c*f,this.y=c*h-i*r,this.z=i*f-l*h,this},projectOnVector:function(e){var t=e.lengthSq();if(t===0)return this.set(0,0,0);var i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)},projectOnPlane:function(e){return my.copy(this).projectOnVector(e),this.sub(my)},reflect:function(e){return this.sub(my.copy(e).multiplyScalar(2*this.dot(e)))},angleTo:function(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;var i=this.dot(e)/t;return Math.acos(jn.clamp(i,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y,l=this.z-e.z;return t*t+i*i+l*l},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)},setFromSphericalCoords:function(e,t,i){var l=Math.sin(t)*e;return this.x=l*Math.sin(i),this.y=Math.cos(t)*e,this.z=l*Math.cos(i),this},setFromCylindrical:function(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)},setFromCylindricalCoords:function(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this},setFromMatrixPosition:function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),l=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=l,this},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,t*4)},setFromMatrix3Column:function(e,t){return this.fromArray(e.elements,t*3)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return t===void 0&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromBufferAttribute:function(e,t,i){return i!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}});var hc=new Pe,Do=new Hn,FE=new Pe(0,0,0),BE=new Pe(1,1,1),ts=new Pe,rf=new Pe,ro=new Pe;function Hn(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}Object.assign(Hn.prototype,{isMatrix4:!0,set:function(e,t,i,l,c,h,f,r,v,x,w,b,A,L,P,R){var F=this.elements;return F[0]=e,F[4]=t,F[8]=i,F[12]=l,F[1]=c,F[5]=h,F[9]=f,F[13]=r,F[2]=v,F[6]=x,F[10]=w,F[14]=b,F[3]=A,F[7]=L,F[11]=P,F[15]=R,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return new Hn().fromArray(this.elements)},copy:function(e){var t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this},copyPosition:function(e){var t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this},extractBasis:function(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this},extractRotation:function(e){var t=this.elements,i=e.elements,l=1/hc.setFromMatrixColumn(e,0).length(),c=1/hc.setFromMatrixColumn(e,1).length(),h=1/hc.setFromMatrixColumn(e,2).length();return t[0]=i[0]*l,t[1]=i[1]*l,t[2]=i[2]*l,t[3]=0,t[4]=i[4]*c,t[5]=i[5]*c,t[6]=i[6]*c,t[7]=0,t[8]=i[8]*h,t[9]=i[9]*h,t[10]=i[10]*h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromEuler:function(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,i=e.x,l=e.y,c=e.z,h=Math.cos(i),f=Math.sin(i),r=Math.cos(l),v=Math.sin(l),x=Math.cos(c),w=Math.sin(c);if(e.order==="XYZ"){var b=h*x,A=h*w,L=f*x,P=f*w;t[0]=r*x,t[4]=-r*w,t[8]=v,t[1]=A+L*v,t[5]=b-P*v,t[9]=-f*r,t[2]=P-b*v,t[6]=L+A*v,t[10]=h*r}else if(e.order==="YXZ"){var R=r*x,F=r*w,V=v*x,j=v*w;t[0]=R+j*f,t[4]=V*f-F,t[8]=h*v,t[1]=h*w,t[5]=h*x,t[9]=-f,t[2]=F*f-V,t[6]=j+R*f,t[10]=h*r}else if(e.order==="ZXY"){var R=r*x,F=r*w,V=v*x,j=v*w;t[0]=R-j*f,t[4]=-h*w,t[8]=V+F*f,t[1]=F+V*f,t[5]=h*x,t[9]=j-R*f,t[2]=-h*v,t[6]=f,t[10]=h*r}else if(e.order==="ZYX"){var b=h*x,A=h*w,L=f*x,P=f*w;t[0]=r*x,t[4]=L*v-A,t[8]=b*v+P,t[1]=r*w,t[5]=P*v+b,t[9]=A*v-L,t[2]=-v,t[6]=f*r,t[10]=h*r}else if(e.order==="YZX"){var J=h*r,ne=h*v,H=f*r,Q=f*v;t[0]=r*x,t[4]=Q-J*w,t[8]=H*w+ne,t[1]=w,t[5]=h*x,t[9]=-f*x,t[2]=-v*x,t[6]=ne*w+H,t[10]=J-Q*w}else if(e.order==="XZY"){var J=h*r,ne=h*v,H=f*r,Q=f*v;t[0]=r*x,t[4]=-w,t[8]=v*x,t[1]=J*w+Q,t[5]=h*x,t[9]=ne*w-H,t[2]=H*w-ne,t[6]=f*x,t[10]=Q*w+J}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(e){return this.compose(FE,e,BE)},lookAt:function(e,t,i){var l=this.elements;return ro.subVectors(e,t),ro.lengthSq()===0&&(ro.z=1),ro.normalize(),ts.crossVectors(i,ro),ts.lengthSq()===0&&(Math.abs(i.z)===1?ro.x+=1e-4:ro.z+=1e-4,ro.normalize(),ts.crossVectors(i,ro)),ts.normalize(),rf.crossVectors(ro,ts),l[0]=ts.x,l[4]=rf.x,l[8]=ro.x,l[1]=ts.y,l[5]=rf.y,l[9]=ro.y,l[2]=ts.z,l[6]=rf.z,l[10]=ro.z,this},multiply:function(e,t){return t!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var i=e.elements,l=t.elements,c=this.elements,h=i[0],f=i[4],r=i[8],v=i[12],x=i[1],w=i[5],b=i[9],A=i[13],L=i[2],P=i[6],R=i[10],F=i[14],V=i[3],j=i[7],J=i[11],ne=i[15],H=l[0],Q=l[4],ae=l[8],ie=l[12],le=l[1],fe=l[5],me=l[9],he=l[13],Oe=l[2],Ve=l[6],He=l[10],at=l[14],At=l[3],yt=l[7],Dt=l[11],It=l[15];return c[0]=h*H+f*le+r*Oe+v*At,c[4]=h*Q+f*fe+r*Ve+v*yt,c[8]=h*ae+f*me+r*He+v*Dt,c[12]=h*ie+f*he+r*at+v*It,c[1]=x*H+w*le+b*Oe+A*At,c[5]=x*Q+w*fe+b*Ve+A*yt,c[9]=x*ae+w*me+b*He+A*Dt,c[13]=x*ie+w*he+b*at+A*It,c[2]=L*H+P*le+R*Oe+F*At,c[6]=L*Q+P*fe+R*Ve+F*yt,c[10]=L*ae+P*me+R*He+F*Dt,c[14]=L*ie+P*he+R*at+F*It,c[3]=V*H+j*le+J*Oe+ne*At,c[7]=V*Q+j*fe+J*Ve+ne*yt,c[11]=V*ae+j*me+J*He+ne*Dt,c[15]=V*ie+j*he+J*at+ne*It,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},determinant:function(){var e=this.elements,t=e[0],i=e[4],l=e[8],c=e[12],h=e[1],f=e[5],r=e[9],v=e[13],x=e[2],w=e[6],b=e[10],A=e[14],L=e[3],P=e[7],R=e[11],F=e[15];return L*(+c*r*w-l*v*w-c*f*b+i*v*b+l*f*A-i*r*A)+P*(+t*r*A-t*v*b+c*h*b-l*h*A+l*v*x-c*r*x)+R*(+t*v*w-t*f*A-c*h*w+i*h*A+c*f*x-i*v*x)+F*(-l*f*x-t*r*w+t*f*b+l*h*w-i*h*b+i*r*x)},transpose:function(){var e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},setPosition:function(e,t,i){var l=this.elements;return e.isVector3?(l[12]=e.x,l[13]=e.y,l[14]=e.z):(l[12]=e,l[13]=t,l[14]=i),this},getInverse:function(e,t){var i=this.elements,l=e.elements,c=l[0],h=l[1],f=l[2],r=l[3],v=l[4],x=l[5],w=l[6],b=l[7],A=l[8],L=l[9],P=l[10],R=l[11],F=l[12],V=l[13],j=l[14],J=l[15],ne=L*j*b-V*P*b+V*w*R-x*j*R-L*w*J+x*P*J,H=F*P*b-A*j*b-F*w*R+v*j*R+A*w*J-v*P*J,Q=A*V*b-F*L*b+F*x*R-v*V*R-A*x*J+v*L*J,ae=F*L*w-A*V*w-F*x*P+v*V*P+A*x*j-v*L*j,ie=c*ne+h*H+f*Q+r*ae;if(ie===0){var le="THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0";if(t===!0)throw new Error(le);return console.warn(le),this.identity()}var fe=1/ie;return i[0]=ne*fe,i[1]=(V*P*r-L*j*r-V*f*R+h*j*R+L*f*J-h*P*J)*fe,i[2]=(x*j*r-V*w*r+V*f*b-h*j*b-x*f*J+h*w*J)*fe,i[3]=(L*w*r-x*P*r-L*f*b+h*P*b+x*f*R-h*w*R)*fe,i[4]=H*fe,i[5]=(A*j*r-F*P*r+F*f*R-c*j*R-A*f*J+c*P*J)*fe,i[6]=(F*w*r-v*j*r-F*f*b+c*j*b+v*f*J-c*w*J)*fe,i[7]=(v*P*r-A*w*r+A*f*b-c*P*b-v*f*R+c*w*R)*fe,i[8]=Q*fe,i[9]=(F*L*r-A*V*r-F*h*R+c*V*R+A*h*J-c*L*J)*fe,i[10]=(v*V*r-F*x*r+F*h*b-c*V*b-v*h*J+c*x*J)*fe,i[11]=(A*x*r-v*L*r-A*h*b+c*L*b+v*h*R-c*x*R)*fe,i[12]=ae*fe,i[13]=(A*V*f-F*L*f+F*h*P-c*V*P-A*h*j+c*L*j)*fe,i[14]=(F*x*f-v*V*f-F*h*w+c*V*w+v*h*j-c*x*j)*fe,i[15]=(v*L*f-A*x*f+A*h*w-c*L*w-v*h*P+c*x*P)*fe,this},scale:function(e){var t=this.elements,i=e.x,l=e.y,c=e.z;return t[0]*=i,t[4]*=l,t[8]*=c,t[1]*=i,t[5]*=l,t[9]*=c,t[2]*=i,t[6]*=l,t[10]*=c,t[3]*=i,t[7]*=l,t[11]*=c,this},getMaxScaleOnAxis:function(){var e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],l=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,l))},makeTranslation:function(e,t,i){return this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this},makeRotationX:function(e){var t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this},makeRotationY:function(e){var t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this},makeRotationZ:function(e){var t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(e,t){var i=Math.cos(t),l=Math.sin(t),c=1-i,h=e.x,f=e.y,r=e.z,v=c*h,x=c*f;return this.set(v*h+i,v*f-l*r,v*r+l*f,0,v*f+l*r,x*f+i,x*r-l*h,0,v*r-l*f,x*r+l*h,c*r*r+i,0,0,0,0,1),this},makeScale:function(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this},makeShear:function(e,t,i){return this.set(1,t,i,0,e,1,i,0,e,t,1,0,0,0,0,1),this},compose:function(e,t,i){var l=this.elements,c=t._x,h=t._y,f=t._z,r=t._w,v=c+c,x=h+h,w=f+f,b=c*v,A=c*x,L=c*w,P=h*x,R=h*w,F=f*w,V=r*v,j=r*x,J=r*w,ne=i.x,H=i.y,Q=i.z;return l[0]=(1-(P+F))*ne,l[1]=(A+J)*ne,l[2]=(L-j)*ne,l[3]=0,l[4]=(A-J)*H,l[5]=(1-(b+F))*H,l[6]=(R+V)*H,l[7]=0,l[8]=(L+j)*Q,l[9]=(R-V)*Q,l[10]=(1-(b+P))*Q,l[11]=0,l[12]=e.x,l[13]=e.y,l[14]=e.z,l[15]=1,this},decompose:function(e,t,i){var l=this.elements,c=hc.set(l[0],l[1],l[2]).length(),h=hc.set(l[4],l[5],l[6]).length(),f=hc.set(l[8],l[9],l[10]).length(),r=this.determinant();r<0&&(c=-c),e.x=l[12],e.y=l[13],e.z=l[14],Do.copy(this);var v=1/c,x=1/h,w=1/f;return Do.elements[0]*=v,Do.elements[1]*=v,Do.elements[2]*=v,Do.elements[4]*=x,Do.elements[5]*=x,Do.elements[6]*=x,Do.elements[8]*=w,Do.elements[9]*=w,Do.elements[10]*=w,t.setFromRotationMatrix(Do),i.x=c,i.y=h,i.z=f,this},makePerspective:function(e,t,i,l,c,h){h===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var f=this.elements,r=2*c/(t-e),v=2*c/(i-l),x=(t+e)/(t-e),w=(i+l)/(i-l),b=-(h+c)/(h-c),A=-2*h*c/(h-c);return f[0]=r,f[4]=0,f[8]=x,f[12]=0,f[1]=0,f[5]=v,f[9]=w,f[13]=0,f[2]=0,f[6]=0,f[10]=b,f[14]=A,f[3]=0,f[7]=0,f[11]=-1,f[15]=0,this},makeOrthographic:function(e,t,i,l,c,h){var f=this.elements,r=1/(t-e),v=1/(i-l),x=1/(h-c),w=(t+e)*r,b=(i+l)*v,A=(h+c)*x;return f[0]=2*r,f[4]=0,f[8]=0,f[12]=-w,f[1]=0,f[5]=2*v,f[9]=0,f[13]=-b,f[2]=0,f[6]=0,f[10]=-2*x,f[14]=-A,f[3]=0,f[7]=0,f[11]=0,f[15]=1,this},equals:function(e){for(var t=this.elements,i=e.elements,l=0;l<16;l++)if(t[l]!==i[l])return!1;return!0},fromArray:function(e,t){t===void 0&&(t=0);for(var i=0;i<16;i++)this.elements[i]=e[i+t];return this},toArray:function(e,t){e===void 0&&(e=[]),t===void 0&&(t=0);var i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}});var $x=new Hn,qx=new Nr;function dc(e,t,i,l){this._x=e||0,this._y=t||0,this._z=i||0,this._order=l||dc.DefaultOrder}dc.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],dc.DefaultOrder="XYZ",Object.defineProperties(dc.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()}},order:{get:function(){return this._order},set:function(e){this._order=e,this._onChangeCallback()}}}),Object.assign(dc.prototype,{isEuler:!0,set:function(e,t,i,l){return this._x=e,this._y=t,this._z=i,this._order=l||this._order,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this},setFromRotationMatrix:function(e,t,i){var l=jn.clamp,c=e.elements,h=c[0],f=c[4],r=c[8],v=c[1],x=c[5],w=c[9],b=c[2],A=c[6],L=c[10];return t=t||this._order,t==="XYZ"?(this._y=Math.asin(l(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(-w,L),this._z=Math.atan2(-f,h)):(this._x=Math.atan2(A,x),this._z=0)):t==="YXZ"?(this._x=Math.asin(-l(w,-1,1)),Math.abs(w)<.9999999?(this._y=Math.atan2(r,L),this._z=Math.atan2(v,x)):(this._y=Math.atan2(-b,h),this._z=0)):t==="ZXY"?(this._x=Math.asin(l(A,-1,1)),Math.abs(A)<.9999999?(this._y=Math.atan2(-b,L),this._z=Math.atan2(-f,x)):(this._y=0,this._z=Math.atan2(v,h))):t==="ZYX"?(this._y=Math.asin(-l(b,-1,1)),Math.abs(b)<.9999999?(this._x=Math.atan2(A,L),this._z=Math.atan2(v,h)):(this._x=0,this._z=Math.atan2(-f,x))):t==="YZX"?(this._z=Math.asin(l(v,-1,1)),Math.abs(v)<.9999999?(this._x=Math.atan2(-w,x),this._y=Math.atan2(-b,h)):(this._x=0,this._y=Math.atan2(r,L))):t==="XZY"?(this._z=Math.asin(-l(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(A,x),this._y=Math.atan2(r,h)):(this._x=Math.atan2(-w,L),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+t),this._order=t,i!==!1&&this._onChangeCallback(),this},setFromQuaternion:function(e,t,i){return $x.makeRotationFromQuaternion(e),this.setFromRotationMatrix($x,t,i)},setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:function(e){return qx.setFromEuler(this),this.setFromQuaternion(qx,e)},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order},fromArray:function(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:function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new Pe(this._x,this._y,this._z)},_onChange:function(e){return this._onChangeCallback=e,this},_onChangeCallback:function(){}});function Xx(){this.mask=1}Object.assign(Xx.prototype,{set:function(e){this.mask=1<<e|0},enable:function(e){this.mask|=1<<e|0},enableAll:function(){this.mask=-1},toggle:function(e){this.mask^=1<<e|0},disable:function(e){this.mask&=~(1<<e|0)},disableAll:function(){this.mask=0},test:function(e){return(this.mask&e.mask)!==0}});var OE=0,Zx=new Pe,pc=new Nr,Ea=new Hn,of=new Pe,bh=new Pe,NE=new Pe,UE=new Nr,Yx=new Pe(1,0,0),Kx=new Pe(0,1,0),Jx=new Pe(0,0,1),VE={type:"added"},GE={type:"removed"};function on(){Object.defineProperty(this,"id",{value:OE++}),this.uuid=jn.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=on.DefaultUp.clone();var e=new Pe,t=new dc,i=new Nr,l=new Pe(1,1,1);function c(){i.setFromEuler(t,!1)}function h(){t.setFromQuaternion(i,void 0,!1)}t._onChange(c),i._onChange(h),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:l},modelViewMatrix:{value:new Hn},normalMatrix:{value:new pr}}),this.matrix=new Hn,this.matrixWorld=new Hn,this.matrixAutoUpdate=on.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Xx,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}on.DefaultUp=new Pe(0,1,0),on.DefaultMatrixAutoUpdate=!0,on.prototype=Object.assign(Object.create(Ta.prototype),{constructor:on,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(e){return this.quaternion.premultiply(e),this},setRotationFromAxisAngle:function(e,t){this.quaternion.setFromAxisAngle(e,t)},setRotationFromEuler:function(e){this.quaternion.setFromEuler(e,!0)},setRotationFromMatrix:function(e){this.quaternion.setFromRotationMatrix(e)},setRotationFromQuaternion:function(e){this.quaternion.copy(e)},rotateOnAxis:function(e,t){return pc.setFromAxisAngle(e,t),this.quaternion.multiply(pc),this},rotateOnWorldAxis:function(e,t){return pc.setFromAxisAngle(e,t),this.quaternion.premultiply(pc),this},rotateX:function(e){return this.rotateOnAxis(Yx,e)},rotateY:function(e){return this.rotateOnAxis(Kx,e)},rotateZ:function(e){return this.rotateOnAxis(Jx,e)},translateOnAxis:function(e,t){return Zx.copy(e).applyQuaternion(this.quaternion),this.position.add(Zx.multiplyScalar(t)),this},translateX:function(e){return this.translateOnAxis(Yx,e)},translateY:function(e){return this.translateOnAxis(Kx,e)},translateZ:function(e){return this.translateOnAxis(Jx,e)},localToWorld:function(e){return e.applyMatrix4(this.matrixWorld)},worldToLocal:function(e){return e.applyMatrix4(Ea.getInverse(this.matrixWorld))},lookAt:function(e,t,i){e.isVector3?of.copy(e):of.set(e,t,i);var l=this.parent;this.updateWorldMatrix(!0,!1),bh.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ea.lookAt(bh,of,this.up):Ea.lookAt(of,bh,this.up),this.quaternion.setFromRotationMatrix(Ea),l&&(Ea.extractRotation(l.matrixWorld),pc.setFromRotationMatrix(Ea),this.quaternion.premultiply(pc.inverse()))},add:function(e){if(arguments.length>1){for(var t=0;t<arguments.length;t++)this.add(arguments[t]);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(VE)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)},remove:function(e){if(arguments.length>1){for(var t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}var i=this.children.indexOf(e);return i!==-1&&(e.parent=null,this.children.splice(i,1),e.dispatchEvent(GE)),this},attach:function(e){return this.updateWorldMatrix(!0,!1),Ea.getInverse(this.matrixWorld),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ea.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ea),e.updateWorldMatrix(!1,!1),this.add(e),this},getObjectById:function(e){return this.getObjectByProperty("id",e)},getObjectByName:function(e){return this.getObjectByProperty("name",e)},getObjectByProperty:function(e,t){if(this[e]===t)return this;for(var i=0,l=this.children.length;i<l;i++){var c=this.children[i],h=c.getObjectByProperty(e,t);if(h!==void 0)return h}},getWorldPosition:function(e){return e===void 0&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),e=new Pe),this.updateMatrixWorld(!0),e.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(e){return e===void 0&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),e=new Nr),this.updateMatrixWorld(!0),this.matrixWorld.decompose(bh,e,NE),e},getWorldScale:function(e){return e===void 0&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),e=new Pe),this.updateMatrixWorld(!0),this.matrixWorld.decompose(bh,UE,e),e},getWorldDirection:function(e){e===void 0&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),e=new Pe),this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()},raycast:function(){},traverse:function(e){e(this);for(var t=this.children,i=0,l=t.length;i<l;i++)t[i].traverse(e)},traverseVisible:function(e){if(this.visible!==!1){e(this);for(var t=this.children,i=0,l=t.length;i<l;i++)t[i].traverseVisible(e)}},traverseAncestors:function(e){var t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(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);for(var t=this.children,i=0,l=t.length;i<l;i++)t[i].updateMatrixWorld(e)},updateWorldMatrix:function(e,t){var i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0)for(var l=this.children,c=0,h=l.length;c<h;c++)l[c].updateWorldMatrix(!1,!0)},toJSON:function(e){var t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{}},i.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var l={};l.uuid=this.uuid,l.type=this.type,this.name!==""&&(l.name=this.name),this.castShadow===!0&&(l.castShadow=!0),this.receiveShadow===!0&&(l.receiveShadow=!0),this.visible===!1&&(l.visible=!1),this.frustumCulled===!1&&(l.frustumCulled=!1),this.renderOrder!==0&&(l.renderOrder=this.renderOrder),JSON.stringify(this.userData)!=="{}"&&(l.userData=this.userData),l.layers=this.layers.mask,l.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(l.matrixAutoUpdate=!1),this.isInstancedMesh&&(l.type="InstancedMesh",l.count=this.count,l.instanceMatrix=this.instanceMatrix.toJSON());function c(F,V){return F[V.uuid]===void 0&&(F[V.uuid]=V.toJSON(e)),V.uuid}if(this.isMesh||this.isLine||this.isPoints){l.geometry=c(e.geometries,this.geometry);var h=this.geometry.parameters;if(h!==void 0&&h.shapes!==void 0){var f=h.shapes;if(Array.isArray(f))for(var r=0,v=f.length;r<v;r++){var x=f[r];c(e.shapes,x)}else c(e.shapes,f)}}if(this.material!==void 0)if(Array.isArray(this.material)){for(var w=[],r=0,v=this.material.length;r<v;r++)w.push(c(e.materials,this.material[r]));l.material=w}else l.material=c(e.materials,this.material);if(this.children.length>0){l.children=[];for(var r=0;r<this.children.length;r++)l.children.push(this.children[r].toJSON(e).object)}if(t){var b=R(e.geometries),A=R(e.materials),L=R(e.textures),P=R(e.images),f=R(e.shapes);b.length>0&&(i.geometries=b),A.length>0&&(i.materials=A),L.length>0&&(i.textures=L),P.length>0&&(i.images=P),f.length>0&&(i.shapes=f)}return i.object=l,i;function R(F){var V=[];for(var j in F){var J=F[j];delete J.metadata,V.push(J)}return V}},clone:function(e){return new this.constructor().copy(this,e)},copy:function(e,t){if(t===void 0&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),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.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.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(var i=0;i<e.children.length;i++){var l=e.children[i];this.add(l.clone())}return this}});function Ca(){on.call(this),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}Ca.prototype=Object.assign(Object.create(on.prototype),{constructor:Ca,isScene:!0,copy:function(e,t){return on.prototype.copy.call(this,e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this},toJSON:function(e){var t=on.prototype.toJSON.call(this,e);return this.background!==null&&(t.object.background=this.background.toJSON(e)),this.environment!==null&&(t.object.environment=this.environment.toJSON(e)),this.fog!==null&&(t.object.fog=this.fog.toJSON()),t},dispose:function(){this.dispatchEvent({type:"dispose"})}});var Aa=[new Pe,new Pe,new Pe,new Pe,new Pe,new Pe,new Pe,new Pe],wh=new Pe,af=new Po,fc=new Pe,mc=new Pe,gc=new Pe,ns=new Pe,is=new Pe,Js=new Pe,Mh=new Pe,sf=new Pe,lf=new Pe,Qs=new Pe;function Po(e,t){this.min=e!==void 0?e:new Pe(1/0,1/0,1/0),this.max=t!==void 0?t:new Pe(-1/0,-1/0,-1/0)}Object.assign(Po.prototype,{isBox3:!0,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){for(var t=1/0,i=1/0,l=1/0,c=-1/0,h=-1/0,f=-1/0,r=0,v=e.length;r<v;r+=3){var x=e[r],w=e[r+1],b=e[r+2];x<t&&(t=x),w<i&&(i=w),b<l&&(l=b),x>c&&(c=x),w>h&&(h=w),b>f&&(f=b)}return this.min.set(t,i,l),this.max.set(c,h,f),this},setFromBufferAttribute:function(e){for(var t=1/0,i=1/0,l=1/0,c=-1/0,h=-1/0,f=-1/0,r=0,v=e.count;r<v;r++){var x=e.getX(r),w=e.getY(r),b=e.getZ(r);x<t&&(t=x),w<i&&(i=w),b<l&&(l=b),x>c&&(c=x),w>h&&(h=w),b>f&&(f=b)}return this.min.set(t,i,l),this.max.set(c,h,f),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this},setFromCenterAndSize:function(e,t){var i=wh.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this},setFromObject:function(e){return this.makeEmpty(),this.expandByObject(e)},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){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:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(e){return e===void 0&&(console.warn("THREE.Box3: .getCenter() target is now required"),e=new Pe),this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(e){return e===void 0&&(console.warn("THREE.Box3: .getSize() target is now required"),e=new Pe),this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)},expandByPoint:function(e){return this.min.min(e),this.max.max(e),this},expandByVector:function(e){return this.min.sub(e),this.max.add(e),this},expandByScalar:function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},expandByObject:function(e){e.updateWorldMatrix(!1,!1);var t=e.geometry;t!==void 0&&(t.boundingBox===null&&t.computeBoundingBox(),af.copy(t.boundingBox),af.applyMatrix4(e.matrixWorld),this.expandByPoint(af.min),this.expandByPoint(af.max));for(var i=e.children,l=0,c=i.length;l<c;l++)this.expandByObject(i[l]);return this},containsPoint:function(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:function(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:function(e,t){return t===void 0&&(console.warn("THREE.Box3: .getParameter() target is now required"),t=new Pe),t.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:function(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:function(e){return this.clampPoint(e.center,wh),wh.distanceToSquared(e.center)<=e.radius*e.radius},intersectsPlane:function(e){var t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant},intersectsTriangle:function(e){if(this.isEmpty())return!1;this.getCenter(Mh),sf.subVectors(this.max,Mh),fc.subVectors(e.a,Mh),mc.subVectors(e.b,Mh),gc.subVectors(e.c,Mh),ns.subVectors(mc,fc),is.subVectors(gc,mc),Js.subVectors(fc,gc);var t=[0,-ns.z,ns.y,0,-is.z,is.y,0,-Js.z,Js.y,ns.z,0,-ns.x,is.z,0,-is.x,Js.z,0,-Js.x,-ns.y,ns.x,0,-is.y,is.x,0,-Js.y,Js.x,0];return!gy(t,fc,mc,gc,sf)||(t=[1,0,0,0,1,0,0,0,1],!gy(t,fc,mc,gc,sf))?!1:(lf.crossVectors(ns,is),t=[lf.x,lf.y,lf.z],gy(t,fc,mc,gc,sf))},clampPoint:function(e,t){return t===void 0&&(console.warn("THREE.Box3: .clampPoint() target is now required"),t=new Pe),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){var t=wh.copy(e).clamp(this.min,this.max);return t.sub(e).length()},getBoundingSphere:function(e){return e===void 0&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(e.center),e.radius=this.getSize(wh).length()*.5,e},intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(e){return this.isEmpty()?this:(Aa[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Aa[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Aa[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Aa[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Aa[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Aa[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Aa[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Aa[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Aa),this)},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}});function gy(e,t,i,l,c){var h,f;for(h=0,f=e.length-3;h<=f;h+=3){Qs.fromArray(e,h);var r=c.x*Math.abs(Qs.x)+c.y*Math.abs(Qs.y)+c.z*Math.abs(Qs.z),v=t.dot(Qs),x=i.dot(Qs),w=l.dot(Qs);if(Math.max(-Math.max(v,x,w),Math.min(v,x,w))>r)return!1}return!0}var WE=new Po;function Da(e,t){this.center=e!==void 0?e:new Pe,this.radius=t!==void 0?t:0}Object.assign(Da.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(e,t){var i=this.center;t!==void 0?i.copy(t):WE.setFromPoints(e).getCenter(i);for(var l=0,c=0,h=e.length;c<h;c++)l=Math.max(l,i.distanceToSquared(e[c]));return this.radius=Math.sqrt(l),this},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.center.copy(e.center),this.radius=e.radius,this},empty:function(){return this.radius<=0},containsPoint:function(e){return e.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(e){return e.distanceTo(this.center)-this.radius},intersectsSphere:function(e){var t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t},intersectsBox:function(e){return e.intersectsSphere(this)},intersectsPlane:function(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius},clampPoint:function(e,t){var i=this.center.distanceToSquared(e);return t===void 0&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),t=new Pe),t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t},getBoundingBox:function(e){return e===void 0&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),e=new Po),e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}});var Pa=new Pe,yy=new Pe,cf=new Pe,rs=new Pe,_y=new Pe,uf=new Pe,vy=new Pe;function yc(e,t){this.origin=e!==void 0?e:new Pe,this.direction=t!==void 0?t:new Pe(0,0,-1)}Object.assign(yc.prototype,{set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){return t===void 0&&(console.warn("THREE.Ray: .at() target is now required"),t=new Pe),t.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(e){return this.origin.copy(this.at(e,Pa)),this},closestPointToPoint:function(e,t){t===void 0&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),t=new Pe),t.subVectors(e,this.origin);var i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(i).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(e){var t=Pa.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Pa.copy(this.direction).multiplyScalar(t).add(this.origin),Pa.distanceToSquared(e))},distanceSqToSegment:function(e,t,i,l){yy.copy(e).add(t).multiplyScalar(.5),cf.copy(t).sub(e).normalize(),rs.copy(this.origin).sub(yy);var c=e.distanceTo(t)*.5,h=-this.direction.dot(cf),f=rs.dot(this.direction),r=-rs.dot(cf),v=rs.lengthSq(),x=Math.abs(1-h*h),w,b,A,L;if(x>0)if(w=h*r-f,b=h*f-r,L=c*x,w>=0)if(b>=-L)if(b<=L){var P=1/x;w*=P,b*=P,A=w*(w+h*b+2*f)+b*(h*w+b+2*r)+v}else b=c,w=Math.max(0,-(h*b+f)),A=-w*w+b*(b+2*r)+v;else b=-c,w=Math.max(0,-(h*b+f)),A=-w*w+b*(b+2*r)+v;else b<=-L?(w=Math.max(0,-(-h*c+f)),b=w>0?-c:Math.min(Math.max(-c,-r),c),A=-w*w+b*(b+2*r)+v):b<=L?(w=0,b=Math.min(Math.max(-c,-r),c),A=b*(b+2*r)+v):(w=Math.max(0,-(h*c+f)),b=w>0?c:Math.min(Math.max(-c,-r),c),A=-w*w+b*(b+2*r)+v);else b=h>0?-c:c,w=Math.max(0,-(h*b+f)),A=-w*w+b*(b+2*r)+v;return i&&i.copy(this.direction).multiplyScalar(w).add(this.origin),l&&l.copy(cf).multiplyScalar(b).add(yy),A},intersectSphere:function(e,t){Pa.subVectors(e.center,this.origin);var i=Pa.dot(this.direction),l=Pa.dot(Pa)-i*i,c=e.radius*e.radius;if(l>c)return null;var h=Math.sqrt(c-l),f=i-h,r=i+h;return f<0&&r<0?null:f<0?this.at(r,t):this.at(f,t)},intersectsSphere:function(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;var i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null},intersectPlane:function(e,t){var i=this.distanceToPlane(e);return i===null?null:this.at(i,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);if(t===0)return!0;var i=e.normal.dot(this.direction);return i*t<0},intersectBox:function(e,t){var i,l,c,h,f,r,v=1/this.direction.x,x=1/this.direction.y,w=1/this.direction.z,b=this.origin;return v>=0?(i=(e.min.x-b.x)*v,l=(e.max.x-b.x)*v):(i=(e.max.x-b.x)*v,l=(e.min.x-b.x)*v),x>=0?(c=(e.min.y-b.y)*x,h=(e.max.y-b.y)*x):(c=(e.max.y-b.y)*x,h=(e.min.y-b.y)*x),i>h||c>l||((c>i||i!==i)&&(i=c),(h<l||l!==l)&&(l=h),w>=0?(f=(e.min.z-b.z)*w,r=(e.max.z-b.z)*w):(f=(e.max.z-b.z)*w,r=(e.min.z-b.z)*w),i>r||f>l)||((f>i||i!==i)&&(i=f),(r<l||l!==l)&&(l=r),l<0)?null:this.at(i>=0?i:l,t)},intersectsBox:function(e){return this.intersectBox(e,Pa)!==null},intersectTriangle:function(e,t,i,l,c){_y.subVectors(t,e),uf.subVectors(i,e),vy.crossVectors(_y,uf);var h=this.direction.dot(vy),f;if(h>0){if(l)return null;f=1}else if(h<0)f=-1,h=-h;else return null;rs.subVectors(this.origin,e);var r=f*this.direction.dot(uf.crossVectors(rs,uf));if(r<0)return null;var v=f*this.direction.dot(_y.cross(rs));if(v<0||r+v>h)return null;var x=-f*rs.dot(vy);return x<0?null:this.at(x/h,c)},applyMatrix4:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}});var xy=new Pe,jE=new Pe,HE=new pr;function $o(e,t){this.normal=e!==void 0?e:new Pe(1,0,0),this.constant=t!==void 0?t:0}Object.assign($o.prototype,{isPlane:!0,set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,i,l){return this.normal.set(e,t,i),this.constant=l,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(e,t,i){var l=xy.subVectors(i,t).cross(jE.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(l,e),this},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return t===void 0&&(console.warn("THREE.Plane: .projectPoint() target is now required"),t=new Pe),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(e,t){t===void 0&&(console.warn("THREE.Plane: .intersectLine() target is now required"),t=new Pe);var i=e.delta(xy),l=this.normal.dot(i);if(l===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):void 0;var c=-(e.start.dot(this.normal)+this.constant)/l;if(!(c<0||c>1))return t.copy(i).multiplyScalar(c).add(e.start)},intersectsLine:function(e){var t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return e===void 0&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),e=new Pe),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(e,t){var i=t||HE.getNormalMatrix(e),l=this.coplanarPoint(xy).applyMatrix4(e),c=this.normal.applyMatrix3(i).normalize();return this.constant=-l.dot(c),this},translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}});var So=new Pe,Sa=new Pe,by=new Pe,La=new Pe,_c=new Pe,vc=new Pe,Qx=new Pe,wy=new Pe,My=new Pe,Ty=new Pe;function lr(e,t,i){this.a=e!==void 0?e:new Pe,this.b=t!==void 0?t:new Pe,this.c=i!==void 0?i:new Pe}Object.assign(lr,{getNormal:function(e,t,i,l){l===void 0&&(console.warn("THREE.Triangle: .getNormal() target is now required"),l=new Pe),l.subVectors(i,t),So.subVectors(e,t),l.cross(So);var c=l.lengthSq();return c>0?l.multiplyScalar(1/Math.sqrt(c)):l.set(0,0,0)},getBarycoord:function(e,t,i,l,c){So.subVectors(l,t),Sa.subVectors(i,t),by.subVectors(e,t);var h=So.dot(So),f=So.dot(Sa),r=So.dot(by),v=Sa.dot(Sa),x=Sa.dot(by),w=h*v-f*f;if(c===void 0&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),c=new Pe),w===0)return c.set(-2,-1,-1);var b=1/w,A=(v*r-f*x)*b,L=(h*x-f*r)*b;return c.set(1-A-L,L,A)},containsPoint:function(e,t,i,l){return lr.getBarycoord(e,t,i,l,La),La.x>=0&&La.y>=0&&La.x+La.y<=1},getUV:function(e,t,i,l,c,h,f,r){return this.getBarycoord(e,t,i,l,La),r.set(0,0),r.addScaledVector(c,La.x),r.addScaledVector(h,La.y),r.addScaledVector(f,La.z),r},isFrontFacing:function(e,t,i,l){return So.subVectors(i,t),Sa.subVectors(e,t),So.cross(Sa).dot(l)<0}}),Object.assign(lr.prototype,{set:function(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this},setFromPointsAndIndices:function(e,t,i,l){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[l]),this},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},getArea:function(){return So.subVectors(this.c,this.b),Sa.subVectors(this.a,this.b),So.cross(Sa).length()*.5},getMidpoint:function(e){return e===void 0&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),e=new Pe),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(.3333333333333333)},getNormal:function(e){return lr.getNormal(this.a,this.b,this.c,e)},getPlane:function(e){return e===void 0&&(console.warn("THREE.Triangle: .getPlane() target is now required"),e=new $o),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,t){return lr.getBarycoord(e,this.a,this.b,this.c,t)},getUV:function(e,t,i,l,c){return lr.getUV(e,this.a,this.b,this.c,t,i,l,c)},containsPoint:function(e){return lr.containsPoint(e,this.a,this.b,this.c)},isFrontFacing:function(e){return lr.isFrontFacing(this.a,this.b,this.c,e)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:function(e,t){t===void 0&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),t=new Pe);var i=this.a,l=this.b,c=this.c,h,f;_c.subVectors(l,i),vc.subVectors(c,i),wy.subVectors(e,i);var r=_c.dot(wy),v=vc.dot(wy);if(r<=0&&v<=0)return t.copy(i);My.subVectors(e,l);var x=_c.dot(My),w=vc.dot(My);if(x>=0&&w<=x)return t.copy(l);var b=r*w-x*v;if(b<=0&&r>=0&&x<=0)return h=r/(r-x),t.copy(i).addScaledVector(_c,h);Ty.subVectors(e,c);var A=_c.dot(Ty),L=vc.dot(Ty);if(L>=0&&A<=L)return t.copy(c);var P=A*v-r*L;if(P<=0&&v>=0&&L<=0)return f=v/(v-L),t.copy(i).addScaledVector(vc,f);var R=x*L-A*w;if(R<=0&&w-x>=0&&A-L>=0)return Qx.subVectors(c,l),f=(w-x)/(w-x+(A-L)),t.copy(l).addScaledVector(Qx,f);var F=1/(R+P+b);return h=P*F,f=b*F,t.copy(i).addScaledVector(_c,h).addScaledVector(vc,f)},equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}});var e0={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},Lo={h:0,s:0,l:0},hf={h:0,s:0,l:0};function tn(e,t,i){return t===void 0&&i===void 0?this.set(e):this.setRGB(e,t,i)}function Ey(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<.16666666666666666?e+(t-e)*6*i:i<.5?t:i<.6666666666666666?e+(t-e)*6*(.6666666666666666-i):e}function Cy(e){return e<.04045?e*.0773993808:Math.pow(e*.9478672986+.0521327014,2.4)}function Ay(e){return e<.0031308?e*12.92:1.055*Math.pow(e,.41666)-.055}Object.assign(tn.prototype,{isColor:!0,r:1,g:1,b:1,set:function(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this},setScalar:function(e){return this.r=e,this.g=e,this.b=e,this},setHex:function(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,this},setRGB:function(e,t,i){return this.r=e,this.g=t,this.b=i,this},setHSL:function(e,t,i){if(e=jn.euclideanModulo(e,1),t=jn.clamp(t,0,1),i=jn.clamp(i,0,1),t===0)this.r=this.g=this.b=i;else{var l=i<=.5?i*(1+t):i+t-i*t,c=2*i-l;this.r=Ey(c,l,e+.3333333333333333),this.g=Ey(c,l,e),this.b=Ey(c,l,e-.3333333333333333)}return this},setStyle:function(e){function t(b){b!==void 0&&parseFloat(b)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var l,c=i[1],h=i[2];switch(c){case"rgb":case"rgba":if(l=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(h))return this.r=Math.min(255,parseInt(l[1],10))/255,this.g=Math.min(255,parseInt(l[2],10))/255,this.b=Math.min(255,parseInt(l[3],10))/255,t(l[5]),this;if(l=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(h))return this.r=Math.min(100,parseInt(l[1],10))/100,this.g=Math.min(100,parseInt(l[2],10))/100,this.b=Math.min(100,parseInt(l[3],10))/100,t(l[5]),this;break;case"hsl":case"hsla":if(l=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(h)){var f=parseFloat(l[1])/360,r=parseInt(l[2],10)/100,v=parseInt(l[3],10)/100;return t(l[5]),this.setHSL(f,r,v)}break}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(e)){var x=i[1],w=x.length;if(w===3)return this.r=parseInt(x.charAt(0)+x.charAt(0),16)/255,this.g=parseInt(x.charAt(1)+x.charAt(1),16)/255,this.b=parseInt(x.charAt(2)+x.charAt(2),16)/255,this;if(w===6)return this.r=parseInt(x.charAt(0)+x.charAt(1),16)/255,this.g=parseInt(x.charAt(2)+x.charAt(3),16)/255,this.b=parseInt(x.charAt(4)+x.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this},setColorName:function(e){var t=e0[e];return t!==void 0?this.setHex(t):console.warn("THREE.Color: Unknown color "+e),this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return t===void 0&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){t===void 0&&(t=2);var i=t>0?1/t:1;return this.r=Math.pow(e.r,i),this.g=Math.pow(e.g,i),this.b=Math.pow(e.b,i),this},convertGammaToLinear:function(e){return this.copyGammaToLinear(this,e),this},convertLinearToGamma:function(e){return this.copyLinearToGamma(this,e),this},copySRGBToLinear:function(e){return this.r=Cy(e.r),this.g=Cy(e.g),this.b=Cy(e.b),this},copyLinearToSRGB:function(e){return this.r=Ay(e.r),this.g=Ay(e.g),this.b=Ay(e.b),this},convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return this.r*255<<16^this.g*255<<8^this.b*255<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){e===void 0&&(console.warn("THREE.Color: .getHSL() target is now required"),e={h:0,s:0,l:0});var t=this.r,i=this.g,l=this.b,c=Math.max(t,i,l),h=Math.min(t,i,l),f,r,v=(h+c)/2;if(h===c)f=0,r=0;else{var x=c-h;switch(r=v<=.5?x/(c+h):x/(2-c-h),c){case t:f=(i-l)/x+(i<l?6:0);break;case i:f=(l-t)/x+2;break;case l:f=(t-i)/x+4;break}f/=6}return e.h=f,e.s=r,e.l=v,e},getStyle:function(){return"rgb("+(this.r*255|0)+","+(this.g*255|0)+","+(this.b*255|0)+")"},offsetHSL:function(e,t,i){return this.getHSL(Lo),Lo.h+=e,Lo.s+=t,Lo.l+=i,this.setHSL(Lo.h,Lo.s,Lo.l),this},add:function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this},addColors:function(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this},addScalar:function(e){return this.r+=e,this.g+=e,this.b+=e,this},sub:function(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:function(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this},multiplyScalar:function(e){return this.r*=e,this.g*=e,this.b*=e,this},lerp:function(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this},lerpHSL:function(e,t){this.getHSL(Lo),e.getHSL(hf);var i=jn.lerp(Lo.h,hf.h,t),l=jn.lerp(Lo.s,hf.s,t),c=jn.lerp(Lo.l,hf.l,t);return this.setHSL(i,l,c),this},equals:function(e){return e.r===this.r&&e.g===this.g&&e.b===this.b},fromArray:function(e,t){return t===void 0&&(t=0),this.r=e[t],this.g=e[t+1],this.b=e[t+2],this},toArray:function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e},toJSON:function(){return this.getHex()}}),tn.NAMES=e0;function df(e,t,i,l,c,h){this.a=e,this.b=t,this.c=i,this.normal=l&&l.isVector3?l:new Pe,this.vertexNormals=Array.isArray(l)?l:[],this.color=c&&c.isColor?c:new tn,this.vertexColors=Array.isArray(c)?c:[],this.materialIndex=h!==void 0?h:0}Object.assign(df.prototype,{clone:function(){return new this.constructor().copy(this)},copy:function(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(var t=0,i=e.vertexNormals.length;t<i;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(var t=0,i=e.vertexColors.length;t<i;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}});var $E=0;function Rn(){Object.defineProperty(this,"id",{value:$E++}),this.uuid=jn.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=dh,this.side=nc,this.flatShading=!1,this.vertexTangents=!1,this.vertexColors=vx,this.opacity=1,this.transparent=!1,this.blendSrc=Cx,this.blendDst=Ax,this.blendEquation=rc,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=iy,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=kE,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=fy,this.stencilZFail=fy,this.stencilZPass=fy,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.alphaTest=0,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}Rn.prototype=Object.assign(Object.create(Ta.prototype),{constructor:Rn,isMaterial:!0,onBeforeCompile:function(){},setValues:function(e){if(e!==void 0)for(var t in e){var i=e[t];if(i===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if(t==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=i===_x;continue}var l=this[t];if(l===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}l&&l.isColor?l.set(i):l&&l.isVector3&&i&&i.isVector3?l.copy(i):this[t]=i}},toJSON:function(e){var t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});var i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(i.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,i.reflectivity=this.reflectivity,i.refractionRatio=this.refractionRatio,this.combine!==void 0&&(i.combine=this.combine),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.size!==void 0&&(i.size=this.size),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==dh&&(i.blending=this.blending),this.flatShading===!0&&(i.flatShading=this.flatShading),this.side!==nc&&(i.side=this.side),this.vertexColors!==vx&&(i.vertexColors=this.vertexColors),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.morphTargets===!0&&(i.morphTargets=!0),this.morphNormals===!0&&(i.morphNormals=!0),this.skinning===!0&&(i.skinning=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),JSON.stringify(this.userData)!=="{}"&&(i.userData=this.userData);function l(f){var r=[];for(var v in f){var x=f[v];delete x.metadata,r.push(x)}return r}if(t){var c=l(e.textures),h=l(e.images);c.length>0&&(i.textures=c),h.length>0&&(i.images=h)}return i},clone:function(){return new this.constructor().copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,this.vertexTangents=e.vertexTangents,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.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;var t=e.clippingPlanes,i=null;if(t!==null){var l=t.length;i=new Array(l);for(var c=0;c!==l;++c)i[c]=t[c].clone()}return this.clippingPlanes=i,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.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(Rn.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}});function cr(e){Rn.call(this),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.combine=Xp,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.setValues(e)}cr.prototype=Object.create(Rn.prototype),cr.prototype.constructor=cr,cr.prototype.isMeshBasicMaterial=!0,cr.prototype.copy=function(e){return Rn.prototype.copy.call(this,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.skinning=e.skinning,this.morphTargets=e.morphTargets,this};var pi=new Pe;function kn(e,t,i){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i===!0,this.usage=nf,this.updateRange={offset:0,count:-1},this.version=0}Object.defineProperty(kn.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(kn.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(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},copyAt:function(e,t,i){e*=this.itemSize,i*=t.itemSize;for(var l=0,c=this.itemSize;l<c;l++)this.array[e+l]=t.array[i+l];return this},copyArray:function(e){return this.array.set(e),this},copyColorsArray:function(e){for(var t=this.array,i=0,l=0,c=e.length;l<c;l++){var h=e[l];h===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",l),h=new tn),t[i++]=h.r,t[i++]=h.g,t[i++]=h.b}return this},copyVector2sArray:function(e){for(var t=this.array,i=0,l=0,c=e.length;l<c;l++){var h=e[l];h===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",l),h=new Lt),t[i++]=h.x,t[i++]=h.y}return this},copyVector3sArray:function(e){for(var t=this.array,i=0,l=0,c=e.length;l<c;l++){var h=e[l];h===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",l),h=new Pe),t[i++]=h.x,t[i++]=h.y,t[i++]=h.z}return this},copyVector4sArray:function(e){for(var t=this.array,i=0,l=0,c=e.length;l<c;l++){var h=e[l];h===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",l),h=new gi),t[i++]=h.x,t[i++]=h.y,t[i++]=h.z,t[i++]=h.w}return this},applyMatrix3:function(e){for(var t=0,i=this.count;t<i;t++)pi.x=this.getX(t),pi.y=this.getY(t),pi.z=this.getZ(t),pi.applyMatrix3(e),this.setXYZ(t,pi.x,pi.y,pi.z);return this},applyMatrix4:function(e){for(var t=0,i=this.count;t<i;t++)pi.x=this.getX(t),pi.y=this.getY(t),pi.z=this.getZ(t),pi.applyMatrix4(e),this.setXYZ(t,pi.x,pi.y,pi.z);return this},applyNormalMatrix:function(e){for(var t=0,i=this.count;t<i;t++)pi.x=this.getX(t),pi.y=this.getY(t),pi.z=this.getZ(t),pi.applyNormalMatrix(e),this.setXYZ(t,pi.x,pi.y,pi.z);return this},transformDirection:function(e){for(var t=0,i=this.count;t<i;t++)pi.x=this.getX(t),pi.y=this.getY(t),pi.z=this.getZ(t),pi.transformDirection(e),this.setXYZ(t,pi.x,pi.y,pi.z);return this},set:function(e,t){return t===void 0&&(t=0),this.array.set(e,t),this},getX:function(e){return this.array[e*this.itemSize]},setX:function(e,t){return this.array[e*this.itemSize]=t,this},getY:function(e){return this.array[e*this.itemSize+1]},setY:function(e,t){return this.array[e*this.itemSize+1]=t,this},getZ:function(e){return this.array[e*this.itemSize+2]},setZ:function(e,t){return this.array[e*this.itemSize+2]=t,this},getW:function(e){return this.array[e*this.itemSize+3]},setW:function(e,t){return this.array[e*this.itemSize+3]=t,this},setXY:function(e,t,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this},setXYZ:function(e,t,i,l){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=l,this},setXYZW:function(e,t,i,l,c){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=l,this.array[e+3]=c,this},onUpload:function(e){return this.onUploadCallback=e,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)},toJSON:function(){return{itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized}}});function Dy(e,t,i){kn.call(this,new Int8Array(e),t,i)}Dy.prototype=Object.create(kn.prototype),Dy.prototype.constructor=Dy;function Py(e,t,i){kn.call(this,new Uint8Array(e),t,i)}Py.prototype=Object.create(kn.prototype),Py.prototype.constructor=Py;function Sy(e,t,i){kn.call(this,new Uint8ClampedArray(e),t,i)}Sy.prototype=Object.create(kn.prototype),Sy.prototype.constructor=Sy;function Ly(e,t,i){kn.call(this,new Int16Array(e),t,i)}Ly.prototype=Object.create(kn.prototype),Ly.prototype.constructor=Ly;function Th(e,t,i){kn.call(this,new Uint16Array(e),t,i)}Th.prototype=Object.create(kn.prototype),Th.prototype.constructor=Th;function Iy(e,t,i){kn.call(this,new Int32Array(e),t,i)}Iy.prototype=Object.create(kn.prototype),Iy.prototype.constructor=Iy;function Eh(e,t,i){kn.call(this,new Uint32Array(e),t,i)}Eh.prototype=Object.create(kn.prototype),Eh.prototype.constructor=Eh;function ln(e,t,i){kn.call(this,new Float32Array(e),t,i)}ln.prototype=Object.create(kn.prototype),ln.prototype.constructor=ln;function Ry(e,t,i){kn.call(this,new Float64Array(e),t,i)}Ry.prototype=Object.create(kn.prototype),Ry.prototype.constructor=Ry;function t0(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}Object.assign(t0.prototype,{computeGroups:function(e){for(var t,i=[],l=void 0,c=e.faces,h=0;h<c.length;h++){var f=c[h];f.materialIndex!==l&&(l=f.materialIndex,t!==void 0&&(t.count=h*3-t.start,i.push(t)),t={start:h*3,materialIndex:l})}t!==void 0&&(t.count=h*3-t.start,i.push(t)),this.groups=i},fromGeometry:function(e){var t=e.faces,i=e.vertices,l=e.faceVertexUvs,c=l[0]&&l[0].length>0,h=l[1]&&l[1].length>0,f=e.morphTargets,r=f.length,v;if(r>0){v=[];for(var x=0;x<r;x++)v[x]={name:f[x].name,data:[]};this.morphTargets.position=v}var w=e.morphNormals,b=w.length,A;if(b>0){A=[];for(var x=0;x<b;x++)A[x]={name:w[x].name,data:[]};this.morphTargets.normal=A}var L=e.skinIndices,P=e.skinWeights,R=L.length===i.length,F=P.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(var x=0;x<t.length;x++){var V=t[x];this.vertices.push(i[V.a],i[V.b],i[V.c]);var j=V.vertexNormals;if(j.length===3)this.normals.push(j[0],j[1],j[2]);else{var J=V.normal;this.normals.push(J,J,J)}var ne=V.vertexColors;if(ne.length===3)this.colors.push(ne[0],ne[1],ne[2]);else{var H=V.color;this.colors.push(H,H,H)}if(c===!0){var Q=l[0][x];Q!==void 0?this.uvs.push(Q[0],Q[1],Q[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",x),this.uvs.push(new Lt,new Lt,new Lt))}if(h===!0){var Q=l[1][x];Q!==void 0?this.uvs2.push(Q[0],Q[1],Q[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",x),this.uvs2.push(new Lt,new Lt,new Lt))}for(var ae=0;ae<r;ae++){var ie=f[ae].vertices;v[ae].data.push(ie[V.a],ie[V.b],ie[V.c])}for(var ae=0;ae<b;ae++){var le=w[ae].vertexNormals[x];A[ae].data.push(le.a,le.b,le.c)}R&&this.skinIndices.push(L[V.a],L[V.b],L[V.c]),F&&this.skinWeights.push(P[V.a],P[V.b],P[V.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}});function n0(e){if(e.length===0)return-1/0;for(var t=e[0],i=1,l=e.length;i<l;++i)e[i]>t&&(t=e[i]);return t}var qE=1,qo=new Hn,ky=new on,xc=new Pe,oo=new Po,Ch=new Po,qi=new Pe;function vn(){Object.defineProperty(this,"id",{value:qE+=2}),this.uuid=jn.generateUUID(),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={}}vn.prototype=Object.assign(Object.create(Ta.prototype),{constructor:vn,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(e){Array.isArray(e)?this.index=new(n0(e)>65535?Eh:Th)(e,1):this.index=e},getAttribute:function(e){return this.attributes[e]},setAttribute:function(e,t){return this.attributes[e]=t,this},deleteAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,i){this.groups.push({start:e,count:t,materialIndex:i!==void 0?i:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix4:function(e){var t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);var i=this.attributes.normal;if(i!==void 0){var l=new pr().getNormalMatrix(e);i.applyNormalMatrix(l),i.needsUpdate=!0}var c=this.attributes.tangent;return c!==void 0&&(c.transformDirection(e),c.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this},rotateX:function(e){return qo.makeRotationX(e),this.applyMatrix4(qo),this},rotateY:function(e){return qo.makeRotationY(e),this.applyMatrix4(qo),this},rotateZ:function(e){return qo.makeRotationZ(e),this.applyMatrix4(qo),this},translate:function(e,t,i){return qo.makeTranslation(e,t,i),this.applyMatrix4(qo),this},scale:function(e,t,i){return qo.makeScale(e,t,i),this.applyMatrix4(qo),this},lookAt:function(e){return ky.lookAt(e),ky.updateMatrix(),this.applyMatrix4(ky.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(xc).negate(),this.translate(xc.x,xc.y,xc.z),this},setFromObject:function(e){var t=e.geometry;if(e.isPoints||e.isLine){var i=new ln(t.vertices.length*3,3),l=new ln(t.colors.length*3,3);if(this.setAttribute("position",i.copyVector3sArray(t.vertices)),this.setAttribute("color",l.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var c=new ln(t.lineDistances.length,1);this.setAttribute("lineDistance",c.copyArray(t.lineDistances))}t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone())}else e.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},setFromPoints:function(e){for(var t=[],i=0,l=e.length;i<l;i++){var c=e[i];t.push(c.x,c.y,c.z||0)}return this.setAttribute("position",new ln(t,3)),this},updateFromObject:function(e){var t=e.geometry;if(e.isMesh){var i=t.__directGeometry;if(t.elementsNeedUpdate===!0&&(i=void 0,t.elementsNeedUpdate=!1),i===void 0)return this.fromGeometry(t);i.verticesNeedUpdate=t.verticesNeedUpdate,i.normalsNeedUpdate=t.normalsNeedUpdate,i.colorsNeedUpdate=t.colorsNeedUpdate,i.uvsNeedUpdate=t.uvsNeedUpdate,i.groupsNeedUpdate=t.groupsNeedUpdate,t.verticesNeedUpdate=!1,t.normalsNeedUpdate=!1,t.colorsNeedUpdate=!1,t.uvsNeedUpdate=!1,t.groupsNeedUpdate=!1,t=i}var l;return t.verticesNeedUpdate===!0&&(l=this.attributes.position,l!==void 0&&(l.copyVector3sArray(t.vertices),l.needsUpdate=!0),t.verticesNeedUpdate=!1),t.normalsNeedUpdate===!0&&(l=this.attributes.normal,l!==void 0&&(l.copyVector3sArray(t.normals),l.needsUpdate=!0),t.normalsNeedUpdate=!1),t.colorsNeedUpdate===!0&&(l=this.attributes.color,l!==void 0&&(l.copyColorsArray(t.colors),l.needsUpdate=!0),t.colorsNeedUpdate=!1),t.uvsNeedUpdate&&(l=this.attributes.uv,l!==void 0&&(l.copyVector2sArray(t.uvs),l.needsUpdate=!0),t.uvsNeedUpdate=!1),t.lineDistancesNeedUpdate&&(l=this.attributes.lineDistance,l!==void 0&&(l.copyArray(t.lineDistances),l.needsUpdate=!0),t.lineDistancesNeedUpdate=!1),t.groupsNeedUpdate&&(t.computeGroups(e.geometry),this.groups=t.groups,t.groupsNeedUpdate=!1),this},fromGeometry:function(e){return e.__directGeometry=new t0().fromGeometry(e),this.fromDirectGeometry(e.__directGeometry)},fromDirectGeometry:function(e){var t=new Float32Array(e.vertices.length*3);if(this.setAttribute("position",new kn(t,3).copyVector3sArray(e.vertices)),e.normals.length>0){var i=new Float32Array(e.normals.length*3);this.setAttribute("normal",new kn(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var l=new Float32Array(e.colors.length*3);this.setAttribute("color",new kn(l,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var c=new Float32Array(e.uvs.length*2);this.setAttribute("uv",new kn(c,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var h=new Float32Array(e.uvs2.length*2);this.setAttribute("uv2",new kn(h,2).copyVector2sArray(e.uvs2))}this.groups=e.groups;for(var f in e.morphTargets){for(var r=[],v=e.morphTargets[f],x=0,w=v.length;x<w;x++){var b=v[x],A=new ln(b.data.length*3,3);A.name=b.name,r.push(A.copyVector3sArray(b.data))}this.morphAttributes[f]=r}if(e.skinIndices.length>0){var L=new ln(e.skinIndices.length*4,4);this.setAttribute("skinIndex",L.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var P=new ln(e.skinWeights.length*4,4);this.setAttribute("skinWeight",P.copyVector4sArray(e.skinWeights))}return e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){this.boundingBox===null&&(this.boundingBox=new Po);var e=this.attributes.position,t=this.morphAttributes.position;if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(var i=0,l=t.length;i<l;i++){var c=t[i];oo.setFromBufferAttribute(c),this.morphTargetsRelative?(qi.addVectors(this.boundingBox.min,oo.min),this.boundingBox.expandByPoint(qi),qi.addVectors(this.boundingBox.max,oo.max),this.boundingBox.expandByPoint(qi)):(this.boundingBox.expandByPoint(oo.min),this.boundingBox.expandByPoint(oo.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:function(){this.boundingSphere===null&&(this.boundingSphere=new Da);var e=this.attributes.position,t=this.morphAttributes.position;if(e){var i=this.boundingSphere.center;if(oo.setFromBufferAttribute(e),t)for(var l=0,c=t.length;l<c;l++){var h=t[l];Ch.setFromBufferAttribute(h),this.morphTargetsRelative?(qi.addVectors(oo.min,Ch.min),oo.expandByPoint(qi),qi.addVectors(oo.max,Ch.max),oo.expandByPoint(qi)):(oo.expandByPoint(Ch.min),oo.expandByPoint(Ch.max))}oo.getCenter(i);for(var f=0,l=0,c=e.count;l<c;l++)qi.fromBufferAttribute(e,l),f=Math.max(f,i.distanceToSquared(qi));if(t)for(var l=0,c=t.length;l<c;l++)for(var h=t[l],r=this.morphTargetsRelative,v=0,x=h.count;v<x;v++)qi.fromBufferAttribute(h,v),r&&(xc.fromBufferAttribute(e,v),qi.add(xc)),f=Math.max(f,i.distanceToSquared(qi));this.boundingSphere.radius=Math.sqrt(f),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}},computeFaceNormals:function(){},computeVertexNormals:function(){var e=this.index,t=this.attributes;if(t.position){var i=t.position.array;if(t.normal===void 0)this.setAttribute("normal",new kn(new Float32Array(i.length),3));else for(var l=t.normal.array,c=0,h=l.length;c<h;c++)l[c]=0;var f=t.normal.array,r,v,x,w=new Pe,b=new Pe,A=new Pe,L=new Pe,P=new Pe;if(e)for(var R=e.array,c=0,h=e.count;c<h;c+=3)r=R[c+0]*3,v=R[c+1]*3,x=R[c+2]*3,w.fromArray(i,r),b.fromArray(i,v),A.fromArray(i,x),L.subVectors(A,b),P.subVectors(w,b),L.cross(P),f[r]+=L.x,f[r+1]+=L.y,f[r+2]+=L.z,f[v]+=L.x,f[v+1]+=L.y,f[v+2]+=L.z,f[x]+=L.x,f[x+1]+=L.y,f[x+2]+=L.z;else for(var c=0,h=i.length;c<h;c+=9)w.fromArray(i,c),b.fromArray(i,c+3),A.fromArray(i,c+6),L.subVectors(A,b),P.subVectors(w,b),L.cross(P),f[c]=L.x,f[c+1]=L.y,f[c+2]=L.z,f[c+3]=L.x,f[c+4]=L.y,f[c+5]=L.z,f[c+6]=L.x,f[c+7]=L.y,f[c+8]=L.z;this.normalizeNormals(),t.normal.needsUpdate=!0}},merge:function(e,t){if(!(e&&e.isBufferGeometry)){console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e);return}t===void 0&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));var i=this.attributes;for(var l in i)if(e.attributes[l]!==void 0)for(var c=i[l],h=c.array,f=e.attributes[l],r=f.array,v=f.itemSize*t,x=Math.min(r.length,h.length-v),w=0,b=v;w<x;w++,b++)h[b]=r[w];return this},normalizeNormals:function(){for(var e=this.attributes.normal,t=0,i=e.count;t<i;t++)qi.x=e.getX(t),qi.y=e.getY(t),qi.z=e.getZ(t),qi.normalize(),e.setXYZ(t,qi.x,qi.y,qi.z)},toNonIndexed:function(){function e(R,F){for(var V=R.array,j=R.itemSize,J=new V.constructor(F.length*j),ne=0,H=0,Q=0,ae=F.length;Q<ae;Q++){ne=F[Q]*j;for(var ie=0;ie<j;ie++)J[H++]=V[ne++]}return new kn(J,j)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var t=new vn,i=this.index.array,l=this.attributes;for(var c in l){var h=l[c],f=e(h,i);t.setAttribute(c,f)}var r=this.morphAttributes;for(c in r){for(var v=[],x=r[c],w=0,b=x.length;w<b;w++){var h=x[w],f=e(h,i);v.push(f)}t.morphAttributes[c]=v}t.morphTargetsRelative=this.morphTargetsRelative;for(var A=this.groups,w=0,L=A.length;w<L;w++){var P=A[w];t.addGroup(P.start,P.count,P.materialIndex)}return t},toJSON:function(){var e={metadata:{version:4.5,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){var t=this.parameters;for(var i in t)t[i]!==void 0&&(e[i]=t[i]);return e}e.data={attributes:{}};var l=this.index;l!==null&&(e.data.index={type:l.array.constructor.name,array:Array.prototype.slice.call(l.array)});var c=this.attributes;for(var i in c){var h=c[i],f=h.toJSON();h.name!==""&&(f.name=h.name),e.data.attributes[i]=f}var r={},v=!1;for(var i in this.morphAttributes){for(var x=this.morphAttributes[i],w=[],b=0,A=x.length;b<A;b++){var h=x[b],f=h.toJSON();h.name!==""&&(f.name=h.name),w.push(f)}w.length>0&&(r[i]=w,v=!0)}v&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);var L=this.groups;L.length>0&&(e.data.groups=JSON.parse(JSON.stringify(L)));var P=this.boundingSphere;return P!==null&&(e.data.boundingSphere={center:P.center.toArray(),radius:P.radius}),e},clone:function(){return new vn().copy(this)},copy:function(e){var t,i,l;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var c=e.index;c!==null&&this.setIndex(c.clone());var h=e.attributes;for(t in h){var f=h[t];this.setAttribute(t,f.clone())}var r=e.morphAttributes;for(t in r){var v=[],x=r[t];for(i=0,l=x.length;i<l;i++)v.push(x[i].clone());this.morphAttributes[t]=v}this.morphTargetsRelative=e.morphTargetsRelative;var w=e.groups;for(i=0,l=w.length;i<l;i++){var b=w[i];this.addGroup(b.start,b.count,b.materialIndex)}var A=e.boundingBox;A!==null&&(this.boundingBox=A.clone());var L=e.boundingSphere;return L!==null&&(this.boundingSphere=L.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var i0=new Hn,el=new yc,zy=new Da,tl=new Pe,nl=new Pe,il=new Pe,Fy=new Pe,By=new Pe,Oy=new Pe,pf=new Pe,ff=new Pe,mf=new Pe,bc=new Lt,wc=new Lt,Mc=new Lt,Ah=new Pe,gf=new Pe;function Ai(e,t){on.call(this),this.type="Mesh",this.geometry=e!==void 0?e:new vn,this.material=t!==void 0?t:new cr,this.updateMorphTargets()}Ai.prototype=Object.assign(Object.create(on.prototype),{constructor:Ai,isMesh:!0,copy:function(e){return on.prototype.copy.call(this,e),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this},updateMorphTargets:function(){var e=this.geometry,t,i,l;if(e.isBufferGeometry){var c=e.morphAttributes,h=Object.keys(c);if(h.length>0){var f=c[h[0]];if(f!==void 0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,i=f.length;t<i;t++)l=f[t].name||String(t),this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=t}}else{var r=e.morphTargets;r!==void 0&&r.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(e,t){var i=this.geometry,l=this.material,c=this.matrixWorld;if(l!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),zy.copy(i.boundingSphere),zy.applyMatrix4(c),e.ray.intersectsSphere(zy)!==!1&&(i0.getInverse(c),el.copy(e.ray).applyMatrix4(i0),!(i.boundingBox!==null&&el.intersectsBox(i.boundingBox)===!1)))){var h;if(i.isBufferGeometry){var f,r,v,x=i.index,w=i.attributes.position,b=i.morphAttributes.position,A=i.morphTargetsRelative,L=i.attributes.uv,P=i.attributes.uv2,R=i.groups,F=i.drawRange,V,j,J,ne,H,Q,ae,ie;if(x!==null)if(Array.isArray(l))for(V=0,J=R.length;V<J;V++)for(H=R[V],Q=l[H.materialIndex],ae=Math.max(H.start,F.start),ie=Math.min(H.start+H.count,F.start+F.count),j=ae,ne=ie;j<ne;j+=3)f=x.getX(j),r=x.getX(j+1),v=x.getX(j+2),h=yf(this,Q,e,el,w,b,A,L,P,f,r,v),h&&(h.faceIndex=Math.floor(j/3),h.face.materialIndex=H.materialIndex,t.push(h));else for(ae=Math.max(0,F.start),ie=Math.min(x.count,F.start+F.count),V=ae,J=ie;V<J;V+=3)f=x.getX(V),r=x.getX(V+1),v=x.getX(V+2),h=yf(this,l,e,el,w,b,A,L,P,f,r,v),h&&(h.faceIndex=Math.floor(V/3),t.push(h));else if(w!==void 0)if(Array.isArray(l))for(V=0,J=R.length;V<J;V++)for(H=R[V],Q=l[H.materialIndex],ae=Math.max(H.start,F.start),ie=Math.min(H.start+H.count,F.start+F.count),j=ae,ne=ie;j<ne;j+=3)f=j,r=j+1,v=j+2,h=yf(this,Q,e,el,w,b,A,L,P,f,r,v),h&&(h.faceIndex=Math.floor(j/3),h.face.materialIndex=H.materialIndex,t.push(h));else for(ae=Math.max(0,F.start),ie=Math.min(w.count,F.start+F.count),V=ae,J=ie;V<J;V+=3)f=V,r=V+1,v=V+2,h=yf(this,l,e,el,w,b,A,L,P,f,r,v),h&&(h.faceIndex=Math.floor(V/3),t.push(h))}else if(i.isGeometry){var le,fe,me,he=Array.isArray(l),Oe=i.vertices,Ve=i.faces,He,at=i.faceVertexUvs[0];at.length>0&&(He=at);for(var At=0,yt=Ve.length;At<yt;At++){var Dt=Ve[At],It=he?l[Dt.materialIndex]:l;if(It!==void 0&&(le=Oe[Dt.a],fe=Oe[Dt.b],me=Oe[Dt.c],h=r0(this,It,e,el,le,fe,me,Ah),h)){if(He&&He[At]){var Nt=He[At];bc.copy(Nt[0]),wc.copy(Nt[1]),Mc.copy(Nt[2]),h.uv=lr.getUV(Ah,le,fe,me,bc,wc,Mc,new Lt)}h.face=Dt,h.faceIndex=At,t.push(h)}}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});function r0(e,t,i,l,c,h,f,r){var v;if(t.side===tr?v=l.intersectTriangle(f,h,c,!0,r):v=l.intersectTriangle(c,h,f,t.side!==hh,r),v===null)return null;gf.copy(r),gf.applyMatrix4(e.matrixWorld);var x=i.ray.origin.distanceTo(gf);return x<i.near||x>i.far?null:{distance:x,point:gf.clone(),object:e}}function yf(e,t,i,l,c,h,f,r,v,x,w,b){tl.fromBufferAttribute(c,x),nl.fromBufferAttribute(c,w),il.fromBufferAttribute(c,b);var A=e.morphTargetInfluences;if(t.morphTargets&&h&&A){pf.set(0,0,0),ff.set(0,0,0),mf.set(0,0,0);for(var L=0,P=h.length;L<P;L++){var R=A[L],F=h[L];R!==0&&(Fy.fromBufferAttribute(F,x),By.fromBufferAttribute(F,w),Oy.fromBufferAttribute(F,b),f?(pf.addScaledVector(Fy,R),ff.addScaledVector(By,R),mf.addScaledVector(Oy,R)):(pf.addScaledVector(Fy.sub(tl),R),ff.addScaledVector(By.sub(nl),R),mf.addScaledVector(Oy.sub(il),R)))}tl.add(pf),nl.add(ff),il.add(mf)}var V=r0(e,t,i,l,tl,nl,il,Ah);if(V){r&&(bc.fromBufferAttribute(r,x),wc.fromBufferAttribute(r,w),Mc.fromBufferAttribute(r,b),V.uv=lr.getUV(Ah,tl,nl,il,bc,wc,Mc,new Lt)),v&&(bc.fromBufferAttribute(v,x),wc.fromBufferAttribute(v,w),Mc.fromBufferAttribute(v,b),V.uv2=lr.getUV(Ah,tl,nl,il,bc,wc,Mc,new Lt));var j=new df(x,w,b);lr.getNormal(tl,nl,il,j.normal),V.face=j}return V}var XE=0,Xo=new Hn,Ny=new on,_f=new Pe;function Bn(){Object.defineProperty(this,"id",{value:XE+=2}),this.uuid=jn.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}Bn.prototype=Object.assign(Object.create(Ta.prototype),{constructor:Bn,isGeometry:!0,applyMatrix4:function(e){for(var t=new pr().getNormalMatrix(e),i=0,l=this.vertices.length;i<l;i++){var c=this.vertices[i];c.applyMatrix4(e)}for(var i=0,l=this.faces.length;i<l;i++){var h=this.faces[i];h.normal.applyMatrix3(t).normalize();for(var f=0,r=h.vertexNormals.length;f<r;f++)h.vertexNormals[f].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(e){return Xo.makeRotationX(e),this.applyMatrix4(Xo),this},rotateY:function(e){return Xo.makeRotationY(e),this.applyMatrix4(Xo),this},rotateZ:function(e){return Xo.makeRotationZ(e),this.applyMatrix4(Xo),this},translate:function(e,t,i){return Xo.makeTranslation(e,t,i),this.applyMatrix4(Xo),this},scale:function(e,t,i){return Xo.makeScale(e,t,i),this.applyMatrix4(Xo),this},lookAt:function(e){return Ny.lookAt(e),Ny.updateMatrix(),this.applyMatrix4(Ny.matrix),this},fromBufferGeometry:function(e){var t=this,i=e.index!==null?e.index.array:void 0,l=e.attributes;if(l.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;var c=l.position.array,h=l.normal!==void 0?l.normal.array:void 0,f=l.color!==void 0?l.color.array:void 0,r=l.uv!==void 0?l.uv.array:void 0,v=l.uv2!==void 0?l.uv2.array:void 0;v!==void 0&&(this.faceVertexUvs[1]=[]);for(var x=0;x<c.length;x+=3)t.vertices.push(new Pe().fromArray(c,x)),f!==void 0&&t.colors.push(new tn().fromArray(f,x));function w(V,j,J,ne){var H=f===void 0?[]:[t.colors[V].clone(),t.colors[j].clone(),t.colors[J].clone()],Q=h===void 0?[]:[new Pe().fromArray(h,V*3),new Pe().fromArray(h,j*3),new Pe().fromArray(h,J*3)],ae=new df(V,j,J,Q,H,ne);t.faces.push(ae),r!==void 0&&t.faceVertexUvs[0].push([new Lt().fromArray(r,V*2),new Lt().fromArray(r,j*2),new Lt().fromArray(r,J*2)]),v!==void 0&&t.faceVertexUvs[1].push([new Lt().fromArray(v,V*2),new Lt().fromArray(v,j*2),new Lt().fromArray(v,J*2)])}var b=e.groups;if(b.length>0)for(var x=0;x<b.length;x++)for(var A=b[x],L=A.start,P=A.count,R=L,F=L+P;R<F;R+=3)i!==void 0?w(i[R],i[R+1],i[R+2],A.materialIndex):w(R,R+1,R+2,A.materialIndex);else if(i!==void 0)for(var x=0;x<i.length;x+=3)w(i[x],i[x+1],i[x+2]);else for(var x=0;x<c.length/3;x+=3)w(x,x+1,x+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(_f).negate(),this.translate(_f.x,_f.y,_f.z),this},normalize:function(){this.computeBoundingSphere();var e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,l=new Hn;return l.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix4(l),this},computeFaceNormals:function(){for(var e=new Pe,t=new Pe,i=0,l=this.faces.length;i<l;i++){var c=this.faces[i],h=this.vertices[c.a],f=this.vertices[c.b],r=this.vertices[c.c];e.subVectors(r,f),t.subVectors(h,f),e.cross(t),e.normalize(),c.normal.copy(e)}},computeVertexNormals:function(e){e===void 0&&(e=!0);var t,i,l,c,h,f;for(f=new Array(this.vertices.length),t=0,i=this.vertices.length;t<i;t++)f[t]=new Pe;if(e){var r,v,x,w=new Pe,b=new Pe;for(l=0,c=this.faces.length;l<c;l++)h=this.faces[l],r=this.vertices[h.a],v=this.vertices[h.b],x=this.vertices[h.c],w.subVectors(x,v),b.subVectors(r,v),w.cross(b),f[h.a].add(w),f[h.b].add(w),f[h.c].add(w)}else for(this.computeFaceNormals(),l=0,c=this.faces.length;l<c;l++)h=this.faces[l],f[h.a].add(h.normal),f[h.b].add(h.normal),f[h.c].add(h.normal);for(t=0,i=this.vertices.length;t<i;t++)f[t].normalize();for(l=0,c=this.faces.length;l<c;l++){h=this.faces[l];var A=h.vertexNormals;A.length===3?(A[0].copy(f[h.a]),A[1].copy(f[h.b]),A[2].copy(f[h.c])):(A[0]=f[h.a].clone(),A[1]=f[h.b].clone(),A[2]=f[h.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,t,i;for(this.computeFaceNormals(),e=0,t=this.faces.length;e<t;e++){i=this.faces[e];var l=i.vertexNormals;l.length===3?(l[0].copy(i.normal),l[1].copy(i.normal),l[2].copy(i.normal)):(l[0]=i.normal.clone(),l[1]=i.normal.clone(),l[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,i,l,c;for(i=0,l=this.faces.length;i<l;i++)for(c=this.faces[i],c.__originalFaceNormal?c.__originalFaceNormal.copy(c.normal):c.__originalFaceNormal=c.normal.clone(),c.__originalVertexNormals||(c.__originalVertexNormals=[]),e=0,t=c.vertexNormals.length;e<t;e++)c.__originalVertexNormals[e]?c.__originalVertexNormals[e].copy(c.vertexNormals[e]):c.__originalVertexNormals[e]=c.vertexNormals[e].clone();var h=new Bn;for(h.faces=this.faces,e=0,t=this.morphTargets.length;e<t;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];var f=this.morphNormals[e].faceNormals,r=this.morphNormals[e].vertexNormals,x,w;for(i=0,l=this.faces.length;i<l;i++)x=new Pe,w={a:new Pe,b:new Pe,c:new Pe},f.push(x),r.push(w)}var v=this.morphNormals[e];h.vertices=this.morphTargets[e].vertices,h.computeFaceNormals(),h.computeVertexNormals();var x,w;for(i=0,l=this.faces.length;i<l;i++)c=this.faces[i],x=v.faceNormals[i],w=v.vertexNormals[i],x.copy(c.normal),w.a.copy(c.vertexNormals[0]),w.b.copy(c.vertexNormals[1]),w.c.copy(c.vertexNormals[2])}for(i=0,l=this.faces.length;i<l;i++)c=this.faces[i],c.normal=c.__originalFaceNormal,c.vertexNormals=c.__originalVertexNormals},computeBoundingBox:function(){this.boundingBox===null&&(this.boundingBox=new Po),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){this.boundingSphere===null&&(this.boundingSphere=new Da),this.boundingSphere.setFromPoints(this.vertices)},merge:function(e,t,i){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}var l,c=this.vertices.length,h=this.vertices,f=e.vertices,r=this.faces,v=e.faces,x=this.colors,w=e.colors;i===void 0&&(i=0),t!==void 0&&(l=new pr().getNormalMatrix(t));for(var b=0,A=f.length;b<A;b++){var L=f[b],P=L.clone();t!==void 0&&P.applyMatrix4(t),h.push(P)}for(var b=0,A=w.length;b<A;b++)x.push(w[b].clone());for(b=0,A=v.length;b<A;b++){var R=v[b],F,V,j,J=R.vertexNormals,ne=R.vertexColors;F=new df(R.a+c,R.b+c,R.c+c),F.normal.copy(R.normal),l!==void 0&&F.normal.applyMatrix3(l).normalize();for(var H=0,Q=J.length;H<Q;H++)V=J[H].clone(),l!==void 0&&V.applyMatrix3(l).normalize(),F.vertexNormals.push(V);F.color.copy(R.color);for(var H=0,Q=ne.length;H<Q;H++)j=ne[H],F.vertexColors.push(j.clone());F.materialIndex=R.materialIndex+i,r.push(F)}for(var b=0,A=e.faceVertexUvs.length;b<A;b++){var ae=e.faceVertexUvs[b];this.faceVertexUvs[b]===void 0&&(this.faceVertexUvs[b]=[]);for(var H=0,Q=ae.length;H<Q;H++){for(var ie=ae[H],le=[],fe=0,me=ie.length;fe<me;fe++)le.push(ie[fe].clone());this.faceVertexUvs[b].push(le)}}},mergeMesh:function(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)},mergeVertices:function(){var e={},t=[],i=[],l,c,h=4,f=Math.pow(10,h),r,v,x,w,b,A;for(r=0,v=this.vertices.length;r<v;r++)l=this.vertices[r],c=Math.round(l.x*f)+"_"+Math.round(l.y*f)+"_"+Math.round(l.z*f),e[c]===void 0?(e[c]=r,t.push(this.vertices[r]),i[r]=t.length-1):i[r]=i[e[c]];var L=[];for(r=0,v=this.faces.length;r<v;r++){x=this.faces[r],x.a=i[x.a],x.b=i[x.b],x.c=i[x.c],w=[x.a,x.b,x.c];for(var P=0;P<3;P++)if(w[P]===w[(P+1)%3]){L.push(r);break}}for(r=L.length-1;r>=0;r--){var R=L[r];for(this.faces.splice(R,1),b=0,A=this.faceVertexUvs.length;b<A;b++)this.faceVertexUvs[b].splice(R,1)}var F=this.vertices.length-t.length;return this.vertices=t,F},setFromPoints:function(e){this.vertices=[];for(var t=0,i=e.length;t<i;t++){var l=e[t];this.vertices.push(new Pe(l.x,l.y,l.z||0))}return this},sortFacesByMaterialIndex:function(){for(var e=this.faces,t=e.length,i=0;i<t;i++)e[i]._id=i;function l(x,w){return x.materialIndex-w.materialIndex}e.sort(l);var c=this.faceVertexUvs[0],h=this.faceVertexUvs[1],f,r;c&&c.length===t&&(f=[]),h&&h.length===t&&(r=[]);for(var i=0;i<t;i++){var v=e[i]._id;f&&f.push(c[v]),r&&r.push(h[v])}f&&(this.faceVertexUvs[0]=f),r&&(this.faceVertexUvs[1]=r)},toJSON:function(){var e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){var t=this.parameters;for(var i in t)t[i]!==void 0&&(e[i]=t[i]);return e}for(var l=[],c=0;c<this.vertices.length;c++){var h=this.vertices[c];l.push(h.x,h.y,h.z)}for(var f=[],r=[],v={},x=[],w={},b=[],A={},c=0;c<this.faces.length;c++){var L=this.faces[c],P=!0,R=!1,F=this.faceVertexUvs[0][c]!==void 0,V=L.normal.length()>0,j=L.vertexNormals.length>0,J=L.color.r!==1||L.color.g!==1||L.color.b!==1,ne=L.vertexColors.length>0,H=0;if(H=le(H,0,0),H=le(H,1,P),H=le(H,2,R),H=le(H,3,F),H=le(H,4,V),H=le(H,5,j),H=le(H,6,J),H=le(H,7,ne),f.push(H),f.push(L.a,L.b,L.c),f.push(L.materialIndex),F){var Q=this.faceVertexUvs[0][c];f.push(he(Q[0]),he(Q[1]),he(Q[2]))}if(V&&f.push(fe(L.normal)),j){var ae=L.vertexNormals;f.push(fe(ae[0]),fe(ae[1]),fe(ae[2]))}if(J&&f.push(me(L.color)),ne){var ie=L.vertexColors;f.push(me(ie[0]),me(ie[1]),me(ie[2]))}}function le(Oe,Ve,He){return He?Oe|1<<Ve:Oe&~(1<<Ve)}function fe(Oe){var Ve=Oe.x.toString()+Oe.y.toString()+Oe.z.toString();return v[Ve]!==void 0||(v[Ve]=r.length/3,r.push(Oe.x,Oe.y,Oe.z)),v[Ve]}function me(Oe){var Ve=Oe.r.toString()+Oe.g.toString()+Oe.b.toString();return w[Ve]!==void 0||(w[Ve]=x.length,x.push(Oe.getHex())),w[Ve]}function he(Oe){var Ve=Oe.x.toString()+Oe.y.toString();return A[Ve]!==void 0||(A[Ve]=b.length/2,b.push(Oe.x,Oe.y)),A[Ve]}return e.data={},e.data.vertices=l,e.data.normals=r,x.length>0&&(e.data.colors=x),b.length>0&&(e.data.uvs=[b]),e.data.faces=f,e},clone:function(){return new Bn().copy(this)},copy:function(e){var t,i,l,c,h,f;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var r=e.vertices;for(t=0,i=r.length;t<i;t++)this.vertices.push(r[t].clone());var v=e.colors;for(t=0,i=v.length;t<i;t++)this.colors.push(v[t].clone());var x=e.faces;for(t=0,i=x.length;t<i;t++)this.faces.push(x[t].clone());for(t=0,i=e.faceVertexUvs.length;t<i;t++){var w=e.faceVertexUvs[t];for(this.faceVertexUvs[t]===void 0&&(this.faceVertexUvs[t]=[]),l=0,c=w.length;l<c;l++){var b=w[l],A=[];for(h=0,f=b.length;h<f;h++){var L=b[h];A.push(L.clone())}this.faceVertexUvs[t].push(A)}}var P=e.morphTargets;for(t=0,i=P.length;t<i;t++){var R={};if(R.name=P[t].name,P[t].vertices!==void 0)for(R.vertices=[],l=0,c=P[t].vertices.length;l<c;l++)R.vertices.push(P[t].vertices[l].clone());if(P[t].normals!==void 0)for(R.normals=[],l=0,c=P[t].normals.length;l<c;l++)R.normals.push(P[t].normals[l].clone());this.morphTargets.push(R)}var F=e.morphNormals;for(t=0,i=F.length;t<i;t++){var V={};if(F[t].vertexNormals!==void 0)for(V.vertexNormals=[],l=0,c=F[t].vertexNormals.length;l<c;l++){var j=F[t].vertexNormals[l],J={};J.a=j.a.clone(),J.b=j.b.clone(),J.c=j.c.clone(),V.vertexNormals.push(J)}if(F[t].faceNormals!==void 0)for(V.faceNormals=[],l=0,c=F[t].faceNormals.length;l<c;l++)V.faceNormals.push(F[t].faceNormals[l].clone());this.morphNormals.push(V)}var ne=e.skinWeights;for(t=0,i=ne.length;t<i;t++)this.skinWeights.push(ne[t].clone());var H=e.skinIndices;for(t=0,i=H.length;t<i;t++)this.skinIndices.push(H[t].clone());var Q=e.lineDistances;for(t=0,i=Q.length;t<i;t++)this.lineDistances.push(Q[t]);var ae=e.boundingBox;ae!==null&&(this.boundingBox=ae.clone());var ie=e.boundingSphere;return ie!==null&&(this.boundingSphere=ie.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});class ZE extends Bn{constructor(t,i,l,c,h,f){super(),this.type="BoxGeometry",this.parameters={width:t,height:i,depth:l,widthSegments:c,heightSegments:h,depthSegments:f},this.fromBufferGeometry(new vf(t,i,l,c,h,f)),this.mergeVertices()}}class vf extends vn{constructor(t,i,l,c,h,f){super(),this.type="BoxBufferGeometry",this.parameters={width:t,height:i,depth:l,widthSegments:c,heightSegments:h,depthSegments:f};var r=this;t=t||1,i=i||1,l=l||1,c=Math.floor(c)||1,h=Math.floor(h)||1,f=Math.floor(f)||1;var v=[],x=[],w=[],b=[],A=0,L=0;P("z","y","x",-1,-1,l,i,t,f,h,0),P("z","y","x",1,-1,l,i,-t,f,h,1),P("x","z","y",1,1,t,l,i,c,f,2),P("x","z","y",1,-1,t,l,-i,c,f,3),P("x","y","z",1,-1,t,i,l,c,h,4),P("x","y","z",-1,-1,t,i,-l,c,h,5),this.setIndex(v),this.setAttribute("position",new ln(x,3)),this.setAttribute("normal",new ln(w,3)),this.setAttribute("uv",new ln(b,2));function P(R,F,V,j,J,ne,H,Q,ae,ie,le){var fe=ne/ae,me=H/ie,he=ne/2,Oe=H/2,Ve=Q/2,He=ae+1,at=ie+1,At=0,yt=0,Dt,It,Nt=new Pe;for(It=0;It<at;It++){var Ie=It*me-Oe;for(Dt=0;Dt<He;Dt++){var be=Dt*fe-he;Nt[R]=be*j,Nt[F]=Ie*J,Nt[V]=Ve,x.push(Nt.x,Nt.y,Nt.z),Nt[R]=0,Nt[F]=0,Nt[V]=Q>0?1:-1,w.push(Nt.x,Nt.y,Nt.z),b.push(Dt/ae),b.push(1-It/ie),At+=1}}for(It=0;It<ie;It++)for(Dt=0;Dt<ae;Dt++){var We=A+Dt+He*It,Ge=A+Dt+He*(It+1),ke=A+(Dt+1)+He*(It+1),ot=A+(Dt+1)+He*It;v.push(We,Ge,ot),v.push(Ge,ke,ot),yt+=6}r.addGroup(L,yt,le),L+=yt,A+=At}}}function Tc(e){var t={};for(var i in e){t[i]={};for(var l in e[i]){var c=e[i][l];c&&(c.isColor||c.isMatrix3||c.isMatrix4||c.isVector2||c.isVector3||c.isVector4||c.isTexture)?t[i][l]=c.clone():Array.isArray(c)?t[i][l]=c.slice():t[i][l]=c}}return t}function fr(e){for(var t={},i=0;i<e.length;i++){var l=Tc(e[i]);for(var c in l)t[c]=l[c]}return t}var YE={clone:Tc,merge:fr},KE=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,JE=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;function Ur(e){Rn.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=KE,this.fragmentShader=JE,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,e!==void 0&&(e.attributes!==void 0&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}Ur.prototype=Object.create(Rn.prototype),Ur.prototype.constructor=Ur,Ur.prototype.isShaderMaterial=!0,Ur.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Tc(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.extensions=e.extensions,this},Ur.prototype.toJSON=function(e){var t=Rn.prototype.toJSON.call(this,e);t.uniforms={};for(var i in this.uniforms){var l=this.uniforms[i],c=l.value;c&&c.isTexture?t.uniforms[i]={type:"t",value:c.toJSON(e).uuid}:c&&c.isColor?t.uniforms[i]={type:"c",value:c.getHex()}:c&&c.isVector2?t.uniforms[i]={type:"v2",value:c.toArray()}:c&&c.isVector3?t.uniforms[i]={type:"v3",value:c.toArray()}:c&&c.isVector4?t.uniforms[i]={type:"v4",value:c.toArray()}:c&&c.isMatrix3?t.uniforms[i]={type:"m3",value:c.toArray()}:c&&c.isMatrix4?t.uniforms[i]={type:"m4",value:c.toArray()}:t.uniforms[i]={value:c}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;var h={};for(var f in this.extensions)this.extensions[f]===!0&&(h[f]=!0);return Object.keys(h).length>0&&(t.extensions=h),t};function Ia(){on.call(this),this.type="Camera",this.matrixWorldInverse=new Hn,this.projectionMatrix=new Hn,this.projectionMatrixInverse=new Hn}Ia.prototype=Object.assign(Object.create(on.prototype),{constructor:Ia,isCamera:!0,copy:function(e,t){return on.prototype.copy.call(this,e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this},getWorldDirection:function(e){e===void 0&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),e=new Pe),this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()},updateMatrixWorld:function(e){on.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.getInverse(this.matrixWorld)},updateWorldMatrix:function(e,t){on.prototype.updateWorldMatrix.call(this,e,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return new this.constructor().copy(this)}});function Xi(e,t,i,l){Ia.call(this),this.type="PerspectiveCamera",this.fov=e!==void 0?e:50,this.zoom=1,this.near=i!==void 0?i:.1,this.far=l!==void 0?l:2e3,this.focus=10,this.aspect=t!==void 0?t:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}Xi.prototype=Object.assign(Object.create(Ia.prototype),{constructor:Xi,isPerspectiveCamera:!0,copy:function(e,t){return Ia.prototype.copy.call(this,e,t),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:function(e){var t=.5*this.getFilmHeight()/e;this.fov=jn.RAD2DEG*2*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){var e=Math.tan(jn.DEG2RAD*.5*this.fov);return .5*this.getFilmHeight()/e},getEffectiveFOV:function(){return jn.RAD2DEG*2*Math.atan(Math.tan(jn.DEG2RAD*.5*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(e,t,i,l,c,h){this.aspect=e/t,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=t,this.view.offsetX=i,this.view.offsetY=l,this.view.width=c,this.view.height=h,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e=this.near,t=e*Math.tan(jn.DEG2RAD*.5*this.fov)/this.zoom,i=2*t,l=this.aspect*i,c=-.5*l,h=this.view;if(this.view!==null&&this.view.enabled){var f=h.fullWidth,r=h.fullHeight;c+=h.offsetX*l/f,t-=h.offsetY*i/r,l*=h.width/f,i*=h.height/r}var v=this.filmOffset;v!==0&&(c+=e*v/this.getFilmWidth()),this.projectionMatrix.makePerspective(c,c+l,t,t-i,e,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){var t=on.prototype.toJSON.call(this,e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}});var Ec=90,Cc=1;function Dh(e,t,i,l){on.call(this),this.type="CubeCamera";var c=new Xi(Ec,Cc,e,t);c.up.set(0,-1,0),c.lookAt(new Pe(1,0,0)),this.add(c);var h=new Xi(Ec,Cc,e,t);h.up.set(0,-1,0),h.lookAt(new Pe(-1,0,0)),this.add(h);var f=new Xi(Ec,Cc,e,t);f.up.set(0,0,1),f.lookAt(new Pe(0,1,0)),this.add(f);var r=new Xi(Ec,Cc,e,t);r.up.set(0,0,-1),r.lookAt(new Pe(0,-1,0)),this.add(r);var v=new Xi(Ec,Cc,e,t);v.up.set(0,-1,0),v.lookAt(new Pe(0,0,1)),this.add(v);var x=new Xi(Ec,Cc,e,t);x.up.set(0,-1,0),x.lookAt(new Pe(0,0,-1)),this.add(x),l=l||{format:Ma,magFilter:$i,minFilter:$i},this.renderTarget=new Ac(i,l),this.renderTarget.texture.name="CubeCamera",this.update=function(w,b){this.parent===null&&this.updateMatrixWorld();var A=w.getRenderTarget(),L=this.renderTarget,P=L.texture.generateMipmaps;L.texture.generateMipmaps=!1,w.setRenderTarget(L,0),w.render(b,c),w.setRenderTarget(L,1),w.render(b,h),w.setRenderTarget(L,2),w.render(b,f),w.setRenderTarget(L,3),w.render(b,r),w.setRenderTarget(L,4),w.render(b,v),L.texture.generateMipmaps=P,w.setRenderTarget(L,5),w.render(b,x),w.setRenderTarget(A)},this.clear=function(w,b,A,L){for(var P=w.getRenderTarget(),R=this.renderTarget,F=0;F<6;F++)w.setRenderTarget(R,F),w.clear(b,A,L);w.setRenderTarget(P)}}Dh.prototype=Object.create(on.prototype),Dh.prototype.constructor=Dh;function Ac(e,t,i){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=i),Tr.call(this,e,e,t)}Ac.prototype=Object.create(Tr.prototype),Ac.prototype.constructor=Ac,Ac.prototype.isWebGLCubeRenderTarget=!0,Ac.prototype.fromEquirectangularTexture=function(e,t){this.texture.type=t.type,this.texture.format=t.format,this.texture.encoding=t.encoding;var i=new Ca,l={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>","}"].join(`
- `),fragmentShader:["uniform sampler2D tEquirect;","varying vec3 vWorldDirection;","#define RECIPROCAL_PI 0.31830988618","#define RECIPROCAL_PI2 0.15915494","void main() {"," vec3 direction = normalize( vWorldDirection );"," vec2 sampleUV;"," sampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;"," sampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;"," gl_FragColor = texture2D( tEquirect, sampleUV );","}"].join(`
- `)},c=new Ur({type:"CubemapFromEquirect",uniforms:Tc(l.uniforms),vertexShader:l.vertexShader,fragmentShader:l.fragmentShader,side:tr,blending:es});c.uniforms.tEquirect.value=t;var h=new Ai(new vf(5,5,5),c);i.add(h);var f=new Dh(1,10,1);return f.renderTarget=this,f.renderTarget.texture.name="CubeCameraTexture",f.update(e,i),h.geometry.dispose(),h.material.dispose(),this};function Dc(e,t,i,l,c,h,f,r,v,x,w,b){mi.call(this,null,h,f,r,v,x,l,c,w,b),this.image={data:e||null,width:t||1,height:i||1},this.magFilter=v!==void 0?v:Ui,this.minFilter=x!==void 0?x:Ui,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}Dc.prototype=Object.create(mi.prototype),Dc.prototype.constructor=Dc,Dc.prototype.isDataTexture=!0;var Pc=new Da,xf=new Pe;function Ph(e,t,i,l,c,h){this.planes=[e!==void 0?e:new $o,t!==void 0?t:new $o,i!==void 0?i:new $o,l!==void 0?l:new $o,c!==void 0?c:new $o,h!==void 0?h:new $o]}Object.assign(Ph.prototype,{set:function(e,t,i,l,c,h){var f=this.planes;return f[0].copy(e),f[1].copy(t),f[2].copy(i),f[3].copy(l),f[4].copy(c),f[5].copy(h),this},clone:function(){return new this.constructor().copy(this)},copy:function(e){for(var t=this.planes,i=0;i<6;i++)t[i].copy(e.planes[i]);return this},setFromProjectionMatrix:function(e){var t=this.planes,i=e.elements,l=i[0],c=i[1],h=i[2],f=i[3],r=i[4],v=i[5],x=i[6],w=i[7],b=i[8],A=i[9],L=i[10],P=i[11],R=i[12],F=i[13],V=i[14],j=i[15];return t[0].setComponents(f-l,w-r,P-b,j-R).normalize(),t[1].setComponents(f+l,w+r,P+b,j+R).normalize(),t[2].setComponents(f+c,w+v,P+A,j+F).normalize(),t[3].setComponents(f-c,w-v,P-A,j-F).normalize(),t[4].setComponents(f-h,w-x,P-L,j-V).normalize(),t[5].setComponents(f+h,w+x,P+L,j+V).normalize(),this},intersectsObject:function(e){var t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),Pc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Pc)},intersectsSprite:function(e){return Pc.center.set(0,0,0),Pc.radius=.7071067811865476,Pc.applyMatrix4(e.matrixWorld),this.intersectsSphere(Pc)},intersectsSphere:function(e){for(var t=this.planes,i=e.center,l=-e.radius,c=0;c<6;c++){var h=t[c].distanceToPoint(i);if(h<l)return!1}return!0},intersectsBox:function(e){for(var t=this.planes,i=0;i<6;i++){var l=t[i];if(xf.x=l.normal.x>0?e.max.x:e.min.x,xf.y=l.normal.y>0?e.max.y:e.min.y,xf.z=l.normal.z>0?e.max.z:e.min.z,l.distanceToPoint(xf)<0)return!1}return!0},containsPoint:function(e){for(var t=this.planes,i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}});var an={common:{diffuse:{value:new tn(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new pr},uv2Transform:{value:new pr},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new Lt(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},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:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new tn(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new pr}},sprite:{diffuse:{value:new tn(15658734)},opacity:{value:1},center:{value:new Lt(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new pr}}};function o0(){var e=null,t=!1,i=null;function l(c,h){t!==!1&&(i(c,h),e.requestAnimationFrame(l))}return{start:function(){t!==!0&&i!==null&&(e.requestAnimationFrame(l),t=!0)},stop:function(){t=!1},setAnimationLoop:function(c){i=c},setContext:function(c){e=c}}}function QE(e,t){var i=t.isWebGL2,l=new WeakMap;function c(x,w){var b=x.array,A=x.usage,L=e.createBuffer();e.bindBuffer(w,L),e.bufferData(w,b,A),x.onUploadCallback();var P=5126;return b instanceof Float32Array?P=5126:b instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):b instanceof Uint16Array?P=5123:b instanceof Int16Array?P=5122:b instanceof Uint32Array?P=5125:b instanceof Int32Array?P=5124:b instanceof Int8Array?P=5120:b instanceof Uint8Array&&(P=5121),{buffer:L,type:P,bytesPerElement:b.BYTES_PER_ELEMENT,version:x.version}}function h(x,w,b){var A=w.array,L=w.updateRange;e.bindBuffer(b,x),L.count===-1?e.bufferSubData(b,0,A):(i?e.bufferSubData(b,L.offset*A.BYTES_PER_ELEMENT,A,L.offset,L.count):e.bufferSubData(b,L.offset*A.BYTES_PER_ELEMENT,A.subarray(L.offset,L.offset+L.count)),L.count=-1)}function f(x){return x.isInterleavedBufferAttribute&&(x=x.data),l.get(x)}function r(x){x.isInterleavedBufferAttribute&&(x=x.data);var w=l.get(x);w&&(e.deleteBuffer(w.buffer),l.delete(x))}function v(x,w){x.isInterleavedBufferAttribute&&(x=x.data);var b=l.get(x);b===void 0?l.set(x,c(x,w)):b.version<x.version&&(h(b.buffer,x,w),b.version=x.version)}return{get:f,remove:r,update:v}}function bf(e,t,i,l){Bn.call(this),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:l},this.fromBufferGeometry(new Sc(e,t,i,l)),this.mergeVertices()}bf.prototype=Object.create(Bn.prototype),bf.prototype.constructor=bf;function Sc(e,t,i,l){vn.call(this),this.type="PlaneBufferGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:l},e=e||1,t=t||1;var c=e/2,h=t/2,f=Math.floor(i)||1,r=Math.floor(l)||1,v=f+1,x=r+1,w=e/f,b=t/r,A,L,P=[],R=[],F=[],V=[];for(L=0;L<x;L++){var j=L*b-h;for(A=0;A<v;A++){var J=A*w-c;R.push(J,-j,0),F.push(0,0,1),V.push(A/f),V.push(1-L/r)}}for(L=0;L<r;L++)for(A=0;A<f;A++){var ne=A+v*L,H=A+v*(L+1),Q=A+1+v*(L+1),ae=A+1+v*L;P.push(ne,H,ae),P.push(H,Q,ae)}this.setIndex(P),this.setAttribute("position",new ln(R,3)),this.setAttribute("normal",new ln(F,3)),this.setAttribute("uv",new ln(V,2))}Sc.prototype=Object.create(vn.prototype),Sc.prototype.constructor=Sc;var eC=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vUv ).g;
- #endif`,tC=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,nC=`#ifdef ALPHATEST
- if ( diffuseColor.a < ALPHATEST ) discard;
- #endif`,iC=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );
- #endif
- #endif`,rC=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,oC="vec3 transformed = vec3( position );",aC=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,sC=`vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {
- 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;
- return vec2( -1.04, 1.04 ) * a004 + r.zw;
- }
- float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- #if defined ( PHYSICALLY_CORRECT_LIGHTS )
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- #else
- if( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
- return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );
- }
- return 1.0;
- #endif
- }
- vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {
- float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );
- return ( 1.0 - specularColor ) * fresnel + specularColor;
- }
- vec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {
- float fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );
- vec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;
- return Fr * fresnel + F0;
- }
- float G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- return 1.0 / ( gl * gv );
- }
- float G_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 );
- }
- vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( incidentLight.direction + viewDir );
- float dotNL = saturate( dot( normal, incidentLight.direction ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
- vec3 F = F_Schlick( specularColor, dotLH );
- float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( G * 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 );
- }
- vec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 brdf = integrateSpecularBRDF( dotNV, roughness );
- return specularColor * brdf.x + brdf.y;
- }
- void BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
- vec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );
- vec2 brdf = integrateSpecularBRDF( dotNV, roughness );
- vec3 FssEss = F * brdf.x + brdf.y;
- float Ess = brdf.x + brdf.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- 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_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );
- float dotNH = saturate( dot( geometry.normal, halfDir ) );
- float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
- vec3 F = F_Schlick( specularColor, dotLH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- }
- float GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {
- return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );
- }
- float BlinnExponentToGGXRoughness( const in float blinnExponent ) {
- return sqrt( 2.0 / ( blinnExponent + 2.0 ) );
- }
- #if defined( USE_SHEEN )
- float D_Charlie(float roughness, float NoH) {
- float invAlpha = 1.0 / roughness;
- float cos2h = NoH * NoH;
- float sin2h = max(1.0 - cos2h, 0.0078125); return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);
- }
- float V_Neubelt(float NoV, float NoL) {
- return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));
- }
- vec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {
- vec3 N = geometry.normal;
- vec3 V = geometry.viewDir;
- vec3 H = normalize( V + L );
- float dotNH = saturate( dot( N, H ) );
- return specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );
- }
- #endif`,lC=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vUv );
- vec2 dSTdy = dFdy( vUv );
- float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {
- vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );
- vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 );
- fDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,cC=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #pragma unroll_loop
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;
- }
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;
- }
- if ( clipped ) discard;
- #endif
- #endif`,uC=`#if NUM_CLIPPING_PLANES > 0
- #if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )
- varying vec3 vViewPosition;
- #endif
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,hC=`#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )
- varying vec3 vViewPosition;
- #endif`,dC=`#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )
- vViewPosition = - mvPosition.xyz;
- #endif`,pC=`#ifdef USE_COLOR
- diffuseColor.rgb *= vColor;
- #endif`,fC=`#ifdef USE_COLOR
- varying vec3 vColor;
- #endif`,mC=`#ifdef USE_COLOR
- varying vec3 vColor;
- #endif`,gC=`#ifdef USE_COLOR
- vColor.xyz = color.xyz;
- #endif`,yC=`#define PI 3.14159265359
- #define PI2 6.28318530718
- #define PI_HALF 1.5707963267949
- #define RECIPROCAL_PI 0.31830988618
- #define RECIPROCAL_PI2 0.15915494
- #define LOG2 1.442695
- #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; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }
- 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 max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- 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;
- };
- struct GeometricContext {
- vec3 position;
- vec3 normal;
- vec3 viewDir;
- #ifdef CLEARCOAT
- vec3 clearcoatNormal;
- #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 );
- }
- vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
- float distance = dot( planeNormal, point - pointOnPlane );
- return - distance * planeNormal + point;
- }
- float sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
- return sign( dot( point - pointOnPlane, planeNormal ) );
- }
- vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {
- return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;
- }
- 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 linearToRelativeLuminance( const in vec3 color ) {
- vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );
- return dot( weights, color.rgb );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }`,_C=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_maxMipLevel 8.0
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_maxTileSize 256.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 = direction.xy / abs(direction.z);
- } else if (face == 3.0) {
- uv = vec2(direction.z, direction.y) / abs(direction.x);
- } else if (face == 4.0) {
- uv = direction.xz / 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);
- float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);
- vec2 uv = getUV(direction, face) * (faceSize - 1.0);
- vec2 f = fract(uv);
- uv += 0.5 - f;
- if (face > 2.0) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- if(mipInt < cubeUV_maxMipLevel){
- uv.y += 2.0 * cubeUV_maxTileSize;
- }
- uv.y += filterInt * 2.0 * cubeUV_minTileSize;
- uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);
- uv *= texelSize;
- vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
- uv.x += texelSize;
- vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
- uv.y += texelSize;
- vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
- uv.x -= texelSize;
- vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
- vec3 tm = mix(tl, tr, f.x);
- vec3 bm = mix(bl, br, f.x);
- return mix(tm, bm, f.y);
- }
- #define r0 1.0
- #define v0 0.339
- #define m0 -2.0
- #define r1 0.8
- #define v1 0.276
- #define m1 -1.0
- #define r4 0.4
- #define v4 0.046
- #define m4 2.0
- #define r5 0.305
- #define v5 0.016
- #define m5 3.0
- #define r6 0.21
- #define v6 0.0038
- #define m6 4.0
- float roughnessToMip(float roughness) {
- float mip = 0.0;
- if (roughness >= r1) {
- mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
- } else if (roughness >= r4) {
- mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;
- } else if (roughness >= r5) {
- mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;
- } else if (roughness >= r6) {
- mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;
- } else {
- mip = -2.0 * log2(1.16 * roughness); }
- return mip;
- }
- vec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {
- float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);
- 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`,vC=`vec3 transformedNormal = objectNormal;
- #ifdef USE_INSTANCING
- transformedNormal = mat3( instanceMatrix ) * transformedNormal;
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,xC=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,bC=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
- #endif`,wC=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vUv );
- emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,MC=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,TC="gl_FragColor = linearToOutputTexel( gl_FragColor );",EC=`
- vec4 LinearToLinear( in vec4 value ) {
- return value;
- }
- vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {
- return vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );
- }
- vec4 LinearToGamma( in vec4 value, in float gammaFactor ) {
- return vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );
- }
- vec4 sRGBToLinear( 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 LinearTosRGB( 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 RGBEToLinear( in vec4 value ) {
- return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );
- }
- vec4 LinearToRGBE( in vec4 value ) {
- float maxComponent = max( max( value.r, value.g ), value.b );
- float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );
- return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );
- }
- vec4 RGBMToLinear( in vec4 value, in float maxRange ) {
- return vec4( value.rgb * value.a * maxRange, 1.0 );
- }
- vec4 LinearToRGBM( in vec4 value, in float maxRange ) {
- float maxRGB = max( value.r, max( value.g, value.b ) );
- float M = clamp( maxRGB / maxRange, 0.0, 1.0 );
- M = ceil( M * 255.0 ) / 255.0;
- return vec4( value.rgb / ( M * maxRange ), M );
- }
- vec4 RGBDToLinear( in vec4 value, in float maxRange ) {
- return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );
- }
- vec4 LinearToRGBD( in vec4 value, in float maxRange ) {
- float maxRGB = max( value.r, max( value.g, value.b ) );
- float D = max( maxRange / maxRGB, 1.0 );
- D = clamp( floor( D ) / 255.0, 0.0, 1.0 );
- return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );
- }
- const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );
- vec4 LinearToLogLuv( in vec4 value ) {
- vec3 Xp_Y_XYZp = cLogLuvM * value.rgb;
- Xp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );
- vec4 vResult;
- vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;
- float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;
- vResult.w = fract( Le );
- vResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;
- return vResult;
- }
- const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );
- vec4 LogLuvToLinear( in vec4 value ) {
- float Le = value.z * 255.0 + value.w;
- vec3 Xp_Y_XYZp;
- Xp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );
- Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;
- Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;
- vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;
- return vec4( max( vRGB, 0.0 ), 1.0 );
- }`,CC=`#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 ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );
- #elif defined( ENVMAP_TYPE_EQUIREC )
- vec2 sampleUV;
- reflectVec = normalize( reflectVec );
- sampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- sampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;
- vec4 envColor = texture2D( envMap, sampleUV );
- #elif defined( ENVMAP_TYPE_SPHERE )
- reflectVec = normalize( reflectVec );
- vec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );
- vec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifndef ENVMAP_TYPE_CUBE_UV
- envColor = envMapTexelToLinear( envColor );
- #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`,AC=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- uniform int maxMipLevel;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,DC=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,PC=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,SC=`#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`,LC=`#ifdef USE_FOG
- fogDepth = -mvPosition.z;
- #endif`,IC=`#ifdef USE_FOG
- varying float fogDepth;
- #endif`,RC=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, fogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,kC=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float fogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,zC=`#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 texture2D( gradientMap, coord ).rgb;
- #else
- return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );
- #endif
- }`,FC=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel= texture2D( lightMap, vUv2 );
- reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
- #endif`,BC=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,OC=`vec3 diffuse = vec3( 1.0 );
- GeometricContext geometry;
- geometry.position = mvPosition.xyz;
- geometry.normal = normalize( transformedNormal );
- geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
- GeometricContext backGeometry;
- backGeometry.position = geometry.position;
- backGeometry.normal = -geometry.normal;
- backGeometry.viewDir = geometry.viewDir;
- vLightFront = vec3( 0.0 );
- vIndirectFront = vec3( 0.0 );
- #ifdef DOUBLE_SIDED
- vLightBack = vec3( 0.0 );
- vIndirectBack = vec3( 0.0 );
- #endif
- IncidentLight directLight;
- float dotNL;
- vec3 directLightColor_Diffuse;
- #if NUM_POINT_LIGHTS > 0
- #pragma unroll_loop
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );
- dotNL = dot( geometry.normal, directLight.direction );
- directLightColor_Diffuse = PI * directLight.color;
- vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
- #ifdef DOUBLE_SIDED
- vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
- #endif
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- #pragma unroll_loop
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );
- dotNL = dot( geometry.normal, directLight.direction );
- directLightColor_Diffuse = PI * directLight.color;
- vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
- #ifdef DOUBLE_SIDED
- vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
- #endif
- }
- #endif
- #if NUM_DIR_LIGHTS > 0
- #pragma unroll_loop
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );
- dotNL = dot( geometry.normal, directLight.direction );
- directLightColor_Diffuse = PI * directLight.color;
- vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
- #ifdef DOUBLE_SIDED
- vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
- #endif
- }
- #endif
- #if NUM_HEMI_LIGHTS > 0
- #pragma unroll_loop
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
- #ifdef DOUBLE_SIDED
- vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );
- #endif
- }
- #endif`,NC=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- uniform vec3 lightProbe[ 9 ];
- 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 GeometricContext geometry ) {
- vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- #ifndef PHYSICALLY_CORRECT_LIGHTS
- irradiance *= PI;
- #endif
- return irradiance;
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- int shadow;
- float shadowBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {
- directLight.color = directionalLight.color;
- directLight.direction = directionalLight.direction;
- directLight.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- int shadow;
- float shadowBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {
- vec3 lVector = pointLight.position - geometry.position;
- directLight.direction = normalize( lVector );
- float lightDistance = length( lVector );
- directLight.color = pointLight.color;
- directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );
- directLight.visible = ( directLight.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;
- int shadow;
- float shadowBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {
- vec3 lVector = spotLight.position - geometry.position;
- directLight.direction = normalize( lVector );
- float lightDistance = length( lVector );
- float angleCos = dot( directLight.direction, spotLight.direction );
- if ( angleCos > spotLight.coneCos ) {
- float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- directLight.color = spotLight.color;
- directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );
- directLight.visible = true;
- } else {
- directLight.color = vec3( 0.0 );
- directLight.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 GeometricContext geometry ) {
- float dotNL = dot( geometry.normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- #ifndef PHYSICALLY_CORRECT_LIGHTS
- irradiance *= PI;
- #endif
- return irradiance;
- }
- #endif`,UC=`#if defined( USE_ENVMAP )
- #ifdef ENVMAP_MODE_REFRACTION
- uniform float refractionRatio;
- #endif
- vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {
- vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
- #ifdef ENVMAP_TYPE_CUBE
- vec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );
- #ifdef TEXTURE_LOD_EXT
- vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );
- #else
- vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );
- #endif
- envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
- #else
- vec4 envMapColor = vec4( 0.0 );
- #endif
- return PI * envMapColor.rgb * envMapIntensity;
- }
- float getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {
- float maxMIPLevelScalar = float( maxMIPLevel );
- float sigma = PI * roughness * roughness / ( 1.0 + roughness );
- float desiredMIPLevel = maxMIPLevelScalar + log2( sigma );
- return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );
- }
- vec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( -viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
- #else
- vec3 reflectVec = refract( -viewDir, normal, refractionRatio );
- #endif
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- float specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );
- #ifdef ENVMAP_TYPE_CUBE
- vec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );
- #ifdef TEXTURE_LOD_EXT
- vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );
- #else
- vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );
- #endif
- envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
- #elif defined( ENVMAP_TYPE_EQUIREC )
- vec2 sampleUV;
- sampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- sampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;
- #ifdef TEXTURE_LOD_EXT
- vec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );
- #else
- vec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );
- #endif
- envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
- #elif defined( ENVMAP_TYPE_SPHERE )
- vec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );
- #ifdef TEXTURE_LOD_EXT
- vec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );
- #else
- vec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );
- #endif
- envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
- #endif
- return envMapColor.rgb * envMapIntensity;
- }
- #endif`,VC=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,GC=`varying vec3 vViewPosition;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- struct ToonMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
- #ifndef PHYSICALLY_CORRECT_LIGHTS
- irradiance *= PI;
- #endif
- reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
- #define Material_LightProbeLOD( material ) (0)`,WC=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,jC=`varying vec3 vViewPosition;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifndef PHYSICALLY_CORRECT_LIGHTS
- irradiance *= PI;
- #endif
- reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong
- #define Material_LightProbeLOD( material ) (0)`,HC=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;
- material.specularRoughness = min( material.specularRoughness, 1.0 );
- #ifdef REFLECTIVITY
- material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );
- #endif
- #ifdef CLEARCOAT
- material.clearcoat = saturate( clearcoat ); material.clearcoatRoughness = max( clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheen;
- #endif`,$C=`struct PhysicalMaterial {
- vec3 diffuseColor;
- float specularRoughness;
- vec3 specularColor;
- #ifdef CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- #endif
- };
- #define MAXIMUM_SPECULAR_COEFFICIENT 0.16
- #define DEFAULT_SPECULAR_COEFFICIENT 0.04
- float clearcoatDHRApprox( const in float roughness, const in float dotNL ) {
- return DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometry.normal;
- vec3 viewDir = geometry.viewDir;
- vec3 position = geometry.position;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.specularRoughness;
- 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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifndef PHYSICALLY_CORRECT_LIGHTS
- irradiance *= PI;
- #endif
- #ifdef CLEARCOAT
- float ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = ccDotNL * directLight.color;
- #ifndef PHYSICALLY_CORRECT_LIGHTS
- ccIrradiance *= PI;
- #endif
- float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );
- reflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );
- #else
- float clearcoatDHR = 0.0;
- #endif
- #ifdef USE_SHEEN
- reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(
- material.specularRoughness,
- directLight.direction,
- geometry,
- material.sheenColor
- );
- #else
- reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);
- #endif
- reflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef CLEARCOAT
- float ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
- reflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );
- float ccDotNL = ccDotNV;
- float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );
- #else
- float clearcoatDHR = 0.0;
- #endif
- float clearcoatInv = 1.0 - clearcoatDHR;
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );
- vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );
- reflectedLight.indirectSpecular += clearcoatInv * 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 );
- }`,qC=`
- GeometricContext geometry;
- geometry.position = - vViewPosition;
- geometry.normal = normal;
- geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- #ifdef CLEARCOAT
- geometry.clearcoatNormal = clearcoatNormal;
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #pragma unroll_loop
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointDirectLightIrradiance( pointLight, geometry, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- directLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometry, material, reflectedLight );
- }
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- #pragma unroll_loop
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotDirectLightIrradiance( spotLight, geometry, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- directLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometry, material, reflectedLight );
- }
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #pragma unroll_loop
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometry, material, reflectedLight );
- }
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
- }
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- irradiance += getLightProbeIrradiance( lightProbe, geometry );
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
- }
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,XC=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel= texture2D( lightMap, vUv2 );
- vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
- #ifndef PHYSICALLY_CORRECT_LIGHTS
- lightMapIrradiance *= PI;
- #endif
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- radiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );
- #ifdef CLEARCOAT
- clearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );
- #endif
- #endif`,ZC=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
- #endif`,YC=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,KC=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,JC=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,QC=`#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`,eA=`#ifdef USE_MAP
- vec4 texelColor = texture2D( map, vUv );
- texelColor = mapTexelToLinear( texelColor );
- diffuseColor *= texelColor;
- #endif`,tA=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,nA=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #ifdef USE_MAP
- vec4 mapTexel = texture2D( map, uv );
- diffuseColor *= mapTexelToLinear( mapTexel );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,iA=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,rA=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,oA=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,aA=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
- objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
- objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
- objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
- #endif`,sA=`#ifdef USE_MORPHTARGETS
- uniform float morphTargetBaseInfluence;
- #ifndef USE_MORPHNORMALS
- uniform float morphTargetInfluences[ 8 ];
- #else
- uniform float morphTargetInfluences[ 4 ];
- #endif
- #endif`,lA=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- 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`,cA=`#ifdef FLAT_SHADED
- vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );
- vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
- #endif
- #ifdef USE_TANGENT
- vec3 tangent = normalize( vTangent );
- vec3 bitangent = normalize( vBitangent );
- #ifdef DOUBLE_SIDED
- tangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
- bitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
- #endif
- #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
- mat3 vTBN = mat3( tangent, bitangent, normal );
- #endif
- #endif
- #endif
- vec3 geometryNormal = normal;`,uA=`#ifdef OBJECTSPACE_NORMALMAP
- normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( TANGENTSPACE_NORMALMAP )
- vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- #ifdef USE_TANGENT
- normal = normalize( vTBN * mapN );
- #else
- normal = perturbNormal2Arb( -vViewPosition, normal, mapN );
- #endif
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );
- #endif`,hA=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef OBJECTSPACE_NORMALMAP
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
- vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {
- vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
- vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
- vec2 st0 = dFdx( vUv.st );
- vec2 st1 = dFdy( vUv.st );
- float scale = sign( st1.t * st0.s - st0.t * st1.s );
- vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );
- vec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );
- vec3 N = normalize( surf_norm );
- mat3 tsn = mat3( S, T, N );
- mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
- return normalize( tsn * mapN );
- }
- #endif`,dA=`#ifdef CLEARCOAT
- vec3 clearcoatNormal = geometryNormal;
- #endif`,pA=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- #ifdef USE_TANGENT
- clearcoatNormal = normalize( vTBN * clearcoatMapN );
- #else
- clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );
- #endif
- #endif`,fA=`#ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif`,mA=`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 );
- }
- 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 linearClipZ, const in float near, const in float far ) {
- return linearClipZ * ( 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 invClipZ, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * invClipZ - far );
- }`,gA=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,yA=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,_A=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,vA=`#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`,xA=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,bA=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,wA=`#ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- varying vec4 vSpotShadowCoord[ 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 ];
- #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;
- bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
- bool inFrustum = all( inFrustumVec );
- bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
- bool frustumTest = all( frustumTestVec );
- 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`,MA=`#ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];
- varying vec4 vSpotShadowCoord[ 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 ];
- #endif
- #endif`,TA=`#ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;
- }
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- #pragma unroll_loop
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;
- }
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;
- }
- #endif
- #endif`,EA=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLight directionalLight;
- #pragma unroll_loop
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLights[ i ];
- shadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLight spotLight;
- #pragma unroll_loop
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLights[ i ];
- shadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
- }
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLight pointLight;
- #pragma unroll_loop
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLights[ i ];
- shadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #endif
- #endif
- return shadow;
- }`,CA=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,AA=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- #ifdef BONE_TEXTURE
- uniform highp sampler2D boneTexture;
- uniform int boneTextureSize;
- mat4 getBoneMatrix( const in float i ) {
- float j = i * 4.0;
- float x = mod( j, float( boneTextureSize ) );
- float y = floor( j / float( boneTextureSize ) );
- float dx = 1.0 / float( boneTextureSize );
- float dy = 1.0 / float( boneTextureSize );
- y = dy * ( y + 0.5 );
- vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
- vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
- vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
- vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
- mat4 bone = mat4( v1, v2, v3, v4 );
- return bone;
- }
- #else
- uniform mat4 boneMatrices[ MAX_BONES ];
- mat4 getBoneMatrix( const in float i ) {
- mat4 bone = boneMatrices[ int(i) ];
- return bone;
- }
- #endif
- #endif`,DA=`#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`,PA=`#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`,SA=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,LA=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,IA=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,RA=`#ifndef saturate
- #define saturate(a) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- uniform float toneMappingWhitePoint;
- vec3 LinearToneMapping( vec3 color ) {
- return toneMappingExposure * color;
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- #define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )
- vec3 Uncharted2ToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );
- }
- 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 ACESFilmicToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );
- }`,kA=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
- varying vec2 vUv;
- #endif`,zA=`#ifdef USE_UV
- #ifdef UVS_VERTEX_ONLY
- vec2 vUv;
- #else
- varying vec2 vUv;
- #endif
- uniform mat3 uvTransform;
- #endif`,FA=`#ifdef USE_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif`,BA=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
- varying vec2 vUv2;
- #endif`,OA=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
- attribute vec2 uv2;
- varying vec2 vUv2;
- uniform mat3 uv2Transform;
- #endif`,NA=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
- vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
- #endif`,UA=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`,VA=`uniform sampler2D t2D;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- gl_FragColor = mapTexelToLinear( texColor );
- #include <tonemapping_fragment>
- #include <encodings_fragment>
- }`,GA=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,WA=`#include <envmap_common_pars_fragment>
- uniform float opacity;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- vec3 vReflect = vWorldDirection;
- #include <envmap_fragment>
- gl_FragColor = envColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <encodings_fragment>
- }`,jA=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,HA=`#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 <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- 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 <logdepthbuf_fragment>
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( gl_FragCoord.z );
- #endif
- }`,$A=`#include <common>
- #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>
- void main() {
- #include <uv_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>
- }`,qA=`#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 <clipping_planes_pars_fragment>
- void main () {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,XA=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #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 <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;
- }`,ZA=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV;
- sampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- sampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;
- vec4 texColor = texture2D( tEquirect, sampleUV );
- gl_FragColor = mapTexelToLinear( texColor );
- #include <tonemapping_fragment>
- #include <encodings_fragment>
- }`,YA=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,KA=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_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 <color_fragment>
- outgoingLight = diffuseColor.rgb;
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );
- #include <tonemapping_fragment>
- #include <encodings_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,JA=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <color_vertex>
- vLineDistance = scale * lineDistance;
- vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,QA=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <uv2_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <cube_uv_reflection_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 <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
-
- vec4 lightMapTexel= texture2D( lightMap, vUv2 );
- reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );
- #include <tonemapping_fragment>
- #include <encodings_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,eD=`#include <common>
- #include <uv_pars_vertex>
- #include <uv2_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 <uv2_vertex>
- #include <color_vertex>
- #include <skinbase_vertex>
- #ifdef USE_ENVMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,tD=`uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- varying vec3 vLightFront;
- varying vec3 vIndirectFront;
- #ifdef DOUBLE_SIDED
- varying vec3 vLightBack;
- varying vec3 vIndirectBack;
- #endif
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <uv2_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <cube_uv_reflection_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <fog_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_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 <specularmap_fragment>
- #include <emissivemap_fragment>
- reflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );
- #ifdef DOUBLE_SIDED
- reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;
- #else
- reflectedLight.indirectDiffuse += vIndirectFront;
- #endif
- #include <lightmap_fragment>
- reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );
- #ifdef DOUBLE_SIDED
- reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;
- #else
- reflectedLight.directDiffuse = vLightFront;
- #endif
- reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );
- #include <tonemapping_fragment>
- #include <encodings_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,nD=`#define LAMBERT
- varying vec3 vLightFront;
- varying vec3 vIndirectFront;
- #ifdef DOUBLE_SIDED
- varying vec3 vLightBack;
- varying vec3 vIndirectBack;
- #endif
- #include <common>
- #include <uv_pars_vertex>
- #include <uv2_pars_vertex>
- #include <envmap_pars_vertex>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <color_pars_vertex>
- #include <fog_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 <uv2_vertex>
- #include <color_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 <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <lights_lambert_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,iD=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <fog_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 <alphamap_fragment>
- #include <alphatest_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 );
- matcapColor = matcapTexelToLinear( matcapColor );
- #else
- vec4 matcapColor = vec4( 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );
- #include <tonemapping_fragment>
- #include <encodings_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,rD=`#define MATCAP
- varying vec3 vViewPosition;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <uv_pars_vertex>
- #include <displacementmap_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 <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #endif
- #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;
- }`,oD=`#define TOON
- 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 <uv2_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_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 <lights_toon_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 <specularmap_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 + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );
- #include <tonemapping_fragment>
- #include <encodings_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,aD=`#define TOON
- varying vec3 vViewPosition;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <uv_pars_vertex>
- #include <uv2_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_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 <uv2_vertex>
- #include <color_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #endif
- #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>
- }`,sD=`#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 <uv2_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <cube_uv_reflection_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #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 <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>
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );
- #include <tonemapping_fragment>
- #include <encodings_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,lD=`#define PHONG
- varying vec3 vViewPosition;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <uv_pars_vertex>
- #include <uv2_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_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 <uv2_vertex>
- #include <color_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #endif
- #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>
- }`,cD=`#define STANDARD
- #ifdef PHYSICAL
- #define REFLECTIVITY
- #define CLEARCOAT
- #define TRANSPARENCY
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef TRANSPARENCY
- uniform float transparency;
- #endif
- #ifdef REFLECTIVITY
- uniform float reflectivity;
- #endif
- #ifdef CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheen;
- #endif
- varying vec3 vViewPosition;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <uv2_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <bsdfs>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <lights_physical_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_normalmap_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 <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 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #ifdef TRANSPARENCY
- diffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );
- #include <tonemapping_fragment>
- #include <encodings_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,uD=`#define STANDARD
- varying vec3 vViewPosition;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif
- #include <common>
- #include <uv_pars_vertex>
- #include <uv2_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_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 <uv2_vertex>
- #include <color_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif
- #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>
- }`,hD=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
- varying vec3 vViewPosition;
- #endif
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif
- #include <packing>
- #include <uv_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 );
- }`,dD=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
- varying vec3 vViewPosition;
- #endif
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif
- #include <common>
- #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>
- void main() {
- #include <uv_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif
- #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( TANGENTSPACE_NORMALMAP )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,pD=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_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>
- outgoingLight = diffuseColor.rgb;
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );
- #include <tonemapping_fragment>
- #include <encodings_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,fD=`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>
- void main() {
- #include <color_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>
- }`,mD=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <encodings_fragment>
- #include <fog_fragment>
- }`,gD=`#include <fog_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <begin_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,yD=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_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>
- outgoingLight = diffuseColor.rgb;
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );
- #include <tonemapping_fragment>
- #include <encodings_fragment>
- #include <fog_fragment>
- }`,_D=`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>
- }`,Zn={alphamap_fragment:eC,alphamap_pars_fragment:tC,alphatest_fragment:nC,aomap_fragment:iC,aomap_pars_fragment:rC,begin_vertex:oC,beginnormal_vertex:aC,bsdfs:sC,bumpmap_pars_fragment:lC,clipping_planes_fragment:cC,clipping_planes_pars_fragment:uC,clipping_planes_pars_vertex:hC,clipping_planes_vertex:dC,color_fragment:pC,color_pars_fragment:fC,color_pars_vertex:mC,color_vertex:gC,common:yC,cube_uv_reflection_fragment:_C,defaultnormal_vertex:vC,displacementmap_pars_vertex:xC,displacementmap_vertex:bC,emissivemap_fragment:wC,emissivemap_pars_fragment:MC,encodings_fragment:TC,encodings_pars_fragment:EC,envmap_fragment:CC,envmap_common_pars_fragment:AC,envmap_pars_fragment:DC,envmap_pars_vertex:PC,envmap_physical_pars_fragment:UC,envmap_vertex:SC,fog_vertex:LC,fog_pars_vertex:IC,fog_fragment:RC,fog_pars_fragment:kC,gradientmap_pars_fragment:zC,lightmap_fragment:FC,lightmap_pars_fragment:BC,lights_lambert_vertex:OC,lights_pars_begin:NC,lights_toon_fragment:VC,lights_toon_pars_fragment:GC,lights_phong_fragment:WC,lights_phong_pars_fragment:jC,lights_physical_fragment:HC,lights_physical_pars_fragment:$C,lights_fragment_begin:qC,lights_fragment_maps:XC,lights_fragment_end:ZC,logdepthbuf_fragment:YC,logdepthbuf_pars_fragment:KC,logdepthbuf_pars_vertex:JC,logdepthbuf_vertex:QC,map_fragment:eA,map_pars_fragment:tA,map_particle_fragment:nA,map_particle_pars_fragment:iA,metalnessmap_fragment:rA,metalnessmap_pars_fragment:oA,morphnormal_vertex:aA,morphtarget_pars_vertex:sA,morphtarget_vertex:lA,normal_fragment_begin:cA,normal_fragment_maps:uA,normalmap_pars_fragment:hA,clearcoat_normal_fragment_begin:dA,clearcoat_normal_fragment_maps:pA,clearcoat_normalmap_pars_fragment:fA,packing:mA,premultiplied_alpha_fragment:gA,project_vertex:yA,dithering_fragment:_A,dithering_pars_fragment:vA,roughnessmap_fragment:xA,roughnessmap_pars_fragment:bA,shadowmap_pars_fragment:wA,shadowmap_pars_vertex:MA,shadowmap_vertex:TA,shadowmask_pars_fragment:EA,skinbase_vertex:CA,skinning_pars_vertex:AA,skinning_vertex:DA,skinnormal_vertex:PA,specularmap_fragment:SA,specularmap_pars_fragment:LA,tonemapping_fragment:IA,tonemapping_pars_fragment:RA,uv_pars_fragment:kA,uv_pars_vertex:zA,uv_vertex:FA,uv2_pars_fragment:BA,uv2_pars_vertex:OA,uv2_vertex:NA,worldpos_vertex:UA,background_frag:VA,background_vert:GA,cube_frag:WA,cube_vert:jA,depth_frag:HA,depth_vert:$A,distanceRGBA_frag:qA,distanceRGBA_vert:XA,equirect_frag:ZA,equirect_vert:YA,linedashed_frag:KA,linedashed_vert:JA,meshbasic_frag:QA,meshbasic_vert:eD,meshlambert_frag:tD,meshlambert_vert:nD,meshmatcap_frag:iD,meshmatcap_vert:rD,meshtoon_frag:oD,meshtoon_vert:aD,meshphong_frag:sD,meshphong_vert:lD,meshphysical_frag:cD,meshphysical_vert:uD,normal_frag:hD,normal_vert:dD,points_frag:pD,points_vert:fD,shadow_frag:mD,shadow_vert:gD,sprite_frag:yD,sprite_vert:_D},Ra={basic:{uniforms:fr([an.common,an.specularmap,an.envmap,an.aomap,an.lightmap,an.fog]),vertexShader:Zn.meshbasic_vert,fragmentShader:Zn.meshbasic_frag},lambert:{uniforms:fr([an.common,an.specularmap,an.envmap,an.aomap,an.lightmap,an.emissivemap,an.fog,an.lights,{emissive:{value:new tn(0)}}]),vertexShader:Zn.meshlambert_vert,fragmentShader:Zn.meshlambert_frag},phong:{uniforms:fr([an.common,an.specularmap,an.envmap,an.aomap,an.lightmap,an.emissivemap,an.bumpmap,an.normalmap,an.displacementmap,an.fog,an.lights,{emissive:{value:new tn(0)},specular:{value:new tn(1118481)},shininess:{value:30}}]),vertexShader:Zn.meshphong_vert,fragmentShader:Zn.meshphong_frag},standard:{uniforms:fr([an.common,an.envmap,an.aomap,an.lightmap,an.emissivemap,an.bumpmap,an.normalmap,an.displacementmap,an.roughnessmap,an.metalnessmap,an.fog,an.lights,{emissive:{value:new tn(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Zn.meshphysical_vert,fragmentShader:Zn.meshphysical_frag},toon:{uniforms:fr([an.common,an.specularmap,an.aomap,an.lightmap,an.emissivemap,an.bumpmap,an.normalmap,an.displacementmap,an.gradientmap,an.fog,an.lights,{emissive:{value:new tn(0)},specular:{value:new tn(1118481)},shininess:{value:30}}]),vertexShader:Zn.meshtoon_vert,fragmentShader:Zn.meshtoon_frag},matcap:{uniforms:fr([an.common,an.bumpmap,an.normalmap,an.displacementmap,an.fog,{matcap:{value:null}}]),vertexShader:Zn.meshmatcap_vert,fragmentShader:Zn.meshmatcap_frag},points:{uniforms:fr([an.points,an.fog]),vertexShader:Zn.points_vert,fragmentShader:Zn.points_frag},dashed:{uniforms:fr([an.common,an.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Zn.linedashed_vert,fragmentShader:Zn.linedashed_frag},depth:{uniforms:fr([an.common,an.displacementmap]),vertexShader:Zn.depth_vert,fragmentShader:Zn.depth_frag},normal:{uniforms:fr([an.common,an.bumpmap,an.normalmap,an.displacementmap,{opacity:{value:1}}]),vertexShader:Zn.normal_vert,fragmentShader:Zn.normal_frag},sprite:{uniforms:fr([an.sprite,an.fog]),vertexShader:Zn.sprite_vert,fragmentShader:Zn.sprite_frag},background:{uniforms:{uvTransform:{value:new pr},t2D:{value:null}},vertexShader:Zn.background_vert,fragmentShader:Zn.background_frag},cube:{uniforms:fr([an.envmap,{opacity:{value:1}}]),vertexShader:Zn.cube_vert,fragmentShader:Zn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Zn.equirect_vert,fragmentShader:Zn.equirect_frag},distanceRGBA:{uniforms:fr([an.common,an.displacementmap,{referencePosition:{value:new Pe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Zn.distanceRGBA_vert,fragmentShader:Zn.distanceRGBA_frag},shadow:{uniforms:fr([an.lights,an.fog,{color:{value:new tn(0)},opacity:{value:1}}]),vertexShader:Zn.shadow_vert,fragmentShader:Zn.shadow_frag}};Ra.physical={uniforms:fr([Ra.standard.uniforms,{transparency:{value:0},clearcoat:{value:0},clearcoatRoughness:{value:0},sheen:{value:new tn(0)},clearcoatNormalScale:{value:new Lt(1,1)},clearcoatNormalMap:{value:null}}]),vertexShader:Zn.meshphysical_vert,fragmentShader:Zn.meshphysical_frag};function vD(e,t,i,l){var c=new tn(0),h=0,f,r,v=null,x=0,w=null;function b(L,P,R,F){var V=P.background,j=e.xr,J=j.getSession&&j.getSession();if(J&&J.environmentBlendMode==="additive"&&(V=null),V===null?A(c,h):V&&V.isColor&&(A(V,1),F=!0),(e.autoClear||F)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),V&&(V.isCubeTexture||V.isWebGLCubeRenderTarget||V.mapping===ph)){r===void 0&&(r=new Ai(new vf(1,1,1),new Ur({type:"BackgroundCubeMaterial",uniforms:Tc(Ra.cube.uniforms),vertexShader:Ra.cube.vertexShader,fragmentShader:Ra.cube.fragmentShader,side:tr,depthTest:!1,depthWrite:!1,fog:!1})),r.geometry.deleteAttribute("normal"),r.geometry.deleteAttribute("uv"),r.onBeforeRender=function(H,Q,ae){this.matrixWorld.copyPosition(ae.matrixWorld)},Object.defineProperty(r.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(r));var ne=V.isWebGLCubeRenderTarget?V.texture:V;r.material.uniforms.envMap.value=ne,r.material.uniforms.flipEnvMap.value=ne.isCubeTexture?-1:1,(v!==V||x!==ne.version||w!==e.toneMapping)&&(r.material.needsUpdate=!0,v=V,x=ne.version,w=e.toneMapping),L.unshift(r,r.geometry,r.material,0,0,null)}else V&&V.isTexture&&(f===void 0&&(f=new Ai(new Sc(2,2),new Ur({type:"BackgroundMaterial",uniforms:Tc(Ra.background.uniforms),vertexShader:Ra.background.vertexShader,fragmentShader:Ra.background.fragmentShader,side:nc,depthTest:!1,depthWrite:!1,fog:!1})),f.geometry.deleteAttribute("normal"),Object.defineProperty(f.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(f)),f.material.uniforms.t2D.value=V,V.matrixAutoUpdate===!0&&V.updateMatrix(),f.material.uniforms.uvTransform.value.copy(V.matrix),(v!==V||x!==V.version||w!==e.toneMapping)&&(f.material.needsUpdate=!0,v=V,x=V.version,w=e.toneMapping),L.unshift(f,f.geometry,f.material,0,0,null))}function A(L,P){t.buffers.color.setClear(L.r,L.g,L.b,P,l)}return{getClearColor:function(){return c},setClearColor:function(L,P){c.set(L),h=P!==void 0?P:1,A(c,h)},getClearAlpha:function(){return h},setClearAlpha:function(L){h=L,A(c,h)},render:b}}function xD(e,t,i,l){var c=l.isWebGL2,h;function f(x){h=x}function r(x,w){e.drawArrays(h,x,w),i.update(w,h)}function v(x,w,b,A){if(A!==0){var L,P;if(c)L=e,P="drawArraysInstanced";else if(L=t.get("ANGLE_instanced_arrays"),P="drawArraysInstancedANGLE",L===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}L[P](h,w,b,A),i.update(b,h,A)}}this.setMode=f,this.render=r,this.renderInstances=v}function bD(e,t,i){var l;function c(){if(l!==void 0)return l;var Q=t.get("EXT_texture_filter_anisotropic");return Q!==null?l=e.getParameter(Q.MAX_TEXTURE_MAX_ANISOTROPY_EXT):l=0,l}function h(Q){if(Q==="highp"){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";Q="mediump"}return Q==="mediump"&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}var f=typeof WebGL2RenderingContext!="undefined"&&e instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext!="undefined"&&e instanceof WebGL2ComputeRenderingContext,r=i.precision!==void 0?i.precision:"highp",v=h(r);v!==r&&(console.warn("THREE.WebGLRenderer:",r,"not supported, using",v,"instead."),r=v);var x=i.logarithmicDepthBuffer===!0,w=e.getParameter(34930),b=e.getParameter(35660),A=e.getParameter(3379),L=e.getParameter(34076),P=e.getParameter(34921),R=e.getParameter(36347),F=e.getParameter(36348),V=e.getParameter(36349),j=b>0,J=f||!!t.get("OES_texture_float"),ne=j&&J,H=f?e.getParameter(36183):0;return{isWebGL2:f,getMaxAnisotropy:c,getMaxPrecision:h,precision:r,logarithmicDepthBuffer:x,maxTextures:w,maxVertexTextures:b,maxTextureSize:A,maxCubemapSize:L,maxAttributes:P,maxVertexUniforms:R,maxVaryings:F,maxFragmentUniforms:V,vertexTextures:j,floatFragmentTextures:J,floatVertexTextures:ne,maxSamples:H}}function wD(){var e=this,t=null,i=0,l=!1,c=!1,h=new $o,f=new pr,r={value:null,needsUpdate:!1};this.uniform=r,this.numPlanes=0,this.numIntersection=0,this.init=function(w,b,A){var L=w.length!==0||b||i!==0||l;return l=b,t=x(w,A,0),i=w.length,L},this.beginShadows=function(){c=!0,x(null)},this.endShadows=function(){c=!1,v()},this.setState=function(w,b,A,L,P,R){if(!l||w===null||w.length===0||c&&!A)c?x(null):v();else{var F=c?0:i,V=F*4,j=P.clippingState||null;r.value=j,j=x(w,L,V,R);for(var J=0;J!==V;++J)j[J]=t[J];P.clippingState=j,this.numIntersection=b?this.numPlanes:0,this.numPlanes+=F}};function v(){r.value!==t&&(r.value=t,r.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function x(w,b,A,L){var P=w!==null?w.length:0,R=null;if(P!==0){if(R=r.value,L!==!0||R===null){var F=A+P*4,V=b.matrixWorldInverse;f.getNormalMatrix(V),(R===null||R.length<F)&&(R=new Float32Array(F));for(var j=0,J=A;j!==P;++j,J+=4)h.copy(w[j]).applyMatrix4(V,f),h.normal.toArray(R,J),R[J+3]=h.constant}r.value=R,r.needsUpdate=!0}return e.numPlanes=P,R}}function MD(e){var t={};return{get:function(i){if(t[i]!==void 0)return t[i];var l;switch(i){case"WEBGL_depth_texture":l=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":l=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":l=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":l=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:l=e.getExtension(i)}return l===null&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),t[i]=l,l}}}function TD(e,t,i){var l=new WeakMap,c=new WeakMap;function h(w){var b=w.target,A=l.get(b);A.index!==null&&t.remove(A.index);for(var L in A.attributes)t.remove(A.attributes[L]);b.removeEventListener("dispose",h),l.delete(b);var P=c.get(A);P&&(t.remove(P),c.delete(A)),i.memory.geometries--}function f(w,b){var A=l.get(b);return A||(b.addEventListener("dispose",h),b.isBufferGeometry?A=b:b.isGeometry&&(b._bufferGeometry===void 0&&(b._bufferGeometry=new vn().setFromObject(w)),A=b._bufferGeometry),l.set(b,A),i.memory.geometries++,A)}function r(w){var b=w.index,A=w.attributes;b!==null&&t.update(b,34963);for(var L in A)t.update(A[L],34962);var P=w.morphAttributes;for(var L in P)for(var R=P[L],F=0,V=R.length;F<V;F++)t.update(R[F],34962)}function v(w){var b=[],A=w.index,L=w.attributes.position,P=0;if(A!==null){var R=A.array;P=A.version;for(var F=0,V=R.length;F<V;F+=3){var j=R[F+0],J=R[F+1],ne=R[F+2];b.push(j,J,J,ne,ne,j)}}else{var R=L.array;P=L.version;for(var F=0,V=R.length/3-1;F<V;F+=3){var j=F+0,J=F+1,ne=F+2;b.push(j,J,J,ne,ne,j)}}var H=new(n0(b)>65535?Eh:Th)(b,1);H.version=P,t.update(H,34963);var Q=c.get(w);Q&&t.remove(Q),c.set(w,H)}function x(w){var b=c.get(w);if(b){var A=w.index;A!==null&&b.version<A.version&&v(w)}else v(w);return c.get(w)}return{get:f,update:r,getWireframeAttribute:x}}function ED(e,t,i,l){var c=l.isWebGL2,h;function f(A){h=A}var r,v;function x(A){r=A.type,v=A.bytesPerElement}function w(A,L){e.drawElements(h,L,r,A*v),i.update(L,h)}function b(A,L,P,R){if(R!==0){var F,V;if(c)F=e,V="drawElementsInstanced";else if(F=t.get("ANGLE_instanced_arrays"),V="drawElementsInstancedANGLE",F===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}F[V](h,P,r,L*v,R),i.update(P,h,R)}}this.setMode=f,this.setIndex=x,this.render=w,this.renderInstances=b}function CD(e){var t={geometries:0,textures:0},i={frame:0,calls:0,triangles:0,points:0,lines:0};function l(h,f,r){switch(r=r||1,i.calls++,f){case 4:i.triangles+=r*(h/3);break;case 1:i.lines+=r*(h/2);break;case 3:i.lines+=r*(h-1);break;case 2:i.lines+=r*h;break;case 0:i.points+=r*h;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",f);break}}function c(){i.frame++,i.calls=0,i.triangles=0,i.points=0,i.lines=0}return{memory:t,render:i,programs:null,autoReset:!0,reset:c,update:l}}function AD(e,t){return Math.abs(t[1])-Math.abs(e[1])}function DD(e){var t={},i=new Float32Array(8);function l(c,h,f,r){var v=c.morphTargetInfluences,x=v===void 0?0:v.length,w=t[h.id];if(w===void 0){w=[];for(var b=0;b<x;b++)w[b]=[b,0];t[h.id]=w}for(var A=f.morphTargets&&h.morphAttributes.position,L=f.morphNormals&&h.morphAttributes.normal,b=0;b<x;b++){var P=w[b];P[1]!==0&&(A&&h.deleteAttribute("morphTarget"+b),L&&h.deleteAttribute("morphNormal"+b))}for(var b=0;b<x;b++){var P=w[b];P[0]=b,P[1]=v[b]}w.sort(AD);for(var R=0,b=0;b<8;b++){var P=w[b];if(P){var F=P[0],V=P[1];if(V){A&&h.setAttribute("morphTarget"+b,A[F]),L&&h.setAttribute("morphNormal"+b,L[F]),i[b]=V,R+=V;continue}}i[b]=0}var j=h.morphTargetsRelative?1:1-R;r.getUniforms().setValue(e,"morphTargetBaseInfluence",j),r.getUniforms().setValue(e,"morphTargetInfluences",i)}return{update:l}}function PD(e,t,i,l){var c={};function h(r){var v=l.render.frame,x=r.geometry,w=t.get(r,x);return c[w.id]!==v&&(x.isGeometry&&w.updateFromObject(r),t.update(w),c[w.id]=v),r.isInstancedMesh&&i.update(r.instanceMatrix,34962),w}function f(){c={}}return{update:h,dispose:f}}function os(e,t,i,l,c,h,f,r,v,x){e=e!==void 0?e:[],t=t!==void 0?t:ay,f=f!==void 0?f:Ma,mi.call(this,e,t,i,l,c,h,f,r,v,x),this.flipY=!1}os.prototype=Object.create(mi.prototype),os.prototype.constructor=os,os.prototype.isCubeTexture=!0,Object.defineProperty(os.prototype,"images",{get:function(){return this.image},set:function(e){this.image=e}});function Sh(e,t,i,l){mi.call(this,null),this.image={data:e||null,width:t||1,height:i||1,depth:l||1},this.magFilter=Ui,this.minFilter=Ui,this.wrapR=Mr,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}Sh.prototype=Object.create(mi.prototype),Sh.prototype.constructor=Sh,Sh.prototype.isDataTexture2DArray=!0;function Lh(e,t,i,l){mi.call(this,null),this.image={data:e||null,width:t||1,height:i||1,depth:l||1},this.magFilter=Ui,this.minFilter=Ui,this.wrapR=Mr,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}Lh.prototype=Object.create(mi.prototype),Lh.prototype.constructor=Lh,Lh.prototype.isDataTexture3D=!0;var a0=new mi,SD=new Sh,LD=new Lh,s0=new os,l0=[],c0=[],u0=new Float32Array(16),h0=new Float32Array(9),d0=new Float32Array(4);function Lc(e,t,i){var l=e[0];if(l<=0||l>0)return e;var c=t*i,h=l0[c];if(h===void 0&&(h=new Float32Array(c),l0[c]=h),t!==0){l.toArray(h,0);for(var f=1,r=0;f!==t;++f)r+=i,e[f].toArray(h,r)}return h}function _o(e,t){if(e.length!==t.length)return!1;for(var i=0,l=e.length;i<l;i++)if(e[i]!==t[i])return!1;return!0}function ao(e,t){for(var i=0,l=t.length;i<l;i++)e[i]=t[i]}function p0(e,t){var i=c0[t];i===void 0&&(i=new Int32Array(t),c0[t]=i);for(var l=0;l!==t;++l)i[l]=e.allocateTextureUnit();return i}function ID(e,t){var i=this.cache;i[0]!==t&&(e.uniform1f(this.addr,t),i[0]=t)}function RD(e,t){var i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y)&&(e.uniform2f(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(_o(i,t))return;e.uniform2fv(this.addr,t),ao(i,t)}}function kD(e,t){var i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z)&&(e.uniform3f(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else if(t.r!==void 0)(i[0]!==t.r||i[1]!==t.g||i[2]!==t.b)&&(e.uniform3f(this.addr,t.r,t.g,t.b),i[0]=t.r,i[1]=t.g,i[2]=t.b);else{if(_o(i,t))return;e.uniform3fv(this.addr,t),ao(i,t)}}function zD(e,t){var i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z||i[3]!==t.w)&&(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(_o(i,t))return;e.uniform4fv(this.addr,t),ao(i,t)}}function FD(e,t){var i=this.cache,l=t.elements;if(l===void 0){if(_o(i,t))return;e.uniformMatrix2fv(this.addr,!1,t),ao(i,t)}else{if(_o(i,l))return;d0.set(l),e.uniformMatrix2fv(this.addr,!1,d0),ao(i,l)}}function BD(e,t){var i=this.cache,l=t.elements;if(l===void 0){if(_o(i,t))return;e.uniformMatrix3fv(this.addr,!1,t),ao(i,t)}else{if(_o(i,l))return;h0.set(l),e.uniformMatrix3fv(this.addr,!1,h0),ao(i,l)}}function OD(e,t){var i=this.cache,l=t.elements;if(l===void 0){if(_o(i,t))return;e.uniformMatrix4fv(this.addr,!1,t),ao(i,t)}else{if(_o(i,l))return;u0.set(l),e.uniformMatrix4fv(this.addr,!1,u0),ao(i,l)}}function ND(e,t,i){var l=this.cache,c=i.allocateTextureUnit();l[0]!==c&&(e.uniform1i(this.addr,c),l[0]=c),i.safeSetTexture2D(t||a0,c)}function UD(e,t,i){var l=this.cache,c=i.allocateTextureUnit();l[0]!==c&&(e.uniform1i(this.addr,c),l[0]=c),i.setTexture2DArray(t||SD,c)}function VD(e,t,i){var l=this.cache,c=i.allocateTextureUnit();l[0]!==c&&(e.uniform1i(this.addr,c),l[0]=c),i.setTexture3D(t||LD,c)}function GD(e,t,i){var l=this.cache,c=i.allocateTextureUnit();l[0]!==c&&(e.uniform1i(this.addr,c),l[0]=c),i.safeSetTextureCube(t||s0,c)}function WD(e,t){var i=this.cache;i[0]!==t&&(e.uniform1i(this.addr,t),i[0]=t)}function jD(e,t){var i=this.cache;_o(i,t)||(e.uniform2iv(this.addr,t),ao(i,t))}function HD(e,t){var i=this.cache;_o(i,t)||(e.uniform3iv(this.addr,t),ao(i,t))}function $D(e,t){var i=this.cache;_o(i,t)||(e.uniform4iv(this.addr,t),ao(i,t))}function qD(e,t){var i=this.cache;i[0]!==t&&(e.uniform1ui(this.addr,t),i[0]=t)}function XD(e){switch(e){case 5126:return ID;case 35664:return RD;case 35665:return kD;case 35666:return zD;case 35674:return FD;case 35675:return BD;case 35676:return OD;case 5124:case 35670:return WD;case 35667:case 35671:return jD;case 35668:case 35672:return HD;case 35669:case 35673:return $D;case 5125:return qD;case 35678:case 36198:case 36298:case 36306:case 35682:return ND;case 35679:case 36299:case 36307:return VD;case 35680:case 36300:case 36308:case 36293:return GD;case 36289:case 36303:case 36311:case 36292:return UD}}function ZD(e,t){e.uniform1fv(this.addr,t)}function YD(e,t){e.uniform1iv(this.addr,t)}function KD(e,t){e.uniform2iv(this.addr,t)}function JD(e,t){e.uniform3iv(this.addr,t)}function QD(e,t){e.uniform4iv(this.addr,t)}function eP(e,t){var i=Lc(t,this.size,2);e.uniform2fv(this.addr,i)}function tP(e,t){var i=Lc(t,this.size,3);e.uniform3fv(this.addr,i)}function nP(e,t){var i=Lc(t,this.size,4);e.uniform4fv(this.addr,i)}function iP(e,t){var i=Lc(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,i)}function rP(e,t){var i=Lc(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,i)}function oP(e,t){var i=Lc(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,i)}function aP(e,t,i){var l=t.length,c=p0(i,l);e.uniform1iv(this.addr,c);for(var h=0;h!==l;++h)i.safeSetTexture2D(t[h]||a0,c[h])}function sP(e,t,i){var l=t.length,c=p0(i,l);e.uniform1iv(this.addr,c);for(var h=0;h!==l;++h)i.safeSetTextureCube(t[h]||s0,c[h])}function lP(e){switch(e){case 5126:return ZD;case 35664:return eP;case 35665:return tP;case 35666:return nP;case 35674:return iP;case 35675:return rP;case 35676:return oP;case 5124:case 35670:return YD;case 35667:case 35671:return KD;case 35668:case 35672:return JD;case 35669:case 35673:return QD;case 35678:case 36198:case 36298:case 36306:case 35682:return aP;case 35680:case 36300:case 36308:case 36293:return sP}}function cP(e,t,i){this.id=e,this.addr=i,this.cache=[],this.setValue=XD(t.type)}function f0(e,t,i){this.id=e,this.addr=i,this.cache=[],this.size=t.size,this.setValue=lP(t.type)}f0.prototype.updateCache=function(e){var t=this.cache;e instanceof Float32Array&&t.length!==e.length&&(this.cache=new Float32Array(e.length)),ao(t,e)};function m0(e){this.id=e,this.seq=[],this.map={}}m0.prototype.setValue=function(e,t,i){for(var l=this.seq,c=0,h=l.length;c!==h;++c){var f=l[c];f.setValue(e,t[f.id],i)}};var Uy=/([\w\d_]+)(\])?(\[|\.)?/g;function g0(e,t){e.seq.push(t),e.map[t.id]=t}function uP(e,t,i){var l=e.name,c=l.length;for(Uy.lastIndex=0;;){var h=Uy.exec(l),f=Uy.lastIndex,r=h[1],v=h[2]==="]",x=h[3];if(v&&(r=r|0),x===void 0||x==="["&&f+2===c){g0(i,x===void 0?new cP(r,e,t):new f0(r,e,t));break}else{var w=i.map,b=w[r];b===void 0&&(b=new m0(r),g0(i,b)),i=b}}}function as(e,t){this.seq=[],this.map={};for(var i=e.getProgramParameter(t,35718),l=0;l<i;++l){var c=e.getActiveUniform(t,l),h=e.getUniformLocation(t,c.name);uP(c,h,this)}}as.prototype.setValue=function(e,t,i,l){var c=this.map[t];c!==void 0&&c.setValue(e,i,l)},as.prototype.setOptional=function(e,t,i){var l=t[i];l!==void 0&&this.setValue(e,i,l)},as.upload=function(e,t,i,l){for(var c=0,h=t.length;c!==h;++c){var f=t[c],r=i[f.id];r.needsUpdate!==!1&&f.setValue(e,r.value,l)}},as.seqWithValue=function(e,t){for(var i=[],l=0,c=e.length;l!==c;++l){var h=e[l];h.id in t&&i.push(h)}return i};function y0(e,t,i){var l=e.createShader(t);return e.shaderSource(l,i),e.compileShader(l),l}var hP=0;function dP(e){for(var t=e.split(`
- `),i=0;i<t.length;i++)t[i]=i+1+": "+t[i];return t.join(`
- `)}function _0(e){switch(e){case io:return["Linear","( value )"];case _h:return["sRGB","( value )"];case py:return["RGBE","( value )"];case Vx:return["RGBM","( value, 7.0 )"];case Gx:return["RGBM","( value, 16.0 )"];case Wx:return["RGBD","( value, 256.0 )"];case Ux:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case SE:return["LogLuv","( value )"];default:throw new Error("unsupported encoding: "+e)}}function v0(e,t,i){var l=e.getShaderParameter(t,35713),c=e.getShaderInfoLog(t).trim();if(l&&c==="")return"";var h=e.getShaderSource(t);return"THREE.WebGLShader: gl.getShaderInfoLog() "+i+`
- `+c+dP(h)}function Ih(e,t){var i=_0(t);return"vec4 "+e+"( vec4 value ) { return "+i[0]+"ToLinear"+i[1]+"; }"}function pP(e,t){var i=_0(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function fP(e,t){var i;switch(t){case ry:i="Linear";break;case jT:i="Reinhard";break;case HT:i="Uncharted2";break;case $T:i="OptimizedCineon";break;case qT:i="ACESFilmic";break;default:throw new Error("unsupported toneMapping: "+t)}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function mP(e){var t=[e.extensionDerivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||e.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""];return t.filter(Rh).join(`
- `)}function gP(e){var t=[];for(var i in e){var l=e[i];l!==!1&&t.push("#define "+i+" "+l)}return t.join(`
- `)}function yP(e,t){for(var i={},l=e.getProgramParameter(t,35721),c=0;c<l;c++){var h=e.getActiveAttrib(t,c),f=h.name;i[f]=e.getAttribLocation(t,f)}return i}function Rh(e){return e!==""}function x0(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function b0(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var _P=/^[ \t]*#include +<([\w\d./]+)>/gm;function Vy(e){return e.replace(_P,vP)}function vP(e,t){var i=Zn[t];if(i===void 0)throw new Error("Can not resolve #include <"+t+">");return Vy(i)}var xP=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;function w0(e){return e.replace(xP,bP)}function bP(e,t,i,l){for(var c="",h=parseInt(t);h<parseInt(i);h++)c+=l.replace(/\[ i \]/g,"[ "+h+" ]").replace(/UNROLLED_LOOP_INDEX/g,h);return c}function M0(e){var t="precision "+e.precision+` float;
- precision `+e.precision+" int;";return e.precision==="highp"?t+=`
- #define HIGH_PRECISION`:e.precision==="mediump"?t+=`
- #define MEDIUM_PRECISION`:e.precision==="lowp"&&(t+=`
- #define LOW_PRECISION`),t}function wP(e){var t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===yx?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===bT?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===uh&&(t="SHADOWMAP_TYPE_VSM"),t}function MP(e){var t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case ay:case sy:t="ENVMAP_TYPE_CUBE";break;case ph:case cy:t="ENVMAP_TYPE_CUBE_UV";break;case Dx:case ly:t="ENVMAP_TYPE_EQUIREC";break;case Px:t="ENVMAP_TYPE_SPHERE";break}return t}function TP(e){var t="ENVMAP_MODE_REFLECTION";if(e.envMap)switch(e.envMapMode){case sy:case ly:t="ENVMAP_MODE_REFRACTION";break}return t}function EP(e){var t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case Xp:t="ENVMAP_BLENDING_MULTIPLY";break;case GT:t="ENVMAP_BLENDING_MIX";break;case WT:t="ENVMAP_BLENDING_ADD";break}return t}function CP(e,t,i){var l=e.getContext(),c=i.defines,h=i.vertexShader,f=i.fragmentShader,r=wP(i),v=MP(i),x=TP(i),w=EP(i),b=e.gammaFactor>0?e.gammaFactor:1,A=i.isWebGL2?"":mP(i),L=gP(c),P=l.createProgram(),R,F,V=i.numMultiviewViews;if(i.isRawShaderMaterial?(R=[L].filter(Rh).join(`
- `),R.length>0&&(R+=`
- `),F=[A,L].filter(Rh).join(`
- `),F.length>0&&(F+=`
- `)):(R=[M0(i),"#define SHADER_NAME "+i.shaderName,L,i.instancing?"#define USE_INSTANCING":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+b,"#define MAX_BONES "+i.maxBones,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+x:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.useVertexTexture?"#define BONE_TEXTURE":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&i.flatShading===!1?"#define USE_MORPHNORMALS":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+r:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.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","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#ifdef USE_COLOR"," attribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS"," 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(Rh).join(`
- `),F=[A,M0(i),"#define SHADER_NAME "+i.shaderName,L,i.alphaTest?"#define ALPHATEST "+i.alphaTest+(i.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+b,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+v:"",i.envMap?"#define "+x:"",i.envMap?"#define "+w:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.sheen?"#define USE_SHEEN":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+r:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(i.extensionShaderTextureLOD||i.envMap)&&i.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",i.toneMapping!==Zp?"#define TONE_MAPPING":"",i.toneMapping!==Zp?Zn.tonemapping_pars_fragment:"",i.toneMapping!==Zp?fP("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.outputEncoding||i.mapEncoding||i.matcapEncoding||i.envMapEncoding||i.emissiveMapEncoding||i.lightMapEncoding?Zn.encodings_pars_fragment:"",i.mapEncoding?Ih("mapTexelToLinear",i.mapEncoding):"",i.matcapEncoding?Ih("matcapTexelToLinear",i.matcapEncoding):"",i.envMapEncoding?Ih("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMapEncoding?Ih("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.lightMapEncoding?Ih("lightMapTexelToLinear",i.lightMapEncoding):"",i.outputEncoding?pP("linearToOutputTexel",i.outputEncoding):"",i.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"",`
- `].filter(Rh).join(`
- `)),h=Vy(h),h=x0(h,i),h=b0(h,i),f=Vy(f),f=x0(f,i),f=b0(f,i),h=w0(h),f=w0(f),i.isWebGL2&&!i.isRawShaderMaterial){var j=!1,J=/^\s*#version\s+300\s+es\s*\n/;i.isShaderMaterial&&h.match(J)!==null&&f.match(J)!==null&&(j=!0,h=h.replace(J,""),f=f.replace(J,"")),R=[`#version 300 es
- `,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+R,F=[`#version 300 es
- `,"#define varying in",j?"":"out highp vec4 pc_fragColor;",j?"":"#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(`
- `)+`
- `+F,V>0&&(R=R.replace(`#version 300 es
- `,[`#version 300 es
- `,"#extension GL_OVR_multiview2 : require","layout(num_views = "+V+") in;","#define VIEW_ID gl_ViewID_OVR"].join(`
- `)),R=R.replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join(`
- `),["uniform mat4 modelViewMatrices["+V+"];","uniform mat4 projectionMatrices["+V+"];","uniform mat4 viewMatrices["+V+"];","uniform mat3 normalMatrices["+V+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join(`
- `)),F=F.replace(`#version 300 es
- `,[`#version 300 es
- `,"#extension GL_OVR_multiview2 : require","#define VIEW_ID gl_ViewID_OVR"].join(`
- `)),F=F.replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+V+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join(`
- `)))}var ne=R+h,H=F+f,Q=y0(l,35633,ne),ae=y0(l,35632,H);if(l.attachShader(P,Q),l.attachShader(P,ae),i.index0AttributeName!==void 0?l.bindAttribLocation(P,0,i.index0AttributeName):i.morphTargets===!0&&l.bindAttribLocation(P,0,"position"),l.linkProgram(P),e.debug.checkShaderErrors){var ie=l.getProgramInfoLog(P).trim(),le=l.getShaderInfoLog(Q).trim(),fe=l.getShaderInfoLog(ae).trim(),me=!0,he=!0;if(l.getProgramParameter(P,35714)===!1){me=!1;var Oe=v0(l,Q,"vertex"),Ve=v0(l,ae,"fragment");console.error("THREE.WebGLProgram: shader error: ",l.getError(),"35715",l.getProgramParameter(P,35715),"gl.getProgramInfoLog",ie,Oe,Ve)}else ie!==""?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",ie):(le===""||fe==="")&&(he=!1);he&&(this.diagnostics={runnable:me,programLog:ie,vertexShader:{log:le,prefix:R},fragmentShader:{log:fe,prefix:F}})}l.deleteShader(Q),l.deleteShader(ae);var He;this.getUniforms=function(){return He===void 0&&(He=new as(l,P)),He};var at;return this.getAttributes=function(){return at===void 0&&(at=yP(l,P)),at},this.destroy=function(){l.deleteProgram(P),this.program=void 0},this.name=i.shaderName,this.id=hP++,this.cacheKey=t,this.usedTimes=1,this.program=P,this.vertexShader=Q,this.fragmentShader=ae,this.numMultiviewViews=V,this}function AP(e,t,i){var l=[],c=i.isWebGL2,h=i.logarithmicDepthBuffer,f=i.floatVertexTextures,r=i.precision,v=i.maxVertexUniforms,x=i.vertexTextures,w={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"},b=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","numMultiviewViews","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen"];function A(R,F){var V;if(F){var j=Ra[F];V={name:R.type,uniforms:YE.clone(j.uniforms),vertexShader:j.vertexShader,fragmentShader:j.fragmentShader}}else V={name:R.type,uniforms:R.uniforms,vertexShader:R.vertexShader,fragmentShader:R.fragmentShader};return V}function L(R){var F=R.skeleton,V=F.bones;if(f)return 1024;var j=v,J=Math.floor((j-20)/4),ne=Math.min(J,V.length);return ne<V.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+V.length+" bones. This GPU supports "+ne+"."),0):ne}function P(R){var F;return R?R.isTexture?F=R.encoding:R.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),F=R.texture.encoding):F=io,F}this.getParameters=function(R,F,V,j,J,ne,H){var Q=j.fog,ae=R.isMeshStandardMaterial?j.environment:null,ie=R.envMap||ae,le=w[R.type],fe=H.isSkinnedMesh?L(H):0;R.precision!==null&&(r=i.getMaxPrecision(R.precision),r!==R.precision&&console.warn("THREE.WebGLProgram.getParameters:",R.precision,"not supported, using",r,"instead."));var me=A(R,le);R.onBeforeCompile(me,e);var he=e.getRenderTarget(),Oe=he&&he.isWebGLMultiviewRenderTarget?he.numViews:0,Ve={isWebGL2:c,shaderID:le,shaderName:me.name,uniforms:me.uniforms,vertexShader:me.vertexShader,fragmentShader:me.fragmentShader,defines:R.defines,isRawShaderMaterial:R.isRawShaderMaterial,isShaderMaterial:R.isShaderMaterial,precision:r,instancing:H.isInstancedMesh===!0,supportsVertexTextures:x,numMultiviewViews:Oe,outputEncoding:he!==null?P(he.texture):e.outputEncoding,map:!!R.map,mapEncoding:P(R.map),matcap:!!R.matcap,matcapEncoding:P(R.matcap),envMap:!!ie,envMapMode:ie&&ie.mapping,envMapEncoding:P(ie),envMapCubeUV:!!ie&&(ie.mapping===ph||ie.mapping===cy),lightMap:!!R.lightMap,lightMapEncoding:P(R.lightMap),aoMap:!!R.aoMap,emissiveMap:!!R.emissiveMap,emissiveMapEncoding:P(R.emissiveMap),bumpMap:!!R.bumpMap,normalMap:!!R.normalMap,objectSpaceNormalMap:R.normalMapType===RE,tangentSpaceNormalMap:R.normalMapType===Ys,clearcoatNormalMap:!!R.clearcoatNormalMap,displacementMap:!!R.displacementMap,roughnessMap:!!R.roughnessMap,metalnessMap:!!R.metalnessMap,specularMap:!!R.specularMap,alphaMap:!!R.alphaMap,gradientMap:!!R.gradientMap,sheen:!!R.sheen,combine:R.combine,vertexTangents:R.normalMap&&R.vertexTangents,vertexColors:R.vertexColors,vertexUvs:!!R.map||!!R.bumpMap||!!R.normalMap||!!R.specularMap||!!R.alphaMap||!!R.emissiveMap||!!R.roughnessMap||!!R.metalnessMap||!!R.clearcoatNormalMap||!!R.displacementMap,uvsVertexOnly:!(R.map||R.bumpMap||R.normalMap||R.specularMap||R.alphaMap||R.emissiveMap||R.roughnessMap||R.metalnessMap||R.clearcoatNormalMap)&&!!R.displacementMap,fog:!!Q,useFog:R.fog,fogExp2:Q&&Q.isFogExp2,flatShading:R.flatShading,sizeAttenuation:R.sizeAttenuation,logarithmicDepthBuffer:h,skinning:R.skinning&&fe>0,maxBones:fe,useVertexTexture:f,morphTargets:R.morphTargets,morphNormals:R.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:F.directional.length,numPointLights:F.point.length,numSpotLights:F.spot.length,numRectAreaLights:F.rectArea.length,numHemiLights:F.hemi.length,numDirLightShadows:F.directionalShadowMap.length,numPointLightShadows:F.pointShadowMap.length,numSpotLightShadows:F.spotShadowMap.length,numClippingPlanes:J,numClipIntersection:ne,dithering:R.dithering,shadowMapEnabled:e.shadowMap.enabled&&V.length>0,shadowMapType:e.shadowMap.type,toneMapping:R.toneMapped?e.toneMapping:Zp,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:R.premultipliedAlpha,alphaTest:R.alphaTest,doubleSided:R.side===hh,flipSided:R.side===tr,depthPacking:R.depthPacking!==void 0?R.depthPacking:!1,index0AttributeName:R.index0AttributeName,extensionDerivatives:R.extensions&&R.extensions.derivatives,extensionFragDepth:R.extensions&&R.extensions.frawbuffers,extensionDrawbuffers:R.extensions&&R.extensions.drawbuffers,extensionShaderTextureLOD:R.extensions&&R.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||t.get("EXT_frag_depth")!==null,rendererExtensionDrawBuffers:c||t.get("WEBGL_draw_buffers")!==null,rendererExtensionShaderTextureLod:c||t.get("EXT_shader_texture_lod")!==null,onBeforeCompile:R.onBeforeCompile};return Ve},this.getProgramCacheKey=function(R){var F=[];if(R.shaderID?F.push(R.shaderID):(F.push(R.fragmentShader),F.push(R.vertexShader)),R.defines!==void 0)for(var V in R.defines)F.push(V),F.push(R.defines[V]);if(R.isRawShaderMaterial===void 0){for(var j=0;j<b.length;j++)F.push(R[b[j]]);F.push(e.outputEncoding),F.push(e.gammaFactor)}return F.push(R.onBeforeCompile.toString()),F.join()},this.acquireProgram=function(R,F){for(var V,j=0,J=l.length;j<J;j++){var ne=l[j];if(ne.cacheKey===F){V=ne,++V.usedTimes;break}}return V===void 0&&(V=new CP(e,F,R),l.push(V)),V},this.releaseProgram=function(R){if(--R.usedTimes===0){var F=l.indexOf(R);l[F]=l[l.length-1],l.pop(),R.destroy()}},this.programs=l}function DP(){var e=new WeakMap;function t(h){var f=e.get(h);return f===void 0&&(f={},e.set(h,f)),f}function i(h){e.delete(h)}function l(h,f,r){e.get(h)[f]=r}function c(){e=new WeakMap}return{get:t,remove:i,update:l,dispose:c}}function PP(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program!==t.program?e.program.id-t.program.id:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function SP(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function T0(){var e=[],t=0,i=[],l=[],c={id:-1};function h(){t=0,i.length=0,l.length=0}function f(w,b,A,L,P,R){var F=e[t];return F===void 0?(F={id:w.id,object:w,geometry:b,material:A,program:A.program||c,groupOrder:L,renderOrder:w.renderOrder,z:P,group:R},e[t]=F):(F.id=w.id,F.object=w,F.geometry=b,F.material=A,F.program=A.program||c,F.groupOrder=L,F.renderOrder=w.renderOrder,F.z=P,F.group=R),t++,F}function r(w,b,A,L,P,R){var F=f(w,b,A,L,P,R);(A.transparent===!0?l:i).push(F)}function v(w,b,A,L,P,R){var F=f(w,b,A,L,P,R);(A.transparent===!0?l:i).unshift(F)}function x(w,b){i.length>1&&i.sort(w||PP),l.length>1&&l.sort(b||SP)}return{opaque:i,transparent:l,init:h,push:r,unshift:v,sort:x}}function LP(){var e=new WeakMap;function t(c){var h=c.target;h.removeEventListener("dispose",t),e.delete(h)}function i(c,h){var f=e.get(c),r;return f===void 0?(r=new T0,e.set(c,new WeakMap),e.get(c).set(h,r),c.addEventListener("dispose",t)):(r=f.get(h),r===void 0&&(r=new T0,f.set(h,r))),r}function l(){e=new WeakMap}return{get:i,dispose:l}}function IP(){var e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];var i;switch(t.type){case"DirectionalLight":i={direction:new Pe,color:new tn,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Lt};break;case"SpotLight":i={position:new Pe,direction:new Pe,color:new tn,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Lt};break;case"PointLight":i={position:new Pe,color:new tn,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Lt,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":i={direction:new Pe,skyColor:new tn,groundColor:new tn};break;case"RectAreaLight":i={color:new tn,position:new Pe,halfWidth:new Pe,halfHeight:new Pe};break}return e[t.id]=i,i}}}var RP=0;function kP(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function zP(){for(var e=new IP,t={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},i=0;i<9;i++)t.probe.push(new Pe);var l=new Pe,c=new Hn,h=new Hn;function f(r,v,x){for(var w=0,b=0,A=0,L=0;L<9;L++)t.probe[L].set(0,0,0);var P=0,R=0,F=0,V=0,j=0,J=0,ne=0,H=0,Q=x.matrixWorldInverse;r.sort(kP);for(var L=0,ae=r.length;L<ae;L++){var ie=r[L],le=ie.color,fe=ie.intensity,me=ie.distance,he=ie.shadow&&ie.shadow.map?ie.shadow.map.texture:null;if(ie.isAmbientLight)w+=le.r*fe,b+=le.g*fe,A+=le.b*fe;else if(ie.isLightProbe)for(var Oe=0;Oe<9;Oe++)t.probe[Oe].addScaledVector(ie.sh.coefficients[Oe],fe);else if(ie.isDirectionalLight){var Ve=e.get(ie);if(Ve.color.copy(ie.color).multiplyScalar(ie.intensity),Ve.direction.setFromMatrixPosition(ie.matrixWorld),l.setFromMatrixPosition(ie.target.matrixWorld),Ve.direction.sub(l),Ve.direction.transformDirection(Q),Ve.shadow=ie.castShadow,ie.castShadow){var He=ie.shadow;Ve.shadowBias=He.bias,Ve.shadowRadius=He.radius,Ve.shadowMapSize=He.mapSize,t.directionalShadowMap[P]=he,t.directionalShadowMatrix[P]=ie.shadow.matrix,J++}t.directional[P]=Ve,P++}else if(ie.isSpotLight){var Ve=e.get(ie);if(Ve.position.setFromMatrixPosition(ie.matrixWorld),Ve.position.applyMatrix4(Q),Ve.color.copy(le).multiplyScalar(fe),Ve.distance=me,Ve.direction.setFromMatrixPosition(ie.matrixWorld),l.setFromMatrixPosition(ie.target.matrixWorld),Ve.direction.sub(l),Ve.direction.transformDirection(Q),Ve.coneCos=Math.cos(ie.angle),Ve.penumbraCos=Math.cos(ie.angle*(1-ie.penumbra)),Ve.decay=ie.decay,Ve.shadow=ie.castShadow,ie.castShadow){var He=ie.shadow;Ve.shadowBias=He.bias,Ve.shadowRadius=He.radius,Ve.shadowMapSize=He.mapSize,t.spotShadowMap[F]=he,t.spotShadowMatrix[F]=ie.shadow.matrix,H++}t.spot[F]=Ve,F++}else if(ie.isRectAreaLight){var Ve=e.get(ie);Ve.color.copy(le).multiplyScalar(fe),Ve.position.setFromMatrixPosition(ie.matrixWorld),Ve.position.applyMatrix4(Q),h.identity(),c.copy(ie.matrixWorld),c.premultiply(Q),h.extractRotation(c),Ve.halfWidth.set(ie.width*.5,0,0),Ve.halfHeight.set(0,ie.height*.5,0),Ve.halfWidth.applyMatrix4(h),Ve.halfHeight.applyMatrix4(h),t.rectArea[V]=Ve,V++}else if(ie.isPointLight){var Ve=e.get(ie);if(Ve.position.setFromMatrixPosition(ie.matrixWorld),Ve.position.applyMatrix4(Q),Ve.color.copy(ie.color).multiplyScalar(ie.intensity),Ve.distance=ie.distance,Ve.decay=ie.decay,Ve.shadow=ie.castShadow,ie.castShadow){var He=ie.shadow;Ve.shadowBias=He.bias,Ve.shadowRadius=He.radius,Ve.shadowMapSize=He.mapSize,Ve.shadowCameraNear=He.camera.near,Ve.shadowCameraFar=He.camera.far,t.pointShadowMap[R]=he,t.pointShadowMatrix[R]=ie.shadow.matrix,ne++}t.point[R]=Ve,R++}else if(ie.isHemisphereLight){var Ve=e.get(ie);Ve.direction.setFromMatrixPosition(ie.matrixWorld),Ve.direction.transformDirection(Q),Ve.direction.normalize(),Ve.skyColor.copy(ie.color).multiplyScalar(fe),Ve.groundColor.copy(ie.groundColor).multiplyScalar(fe),t.hemi[j]=Ve,j++}}t.ambient[0]=w,t.ambient[1]=b,t.ambient[2]=A;var at=t.hash;(at.directionalLength!==P||at.pointLength!==R||at.spotLength!==F||at.rectAreaLength!==V||at.hemiLength!==j||at.numDirectionalShadows!==J||at.numPointShadows!==ne||at.numSpotShadows!==H)&&(t.directional.length=P,t.spot.length=F,t.rectArea.length=V,t.point.length=R,t.hemi.length=j,t.directionalShadowMap.length=J,t.pointShadowMap.length=ne,t.spotShadowMap.length=H,t.directionalShadowMatrix.length=J,t.pointShadowMatrix.length=ne,t.spotShadowMatrix.length=H,at.directionalLength=P,at.pointLength=R,at.spotLength=F,at.rectAreaLength=V,at.hemiLength=j,at.numDirectionalShadows=J,at.numPointShadows=ne,at.numSpotShadows=H,t.version=RP++)}return{setup:f,state:t}}function E0(){var e=new zP,t=[],i=[];function l(){t.length=0,i.length=0}function c(v){t.push(v)}function h(v){i.push(v)}function f(v){e.setup(t,i,v)}var r={lightsArray:t,shadowsArray:i,lights:e};return{init:l,state:r,setupLights:f,pushLight:c,pushShadow:h}}function FP(){var e=new WeakMap;function t(c){var h=c.target;h.removeEventListener("dispose",t),e.delete(h)}function i(c,h){var f;return e.has(c)===!1?(f=new E0,e.set(c,new WeakMap),e.get(c).set(h,f),c.addEventListener("dispose",t)):e.get(c).has(h)===!1?(f=new E0,e.get(c).set(h,f)):f=e.get(c).get(h),f}function l(){e=new WeakMap}return{get:i,dispose:l}}function rl(e){Rn.call(this),this.type="MeshDepthMaterial",this.depthPacking=LE,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}rl.prototype=Object.create(Rn.prototype),rl.prototype.constructor=rl,rl.prototype.isMeshDepthMaterial=!0,rl.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.skinning=e.skinning,this.morphTargets=e.morphTargets,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};function ol(e){Rn.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new Pe,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}ol.prototype=Object.create(Rn.prototype),ol.prototype.constructor=ol,ol.prototype.isMeshDistanceMaterial=!0,ol.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this};var BP=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- float mean = 0.0;
- float squared_mean = 0.0;
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );
- for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {
- #ifdef HORIZONAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 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, i ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean * HALF_SAMPLE_RATE;
- squared_mean = squared_mean * HALF_SAMPLE_RATE;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`,OP=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`;function C0(e,t,i){var l=new Ph,c=new Lt,h=new Lt,f=new gi,r=[],v=[],x={},w={0:tr,1:nc,2:hh},b=new Ur({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new Lt},radius:{value:4}},vertexShader:OP,fragmentShader:BP}),A=b.clone();A.defines.HORIZONAL_PASS=1;var L=new vn;L.setAttribute("position",new kn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var P=new Ai(L,b),R=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=yx,this.render=function(H,Q,ae){if(R.enabled!==!1&&!(R.autoUpdate===!1&&R.needsUpdate===!1)&&H.length!==0){var ie=e.getRenderTarget(),le=e.getActiveCubeFace(),fe=e.getActiveMipmapLevel(),me=e.state;me.setBlending(es),me.buffers.color.setClear(1,1,1,1),me.buffers.depth.setTest(!0),me.setScissorTest(!1);for(var he=0,Oe=H.length;he<Oe;he++){var Ve=H[he],He=Ve.shadow;if(He===void 0){console.warn("THREE.WebGLShadowMap:",Ve,"has no shadow.");continue}c.copy(He.mapSize);var at=He.getFrameExtents();if(c.multiply(at),h.copy(He.mapSize),(c.x>i||c.y>i)&&(console.warn("THREE.WebGLShadowMap:",Ve,"has shadow exceeding max texture size, reducing"),c.x>i&&(h.x=Math.floor(i/at.x),c.x=h.x*at.x,He.mapSize.x=h.x),c.y>i&&(h.y=Math.floor(i/at.y),c.y=h.y*at.y,He.mapSize.y=h.y)),He.map===null&&!He.isPointLightShadow&&this.type===uh){var At={minFilter:$i,magFilter:$i,format:Ao};He.map=new Tr(c.x,c.y,At),He.map.texture.name=Ve.name+".shadowMap",He.mapPass=new Tr(c.x,c.y,At),He.camera.updateProjectionMatrix()}if(He.map===null){var At={minFilter:Ui,magFilter:Ui,format:Ao};He.map=new Tr(c.x,c.y,At),He.map.texture.name=Ve.name+".shadowMap",He.camera.updateProjectionMatrix()}e.setRenderTarget(He.map),e.clear();for(var yt=He.getViewportCount(),Dt=0;Dt<yt;Dt++){var It=He.getViewport(Dt);f.set(h.x*It.x,h.y*It.y,h.x*It.z,h.y*It.w),me.viewport(f),He.updateMatrices(Ve,Dt),l=He.getFrustum(),ne(Q,ae,He.camera,Ve,this.type)}!He.isPointLightShadow&&this.type===uh&&F(He,ae)}R.needsUpdate=!1,e.setRenderTarget(ie,le,fe)}};function F(H,Q){var ae=t.update(P);b.uniforms.shadow_pass.value=H.map.texture,b.uniforms.resolution.value=H.mapSize,b.uniforms.radius.value=H.radius,e.setRenderTarget(H.mapPass),e.clear(),e.renderBufferDirect(Q,null,ae,b,P,null),A.uniforms.shadow_pass.value=H.mapPass.texture,A.uniforms.resolution.value=H.mapSize,A.uniforms.radius.value=H.radius,e.setRenderTarget(H.map),e.clear(),e.renderBufferDirect(Q,null,ae,A,P,null)}function V(H,Q,ae){var ie=H<<0|Q<<1|ae<<2,le=r[ie];return le===void 0&&(le=new rl({depthPacking:IE,morphTargets:H,skinning:Q}),r[ie]=le),le}function j(H,Q,ae){var ie=H<<0|Q<<1|ae<<2,le=v[ie];return le===void 0&&(le=new ol({morphTargets:H,skinning:Q}),v[ie]=le),le}function J(H,Q,ae,ie,le,fe){var me=H.geometry,he=null,Oe=V,Ve=H.customDepthMaterial;if(ae.isPointLight===!0&&(Oe=j,Ve=H.customDistanceMaterial),Ve===void 0){var He=!1;Q.morphTargets===!0&&(me.isBufferGeometry===!0?He=me.morphAttributes&&me.morphAttributes.position&&me.morphAttributes.position.length>0:me.isGeometry===!0&&(He=me.morphTargets&&me.morphTargets.length>0));var at=!1;H.isSkinnedMesh===!0&&(Q.skinning===!0?at=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",H));var At=H.isInstancedMesh===!0;he=Oe(He,at,At)}else he=Ve;if(e.localClippingEnabled&&Q.clipShadows===!0&&Q.clippingPlanes.length!==0){var yt=he.uuid,Dt=Q.uuid,It=x[yt];It===void 0&&(It={},x[yt]=It);var Nt=It[Dt];Nt===void 0&&(Nt=he.clone(),It[Dt]=Nt),he=Nt}return he.visible=Q.visible,he.wireframe=Q.wireframe,fe===uh?he.side=Q.shadowSide!==null?Q.shadowSide:Q.side:he.side=Q.shadowSide!==null?Q.shadowSide:w[Q.side],he.clipShadows=Q.clipShadows,he.clippingPlanes=Q.clippingPlanes,he.clipIntersection=Q.clipIntersection,he.wireframeLinewidth=Q.wireframeLinewidth,he.linewidth=Q.linewidth,ae.isPointLight===!0&&he.isMeshDistanceMaterial===!0&&(he.referencePosition.setFromMatrixPosition(ae.matrixWorld),he.nearDistance=ie,he.farDistance=le),he}function ne(H,Q,ae,ie,le){if(H.visible!==!1){var fe=H.layers.test(Q.layers);if(fe&&(H.isMesh||H.isLine||H.isPoints)&&(H.castShadow||H.receiveShadow&&le===uh)&&(!H.frustumCulled||l.intersectsObject(H))){H.modelViewMatrix.multiplyMatrices(ae.matrixWorldInverse,H.matrixWorld);var me=t.update(H),he=H.material;if(Array.isArray(he))for(var Oe=me.groups,Ve=0,He=Oe.length;Ve<He;Ve++){var at=Oe[Ve],At=he[at.materialIndex];if(At&&At.visible){var yt=J(H,At,ie,ae.near,ae.far,le);e.renderBufferDirect(ae,null,me,yt,H,at)}}else if(he.visible){var yt=J(H,he,ie,ae.near,ae.far,le);e.renderBufferDirect(ae,null,me,yt,H,null)}}for(var Dt=H.children,It=0,Nt=Dt.length;It<Nt;It++)ne(Dt[It],Q,ae,ie,le)}}}function NP(e,t,i){var l=i.isWebGL2;function c(){var Xe=!1,Ut=new gi,en=null,Pn=new gi(0,0,0,0);return{setMask:function(fn){en!==fn&&!Xe&&(e.colorMask(fn,fn,fn,fn),en=fn)},setLocked:function(fn){Xe=fn},setClear:function(fn,On,Gn,qn,ji){ji===!0&&(fn*=qn,On*=qn,Gn*=qn),Ut.set(fn,On,Gn,qn),Pn.equals(Ut)===!1&&(e.clearColor(fn,On,Gn,qn),Pn.copy(Ut))},reset:function(){Xe=!1,en=null,Pn.set(-1,0,0,0)}}}function h(){var Xe=!1,Ut=null,en=null,Pn=null;return{setTest:function(fn){fn?ge(2929):Ce(2929)},setMask:function(fn){Ut!==fn&&!Xe&&(e.depthMask(fn),Ut=fn)},setFunc:function(fn){if(en!==fn){if(fn)switch(fn){case zT:e.depthFunc(512);break;case FT:e.depthFunc(519);break;case BT:e.depthFunc(513);break;case iy:e.depthFunc(515);break;case OT:e.depthFunc(514);break;case NT:e.depthFunc(518);break;case UT:e.depthFunc(516);break;case VT:e.depthFunc(517);break;default:e.depthFunc(515)}else e.depthFunc(515);en=fn}},setLocked:function(fn){Xe=fn},setClear:function(fn){Pn!==fn&&(e.clearDepth(fn),Pn=fn)},reset:function(){Xe=!1,Ut=null,en=null,Pn=null}}}function f(){var Xe=!1,Ut=null,en=null,Pn=null,fn=null,On=null,Gn=null,qn=null,ji=null;return{setTest:function(Nn){Xe||(Nn?ge(2960):Ce(2960))},setMask:function(Nn){Ut!==Nn&&!Xe&&(e.stencilMask(Nn),Ut=Nn)},setFunc:function(Nn,Di,ei){(en!==Nn||Pn!==Di||fn!==ei)&&(e.stencilFunc(Nn,Di,ei),en=Nn,Pn=Di,fn=ei)},setOp:function(Nn,Di,ei){(On!==Nn||Gn!==Di||qn!==ei)&&(e.stencilOp(Nn,Di,ei),On=Nn,Gn=Di,qn=ei)},setLocked:function(Nn){Xe=Nn},setClear:function(Nn){ji!==Nn&&(e.clearStencil(Nn),ji=Nn)},reset:function(){Xe=!1,Ut=null,en=null,Pn=null,fn=null,On=null,Gn=null,qn=null,ji=null}}}var r=new c,v=new h,x=new f,w=e.getParameter(34921),b=new Uint8Array(w),A=new Uint8Array(w),L=new Uint8Array(w),P={},R=null,F=null,V=null,j=null,J=null,ne=null,H=null,Q=null,ae=null,ie=!1,le=null,fe=null,me=null,he=null,Oe=null,Ve=e.getParameter(35661),He=!1,at=0,At=e.getParameter(7938);At.indexOf("WebGL")!==-1?(at=parseFloat(/^WebGL\ ([0-9])/.exec(At)[1]),He=at>=1):At.indexOf("OpenGL ES")!==-1&&(at=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(At)[1]),He=at>=2);var yt=null,Dt={},It=new gi,Nt=new gi;function Ie(Xe,Ut,en){var Pn=new Uint8Array(4),fn=e.createTexture();e.bindTexture(Xe,fn),e.texParameteri(Xe,10241,9728),e.texParameteri(Xe,10240,9728);for(var On=0;On<en;On++)e.texImage2D(Ut+On,0,6408,1,1,0,6408,5121,Pn);return fn}var be={};be[3553]=Ie(3553,3553,1),be[34067]=Ie(34067,34069,6),r.setClear(0,0,0,1),v.setClear(1),x.setClear(0),ge(2929),v.setFunc(iy),Gt(!1),pe(gx),ge(2884),ct(es);function We(){for(var Xe=0,Ut=b.length;Xe<Ut;Xe++)b[Xe]=0}function Ge(Xe){ke(Xe,0)}function ke(Xe,Ut){if(b[Xe]=1,A[Xe]===0&&(e.enableVertexAttribArray(Xe),A[Xe]=1),L[Xe]!==Ut){var en=l?e:t.get("ANGLE_instanced_arrays");en[l?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](Xe,Ut),L[Xe]=Ut}}function ot(){for(var Xe=0,Ut=A.length;Xe!==Ut;++Xe)A[Xe]!==b[Xe]&&(e.disableVertexAttribArray(Xe),A[Xe]=0)}function ge(Xe){P[Xe]!==!0&&(e.enable(Xe),P[Xe]=!0)}function Ce(Xe){P[Xe]!==!1&&(e.disable(Xe),P[Xe]=!1)}function Ae(Xe){return R!==Xe?(e.useProgram(Xe),R=Xe,!0):!1}var _e={[rc]:32774,[TT]:32778,[ET]:32779};if(l)_e[Tx]=32775,_e[Ex]=32776;else{var Ne=t.get("EXT_blend_minmax");Ne!==null&&(_e[Tx]=Ne.MIN_EXT,_e[Ex]=Ne.MAX_EXT)}var Je={[CT]:0,[AT]:1,[DT]:768,[Cx]:770,[kT]:776,[IT]:774,[ST]:772,[PT]:769,[Ax]:771,[RT]:775,[LT]:773};function ct(Xe,Ut,en,Pn,fn,On,Gn,qn){if(Xe===es){F&&(Ce(3042),F=!1);return}if(F||(ge(3042),F=!0),Xe!==MT){if(Xe!==V||qn!==ie){if((j!==rc||H!==rc)&&(e.blendEquation(32774),j=rc,H=rc),qn)switch(Xe){case dh:e.blendFuncSeparate(1,771,1,771);break;case xx:e.blendFunc(1,1);break;case bx:e.blendFuncSeparate(0,0,769,771);break;case wx:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Xe);break}else switch(Xe){case dh:e.blendFuncSeparate(770,771,1,771);break;case xx:e.blendFunc(770,1);break;case bx:e.blendFunc(0,769);break;case wx:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Xe);break}J=null,ne=null,Q=null,ae=null,V=Xe,ie=qn}return}fn=fn||Ut,On=On||en,Gn=Gn||Pn,(Ut!==j||fn!==H)&&(e.blendEquationSeparate(_e[Ut],_e[fn]),j=Ut,H=fn),(en!==J||Pn!==ne||On!==Q||Gn!==ae)&&(e.blendFuncSeparate(Je[en],Je[Pn],Je[On],Je[Gn]),J=en,ne=Pn,Q=On,ae=Gn),V=Xe,ie=null}function wt(Xe,Ut){Xe.side===hh?Ce(2884):ge(2884);var en=Xe.side===tr;Ut&&(en=!en),Gt(en),Xe.blending===dh&&Xe.transparent===!1?ct(es):ct(Xe.blending,Xe.blendEquation,Xe.blendSrc,Xe.blendDst,Xe.blendEquationAlpha,Xe.blendSrcAlpha,Xe.blendDstAlpha,Xe.premultipliedAlpha),v.setFunc(Xe.depthFunc),v.setTest(Xe.depthTest),v.setMask(Xe.depthWrite),r.setMask(Xe.colorWrite);var Pn=Xe.stencilWrite;x.setTest(Pn),Pn&&(x.setMask(Xe.stencilWriteMask),x.setFunc(Xe.stencilFunc,Xe.stencilRef,Xe.stencilFuncMask),x.setOp(Xe.stencilFail,Xe.stencilZFail,Xe.stencilZPass)),bt(Xe.polygonOffset,Xe.polygonOffsetFactor,Xe.polygonOffsetUnits)}function Gt(Xe){le!==Xe&&(Xe?e.frontFace(2304):e.frontFace(2305),le=Xe)}function pe(Xe){Xe!==vT?(ge(2884),Xe!==fe&&(Xe===gx?e.cullFace(1029):Xe===xT?e.cullFace(1028):e.cullFace(1032))):Ce(2884),fe=Xe}function Me(Xe){Xe!==me&&(He&&e.lineWidth(Xe),me=Xe)}function bt(Xe,Ut,en){Xe?(ge(32823),(he!==Ut||Oe!==en)&&(e.polygonOffset(Ut,en),he=Ut,Oe=en)):Ce(32823)}function gt(Xe){Xe?ge(3089):Ce(3089)}function bn(Xe){Xe===void 0&&(Xe=33984+Ve-1),yt!==Xe&&(e.activeTexture(Xe),yt=Xe)}function hn(Xe,Ut){yt===null&&bn();var en=Dt[yt];en===void 0&&(en={type:void 0,texture:void 0},Dt[yt]=en),(en.type!==Xe||en.texture!==Ut)&&(e.bindTexture(Xe,Ut||be[Xe]),en.type=Xe,en.texture=Ut)}function nn(){var Xe=Dt[yt];Xe!==void 0&&Xe.type!==void 0&&(e.bindTexture(Xe.type,null),Xe.type=void 0,Xe.texture=void 0)}function pn(){try{e.compressedTexImage2D.apply(e,arguments)}catch(Xe){console.error("THREE.WebGLState:",Xe)}}function wn(){try{e.texImage2D.apply(e,arguments)}catch(Xe){console.error("THREE.WebGLState:",Xe)}}function cn(){try{e.texImage3D.apply(e,arguments)}catch(Xe){console.error("THREE.WebGLState:",Xe)}}function Wt(Xe){It.equals(Xe)===!1&&(e.scissor(Xe.x,Xe.y,Xe.z,Xe.w),It.copy(Xe))}function sn(Xe){Nt.equals(Xe)===!1&&(e.viewport(Xe.x,Xe.y,Xe.z,Xe.w),Nt.copy(Xe))}function Xt(){for(var Xe=0;Xe<A.length;Xe++)A[Xe]===1&&(e.disableVertexAttribArray(Xe),A[Xe]=0);P={},yt=null,Dt={},R=null,V=null,le=null,fe=null,r.reset(),v.reset(),x.reset()}return{buffers:{color:r,depth:v,stencil:x},initAttributes:We,enableAttribute:Ge,enableAttributeAndDivisor:ke,disableUnusedAttributes:ot,enable:ge,disable:Ce,useProgram:Ae,setBlending:ct,setMaterial:wt,setFlipSided:Gt,setCullFace:pe,setLineWidth:Me,setPolygonOffset:bt,setScissorTest:gt,activeTexture:bn,bindTexture:hn,unbindTexture:nn,compressedTexImage2D:pn,texImage2D:wn,texImage3D:cn,scissor:Wt,viewport:sn,reset:Xt}}function UP(e,t,i,l,c,h,f){var r=c.isWebGL2,v=c.maxTextures,x=c.maxCubemapSize,w=c.maxTextureSize,b=c.maxSamples,A=new WeakMap,L,P=!1;try{P=typeof OffscreenCanvas!="undefined"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(pe){}function R(pe,Me){return P?new OffscreenCanvas(pe,Me):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function F(pe,Me,bt,gt){var bn=1;if((pe.width>gt||pe.height>gt)&&(bn=gt/Math.max(pe.width,pe.height)),bn<1||Me===!0)if(typeof HTMLImageElement!="undefined"&&pe instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&pe instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&pe instanceof ImageBitmap){var hn=Me?jn.floorPowerOfTwo:Math.floor,nn=hn(bn*pe.width),pn=hn(bn*pe.height);L===void 0&&(L=R(nn,pn));var wn=bt?R(nn,pn):L;wn.width=nn,wn.height=pn;var cn=wn.getContext("2d");return cn.drawImage(pe,0,0,nn,pn),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+pe.width+"x"+pe.height+") to ("+nn+"x"+pn+")."),wn}else return"data"in pe&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+pe.width+"x"+pe.height+")."),pe;return pe}function V(pe){return jn.isPowerOfTwo(pe.width)&&jn.isPowerOfTwo(pe.height)}function j(pe){return r?!1:pe.wrapS!==Mr||pe.wrapT!==Mr||pe.minFilter!==Ui&&pe.minFilter!==$i}function J(pe,Me){return pe.generateMipmaps&&Me&&pe.minFilter!==Ui&&pe.minFilter!==$i}function ne(pe,Me,bt,gt){e.generateMipmap(pe);var bn=l.get(Me);bn.__maxMipLevel=Math.log(Math.max(bt,gt))*Math.LOG2E}function H(pe,Me,bt){if(r===!1)return Me;if(pe!==null){if(e[pe]!==void 0)return e[pe];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+pe+"'")}var gt=Me;return Me===6403&&(bt===5126&&(gt=33326),bt===5131&&(gt=33325),bt===5121&&(gt=33321)),Me===6407&&(bt===5126&&(gt=34837),bt===5131&&(gt=34843),bt===5121&&(gt=32849)),Me===6408&&(bt===5126&&(gt=34836),bt===5131&&(gt=34842),bt===5121&&(gt=32856)),gt===33325||gt===33326||gt===34842||gt===34836?t.get("EXT_color_buffer_float"):(gt===34843||gt===34837)&&console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead."),gt}function Q(pe){return pe===Ui||pe===Yp||pe===Kp?9728:9729}function ae(pe){var Me=pe.target;Me.removeEventListener("dispose",ae),le(Me),Me.isVideoTexture&&A.delete(Me),f.memory.textures--}function ie(pe){var Me=pe.target;Me.removeEventListener("dispose",ie),fe(Me),f.memory.textures--}function le(pe){var Me=l.get(pe);Me.__webglInit!==void 0&&(e.deleteTexture(Me.__webglTexture),l.remove(pe))}function fe(pe){var Me=l.get(pe),bt=l.get(pe.texture);if(pe){if(bt.__webglTexture!==void 0&&e.deleteTexture(bt.__webglTexture),pe.depthTexture&&pe.depthTexture.dispose(),pe.isWebGLCubeRenderTarget)for(var gt=0;gt<6;gt++)e.deleteFramebuffer(Me.__webglFramebuffer[gt]),Me.__webglDepthbuffer&&e.deleteRenderbuffer(Me.__webglDepthbuffer[gt]);else e.deleteFramebuffer(Me.__webglFramebuffer),Me.__webglDepthbuffer&&e.deleteRenderbuffer(Me.__webglDepthbuffer);if(pe.isWebGLMultiviewRenderTarget){e.deleteTexture(Me.__webglColorTexture),e.deleteTexture(Me.__webglDepthStencilTexture),f.memory.textures-=2;for(var gt=0,bn=Me.__webglViewFramebuffers.length;gt<bn;gt++)e.deleteFramebuffer(Me.__webglViewFramebuffers[gt])}l.remove(pe.texture),l.remove(pe)}}var me=0;function he(){me=0}function Oe(){var pe=me;return pe>=v&&console.warn("THREE.WebGLTextures: Trying to use "+pe+" texture units while this GPU supports only "+v),me+=1,pe}function Ve(pe,Me){var bt=l.get(pe);if(pe.isVideoTexture&&Ne(pe),pe.version>0&&bt.__version!==pe.version){var gt=pe.image;if(gt===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(gt.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{be(bt,pe,Me);return}}i.activeTexture(33984+Me),i.bindTexture(3553,bt.__webglTexture)}function He(pe,Me){var bt=l.get(pe);if(pe.version>0&&bt.__version!==pe.version){be(bt,pe,Me);return}i.activeTexture(33984+Me),i.bindTexture(35866,bt.__webglTexture)}function at(pe,Me){var bt=l.get(pe);if(pe.version>0&&bt.__version!==pe.version){be(bt,pe,Me);return}i.activeTexture(33984+Me),i.bindTexture(32879,bt.__webglTexture)}function At(pe,Me){if(pe.image.length===6){var bt=l.get(pe);if(pe.version>0&&bt.__version!==pe.version){Ie(bt,pe),i.activeTexture(33984+Me),i.bindTexture(34067,bt.__webglTexture),e.pixelStorei(37440,pe.flipY);for(var gt=pe&&(pe.isCompressedTexture||pe.image[0].isCompressedTexture),bn=pe.image[0]&&pe.image[0].isDataTexture,hn=[],nn=0;nn<6;nn++)!gt&&!bn?hn[nn]=F(pe.image[nn],!1,!0,x):hn[nn]=bn?pe.image[nn].image:pe.image[nn];var pn=hn[0],wn=V(pn)||r,cn=h.convert(pe.format),Wt=h.convert(pe.type),sn=H(pe.internalFormat,cn,Wt);Nt(34067,pe,wn);var Xt;if(gt){for(var nn=0;nn<6;nn++){Xt=hn[nn].mipmaps;for(var Xe=0;Xe<Xt.length;Xe++){var Ut=Xt[Xe];pe.format!==Ao&&pe.format!==Ma?cn!==null?i.compressedTexImage2D(34069+nn,Xe,sn,Ut.width,Ut.height,0,Ut.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(34069+nn,Xe,sn,Ut.width,Ut.height,0,cn,Wt,Ut.data)}}bt.__maxMipLevel=Xt.length-1}else{Xt=pe.mipmaps;for(var nn=0;nn<6;nn++)if(bn){i.texImage2D(34069+nn,0,sn,hn[nn].width,hn[nn].height,0,cn,Wt,hn[nn].data);for(var Xe=0;Xe<Xt.length;Xe++){var Ut=Xt[Xe],en=Ut.image[nn].image;i.texImage2D(34069+nn,Xe+1,sn,en.width,en.height,0,cn,Wt,en.data)}}else{i.texImage2D(34069+nn,0,sn,cn,Wt,hn[nn]);for(var Xe=0;Xe<Xt.length;Xe++){var Ut=Xt[Xe];i.texImage2D(34069+nn,Xe+1,sn,cn,Wt,Ut.image[nn])}}bt.__maxMipLevel=Xt.length}J(pe,wn)&&ne(34067,pe,pn.width,pn.height),bt.__version=pe.version,pe.onUpdate&&pe.onUpdate(pe)}else i.activeTexture(33984+Me),i.bindTexture(34067,bt.__webglTexture)}}function yt(pe,Me){i.activeTexture(33984+Me),i.bindTexture(34067,l.get(pe).__webglTexture)}var Dt={[Zs]:10497,[Mr]:33071,[fh]:33648},It={[Ui]:9728,[Yp]:9984,[Kp]:9986,[$i]:9729,[uy]:9985,[oc]:9987};function Nt(pe,Me,bt){bt?(e.texParameteri(pe,10242,Dt[Me.wrapS]),e.texParameteri(pe,10243,Dt[Me.wrapT]),(pe===32879||pe===35866)&&e.texParameteri(pe,32882,Dt[Me.wrapR]),e.texParameteri(pe,10240,It[Me.magFilter]),e.texParameteri(pe,10241,It[Me.minFilter])):(e.texParameteri(pe,10242,33071),e.texParameteri(pe,10243,33071),(pe===32879||pe===35866)&&e.texParameteri(pe,32882,33071),(Me.wrapS!==Mr||Me.wrapT!==Mr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(pe,10240,Q(Me.magFilter)),e.texParameteri(pe,10241,Q(Me.minFilter)),Me.minFilter!==Ui&&Me.minFilter!==$i&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));var gt=t.get("EXT_texture_filter_anisotropic");if(gt){if(Me.type===mh&&t.get("OES_texture_float_linear")===null||Me.type===hy&&(r||t.get("OES_texture_half_float_linear"))===null)return;(Me.anisotropy>1||l.get(Me).__currentAnisotropy)&&(e.texParameterf(pe,gt.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(Me.anisotropy,c.getMaxAnisotropy())),l.get(Me).__currentAnisotropy=Me.anisotropy)}}function Ie(pe,Me){pe.__webglInit===void 0&&(pe.__webglInit=!0,Me.addEventListener("dispose",ae),pe.__webglTexture=e.createTexture(),f.memory.textures++)}function be(pe,Me,bt){var gt=3553;Me.isDataTexture2DArray&&(gt=35866),Me.isDataTexture3D&&(gt=32879),Ie(pe,Me),i.activeTexture(33984+bt),i.bindTexture(gt,pe.__webglTexture),e.pixelStorei(37440,Me.flipY),e.pixelStorei(37441,Me.premultiplyAlpha),e.pixelStorei(3317,Me.unpackAlignment);var bn=j(Me)&&V(Me.image)===!1,hn=F(Me.image,bn,!1,w),nn=V(hn)||r,pn=h.convert(Me.format),wn=h.convert(Me.type),cn=H(Me.internalFormat,pn,wn);Nt(gt,Me,nn);var Wt,sn=Me.mipmaps;if(Me.isDepthTexture){if(cn=6402,Me.type===mh){if(r===!1)throw new Error("Float Depth Texture only supported in WebGL2.0");cn=36012}else r&&(cn=33189);Me.format===ac&&cn===6402&&Me.type!==Qp&&Me.type!==Sx&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),Me.type=Qp,wn=h.convert(Me.type)),Me.format===gh&&(cn=34041,Me.type!==ef&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),Me.type=ef,wn=h.convert(Me.type))),i.texImage2D(3553,0,cn,hn.width,hn.height,0,pn,wn,null)}else if(Me.isDataTexture)if(sn.length>0&&nn){for(var Xt=0,Xe=sn.length;Xt<Xe;Xt++)Wt=sn[Xt],i.texImage2D(3553,Xt,cn,Wt.width,Wt.height,0,pn,wn,Wt.data);Me.generateMipmaps=!1,pe.__maxMipLevel=sn.length-1}else i.texImage2D(3553,0,cn,hn.width,hn.height,0,pn,wn,hn.data),pe.__maxMipLevel=0;else if(Me.isCompressedTexture){for(var Xt=0,Xe=sn.length;Xt<Xe;Xt++)Wt=sn[Xt],Me.format!==Ao&&Me.format!==Ma?pn!==null?i.compressedTexImage2D(3553,Xt,cn,Wt.width,Wt.height,0,Wt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(3553,Xt,cn,Wt.width,Wt.height,0,pn,wn,Wt.data);pe.__maxMipLevel=sn.length-1}else if(Me.isDataTexture2DArray)i.texImage3D(35866,0,cn,hn.width,hn.height,hn.depth,0,pn,wn,hn.data),pe.__maxMipLevel=0;else if(Me.isDataTexture3D)i.texImage3D(32879,0,cn,hn.width,hn.height,hn.depth,0,pn,wn,hn.data),pe.__maxMipLevel=0;else if(sn.length>0&&nn){for(var Xt=0,Xe=sn.length;Xt<Xe;Xt++)Wt=sn[Xt],i.texImage2D(3553,Xt,cn,pn,wn,Wt);Me.generateMipmaps=!1,pe.__maxMipLevel=sn.length-1}else i.texImage2D(3553,0,cn,pn,wn,hn),pe.__maxMipLevel=0;J(Me,nn)&&ne(gt,Me,hn.width,hn.height),pe.__version=Me.version,Me.onUpdate&&Me.onUpdate(Me)}function We(pe,Me,bt,gt){var bn=h.convert(Me.texture.format),hn=h.convert(Me.texture.type),nn=H(Me.texture.internalFormat,bn,hn);i.texImage2D(gt,0,nn,Me.width,Me.height,0,bn,hn,null),e.bindFramebuffer(36160,pe),e.framebufferTexture2D(36160,bt,gt,l.get(Me.texture).__webglTexture,0),e.bindFramebuffer(36160,null)}function Ge(pe,Me,bt){if(e.bindRenderbuffer(36161,pe),Me.depthBuffer&&!Me.stencilBuffer){if(bt){var gt=_e(Me);e.renderbufferStorageMultisample(36161,gt,33189,Me.width,Me.height)}else e.renderbufferStorage(36161,33189,Me.width,Me.height);e.framebufferRenderbuffer(36160,36096,36161,pe)}else if(Me.depthBuffer&&Me.stencilBuffer){if(bt){var gt=_e(Me);e.renderbufferStorageMultisample(36161,gt,35056,Me.width,Me.height)}else e.renderbufferStorage(36161,34041,Me.width,Me.height);e.framebufferRenderbuffer(36160,33306,36161,pe)}else{var bn=h.convert(Me.texture.format),hn=h.convert(Me.texture.type),nn=H(Me.texture.internalFormat,bn,hn);if(bt){var gt=_e(Me);e.renderbufferStorageMultisample(36161,gt,nn,Me.width,Me.height)}else e.renderbufferStorage(36161,nn,Me.width,Me.height)}e.bindRenderbuffer(36161,null)}function ke(pe,Me){var bt=Me&&Me.isWebGLCubeRenderTarget;if(bt)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,pe),!(Me.depthTexture&&Me.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!l.get(Me.depthTexture).__webglTexture||Me.depthTexture.image.width!==Me.width||Me.depthTexture.image.height!==Me.height)&&(Me.depthTexture.image.width=Me.width,Me.depthTexture.image.height=Me.height,Me.depthTexture.needsUpdate=!0),Ve(Me.depthTexture,0);var gt=l.get(Me.depthTexture).__webglTexture;if(Me.depthTexture.format===ac)e.framebufferTexture2D(36160,36096,3553,gt,0);else if(Me.depthTexture.format===gh)e.framebufferTexture2D(36160,33306,3553,gt,0);else throw new Error("Unknown depthTexture format")}function ot(pe){var Me=l.get(pe),bt=pe.isWebGLCubeRenderTarget===!0;if(pe.depthTexture){if(bt)throw new Error("target.depthTexture not supported in Cube render targets");ke(Me.__webglFramebuffer,pe)}else if(bt){Me.__webglDepthbuffer=[];for(var gt=0;gt<6;gt++)e.bindFramebuffer(36160,Me.__webglFramebuffer[gt]),Me.__webglDepthbuffer[gt]=e.createRenderbuffer(),Ge(Me.__webglDepthbuffer[gt],pe)}else e.bindFramebuffer(36160,Me.__webglFramebuffer),Me.__webglDepthbuffer=e.createRenderbuffer(),Ge(Me.__webglDepthbuffer,pe);e.bindFramebuffer(36160,null)}function ge(pe){var Me=l.get(pe),bt=l.get(pe.texture);pe.addEventListener("dispose",ie),bt.__webglTexture=e.createTexture(),f.memory.textures++;var gt=pe.isWebGLCubeRenderTarget===!0,bn=pe.isWebGLMultisampleRenderTarget===!0,hn=pe.isWebGLMultiviewRenderTarget===!0,nn=V(pe)||r;if(gt){Me.__webglFramebuffer=[];for(var pn=0;pn<6;pn++)Me.__webglFramebuffer[pn]=e.createFramebuffer()}else if(Me.__webglFramebuffer=e.createFramebuffer(),bn)if(r){Me.__webglMultisampledFramebuffer=e.createFramebuffer(),Me.__webglColorRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,Me.__webglColorRenderbuffer);var wn=h.convert(pe.texture.format),cn=h.convert(pe.texture.type),Wt=H(pe.texture.internalFormat,wn,cn),sn=_e(pe);e.renderbufferStorageMultisample(36161,sn,Wt,pe.width,pe.height),e.bindFramebuffer(36160,Me.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064,36161,Me.__webglColorRenderbuffer),e.bindRenderbuffer(36161,null),pe.depthBuffer&&(Me.__webglDepthRenderbuffer=e.createRenderbuffer(),Ge(Me.__webglDepthRenderbuffer,pe,!0)),e.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");else if(hn){var Xt=pe.width,Xe=pe.height,Ut=pe.numViews;e.bindFramebuffer(36160,Me.__webglFramebuffer);var en=t.get("OVR_multiview2");f.memory.textures+=2;var Pn=e.createTexture();e.bindTexture(35866,Pn),e.texParameteri(35866,10240,9728),e.texParameteri(35866,10241,9728),e.texImage3D(35866,0,32856,Xt,Xe,Ut,0,6408,5121,null),en.framebufferTextureMultiviewOVR(36160,36064,Pn,0,0,Ut);var fn=e.createTexture();e.bindTexture(35866,fn),e.texParameteri(35866,10240,9728),e.texParameteri(35866,10241,9728),e.texImage3D(35866,0,35056,Xt,Xe,Ut,0,34041,34042,null),en.framebufferTextureMultiviewOVR(36160,33306,fn,0,0,Ut);for(var On=new Array(Ut),pn=0;pn<Ut;++pn)On[pn]=e.createFramebuffer(),e.bindFramebuffer(36160,On[pn]),e.framebufferTextureLayer(36160,36064,Pn,0,pn);Me.__webglColorTexture=Pn,Me.__webglDepthStencilTexture=fn,Me.__webglViewFramebuffers=On,e.bindFramebuffer(36160,null),e.bindTexture(35866,null)}if(gt){i.bindTexture(34067,bt.__webglTexture),Nt(34067,pe.texture,nn);for(var pn=0;pn<6;pn++)We(Me.__webglFramebuffer[pn],pe,36064,34069+pn);J(pe.texture,nn)&&ne(34067,pe.texture,pe.width,pe.height),i.bindTexture(34067,null)}else hn||(i.bindTexture(3553,bt.__webglTexture),Nt(3553,pe.texture,nn),We(Me.__webglFramebuffer,pe,36064,3553),J(pe.texture,nn)&&ne(3553,pe.texture,pe.width,pe.height),i.bindTexture(3553,null));pe.depthBuffer&&ot(pe)}function Ce(pe){var Me=pe.texture,bt=V(pe)||r;if(J(Me,bt)){var gt=pe.isWebGLCubeRenderTarget?34067:3553,bn=l.get(Me).__webglTexture;i.bindTexture(gt,bn),ne(gt,Me,pe.width,pe.height),i.bindTexture(gt,null)}}function Ae(pe){if(pe.isWebGLMultisampleRenderTarget)if(r){var Me=l.get(pe);e.bindFramebuffer(36008,Me.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,Me.__webglFramebuffer);var bt=pe.width,gt=pe.height,bn=16384;pe.depthBuffer&&(bn|=256),pe.stencilBuffer&&(bn|=1024),e.blitFramebuffer(0,0,bt,gt,0,0,bt,gt,bn,9728)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")}function _e(pe){return r&&pe.isWebGLMultisampleRenderTarget?Math.min(b,pe.samples):0}function Ne(pe){var Me=f.render.frame;A.get(pe)!==Me&&(A.set(pe,Me),pe.update())}var Je=!1,ct=!1;function wt(pe,Me){pe&&pe.isWebGLRenderTarget&&(Je===!1&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),Je=!0),pe=pe.texture),Ve(pe,Me)}function Gt(pe,Me){pe&&pe.isWebGLCubeRenderTarget&&(ct===!1&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),ct=!0),pe=pe.texture),pe&&pe.isCubeTexture||Array.isArray(pe.image)&&pe.image.length===6?At(pe,Me):yt(pe,Me)}this.allocateTextureUnit=Oe,this.resetTextureUnits=he,this.setTexture2D=Ve,this.setTexture2DArray=He,this.setTexture3D=at,this.setTextureCube=At,this.setTextureCubeDynamic=yt,this.setupRenderTarget=ge,this.updateRenderTargetMipmap=Ce,this.updateMultisampleRenderTarget=Ae,this.safeSetTexture2D=wt,this.safeSetTextureCube=Gt}function VP(e,t,i){var l=i.isWebGL2;function c(h){var f;if(h===Jp)return 5121;if(h===KT)return 32819;if(h===JT)return 32820;if(h===QT)return 33635;if(h===XT)return 5120;if(h===ZT)return 5122;if(h===Qp)return 5123;if(h===YT)return 5124;if(h===Sx)return 5125;if(h===mh)return 5126;if(h===hy)return l?5131:(f=t.get("OES_texture_half_float"),f!==null?f.HALF_FLOAT_OES:null);if(h===eE)return 6406;if(h===Ma)return 6407;if(h===Ao)return 6408;if(h===tE)return 6409;if(h===nE)return 6410;if(h===ac)return 6402;if(h===gh)return 34041;if(h===rE)return 6403;if(h===oE)return 36244;if(h===aE)return 33319;if(h===sE)return 33320;if(h===lE)return 36248;if(h===cE)return 36249;if(h===Lx||h===Ix||h===Rx||h===kx)if(f=t.get("WEBGL_compressed_texture_s3tc"),f!==null){if(h===Lx)return f.COMPRESSED_RGB_S3TC_DXT1_EXT;if(h===Ix)return f.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(h===Rx)return f.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(h===kx)return f.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(h===zx||h===Fx||h===Bx||h===Ox)if(f=t.get("WEBGL_compressed_texture_pvrtc"),f!==null){if(h===zx)return f.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(h===Fx)return f.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(h===Bx)return f.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(h===Ox)return f.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(h===uE)return f=t.get("WEBGL_compressed_texture_etc1"),f!==null?f.COMPRESSED_RGB_ETC1_WEBGL:null;if(h===hE||h===dE||h===pE||h===fE||h===mE||h===gE||h===yE||h===_E||h===vE||h===xE||h===bE||h===wE||h===ME||h===TE)return f=t.get("WEBGL_compressed_texture_astc"),f!==null?h:null;if(h===ef)return l?34042:(f=t.get("WEBGL_depth_texture"),f!==null?f.UNSIGNED_INT_24_8_WEBGL:null)}return{convert:c}}function Gy(e,t,i,l){Tr.call(this,e,t,l),this.depthBuffer=!1,this.stencilBuffer=!1,this.numViews=i}Gy.prototype=Object.assign(Object.create(Tr.prototype),{constructor:Gy,isWebGLMultiviewRenderTarget:!0,copy:function(e){return Tr.prototype.copy.call(this,e),this.numViews=e.numViews,this},setNumViews:function(e){return this.numViews!==e&&(this.numViews=e,this.dispose()),this}});function GP(e,t){var i=2,l=e.extensions,c=e.properties,h,f,r,v,x,w,b,A=0;function L(){if(b===void 0){var ae=l.get("OVR_multiview2");if(b=ae!==null&&t.getContextAttributes().antialias===!1,b){A=t.getParameter(ae.MAX_VIEWS_OVR),h=new Gy(0,0,i),w=new Lt,v=[],r=[],x=[];for(var ie=0;ie<A;ie++)v[ie]=new Hn,r[ie]=new pr}}return b}function P(ae){return ae.isArrayCamera?ae.cameras:(x[0]=ae,x)}function R(ae,ie){for(var le=P(ae),fe=0;fe<le.length;fe++)v[fe].copy(le[fe].projectionMatrix);ie.setValue(t,"projectionMatrices",v)}function F(ae,ie){for(var le=P(ae),fe=0;fe<le.length;fe++)v[fe].copy(le[fe].matrixWorldInverse);ie.setValue(t,"viewMatrices",v)}function V(ae,ie,le){for(var fe=P(ie),me=0;me<fe.length;me++)v[me].multiplyMatrices(fe[me].matrixWorldInverse,ae.matrixWorld),r[me].getNormalMatrix(v[me]);le.setValue(t,"modelViewMatrices",v),le.setValue(t,"normalMatrices",r)}function j(ae){if(ae.isArrayCamera===void 0)return!0;var ie=ae.cameras;if(ie.length>A)return!1;for(var le=1,fe=ie.length;le<fe;le++)if(ie[0].viewport.z!==ie[le].viewport.z||ie[0].viewport.w!==ie[le].viewport.w)return!1;return!0}function J(ae){if(f?w.set(f.width,f.height):e.getDrawingBufferSize(w),ae.isArrayCamera){var ie=ae.cameras[0].viewport;h.setSize(ie.z,ie.w),h.setNumViews(ae.cameras.length)}else h.setSize(w.x,w.y),h.setNumViews(i)}function ne(ae){j(ae)!==!1&&(f=e.getRenderTarget(),J(ae),e.setRenderTarget(h))}function H(ae){h===e.getRenderTarget()&&(e.setRenderTarget(f),Q(ae))}function Q(ae){var ie=h,le=ie.numViews,fe=c.get(ie).__webglViewFramebuffers,me=ie.width,he=ie.height;if(ae.isArrayCamera)for(var Oe=0;Oe<le;Oe++){var Ve=ae.cameras[Oe].viewport,He=Ve.x,at=Ve.y,At=He+Ve.z,yt=at+Ve.w;t.bindFramebuffer(36008,fe[Oe]),t.blitFramebuffer(0,0,me,he,He,at,At,yt,16384,9728)}else t.bindFramebuffer(36008,fe[0]),t.blitFramebuffer(0,0,me,he,0,0,w.x,w.y,16384,9728)}this.isAvailable=L,this.attachCamera=ne,this.detachCamera=H,this.updateCameraProjectionMatricesUniform=R,this.updateCameraViewMatricesUniform=F,this.updateObjectMatricesUniforms=V}function Wy(e){Xi.call(this),this.cameras=e||[]}Wy.prototype=Object.assign(Object.create(Xi.prototype),{constructor:Wy,isArrayCamera:!0});function al(){on.call(this),this.type="Group"}al.prototype=Object.assign(Object.create(on.prototype),{constructor:al,isGroup:!0});function A0(e,t){var i=this,l=null,c=null,h="local-floor",f=null,r=[],v=new Map,x=new Xi;x.layers.enable(1),x.viewport=new gi;var w=new Xi;w.layers.enable(2),w.viewport=new gi;var b=new Wy([x,w]);b.layers.enable(1),b.layers.enable(2);var A=null,L=null;this.enabled=!1,this.isPresenting=!1,this.getController=function(le){var fe=r[le];return fe===void 0&&(fe={},r[le]=fe),fe.targetRay===void 0&&(fe.targetRay=new al,fe.targetRay.matrixAutoUpdate=!1,fe.targetRay.visible=!1),fe.targetRay},this.getControllerGrip=function(le){var fe=r[le];return fe===void 0&&(fe={},r[le]=fe),fe.grip===void 0&&(fe.grip=new al,fe.grip.matrixAutoUpdate=!1,fe.grip.visible=!1),fe.grip};function P(le){var fe=v.get(le.inputSource);fe&&(fe.targetRay&&fe.targetRay.dispatchEvent({type:le.type}),fe.grip&&fe.grip.dispatchEvent({type:le.type}))}function R(){v.forEach(function(le,fe){le.targetRay&&(le.targetRay.dispatchEvent({type:"disconnected",data:fe}),le.targetRay.visible=!1),le.grip&&(le.grip.dispatchEvent({type:"disconnected",data:fe}),le.grip.visible=!1)}),v.clear(),e.setFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),ie.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function F(le){c=le,ie.setContext(l),ie.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}this.setFramebufferScaleFactor=function(){},this.setReferenceSpaceType=function(le){h=le},this.getReferenceSpace=function(){return c},this.getSession=function(){return l},this.setSession=function(le){if(l=le,l!==null){l.addEventListener("select",P),l.addEventListener("selectstart",P),l.addEventListener("selectend",P),l.addEventListener("squeeze",P),l.addEventListener("squeezestart",P),l.addEventListener("squeezeend",P),l.addEventListener("end",R);var fe=t.getContextAttributes(),me={antialias:fe.antialias,alpha:fe.alpha,depth:fe.depth,stencil:fe.stencil},he=new XRWebGLLayer(l,t,me);l.updateRenderState({baseLayer:he}),l.requestReferenceSpace(h).then(F),l.addEventListener("inputsourceschange",V)}};function V(le){for(var fe=l.inputSources,me=0;me<r.length;me++)v.set(fe[me],r[me]);for(var me=0;me<le.removed.length;me++){var he=le.removed[me],Oe=v.get(he);Oe&&(Oe.targetRay&&Oe.targetRay.dispatchEvent({type:"disconnected",data:he}),Oe.grip&&Oe.grip.dispatchEvent({type:"disconnected",data:he}),v.delete(he))}for(var me=0;me<le.added.length;me++){var he=le.added[me],Oe=v.get(he);Oe&&(Oe.targetRay&&Oe.targetRay.dispatchEvent({type:"connected",data:he}),Oe.grip&&Oe.grip.dispatchEvent({type:"connected",data:he}))}}var j=new Pe,J=new Pe;function ne(le,fe,me){j.setFromMatrixPosition(fe.matrixWorld),J.setFromMatrixPosition(me.matrixWorld);var he=j.distanceTo(J),Oe=fe.projectionMatrix.elements,Ve=me.projectionMatrix.elements,He=Oe[14]/(Oe[10]-1),at=Oe[14]/(Oe[10]+1),At=(Oe[9]+1)/Oe[5],yt=(Oe[9]-1)/Oe[5],Dt=(Oe[8]-1)/Oe[0],It=(Ve[8]+1)/Ve[0],Nt=He*Dt,Ie=He*It,be=he/(-Dt+It),We=be*-Dt;fe.matrixWorld.decompose(le.position,le.quaternion,le.scale),le.translateX(We),le.translateZ(be),le.matrixWorld.compose(le.position,le.quaternion,le.scale),le.matrixWorldInverse.getInverse(le.matrixWorld);var Ge=He+be,ke=at+be,ot=Nt-We,ge=Ie+(he-We),Ce=At*at/ke*Ge,Ae=yt*at/ke*Ge;le.projectionMatrix.makePerspective(ot,ge,Ce,Ae,Ge,ke)}function H(le,fe){fe===null?le.matrixWorld.copy(le.matrix):le.matrixWorld.multiplyMatrices(fe.matrixWorld,le.matrix),le.matrixWorldInverse.getInverse(le.matrixWorld)}this.getCamera=function(le){b.near=w.near=x.near=le.near,b.far=w.far=x.far=le.far,(A!==b.near||L!==b.far)&&(l.updateRenderState({depthNear:b.near,depthFar:b.far}),A=b.near,L=b.far);var fe=le.parent,me=b.cameras;H(b,fe);for(var he=0;he<me.length;he++)H(me[he],fe);le.matrixWorld.copy(b.matrixWorld);for(var Oe=le.children,he=0,Ve=Oe.length;he<Ve;he++)Oe[he].updateMatrixWorld(!0);return ne(b,x,w),b};var Q=null;function ae(le,fe){if(f=fe.getViewerPose(c),f!==null){var me=f.views,he=l.renderState.baseLayer;e.setFramebuffer(he.framebuffer);for(var Oe=0;Oe<me.length;Oe++){var Ve=me[Oe],He=he.getViewport(Ve),at=b.cameras[Oe];at.matrix.fromArray(Ve.transform.matrix),at.projectionMatrix.fromArray(Ve.projectionMatrix),at.viewport.set(He.x,He.y,He.width,He.height),Oe===0&&b.matrix.copy(at.matrix)}}for(var At=l.inputSources,Oe=0;Oe<r.length;Oe++){var yt=r[Oe],Dt=At[Oe],It=null,Nt=null;Dt&&(yt.targetRay&&(It=fe.getPose(Dt.targetRaySpace,c),It!==null&&(yt.targetRay.matrix.fromArray(It.transform.matrix),yt.targetRay.matrix.decompose(yt.targetRay.position,yt.targetRay.rotation,yt.targetRay.scale))),yt.grip&&Dt.gripSpace&&(Nt=fe.getPose(Dt.gripSpace,c),Nt!==null&&(yt.grip.matrix.fromArray(Nt.transform.matrix),yt.grip.matrix.decompose(yt.grip.position,yt.grip.rotation,yt.grip.scale)))),yt.targetRay&&(yt.targetRay.visible=It!==null),yt.grip&&(yt.grip.visible=Nt!==null)}Q&&Q(le,fe)}var ie=new o0;ie.setAnimationLoop(ae),this.setAnimationLoop=function(le){Q=le},this.dispose=function(){}}Object.assign(A0.prototype,Ta.prototype);function D0(e){e=e||{};var t=e.canvas!==void 0?e.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),i=e.context!==void 0?e.context:null,l=e.alpha!==void 0?e.alpha:!1,c=e.depth!==void 0?e.depth:!0,h=e.stencil!==void 0?e.stencil:!0,f=e.antialias!==void 0?e.antialias:!1,r=e.premultipliedAlpha!==void 0?e.premultipliedAlpha:!0,v=e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1,x=e.powerPreference!==void 0?e.powerPreference:"default",w=e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1,b=null,A=null;this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=io,this.physicallyCorrectLights=!1,this.toneMapping=ry,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var L=this,P=!1,R=null,F=0,V=0,j=null,J=null,ne=-1,H={geometry:null,program:null,wireframe:!1},Q=null,ae=null,ie=new gi,le=new gi,fe=null,me=t.width,he=t.height,Oe=1,Ve=null,He=null,at=new gi(0,0,me,he),At=new gi(0,0,me,he),yt=!1,Dt=new Ph,It=new wD,Nt=!1,Ie=!1,be=new Hn,We=new Pe;function Ge(){return j===null?Oe:1}var ke;try{var ot={alpha:l,depth:c,stencil:h,antialias:f,premultipliedAlpha:r,preserveDrawingBuffer:v,powerPreference:x,failIfMajorPerformanceCaveat:w,xrCompatible:!0};if(t.addEventListener("webglcontextlost",Xt,!1),t.addEventListener("webglcontextrestored",Xe,!1),ke=i||t.getContext("webgl",ot)||t.getContext("experimental-webgl",ot),ke===null)throw t.getContext("webgl")!==null?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.");ke.getShaderPrecisionFormat===void 0&&(ke.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Y){throw console.error("THREE.WebGLRenderer: "+Y.message),Y}var ge,Ce,Ae,_e,Ne,Je,ct,wt,Gt,pe,Me,bt,gt,bn,hn,nn,pn;function wn(){ge=new MD(ke),Ce=new bD(ke,ge,e),Ce.isWebGL2===!1&&(ge.get("WEBGL_depth_texture"),ge.get("OES_texture_float"),ge.get("OES_texture_half_float"),ge.get("OES_texture_half_float_linear"),ge.get("OES_standard_derivatives"),ge.get("OES_element_index_uint"),ge.get("ANGLE_instanced_arrays")),ge.get("OES_texture_float_linear"),pn=new VP(ke,ge,Ce),Ae=new NP(ke,ge,Ce),Ae.scissor(le.copy(At).multiplyScalar(Oe).floor()),Ae.viewport(ie.copy(at).multiplyScalar(Oe).floor()),_e=new CD,Ne=new DP,Je=new UP(ke,ge,Ae,Ne,Ce,pn,_e),ct=new QE(ke,Ce),wt=new TD(ke,ct,_e),Gt=new PD(ke,wt,ct,_e),bn=new DD(ke),pe=new AP(L,ge,Ce),Me=new LP,bt=new FP,gt=new vD(L,Ae,Gt,r),hn=new xD(ke,ge,_e,Ce),nn=new ED(ke,ge,_e,Ce),_e.programs=pe.programs,L.capabilities=Ce,L.extensions=ge,L.properties=Ne,L.renderLists=Me,L.state=Ae,L.info=_e}wn();var cn=new A0(L,ke);this.xr=cn;var Wt=new GP(L,ke),sn=new C0(L,Gt,Ce.maxTextureSize);this.shadowMap=sn,this.getContext=function(){return ke},this.getContextAttributes=function(){return ke.getContextAttributes()},this.forceContextLoss=function(){var Y=ge.get("WEBGL_lose_context");Y&&Y.loseContext()},this.forceContextRestore=function(){var Y=ge.get("WEBGL_lose_context");Y&&Y.restoreContext()},this.getPixelRatio=function(){return Oe},this.setPixelRatio=function(Y){Y!==void 0&&(Oe=Y,this.setSize(me,he,!1))},this.getSize=function(Y){return Y===void 0&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),Y=new Lt),Y.set(me,he)},this.setSize=function(Y,re,Fe){if(cn.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}me=Y,he=re,t.width=Math.floor(Y*Oe),t.height=Math.floor(re*Oe),Fe!==!1&&(t.style.width=Y+"px",t.style.height=re+"px"),this.setViewport(0,0,Y,re)},this.getDrawingBufferSize=function(Y){return Y===void 0&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),Y=new Lt),Y.set(me*Oe,he*Oe).floor()},this.setDrawingBufferSize=function(Y,re,Fe){me=Y,he=re,Oe=Fe,t.width=Math.floor(Y*Fe),t.height=Math.floor(re*Fe),this.setViewport(0,0,Y,re)},this.getCurrentViewport=function(Y){return Y===void 0&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),Y=new gi),Y.copy(ie)},this.getViewport=function(Y){return Y.copy(at)},this.setViewport=function(Y,re,Fe,Te){Y.isVector4?at.set(Y.x,Y.y,Y.z,Y.w):at.set(Y,re,Fe,Te),Ae.viewport(ie.copy(at).multiplyScalar(Oe).floor())},this.getScissor=function(Y){return Y.copy(At)},this.setScissor=function(Y,re,Fe,Te){Y.isVector4?At.set(Y.x,Y.y,Y.z,Y.w):At.set(Y,re,Fe,Te),Ae.scissor(le.copy(At).multiplyScalar(Oe).floor())},this.getScissorTest=function(){return yt},this.setScissorTest=function(Y){Ae.setScissorTest(yt=Y)},this.setOpaqueSort=function(Y){Ve=Y},this.setTransparentSort=function(Y){He=Y},this.getClearColor=function(){return gt.getClearColor()},this.setClearColor=function(){gt.setClearColor.apply(gt,arguments)},this.getClearAlpha=function(){return gt.getClearAlpha()},this.setClearAlpha=function(){gt.setClearAlpha.apply(gt,arguments)},this.clear=function(Y,re,Fe){var Te=0;(Y===void 0||Y)&&(Te|=16384),(re===void 0||re)&&(Te|=256),(Fe===void 0||Fe)&&(Te|=1024),ke.clear(Te)},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(){t.removeEventListener("webglcontextlost",Xt,!1),t.removeEventListener("webglcontextrestored",Xe,!1),Me.dispose(),bt.dispose(),Ne.dispose(),Gt.dispose(),cn.dispose(),Nn.stop()};function Xt(Y){Y.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),P=!0}function Xe(){console.log("THREE.WebGLRenderer: Context Restored."),P=!1,wn()}function Ut(Y){var re=Y.target;re.removeEventListener("dispose",Ut),en(re)}function en(Y){Pn(Y),Ne.remove(Y)}function Pn(Y){var re=Ne.get(Y).program;Y.program=void 0,re!==void 0&&pe.releaseProgram(re)}function fn(Y,re){Y.render(function(Fe){L.renderBufferImmediate(Fe,re)})}this.renderBufferImmediate=function(Y,re){Ae.initAttributes();var Fe=Ne.get(Y);Y.hasPositions&&!Fe.position&&(Fe.position=ke.createBuffer()),Y.hasNormals&&!Fe.normal&&(Fe.normal=ke.createBuffer()),Y.hasUvs&&!Fe.uv&&(Fe.uv=ke.createBuffer()),Y.hasColors&&!Fe.color&&(Fe.color=ke.createBuffer());var Te=re.getAttributes();Y.hasPositions&&(ke.bindBuffer(34962,Fe.position),ke.bufferData(34962,Y.positionArray,35048),Ae.enableAttribute(Te.position),ke.vertexAttribPointer(Te.position,3,5126,!1,0,0)),Y.hasNormals&&(ke.bindBuffer(34962,Fe.normal),ke.bufferData(34962,Y.normalArray,35048),Ae.enableAttribute(Te.normal),ke.vertexAttribPointer(Te.normal,3,5126,!1,0,0)),Y.hasUvs&&(ke.bindBuffer(34962,Fe.uv),ke.bufferData(34962,Y.uvArray,35048),Ae.enableAttribute(Te.uv),ke.vertexAttribPointer(Te.uv,2,5126,!1,0,0)),Y.hasColors&&(ke.bindBuffer(34962,Fe.color),ke.bufferData(34962,Y.colorArray,35048),Ae.enableAttribute(Te.color),ke.vertexAttribPointer(Te.color,3,5126,!1,0,0)),Ae.disableUnusedAttributes(),ke.drawArrays(4,0,Y.count),Y.count=0};var On=new Ca;this.renderBufferDirect=function(Y,re,Fe,Te,Tt,_t){re===null&&(re=On);var Ot=Tt.isMesh&&Tt.matrixWorld.determinant()<0,rn=jr(Y,re,Te,Tt);Ae.setMaterial(Te,Ot);var Sn=!1;(H.geometry!==Fe.id||H.program!==rn.id||H.wireframe!==(Te.wireframe===!0))&&(H.geometry=Fe.id,H.program=rn.id,H.wireframe=Te.wireframe===!0,Sn=!0),(Te.morphTargets||Te.morphNormals)&&(bn.update(Tt,Fe,Te,rn),Sn=!0);var Ln=Fe.index,Mt=Fe.attributes.position;if(Ln===null){if(Mt===void 0||Mt.count===0)return}else if(Ln.count===0)return;var un=1;Te.wireframe===!0&&(Ln=wt.getWireframeAttribute(Fe),un=2);var Kt,mn=hn;Ln!==null&&(Kt=ct.get(Ln),mn=nn,mn.setIndex(Kt)),Sn&&(Gn(Tt,Fe,Te,rn),Ln!==null&&ke.bindBuffer(34963,Kt.buffer));var Tn=Ln!==null?Ln.count:Mt.count,Cn=Fe.drawRange.start*un,di=Fe.drawRange.count*un,Dr=_t!==null?_t.start*un:0,oi=_t!==null?_t.count*un:1/0,li=Math.max(Cn,Dr),ai=Math.min(Tn,Cn+di,Dr+oi)-1,xs=Math.max(0,ai-li+1);if(xs!==0){if(Tt.isMesh)Te.wireframe===!0?(Ae.setLineWidth(Te.wireframeLinewidth*Ge()),mn.setMode(1)):mn.setMode(4);else if(Tt.isLine){var ko=Te.linewidth;ko===void 0&&(ko=1),Ae.setLineWidth(ko*Ge()),Tt.isLineSegments?mn.setMode(1):Tt.isLineLoop?mn.setMode(2):mn.setMode(3)}else Tt.isPoints?mn.setMode(0):Tt.isSprite&&mn.setMode(4);Tt.isInstancedMesh?mn.renderInstances(Fe,li,xs,Tt.count):Fe.isInstancedBufferGeometry?mn.renderInstances(Fe,li,xs,Fe.maxInstancedCount):mn.render(li,xs)}};function Gn(Y,re,Fe,Te){if(!(Ce.isWebGL2===!1&&(Y.isInstancedMesh||re.isInstancedBufferGeometry)&&ge.get("ANGLE_instanced_arrays")===null)){Ae.initAttributes();var Tt=re.attributes,_t=Te.getAttributes(),Ot=Fe.defaultAttributeValues;for(var rn in _t){var Sn=_t[rn];if(Sn>=0){var Ln=Tt[rn];if(Ln!==void 0){var Mt=Ln.normalized,un=Ln.itemSize,Kt=ct.get(Ln);if(Kt===void 0)continue;var mn=Kt.buffer,Tn=Kt.type,Cn=Kt.bytesPerElement;if(Ln.isInterleavedBufferAttribute){var di=Ln.data,Dr=di.stride,oi=Ln.offset;di&&di.isInstancedInterleavedBuffer?(Ae.enableAttributeAndDivisor(Sn,di.meshPerAttribute),re.maxInstancedCount===void 0&&(re.maxInstancedCount=di.meshPerAttribute*di.count)):Ae.enableAttribute(Sn),ke.bindBuffer(34962,mn),ke.vertexAttribPointer(Sn,un,Tn,Mt,Dr*Cn,oi*Cn)}else Ln.isInstancedBufferAttribute?(Ae.enableAttributeAndDivisor(Sn,Ln.meshPerAttribute),re.maxInstancedCount===void 0&&(re.maxInstancedCount=Ln.meshPerAttribute*Ln.count)):Ae.enableAttribute(Sn),ke.bindBuffer(34962,mn),ke.vertexAttribPointer(Sn,un,Tn,Mt,0,0)}else if(rn==="instanceMatrix"){var Kt=ct.get(Y.instanceMatrix);if(Kt===void 0)continue;var mn=Kt.buffer,Tn=Kt.type;Ae.enableAttributeAndDivisor(Sn+0,1),Ae.enableAttributeAndDivisor(Sn+1,1),Ae.enableAttributeAndDivisor(Sn+2,1),Ae.enableAttributeAndDivisor(Sn+3,1),ke.bindBuffer(34962,mn),ke.vertexAttribPointer(Sn+0,4,Tn,!1,64,0),ke.vertexAttribPointer(Sn+1,4,Tn,!1,64,16),ke.vertexAttribPointer(Sn+2,4,Tn,!1,64,32),ke.vertexAttribPointer(Sn+3,4,Tn,!1,64,48)}else if(Ot!==void 0){var li=Ot[rn];if(li!==void 0)switch(li.length){case 2:ke.vertexAttrib2fv(Sn,li);break;case 3:ke.vertexAttrib3fv(Sn,li);break;case 4:ke.vertexAttrib4fv(Sn,li);break;default:ke.vertexAttrib1fv(Sn,li)}}}}Ae.disableUnusedAttributes()}}this.compile=function(Y,re){A=bt.get(Y,re),A.init(),Y.traverse(function(Te){Te.isLight&&(A.pushLight(Te),Te.castShadow&&A.pushShadow(Te))}),A.setupLights(re);var Fe={};Y.traverse(function(Te){if(Te.material)if(Array.isArray(Te.material))for(var Tt=0;Tt<Te.material.length;Tt++)Te.material[Tt].uuid in Fe||(_i(Te.material[Tt],Y,Te),Fe[Te.material[Tt].uuid]=!0);else Te.material.uuid in Fe||(_i(Te.material,Y,Te),Fe[Te.material.uuid]=!0)})};var qn=null;function ji(Y){cn.isPresenting||qn&&qn(Y)}var Nn=new o0;Nn.setAnimationLoop(ji),typeof window!="undefined"&&Nn.setContext(window),this.setAnimationLoop=function(Y){qn=Y,cn.setAnimationLoop(Y),Nn.start()},this.render=function(Y,re){var Fe,Te;if(arguments[2]!==void 0&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),Fe=arguments[2]),arguments[3]!==void 0&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),Te=arguments[3]),!(re&&re.isCamera)){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(!P){H.geometry=null,H.program=null,H.wireframe=!1,ne=-1,Q=null,Y.autoUpdate===!0&&Y.updateMatrixWorld(),re.parent===null&&re.updateMatrixWorld(),cn.enabled&&cn.isPresenting&&(re=cn.getCamera(re)),A=bt.get(Y,re),A.init(),Y.onBeforeRender(L,Y,re,Fe||j),be.multiplyMatrices(re.projectionMatrix,re.matrixWorldInverse),Dt.setFromProjectionMatrix(be),Ie=this.localClippingEnabled,Nt=It.init(this.clippingPlanes,Ie,re),b=Me.get(Y,re),b.init(),Di(Y,re,0,L.sortObjects),L.sortObjects===!0&&b.sort(Ve,He),Nt&&It.beginShadows();var Tt=A.state.shadowsArray;sn.render(Tt,Y,re),A.setupLights(re),Nt&&It.endShadows(),this.info.autoReset&&this.info.reset(),Fe!==void 0&&this.setRenderTarget(Fe),cn.enabled&&Wt.isAvailable()&&Wt.attachCamera(re),gt.render(b,Y,re,Te);var _t=b.opaque,Ot=b.transparent;if(Y.overrideMaterial){var rn=Y.overrideMaterial;_t.length&&ei(_t,Y,re,rn),Ot.length&&ei(Ot,Y,re,rn)}else _t.length&&ei(_t,Y,re),Ot.length&&ei(Ot,Y,re);Y.onAfterRender(L,Y,re),j!==null&&(Je.updateRenderTargetMipmap(j),Je.updateMultisampleRenderTarget(j)),Ae.buffers.depth.setTest(!0),Ae.buffers.depth.setMask(!0),Ae.buffers.color.setMask(!0),Ae.setPolygonOffset(!1),cn.enabled&&Wt.isAvailable()&&Wt.detachCamera(re),b=null,A=null}};function Di(Y,re,Fe,Te){if(Y.visible!==!1){var Tt=Y.layers.test(re.layers);if(Tt){if(Y.isGroup)Fe=Y.renderOrder;else if(Y.isLOD)Y.autoUpdate===!0&&Y.update(re);else if(Y.isLight)A.pushLight(Y),Y.castShadow&&A.pushShadow(Y);else if(Y.isSprite){if(!Y.frustumCulled||Dt.intersectsSprite(Y)){Te&&We.setFromMatrixPosition(Y.matrixWorld).applyMatrix4(be);var _t=Gt.update(Y),Ot=Y.material;Ot.visible&&b.push(Y,_t,Ot,Fe,We.z,null)}}else if(Y.isImmediateRenderObject)Te&&We.setFromMatrixPosition(Y.matrixWorld).applyMatrix4(be),b.push(Y,null,Y.material,Fe,We.z,null);else if((Y.isMesh||Y.isLine||Y.isPoints)&&(Y.isSkinnedMesh&&Y.skeleton.frame!==_e.render.frame&&(Y.skeleton.update(),Y.skeleton.frame=_e.render.frame),!Y.frustumCulled||Dt.intersectsObject(Y))){Te&&We.setFromMatrixPosition(Y.matrixWorld).applyMatrix4(be);var _t=Gt.update(Y),Ot=Y.material;if(Array.isArray(Ot))for(var rn=_t.groups,Sn=0,Ln=rn.length;Sn<Ln;Sn++){var Mt=rn[Sn],un=Ot[Mt.materialIndex];un&&un.visible&&b.push(Y,_t,un,Fe,We.z,Mt)}else Ot.visible&&b.push(Y,_t,Ot,Fe,We.z,null)}}for(var Kt=Y.children,Sn=0,Ln=Kt.length;Sn<Ln;Sn++)Di(Kt[Sn],re,Fe,Te)}}function ei(Y,re,Fe,Te){for(var Tt=0,_t=Y.length;Tt<_t;Tt++){var Ot=Y[Tt],rn=Ot.object,Sn=Ot.geometry,Ln=Te===void 0?Ot.material:Te,Mt=Ot.group;if(Fe.isArrayCamera)if(ae=Fe,cn.enabled&&Wt.isAvailable())Ji(rn,re,Fe,Sn,Ln,Mt);else for(var un=Fe.cameras,Kt=0,mn=un.length;Kt<mn;Kt++){var Tn=un[Kt];rn.layers.test(Tn.layers)&&(Ae.viewport(ie.copy(Tn.viewport)),A.setupLights(Tn),Ji(rn,re,Tn,Sn,Ln,Mt))}else ae=null,Ji(rn,re,Fe,Sn,Ln,Mt)}}function Ji(Y,re,Fe,Te,Tt,_t){if(Y.onBeforeRender(L,re,Fe,Te,Tt,_t),A=bt.get(re,ae||Fe),Y.modelViewMatrix.multiplyMatrices(Fe.matrixWorldInverse,Y.matrixWorld),Y.normalMatrix.getNormalMatrix(Y.modelViewMatrix),Y.isImmediateRenderObject){var Ot=jr(Fe,re,Tt,Y);Ae.setMaterial(Tt),H.geometry=null,H.program=null,H.wireframe=!1,fn(Y,Ot)}else L.renderBufferDirect(Fe,re,Te,Tt,Y,_t);Y.onAfterRender(L,re,Fe,Te,Tt,_t),A=bt.get(re,ae||Fe)}function _i(Y,re,Fe){var Te=Ne.get(Y),Tt=A.state.lights,_t=A.state.shadowsArray,Ot=Tt.state.version,rn=pe.getParameters(Y,Tt.state,_t,re,It.numPlanes,It.numIntersection,Fe),Sn=pe.getProgramCacheKey(rn),Ln=Te.program,Mt=!0;if(Ln===void 0)Y.addEventListener("dispose",Ut);else if(Ln.cacheKey!==Sn)Pn(Y);else if(Te.lightsStateVersion!==Ot)Te.lightsStateVersion=Ot,Mt=!1;else{if(rn.shaderID!==void 0)return;Mt=!1}Mt&&(Ln=pe.acquireProgram(rn,Sn),Te.program=Ln,Te.uniforms=rn.uniforms,Te.environment=Y.isMeshStandardMaterial?re.environment:null,Te.outputEncoding=L.outputEncoding,Y.program=Ln);var un=Ln.getAttributes();if(Y.morphTargets){Y.numSupportedMorphTargets=0;for(var Kt=0;Kt<L.maxMorphTargets;Kt++)un["morphTarget"+Kt]>=0&&Y.numSupportedMorphTargets++}if(Y.morphNormals){Y.numSupportedMorphNormals=0;for(var Kt=0;Kt<L.maxMorphNormals;Kt++)un["morphNormal"+Kt]>=0&&Y.numSupportedMorphNormals++}var mn=Te.uniforms;(!Y.isShaderMaterial&&!Y.isRawShaderMaterial||Y.clipping===!0)&&(Te.numClippingPlanes=It.numPlanes,Te.numIntersection=It.numIntersection,mn.clippingPlanes=It.uniform),Te.fog=re.fog,Te.needsLights=_n(Y),Te.lightsStateVersion=Ot,Te.needsLights&&(mn.ambientLightColor.value=Tt.state.ambient,mn.lightProbe.value=Tt.state.probe,mn.directionalLights.value=Tt.state.directional,mn.spotLights.value=Tt.state.spot,mn.rectAreaLights.value=Tt.state.rectArea,mn.pointLights.value=Tt.state.point,mn.hemisphereLights.value=Tt.state.hemi,mn.directionalShadowMap.value=Tt.state.directionalShadowMap,mn.directionalShadowMatrix.value=Tt.state.directionalShadowMatrix,mn.spotShadowMap.value=Tt.state.spotShadowMap,mn.spotShadowMatrix.value=Tt.state.spotShadowMatrix,mn.pointShadowMap.value=Tt.state.pointShadowMap,mn.pointShadowMatrix.value=Tt.state.pointShadowMatrix);var Tn=Te.program.getUniforms(),Cn=as.seqWithValue(Tn.seq,mn);Te.uniformsList=Cn}function jr(Y,re,Fe,Te){Je.resetTextureUnits();var Tt=re.fog,_t=Fe.isMeshStandardMaterial?re.environment:null,Ot=Ne.get(Fe),rn=A.state.lights;if(Nt&&(Ie||Y!==Q)){var Sn=Y===Q&&Fe.id===ne;It.setState(Fe.clippingPlanes,Fe.clipIntersection,Fe.clipShadows,Y,Ot,Sn)}Fe.version===Ot.__version?(Ot.program===void 0||Fe.fog&&Ot.fog!==Tt||Ot.environment!==_t||Ot.needsLights&&Ot.lightsStateVersion!==rn.state.version||Ot.numClippingPlanes!==void 0&&(Ot.numClippingPlanes!==It.numPlanes||Ot.numIntersection!==It.numIntersection)||Ot.outputEncoding!==L.outputEncoding)&&_i(Fe,re,Te):(_i(Fe,re,Te),Ot.__version=Fe.version);var Ln=!1,Mt=!1,un=!1,Kt=Ot.program,mn=Kt.getUniforms(),Tn=Ot.uniforms;if(Ae.useProgram(Kt.program)&&(Ln=!0,Mt=!0,un=!0),Fe.id!==ne&&(ne=Fe.id,Mt=!0),Ln||Q!==Y){if(Kt.numMultiviewViews>0?Wt.updateCameraProjectionMatricesUniform(Y,mn):mn.setValue(ke,"projectionMatrix",Y.projectionMatrix),Ce.logarithmicDepthBuffer&&mn.setValue(ke,"logDepthBufFC",2/(Math.log(Y.far+1)/Math.LN2)),Q!==Y&&(Q=Y,Mt=!0,un=!0),Fe.isShaderMaterial||Fe.isMeshPhongMaterial||Fe.isMeshToonMaterial||Fe.isMeshStandardMaterial||Fe.envMap){var Cn=mn.map.cameraPosition;Cn!==void 0&&Cn.setValue(ke,We.setFromMatrixPosition(Y.matrixWorld))}(Fe.isMeshPhongMaterial||Fe.isMeshToonMaterial||Fe.isMeshLambertMaterial||Fe.isMeshBasicMaterial||Fe.isMeshStandardMaterial||Fe.isShaderMaterial)&&mn.setValue(ke,"isOrthographic",Y.isOrthographicCamera===!0),(Fe.isMeshPhongMaterial||Fe.isMeshToonMaterial||Fe.isMeshLambertMaterial||Fe.isMeshBasicMaterial||Fe.isMeshStandardMaterial||Fe.isShaderMaterial||Fe.skinning)&&(Kt.numMultiviewViews>0?Wt.updateCameraViewMatricesUniform(Y,mn):mn.setValue(ke,"viewMatrix",Y.matrixWorldInverse))}if(Fe.skinning){mn.setOptional(ke,Te,"bindMatrix"),mn.setOptional(ke,Te,"bindMatrixInverse");var di=Te.skeleton;if(di){var Dr=di.bones;if(Ce.floatVertexTextures){if(di.boneTexture===void 0){var oi=Math.sqrt(Dr.length*4);oi=jn.ceilPowerOfTwo(oi),oi=Math.max(oi,4);var li=new Float32Array(oi*oi*4);li.set(di.boneMatrices);var ai=new Dc(li,oi,oi,Ao,mh);di.boneMatrices=li,di.boneTexture=ai,di.boneTextureSize=oi}mn.setValue(ke,"boneTexture",di.boneTexture,Je),mn.setValue(ke,"boneTextureSize",di.boneTextureSize)}else mn.setOptional(ke,di,"boneMatrices")}}return(Mt||Ot.receiveShadow!==Te.receiveShadow)&&(Ot.receiveShadow=Te.receiveShadow,mn.setValue(ke,"receiveShadow",Te.receiveShadow)),Mt&&(mn.setValue(ke,"toneMappingExposure",L.toneMappingExposure),mn.setValue(ke,"toneMappingWhitePoint",L.toneMappingWhitePoint),Ot.needsLights&&Ct(Tn,un),Tt&&Fe.fog&&ee(Tn,Tt),Fe.isMeshBasicMaterial?zi(Tn,Fe):Fe.isMeshLambertMaterial?(zi(Tn,Fe),ye(Tn,Fe)):Fe.isMeshToonMaterial?(zi(Tn,Fe),je(Tn,Fe)):Fe.isMeshPhongMaterial?(zi(Tn,Fe),Re(Tn,Fe)):Fe.isMeshStandardMaterial?(zi(Tn,Fe,_t),Fe.isMeshPhysicalMaterial?tt(Tn,Fe,_t):et(Tn,Fe,_t)):Fe.isMeshMatcapMaterial?(zi(Tn,Fe),qe(Tn,Fe)):Fe.isMeshDepthMaterial?(zi(Tn,Fe),rt(Tn,Fe)):Fe.isMeshDistanceMaterial?(zi(Tn,Fe),vt(Tn,Fe)):Fe.isMeshNormalMaterial?(zi(Tn,Fe),Vt(Tn,Fe)):Fe.isLineBasicMaterial?(Hr(Tn,Fe),Fe.isLineDashedMaterial&&Ar(Tn,Fe)):Fe.isPointsMaterial?we(Tn,Fe):Fe.isSpriteMaterial?$(Tn,Fe):Fe.isShadowMaterial&&(Tn.color.value.copy(Fe.color),Tn.opacity.value=Fe.opacity),Tn.ltc_1!==void 0&&(Tn.ltc_1.value=an.LTC_1),Tn.ltc_2!==void 0&&(Tn.ltc_2.value=an.LTC_2),as.upload(ke,Ot.uniformsList,Tn,Je),Fe.isShaderMaterial&&(Fe.uniformsNeedUpdate=!1)),Fe.isShaderMaterial&&Fe.uniformsNeedUpdate===!0&&(as.upload(ke,Ot.uniformsList,Tn,Je),Fe.uniformsNeedUpdate=!1),Fe.isSpriteMaterial&&mn.setValue(ke,"center",Te.center),Kt.numMultiviewViews>0?Wt.updateObjectMatricesUniforms(Te,Y,mn):(mn.setValue(ke,"modelViewMatrix",Te.modelViewMatrix),mn.setValue(ke,"normalMatrix",Te.normalMatrix)),mn.setValue(ke,"modelMatrix",Te.matrixWorld),Kt}function zi(Y,re,Fe){Y.opacity.value=re.opacity,re.color&&Y.diffuse.value.copy(re.color),re.emissive&&Y.emissive.value.copy(re.emissive).multiplyScalar(re.emissiveIntensity),re.map&&(Y.map.value=re.map),re.alphaMap&&(Y.alphaMap.value=re.alphaMap),re.specularMap&&(Y.specularMap.value=re.specularMap);var Te=re.envMap||Fe;Te&&(Y.envMap.value=Te,Y.flipEnvMap.value=Te.isCubeTexture?-1:1,Y.reflectivity.value=re.reflectivity,Y.refractionRatio.value=re.refractionRatio,Y.maxMipLevel.value=Ne.get(Te).__maxMipLevel),re.lightMap&&(Y.lightMap.value=re.lightMap,Y.lightMapIntensity.value=re.lightMapIntensity),re.aoMap&&(Y.aoMap.value=re.aoMap,Y.aoMapIntensity.value=re.aoMapIntensity);var Tt;re.map?Tt=re.map:re.specularMap?Tt=re.specularMap:re.displacementMap?Tt=re.displacementMap:re.normalMap?Tt=re.normalMap:re.bumpMap?Tt=re.bumpMap:re.roughnessMap?Tt=re.roughnessMap:re.metalnessMap?Tt=re.metalnessMap:re.alphaMap?Tt=re.alphaMap:re.emissiveMap&&(Tt=re.emissiveMap),Tt!==void 0&&(Tt.isWebGLRenderTarget&&(Tt=Tt.texture),Tt.matrixAutoUpdate===!0&&Tt.updateMatrix(),Y.uvTransform.value.copy(Tt.matrix));var _t;re.aoMap?_t=re.aoMap:re.lightMap&&(_t=re.lightMap),_t!==void 0&&(_t.isWebGLRenderTarget&&(_t=_t.texture),_t.matrixAutoUpdate===!0&&_t.updateMatrix(),Y.uv2Transform.value.copy(_t.matrix))}function Hr(Y,re){Y.diffuse.value.copy(re.color),Y.opacity.value=re.opacity}function Ar(Y,re){Y.dashSize.value=re.dashSize,Y.totalSize.value=re.dashSize+re.gapSize,Y.scale.value=re.scale}function we(Y,re){Y.diffuse.value.copy(re.color),Y.opacity.value=re.opacity,Y.size.value=re.size*Oe,Y.scale.value=he*.5,re.map&&(Y.map.value=re.map),re.alphaMap&&(Y.alphaMap.value=re.alphaMap);var Fe;re.map?Fe=re.map:re.alphaMap&&(Fe=re.alphaMap),Fe!==void 0&&(Fe.matrixAutoUpdate===!0&&Fe.updateMatrix(),Y.uvTransform.value.copy(Fe.matrix))}function $(Y,re){Y.diffuse.value.copy(re.color),Y.opacity.value=re.opacity,Y.rotation.value=re.rotation,re.map&&(Y.map.value=re.map),re.alphaMap&&(Y.alphaMap.value=re.alphaMap);var Fe;re.map?Fe=re.map:re.alphaMap&&(Fe=re.alphaMap),Fe!==void 0&&(Fe.matrixAutoUpdate===!0&&Fe.updateMatrix(),Y.uvTransform.value.copy(Fe.matrix))}function ee(Y,re){Y.fogColor.value.copy(re.color),re.isFog?(Y.fogNear.value=re.near,Y.fogFar.value=re.far):re.isFogExp2&&(Y.fogDensity.value=re.density)}function ye(Y,re){re.emissiveMap&&(Y.emissiveMap.value=re.emissiveMap)}function Re(Y,re){Y.specular.value.copy(re.specular),Y.shininess.value=Math.max(re.shininess,1e-4),re.emissiveMap&&(Y.emissiveMap.value=re.emissiveMap),re.bumpMap&&(Y.bumpMap.value=re.bumpMap,Y.bumpScale.value=re.bumpScale,re.side===tr&&(Y.bumpScale.value*=-1)),re.normalMap&&(Y.normalMap.value=re.normalMap,Y.normalScale.value.copy(re.normalScale),re.side===tr&&Y.normalScale.value.negate()),re.displacementMap&&(Y.displacementMap.value=re.displacementMap,Y.displacementScale.value=re.displacementScale,Y.displacementBias.value=re.displacementBias)}function je(Y,re){Y.specular.value.copy(re.specular),Y.shininess.value=Math.max(re.shininess,1e-4),re.gradientMap&&(Y.gradientMap.value=re.gradientMap),re.emissiveMap&&(Y.emissiveMap.value=re.emissiveMap),re.bumpMap&&(Y.bumpMap.value=re.bumpMap,Y.bumpScale.value=re.bumpScale,re.side===tr&&(Y.bumpScale.value*=-1)),re.normalMap&&(Y.normalMap.value=re.normalMap,Y.normalScale.value.copy(re.normalScale),re.side===tr&&Y.normalScale.value.negate()),re.displacementMap&&(Y.displacementMap.value=re.displacementMap,Y.displacementScale.value=re.displacementScale,Y.displacementBias.value=re.displacementBias)}function et(Y,re,Fe){Y.roughness.value=re.roughness,Y.metalness.value=re.metalness,re.roughnessMap&&(Y.roughnessMap.value=re.roughnessMap),re.metalnessMap&&(Y.metalnessMap.value=re.metalnessMap),re.emissiveMap&&(Y.emissiveMap.value=re.emissiveMap),re.bumpMap&&(Y.bumpMap.value=re.bumpMap,Y.bumpScale.value=re.bumpScale,re.side===tr&&(Y.bumpScale.value*=-1)),re.normalMap&&(Y.normalMap.value=re.normalMap,Y.normalScale.value.copy(re.normalScale),re.side===tr&&Y.normalScale.value.negate()),re.displacementMap&&(Y.displacementMap.value=re.displacementMap,Y.displacementScale.value=re.displacementScale,Y.displacementBias.value=re.displacementBias),(re.envMap||Fe)&&(Y.envMapIntensity.value=re.envMapIntensity)}function tt(Y,re,Fe){et(Y,re,Fe),Y.reflectivity.value=re.reflectivity,Y.clearcoat.value=re.clearcoat,Y.clearcoatRoughness.value=re.clearcoatRoughness,re.sheen&&Y.sheen.value.copy(re.sheen),re.clearcoatNormalMap&&(Y.clearcoatNormalScale.value.copy(re.clearcoatNormalScale),Y.clearcoatNormalMap.value=re.clearcoatNormalMap,re.side===tr&&Y.clearcoatNormalScale.value.negate()),Y.transparency.value=re.transparency}function qe(Y,re){re.matcap&&(Y.matcap.value=re.matcap),re.bumpMap&&(Y.bumpMap.value=re.bumpMap,Y.bumpScale.value=re.bumpScale,re.side===tr&&(Y.bumpScale.value*=-1)),re.normalMap&&(Y.normalMap.value=re.normalMap,Y.normalScale.value.copy(re.normalScale),re.side===tr&&Y.normalScale.value.negate()),re.displacementMap&&(Y.displacementMap.value=re.displacementMap,Y.displacementScale.value=re.displacementScale,Y.displacementBias.value=re.displacementBias)}function rt(Y,re){re.displacementMap&&(Y.displacementMap.value=re.displacementMap,Y.displacementScale.value=re.displacementScale,Y.displacementBias.value=re.displacementBias)}function vt(Y,re){re.displacementMap&&(Y.displacementMap.value=re.displacementMap,Y.displacementScale.value=re.displacementScale,Y.displacementBias.value=re.displacementBias),Y.referencePosition.value.copy(re.referencePosition),Y.nearDistance.value=re.nearDistance,Y.farDistance.value=re.farDistance}function Vt(Y,re){re.bumpMap&&(Y.bumpMap.value=re.bumpMap,Y.bumpScale.value=re.bumpScale,re.side===tr&&(Y.bumpScale.value*=-1)),re.normalMap&&(Y.normalMap.value=re.normalMap,Y.normalScale.value.copy(re.normalScale),re.side===tr&&Y.normalScale.value.negate()),re.displacementMap&&(Y.displacementMap.value=re.displacementMap,Y.displacementScale.value=re.displacementScale,Y.displacementBias.value=re.displacementBias)}function Ct(Y,re){Y.ambientLightColor.needsUpdate=re,Y.lightProbe.needsUpdate=re,Y.directionalLights.needsUpdate=re,Y.pointLights.needsUpdate=re,Y.spotLights.needsUpdate=re,Y.rectAreaLights.needsUpdate=re,Y.hemisphereLights.needsUpdate=re}function _n(Y){return Y.isMeshLambertMaterial||Y.isMeshToonMaterial||Y.isMeshPhongMaterial||Y.isMeshStandardMaterial||Y.isShadowMaterial||Y.isShaderMaterial&&Y.lights===!0}this.setFramebuffer=function(Y){R!==Y&&j===null&&ke.bindFramebuffer(36160,Y),R=Y},this.getActiveCubeFace=function(){return F},this.getActiveMipmapLevel=function(){return V},this.getRenderTarget=function(){return j},this.setRenderTarget=function(Y,re,Fe){j=Y,F=re,V=Fe,Y&&Ne.get(Y).__webglFramebuffer===void 0&&Je.setupRenderTarget(Y);var Te=R,Tt=!1;if(Y){var _t=Ne.get(Y).__webglFramebuffer;Y.isWebGLCubeRenderTarget?(Te=_t[re||0],Tt=!0):Y.isWebGLMultisampleRenderTarget?Te=Ne.get(Y).__webglMultisampledFramebuffer:Te=_t,ie.copy(Y.viewport),le.copy(Y.scissor),fe=Y.scissorTest}else ie.copy(at).multiplyScalar(Oe).floor(),le.copy(At).multiplyScalar(Oe).floor(),fe=yt;if(J!==Te&&(ke.bindFramebuffer(36160,Te),J=Te),Ae.viewport(ie),Ae.scissor(le),Ae.setScissorTest(fe),Tt){var Ot=Ne.get(Y.texture);ke.framebufferTexture2D(36160,36064,34069+(re||0),Ot.__webglTexture,Fe||0)}},this.readRenderTargetPixels=function(Y,re,Fe,Te,Tt,_t,Ot){if(!(Y&&Y.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}var rn=Ne.get(Y).__webglFramebuffer;if(Y.isWebGLCubeRenderTarget&&Ot!==void 0&&(rn=rn[Ot]),rn){var Sn=!1;rn!==J&&(ke.bindFramebuffer(36160,rn),Sn=!0);try{var Ln=Y.texture,Mt=Ln.format,un=Ln.type;if(Mt!==Ao&&pn.convert(Mt)!==ke.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(un!==Jp&&pn.convert(un)!==ke.getParameter(35738)&&!(un===mh&&(Ce.isWebGL2||ge.get("OES_texture_float")||ge.get("WEBGL_color_buffer_float")))&&!(un===hy&&(Ce.isWebGL2?ge.get("EXT_color_buffer_float"):ge.get("EXT_color_buffer_half_float")))){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ke.checkFramebufferStatus(36160)===36053?re>=0&&re<=Y.width-Te&&Fe>=0&&Fe<=Y.height-Tt&&ke.readPixels(re,Fe,Te,Tt,pn.convert(Mt),pn.convert(un),_t):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{Sn&&ke.bindFramebuffer(36160,J)}}},this.copyFramebufferToTexture=function(Y,re,Fe){Fe===void 0&&(Fe=0);var Te=Math.pow(2,-Fe),Tt=Math.floor(re.image.width*Te),_t=Math.floor(re.image.height*Te),Ot=pn.convert(re.format);Je.setTexture2D(re,0),ke.copyTexImage2D(3553,Fe,Ot,Y.x,Y.y,Tt,_t,0),Ae.unbindTexture()},this.copyTextureToTexture=function(Y,re,Fe,Te){var Tt=re.image.width,_t=re.image.height,Ot=pn.convert(Fe.format),rn=pn.convert(Fe.type);Je.setTexture2D(Fe,0),re.isDataTexture?ke.texSubImage2D(3553,Te||0,Y.x,Y.y,Tt,_t,Ot,rn,re.image.data):ke.texSubImage2D(3553,Te||0,Y.x,Y.y,Ot,rn,re.image),Ae.unbindTexture()},this.initTexture=function(Y){Je.setTexture2D(Y,0),Ae.unbindTexture()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function jy(e,t){this.name="",this.color=new tn(e),this.density=t!==void 0?t:25e-5}Object.assign(jy.prototype,{isFogExp2:!0,clone:function(){return new jy(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}});function Hy(e,t,i){this.name="",this.color=new tn(e),this.near=t!==void 0?t:1,this.far=i!==void 0?i:1e3}Object.assign(Hy.prototype,{isFog:!0,clone:function(){return new Hy(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}});function ka(e,t){this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=nf,this.updateRange={offset:0,count:-1},this.version=0}Object.defineProperty(ka.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(ka.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this},copyAt:function(e,t,i){e*=this.stride,i*=t.stride;for(var l=0,c=this.stride;l<c;l++)this.array[e+l]=t.array[i+l];return this},set:function(e,t){return t===void 0&&(t=0),this.array.set(e,t),this},clone:function(){return new this.constructor().copy(this)},onUpload:function(e){return this.onUploadCallback=e,this}});var sl=new Pe;function kh(e,t,i,l){this.data=e,this.itemSize=t,this.offset=i,this.normalized=l===!0}Object.defineProperties(kh.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}}),Object.assign(kh.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(e){for(var t=0,i=this.data.count;t<i;t++)sl.x=this.getX(t),sl.y=this.getY(t),sl.z=this.getZ(t),sl.applyMatrix4(e),this.setXYZ(t,sl.x,sl.y,sl.z);return this},setX:function(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this},setY:function(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this},setZ:function(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this},setW:function(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this},getX:function(e){return this.data.array[e*this.data.stride+this.offset]},getY:function(e){return this.data.array[e*this.data.stride+this.offset+1]},getZ:function(e){return this.data.array[e*this.data.stride+this.offset+2]},getW:function(e){return this.data.array[e*this.data.stride+this.offset+3]},setXY:function(e,t,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this},setXYZ:function(e,t,i,l){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=l,this},setXYZW:function(e,t,i,l,c){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=l,this.data.array[e+3]=c,this}});function ll(e){Rn.call(this),this.type="SpriteMaterial",this.color=new tn(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}ll.prototype=Object.create(Rn.prototype),ll.prototype.constructor=ll,ll.prototype.isSpriteMaterial=!0,ll.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this};var Ic,zh=new Pe,Rc=new Pe,kc=new Pe,zc=new Lt,Fh=new Lt,P0=new Hn,wf=new Pe,Bh=new Pe,Mf=new Pe,S0=new Lt,$y=new Lt,L0=new Lt;function qy(e){if(on.call(this),this.type="Sprite",Ic===void 0){Ic=new vn;var t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new ka(t,5);Ic.setIndex([0,1,2,0,2,3]),Ic.setAttribute("position",new kh(i,3,0,!1)),Ic.setAttribute("uv",new kh(i,2,3,!1))}this.geometry=Ic,this.material=e!==void 0?e:new ll,this.center=new Lt(.5,.5)}qy.prototype=Object.assign(Object.create(on.prototype),{constructor:qy,isSprite:!0,raycast:function(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Rc.setFromMatrixScale(this.matrixWorld),P0.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),kc.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Rc.multiplyScalar(-kc.z);var i=this.material.rotation,l,c;i!==0&&(c=Math.cos(i),l=Math.sin(i));var h=this.center;Tf(wf.set(-.5,-.5,0),kc,h,Rc,l,c),Tf(Bh.set(.5,-.5,0),kc,h,Rc,l,c),Tf(Mf.set(.5,.5,0),kc,h,Rc,l,c),S0.set(0,0),$y.set(1,0),L0.set(1,1);var f=e.ray.intersectTriangle(wf,Bh,Mf,!1,zh);if(!(f===null&&(Tf(Bh.set(-.5,.5,0),kc,h,Rc,l,c),$y.set(0,1),f=e.ray.intersectTriangle(wf,Mf,Bh,!1,zh),f===null))){var r=e.ray.origin.distanceTo(zh);r<e.near||r>e.far||t.push({distance:r,point:zh.clone(),uv:lr.getUV(zh,wf,Bh,Mf,S0,$y,L0,new Lt),face:null,object:this})}},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return on.prototype.copy.call(this,e),e.center!==void 0&&this.center.copy(e.center),this}});function Tf(e,t,i,l,c,h){zc.subVectors(e,i).addScalar(.5).multiply(l),c!==void 0?(Fh.x=h*zc.x-c*zc.y,Fh.y=c*zc.x+h*zc.y):Fh.copy(zc),e.copy(t),e.x+=Fh.x,e.y+=Fh.y,e.applyMatrix4(P0)}var Ef=new Pe,I0=new Pe;function Cf(){on.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}Cf.prototype=Object.assign(Object.create(on.prototype),{constructor:Cf,isLOD:!0,copy:function(e){on.prototype.copy.call(this,e,!1);for(var t=e.levels,i=0,l=t.length;i<l;i++){var c=t[i];this.addLevel(c.object.clone(),c.distance)}return this.autoUpdate=e.autoUpdate,this},addLevel:function(e,t){t===void 0&&(t=0),t=Math.abs(t);for(var i=this.levels,l=0;l<i.length&&!(t<i[l].distance);l++);return i.splice(l,0,{distance:t,object:e}),this.add(e),this},getObjectForDistance:function(e){var t=this.levels;if(t.length>0){for(var i=1,l=t.length;i<l&&!(e<t[i].distance);i++);return t[i-1].object}return null},raycast:function(e,t){var i=this.levels;if(i.length>0){Ef.setFromMatrixPosition(this.matrixWorld);var l=e.ray.origin.distanceTo(Ef);this.getObjectForDistance(l).raycast(e,t)}},update:function(e){var t=this.levels;if(t.length>1){Ef.setFromMatrixPosition(e.matrixWorld),I0.setFromMatrixPosition(this.matrixWorld);var i=Ef.distanceTo(I0);t[0].object.visible=!0;for(var l=1,c=t.length;l<c&&i>=t[l].distance;l++)t[l-1].object.visible=!1,t[l].object.visible=!0;for(;l<c;l++)t[l].object.visible=!1}},toJSON:function(e){var t=on.prototype.toJSON.call(this,e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];for(var i=this.levels,l=0,c=i.length;l<c;l++){var h=i[l];t.object.levels.push({object:h.object.uuid,distance:h.distance})}return t}});function Oh(e,t){e&&e.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),Ai.call(this,e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Hn,this.bindMatrixInverse=new Hn}Oh.prototype=Object.assign(Object.create(Ai.prototype),{constructor:Oh,isSkinnedMesh:!0,bind:function(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.getInverse(t)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){for(var e=new gi,t=this.geometry.attributes.skinWeight,i=0,l=t.count;i<l;i++){e.x=t.getX(i),e.y=t.getY(i),e.z=t.getZ(i),e.w=t.getW(i);var c=1/e.manhattanLength();c!==1/0?e.multiplyScalar(c):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}},updateMatrixWorld:function(e){Ai.prototype.updateMatrixWorld.call(this,e),this.bindMode==="attached"?this.bindMatrixInverse.getInverse(this.matrixWorld):this.bindMode==="detached"?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var R0=new Hn,WP=new Hn;function Af(e,t){if(e=e||[],this.bones=e.slice(0),this.boneMatrices=new Float32Array(this.bones.length*16),this.frame=-1,t===void 0)this.calculateInverses();else if(this.bones.length===t.length)this.boneInverses=t.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var i=0,l=this.bones.length;i<l;i++)this.boneInverses.push(new Hn)}}Object.assign(Af.prototype,{calculateInverses:function(){this.boneInverses=[];for(var e=0,t=this.bones.length;e<t;e++){var i=new Hn;this.bones[e]&&i.getInverse(this.bones[e].matrixWorld),this.boneInverses.push(i)}},pose:function(){var e,t,i;for(t=0,i=this.bones.length;t<i;t++)e=this.bones[t],e&&e.matrixWorld.getInverse(this.boneInverses[t]);for(t=0,i=this.bones.length;t<i;t++)e=this.bones[t],e&&(e.parent&&e.parent.isBone?(e.matrix.getInverse(e.parent.matrixWorld),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))},update:function(){for(var e=this.bones,t=this.boneInverses,i=this.boneMatrices,l=this.boneTexture,c=0,h=e.length;c<h;c++){var f=e[c]?e[c].matrixWorld:WP;R0.multiplyMatrices(f,t[c]),R0.toArray(i,c*16)}l!==void 0&&(l.needsUpdate=!0)},clone:function(){return new Af(this.bones,this.boneInverses)},getBoneByName:function(e){for(var t=0,i=this.bones.length;t<i;t++){var l=this.bones[t];if(l.name===e)return l}}});function Xy(){on.call(this),this.type="Bone"}Xy.prototype=Object.assign(Object.create(on.prototype),{constructor:Xy,isBone:!0});var k0=new Hn,z0=new Hn,Fc=[],Nh=new Ai;function Zy(e,t,i){Ai.call(this,e,t),this.instanceMatrix=new kn(new Float32Array(i*16),16),this.count=i,this.frustumCulled=!1}Zy.prototype=Object.assign(Object.create(Ai.prototype),{constructor:Zy,isInstancedMesh:!0,getMatrixAt:function(e,t){t.fromArray(this.instanceMatrix.array,e*16)},raycast:function(e,t){var i=this.matrixWorld,l=this.count;if(Nh.geometry=this.geometry,Nh.material=this.material,Nh.material!==void 0)for(var c=0;c<l;c++)this.getMatrixAt(c,k0),z0.multiplyMatrices(i,k0),Nh.matrixWorld=z0,Nh.raycast(e,Fc),Fc.length>0&&(Fc[0].instanceId=c,Fc[0].object=this,t.push(Fc[0]),Fc.length=0)},setMatrixAt:function(e,t){t.toArray(this.instanceMatrix.array,e*16)},updateMorphTargets:function(){}});function Ri(e){Rn.call(this),this.type="LineBasicMaterial",this.color=new tn(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.setValues(e)}Ri.prototype=Object.create(Rn.prototype),Ri.prototype.constructor=Ri,Ri.prototype.isLineBasicMaterial=!0,Ri.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this};var F0=new Pe,B0=new Pe,O0=new Hn,Df=new yc,Pf=new Da;function so(e,t,i){i===1&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead."),on.call(this),this.type="Line",this.geometry=e!==void 0?e:new vn,this.material=t!==void 0?t:new Ri}so.prototype=Object.assign(Object.create(on.prototype),{constructor:so,isLine:!0,computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(e.index===null){for(var t=e.attributes.position,i=[0],l=1,c=t.count;l<c;l++)F0.fromBufferAttribute(t,l-1),B0.fromBufferAttribute(t,l),i[l]=i[l-1],i[l]+=F0.distanceTo(B0);e.setAttribute("lineDistance",new ln(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(e.isGeometry){var h=e.vertices,i=e.lineDistances;i[0]=0;for(var l=1,c=h.length;l<c;l++)i[l]=i[l-1],i[l]+=h[l-1].distanceTo(h[l])}return this},raycast:function(e,t){var i=e.linePrecision,l=this.geometry,c=this.matrixWorld;if(l.boundingSphere===null&&l.computeBoundingSphere(),Pf.copy(l.boundingSphere),Pf.applyMatrix4(c),Pf.radius+=i,e.ray.intersectsSphere(Pf)!==!1){O0.getInverse(c),Df.copy(e.ray).applyMatrix4(O0);var h=i/((this.scale.x+this.scale.y+this.scale.z)/3),f=h*h,r=new Pe,v=new Pe,x=new Pe,w=new Pe,b=this&&this.isLineSegments?2:1;if(l.isBufferGeometry){var A=l.index,L=l.attributes,P=L.position.array;if(A!==null)for(var R=A.array,F=0,V=R.length-1;F<V;F+=b){var j=R[F],J=R[F+1];r.fromArray(P,j*3),v.fromArray(P,J*3);var ne=Df.distanceSqToSegment(r,v,w,x);if(!(ne>f)){w.applyMatrix4(this.matrixWorld);var H=e.ray.origin.distanceTo(w);H<e.near||H>e.far||t.push({distance:H,point:x.clone().applyMatrix4(this.matrixWorld),index:F,face:null,faceIndex:null,object:this})}}else for(var F=0,V=P.length/3-1;F<V;F+=b){r.fromArray(P,3*F),v.fromArray(P,3*F+3);var ne=Df.distanceSqToSegment(r,v,w,x);if(!(ne>f)){w.applyMatrix4(this.matrixWorld);var H=e.ray.origin.distanceTo(w);H<e.near||H>e.far||t.push({distance:H,point:x.clone().applyMatrix4(this.matrixWorld),index:F,face:null,faceIndex:null,object:this})}}}else if(l.isGeometry)for(var Q=l.vertices,ae=Q.length,F=0;F<ae-1;F+=b){var ne=Df.distanceSqToSegment(Q[F],Q[F+1],w,x);if(!(ne>f)){w.applyMatrix4(this.matrixWorld);var H=e.ray.origin.distanceTo(w);H<e.near||H>e.far||t.push({distance:H,point:x.clone().applyMatrix4(this.matrixWorld),index:F,face:null,faceIndex:null,object:this})}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var Sf=new Pe,Lf=new Pe;function Vi(e,t){so.call(this,e,t),this.type="LineSegments"}Vi.prototype=Object.assign(Object.create(so.prototype),{constructor:Vi,isLineSegments:!0,computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(e.index===null){for(var t=e.attributes.position,i=[],l=0,c=t.count;l<c;l+=2)Sf.fromBufferAttribute(t,l),Lf.fromBufferAttribute(t,l+1),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+Sf.distanceTo(Lf);e.setAttribute("lineDistance",new ln(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(e.isGeometry)for(var h=e.vertices,i=e.lineDistances,l=0,c=h.length;l<c;l+=2)Sf.copy(h[l]),Lf.copy(h[l+1]),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+Sf.distanceTo(Lf);return this}});function If(e,t){so.call(this,e,t),this.type="LineLoop"}If.prototype=Object.assign(Object.create(so.prototype),{constructor:If,isLineLoop:!0});function ss(e){Rn.call(this),this.type="PointsMaterial",this.color=new tn(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(e)}ss.prototype=Object.create(Rn.prototype),ss.prototype.constructor=ss,ss.prototype.isPointsMaterial=!0,ss.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.morphTargets=e.morphTargets,this};var N0=new Hn,Yy=new yc,Rf=new Da,kf=new Pe;function zf(e,t){on.call(this),this.type="Points",this.geometry=e!==void 0?e:new vn,this.material=t!==void 0?t:new ss,this.updateMorphTargets()}zf.prototype=Object.assign(Object.create(on.prototype),{constructor:zf,isPoints:!0,raycast:function(e,t){var i=this.geometry,l=this.matrixWorld,c=e.params.Points.threshold;if(i.boundingSphere===null&&i.computeBoundingSphere(),Rf.copy(i.boundingSphere),Rf.applyMatrix4(l),Rf.radius+=c,e.ray.intersectsSphere(Rf)!==!1){N0.getInverse(l),Yy.copy(e.ray).applyMatrix4(N0);var h=c/((this.scale.x+this.scale.y+this.scale.z)/3),f=h*h;if(i.isBufferGeometry){var r=i.index,v=i.attributes,x=v.position.array;if(r!==null)for(var w=r.array,b=0,A=w.length;b<A;b++){var L=w[b];kf.fromArray(x,L*3),Ky(kf,L,f,l,e,t,this)}else for(var b=0,P=x.length/3;b<P;b++)kf.fromArray(x,b*3),Ky(kf,b,f,l,e,t,this)}else for(var R=i.vertices,b=0,P=R.length;b<P;b++)Ky(R[b],b,f,l,e,t,this)}},updateMorphTargets:function(){var e=this.geometry,t,i,l;if(e.isBufferGeometry){var c=e.morphAttributes,h=Object.keys(c);if(h.length>0){var f=c[h[0]];if(f!==void 0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,i=f.length;t<i;t++)l=f[t].name||String(t),this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=t}}else{var r=e.morphTargets;r!==void 0&&r.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});function Ky(e,t,i,l,c,h,f){var r=Yy.distanceSqToPoint(e);if(r<i){var v=new Pe;Yy.closestPointToPoint(e,v),v.applyMatrix4(l);var x=c.ray.origin.distanceTo(v);if(x<c.near||x>c.far)return;h.push({distance:x,distanceToRay:Math.sqrt(r),point:v,index:t,face:null,object:f})}}function U0(e,t,i,l,c,h,f,r,v){mi.call(this,e,t,i,l,c,h,f,r,v),this.format=f!==void 0?f:Ma,this.minFilter=h!==void 0?h:$i,this.magFilter=c!==void 0?c:$i,this.generateMipmaps=!1}U0.prototype=Object.assign(Object.create(mi.prototype),{constructor:U0,isVideoTexture:!0,update:function(){var e=this.image;e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});function Uh(e,t,i,l,c,h,f,r,v,x,w,b){mi.call(this,null,h,f,r,v,x,l,c,w,b),this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}Uh.prototype=Object.create(mi.prototype),Uh.prototype.constructor=Uh,Uh.prototype.isCompressedTexture=!0;function Ff(e,t,i,l,c,h,f,r,v){mi.call(this,e,t,i,l,c,h,f,r,v),this.needsUpdate=!0}Ff.prototype=Object.create(mi.prototype),Ff.prototype.constructor=Ff,Ff.prototype.isCanvasTexture=!0;function Bf(e,t,i,l,c,h,f,r,v,x){if(x=x!==void 0?x:ac,x!==ac&&x!==gh)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&x===ac&&(i=Qp),i===void 0&&x===gh&&(i=ef),mi.call(this,null,l,c,h,f,r,x,i,v),this.image={width:e,height:t},this.magFilter=f!==void 0?f:Ui,this.minFilter=r!==void 0?r:Ui,this.flipY=!1,this.generateMipmaps=!1}Bf.prototype=Object.create(mi.prototype),Bf.prototype.constructor=Bf,Bf.prototype.isDepthTexture=!0;function Of(e){vn.call(this),this.type="WireframeGeometry";var t=[],i,l,c,h,f,r=[0,0],v={},x,w,b,A,L=["a","b","c"],P;if(e&&e.isGeometry){var R=e.faces;for(i=0,c=R.length;i<c;i++){var F=R[i];for(l=0;l<3;l++)w=F[L[l]],b=F[L[(l+1)%3]],r[0]=Math.min(w,b),r[1]=Math.max(w,b),A=r[0]+","+r[1],v[A]===void 0&&(v[A]={index1:r[0],index2:r[1]})}for(A in v)x=v[A],P=e.vertices[x.index1],t.push(P.x,P.y,P.z),P=e.vertices[x.index2],t.push(P.x,P.y,P.z)}else if(e&&e.isBufferGeometry){var V,j,J,ne,H,Q,ae,ie;if(P=new Pe,e.index!==null){for(V=e.attributes.position,j=e.index,J=e.groups,J.length===0&&(J=[{start:0,count:j.count,materialIndex:0}]),h=0,f=J.length;h<f;++h)for(ne=J[h],H=ne.start,Q=ne.count,i=H,c=H+Q;i<c;i+=3)for(l=0;l<3;l++)w=j.getX(i+l),b=j.getX(i+(l+1)%3),r[0]=Math.min(w,b),r[1]=Math.max(w,b),A=r[0]+","+r[1],v[A]===void 0&&(v[A]={index1:r[0],index2:r[1]});for(A in v)x=v[A],P.fromBufferAttribute(V,x.index1),t.push(P.x,P.y,P.z),P.fromBufferAttribute(V,x.index2),t.push(P.x,P.y,P.z)}else for(V=e.attributes.position,i=0,c=V.count/3;i<c;i++)for(l=0;l<3;l++)ae=3*i+l,P.fromBufferAttribute(V,ae),t.push(P.x,P.y,P.z),ie=3*i+(l+1)%3,P.fromBufferAttribute(V,ie),t.push(P.x,P.y,P.z)}this.setAttribute("position",new ln(t,3))}Of.prototype=Object.create(vn.prototype),Of.prototype.constructor=Of;function Nf(e,t,i){Bn.call(this),this.type="ParametricGeometry",this.parameters={func:e,slices:t,stacks:i},this.fromBufferGeometry(new Vh(e,t,i)),this.mergeVertices()}Nf.prototype=Object.create(Bn.prototype),Nf.prototype.constructor=Nf;function Vh(e,t,i){vn.call(this),this.type="ParametricBufferGeometry",this.parameters={func:e,slices:t,stacks:i};var l=[],c=[],h=[],f=[],r=1e-5,v=new Pe,x=new Pe,w=new Pe,b=new Pe,A=new Pe,L,P;e.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");var R=t+1;for(L=0;L<=i;L++){var F=L/i;for(P=0;P<=t;P++){var V=P/t;e(V,F,x),c.push(x.x,x.y,x.z),V-r>=0?(e(V-r,F,w),b.subVectors(x,w)):(e(V+r,F,w),b.subVectors(w,x)),F-r>=0?(e(V,F-r,w),A.subVectors(x,w)):(e(V,F+r,w),A.subVectors(w,x)),v.crossVectors(b,A).normalize(),h.push(v.x,v.y,v.z),f.push(V,F)}}for(L=0;L<i;L++)for(P=0;P<t;P++){var j=L*R+P,J=L*R+P+1,ne=(L+1)*R+P+1,H=(L+1)*R+P;l.push(j,J,H),l.push(J,ne,H)}this.setIndex(l),this.setAttribute("position",new ln(c,3)),this.setAttribute("normal",new ln(h,3)),this.setAttribute("uv",new ln(f,2))}Vh.prototype=Object.create(vn.prototype),Vh.prototype.constructor=Vh;function Uf(e,t,i,l){Bn.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:l},this.fromBufferGeometry(new lo(e,t,i,l)),this.mergeVertices()}Uf.prototype=Object.create(Bn.prototype),Uf.prototype.constructor=Uf;function lo(e,t,i,l){vn.call(this),this.type="PolyhedronBufferGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:l},i=i||1,l=l||0;var c=[],h=[];f(l),v(i),x(),this.setAttribute("position",new ln(c,3)),this.setAttribute("normal",new ln(c.slice(),3)),this.setAttribute("uv",new ln(h,2)),l===0?this.computeVertexNormals():this.normalizeNormals();function f(V){for(var j=new Pe,J=new Pe,ne=new Pe,H=0;H<t.length;H+=3)A(t[H+0],j),A(t[H+1],J),A(t[H+2],ne),r(j,J,ne,V)}function r(V,j,J,ne){var H=Math.pow(2,ne),Q=[],ae,ie;for(ae=0;ae<=H;ae++){Q[ae]=[];var le=V.clone().lerp(J,ae/H),fe=j.clone().lerp(J,ae/H),me=H-ae;for(ie=0;ie<=me;ie++)ie===0&&ae===H?Q[ae][ie]=le:Q[ae][ie]=le.clone().lerp(fe,ie/me)}for(ae=0;ae<H;ae++)for(ie=0;ie<2*(H-ae)-1;ie++){var he=Math.floor(ie/2);ie%2===0?(b(Q[ae][he+1]),b(Q[ae+1][he]),b(Q[ae][he])):(b(Q[ae][he+1]),b(Q[ae+1][he+1]),b(Q[ae+1][he]))}}function v(V){for(var j=new Pe,J=0;J<c.length;J+=3)j.x=c[J+0],j.y=c[J+1],j.z=c[J+2],j.normalize().multiplyScalar(V),c[J+0]=j.x,c[J+1]=j.y,c[J+2]=j.z}function x(){for(var V=new Pe,j=0;j<c.length;j+=3){V.x=c[j+0],V.y=c[j+1],V.z=c[j+2];var J=R(V)/2/Math.PI+.5,ne=F(V)/Math.PI+.5;h.push(J,1-ne)}L(),w()}function w(){for(var V=0;V<h.length;V+=6){var j=h[V+0],J=h[V+2],ne=h[V+4],H=Math.max(j,J,ne),Q=Math.min(j,J,ne);H>.9&&Q<.1&&(j<.2&&(h[V+0]+=1),J<.2&&(h[V+2]+=1),ne<.2&&(h[V+4]+=1))}}function b(V){c.push(V.x,V.y,V.z)}function A(V,j){var J=V*3;j.x=e[J+0],j.y=e[J+1],j.z=e[J+2]}function L(){for(var V=new Pe,j=new Pe,J=new Pe,ne=new Pe,H=new Lt,Q=new Lt,ae=new Lt,ie=0,le=0;ie<c.length;ie+=9,le+=6){V.set(c[ie+0],c[ie+1],c[ie+2]),j.set(c[ie+3],c[ie+4],c[ie+5]),J.set(c[ie+6],c[ie+7],c[ie+8]),H.set(h[le+0],h[le+1]),Q.set(h[le+2],h[le+3]),ae.set(h[le+4],h[le+5]),ne.copy(V).add(j).add(J).divideScalar(3);var fe=R(ne);P(H,le+0,V,fe),P(Q,le+2,j,fe),P(ae,le+4,J,fe)}}function P(V,j,J,ne){ne<0&&V.x===1&&(h[j]=V.x-1),J.x===0&&J.z===0&&(h[j]=ne/2/Math.PI+.5)}function R(V){return Math.atan2(V.z,-V.x)}function F(V){return Math.atan2(-V.y,Math.sqrt(V.x*V.x+V.z*V.z))}}lo.prototype=Object.create(vn.prototype),lo.prototype.constructor=lo;function Vf(e,t){Bn.call(this),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Gh(e,t)),this.mergeVertices()}Vf.prototype=Object.create(Bn.prototype),Vf.prototype.constructor=Vf;function Gh(e,t){var i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],l=[2,1,0,0,3,2,1,3,0,2,3,1];lo.call(this,i,l,e,t),this.type="TetrahedronBufferGeometry",this.parameters={radius:e,detail:t}}Gh.prototype=Object.create(lo.prototype),Gh.prototype.constructor=Gh;function Gf(e,t){Bn.call(this),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Bc(e,t)),this.mergeVertices()}Gf.prototype=Object.create(Bn.prototype),Gf.prototype.constructor=Gf;function Bc(e,t){var i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],l=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];lo.call(this,i,l,e,t),this.type="OctahedronBufferGeometry",this.parameters={radius:e,detail:t}}Bc.prototype=Object.create(lo.prototype),Bc.prototype.constructor=Bc;function Wf(e,t){Bn.call(this),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Wh(e,t)),this.mergeVertices()}Wf.prototype=Object.create(Bn.prototype),Wf.prototype.constructor=Wf;function Wh(e,t){var i=(1+Math.sqrt(5))/2,l=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],c=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];lo.call(this,l,c,e,t),this.type="IcosahedronBufferGeometry",this.parameters={radius:e,detail:t}}Wh.prototype=Object.create(lo.prototype),Wh.prototype.constructor=Wh;function jf(e,t){Bn.call(this),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new jh(e,t)),this.mergeVertices()}jf.prototype=Object.create(Bn.prototype),jf.prototype.constructor=jf;function jh(e,t){var i=(1+Math.sqrt(5))/2,l=1/i,c=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-l,-i,0,-l,i,0,l,-i,0,l,i,-l,-i,0,-l,i,0,l,-i,0,l,i,0,-i,0,-l,i,0,-l,-i,0,l,i,0,l],h=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];lo.call(this,c,h,e,t),this.type="DodecahedronBufferGeometry",this.parameters={radius:e,detail:t}}jh.prototype=Object.create(lo.prototype),jh.prototype.constructor=jh;function Hf(e,t,i,l,c,h){Bn.call(this),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:l,closed:c},h!==void 0&&console.warn("THREE.TubeGeometry: taper has been removed.");var f=new Oc(e,t,i,l,c);this.tangents=f.tangents,this.normals=f.normals,this.binormals=f.binormals,this.fromBufferGeometry(f),this.mergeVertices()}Hf.prototype=Object.create(Bn.prototype),Hf.prototype.constructor=Hf;function Oc(e,t,i,l,c){vn.call(this),this.type="TubeBufferGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:l,closed:c},t=t||64,i=i||1,l=l||8,c=c||!1;var h=e.computeFrenetFrames(t,c);this.tangents=h.tangents,this.normals=h.normals,this.binormals=h.binormals;var f=new Pe,r=new Pe,v=new Lt,x=new Pe,w,b,A=[],L=[],P=[],R=[];F(),this.setIndex(R),this.setAttribute("position",new ln(A,3)),this.setAttribute("normal",new ln(L,3)),this.setAttribute("uv",new ln(P,2));function F(){for(w=0;w<t;w++)V(w);V(c===!1?t:0),J(),j()}function V(ne){x=e.getPointAt(ne/t,x);var H=h.normals[ne],Q=h.binormals[ne];for(b=0;b<=l;b++){var ae=b/l*Math.PI*2,ie=Math.sin(ae),le=-Math.cos(ae);r.x=le*H.x+ie*Q.x,r.y=le*H.y+ie*Q.y,r.z=le*H.z+ie*Q.z,r.normalize(),L.push(r.x,r.y,r.z),f.x=x.x+i*r.x,f.y=x.y+i*r.y,f.z=x.z+i*r.z,A.push(f.x,f.y,f.z)}}function j(){for(b=1;b<=t;b++)for(w=1;w<=l;w++){var ne=(l+1)*(b-1)+(w-1),H=(l+1)*b+(w-1),Q=(l+1)*b+w,ae=(l+1)*(b-1)+w;R.push(ne,H,ae),R.push(H,Q,ae)}}function J(){for(w=0;w<=t;w++)for(b=0;b<=l;b++)v.x=w/t,v.y=b/l,P.push(v.x,v.y)}}Oc.prototype=Object.create(vn.prototype),Oc.prototype.constructor=Oc,Oc.prototype.toJSON=function(){var e=vn.prototype.toJSON.call(this);return e.path=this.parameters.path.toJSON(),e};function $f(e,t,i,l,c,h,f){Bn.call(this),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:l,p:c,q:h},f!==void 0&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),this.fromBufferGeometry(new Hh(e,t,i,l,c,h)),this.mergeVertices()}$f.prototype=Object.create(Bn.prototype),$f.prototype.constructor=$f;function Hh(e,t,i,l,c,h){vn.call(this),this.type="TorusKnotBufferGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:l,p:c,q:h},e=e||1,t=t||.4,i=Math.floor(i)||64,l=Math.floor(l)||8,c=c||2,h=h||3;var f=[],r=[],v=[],x=[],w,b,A=new Pe,L=new Pe,P=new Pe,R=new Pe,F=new Pe,V=new Pe,j=new Pe;for(w=0;w<=i;++w){var J=w/i*c*Math.PI*2;for(me(J,c,h,e,P),me(J+.01,c,h,e,R),V.subVectors(R,P),j.addVectors(R,P),F.crossVectors(V,j),j.crossVectors(F,V),F.normalize(),j.normalize(),b=0;b<=l;++b){var ne=b/l*Math.PI*2,H=-t*Math.cos(ne),Q=t*Math.sin(ne);A.x=P.x+(H*j.x+Q*F.x),A.y=P.y+(H*j.y+Q*F.y),A.z=P.z+(H*j.z+Q*F.z),r.push(A.x,A.y,A.z),L.subVectors(A,P).normalize(),v.push(L.x,L.y,L.z),x.push(w/i),x.push(b/l)}}for(b=1;b<=i;b++)for(w=1;w<=l;w++){var ae=(l+1)*(b-1)+(w-1),ie=(l+1)*b+(w-1),le=(l+1)*b+w,fe=(l+1)*(b-1)+w;f.push(ae,ie,fe),f.push(ie,le,fe)}this.setIndex(f),this.setAttribute("position",new ln(r,3)),this.setAttribute("normal",new ln(v,3)),this.setAttribute("uv",new ln(x,2));function me(he,Oe,Ve,He,at){var At=Math.cos(he),yt=Math.sin(he),Dt=Ve/Oe*he,It=Math.cos(Dt);at.x=He*(2+It)*.5*At,at.y=He*(2+It)*yt*.5,at.z=He*Math.sin(Dt)*.5}}Hh.prototype=Object.create(vn.prototype),Hh.prototype.constructor=Hh;function qf(e,t,i,l,c){Bn.call(this),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:l,arc:c},this.fromBufferGeometry(new $h(e,t,i,l,c)),this.mergeVertices()}qf.prototype=Object.create(Bn.prototype),qf.prototype.constructor=qf;function $h(e,t,i,l,c){vn.call(this),this.type="TorusBufferGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:l,arc:c},e=e||1,t=t||.4,i=Math.floor(i)||8,l=Math.floor(l)||6,c=c||Math.PI*2;var h=[],f=[],r=[],v=[],x=new Pe,w=new Pe,b=new Pe,A,L;for(A=0;A<=i;A++)for(L=0;L<=l;L++){var P=L/l*c,R=A/i*Math.PI*2;w.x=(e+t*Math.cos(R))*Math.cos(P),w.y=(e+t*Math.cos(R))*Math.sin(P),w.z=t*Math.sin(R),f.push(w.x,w.y,w.z),x.x=e*Math.cos(P),x.y=e*Math.sin(P),b.subVectors(w,x).normalize(),r.push(b.x,b.y,b.z),v.push(L/l),v.push(A/i)}for(A=1;A<=i;A++)for(L=1;L<=l;L++){var F=(l+1)*A+L-1,V=(l+1)*(A-1)+L-1,j=(l+1)*(A-1)+L,J=(l+1)*A+L;h.push(F,V,J),h.push(V,j,J)}this.setIndex(h),this.setAttribute("position",new ln(f,3)),this.setAttribute("normal",new ln(r,3)),this.setAttribute("uv",new ln(v,2))}$h.prototype=Object.create(vn.prototype),$h.prototype.constructor=$h;var jP={triangulate:function(e,t,i){i=i||2;var l=t&&t.length,c=l?t[0]*i:e.length,h=V0(e,0,c,i,!0),f=[];if(!h||h.next===h.prev)return f;var r,v,x,w,b,A,L;if(l&&(h=ZP(e,t,h,i)),e.length>80*i){r=x=e[0],v=w=e[1];for(var P=i;P<c;P+=i)b=e[P],A=e[P+1],b<r&&(r=b),A<v&&(v=A),b>x&&(x=b),A>w&&(w=A);L=Math.max(x-r,w-v),L=L!==0?1/L:0}return Xh(h,f,i,r,v,L),f}};function V0(e,t,i,l,c){var h,f;if(c===oS(e,t,i,l)>0)for(h=t;h<i;h+=l)f=j0(h,e[h],e[h+1],f);else for(h=i-l;h>=t;h-=l)f=j0(h,e[h],e[h+1],f);return f&&cl(f,f.next)&&(Yh(f),f=f.next),f}function qh(e,t){if(!e)return e;t||(t=e);var i=e,l;do if(l=!1,!i.steiner&&(cl(i,i.next)||ur(i.prev,i,i.next)===0)){if(Yh(i),i=t=i.prev,i===i.next)break;l=!0}else i=i.next;while(l||i!==t);return t}function Xh(e,t,i,l,c,h,f){if(e){!f&&h&&QP(e,l,c,h);for(var r=e,v,x;e.prev!==e.next;){if(v=e.prev,x=e.next,h?$P(e,l,c,h):HP(e)){t.push(v.i/i),t.push(e.i/i),t.push(x.i/i),Yh(e),e=x.next,r=x.next;continue}if(e=x,e===r){f?f===1?(e=qP(e,t,i),Xh(e,t,i,l,c,h,2)):f===2&&XP(e,t,i,l,c,h):Xh(qh(e),t,i,l,c,h,1);break}}}}function HP(e){var t=e.prev,i=e,l=e.next;if(ur(t,i,l)>=0)return!1;for(var c=e.next.next;c!==e.prev;){if(Nc(t.x,t.y,i.x,i.y,l.x,l.y,c.x,c.y)&&ur(c.prev,c,c.next)>=0)return!1;c=c.next}return!0}function $P(e,t,i,l){var c=e.prev,h=e,f=e.next;if(ur(c,h,f)>=0)return!1;for(var r=c.x<h.x?c.x<f.x?c.x:f.x:h.x<f.x?h.x:f.x,v=c.y<h.y?c.y<f.y?c.y:f.y:h.y<f.y?h.y:f.y,x=c.x>h.x?c.x>f.x?c.x:f.x:h.x>f.x?h.x:f.x,w=c.y>h.y?c.y>f.y?c.y:f.y:h.y>f.y?h.y:f.y,b=Jy(r,v,t,i,l),A=Jy(x,w,t,i,l),L=e.prevZ,P=e.nextZ;L&&L.z>=b&&P&&P.z<=A;){if(L!==e.prev&&L!==e.next&&Nc(c.x,c.y,h.x,h.y,f.x,f.y,L.x,L.y)&&ur(L.prev,L,L.next)>=0||(L=L.prevZ,P!==e.prev&&P!==e.next&&Nc(c.x,c.y,h.x,h.y,f.x,f.y,P.x,P.y)&&ur(P.prev,P,P.next)>=0))return!1;P=P.nextZ}for(;L&&L.z>=b;){if(L!==e.prev&&L!==e.next&&Nc(c.x,c.y,h.x,h.y,f.x,f.y,L.x,L.y)&&ur(L.prev,L,L.next)>=0)return!1;L=L.prevZ}for(;P&&P.z<=A;){if(P!==e.prev&&P!==e.next&&Nc(c.x,c.y,h.x,h.y,f.x,f.y,P.x,P.y)&&ur(P.prev,P,P.next)>=0)return!1;P=P.nextZ}return!0}function qP(e,t,i){var l=e;do{var c=l.prev,h=l.next.next;!cl(c,h)&&G0(c,l,l.next,h)&&Zh(c,h)&&Zh(h,c)&&(t.push(c.i/i),t.push(l.i/i),t.push(h.i/i),Yh(l),Yh(l.next),l=e=h),l=l.next}while(l!==e);return l}function XP(e,t,i,l,c,h){var f=e;do{for(var r=f.next.next;r!==f.prev;){if(f.i!==r.i&&nS(f,r)){var v=W0(f,r);f=qh(f,f.next),v=qh(v,v.next),Xh(f,t,i,l,c,h),Xh(v,t,i,l,c,h);return}r=r.next}f=f.next}while(f!==e)}function ZP(e,t,i,l){var c=[],h,f,r,v,x;for(h=0,f=t.length;h<f;h++)r=t[h]*l,v=h<f-1?t[h+1]*l:e.length,x=V0(e,r,v,l,!1),x===x.next&&(x.steiner=!0),c.push(tS(x));for(c.sort(YP),h=0;h<c.length;h++)KP(c[h],i),i=qh(i,i.next);return i}function YP(e,t){return e.x-t.x}function KP(e,t){if(t=JP(e,t),t){var i=W0(t,e);qh(i,i.next)}}function JP(e,t){var i=t,l=e.x,c=e.y,h=-1/0,f;do{if(c<=i.y&&c>=i.next.y&&i.next.y!==i.y){var r=i.x+(c-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(r<=l&&r>h){if(h=r,r===l){if(c===i.y)return i;if(c===i.next.y)return i.next}f=i.x<i.next.x?i:i.next}}i=i.next}while(i!==t);if(!f)return null;if(l===h)return f.prev;var v=f,x=f.x,w=f.y,b=1/0,A;for(i=f.next;i!==v;)l>=i.x&&i.x>=x&&l!==i.x&&Nc(c<w?l:h,c,x,w,c<w?h:l,c,i.x,i.y)&&(A=Math.abs(c-i.y)/(l-i.x),(A<b||A===b&&i.x>f.x)&&Zh(i,e)&&(f=i,b=A)),i=i.next;return f}function QP(e,t,i,l){var c=e;do c.z===null&&(c.z=Jy(c.x,c.y,t,i,l)),c.prevZ=c.prev,c.nextZ=c.next,c=c.next;while(c!==e);c.prevZ.nextZ=null,c.prevZ=null,eS(c)}function eS(e){var t,i,l,c,h,f,r,v,x=1;do{for(i=e,e=null,h=null,f=0;i;){for(f++,l=i,r=0,t=0;t<x&&(r++,l=l.nextZ,!!l);t++);for(v=x;r>0||v>0&&l;)r!==0&&(v===0||!l||i.z<=l.z)?(c=i,i=i.nextZ,r--):(c=l,l=l.nextZ,v--),h?h.nextZ=c:e=c,c.prevZ=h,h=c;i=l}h.nextZ=null,x*=2}while(f>1);return e}function Jy(e,t,i,l,c){return e=32767*(e-i)*c,t=32767*(t-l)*c,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function tS(e){var t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function Nc(e,t,i,l,c,h,f,r){return(c-f)*(t-r)-(e-f)*(h-r)>=0&&(e-f)*(l-r)-(i-f)*(t-r)>=0&&(i-f)*(h-r)-(c-f)*(l-r)>=0}function nS(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!iS(e,t)&&Zh(e,t)&&Zh(t,e)&&rS(e,t)}function ur(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function cl(e,t){return e.x===t.x&&e.y===t.y}function G0(e,t,i,l){return cl(e,i)&&cl(t,l)||cl(e,l)&&cl(i,t)?!0:ur(e,t,i)>0!=ur(e,t,l)>0&&ur(i,l,e)>0!=ur(i,l,t)>0}function iS(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&G0(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Zh(e,t){return ur(e.prev,e,e.next)<0?ur(e,t,e.next)>=0&&ur(e,e.prev,t)>=0:ur(e,t,e.prev)<0||ur(e,e.next,t)<0}function rS(e,t){var i=e,l=!1,c=(e.x+t.x)/2,h=(e.y+t.y)/2;do i.y>h!=i.next.y>h&&i.next.y!==i.y&&c<(i.next.x-i.x)*(h-i.y)/(i.next.y-i.y)+i.x&&(l=!l),i=i.next;while(i!==e);return l}function W0(e,t){var i=new Qy(e.i,e.x,e.y),l=new Qy(t.i,t.x,t.y),c=e.next,h=t.prev;return e.next=t,t.prev=e,i.next=c,c.prev=i,l.next=i,i.prev=l,h.next=l,l.prev=h,l}function j0(e,t,i,l){var c=new Qy(e,t,i);return l?(c.next=l.next,c.prev=l,l.next.prev=c,l.next=c):(c.prev=c,c.next=c),c}function Yh(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Qy(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function oS(e,t,i,l){for(var c=0,h=t,f=i-l;h<i;h+=l)c+=(e[f]-e[h])*(e[h+1]+e[f+1]),f=h;return c}var ls={area:function(e){for(var t=e.length,i=0,l=t-1,c=0;c<t;l=c++)i+=e[l].x*e[c].y-e[c].x*e[l].y;return i*.5},isClockWise:function(e){return ls.area(e)<0},triangulateShape:function(e,t){var i=[],l=[],c=[];H0(e),$0(i,e);var h=e.length;t.forEach(H0);for(var f=0;f<t.length;f++)l.push(h),h+=t[f].length,$0(i,t[f]);for(var r=jP.triangulate(i,l),f=0;f<r.length;f+=3)c.push(r.slice(f,f+3));return c}};function H0(e){var t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function $0(e,t){for(var i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}function Uc(e,t){Bn.call(this),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},this.fromBufferGeometry(new za(e,t)),this.mergeVertices()}Uc.prototype=Object.create(Bn.prototype),Uc.prototype.constructor=Uc,Uc.prototype.toJSON=function(){var e=Bn.prototype.toJSON.call(this),t=this.parameters.shapes,i=this.parameters.options;return q0(t,i,e)};function za(e,t){vn.call(this),this.type="ExtrudeBufferGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];for(var i=this,l=[],c=[],h=0,f=e.length;h<f;h++){var r=e[h];v(r)}this.setAttribute("position",new ln(l,3)),this.setAttribute("uv",new ln(c,2)),this.computeVertexNormals();function v(x){var w=[],b=t.curveSegments!==void 0?t.curveSegments:12,A=t.steps!==void 0?t.steps:1,L=t.depth!==void 0?t.depth:100,P=t.bevelEnabled!==void 0?t.bevelEnabled:!0,R=t.bevelThickness!==void 0?t.bevelThickness:6,F=t.bevelSize!==void 0?t.bevelSize:R-2,V=t.bevelOffset!==void 0?t.bevelOffset:0,j=t.bevelSegments!==void 0?t.bevelSegments:3,J=t.extrudePath,ne=t.UVGenerator!==void 0?t.UVGenerator:aS;t.amount!==void 0&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),L=t.amount);var H,Q=!1,ae,ie,le,fe;J&&(H=J.getSpacedPoints(A),Q=!0,P=!1,ae=J.computeFrenetFrames(A,!1),ie=new Pe,le=new Pe,fe=new Pe),P||(j=0,R=0,F=0,V=0);var me,he,Oe,Ve=x.extractPoints(b),He=Ve.shape,at=Ve.holes,At=!ls.isClockWise(He);if(At)for(He=He.reverse(),he=0,Oe=at.length;he<Oe;he++)me=at[he],ls.isClockWise(me)&&(at[he]=me.reverse());var yt=ls.triangulateShape(He,at),Dt=He;for(he=0,Oe=at.length;he<Oe;he++)me=at[he],He=He.concat(me);function It(Wt,sn,Xt){return sn||console.error("THREE.ExtrudeGeometry: vec does not exist"),sn.clone().multiplyScalar(Xt).add(Wt)}var Nt,Ie,be,We,Ge,ke=He.length,ot,ge=yt.length;function Ce(Wt,sn,Xt){var Xe,Ut,en,Pn=Wt.x-sn.x,fn=Wt.y-sn.y,On=Xt.x-Wt.x,Gn=Xt.y-Wt.y,qn=Pn*Pn+fn*fn,ji=Pn*Gn-fn*On;if(Math.abs(ji)>Number.EPSILON){var Nn=Math.sqrt(qn),Di=Math.sqrt(On*On+Gn*Gn),ei=sn.x-fn/Nn,Ji=sn.y+Pn/Nn,_i=Xt.x-Gn/Di,jr=Xt.y+On/Di,zi=((_i-ei)*Gn-(jr-Ji)*On)/(Pn*Gn-fn*On);Xe=ei+Pn*zi-Wt.x,Ut=Ji+fn*zi-Wt.y;var Hr=Xe*Xe+Ut*Ut;if(Hr<=2)return new Lt(Xe,Ut);en=Math.sqrt(Hr/2)}else{var Ar=!1;Pn>Number.EPSILON?On>Number.EPSILON&&(Ar=!0):Pn<-Number.EPSILON?On<-Number.EPSILON&&(Ar=!0):Math.sign(fn)===Math.sign(Gn)&&(Ar=!0),Ar?(Xe=-fn,Ut=Pn,en=Math.sqrt(qn)):(Xe=Pn,Ut=fn,en=Math.sqrt(qn/2))}return new Lt(Xe/en,Ut/en)}for(var Ae=[],_e=0,Ne=Dt.length,Je=Ne-1,ct=_e+1;_e<Ne;_e++,Je++,ct++)Je===Ne&&(Je=0),ct===Ne&&(ct=0),Ae[_e]=Ce(Dt[_e],Dt[Je],Dt[ct]);var wt=[],Gt,pe=Ae.concat();for(he=0,Oe=at.length;he<Oe;he++){for(me=at[he],Gt=[],_e=0,Ne=me.length,Je=Ne-1,ct=_e+1;_e<Ne;_e++,Je++,ct++)Je===Ne&&(Je=0),ct===Ne&&(ct=0),Gt[_e]=Ce(me[_e],me[Je],me[ct]);wt.push(Gt),pe=pe.concat(Gt)}for(Nt=0;Nt<j;Nt++){for(be=Nt/j,We=R*Math.cos(be*Math.PI/2),Ie=F*Math.sin(be*Math.PI/2)+V,_e=0,Ne=Dt.length;_e<Ne;_e++)Ge=It(Dt[_e],Ae[_e],Ie),hn(Ge.x,Ge.y,-We);for(he=0,Oe=at.length;he<Oe;he++)for(me=at[he],Gt=wt[he],_e=0,Ne=me.length;_e<Ne;_e++)Ge=It(me[_e],Gt[_e],Ie),hn(Ge.x,Ge.y,-We)}for(Ie=F+V,_e=0;_e<ke;_e++)Ge=P?It(He[_e],pe[_e],Ie):He[_e],Q?(le.copy(ae.normals[0]).multiplyScalar(Ge.x),ie.copy(ae.binormals[0]).multiplyScalar(Ge.y),fe.copy(H[0]).add(le).add(ie),hn(fe.x,fe.y,fe.z)):hn(Ge.x,Ge.y,0);var Me;for(Me=1;Me<=A;Me++)for(_e=0;_e<ke;_e++)Ge=P?It(He[_e],pe[_e],Ie):He[_e],Q?(le.copy(ae.normals[Me]).multiplyScalar(Ge.x),ie.copy(ae.binormals[Me]).multiplyScalar(Ge.y),fe.copy(H[Me]).add(le).add(ie),hn(fe.x,fe.y,fe.z)):hn(Ge.x,Ge.y,L/A*Me);for(Nt=j-1;Nt>=0;Nt--){for(be=Nt/j,We=R*Math.cos(be*Math.PI/2),Ie=F*Math.sin(be*Math.PI/2)+V,_e=0,Ne=Dt.length;_e<Ne;_e++)Ge=It(Dt[_e],Ae[_e],Ie),hn(Ge.x,Ge.y,L+We);for(he=0,Oe=at.length;he<Oe;he++)for(me=at[he],Gt=wt[he],_e=0,Ne=me.length;_e<Ne;_e++)Ge=It(me[_e],Gt[_e],Ie),Q?hn(Ge.x,Ge.y+H[A-1].y,H[A-1].x+We):hn(Ge.x,Ge.y,L+We)}bt(),gt();function bt(){var Wt=l.length/3;if(P){var sn=0,Xt=ke*sn;for(_e=0;_e<ge;_e++)ot=yt[_e],nn(ot[2]+Xt,ot[1]+Xt,ot[0]+Xt);for(sn=A+j*2,Xt=ke*sn,_e=0;_e<ge;_e++)ot=yt[_e],nn(ot[0]+Xt,ot[1]+Xt,ot[2]+Xt)}else{for(_e=0;_e<ge;_e++)ot=yt[_e],nn(ot[2],ot[1],ot[0]);for(_e=0;_e<ge;_e++)ot=yt[_e],nn(ot[0]+ke*A,ot[1]+ke*A,ot[2]+ke*A)}i.addGroup(Wt,l.length/3-Wt,0)}function gt(){var Wt=l.length/3,sn=0;for(bn(Dt,sn),sn+=Dt.length,he=0,Oe=at.length;he<Oe;he++)me=at[he],bn(me,sn),sn+=me.length;i.addGroup(Wt,l.length/3-Wt,1)}function bn(Wt,sn){var Xt,Xe;for(_e=Wt.length;--_e>=0;){Xt=_e,Xe=_e-1,Xe<0&&(Xe=Wt.length-1);var Ut=0,en=A+j*2;for(Ut=0;Ut<en;Ut++){var Pn=ke*Ut,fn=ke*(Ut+1),On=sn+Xt+Pn,Gn=sn+Xe+Pn,qn=sn+Xe+fn,ji=sn+Xt+fn;pn(On,Gn,qn,ji)}}}function hn(Wt,sn,Xt){w.push(Wt),w.push(sn),w.push(Xt)}function nn(Wt,sn,Xt){wn(Wt),wn(sn),wn(Xt);var Xe=l.length/3,Ut=ne.generateTopUV(i,l,Xe-3,Xe-2,Xe-1);cn(Ut[0]),cn(Ut[1]),cn(Ut[2])}function pn(Wt,sn,Xt,Xe){wn(Wt),wn(sn),wn(Xe),wn(sn),wn(Xt),wn(Xe);var Ut=l.length/3,en=ne.generateSideWallUV(i,l,Ut-6,Ut-3,Ut-2,Ut-1);cn(en[0]),cn(en[1]),cn(en[3]),cn(en[1]),cn(en[2]),cn(en[3])}function wn(Wt){l.push(w[Wt*3+0]),l.push(w[Wt*3+1]),l.push(w[Wt*3+2])}function cn(Wt){c.push(Wt.x),c.push(Wt.y)}}}za.prototype=Object.create(vn.prototype),za.prototype.constructor=za,za.prototype.toJSON=function(){var e=vn.prototype.toJSON.call(this),t=this.parameters.shapes,i=this.parameters.options;return q0(t,i,e)};var aS={generateTopUV:function(e,t,i,l,c){var h=t[i*3],f=t[i*3+1],r=t[l*3],v=t[l*3+1],x=t[c*3],w=t[c*3+1];return[new Lt(h,f),new Lt(r,v),new Lt(x,w)]},generateSideWallUV:function(e,t,i,l,c,h){var f=t[i*3],r=t[i*3+1],v=t[i*3+2],x=t[l*3],w=t[l*3+1],b=t[l*3+2],A=t[c*3],L=t[c*3+1],P=t[c*3+2],R=t[h*3],F=t[h*3+1],V=t[h*3+2];return Math.abs(r-w)<.01?[new Lt(f,1-v),new Lt(x,1-b),new Lt(A,1-P),new Lt(R,1-V)]:[new Lt(r,1-v),new Lt(w,1-b),new Lt(L,1-P),new Lt(F,1-V)]}};function q0(e,t,i){if(i.shapes=[],Array.isArray(e))for(var l=0,c=e.length;l<c;l++){var h=e[l];i.shapes.push(h.uuid)}else i.shapes.push(e.uuid);return t.extrudePath!==void 0&&(i.options.extrudePath=t.extrudePath.toJSON()),i}function Xf(e,t){Bn.call(this),this.type="TextGeometry",this.parameters={text:e,parameters:t},this.fromBufferGeometry(new Kh(e,t)),this.mergeVertices()}Xf.prototype=Object.create(Bn.prototype),Xf.prototype.constructor=Xf;function Kh(e,t){t=t||{};var i=t.font;if(!(i&&i.isFont))return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new Bn;var l=i.generateShapes(e,t.size);t.depth=t.height!==void 0?t.height:50,t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),za.call(this,l,t),this.type="TextBufferGeometry"}Kh.prototype=Object.create(za.prototype),Kh.prototype.constructor=Kh;function Zf(e,t,i,l,c,h,f){Bn.call(this),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:l,phiLength:c,thetaStart:h,thetaLength:f},this.fromBufferGeometry(new Vc(e,t,i,l,c,h,f)),this.mergeVertices()}Zf.prototype=Object.create(Bn.prototype),Zf.prototype.constructor=Zf;function Vc(e,t,i,l,c,h,f){vn.call(this),this.type="SphereBufferGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:l,phiLength:c,thetaStart:h,thetaLength:f},e=e||1,t=Math.max(3,Math.floor(t)||8),i=Math.max(2,Math.floor(i)||6),l=l!==void 0?l:0,c=c!==void 0?c:Math.PI*2,h=h!==void 0?h:0,f=f!==void 0?f:Math.PI;var r=Math.min(h+f,Math.PI),v,x,w=0,b=[],A=new Pe,L=new Pe,P=[],R=[],F=[],V=[];for(x=0;x<=i;x++){var j=[],J=x/i,ne=0;for(x==0&&h==0?ne=.5/t:x==i&&r==Math.PI&&(ne=-.5/t),v=0;v<=t;v++){var H=v/t;A.x=-e*Math.cos(l+H*c)*Math.sin(h+J*f),A.y=e*Math.cos(h+J*f),A.z=e*Math.sin(l+H*c)*Math.sin(h+J*f),R.push(A.x,A.y,A.z),L.copy(A).normalize(),F.push(L.x,L.y,L.z),V.push(H+ne,1-J),j.push(w++)}b.push(j)}for(x=0;x<i;x++)for(v=0;v<t;v++){var Q=b[x][v+1],ae=b[x][v],ie=b[x+1][v],le=b[x+1][v+1];(x!==0||h>0)&&P.push(Q,ae,le),(x!==i-1||r<Math.PI)&&P.push(ae,ie,le)}this.setIndex(P),this.setAttribute("position",new ln(R,3)),this.setAttribute("normal",new ln(F,3)),this.setAttribute("uv",new ln(V,2))}Vc.prototype=Object.create(vn.prototype),Vc.prototype.constructor=Vc;function Yf(e,t,i,l,c,h){Bn.call(this),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:l,thetaStart:c,thetaLength:h},this.fromBufferGeometry(new Jh(e,t,i,l,c,h)),this.mergeVertices()}Yf.prototype=Object.create(Bn.prototype),Yf.prototype.constructor=Yf;function Jh(e,t,i,l,c,h){vn.call(this),this.type="RingBufferGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:l,thetaStart:c,thetaLength:h},e=e||.5,t=t||1,c=c!==void 0?c:0,h=h!==void 0?h:Math.PI*2,i=i!==void 0?Math.max(3,i):8,l=l!==void 0?Math.max(1,l):1;var f=[],r=[],v=[],x=[],w,b=e,A=(t-e)/l,L=new Pe,P=new Lt,R,F;for(R=0;R<=l;R++){for(F=0;F<=i;F++)w=c+F/i*h,L.x=b*Math.cos(w),L.y=b*Math.sin(w),r.push(L.x,L.y,L.z),v.push(0,0,1),P.x=(L.x/t+1)/2,P.y=(L.y/t+1)/2,x.push(P.x,P.y);b+=A}for(R=0;R<l;R++){var V=R*(i+1);for(F=0;F<i;F++){w=F+V;var j=w,J=w+i+1,ne=w+i+2,H=w+1;f.push(j,J,H),f.push(J,ne,H)}}this.setIndex(f),this.setAttribute("position",new ln(r,3)),this.setAttribute("normal",new ln(v,3)),this.setAttribute("uv",new ln(x,2))}Jh.prototype=Object.create(vn.prototype),Jh.prototype.constructor=Jh;function Kf(e,t,i,l){Bn.call(this),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:l},this.fromBufferGeometry(new Qh(e,t,i,l)),this.mergeVertices()}Kf.prototype=Object.create(Bn.prototype),Kf.prototype.constructor=Kf;function Qh(e,t,i,l){vn.call(this),this.type="LatheBufferGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:l},t=Math.floor(t)||12,i=i||0,l=l||Math.PI*2,l=jn.clamp(l,0,Math.PI*2);var c=[],h=[],f=[],r,v=1/t,x=new Pe,w=new Lt,b,A;for(b=0;b<=t;b++){var L=i+b*v*l,P=Math.sin(L),R=Math.cos(L);for(A=0;A<=e.length-1;A++)x.x=e[A].x*P,x.y=e[A].y,x.z=e[A].x*R,h.push(x.x,x.y,x.z),w.x=b/t,w.y=A/(e.length-1),f.push(w.x,w.y)}for(b=0;b<t;b++)for(A=0;A<e.length-1;A++){r=A+b*e.length;var F=r,V=r+e.length,j=r+e.length+1,J=r+1;c.push(F,V,J),c.push(V,j,J)}if(this.setIndex(c),this.setAttribute("position",new ln(h,3)),this.setAttribute("uv",new ln(f,2)),this.computeVertexNormals(),l===Math.PI*2){var ne=this.attributes.normal.array,H=new Pe,Q=new Pe,ae=new Pe;for(r=t*e.length*3,b=0,A=0;b<e.length;b++,A+=3)H.x=ne[A+0],H.y=ne[A+1],H.z=ne[A+2],Q.x=ne[r+A+0],Q.y=ne[r+A+1],Q.z=ne[r+A+2],ae.addVectors(H,Q).normalize(),ne[A+0]=ne[r+A+0]=ae.x,ne[A+1]=ne[r+A+1]=ae.y,ne[A+2]=ne[r+A+2]=ae.z}}Qh.prototype=Object.create(vn.prototype),Qh.prototype.constructor=Qh;function Gc(e,t){Bn.call(this),this.type="ShapeGeometry",typeof t=="object"&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),t=t.curveSegments),this.parameters={shapes:e,curveSegments:t},this.fromBufferGeometry(new Wc(e,t)),this.mergeVertices()}Gc.prototype=Object.create(Bn.prototype),Gc.prototype.constructor=Gc,Gc.prototype.toJSON=function(){var e=Bn.prototype.toJSON.call(this),t=this.parameters.shapes;return X0(t,e)};function Wc(e,t){vn.call(this),this.type="ShapeBufferGeometry",this.parameters={shapes:e,curveSegments:t},t=t||12;var i=[],l=[],c=[],h=[],f=0,r=0;if(Array.isArray(e)===!1)x(e);else for(var v=0;v<e.length;v++)x(e[v]),this.addGroup(f,r,v),f+=r,r=0;this.setIndex(i),this.setAttribute("position",new ln(l,3)),this.setAttribute("normal",new ln(c,3)),this.setAttribute("uv",new ln(h,2));function x(w){var b,A,L,P=l.length/3,R=w.extractPoints(t),F=R.shape,V=R.holes;for(ls.isClockWise(F)===!1&&(F=F.reverse()),b=0,A=V.length;b<A;b++)L=V[b],ls.isClockWise(L)===!0&&(V[b]=L.reverse());var j=ls.triangulateShape(F,V);for(b=0,A=V.length;b<A;b++)L=V[b],F=F.concat(L);for(b=0,A=F.length;b<A;b++){var J=F[b];l.push(J.x,J.y,0),c.push(0,0,1),h.push(J.x,J.y)}for(b=0,A=j.length;b<A;b++){var ne=j[b],H=ne[0]+P,Q=ne[1]+P,ae=ne[2]+P;i.push(H,Q,ae),r+=3}}}Wc.prototype=Object.create(vn.prototype),Wc.prototype.constructor=Wc,Wc.prototype.toJSON=function(){var e=vn.prototype.toJSON.call(this),t=this.parameters.shapes;return X0(t,e)};function X0(e,t){if(t.shapes=[],Array.isArray(e))for(var i=0,l=e.length;i<l;i++){var c=e[i];t.shapes.push(c.uuid)}else t.shapes.push(e.uuid);return t}function Jf(e,t){vn.call(this),this.type="EdgesGeometry",this.parameters={thresholdAngle:t},t=t!==void 0?t:1;var i=[],l=Math.cos(jn.DEG2RAD*t),c=[0,0],h={},f,r,v,x=["a","b","c"],w;e.isBufferGeometry?(w=new Bn,w.fromBufferGeometry(e)):w=e.clone(),w.mergeVertices(),w.computeFaceNormals();for(var b=w.vertices,A=w.faces,L=0,P=A.length;L<P;L++)for(var R=A[L],F=0;F<3;F++)f=R[x[F]],r=R[x[(F+1)%3]],c[0]=Math.min(f,r),c[1]=Math.max(f,r),v=c[0]+","+c[1],h[v]===void 0?h[v]={index1:c[0],index2:c[1],face1:L,face2:void 0}:h[v].face2=L;for(v in h){var V=h[v];if(V.face2===void 0||A[V.face1].normal.dot(A[V.face2].normal)<=l){var j=b[V.index1];i.push(j.x,j.y,j.z),j=b[V.index2],i.push(j.x,j.y,j.z)}}this.setAttribute("position",new ln(i,3))}Jf.prototype=Object.create(vn.prototype),Jf.prototype.constructor=Jf;function jc(e,t,i,l,c,h,f,r){Bn.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:l,heightSegments:c,openEnded:h,thetaStart:f,thetaLength:r},this.fromBufferGeometry(new cs(e,t,i,l,c,h,f,r)),this.mergeVertices()}jc.prototype=Object.create(Bn.prototype),jc.prototype.constructor=jc;function cs(e,t,i,l,c,h,f,r){vn.call(this),this.type="CylinderBufferGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:l,heightSegments:c,openEnded:h,thetaStart:f,thetaLength:r};var v=this;e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,l=Math.floor(l)||8,c=Math.floor(c)||1,h=h!==void 0?h:!1,f=f!==void 0?f:0,r=r!==void 0?r:Math.PI*2;var x=[],w=[],b=[],A=[],L=0,P=[],R=i/2,F=0;V(),h===!1&&(e>0&&j(!0),t>0&&j(!1)),this.setIndex(x),this.setAttribute("position",new ln(w,3)),this.setAttribute("normal",new ln(b,3)),this.setAttribute("uv",new ln(A,2));function V(){var J,ne,H=new Pe,Q=new Pe,ae=0,ie=(t-e)/i;for(ne=0;ne<=c;ne++){var le=[],fe=ne/c,me=fe*(t-e)+e;for(J=0;J<=l;J++){var he=J/l,Oe=he*r+f,Ve=Math.sin(Oe),He=Math.cos(Oe);Q.x=me*Ve,Q.y=-fe*i+R,Q.z=me*He,w.push(Q.x,Q.y,Q.z),H.set(Ve,ie,He).normalize(),b.push(H.x,H.y,H.z),A.push(he,1-fe),le.push(L++)}P.push(le)}for(J=0;J<l;J++)for(ne=0;ne<c;ne++){var at=P[ne][J],At=P[ne+1][J],yt=P[ne+1][J+1],Dt=P[ne][J+1];x.push(at,At,Dt),x.push(At,yt,Dt),ae+=6}v.addGroup(F,ae,0),F+=ae}function j(J){var ne,H,Q,ae=new Lt,ie=new Pe,le=0,fe=J===!0?e:t,me=J===!0?1:-1;for(H=L,ne=1;ne<=l;ne++)w.push(0,R*me,0),b.push(0,me,0),A.push(.5,.5),L++;for(Q=L,ne=0;ne<=l;ne++){var he=ne/l,Oe=he*r+f,Ve=Math.cos(Oe),He=Math.sin(Oe);ie.x=fe*He,ie.y=R*me,ie.z=fe*Ve,w.push(ie.x,ie.y,ie.z),b.push(0,me,0),ae.x=Ve*.5+.5,ae.y=He*.5*me+.5,A.push(ae.x,ae.y),L++}for(ne=0;ne<l;ne++){var at=H+ne,At=Q+ne;J===!0?x.push(At,At+1,at):x.push(At+1,At,at),le+=3}v.addGroup(F,le,J===!0?1:2),F+=le}}cs.prototype=Object.create(vn.prototype),cs.prototype.constructor=cs;function Qf(e,t,i,l,c,h,f){jc.call(this,0,e,t,i,l,c,h,f),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:l,openEnded:c,thetaStart:h,thetaLength:f}}Qf.prototype=Object.create(jc.prototype),Qf.prototype.constructor=Qf;function em(e,t,i,l,c,h,f){cs.call(this,0,e,t,i,l,c,h,f),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:l,openEnded:c,thetaStart:h,thetaLength:f}}em.prototype=Object.create(cs.prototype),em.prototype.constructor=em;function tm(e,t,i,l){Bn.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:l},this.fromBufferGeometry(new ed(e,t,i,l)),this.mergeVertices()}tm.prototype=Object.create(Bn.prototype),tm.prototype.constructor=tm;function ed(e,t,i,l){vn.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:l},e=e||1,t=t!==void 0?Math.max(3,t):8,i=i!==void 0?i:0,l=l!==void 0?l:Math.PI*2;var c=[],h=[],f=[],r=[],v,x,w=new Pe,b=new Lt;for(h.push(0,0,0),f.push(0,0,1),r.push(.5,.5),x=0,v=3;x<=t;x++,v+=3){var A=i+x/t*l;w.x=e*Math.cos(A),w.y=e*Math.sin(A),h.push(w.x,w.y,w.z),f.push(0,0,1),b.x=(h[v]/e+1)/2,b.y=(h[v+1]/e+1)/2,r.push(b.x,b.y)}for(v=1;v<=t;v++)c.push(v,v+1,0);this.setIndex(c),this.setAttribute("position",new ln(h,3)),this.setAttribute("normal",new ln(f,3)),this.setAttribute("uv",new ln(r,2))}ed.prototype=Object.create(vn.prototype),ed.prototype.constructor=ed;var Er=Object.freeze({__proto__:null,WireframeGeometry:Of,ParametricGeometry:Nf,ParametricBufferGeometry:Vh,TetrahedronGeometry:Vf,TetrahedronBufferGeometry:Gh,OctahedronGeometry:Gf,OctahedronBufferGeometry:Bc,IcosahedronGeometry:Wf,IcosahedronBufferGeometry:Wh,DodecahedronGeometry:jf,DodecahedronBufferGeometry:jh,PolyhedronGeometry:Uf,PolyhedronBufferGeometry:lo,TubeGeometry:Hf,TubeBufferGeometry:Oc,TorusKnotGeometry:$f,TorusKnotBufferGeometry:Hh,TorusGeometry:qf,TorusBufferGeometry:$h,TextGeometry:Xf,TextBufferGeometry:Kh,SphereGeometry:Zf,SphereBufferGeometry:Vc,RingGeometry:Yf,RingBufferGeometry:Jh,PlaneGeometry:bf,PlaneBufferGeometry:Sc,LatheGeometry:Kf,LatheBufferGeometry:Qh,ShapeGeometry:Gc,ShapeBufferGeometry:Wc,ExtrudeGeometry:Uc,ExtrudeBufferGeometry:za,EdgesGeometry:Jf,ConeGeometry:Qf,ConeBufferGeometry:em,CylinderGeometry:jc,CylinderBufferGeometry:cs,CircleGeometry:tm,CircleBufferGeometry:ed,BoxGeometry:ZE,BoxBufferGeometry:vf});function Hc(e){Rn.call(this),this.type="ShadowMaterial",this.color=new tn(0),this.transparent=!0,this.setValues(e)}Hc.prototype=Object.create(Rn.prototype),Hc.prototype.constructor=Hc,Hc.prototype.isShadowMaterial=!0,Hc.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.color.copy(e.color),this};function us(e){Ur.call(this,e),this.type="RawShaderMaterial"}us.prototype=Object.create(Ur.prototype),us.prototype.constructor=us,us.prototype.isRawShaderMaterial=!0;function Vr(e){Rn.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new tn(16777215),this.roughness=1,this.metalness=0,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=Ys,this.normalScale=new Lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}Vr.prototype=Object.create(Rn.prototype),Vr.prototype.constructor=Vr,Vr.prototype.isMeshStandardMaterial=!0,Vr.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,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.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this};function $c(e){Vr.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearcoat=0,this.clearcoatRoughness=0,this.sheen=null,this.clearcoatNormalScale=new Lt(1,1),this.clearcoatNormalMap=null,this.transparency=0,this.setValues(e)}$c.prototype=Object.create(Vr.prototype),$c.prototype.constructor=$c,$c.prototype.isMeshPhysicalMaterial=!0,$c.prototype.copy=function(e){return Vr.prototype.copy.call(this,e),this.defines={STANDARD:"",PHYSICAL:""},this.reflectivity=e.reflectivity,this.clearcoat=e.clearcoat,this.clearcoatRoughness=e.clearcoatRoughness,e.sheen?this.sheen=(this.sheen||new tn).copy(e.sheen):this.sheen=null,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.transparency=e.transparency,this};function ul(e){Rn.call(this),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=Ys,this.normalScale=new Lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Xp,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}ul.prototype=Object.create(Rn.prototype),ul.prototype.constructor=ul,ul.prototype.isMeshPhongMaterial=!0,ul.prototype.copy=function(e){return Rn.prototype.copy.call(this,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.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.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this};function qc(e){Rn.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new tn(16777215),this.specular=new tn(1118481),this.shininess=30,this.map=null,this.gradientMap=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=Ys,this.normalScale=new Lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}qc.prototype=Object.create(Rn.prototype),qc.prototype.constructor=qc,qc.prototype.isMeshToonMaterial=!0,qc.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.gradientMap=e.gradientMap,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.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this};function Xc(e){Rn.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ys,this.normalScale=new Lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}Xc.prototype=Object.create(Rn.prototype),Xc.prototype.constructor=Xc,Xc.prototype.isMeshNormalMaterial=!0,Xc.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),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.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this};function Zc(e){Rn.call(this),this.type="MeshLambertMaterial",this.color=new tn(16777215),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.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Xp,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}Zc.prototype=Object.create(Rn.prototype),Zc.prototype.constructor=Zc,Zc.prototype.isMeshLambertMaterial=!0,Zc.prototype.copy=function(e){return Rn.prototype.copy.call(this,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.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.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this};function Yc(e){Rn.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new tn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ys,this.normalScale=new Lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}Yc.prototype=Object.create(Rn.prototype),Yc.prototype.constructor=Yc,Yc.prototype.isMeshMatcapMaterial=!0,Yc.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,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.alphaMap=e.alphaMap,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this};function Kc(e){Ri.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}Kc.prototype=Object.create(Ri.prototype),Kc.prototype.constructor=Kc,Kc.prototype.isLineDashedMaterial=!0,Kc.prototype.copy=function(e){return Ri.prototype.copy.call(this,e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this};var sS=Object.freeze({__proto__:null,ShadowMaterial:Hc,SpriteMaterial:ll,RawShaderMaterial:us,ShaderMaterial:Ur,PointsMaterial:ss,MeshPhysicalMaterial:$c,MeshStandardMaterial:Vr,MeshPhongMaterial:ul,MeshToonMaterial:qc,MeshNormalMaterial:Xc,MeshLambertMaterial:Zc,MeshDepthMaterial:rl,MeshDistanceMaterial:ol,MeshBasicMaterial:cr,MeshMatcapMaterial:Yc,LineDashedMaterial:Kc,LineBasicMaterial:Ri,Material:Rn}),Gi={arraySlice:function(e,t,i){return Gi.isTypedArray(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)},convertArray:function(e,t,i){return!e||!i&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){function t(h,f){return e[h]-e[f]}for(var i=e.length,l=new Array(i),c=0;c!==i;++c)l[c]=c;return l.sort(t),l},sortedArray:function(e,t,i){for(var l=e.length,c=new e.constructor(l),h=0,f=0;f!==l;++h)for(var r=i[h]*t,v=0;v!==t;++v)c[f++]=e[r+v];return c},flattenJSON:function(e,t,i,l){for(var c=1,h=e[0];h!==void 0&&h[l]===void 0;)h=e[c++];if(h!==void 0){var f=h[l];if(f!==void 0)if(Array.isArray(f))do f=h[l],f!==void 0&&(t.push(h.time),i.push.apply(i,f)),h=e[c++];while(h!==void 0);else if(f.toArray!==void 0)do f=h[l],f!==void 0&&(t.push(h.time),f.toArray(i,i.length)),h=e[c++];while(h!==void 0);else do f=h[l],f!==void 0&&(t.push(h.time),i.push(f)),h=e[c++];while(h!==void 0)}},subclip:function(e,t,i,l,c){c=c||30;var h=e.clone();h.name=t;for(var f=[],r=0;r<h.tracks.length;++r){for(var v=h.tracks[r],x=v.getValueSize(),w=[],b=[],A=0;A<v.times.length;++A){var L=v.times[A]*c;if(!(L<i||L>=l)){w.push(v.times[A]);for(var P=0;P<x;++P)b.push(v.values[A*x+P])}}w.length!==0&&(v.times=Gi.convertArray(w,v.times.constructor),v.values=Gi.convertArray(b,v.values.constructor),f.push(v))}h.tracks=f;for(var R=1/0,r=0;r<h.tracks.length;++r)R>h.tracks[r].times[0]&&(R=h.tracks[r].times[0]);for(var r=0;r<h.tracks.length;++r)h.tracks[r].shift(-1*R);return h.resetDuration(),h}};function Gr(e,t,i,l){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=l!==void 0?l:new t.constructor(i),this.sampleValues=t,this.valueSize=i}Object.assign(Gr.prototype,{evaluate:function(e){var t=this.parameterPositions,i=this._cachedIndex,l=t[i],c=t[i-1];e:{t:{var h;n:{i:if(!(e<l)){for(var f=i+2;;){if(l===void 0){if(e<c)break i;return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,e,c)}if(i===f)break;if(c=l,l=t[++i],e<l)break t}h=t.length;break n}if(!(e>=c)){var r=t[1];e<r&&(i=2,c=r);for(var f=i-2;;){if(c===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,l);if(i===f)break;if(l=c,c=t[--i-1],e>=c)break t}h=i,i=0;break n}break e}for(;i<h;){var v=i+h>>>1;e<t[v]?h=v:i=v+1}if(l=t[i],c=t[i-1],c===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,l);if(l===void 0)return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,c,e)}this._cachedIndex=i,this.intervalChanged_(i,c,l)}return this.interpolate_(i,c,e,l)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(e){for(var t=this.resultBuffer,i=this.sampleValues,l=this.valueSize,c=e*l,h=0;h!==l;++h)t[h]=i[c+h];return t},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}});//!\ DECLARE ALIAS AFTER assign prototype !
- Object.assign(Gr.prototype,{beforeStart_:Gr.prototype.copySampleValue_,afterEnd_:Gr.prototype.copySampleValue_});function e_(e,t,i,l){Gr.call(this,e,t,i,l),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}e_.prototype=Object.assign(Object.create(Gr.prototype),{constructor:e_,DefaultSettings_:{endingStart:lc,endingEnd:lc},intervalChanged_:function(e,t,i){var l=this.parameterPositions,c=e-2,h=e+1,f=l[c],r=l[h];if(f===void 0)switch(this.getSettings_().endingStart){case cc:c=e,f=2*t-i;break;case tf:c=l.length-2,f=t+l[c]-l[c+1];break;default:c=e,f=i}if(r===void 0)switch(this.getSettings_().endingEnd){case cc:h=e,r=2*i-t;break;case tf:h=1,r=i+l[1]-l[0];break;default:h=e-1,r=t}var v=(i-t)*.5,x=this.valueSize;this._weightPrev=v/(t-f),this._weightNext=v/(r-i),this._offsetPrev=c*x,this._offsetNext=h*x},interpolate_:function(e,t,i,l){for(var c=this.resultBuffer,h=this.sampleValues,f=this.valueSize,r=e*f,v=r-f,x=this._offsetPrev,w=this._offsetNext,b=this._weightPrev,A=this._weightNext,L=(i-t)/(l-t),P=L*L,R=P*L,F=-b*R+2*b*P-b*L,V=(1+b)*R+(-1.5-2*b)*P+(-.5+b)*L+1,j=(-1-A)*R+(1.5+A)*P+.5*L,J=A*R-A*P,ne=0;ne!==f;++ne)c[ne]=F*h[x+ne]+V*h[v+ne]+j*h[r+ne]+J*h[w+ne];return c}});function nm(e,t,i,l){Gr.call(this,e,t,i,l)}nm.prototype=Object.assign(Object.create(Gr.prototype),{constructor:nm,interpolate_:function(e,t,i,l){for(var c=this.resultBuffer,h=this.sampleValues,f=this.valueSize,r=e*f,v=r-f,x=(i-t)/(l-t),w=1-x,b=0;b!==f;++b)c[b]=h[v+b]*w+h[r+b]*x;return c}});function t_(e,t,i,l){Gr.call(this,e,t,i,l)}t_.prototype=Object.assign(Object.create(Gr.prototype),{constructor:t_,interpolate_:function(e){return this.copySampleValue_(e-1)}});function mr(e,t,i,l){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Gi.convertArray(t,this.TimeBufferType),this.values=Gi.convertArray(i,this.ValueBufferType),this.setInterpolation(l||this.DefaultInterpolation)}Object.assign(mr,{toJSON:function(e){var t=e.constructor,i;if(t.toJSON!==void 0)i=t.toJSON(e);else{i={name:e.name,times:Gi.convertArray(e.times,Array),values:Gi.convertArray(e.values,Array)};var l=e.getInterpolation();l!==e.DefaultInterpolation&&(i.interpolation=l)}return i.type=e.ValueTypeName,i}}),Object.assign(mr.prototype,{constructor:mr,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:sc,InterpolantFactoryMethodDiscrete:function(e){return new t_(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodLinear:function(e){return new nm(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:function(e){return new e_(this.times,this.values,this.getValueSize(),e)},setInterpolation:function(e){var t;switch(e){case yh:t=this.InterpolantFactoryMethodDiscrete;break;case sc:t=this.InterpolantFactoryMethodLinear;break;case dy:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){var i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return yh;case this.InterpolantFactoryMethodLinear:return sc;case this.InterpolantFactoryMethodSmooth:return dy}},getValueSize:function(){return this.values.length/this.times.length},shift:function(e){if(e!==0)for(var t=this.times,i=0,l=t.length;i!==l;++i)t[i]+=e;return this},scale:function(e){if(e!==1)for(var t=this.times,i=0,l=t.length;i!==l;++i)t[i]*=e;return this},trim:function(e,t){for(var i=this.times,l=i.length,c=0,h=l-1;c!==l&&i[c]<e;)++c;for(;h!==-1&&i[h]>t;)--h;if(++h,c!==0||h!==l){c>=h&&(h=Math.max(h,1),c=h-1);var f=this.getValueSize();this.times=Gi.arraySlice(i,c,h),this.values=Gi.arraySlice(this.values,c*f,h*f)}return this},validate:function(){var e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);var i=this.times,l=this.values,c=i.length;c===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);for(var h=null,f=0;f!==c;f++){var r=i[f];if(typeof r=="number"&&isNaN(r)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,f,r),e=!1;break}if(h!==null&&h>r){console.error("THREE.KeyframeTrack: Out of order keys.",this,f,r,h),e=!1;break}h=r}if(l!==void 0&&Gi.isTypedArray(l))for(var f=0,v=l.length;f!==v;++f){var x=l[f];if(isNaN(x)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,f,x),e=!1;break}}return e},optimize:function(){for(var e=Gi.arraySlice(this.times),t=Gi.arraySlice(this.values),i=this.getValueSize(),l=this.getInterpolation()===dy,c=1,h=e.length-1,f=1;f<h;++f){var r=!1,v=e[f],x=e[f+1];if(v!==x&&(f!==1||v!==v[0]))if(l)r=!0;else for(var w=f*i,b=w-i,A=w+i,L=0;L!==i;++L){var P=t[w+L];if(P!==t[b+L]||P!==t[A+L]){r=!0;break}}if(r){if(f!==c){e[c]=e[f];for(var R=f*i,F=c*i,L=0;L!==i;++L)t[F+L]=t[R+L]}++c}}if(h>0){e[c]=e[h];for(var R=h*i,F=c*i,L=0;L!==i;++L)t[F+L]=t[R+L];++c}return c!==e.length?(this.times=Gi.arraySlice(e,0,c),this.values=Gi.arraySlice(t,0,c*i)):(this.times=e,this.values=t),this},clone:function(){var e=Gi.arraySlice(this.times,0),t=Gi.arraySlice(this.values,0),i=this.constructor,l=new i(this.name,e,t);return l.createInterpolant=this.createInterpolant,l}});function n_(e,t,i){mr.call(this,e,t,i)}n_.prototype=Object.assign(Object.create(mr.prototype),{constructor:n_,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:yh,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function i_(e,t,i,l){mr.call(this,e,t,i,l)}i_.prototype=Object.assign(Object.create(mr.prototype),{constructor:i_,ValueTypeName:"color"});function Jc(e,t,i,l){mr.call(this,e,t,i,l)}Jc.prototype=Object.assign(Object.create(mr.prototype),{constructor:Jc,ValueTypeName:"number"});function r_(e,t,i,l){Gr.call(this,e,t,i,l)}r_.prototype=Object.assign(Object.create(Gr.prototype),{constructor:r_,interpolate_:function(e,t,i,l){for(var c=this.resultBuffer,h=this.sampleValues,f=this.valueSize,r=e*f,v=(i-t)/(l-t),x=r+f;r!==x;r+=4)Nr.slerpFlat(c,0,h,r-f,h,r,v);return c}});function td(e,t,i,l){mr.call(this,e,t,i,l)}td.prototype=Object.assign(Object.create(mr.prototype),{constructor:td,ValueTypeName:"quaternion",DefaultInterpolation:sc,InterpolantFactoryMethodLinear:function(e){return new r_(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0});function o_(e,t,i,l){mr.call(this,e,t,i,l)}o_.prototype=Object.assign(Object.create(mr.prototype),{constructor:o_,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:yh,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function Qc(e,t,i,l){mr.call(this,e,t,i,l)}Qc.prototype=Object.assign(Object.create(mr.prototype),{constructor:Qc,ValueTypeName:"vector"});function vo(e,t,i){this.name=e,this.tracks=i,this.duration=t!==void 0?t:-1,this.uuid=jn.generateUUID(),this.duration<0&&this.resetDuration()}function lS(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Jc;case"vector":case"vector2":case"vector3":case"vector4":return Qc;case"color":return i_;case"quaternion":return td;case"bool":case"boolean":return n_;case"string":return o_}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function cS(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");var t=lS(e.type);if(e.times===void 0){var i=[],l=[];Gi.flattenJSON(e.keys,i,l,"value"),e.times=i,e.values=l}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}Object.assign(vo,{parse:function(e){for(var t=[],i=e.tracks,l=1/(e.fps||1),c=0,h=i.length;c!==h;++c)t.push(cS(i[c]).scale(l));return new vo(e.name,e.duration,t)},toJSON:function(e){for(var t=[],i=e.tracks,l={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid},c=0,h=i.length;c!==h;++c)t.push(mr.toJSON(i[c]));return l},CreateFromMorphTargetSequence:function(e,t,i,l){for(var c=t.length,h=[],f=0;f<c;f++){var r=[],v=[];r.push((f+c-1)%c,f,(f+1)%c),v.push(0,1,0);var x=Gi.getKeyframeOrder(r);r=Gi.sortedArray(r,1,x),v=Gi.sortedArray(v,1,x),!l&&r[0]===0&&(r.push(c),v.push(v[0])),h.push(new Jc(".morphTargetInfluences["+t[f].name+"]",r,v).scale(1/i))}return new vo(e,-1,h)},findByName:function(e,t){var i=e;if(!Array.isArray(e)){var l=e;i=l.geometry&&l.geometry.animations||l.animations}for(var c=0;c<i.length;c++)if(i[c].name===t)return i[c];return null},CreateClipsFromMorphTargetSequences:function(e,t,i){for(var l={},c=/^([\w-]*?)([\d]+)$/,h=0,f=e.length;h<f;h++){var r=e[h],v=r.name.match(c);if(v&&v.length>1){var x=v[1],w=l[x];w||(l[x]=w=[]),w.push(r)}}var b=[];for(var x in l)b.push(vo.CreateFromMorphTargetSequence(x,l[x],t,i));return b},parseAnimation:function(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var i=function(J,ne,H,Q,ae){if(H.length!==0){var ie=[],le=[];Gi.flattenJSON(H,ie,le,Q),ie.length!==0&&ae.push(new J(ne,ie,le))}},l=[],c=e.name||"default",h=e.length||-1,f=e.fps||30,r=e.hierarchy||[],v=0;v<r.length;v++){var x=r[v].keys;if(!(!x||x.length===0))if(x[0].morphTargets){for(var w={},b=0;b<x.length;b++)if(x[b].morphTargets)for(var A=0;A<x[b].morphTargets.length;A++)w[x[b].morphTargets[A]]=-1;for(var L in w){for(var P=[],R=[],A=0;A!==x[b].morphTargets.length;++A){var F=x[b];P.push(F.time),R.push(F.morphTarget===L?1:0)}l.push(new Jc(".morphTargetInfluence["+L+"]",P,R))}h=w.length*(f||1)}else{var V=".bones["+t[v].name+"]";i(Qc,V+".position",x,"pos",l),i(td,V+".quaternion",x,"rot",l),i(Qc,V+".scale",x,"scl",l)}}if(l.length===0)return null;var j=new vo(c,h,l);return j}}),Object.assign(vo.prototype,{resetDuration:function(){for(var e=this.tracks,t=0,i=0,l=e.length;i!==l;++i){var c=this.tracks[i];t=Math.max(t,c.times[c.times.length-1])}return this.duration=t,this},trim:function(){for(var e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this},validate:function(){for(var e=!0,t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e},optimize:function(){for(var e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this},clone:function(){for(var e=[],t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new vo(this.name,this.duration,e)}});var eu={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function Z0(e,t,i){var l=this,c=!1,h=0,f=0,r=void 0,v=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(x){f++,c===!1&&l.onStart!==void 0&&l.onStart(x,h,f),c=!0},this.itemEnd=function(x){h++,l.onProgress!==void 0&&l.onProgress(x,h,f),h===f&&(c=!1,l.onLoad!==void 0&&l.onLoad())},this.itemError=function(x){l.onError!==void 0&&l.onError(x)},this.resolveURL=function(x){return r?r(x):x},this.setURLModifier=function(x){return r=x,this},this.addHandler=function(x,w){return v.push(x,w),this},this.removeHandler=function(x){var w=v.indexOf(x);return w!==-1&&v.splice(w,2),this},this.getHandler=function(x){for(var w=0,b=v.length;w<b;w+=2){var A=v[w],L=v[w+1];if(A.global&&(A.lastIndex=0),A.test(x))return L}return null}}var uS=new Z0;function ri(e){this.manager=e!==void 0?e:uS,this.crossOrigin="anonymous",this.path="",this.resourcePath=""}Object.assign(ri.prototype,{load:function(){},parse:function(){},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this},setResourcePath:function(e){return this.resourcePath=e,this}});var Io={};function xo(e){ri.call(this,e)}xo.prototype=Object.assign(Object.create(ri.prototype),{constructor:xo,load:function(e,t,i,l){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);var c=this,h=eu.get(e);if(h!==void 0)return c.manager.itemStart(e),setTimeout(function(){t&&t(h),c.manager.itemEnd(e)},0),h;if(Io[e]!==void 0){Io[e].push({onLoad:t,onProgress:i,onError:l});return}var f=/^data:(.*?)(;base64)?,(.*)$/,r=e.match(f);if(r){var v=r[1],x=!!r[2],w=r[3];w=decodeURIComponent(w),x&&(w=atob(w));try{var b,A=(this.responseType||"").toLowerCase();switch(A){case"arraybuffer":case"blob":for(var L=new Uint8Array(w.length),P=0;P<w.length;P++)L[P]=w.charCodeAt(P);A==="blob"?b=new Blob([L.buffer],{type:v}):b=L.buffer;break;case"document":var R=new DOMParser;b=R.parseFromString(w,v);break;case"json":b=JSON.parse(w);break;default:b=w;break}setTimeout(function(){t&&t(b),c.manager.itemEnd(e)},0)}catch(j){setTimeout(function(){l&&l(j),c.manager.itemError(e),c.manager.itemEnd(e)},0)}}else{Io[e]=[],Io[e].push({onLoad:t,onProgress:i,onError:l});var F=new XMLHttpRequest;F.open("GET",e,!0),F.addEventListener("load",function(j){var J=this.response,ne=Io[e];if(delete Io[e],this.status===200||this.status===0){this.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),eu.add(e,J);for(var H=0,Q=ne.length;H<Q;H++){var ae=ne[H];ae.onLoad&&ae.onLoad(J)}c.manager.itemEnd(e)}else{for(var H=0,Q=ne.length;H<Q;H++){var ae=ne[H];ae.onError&&ae.onError(j)}c.manager.itemError(e),c.manager.itemEnd(e)}},!1),F.addEventListener("progress",function(j){for(var J=Io[e],ne=0,H=J.length;ne<H;ne++){var Q=J[ne];Q.onProgress&&Q.onProgress(j)}},!1),F.addEventListener("error",function(j){var J=Io[e];delete Io[e];for(var ne=0,H=J.length;ne<H;ne++){var Q=J[ne];Q.onError&&Q.onError(j)}c.manager.itemError(e),c.manager.itemEnd(e)},!1),F.addEventListener("abort",function(j){var J=Io[e];delete Io[e];for(var ne=0,H=J.length;ne<H;ne++){var Q=J[ne];Q.onError&&Q.onError(j)}c.manager.itemError(e),c.manager.itemEnd(e)},!1),this.responseType!==void 0&&(F.responseType=this.responseType),this.withCredentials!==void 0&&(F.withCredentials=this.withCredentials),F.overrideMimeType&&F.overrideMimeType(this.mimeType!==void 0?this.mimeType:"text/plain");for(var V in this.requestHeader)F.setRequestHeader(V,this.requestHeader[V]);F.send(null)}return c.manager.itemStart(e),F},setResponseType:function(e){return this.responseType=e,this},setWithCredentials:function(e){return this.withCredentials=e,this},setMimeType:function(e){return this.mimeType=e,this},setRequestHeader:function(e){return this.requestHeader=e,this}});function Y0(e){ri.call(this,e)}Y0.prototype=Object.assign(Object.create(ri.prototype),{constructor:Y0,load:function(e,t,i,l){var c=this,h=new xo(c.manager);h.setPath(c.path),h.load(e,function(f){t(c.parse(JSON.parse(f)))},i,l)},parse:function(e){for(var t=[],i=0;i<e.length;i++){var l=vo.parse(e[i]);t.push(l)}return t}});function K0(e){ri.call(this,e)}K0.prototype=Object.assign(Object.create(ri.prototype),{constructor:K0,load:function(e,t,i,l){var c=this,h=[],f=new Uh;f.image=h;var r=new xo(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer");function v(A){r.load(e[A],function(L){var P=c.parse(L,!0);h[A]={width:P.width,height:P.height,format:P.format,mipmaps:P.mipmaps},x+=1,x===6&&(P.mipmapCount===1&&(f.minFilter=$i),f.format=P.format,f.needsUpdate=!0,t&&t(f))},i,l)}if(Array.isArray(e))for(var x=0,w=0,b=e.length;w<b;++w)v(w);else r.load(e,function(A){var L=c.parse(A,!0);if(L.isCubemap)for(var P=L.mipmaps.length/L.mipmapCount,R=0;R<P;R++){h[R]={mipmaps:[]};for(var F=0;F<L.mipmapCount;F++)h[R].mipmaps.push(L.mipmaps[R*L.mipmapCount+F]),h[R].format=L.format,h[R].width=L.width,h[R].height=L.height}else f.image.width=L.width,f.image.height=L.height,f.mipmaps=L.mipmaps;L.mipmapCount===1&&(f.minFilter=$i),f.format=L.format,f.needsUpdate=!0,t&&t(f)},i,l);return f}});function J0(e){ri.call(this,e)}J0.prototype=Object.assign(Object.create(ri.prototype),{constructor:J0,load:function(e,t,i,l){var c=this,h=new Dc,f=new xo(this.manager);return f.setResponseType("arraybuffer"),f.setPath(this.path),f.load(e,function(r){var v=c.parse(r);v&&(v.image!==void 0?h.image=v.image:v.data!==void 0&&(h.image.width=v.width,h.image.height=v.height,h.image.data=v.data),h.wrapS=v.wrapS!==void 0?v.wrapS:Mr,h.wrapT=v.wrapT!==void 0?v.wrapT:Mr,h.magFilter=v.magFilter!==void 0?v.magFilter:$i,h.minFilter=v.minFilter!==void 0?v.minFilter:$i,h.anisotropy=v.anisotropy!==void 0?v.anisotropy:1,v.format!==void 0&&(h.format=v.format),v.type!==void 0&&(h.type=v.type),v.mipmaps!==void 0&&(h.mipmaps=v.mipmaps,h.minFilter=oc),v.mipmapCount===1&&(h.minFilter=$i),h.needsUpdate=!0,t&&t(h,v))},i,l),h}});function nd(e){ri.call(this,e)}nd.prototype=Object.assign(Object.create(ri.prototype),{constructor:nd,load:function(e,t,i,l){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);var c=this,h=eu.get(e);if(h!==void 0)return c.manager.itemStart(e),setTimeout(function(){t&&t(h),c.manager.itemEnd(e)},0),h;var f=document.createElementNS("http://www.w3.org/1999/xhtml","img");function r(){f.removeEventListener("load",r,!1),f.removeEventListener("error",v,!1),eu.add(e,this),t&&t(this),c.manager.itemEnd(e)}function v(x){f.removeEventListener("load",r,!1),f.removeEventListener("error",v,!1),l&&l(x),c.manager.itemError(e),c.manager.itemEnd(e)}return f.addEventListener("load",r,!1),f.addEventListener("error",v,!1),e.substr(0,5)!=="data:"&&this.crossOrigin!==void 0&&(f.crossOrigin=this.crossOrigin),c.manager.itemStart(e),f.src=e,f}});function a_(e){ri.call(this,e)}a_.prototype=Object.assign(Object.create(ri.prototype),{constructor:a_,load:function(e,t,i,l){var c=new os,h=new nd(this.manager);h.setCrossOrigin(this.crossOrigin),h.setPath(this.path);var f=0;function r(x){h.load(e[x],function(w){c.images[x]=w,f++,f===6&&(c.needsUpdate=!0,t&&t(c))},void 0,l)}for(var v=0;v<e.length;++v)r(v);return c}});function id(e){ri.call(this,e)}id.prototype=Object.assign(Object.create(ri.prototype),{constructor:id,load:function(e,t,i,l){var c=new mi,h=new nd(this.manager);return h.setCrossOrigin(this.crossOrigin),h.setPath(this.path),h.load(e,function(f){c.image=f;var r=e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0;c.format=r?Ma:Ao,c.needsUpdate=!0,t!==void 0&&t(c)},i,l),c}});function Dn(){this.type="Curve",this.arcLengthDivisions=200}Object.assign(Dn.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(e,t){var i=this.getUtoTmapping(e);return this.getPoint(i,t)},getPoints:function(e){e===void 0&&(e=5);for(var t=[],i=0;i<=e;i++)t.push(this.getPoint(i/e));return t},getSpacedPoints:function(e){e===void 0&&(e=5);for(var t=[],i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t},getLength:function(){var e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(e===void 0&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t=[],i,l=this.getPoint(0),c,h=0;for(t.push(0),c=1;c<=e;c++)i=this.getPoint(c/e),h+=i.distanceTo(l),t.push(h),l=i;return this.cacheArcLengths=t,t},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){var i=this.getLengths(),l=0,c=i.length,h;t?h=t:h=e*i[c-1];for(var f=0,r=c-1,v;f<=r;)if(l=Math.floor(f+(r-f)/2),v=i[l]-h,v<0)f=l+1;else if(v>0)r=l-1;else{r=l;break}if(l=r,i[l]===h)return l/(c-1);var x=i[l],w=i[l+1],b=w-x,A=(h-x)/b,L=(l+A)/(c-1);return L},getTangent:function(e){var t=1e-4,i=e-t,l=e+t;i<0&&(i=0),l>1&&(l=1);var c=this.getPoint(i),h=this.getPoint(l),f=h.clone().sub(c);return f.normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},computeFrenetFrames:function(e,t){var i=new Pe,l=[],c=[],h=[],f=new Pe,r=new Hn,v,x,w;for(v=0;v<=e;v++)x=v/e,l[v]=this.getTangentAt(x),l[v].normalize();c[0]=new Pe,h[0]=new Pe;var b=Number.MAX_VALUE,A=Math.abs(l[0].x),L=Math.abs(l[0].y),P=Math.abs(l[0].z);for(A<=b&&(b=A,i.set(1,0,0)),L<=b&&(b=L,i.set(0,1,0)),P<=b&&i.set(0,0,1),f.crossVectors(l[0],i).normalize(),c[0].crossVectors(l[0],f),h[0].crossVectors(l[0],c[0]),v=1;v<=e;v++)c[v]=c[v-1].clone(),h[v]=h[v-1].clone(),f.crossVectors(l[v-1],l[v]),f.length()>Number.EPSILON&&(f.normalize(),w=Math.acos(jn.clamp(l[v-1].dot(l[v]),-1,1)),c[v].applyMatrix4(r.makeRotationAxis(f,w))),h[v].crossVectors(l[v],c[v]);if(t===!0)for(w=Math.acos(jn.clamp(c[0].dot(c[e]),-1,1)),w/=e,l[0].dot(f.crossVectors(c[0],c[e]))>0&&(w=-w),v=1;v<=e;v++)c[v].applyMatrix4(r.makeRotationAxis(l[v],w*v)),h[v].crossVectors(l[v],c[v]);return{tangents:l,normals:c,binormals:h}},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){var e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}});function bo(e,t,i,l,c,h,f,r){Dn.call(this),this.type="EllipseCurve",this.aX=e||0,this.aY=t||0,this.xRadius=i||1,this.yRadius=l||1,this.aStartAngle=c||0,this.aEndAngle=h||2*Math.PI,this.aClockwise=f||!1,this.aRotation=r||0}bo.prototype=Object.create(Dn.prototype),bo.prototype.constructor=bo,bo.prototype.isEllipseCurve=!0,bo.prototype.getPoint=function(e,t){for(var i=t||new Lt,l=Math.PI*2,c=this.aEndAngle-this.aStartAngle,h=Math.abs(c)<Number.EPSILON;c<0;)c+=l;for(;c>l;)c-=l;c<Number.EPSILON&&(h?c=0:c=l),this.aClockwise===!0&&!h&&(c===l?c=-l:c=c-l);var f=this.aStartAngle+e*c,r=this.aX+this.xRadius*Math.cos(f),v=this.aY+this.yRadius*Math.sin(f);if(this.aRotation!==0){var x=Math.cos(this.aRotation),w=Math.sin(this.aRotation),b=r-this.aX,A=v-this.aY;r=b*x-A*w+this.aX,v=b*w+A*x+this.aY}return i.set(r,v)},bo.prototype.copy=function(e){return Dn.prototype.copy.call(this,e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this},bo.prototype.toJSON=function(){var e=Dn.prototype.toJSON.call(this);return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e},bo.prototype.fromJSON=function(e){return Dn.prototype.fromJSON.call(this,e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this};function rd(e,t,i,l,c,h){bo.call(this,e,t,i,i,l,c,h),this.type="ArcCurve"}rd.prototype=Object.create(bo.prototype),rd.prototype.constructor=rd,rd.prototype.isArcCurve=!0;function s_(){var e=0,t=0,i=0,l=0;function c(h,f,r,v){e=h,t=r,i=-3*h+3*f-2*r-v,l=2*h-2*f+r+v}return{initCatmullRom:function(h,f,r,v,x){c(f,r,x*(r-h),x*(v-f))},initNonuniformCatmullRom:function(h,f,r,v,x,w,b){var A=(f-h)/x-(r-h)/(x+w)+(r-f)/w,L=(r-f)/w-(v-f)/(w+b)+(v-r)/b;A*=w,L*=w,c(f,r,A,L)},calc:function(h){var f=h*h,r=f*h;return e+t*h+i*f+l*r}}}var im=new Pe,l_=new s_,c_=new s_,u_=new s_;function co(e,t,i,l){Dn.call(this),this.type="CatmullRomCurve3",this.points=e||[],this.closed=t||!1,this.curveType=i||"centripetal",this.tension=l||.5}co.prototype=Object.create(Dn.prototype),co.prototype.constructor=co,co.prototype.isCatmullRomCurve3=!0,co.prototype.getPoint=function(e,t){var i=t||new Pe,l=this.points,c=l.length,h=(c-(this.closed?0:1))*e,f=Math.floor(h),r=h-f;this.closed?f+=f>0?0:(Math.floor(Math.abs(f)/c)+1)*c:r===0&&f===c-1&&(f=c-2,r=1);var v,x,w,b;if(this.closed||f>0?v=l[(f-1)%c]:(im.subVectors(l[0],l[1]).add(l[0]),v=im),x=l[f%c],w=l[(f+1)%c],this.closed||f+2<c?b=l[(f+2)%c]:(im.subVectors(l[c-1],l[c-2]).add(l[c-1]),b=im),this.curveType==="centripetal"||this.curveType==="chordal"){var A=this.curveType==="chordal"?.5:.25,L=Math.pow(v.distanceToSquared(x),A),P=Math.pow(x.distanceToSquared(w),A),R=Math.pow(w.distanceToSquared(b),A);P<1e-4&&(P=1),L<1e-4&&(L=P),R<1e-4&&(R=P),l_.initNonuniformCatmullRom(v.x,x.x,w.x,b.x,L,P,R),c_.initNonuniformCatmullRom(v.y,x.y,w.y,b.y,L,P,R),u_.initNonuniformCatmullRom(v.z,x.z,w.z,b.z,L,P,R)}else this.curveType==="catmullrom"&&(l_.initCatmullRom(v.x,x.x,w.x,b.x,this.tension),c_.initCatmullRom(v.y,x.y,w.y,b.y,this.tension),u_.initCatmullRom(v.z,x.z,w.z,b.z,this.tension));return i.set(l_.calc(r),c_.calc(r),u_.calc(r)),i},co.prototype.copy=function(e){Dn.prototype.copy.call(this,e),this.points=[];for(var t=0,i=e.points.length;t<i;t++){var l=e.points[t];this.points.push(l.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this},co.prototype.toJSON=function(){var e=Dn.prototype.toJSON.call(this);e.points=[];for(var t=0,i=this.points.length;t<i;t++){var l=this.points[t];e.points.push(l.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e},co.prototype.fromJSON=function(e){Dn.prototype.fromJSON.call(this,e),this.points=[];for(var t=0,i=e.points.length;t<i;t++){var l=e.points[t];this.points.push(new Pe().fromArray(l))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this};function Q0(e,t,i,l,c){var h=(l-t)*.5,f=(c-i)*.5,r=e*e,v=e*r;return(2*i-2*l+h+f)*v+(-3*i+3*l-2*h-f)*r+h*e+i}function hS(e,t){var i=1-e;return i*i*t}function dS(e,t){return 2*(1-e)*e*t}function pS(e,t){return e*e*t}function od(e,t,i,l){return hS(e,t)+dS(e,i)+pS(e,l)}function fS(e,t){var i=1-e;return i*i*i*t}function mS(e,t){var i=1-e;return 3*i*i*e*t}function gS(e,t){return 3*(1-e)*e*e*t}function yS(e,t){return e*e*e*t}function ad(e,t,i,l,c){return fS(e,t)+mS(e,i)+gS(e,l)+yS(e,c)}function Zo(e,t,i,l){Dn.call(this),this.type="CubicBezierCurve",this.v0=e||new Lt,this.v1=t||new Lt,this.v2=i||new Lt,this.v3=l||new Lt}Zo.prototype=Object.create(Dn.prototype),Zo.prototype.constructor=Zo,Zo.prototype.isCubicBezierCurve=!0,Zo.prototype.getPoint=function(e,t){var i=t||new Lt,l=this.v0,c=this.v1,h=this.v2,f=this.v3;return i.set(ad(e,l.x,c.x,h.x,f.x),ad(e,l.y,c.y,h.y,f.y)),i},Zo.prototype.copy=function(e){return Dn.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},Zo.prototype.toJSON=function(){var e=Dn.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},Zo.prototype.fromJSON=function(e){return Dn.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this};function Fa(e,t,i,l){Dn.call(this),this.type="CubicBezierCurve3",this.v0=e||new Pe,this.v1=t||new Pe,this.v2=i||new Pe,this.v3=l||new Pe}Fa.prototype=Object.create(Dn.prototype),Fa.prototype.constructor=Fa,Fa.prototype.isCubicBezierCurve3=!0,Fa.prototype.getPoint=function(e,t){var i=t||new Pe,l=this.v0,c=this.v1,h=this.v2,f=this.v3;return i.set(ad(e,l.x,c.x,h.x,f.x),ad(e,l.y,c.y,h.y,f.y),ad(e,l.z,c.z,h.z,f.z)),i},Fa.prototype.copy=function(e){return Dn.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},Fa.prototype.toJSON=function(){var e=Dn.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},Fa.prototype.fromJSON=function(e){return Dn.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this};function uo(e,t){Dn.call(this),this.type="LineCurve",this.v1=e||new Lt,this.v2=t||new Lt}uo.prototype=Object.create(Dn.prototype),uo.prototype.constructor=uo,uo.prototype.isLineCurve=!0,uo.prototype.getPoint=function(e,t){var i=t||new Lt;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i},uo.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},uo.prototype.getTangent=function(){var e=this.v2.clone().sub(this.v1);return e.normalize()},uo.prototype.copy=function(e){return Dn.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},uo.prototype.toJSON=function(){var e=Dn.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},uo.prototype.fromJSON=function(e){return Dn.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this};function Yo(e,t){Dn.call(this),this.type="LineCurve3",this.v1=e||new Pe,this.v2=t||new Pe}Yo.prototype=Object.create(Dn.prototype),Yo.prototype.constructor=Yo,Yo.prototype.isLineCurve3=!0,Yo.prototype.getPoint=function(e,t){var i=t||new Pe;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i},Yo.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},Yo.prototype.copy=function(e){return Dn.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Yo.prototype.toJSON=function(){var e=Dn.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},Yo.prototype.fromJSON=function(e){return Dn.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this};function Ko(e,t,i){Dn.call(this),this.type="QuadraticBezierCurve",this.v0=e||new Lt,this.v1=t||new Lt,this.v2=i||new Lt}Ko.prototype=Object.create(Dn.prototype),Ko.prototype.constructor=Ko,Ko.prototype.isQuadraticBezierCurve=!0,Ko.prototype.getPoint=function(e,t){var i=t||new Lt,l=this.v0,c=this.v1,h=this.v2;return i.set(od(e,l.x,c.x,h.x),od(e,l.y,c.y,h.y)),i},Ko.prototype.copy=function(e){return Dn.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Ko.prototype.toJSON=function(){var e=Dn.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},Ko.prototype.fromJSON=function(e){return Dn.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this};function Ba(e,t,i){Dn.call(this),this.type="QuadraticBezierCurve3",this.v0=e||new Pe,this.v1=t||new Pe,this.v2=i||new Pe}Ba.prototype=Object.create(Dn.prototype),Ba.prototype.constructor=Ba,Ba.prototype.isQuadraticBezierCurve3=!0,Ba.prototype.getPoint=function(e,t){var i=t||new Pe,l=this.v0,c=this.v1,h=this.v2;return i.set(od(e,l.x,c.x,h.x),od(e,l.y,c.y,h.y),od(e,l.z,c.z,h.z)),i},Ba.prototype.copy=function(e){return Dn.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Ba.prototype.toJSON=function(){var e=Dn.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},Ba.prototype.fromJSON=function(e){return Dn.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this};function Jo(e){Dn.call(this),this.type="SplineCurve",this.points=e||[]}Jo.prototype=Object.create(Dn.prototype),Jo.prototype.constructor=Jo,Jo.prototype.isSplineCurve=!0,Jo.prototype.getPoint=function(e,t){var i=t||new Lt,l=this.points,c=(l.length-1)*e,h=Math.floor(c),f=c-h,r=l[h===0?h:h-1],v=l[h],x=l[h>l.length-2?l.length-1:h+1],w=l[h>l.length-3?l.length-1:h+2];return i.set(Q0(f,r.x,v.x,x.x,w.x),Q0(f,r.y,v.y,x.y,w.y)),i},Jo.prototype.copy=function(e){Dn.prototype.copy.call(this,e),this.points=[];for(var t=0,i=e.points.length;t<i;t++){var l=e.points[t];this.points.push(l.clone())}return this},Jo.prototype.toJSON=function(){var e=Dn.prototype.toJSON.call(this);e.points=[];for(var t=0,i=this.points.length;t<i;t++){var l=this.points[t];e.points.push(l.toArray())}return e},Jo.prototype.fromJSON=function(e){Dn.prototype.fromJSON.call(this,e),this.points=[];for(var t=0,i=e.points.length;t<i;t++){var l=e.points[t];this.points.push(new Lt().fromArray(l))}return this};var h_=Object.freeze({__proto__:null,ArcCurve:rd,CatmullRomCurve3:co,CubicBezierCurve:Zo,CubicBezierCurve3:Fa,EllipseCurve:bo,LineCurve:uo,LineCurve3:Yo,QuadraticBezierCurve:Ko,QuadraticBezierCurve3:Ba,SplineCurve:Jo});function hs(){Dn.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}hs.prototype=Object.assign(Object.create(Dn.prototype),{constructor:hs,add:function(e){this.curves.push(e)},closePath:function(){var e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new uo(t,e))},getPoint:function(e){for(var t=e*this.getLength(),i=this.getCurveLengths(),l=0;l<i.length;){if(i[l]>=t){var c=i[l]-t,h=this.curves[l],f=h.getLength(),r=f===0?0:1-c/f;return h.getPointAt(r)}l++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],t=0,i=0,l=this.curves.length;i<l;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e},getSpacedPoints:function(e){e===void 0&&(e=40);for(var t=[],i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t},getPoints:function(e){e=e||12;for(var t=[],i,l=0,c=this.curves;l<c.length;l++)for(var h=c[l],f=h&&h.isEllipseCurve?e*2:h&&(h.isLineCurve||h.isLineCurve3)?1:h&&h.isSplineCurve?e*h.points.length:e,r=h.getPoints(f),v=0;v<r.length;v++){var x=r[v];i&&i.equals(x)||(t.push(x),i=x)}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t},copy:function(e){Dn.prototype.copy.call(this,e),this.curves=[];for(var t=0,i=e.curves.length;t<i;t++){var l=e.curves[t];this.curves.push(l.clone())}return this.autoClose=e.autoClose,this},toJSON:function(){var e=Dn.prototype.toJSON.call(this);e.autoClose=this.autoClose,e.curves=[];for(var t=0,i=this.curves.length;t<i;t++){var l=this.curves[t];e.curves.push(l.toJSON())}return e},fromJSON:function(e){Dn.prototype.fromJSON.call(this,e),this.autoClose=e.autoClose,this.curves=[];for(var t=0,i=e.curves.length;t<i;t++){var l=e.curves[t];this.curves.push(new h_[l.type]().fromJSON(l))}return this}});function Qo(e){hs.call(this),this.type="Path",this.currentPoint=new Lt,e&&this.setFromPoints(e)}Qo.prototype=Object.assign(Object.create(hs.prototype),{constructor:Qo,setFromPoints:function(e){this.moveTo(e[0].x,e[0].y);for(var t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this},moveTo:function(e,t){return this.currentPoint.set(e,t),this},lineTo:function(e,t){var i=new uo(this.currentPoint.clone(),new Lt(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this},quadraticCurveTo:function(e,t,i,l){var c=new Ko(this.currentPoint.clone(),new Lt(e,t),new Lt(i,l));return this.curves.push(c),this.currentPoint.set(i,l),this},bezierCurveTo:function(e,t,i,l,c,h){var f=new Zo(this.currentPoint.clone(),new Lt(e,t),new Lt(i,l),new Lt(c,h));return this.curves.push(f),this.currentPoint.set(c,h),this},splineThru:function(e){var t=[this.currentPoint.clone()].concat(e),i=new Jo(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this},arc:function(e,t,i,l,c,h){var f=this.currentPoint.x,r=this.currentPoint.y;return this.absarc(e+f,t+r,i,l,c,h),this},absarc:function(e,t,i,l,c,h){return this.absellipse(e,t,i,i,l,c,h),this},ellipse:function(e,t,i,l,c,h,f,r){var v=this.currentPoint.x,x=this.currentPoint.y;return this.absellipse(e+v,t+x,i,l,c,h,f,r),this},absellipse:function(e,t,i,l,c,h,f,r){var v=new bo(e,t,i,l,c,h,f,r);if(this.curves.length>0){var x=v.getPoint(0);x.equals(this.currentPoint)||this.lineTo(x.x,x.y)}this.curves.push(v);var w=v.getPoint(1);return this.currentPoint.copy(w),this},copy:function(e){return hs.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){var e=hs.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return hs.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}});function hl(e){Qo.call(this,e),this.uuid=jn.generateUUID(),this.type="Shape",this.holes=[]}hl.prototype=Object.assign(Object.create(Qo.prototype),{constructor:hl,getPointsHoles:function(e){for(var t=[],i=0,l=this.holes.length;i<l;i++)t[i]=this.holes[i].getPoints(e);return t},extractPoints:function(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}},copy:function(e){Qo.prototype.copy.call(this,e),this.holes=[];for(var t=0,i=e.holes.length;t<i;t++){var l=e.holes[t];this.holes.push(l.clone())}return this},toJSON:function(){var e=Qo.prototype.toJSON.call(this);e.uuid=this.uuid,e.holes=[];for(var t=0,i=this.holes.length;t<i;t++){var l=this.holes[t];e.holes.push(l.toJSON())}return e},fromJSON:function(e){Qo.prototype.fromJSON.call(this,e),this.uuid=e.uuid,this.holes=[];for(var t=0,i=e.holes.length;t<i;t++){var l=e.holes[t];this.holes.push(new Qo().fromJSON(l))}return this}});function Mi(e,t){on.call(this),this.type="Light",this.color=new tn(e),this.intensity=t!==void 0?t:1,this.receiveShadow=void 0}Mi.prototype=Object.assign(Object.create(on.prototype),{constructor:Mi,isLight:!0,copy:function(e){return on.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this},toJSON:function(e){var t=on.prototype.toJSON.call(this,e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}});function d_(e,t,i){Mi.call(this,e,i),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(on.DefaultUp),this.updateMatrix(),this.groundColor=new tn(t)}d_.prototype=Object.assign(Object.create(Mi.prototype),{constructor:d_,isHemisphereLight:!0,copy:function(e){return Mi.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}});function Oa(e){this.camera=e,this.bias=0,this.radius=1,this.mapSize=new Lt(512,512),this.map=null,this.mapPass=null,this.matrix=new Hn,this._frustum=new Ph,this._frameExtents=new Lt(1,1),this._viewportCount=1,this._viewports=[new gi(0,0,1,1)]}Object.assign(Oa.prototype,{_projScreenMatrix:new Hn,_lightPositionWorld:new Pe,_lookTarget:new Pe,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(e){var t=this.camera,i=this.matrix,l=this._projScreenMatrix,c=this._lookTarget,h=this._lightPositionWorld;h.setFromMatrixPosition(e.matrixWorld),t.position.copy(h),c.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(c),t.updateMatrixWorld(),l.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(l),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(t.projectionMatrix),i.multiply(t.matrixWorldInverse)},getViewport:function(e){return this._viewports[e]},getFrameExtents:function(){return this._frameExtents},copy:function(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this},clone:function(){return new this.constructor().copy(this)},toJSON:function(){var e={};return this.bias!==0&&(e.bias=this.bias),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}});function p_(){Oa.call(this,new Xi(50,1,.5,500))}p_.prototype=Object.assign(Object.create(Oa.prototype),{constructor:p_,isSpotLightShadow:!0,updateMatrices:function(e){var t=this.camera,i=jn.RAD2DEG*2*e.angle,l=this.mapSize.width/this.mapSize.height,c=e.distance||t.far;(i!==t.fov||l!==t.aspect||c!==t.far)&&(t.fov=i,t.aspect=l,t.far=c,t.updateProjectionMatrix()),Oa.prototype.updateMatrices.call(this,e)}});function rm(e,t,i,l,c,h){Mi.call(this,e,t),this.type="SpotLight",this.position.copy(on.DefaultUp),this.updateMatrix(),this.target=new on,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(f){this.intensity=f/Math.PI}}),this.distance=i!==void 0?i:0,this.angle=l!==void 0?l:Math.PI/3,this.penumbra=c!==void 0?c:0,this.decay=h!==void 0?h:1,this.shadow=new p_}rm.prototype=Object.assign(Object.create(Mi.prototype),{constructor:rm,isSpotLight:!0,copy:function(e){return Mi.prototype.copy.call(this,e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}});function f_(){Oa.call(this,new Xi(90,1,.5,500)),this._frameExtents=new Lt(4,2),this._viewportCount=6,this._viewports=[new gi(2,1,1,1),new gi(0,1,1,1),new gi(3,1,1,1),new gi(1,1,1,1),new gi(3,0,1,1),new gi(1,0,1,1)],this._cubeDirections=[new Pe(1,0,0),new Pe(-1,0,0),new Pe(0,0,1),new Pe(0,0,-1),new Pe(0,1,0),new Pe(0,-1,0)],this._cubeUps=[new Pe(0,1,0),new Pe(0,1,0),new Pe(0,1,0),new Pe(0,1,0),new Pe(0,0,1),new Pe(0,0,-1)]}f_.prototype=Object.assign(Object.create(Oa.prototype),{constructor:f_,isPointLightShadow:!0,updateMatrices:function(e,t){t===void 0&&(t=0);var i=this.camera,l=this.matrix,c=this._lightPositionWorld,h=this._lookTarget,f=this._projScreenMatrix;c.setFromMatrixPosition(e.matrixWorld),i.position.copy(c),h.copy(i.position),h.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(h),i.updateMatrixWorld(),l.makeTranslation(-c.x,-c.y,-c.z),f.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(f)}});function om(e,t,i,l){Mi.call(this,e,t),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return this.intensity*4*Math.PI},set:function(c){this.intensity=c/(4*Math.PI)}}),this.distance=i!==void 0?i:0,this.decay=l!==void 0?l:1,this.shadow=new f_}om.prototype=Object.assign(Object.create(Mi.prototype),{constructor:om,isPointLight:!0,copy:function(e){return Mi.prototype.copy.call(this,e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}});function tu(e,t,i,l,c,h){Ia.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e!==void 0?e:-1,this.right=t!==void 0?t:1,this.top=i!==void 0?i:1,this.bottom=l!==void 0?l:-1,this.near=c!==void 0?c:.1,this.far=h!==void 0?h:2e3,this.updateProjectionMatrix()}tu.prototype=Object.assign(Object.create(Ia.prototype),{constructor:tu,isOrthographicCamera:!0,copy:function(e,t){return Ia.prototype.copy.call(this,e,t),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:function(e,t,i,l,c,h){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=t,this.view.offsetX=i,this.view.offsetY=l,this.view.width=c,this.view.height=h,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,l=(this.top+this.bottom)/2,c=i-e,h=i+e,f=l+t,r=l-t;if(this.view!==null&&this.view.enabled){var v=(this.right-this.left)/this.view.fullWidth/this.zoom,x=(this.top-this.bottom)/this.view.fullHeight/this.zoom;c+=v*this.view.offsetX,h=c+v*this.view.width,f-=x*this.view.offsetY,r=f-x*this.view.height}this.projectionMatrix.makeOrthographic(c,h,f,r,this.near,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){var t=on.prototype.toJSON.call(this,e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}});function m_(){Oa.call(this,new tu(-5,5,5,-5,.5,500))}m_.prototype=Object.assign(Object.create(Oa.prototype),{constructor:m_,isDirectionalLightShadow:!0,updateMatrices:function(e){Oa.prototype.updateMatrices.call(this,e)}});function am(e,t){Mi.call(this,e,t),this.type="DirectionalLight",this.position.copy(on.DefaultUp),this.updateMatrix(),this.target=new on,this.shadow=new m_}am.prototype=Object.assign(Object.create(Mi.prototype),{constructor:am,isDirectionalLight:!0,copy:function(e){return Mi.prototype.copy.call(this,e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}});function g_(e,t){Mi.call(this,e,t),this.type="AmbientLight",this.castShadow=void 0}g_.prototype=Object.assign(Object.create(Mi.prototype),{constructor:g_,isAmbientLight:!0});function y_(e,t,i,l){Mi.call(this,e,t),this.type="RectAreaLight",this.width=i!==void 0?i:10,this.height=l!==void 0?l:10}y_.prototype=Object.assign(Object.create(Mi.prototype),{constructor:y_,isRectAreaLight:!0,copy:function(e){return Mi.prototype.copy.call(this,e),this.width=e.width,this.height=e.height,this},toJSON:function(e){var t=Mi.prototype.toJSON.call(this,e);return t.object.width=this.width,t.object.height=this.height,t}});function __(e){ri.call(this,e),this.textures={}}__.prototype=Object.assign(Object.create(ri.prototype),{constructor:__,load:function(e,t,i,l){var c=this,h=new xo(c.manager);h.setPath(c.path),h.load(e,function(f){t(c.parse(JSON.parse(f)))},i,l)},parse:function(e){var t=this.textures;function i(v){return t[v]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",v),t[v]}var l=new sS[e.type];if(e.uuid!==void 0&&(l.uuid=e.uuid),e.name!==void 0&&(l.name=e.name),e.color!==void 0&&l.color.setHex(e.color),e.roughness!==void 0&&(l.roughness=e.roughness),e.metalness!==void 0&&(l.metalness=e.metalness),e.sheen!==void 0&&(l.sheen=new tn().setHex(e.sheen)),e.emissive!==void 0&&l.emissive.setHex(e.emissive),e.specular!==void 0&&l.specular.setHex(e.specular),e.shininess!==void 0&&(l.shininess=e.shininess),e.clearcoat!==void 0&&(l.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(l.clearcoatRoughness=e.clearcoatRoughness),e.vertexColors!==void 0&&(l.vertexColors=e.vertexColors),e.fog!==void 0&&(l.fog=e.fog),e.flatShading!==void 0&&(l.flatShading=e.flatShading),e.blending!==void 0&&(l.blending=e.blending),e.combine!==void 0&&(l.combine=e.combine),e.side!==void 0&&(l.side=e.side),e.opacity!==void 0&&(l.opacity=e.opacity),e.transparent!==void 0&&(l.transparent=e.transparent),e.alphaTest!==void 0&&(l.alphaTest=e.alphaTest),e.depthTest!==void 0&&(l.depthTest=e.depthTest),e.depthWrite!==void 0&&(l.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(l.colorWrite=e.colorWrite),e.stencilWrite!==void 0&&(l.stencilWrite=e.stencilWrite),e.stencilWriteMask!==void 0&&(l.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(l.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(l.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(l.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(l.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(l.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(l.stencilZPass=e.stencilZPass),e.wireframe!==void 0&&(l.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(l.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(l.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(l.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(l.rotation=e.rotation),e.linewidth!==1&&(l.linewidth=e.linewidth),e.dashSize!==void 0&&(l.dashSize=e.dashSize),e.gapSize!==void 0&&(l.gapSize=e.gapSize),e.scale!==void 0&&(l.scale=e.scale),e.polygonOffset!==void 0&&(l.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(l.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(l.polygonOffsetUnits=e.polygonOffsetUnits),e.skinning!==void 0&&(l.skinning=e.skinning),e.morphTargets!==void 0&&(l.morphTargets=e.morphTargets),e.morphNormals!==void 0&&(l.morphNormals=e.morphNormals),e.dithering!==void 0&&(l.dithering=e.dithering),e.visible!==void 0&&(l.visible=e.visible),e.toneMapped!==void 0&&(l.toneMapped=e.toneMapped),e.userData!==void 0&&(l.userData=e.userData),e.uniforms!==void 0)for(var c in e.uniforms){var h=e.uniforms[c];switch(l.uniforms[c]={},h.type){case"t":l.uniforms[c].value=i(h.value);break;case"c":l.uniforms[c].value=new tn().setHex(h.value);break;case"v2":l.uniforms[c].value=new Lt().fromArray(h.value);break;case"v3":l.uniforms[c].value=new Pe().fromArray(h.value);break;case"v4":l.uniforms[c].value=new gi().fromArray(h.value);break;case"m3":l.uniforms[c].value=new pr().fromArray(h.value);case"m4":l.uniforms[c].value=new Hn().fromArray(h.value);break;default:l.uniforms[c].value=h.value}}if(e.defines!==void 0&&(l.defines=e.defines),e.vertexShader!==void 0&&(l.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(l.fragmentShader=e.fragmentShader),e.extensions!==void 0)for(var f in e.extensions)l.extensions[f]=e.extensions[f];if(e.shading!==void 0&&(l.flatShading=e.shading===1),e.size!==void 0&&(l.size=e.size),e.sizeAttenuation!==void 0&&(l.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(l.map=i(e.map)),e.matcap!==void 0&&(l.matcap=i(e.matcap)),e.alphaMap!==void 0&&(l.alphaMap=i(e.alphaMap),l.transparent=!0),e.bumpMap!==void 0&&(l.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(l.bumpScale=e.bumpScale),e.normalMap!==void 0&&(l.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(l.normalMapType=e.normalMapType),e.normalScale!==void 0){var r=e.normalScale;Array.isArray(r)===!1&&(r=[r,r]),l.normalScale=new Lt().fromArray(r)}return e.displacementMap!==void 0&&(l.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(l.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(l.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(l.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(l.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(l.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(l.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(l.specularMap=i(e.specularMap)),e.envMap!==void 0&&(l.envMap=i(e.envMap)),e.envMapIntensity!==void 0&&(l.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(l.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(l.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(l.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(l.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(l.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(l.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(l.gradientMap=i(e.gradientMap)),e.clearcoatNormalMap!==void 0&&(l.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(l.clearcoatNormalScale=new Lt().fromArray(e.clearcoatNormalScale)),l},setTextures:function(e){return this.textures=e,this}});var dl={decodeText:function(e){if(typeof TextDecoder!="undefined")return new TextDecoder().decode(e);for(var t="",i=0,l=e.length;i<l;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch(c){return t}},extractUrlBase:function(e){var t=e.lastIndexOf("/");return t===-1?"./":e.substr(0,t+1)}};function v_(){vn.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}v_.prototype=Object.assign(Object.create(vn.prototype),{constructor:v_,isInstancedBufferGeometry:!0,copy:function(e){return vn.prototype.copy.call(this,e),this.maxInstancedCount=e.maxInstancedCount,this},clone:function(){return new this.constructor().copy(this)},toJSON:function(){var e=vn.prototype.toJSON.call(this);return e.maxInstancedCount=this.maxInstancedCount,e.isInstancedBufferGeometry=!0,e}});function x_(e,t,i,l){typeof i=="number"&&(l=i,i=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),kn.call(this,e,t,i),this.meshPerAttribute=l||1}x_.prototype=Object.assign(Object.create(kn.prototype),{constructor:x_,isInstancedBufferAttribute:!0,copy:function(e){return kn.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this},toJSON:function(){var e=kn.prototype.toJSON.call(this);return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}});function b_(e){ri.call(this,e)}b_.prototype=Object.assign(Object.create(ri.prototype),{constructor:b_,load:function(e,t,i,l){var c=this,h=new xo(c.manager);h.setPath(c.path),h.load(e,function(f){t(c.parse(JSON.parse(f)))},i,l)},parse:function(e){var t=e.isInstancedBufferGeometry?new v_:new vn,i=e.data.index;if(i!==void 0){var l=new w_[i.type](i.array);t.setIndex(new kn(l,1))}var c=e.data.attributes;for(var h in c){var f=c[h],l=new w_[f.type](f.array),r=f.isInstancedBufferAttribute?x_:kn,v=new r(l,f.itemSize,f.normalized);f.name!==void 0&&(v.name=f.name),t.setAttribute(h,v)}var x=e.data.morphAttributes;if(x)for(var h in x){for(var w=x[h],b=[],A=0,L=w.length;A<L;A++){var f=w[A],l=new w_[f.type](f.array),v=new kn(l,f.itemSize,f.normalized);f.name!==void 0&&(v.name=f.name),b.push(v)}t.morphAttributes[h]=b}var P=e.data.morphTargetsRelative;P&&(t.morphTargetsRelative=!0);var R=e.data.groups||e.data.drawcalls||e.data.offsets;if(R!==void 0)for(var A=0,F=R.length;A!==F;++A){var V=R[A];t.addGroup(V.start,V.count,V.materialIndex)}var j=e.data.boundingSphere;if(j!==void 0){var J=new Pe;j.center!==void 0&&J.fromArray(j.center),t.boundingSphere=new Da(J,j.radius)}return e.name&&(t.name=e.name),e.userData&&(t.userData=e.userData),t}});var w_={Int8Array,Uint8Array,Uint8ClampedArray:typeof Uint8ClampedArray!="undefined"?Uint8ClampedArray:Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function M_(e){ri.call(this,e)}M_.prototype=Object.assign(Object.create(ri.prototype),{constructor:M_,load:function(e,t,i,l){var c=this,h=this.path===""?dl.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||h;var f=new xo(c.manager);f.setPath(this.path),f.load(e,function(r){var v=null;try{v=JSON.parse(r)}catch(w){l!==void 0&&l(w),console.error("THREE:ObjectLoader: Can't parse "+e+".",w.message);return}var x=v.metadata;if(x===void 0||x.type===void 0||x.type.toLowerCase()==="geometry"){console.error("THREE.ObjectLoader: Can't load "+e);return}c.parse(v,t)},i,l)},parse:function(e,t){var i=this.parseShape(e.shapes),l=this.parseGeometries(e.geometries,i),c=this.parseImages(e.images,function(){t!==void 0&&t(r)}),h=this.parseTextures(e.textures,c),f=this.parseMaterials(e.materials,h),r=this.parseObject(e.object,l,f);return e.animations&&(r.animations=this.parseAnimations(e.animations)),(e.images===void 0||e.images.length===0)&&t!==void 0&&t(r),r},parseShape:function(e){var t={};if(e!==void 0)for(var i=0,l=e.length;i<l;i++){var c=new hl().fromJSON(e[i]);t[c.uuid]=c}return t},parseGeometries:function(e,t){var i={};if(e!==void 0)for(var l=new b_,c=0,h=e.length;c<h;c++){var f,r=e[c];switch(r.type){case"PlaneGeometry":case"PlaneBufferGeometry":f=new Er[r.type](r.width,r.height,r.widthSegments,r.heightSegments);break;case"BoxGeometry":case"BoxBufferGeometry":case"CubeGeometry":f=new Er[r.type](r.width,r.height,r.depth,r.widthSegments,r.heightSegments,r.depthSegments);break;case"CircleGeometry":case"CircleBufferGeometry":f=new Er[r.type](r.radius,r.segments,r.thetaStart,r.thetaLength);break;case"CylinderGeometry":case"CylinderBufferGeometry":f=new Er[r.type](r.radiusTop,r.radiusBottom,r.height,r.radialSegments,r.heightSegments,r.openEnded,r.thetaStart,r.thetaLength);break;case"ConeGeometry":case"ConeBufferGeometry":f=new Er[r.type](r.radius,r.height,r.radialSegments,r.heightSegments,r.openEnded,r.thetaStart,r.thetaLength);break;case"SphereGeometry":case"SphereBufferGeometry":f=new Er[r.type](r.radius,r.widthSegments,r.heightSegments,r.phiStart,r.phiLength,r.thetaStart,r.thetaLength);break;case"DodecahedronGeometry":case"DodecahedronBufferGeometry":case"IcosahedronGeometry":case"IcosahedronBufferGeometry":case"OctahedronGeometry":case"OctahedronBufferGeometry":case"TetrahedronGeometry":case"TetrahedronBufferGeometry":f=new Er[r.type](r.radius,r.detail);break;case"RingGeometry":case"RingBufferGeometry":f=new Er[r.type](r.innerRadius,r.outerRadius,r.thetaSegments,r.phiSegments,r.thetaStart,r.thetaLength);break;case"TorusGeometry":case"TorusBufferGeometry":f=new Er[r.type](r.radius,r.tube,r.radialSegments,r.tubularSegments,r.arc);break;case"TorusKnotGeometry":case"TorusKnotBufferGeometry":f=new Er[r.type](r.radius,r.tube,r.tubularSegments,r.radialSegments,r.p,r.q);break;case"TubeGeometry":case"TubeBufferGeometry":f=new Er[r.type](new h_[r.path.type]().fromJSON(r.path),r.tubularSegments,r.radius,r.radialSegments,r.closed);break;case"LatheGeometry":case"LatheBufferGeometry":f=new Er[r.type](r.points,r.segments,r.phiStart,r.phiLength);break;case"PolyhedronGeometry":case"PolyhedronBufferGeometry":f=new Er[r.type](r.vertices,r.indices,r.radius,r.details);break;case"ShapeGeometry":case"ShapeBufferGeometry":for(var b=[],v=0,x=r.shapes.length;v<x;v++){var w=t[r.shapes[v]];b.push(w)}f=new Er[r.type](b,r.curveSegments);break;case"ExtrudeGeometry":case"ExtrudeBufferGeometry":for(var b=[],v=0,x=r.shapes.length;v<x;v++){var w=t[r.shapes[v]];b.push(w)}var A=r.options.extrudePath;A!==void 0&&(r.options.extrudePath=new h_[A.type]().fromJSON(A)),f=new Er[r.type](b,r.options);break;case"BufferGeometry":case"InstancedBufferGeometry":f=l.parse(r);break;case"Geometry":if("THREE"in window&&"LegacyJSONLoader"in THREE){var L=new THREE.LegacyJSONLoader;f=L.parse(r,this.resourcePath).geometry}else console.error('THREE.ObjectLoader: You have to import LegacyJSONLoader in order load geometry data of type "Geometry".');break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+r.type+'"');continue}f.uuid=r.uuid,r.name!==void 0&&(f.name=r.name),f.isBufferGeometry===!0&&r.userData!==void 0&&(f.userData=r.userData),i[r.uuid]=f}return i},parseMaterials:function(e,t){var i={},l={};if(e!==void 0){var c=new __;c.setTextures(t);for(var h=0,f=e.length;h<f;h++){var r=e[h];if(r.type==="MultiMaterial"){for(var v=[],x=0;x<r.materials.length;x++){var w=r.materials[x];i[w.uuid]===void 0&&(i[w.uuid]=c.parse(w)),v.push(i[w.uuid])}l[r.uuid]=v}else i[r.uuid]===void 0&&(i[r.uuid]=c.parse(r)),l[r.uuid]=i[r.uuid]}}return l},parseAnimations:function(e){for(var t=[],i=0;i<e.length;i++){var l=e[i],c=vo.parse(l);l.uuid!==void 0&&(c.uuid=l.uuid),t.push(c)}return t},parseImages:function(e,t){var i=this,l={};function c(R){return i.manager.itemStart(R),f.load(R,function(){i.manager.itemEnd(R)},void 0,function(){i.manager.itemError(R),i.manager.itemEnd(R)})}if(e!==void 0&&e.length>0){var h=new Z0(t),f=new nd(h);f.setCrossOrigin(this.crossOrigin);for(var r=0,v=e.length;r<v;r++){var x=e[r],w=x.url;if(Array.isArray(w)){l[x.uuid]=[];for(var b=0,A=w.length;b<A;b++){var L=w[b],P=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(L)?L:i.resourcePath+L;l[x.uuid].push(c(P))}}else{var P=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(x.url)?x.url:i.resourcePath+x.url;l[x.uuid]=c(P)}}}return l},parseTextures:function(e,t){function i(v,x){return typeof v=="number"?v:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",v),x[v])}var l={};if(e!==void 0)for(var c=0,h=e.length;c<h;c++){var f=e[c];f.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',f.uuid),t[f.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",f.image);var r;Array.isArray(t[f.image])?r=new os(t[f.image]):r=new mi(t[f.image]),r.needsUpdate=!0,r.uuid=f.uuid,f.name!==void 0&&(r.name=f.name),f.mapping!==void 0&&(r.mapping=i(f.mapping,_S)),f.offset!==void 0&&r.offset.fromArray(f.offset),f.repeat!==void 0&&r.repeat.fromArray(f.repeat),f.center!==void 0&&r.center.fromArray(f.center),f.rotation!==void 0&&(r.rotation=f.rotation),f.wrap!==void 0&&(r.wrapS=i(f.wrap[0],e1),r.wrapT=i(f.wrap[1],e1)),f.format!==void 0&&(r.format=f.format),f.type!==void 0&&(r.type=f.type),f.encoding!==void 0&&(r.encoding=f.encoding),f.minFilter!==void 0&&(r.minFilter=i(f.minFilter,t1)),f.magFilter!==void 0&&(r.magFilter=i(f.magFilter,t1)),f.anisotropy!==void 0&&(r.anisotropy=f.anisotropy),f.flipY!==void 0&&(r.flipY=f.flipY),f.premultiplyAlpha!==void 0&&(r.premultiplyAlpha=f.premultiplyAlpha),f.unpackAlignment!==void 0&&(r.unpackAlignment=f.unpackAlignment),l[f.uuid]=r}return l},parseObject:function(e,t,i){var l;function c(F){return t[F]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",F),t[F]}function h(F){if(F!==void 0){if(Array.isArray(F)){for(var V=[],j=0,J=F.length;j<J;j++){var ne=F[j];i[ne]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",ne),V.push(i[ne])}return V}return i[F]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",F),i[F]}}switch(e.type){case"Scene":l=new Ca,e.background!==void 0&&Number.isInteger(e.background)&&(l.background=new tn(e.background)),e.fog!==void 0&&(e.fog.type==="Fog"?l.fog=new Hy(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(l.fog=new jy(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":l=new Xi(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(l.focus=e.focus),e.zoom!==void 0&&(l.zoom=e.zoom),e.filmGauge!==void 0&&(l.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(l.filmOffset=e.filmOffset),e.view!==void 0&&(l.view=Object.assign({},e.view));break;case"OrthographicCamera":l=new tu(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(l.zoom=e.zoom),e.view!==void 0&&(l.view=Object.assign({},e.view));break;case"AmbientLight":l=new g_(e.color,e.intensity);break;case"DirectionalLight":l=new am(e.color,e.intensity);break;case"PointLight":l=new om(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":l=new y_(e.color,e.intensity,e.width,e.height);break;case"SpotLight":l=new rm(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":l=new d_(e.color,e.groundColor,e.intensity);break;case"SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");case"Mesh":var f=c(e.geometry),r=h(e.material);f.bones&&f.bones.length>0?l=new Oh(f,r):l=new Ai(f,r);break;case"InstancedMesh":var f=c(e.geometry),r=h(e.material),v=e.count,x=e.instanceMatrix;l=new Zy(f,r,v),l.instanceMatrix=new kn(new Float32Array(x.array),16);break;case"LOD":l=new Cf;break;case"Line":l=new so(c(e.geometry),h(e.material),e.mode);break;case"LineLoop":l=new If(c(e.geometry),h(e.material));break;case"LineSegments":l=new Vi(c(e.geometry),h(e.material));break;case"PointCloud":case"Points":l=new zf(c(e.geometry),h(e.material));break;case"Sprite":l=new qy(h(e.material));break;case"Group":l=new al;break;default:l=new on}if(l.uuid=e.uuid,e.name!==void 0&&(l.name=e.name),e.matrix!==void 0?(l.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(l.matrixAutoUpdate=e.matrixAutoUpdate),l.matrixAutoUpdate&&l.matrix.decompose(l.position,l.quaternion,l.scale)):(e.position!==void 0&&l.position.fromArray(e.position),e.rotation!==void 0&&l.rotation.fromArray(e.rotation),e.quaternion!==void 0&&l.quaternion.fromArray(e.quaternion),e.scale!==void 0&&l.scale.fromArray(e.scale)),e.castShadow!==void 0&&(l.castShadow=e.castShadow),e.receiveShadow!==void 0&&(l.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(l.shadow.bias=e.shadow.bias),e.shadow.radius!==void 0&&(l.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&l.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(l.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(l.visible=e.visible),e.frustumCulled!==void 0&&(l.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(l.renderOrder=e.renderOrder),e.userData!==void 0&&(l.userData=e.userData),e.layers!==void 0&&(l.layers.mask=e.layers),e.children!==void 0)for(var w=e.children,b=0;b<w.length;b++)l.add(this.parseObject(w[b],t,i));if(e.type==="LOD"){e.autoUpdate!==void 0&&(l.autoUpdate=e.autoUpdate);for(var A=e.levels,L=0;L<A.length;L++){var P=A[L],R=l.getObjectByProperty("uuid",P.object);R!==void 0&&l.addLevel(R,P.distance)}}return l}});var _S={UVMapping:oy,CubeReflectionMapping:ay,CubeRefractionMapping:sy,EquirectangularReflectionMapping:Dx,EquirectangularRefractionMapping:ly,SphericalReflectionMapping:Px,CubeUVReflectionMapping:ph,CubeUVRefractionMapping:cy},e1={RepeatWrapping:Zs,ClampToEdgeWrapping:Mr,MirroredRepeatWrapping:fh},t1={NearestFilter:Ui,NearestMipmapNearestFilter:Yp,NearestMipmapLinearFilter:Kp,LinearFilter:$i,LinearMipmapNearestFilter:uy,LinearMipmapLinearFilter:oc};function n1(e){typeof createImageBitmap=="undefined"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch=="undefined"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),ri.call(this,e),this.options=void 0}n1.prototype=Object.assign(Object.create(ri.prototype),{constructor:n1,setOptions:function(t){return this.options=t,this},load:function(e,t,i,l){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);var c=this,h=eu.get(e);if(h!==void 0)return c.manager.itemStart(e),setTimeout(function(){t&&t(h),c.manager.itemEnd(e)},0),h;fetch(e).then(function(f){return f.blob()}).then(function(f){return c.options===void 0?createImageBitmap(f):createImageBitmap(f,c.options)}).then(function(f){eu.add(e,f),t&&t(f),c.manager.itemEnd(e)}).catch(function(f){l&&l(f),c.manager.itemError(e),c.manager.itemEnd(e)}),c.manager.itemStart(e)}});function i1(){this.type="ShapePath",this.color=new tn,this.subPaths=[],this.currentPath=null}Object.assign(i1.prototype,{moveTo:function(e,t){return this.currentPath=new Qo,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this},lineTo:function(e,t){return this.currentPath.lineTo(e,t),this},quadraticCurveTo:function(e,t,i,l){return this.currentPath.quadraticCurveTo(e,t,i,l),this},bezierCurveTo:function(e,t,i,l,c,h){return this.currentPath.bezierCurveTo(e,t,i,l,c,h),this},splineThru:function(e){return this.currentPath.splineThru(e),this},toShapes:function(e,t){function i(He){for(var at=[],At=0,yt=He.length;At<yt;At++){var Dt=He[At],It=new hl;It.curves=Dt.curves,at.push(It)}return at}function l(He,at){for(var At=at.length,yt=!1,Dt=At-1,It=0;It<At;Dt=It++){var Nt=at[Dt],Ie=at[It],be=Ie.x-Nt.x,We=Ie.y-Nt.y;if(Math.abs(We)>Number.EPSILON){if(We<0&&(Nt=at[It],be=-be,Ie=at[Dt],We=-We),He.y<Nt.y||He.y>Ie.y)continue;if(He.y===Nt.y){if(He.x===Nt.x)return!0}else{var Ge=We*(He.x-Nt.x)-be*(He.y-Nt.y);if(Ge===0)return!0;if(Ge<0)continue;yt=!yt}}else{if(He.y!==Nt.y)continue;if(Ie.x<=He.x&&He.x<=Nt.x||Nt.x<=He.x&&He.x<=Ie.x)return!0}}return yt}var c=ls.isClockWise,h=this.subPaths;if(h.length===0)return[];if(t===!0)return i(h);var f,r,v,x=[];if(h.length===1)return r=h[0],v=new hl,v.curves=r.curves,x.push(v),x;var w=!c(h[0].getPoints());w=e?!w:w;var b=[],A=[],L=[],P=0,R;A[P]=void 0,L[P]=[];for(var F=0,V=h.length;F<V;F++)r=h[F],R=r.getPoints(),f=c(R),f=e?!f:f,f?(!w&&A[P]&&P++,A[P]={s:new hl,p:R},A[P].s.curves=r.curves,w&&P++,L[P]=[]):L[P].push({h:r,p:R[0]});if(!A[0])return i(h);if(A.length>1){for(var j=!1,J=[],ne=0,H=A.length;ne<H;ne++)b[ne]=[];for(var ne=0,H=A.length;ne<H;ne++)for(var Q=L[ne],ae=0;ae<Q.length;ae++){for(var ie=Q[ae],le=!0,fe=0;fe<A.length;fe++)l(ie.p,A[fe].p)&&(ne!==fe&&J.push({froms:ne,tos:fe,hole:ae}),le?(le=!1,b[fe].push(ie)):j=!0);le&&b[ne].push(ie)}J.length>0&&(j||(L=b))}for(var me,F=0,he=A.length;F<he;F++){v=A[F].s,x.push(v),me=L[F];for(var Oe=0,Ve=me.length;Oe<Ve;Oe++)v.holes.push(me[Oe].h)}return x}});function r1(e){this.type="Font",this.data=e}Object.assign(r1.prototype,{isFont:!0,generateShapes:function(e,t){t===void 0&&(t=100);for(var i=[],l=vS(e,t,this.data),c=0,h=l.length;c<h;c++)Array.prototype.push.apply(i,l[c].toShapes());return i}});function vS(e,t,i){for(var l=Array.from?Array.from(e):String(e).split(""),c=t/i.resolution,h=(i.boundingBox.yMax-i.boundingBox.yMin+i.underlineThickness)*c,f=[],r=0,v=0,x=0;x<l.length;x++){var w=l[x];if(w===`
- `)r=0,v-=h;else{var b=xS(w,c,r,v,i);r+=b.offsetX,f.push(b.path)}}return f}function xS(e,t,i,l,c){var h=c.glyphs[e]||c.glyphs["?"];if(!h){console.error('THREE.Font: character "'+e+'" does not exists in font family '+c.familyName+".");return}var f=new i1,r,v,x,w,b,A,L,P;if(h.o)for(var R=h._cachedOutline||(h._cachedOutline=h.o.split(" ")),F=0,V=R.length;F<V;){var j=R[F++];switch(j){case"m":r=R[F++]*t+i,v=R[F++]*t+l,f.moveTo(r,v);break;case"l":r=R[F++]*t+i,v=R[F++]*t+l,f.lineTo(r,v);break;case"q":x=R[F++]*t+i,w=R[F++]*t+l,b=R[F++]*t+i,A=R[F++]*t+l,f.quadraticCurveTo(b,A,x,w);break;case"b":x=R[F++]*t+i,w=R[F++]*t+l,b=R[F++]*t+i,A=R[F++]*t+l,L=R[F++]*t+i,P=R[F++]*t+l,f.bezierCurveTo(b,A,L,P,x,w);break}}return{offsetX:h.ha*t,path:f}}function o1(e){ri.call(this,e)}o1.prototype=Object.assign(Object.create(ri.prototype),{constructor:o1,load:function(e,t,i,l){var c=this,h=new xo(this.manager);h.setPath(this.path),h.load(e,function(f){var r;try{r=JSON.parse(f)}catch(x){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),r=JSON.parse(f.substring(65,f.length-2))}var v=c.parse(r);t&&t(v)},i,l)},parse:function(e){return new r1(e)}});var sm,a1={getContext:function(){return sm===void 0&&(sm=new(window.AudioContext||window.webkitAudioContext)),sm},setContext:function(e){sm=e}};function T_(e){ri.call(this,e)}T_.prototype=Object.assign(Object.create(ri.prototype),{constructor:T_,load:function(e,t,i,l){var c=new xo(this.manager);c.setResponseType("arraybuffer"),c.setPath(this.path),c.load(e,function(h){var f=h.slice(0),r=a1.getContext();r.decodeAudioData(f,function(v){t(v)})},i,l)}});function E_(){this.coefficients=[];for(var e=0;e<9;e++)this.coefficients.push(new Pe)}Object.assign(E_.prototype,{isSphericalHarmonics3:!0,set:function(e){for(var t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this},zero:function(){for(var e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this},getAt:function(e,t){var i=e.x,l=e.y,c=e.z,h=this.coefficients;return t.copy(h[0]).multiplyScalar(.282095),t.addScale(h[1],.488603*l),t.addScale(h[2],.488603*c),t.addScale(h[3],.488603*i),t.addScale(h[4],1.092548*(i*l)),t.addScale(h[5],1.092548*(l*c)),t.addScale(h[6],.315392*(3*c*c-1)),t.addScale(h[7],1.092548*(i*c)),t.addScale(h[8],.546274*(i*i-l*l)),t},getIrradianceAt:function(e,t){var i=e.x,l=e.y,c=e.z,h=this.coefficients;return t.copy(h[0]).multiplyScalar(.886227),t.addScale(h[1],1.023328*l),t.addScale(h[2],1.023328*c),t.addScale(h[3],1.023328*i),t.addScale(h[4],.858086*i*l),t.addScale(h[5],.858086*l*c),t.addScale(h[6],.743125*c*c-.247708),t.addScale(h[7],.858086*i*c),t.addScale(h[8],.429043*(i*i-l*l)),t},add:function(e){for(var t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this},scale:function(e){for(var t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this},lerp:function(e,t){for(var i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this},equals:function(e){for(var t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0},copy:function(e){return this.set(e.coefficients)},clone:function(){return new this.constructor().copy(this)},fromArray:function(e,t){t===void 0&&(t=0);for(var i=this.coefficients,l=0;l<9;l++)i[l].fromArray(e,t+l*3);return this},toArray:function(e,t){e===void 0&&(e=[]),t===void 0&&(t=0);for(var i=this.coefficients,l=0;l<9;l++)i[l].toArray(e,t+l*3);return e}}),Object.assign(E_,{getBasisAt:function(e,t){var i=e.x,l=e.y,c=e.z;t[0]=.282095,t[1]=.488603*l,t[2]=.488603*c,t[3]=.488603*i,t[4]=1.092548*i*l,t[5]=1.092548*l*c,t[6]=.315392*(3*c*c-1),t[7]=1.092548*i*c,t[8]=.546274*(i*i-l*l)}});function ea(e,t){Mi.call(this,void 0,t),this.sh=e!==void 0?e:new E_}ea.prototype=Object.assign(Object.create(Mi.prototype),{constructor:ea,isLightProbe:!0,copy:function(e){return Mi.prototype.copy.call(this,e),this.sh.copy(e.sh),this.intensity=e.intensity,this},toJSON:function(e){var t=Mi.prototype.toJSON.call(this,e);return t}});function s1(e,t,i){ea.call(this,void 0,i);var l=new tn().set(e),c=new tn().set(t),h=new Pe(l.r,l.g,l.b),f=new Pe(c.r,c.g,c.b),r=Math.sqrt(Math.PI),v=r*Math.sqrt(.75);this.sh.coefficients[0].copy(h).add(f).multiplyScalar(r),this.sh.coefficients[1].copy(h).sub(f).multiplyScalar(v)}s1.prototype=Object.assign(Object.create(ea.prototype),{constructor:s1,isHemisphereLightProbe:!0,copy:function(e){return ea.prototype.copy.call(this,e),this},toJSON:function(e){var t=ea.prototype.toJSON.call(this,e);return t}});function l1(e,t){ea.call(this,void 0,t);var i=new tn().set(e);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}l1.prototype=Object.assign(Object.create(ea.prototype),{constructor:l1,isAmbientLightProbe:!0,copy:function(e){return ea.prototype.copy.call(this,e),this},toJSON:function(e){var t=ea.prototype.toJSON.call(this,e);return t}});var c1=new Hn,u1=new Hn;function bS(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Xi,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Xi,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}Object.assign(bS.prototype,{update:function(e){var t=this._cache,i=t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep;if(i){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep;var l=e.projectionMatrix.clone(),c=t.eyeSep/2,h=c*t.near/t.focus,f=t.near*Math.tan(jn.DEG2RAD*t.fov*.5)/t.zoom,r,v;u1.elements[12]=-c,c1.elements[12]=c,r=-f*t.aspect+h,v=f*t.aspect+h,l.elements[0]=2*t.near/(v-r),l.elements[8]=(v+r)/(v-r),this.cameraL.projectionMatrix.copy(l),r=-f*t.aspect-h,v=f*t.aspect-h,l.elements[0]=2*t.near/(v-r),l.elements[8]=(v+r)/(v-r),this.cameraR.projectionMatrix.copy(l)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(u1),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(c1)}});function h1(e){this.autoStart=e!==void 0?e:!0,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}Object.assign(h1.prototype,{start:function(){this.startTime=(typeof performance=="undefined"?Date:performance).now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1,this.autoStart=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var t=(typeof performance=="undefined"?Date:performance).now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}});var pl=new Pe,d1=new Nr,wS=new Pe,fl=new Pe;function p1(){on.call(this),this.type="AudioListener",this.context=a1.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new h1}p1.prototype=Object.assign(Object.create(on.prototype),{constructor:p1,getInput:function(){return this.gain},removeFilter:function(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this},getFilter:function(){return this.filter},setFilter:function(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this},getMasterVolume:function(){return this.gain.gain.value},setMasterVolume:function(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this},updateMatrixWorld:function(e){on.prototype.updateMatrixWorld.call(this,e);var t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(pl,d1,wS),fl.set(0,0,-1).applyQuaternion(d1),t.positionX){var l=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(pl.x,l),t.positionY.linearRampToValueAtTime(pl.y,l),t.positionZ.linearRampToValueAtTime(pl.z,l),t.forwardX.linearRampToValueAtTime(fl.x,l),t.forwardY.linearRampToValueAtTime(fl.y,l),t.forwardZ.linearRampToValueAtTime(fl.z,l),t.upX.linearRampToValueAtTime(i.x,l),t.upY.linearRampToValueAtTime(i.y,l),t.upZ.linearRampToValueAtTime(i.z,l)}else t.setPosition(pl.x,pl.y,pl.z),t.setOrientation(fl.x,fl.y,fl.z,i.x,i.y,i.z)}});function sd(e){on.call(this),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this._startedAt=0,this._pausedAt=0,this.filters=[]}sd.prototype=Object.assign(Object.create(on.prototype),{constructor:sd,getOutput:function(){return this.gain},setNodeSource:function(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this},setMediaElementSource:function(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this},setMediaStreamSource:function(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this},setBuffer:function(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this},play:function(e){if(e===void 0&&(e=0),this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;var t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._pausedAt+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()},pause:function(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._pausedAt=(this.context.currentTime-this._startedAt)*this.playbackRate,this.source.stop(),this.source.onended=null,this.isPlaying=!1),this},stop:function(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._pausedAt=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this},connect:function(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(var e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this},disconnect:function(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(var e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this},getFilters:function(){return this.filters},setFilters:function(e){return e||(e=[]),this.isPlaying===!0?(this.disconnect(),this.filters=e,this.connect()):this.filters=e,this},setDetune:function(e){if(this.detune=e,this.source.detune!==void 0)return this.isPlaying===!0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this},getDetune:function(){return this.detune},getFilter:function(){return this.getFilters()[0]},setFilter:function(e){return this.setFilters(e?[e]:[])},setPlaybackRate:function(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this},getPlaybackRate:function(){return this.playbackRate},onEnded:function(){this.isPlaying=!1},getLoop:function(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop},setLoop:function(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this},setLoopStart:function(e){return this.loopStart=e,this},setLoopEnd:function(e){return this.loopEnd=e,this},getVolume:function(){return this.gain.gain.value},setVolume:function(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}});var ml=new Pe,f1=new Nr,MS=new Pe,gl=new Pe;function m1(e){sd.call(this,e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}m1.prototype=Object.assign(Object.create(sd.prototype),{constructor:m1,getOutput:function(){return this.panner},getRefDistance:function(){return this.panner.refDistance},setRefDistance:function(e){return this.panner.refDistance=e,this},getRolloffFactor:function(){return this.panner.rolloffFactor},setRolloffFactor:function(e){return this.panner.rolloffFactor=e,this},getDistanceModel:function(){return this.panner.distanceModel},setDistanceModel:function(e){return this.panner.distanceModel=e,this},getMaxDistance:function(){return this.panner.maxDistance},setMaxDistance:function(e){return this.panner.maxDistance=e,this},setDirectionalCone:function(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this},updateMatrixWorld:function(e){if(on.prototype.updateMatrixWorld.call(this,e),!(this.hasPlaybackControl===!0&&this.isPlaying===!1)){this.matrixWorld.decompose(ml,f1,MS),gl.set(0,0,1).applyQuaternion(f1);var t=this.panner;if(t.positionX){var i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(ml.x,i),t.positionY.linearRampToValueAtTime(ml.y,i),t.positionZ.linearRampToValueAtTime(ml.z,i),t.orientationX.linearRampToValueAtTime(gl.x,i),t.orientationY.linearRampToValueAtTime(gl.y,i),t.orientationZ.linearRampToValueAtTime(gl.z,i)}else t.setPosition(ml.x,ml.y,ml.z),t.setOrientation(gl.x,gl.y,gl.z)}}});function g1(e,t){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t!==void 0?t:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}Object.assign(g1.prototype,{getFrequencyData:function(){return this.analyser.getByteFrequencyData(this.data),this.data},getAverageFrequency:function(){for(var e=0,t=this.getFrequencyData(),i=0;i<t.length;i++)e+=t[i];return e/t.length}});function y1(e,t,i){this.binding=e,this.valueSize=i;var l=Float64Array,c;switch(t){case"quaternion":c=this._slerp;break;case"string":case"bool":l=Array,c=this._select;break;default:c=this._lerp}this.buffer=new l(i*4),this._mixBufferRegion=c,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}Object.assign(y1.prototype,{accumulate:function(e,t){var i=this.buffer,l=this.valueSize,c=e*l+l,h=this.cumulativeWeight;if(h===0){for(var f=0;f!==l;++f)i[c+f]=i[f];h=t}else{h+=t;var r=t/h;this._mixBufferRegion(i,c,0,r,l)}this.cumulativeWeight=h},apply:function(e){var t=this.valueSize,i=this.buffer,l=e*t+t,c=this.cumulativeWeight,h=this.binding;if(this.cumulativeWeight=0,c<1){var f=t*3;this._mixBufferRegion(i,l,f,1-c,t)}for(var r=t,v=t+t;r!==v;++r)if(i[r]!==i[r+t]){h.setValue(i,l);break}},saveOriginalState:function(){var e=this.binding,t=this.buffer,i=this.valueSize,l=i*3;e.getValue(t,l);for(var c=i,h=l;c!==h;++c)t[c]=t[l+c%i];this.cumulativeWeight=0},restoreOriginalState:function(){var e=this.valueSize*3;this.binding.setValue(this.buffer,e)},_select:function(e,t,i,l,c){if(l>=.5)for(var h=0;h!==c;++h)e[t+h]=e[i+h]},_slerp:function(e,t,i,l){Nr.slerpFlat(e,t,e,t,e,i,l)},_lerp:function(e,t,i,l,c){for(var h=1-l,f=0;f!==c;++f){var r=t+f;e[r]=e[r]*h+e[i+f]*l}}});var C_="\\[\\]\\.:\\/",TS=new RegExp("["+C_+"]","g"),A_="[^"+C_+"]",ES="[^"+C_.replace("\\.","")+"]",CS=/((?:WC+[\/:])*)/.source.replace("WC",A_),AS=/(WCOD+)?/.source.replace("WCOD",ES),DS=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",A_),PS=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",A_),SS=new RegExp("^"+CS+AS+DS+PS+"$"),LS=["material","materials","bones"];function _1(e,t,i){var l=i||gr.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,l)}Object.assign(_1.prototype,{getValue:function(e,t){this.bind();var i=this._targetGroup.nCachedObjects_,l=this._bindings[i];l!==void 0&&l.getValue(e,t)},setValue:function(e,t){for(var i=this._bindings,l=this._targetGroup.nCachedObjects_,c=i.length;l!==c;++l)i[l].setValue(e,t)},bind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()},unbind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}});function gr(e,t,i){this.path=t,this.parsedPath=i||gr.parseTrackName(t),this.node=gr.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}Object.assign(gr,{Composite:_1,create:function(e,t,i){return e&&e.isAnimationObjectGroup?new gr.Composite(e,t,i):new gr(e,t,i)},sanitizeNodeName:function(e){return e.replace(/\s/g,"_").replace(TS,"")},parseTrackName:function(e){var t=SS.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);var i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},l=i.nodeName&&i.nodeName.lastIndexOf(".");if(l!==void 0&&l!==-1){var c=i.nodeName.substring(l+1);LS.indexOf(c)!==-1&&(i.nodeName=i.nodeName.substring(0,l),i.objectName=c)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i},findNode:function(e,t){if(!t||t===""||t==="root"||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){var i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){var l=function(h){for(var f=0;f<h.length;f++){var r=h[f];if(r.name===t||r.uuid===t)return r;var v=l(r.children);if(v)return v}return null},c=l(e.children);if(c)return c}return null}}),Object.assign(gr.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(t,i){t[i]=this.node[this.propertyName]},function(t,i){for(var l=this.resolvedProperty,c=0,h=l.length;c!==h;++c)t[i++]=l[c]},function(t,i){t[i]=this.resolvedProperty[this.propertyIndex]},function(t,i){this.resolvedProperty.toArray(t,i)}],SetterByBindingTypeAndVersioning:[[function(t,i){this.targetObject[this.propertyName]=t[i]},function(t,i){this.targetObject[this.propertyName]=t[i],this.targetObject.needsUpdate=!0},function(t,i){this.targetObject[this.propertyName]=t[i],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,i){for(var l=this.resolvedProperty,c=0,h=l.length;c!==h;++c)l[c]=t[i++]},function(t,i){for(var l=this.resolvedProperty,c=0,h=l.length;c!==h;++c)l[c]=t[i++];this.targetObject.needsUpdate=!0},function(t,i){for(var l=this.resolvedProperty,c=0,h=l.length;c!==h;++c)l[c]=t[i++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,i){this.resolvedProperty[this.propertyIndex]=t[i]},function(t,i){this.resolvedProperty[this.propertyIndex]=t[i],this.targetObject.needsUpdate=!0},function(t,i){this.resolvedProperty[this.propertyIndex]=t[i],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,i){this.resolvedProperty.fromArray(t,i)},function(t,i){this.resolvedProperty.fromArray(t,i),this.targetObject.needsUpdate=!0},function(t,i){this.resolvedProperty.fromArray(t,i),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(t,i){this.bind(),this.getValue(t,i)},setValue:function(t,i){this.bind(),this.setValue(t,i)},bind:function(){var e=this.node,t=this.parsedPath,i=t.objectName,l=t.propertyName,c=t.propertyIndex;if(e||(e=gr.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(i){var h=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(var f=0;f<e.length;f++)if(e[f].name===h){h=f;break}break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(h!==void 0){if(e[h]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[h]}}var r=e[l];if(r===void 0){var v=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+v+"."+l+" but it wasn't found.",e);return}var x=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?x=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(x=this.Versioning.MatrixWorldNeedsUpdate);var w=this.BindingType.Direct;if(c!==void 0){if(l==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(e.geometry.isBufferGeometry){if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}for(var f=0;f<this.node.geometry.morphAttributes.position.length;f++)if(e.geometry.morphAttributes.position[f].name===c){c=f;break}}else{if(!e.geometry.morphTargets){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphTargets.",this);return}for(var f=0;f<this.node.geometry.morphTargets.length;f++)if(e.geometry.morphTargets[f].name===c){c=f;break}}}w=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=c}else r.fromArray!==void 0&&r.toArray!==void 0?(w=this.BindingType.HasFromToArray,this.resolvedProperty=r):Array.isArray(r)?(w=this.BindingType.EntireArray,this.resolvedProperty=r):this.propertyName=l;this.getValue=this.GetterByBindingType[w],this.setValue=this.SetterByBindingTypeAndVersioning[w][x]},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}});//!\ DECLARE ALIAS AFTER assign prototype !
- Object.assign(gr.prototype,{_getValue_unbound:gr.prototype.getValue,_setValue_unbound:gr.prototype.setValue});function IS(){this.uuid=jn.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(var t=0,i=arguments.length;t!==i;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var l=this;this.stats={objects:{get total(){return l._objects.length},get inUse(){return this.total-l.nCachedObjects_}},get bindingsPerObject(){return l._bindings.length}}}Object.assign(IS.prototype,{isAnimationObjectGroup:!0,add:function(){for(var e=this._objects,t=e.length,i=this.nCachedObjects_,l=this._indicesByUUID,c=this._paths,h=this._parsedPaths,f=this._bindings,r=f.length,v=void 0,x=0,w=arguments.length;x!==w;++x){var b=arguments[x],A=b.uuid,L=l[A];if(L===void 0){L=t++,l[A]=L,e.push(b);for(var P=0,R=r;P!==R;++P)f[P].push(new gr(b,c[P],h[P]))}else if(L<i){v=e[L];var F=--i,V=e[F];l[V.uuid]=L,e[L]=V,l[A]=F,e[F]=b;for(var P=0,R=r;P!==R;++P){var j=f[P],J=j[F],ne=j[L];j[L]=J,ne===void 0&&(ne=new gr(b,c[P],h[P])),j[F]=ne}}else e[L]!==v&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=i},remove:function(){for(var e=this._objects,t=this.nCachedObjects_,i=this._indicesByUUID,l=this._bindings,c=l.length,h=0,f=arguments.length;h!==f;++h){var r=arguments[h],v=r.uuid,x=i[v];if(x!==void 0&&x>=t){var w=t++,b=e[w];i[b.uuid]=x,e[x]=b,i[v]=w,e[w]=r;for(var A=0,L=c;A!==L;++A){var P=l[A],R=P[w],F=P[x];P[x]=R,P[w]=F}}}this.nCachedObjects_=t},uncache:function(){for(var e=this._objects,t=e.length,i=this.nCachedObjects_,l=this._indicesByUUID,c=this._bindings,h=c.length,f=0,r=arguments.length;f!==r;++f){var v=arguments[f],x=v.uuid,w=l[x];if(w!==void 0)if(delete l[x],w<i){var b=--i,A=e[b],L=--t,P=e[L];l[A.uuid]=w,e[w]=A,l[P.uuid]=b,e[b]=P,e.pop();for(var R=0,F=h;R!==F;++R){var V=c[R],j=V[b],J=V[L];V[w]=j,V[b]=J,V.pop()}}else{var L=--t,P=e[L];l[P.uuid]=w,e[w]=P,e.pop();for(var R=0,F=h;R!==F;++R){var V=c[R];V[w]=V[L],V.pop()}}}this.nCachedObjects_=i},subscribe_:function(e,t){var i=this._bindingsIndicesByPath,l=i[e],c=this._bindings;if(l!==void 0)return c[l];var h=this._paths,f=this._parsedPaths,r=this._objects,v=r.length,x=this.nCachedObjects_,w=new Array(v);l=c.length,i[e]=l,h.push(e),f.push(t),c.push(w);for(var b=x,A=r.length;b!==A;++b){var L=r[b];w[b]=new gr(L,e,t)}return w},unsubscribe_:function(e){var t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){var l=this._paths,c=this._parsedPaths,h=this._bindings,f=h.length-1,r=h[f],v=e[f];t[v]=i,h[i]=r,h.pop(),c[i]=c[f],c.pop(),l[i]=l[f],l.pop()}}});function v1(e,t,i){this._mixer=e,this._clip=t,this._localRoot=i||null;for(var l=t.tracks,c=l.length,h=new Array(c),f={endingStart:lc,endingEnd:lc},r=0;r!==c;++r){var v=l[r].createInterpolant(null);h[r]=v,v.settings=f}this._interpolantSettings=f,this._interpolants=h,this._propertyBindings=new Array(c),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=CE,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}Object.assign(v1.prototype,{play:function(){return this._mixer._activateAction(this),this},stop:function(){return this._mixer._deactivateAction(this),this.reset()},reset:function(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()},isRunning:function(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},startAt:function(e){return this._startTime=e,this},setLoop:function(e,t){return this.loop=e,this.repetitions=t,this},setEffectiveWeight:function(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(e){return this._scheduleFading(e,0,1)},fadeOut:function(e){return this._scheduleFading(e,1,0)},crossFadeFrom:function(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){var l=this._clip.duration,c=e._clip.duration,h=c/l,f=l/c;e.warp(1,h,t),this.warp(f,1,t)}return this},crossFadeTo:function(e,t,i){return e.crossFadeFrom(this,t,i)},stopFading:function(){var e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this},setEffectiveTimeScale:function(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(e){return this.timeScale=this._clip.duration/e,this.stopWarping()},syncWith:function(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()},halt:function(e){return this.warp(this._effectiveTimeScale,0,e)},warp:function(e,t,i){var l=this._mixer,c=l.time,h=this._timeScaleInterpolant,f=this.timeScale;h===null&&(h=l._lendControlInterpolant(),this._timeScaleInterpolant=h);var r=h.parameterPositions,v=h.sampleValues;return r[0]=c,r[1]=c+i,v[0]=e/f,v[1]=t/f,this},stopWarping:function(){var e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||this._mixer._root},_update:function(e,t,i,l){if(!this.enabled){this._updateWeight(e);return}var c=this._startTime;if(c!==null){var h=(e-c)*i;if(h<0||i===0)return;this._startTime=null,t=i*h}t*=this._updateTimeScale(e);var f=this._updateTime(t),r=this._updateWeight(e);if(r>0)for(var v=this._interpolants,x=this._propertyBindings,w=0,b=v.length;w!==b;++w)v[w].evaluate(f),x[w].accumulate(l,r)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var i=this._weightInterpolant;if(i!==null){var l=i.evaluate(e)[0];t*=l,e>i.parameterPositions[1]&&(this.stopFading(),l===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var i=this._timeScaleInterpolant;if(i!==null){var l=i.evaluate(e)[0];t*=l,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t},_updateTime:function(e){var t=this.time+e,i=this._clip.duration,l=this.loop,c=this._loopCount,h=l===AE;if(e===0)return c===-1?t:h&&(c&1)===1?i-t:t;if(l===EE){c===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(t>=i)t=i;else if(t<0)t=0;else{this.time=t;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=t,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(c===-1&&(e>=0?(c=0,this._setEndings(!0,this.repetitions===0,h)):this._setEndings(this.repetitions===0,!0,h)),t>=i||t<0){var f=Math.floor(t/i);t-=i*f,c+=Math.abs(f);var r=this.repetitions-c;if(r<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=e>0?i:0,this.time=t,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(r===1){var v=e<0;this._setEndings(v,!v,h)}else this._setEndings(!1,!1,h);this._loopCount=c,this.time=t,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:f})}}else this.time=t;if(h&&(c&1)===1)return i-t}return t},_setEndings:function(e,t,i){var l=this._interpolantSettings;i?(l.endingStart=cc,l.endingEnd=cc):(e?l.endingStart=this.zeroSlopeAtStart?cc:lc:l.endingStart=tf,t?l.endingEnd=this.zeroSlopeAtEnd?cc:lc:l.endingEnd=tf)},_scheduleFading:function(e,t,i){var l=this._mixer,c=l.time,h=this._weightInterpolant;h===null&&(h=l._lendControlInterpolant(),this._weightInterpolant=h);var f=h.parameterPositions,r=h.sampleValues;return f[0]=c,r[0]=t,f[1]=c+e,r[1]=i,this}});function x1(e){this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}x1.prototype=Object.assign(Object.create(Ta.prototype),{constructor:x1,_bindAction:function(e,t){var i=e._localRoot||this._root,l=e._clip.tracks,c=l.length,h=e._propertyBindings,f=e._interpolants,r=i.uuid,v=this._bindingsByRootAndName,x=v[r];x===void 0&&(x={},v[r]=x);for(var w=0;w!==c;++w){var b=l[w],A=b.name,L=x[A];if(L!==void 0)h[w]=L;else{if(L=h[w],L!==void 0){L._cacheIndex===null&&(++L.referenceCount,this._addInactiveBinding(L,r,A));continue}var P=t&&t._propertyBindings[w].binding.parsedPath;L=new y1(gr.create(i,A,P),b.ValueTypeName,b.getValueSize()),++L.referenceCount,this._addInactiveBinding(L,r,A),h[w]=L}f[w].resultBuffer=L.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){var t=(e._localRoot||this._root).uuid,i=e._clip.uuid,l=this._actionsByClip[i];this._bindAction(e,l&&l.knownActions[0]),this._addInactiveAction(e,i,t)}for(var c=e._propertyBindings,h=0,f=c.length;h!==f;++h){var r=c[h];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,i=0,l=t.length;i!==l;++i){var c=t[i];--c.useCount===0&&(c.restoreOriginalState(),this._takeBackBinding(c))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){var t=e._cacheIndex;return t!==null&&t<this._nActiveActions},_addInactiveAction:function(e,t,i){var l=this._actions,c=this._actionsByClip,h=c[t];if(h===void 0)h={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,c[t]=h;else{var f=h.knownActions;e._byClipCacheIndex=f.length,f.push(e)}e._cacheIndex=l.length,l.push(e),h.actionByRoot[i]=e},_removeInactiveAction:function(e){var t=this._actions,i=t[t.length-1],l=e._cacheIndex;i._cacheIndex=l,t[l]=i,t.pop(),e._cacheIndex=null;var c=e._clip.uuid,h=this._actionsByClip,f=h[c],r=f.knownActions,v=r[r.length-1],x=e._byClipCacheIndex;v._byClipCacheIndex=x,r[x]=v,r.pop(),e._byClipCacheIndex=null;var w=f.actionByRoot,b=(e._localRoot||this._root).uuid;delete w[b],r.length===0&&delete h[c],this._removeInactiveBindingsForAction(e)},_removeInactiveBindingsForAction:function(e){for(var t=e._propertyBindings,i=0,l=t.length;i!==l;++i){var c=t[i];--c.referenceCount===0&&this._removeInactiveBinding(c)}},_lendAction:function(e){var t=this._actions,i=e._cacheIndex,l=this._nActiveActions++,c=t[l];e._cacheIndex=l,t[l]=e,c._cacheIndex=i,t[i]=c},_takeBackAction:function(e){var t=this._actions,i=e._cacheIndex,l=--this._nActiveActions,c=t[l];e._cacheIndex=l,t[l]=e,c._cacheIndex=i,t[i]=c},_addInactiveBinding:function(e,t,i){var l=this._bindingsByRootAndName,c=l[t],h=this._bindings;c===void 0&&(c={},l[t]=c),c[i]=e,e._cacheIndex=h.length,h.push(e)},_removeInactiveBinding:function(e){var t=this._bindings,i=e.binding,l=i.rootNode.uuid,c=i.path,h=this._bindingsByRootAndName,f=h[l],r=t[t.length-1],v=e._cacheIndex;r._cacheIndex=v,t[v]=r,t.pop(),delete f[c],Object.keys(f).length===0&&delete h[l]},_lendBinding:function(e){var t=this._bindings,i=e._cacheIndex,l=this._nActiveBindings++,c=t[l];e._cacheIndex=l,t[l]=e,c._cacheIndex=i,t[i]=c},_takeBackBinding:function(e){var t=this._bindings,i=e._cacheIndex,l=--this._nActiveBindings,c=t[l];e._cacheIndex=l,t[l]=e,c._cacheIndex=i,t[i]=c},_lendControlInterpolant:function(){var e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new nm(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),i.__cacheIndex=t,e[t]=i),i},_takeBackControlInterpolant:function(e){var t=this._controlInterpolants,i=e.__cacheIndex,l=--this._nActiveControlInterpolants,c=t[l];e.__cacheIndex=l,t[l]=e,c.__cacheIndex=i,t[i]=c},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(e,t){var i=t||this._root,l=i.uuid,c=typeof e=="string"?vo.findByName(i,e):e,h=c!==null?c.uuid:e,f=this._actionsByClip[h],r=null;if(f!==void 0){var v=f.actionByRoot[l];if(v!==void 0)return v;r=f.knownActions[0],c===null&&(c=r._clip)}if(c===null)return null;var x=new v1(this,c,t);return this._bindAction(x,r),this._addInactiveAction(x,h,l),x},existingAction:function(e,t){var i=t||this._root,l=i.uuid,c=typeof e=="string"?vo.findByName(i,e):e,h=c?c.uuid:e,f=this._actionsByClip[h];return f!==void 0&&f.actionByRoot[l]||null},stopAllAction:function(){var e=this._actions,t=this._nActiveActions,i=this._bindings,l=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(var c=0;c!==t;++c)e[c].reset();for(var c=0;c!==l;++c)i[c].useCount=0;return this},update:function(e){e*=this.timeScale;for(var t=this._actions,i=this._nActiveActions,l=this.time+=e,c=Math.sign(e),h=this._accuIndex^=1,f=0;f!==i;++f){var r=t[f];r._update(l,e,c,h)}for(var v=this._bindings,x=this._nActiveBindings,f=0;f!==x;++f)v[f].apply(h);return this},setTime:function(e){this.time=0;for(var t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)},getRoot:function(){return this._root},uncacheClip:function(e){var t=this._actions,i=e.uuid,l=this._actionsByClip,c=l[i];if(c!==void 0){for(var h=c.knownActions,f=0,r=h.length;f!==r;++f){var v=h[f];this._deactivateAction(v);var x=v._cacheIndex,w=t[t.length-1];v._cacheIndex=null,v._byClipCacheIndex=null,w._cacheIndex=x,t[x]=w,t.pop(),this._removeInactiveBindingsForAction(v)}delete l[i]}},uncacheRoot:function(e){var t=e.uuid,i=this._actionsByClip;for(var l in i){var c=i[l].actionByRoot,h=c[t];h!==void 0&&(this._deactivateAction(h),this._removeInactiveAction(h))}var f=this._bindingsByRootAndName,r=f[t];if(r!==void 0)for(var v in r){var x=r[v];x.restoreOriginalState(),this._removeInactiveBinding(x)}},uncacheAction:function(e,t){var i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}});function D_(e){typeof e=="string"&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}D_.prototype.clone=function(){return new D_(this.value.clone===void 0?this.value:this.value.clone())};function b1(e,t,i){ka.call(this,e,t),this.meshPerAttribute=i||1}b1.prototype=Object.assign(Object.create(ka.prototype),{constructor:b1,isInstancedInterleavedBuffer:!0,copy:function(e){return ka.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this}});function RS(e,t,i,l){this.ray=new yc(e,t),this.near=i||0,this.far=l||1/0,this.camera=null,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function w1(e,t){return e.distance-t.distance}function P_(e,t,i,l){if(e.visible!==!1&&(e.raycast(t,i),l===!0))for(var c=e.children,h=0,f=c.length;h<f;h++)P_(c[h],t,i,!0)}Object.assign(RS.prototype,{linePrecision:1,set:function(e,t){this.ray.set(e,t)},setFromCamera:function(e,t){t&&t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t&&t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(e,t,i){var l=i||[];return P_(e,this,l,t),l.sort(w1),l},intersectObjects:function(e,t,i){var l=i||[];if(Array.isArray(e)===!1)return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),l;for(var c=0,h=e.length;c<h;c++)P_(e[c],this,l,t);return l.sort(w1),l}});function kS(e,t,i){return this.radius=e!==void 0?e:1,this.phi=t!==void 0?t:0,this.theta=i!==void 0?i:0,this}Object.assign(kS.prototype,{set:function(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this},makeSafe:function(){var e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,this.phi)),this},setFromVector3:function(e){return this.setFromCartesianCoords(e.x,e.y,e.z)},setFromCartesianCoords:function(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(jn.clamp(t/this.radius,-1,1))),this}});function zS(e,t,i){return this.radius=e!==void 0?e:1,this.theta=t!==void 0?t:0,this.y=i!==void 0?i:0,this}Object.assign(zS.prototype,{set:function(e,t,i){return this.radius=e,this.theta=t,this.y=i,this},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this},setFromVector3:function(e){return this.setFromCartesianCoords(e.x,e.y,e.z)},setFromCartesianCoords:function(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}});var M1=new Lt;function T1(e,t){this.min=e!==void 0?e:new Lt(1/0,1/0),this.max=t!==void 0?t:new Lt(-1/0,-1/0)}Object.assign(T1.prototype,{set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this},setFromCenterAndSize:function(e,t){var i=M1.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},getCenter:function(e){return e===void 0&&(console.warn("THREE.Box2: .getCenter() target is now required"),e=new Lt),this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(e){return e===void 0&&(console.warn("THREE.Box2: .getSize() target is now required"),e=new Lt),this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)},expandByPoint:function(e){return this.min.min(e),this.max.max(e),this},expandByVector:function(e){return this.min.sub(e),this.max.add(e),this},expandByScalar:function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},containsPoint:function(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)},containsBox:function(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},getParameter:function(e,t){return t===void 0&&(console.warn("THREE.Box2: .getParameter() target is now required"),t=new Lt),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(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)},clampPoint:function(e,t){return t===void 0&&(console.warn("THREE.Box2: .clampPoint() target is now required"),t=new Lt),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){var t=M1.copy(e).clamp(this.min,this.max);return t.sub(e).length()},intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}});var E1=new Pe,lm=new Pe;function C1(e,t){this.start=e!==void 0?e:new Pe,this.end=t!==void 0?t:new Pe}Object.assign(C1.prototype,{set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},getCenter:function(e){return e===void 0&&(console.warn("THREE.Line3: .getCenter() target is now required"),e=new Pe),e.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return e===void 0&&(console.warn("THREE.Line3: .delta() target is now required"),e=new Pe),e.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){return t===void 0&&(console.warn("THREE.Line3: .at() target is now required"),t=new Pe),this.delta(t).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(e,t){E1.subVectors(e,this.start),lm.subVectors(this.end,this.start);var i=lm.dot(lm),l=lm.dot(E1),c=l/i;return t&&(c=jn.clamp(c,0,1)),c},closestPointToPoint:function(e,t,i){var l=this.closestPointToPointParameter(e,t);return i===void 0&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),i=new Pe),this.delta(i).multiplyScalar(l).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}});function cm(e){on.call(this),this.material=e,this.render=function(){}}cm.prototype=Object.create(on.prototype),cm.prototype.constructor=cm,cm.prototype.isImmediateRenderObject=!0;var A1=new Pe;function ld(e,t){on.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;for(var i=new vn,l=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1],c=0,h=1,f=32;c<f;c++,h++){var r=c/f*Math.PI*2,v=h/f*Math.PI*2;l.push(Math.cos(r),Math.sin(r),1,Math.cos(v),Math.sin(v),1)}i.setAttribute("position",new ln(l,3));var x=new Ri({fog:!1});this.cone=new Vi(i,x),this.add(this.cone),this.update()}ld.prototype=Object.create(on.prototype),ld.prototype.constructor=ld,ld.prototype.dispose=function(){this.cone.geometry.dispose(),this.cone.material.dispose()},ld.prototype.update=function(){this.light.updateMatrixWorld();var e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),A1.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(A1),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)};var ds=new Pe,um=new Hn,S_=new Hn;function D1(e){var t=[];e&&e.isBone&&t.push(e);for(var i=0;i<e.children.length;i++)t.push.apply(t,D1(e.children[i]));return t}function cd(e){for(var t=D1(e),i=new vn,l=[],c=[],h=new tn(0,0,1),f=new tn(0,1,0),r=0;r<t.length;r++){var v=t[r];v.parent&&v.parent.isBone&&(l.push(0,0,0),l.push(0,0,0),c.push(h.r,h.g,h.b),c.push(f.r,f.g,f.b))}i.setAttribute("position",new ln(l,3)),i.setAttribute("color",new ln(c,3));var x=new Ri({vertexColors:ic,depthTest:!1,depthWrite:!1,transparent:!0});Vi.call(this,i,x),this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}cd.prototype=Object.create(Vi.prototype),cd.prototype.constructor=cd,cd.prototype.updateMatrixWorld=function(e){var t=this.bones,i=this.geometry,l=i.getAttribute("position");S_.getInverse(this.root.matrixWorld);for(var c=0,h=0;c<t.length;c++){var f=t[c];f.parent&&f.parent.isBone&&(um.multiplyMatrices(S_,f.matrixWorld),ds.setFromMatrixPosition(um),l.setXYZ(h,ds.x,ds.y,ds.z),um.multiplyMatrices(S_,f.parent.matrixWorld),ds.setFromMatrixPosition(um),l.setXYZ(h+1,ds.x,ds.y,ds.z),h+=2)}i.getAttribute("position").needsUpdate=!0,on.prototype.updateMatrixWorld.call(this,e)};function ud(e,t,i){this.light=e,this.light.updateMatrixWorld(),this.color=i;var l=new Vc(t,4,2),c=new cr({wireframe:!0,fog:!1});Ai.call(this,l,c),this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}ud.prototype=Object.create(Ai.prototype),ud.prototype.constructor=ud,ud.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose()},ud.prototype.update=function(){this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)};var FS=new Pe,P1=new tn,S1=new tn;function hd(e,t,i){on.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i;var l=new Bc(t);l.rotateY(Math.PI*.5),this.material=new cr({wireframe:!0,fog:!1}),this.color===void 0&&(this.material.vertexColors=ic);var c=l.getAttribute("position"),h=new Float32Array(c.count*3);l.setAttribute("color",new kn(h,3)),this.add(new Ai(l,this.material)),this.update()}hd.prototype=Object.create(on.prototype),hd.prototype.constructor=hd,hd.prototype.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},hd.prototype.update=function(){var e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{var t=e.geometry.getAttribute("color");P1.copy(this.light.color),S1.copy(this.light.groundColor);for(var i=0,l=t.count;i<l;i++){var c=i<l/2?P1:S1;t.setXYZ(i,c.r,c.g,c.b)}t.needsUpdate=!0}e.lookAt(FS.setFromMatrixPosition(this.light.matrixWorld).negate())};function L_(e,t,i,l){e=e||10,t=t||10,i=new tn(i!==void 0?i:4473924),l=new tn(l!==void 0?l:8947848);for(var c=t/2,h=e/t,f=e/2,r=[],v=[],x=0,w=0,b=-f;x<=t;x++,b+=h){r.push(-f,0,b,f,0,b),r.push(b,0,-f,b,0,f);var A=x===c?i:l;A.toArray(v,w),w+=3,A.toArray(v,w),w+=3,A.toArray(v,w),w+=3,A.toArray(v,w),w+=3}var L=new vn;L.setAttribute("position",new ln(r,3)),L.setAttribute("color",new ln(v,3));var P=new Ri({vertexColors:ic});Vi.call(this,L,P)}L_.prototype=Object.assign(Object.create(Vi.prototype),{constructor:L_,copy:function(e){return Vi.prototype.copy.call(this,e),this.geometry.copy(e.geometry),this.material.copy(e.material),this},clone:function(){return new this.constructor().copy(this)}});function I_(e,t,i,l,c,h){e=e||10,t=t||16,i=i||8,l=l||64,c=new tn(c!==void 0?c:4473924),h=new tn(h!==void 0?h:8947848);var f=[],r=[],v,x,w,b,A,L,P;for(b=0;b<=t;b++)w=b/t*(Math.PI*2),v=Math.sin(w)*e,x=Math.cos(w)*e,f.push(0,0,0),f.push(v,0,x),P=b&1?c:h,r.push(P.r,P.g,P.b),r.push(P.r,P.g,P.b);for(b=0;b<=i;b++)for(P=b&1?c:h,L=e-e/i*b,A=0;A<l;A++)w=A/l*(Math.PI*2),v=Math.sin(w)*L,x=Math.cos(w)*L,f.push(v,0,x),r.push(P.r,P.g,P.b),w=(A+1)/l*(Math.PI*2),v=Math.sin(w)*L,x=Math.cos(w)*L,f.push(v,0,x),r.push(P.r,P.g,P.b);var R=new vn;R.setAttribute("position",new ln(f,3)),R.setAttribute("color",new ln(r,3));var F=new Ri({vertexColors:ic});Vi.call(this,R,F)}I_.prototype=Object.create(Vi.prototype),I_.prototype.constructor=I_;var L1=new Pe,hm=new Pe,I1=new Pe;function dd(e,t,i){on.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,t===void 0&&(t=1);var l=new vn;l.setAttribute("position",new ln([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));var c=new Ri({fog:!1});this.lightPlane=new so(l,c),this.add(this.lightPlane),l=new vn,l.setAttribute("position",new ln([0,0,0,0,0,1],3)),this.targetLine=new so(l,c),this.add(this.targetLine),this.update()}dd.prototype=Object.create(on.prototype),dd.prototype.constructor=dd,dd.prototype.dispose=function(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()},dd.prototype.update=function(){L1.setFromMatrixPosition(this.light.matrixWorld),hm.setFromMatrixPosition(this.light.target.matrixWorld),I1.subVectors(hm,L1),this.lightPlane.lookAt(hm),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(hm),this.targetLine.scale.z=I1.length()};var dm=new Pe,ki=new Ia;function pm(e){var t=new vn,i=new Ri({color:16777215,vertexColors:wT}),l=[],c=[],h={},f=new tn(16755200),r=new tn(16711680),v=new tn(43775),x=new tn(16777215),w=new tn(3355443);b("n1","n2",f),b("n2","n4",f),b("n4","n3",f),b("n3","n1",f),b("f1","f2",f),b("f2","f4",f),b("f4","f3",f),b("f3","f1",f),b("n1","f1",f),b("n2","f2",f),b("n3","f3",f),b("n4","f4",f),b("p","n1",r),b("p","n2",r),b("p","n3",r),b("p","n4",r),b("u1","u2",v),b("u2","u3",v),b("u3","u1",v),b("c","t",x),b("p","c",w),b("cn1","cn2",w),b("cn3","cn4",w),b("cf1","cf2",w),b("cf3","cf4",w);function b(L,P,R){A(L,R),A(P,R)}function A(L,P){l.push(0,0,0),c.push(P.r,P.g,P.b),h[L]===void 0&&(h[L]=[]),h[L].push(l.length/3-1)}t.setAttribute("position",new ln(l,3)),t.setAttribute("color",new ln(c,3)),Vi.call(this,t,i),this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=h,this.update()}pm.prototype=Object.create(Vi.prototype),pm.prototype.constructor=pm,pm.prototype.update=function(){var e=this.geometry,t=this.pointMap,i=1,l=1;ki.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Wi("c",t,e,ki,0,0,-1),Wi("t",t,e,ki,0,0,1),Wi("n1",t,e,ki,-i,-l,-1),Wi("n2",t,e,ki,i,-l,-1),Wi("n3",t,e,ki,-i,l,-1),Wi("n4",t,e,ki,i,l,-1),Wi("f1",t,e,ki,-i,-l,1),Wi("f2",t,e,ki,i,-l,1),Wi("f3",t,e,ki,-i,l,1),Wi("f4",t,e,ki,i,l,1),Wi("u1",t,e,ki,i*.7,l*1.1,-1),Wi("u2",t,e,ki,-i*.7,l*1.1,-1),Wi("u3",t,e,ki,0,l*2,-1),Wi("cf1",t,e,ki,-i,0,1),Wi("cf2",t,e,ki,i,0,1),Wi("cf3",t,e,ki,0,-l,1),Wi("cf4",t,e,ki,0,l,1),Wi("cn1",t,e,ki,-i,0,-1),Wi("cn2",t,e,ki,i,0,-1),Wi("cn3",t,e,ki,0,-l,-1),Wi("cn4",t,e,ki,0,l,-1),e.getAttribute("position").needsUpdate=!0};function Wi(e,t,i,l,c,h,f){dm.set(c,h,f).unproject(l);var r=t[e];if(r!==void 0)for(var v=i.getAttribute("position"),x=0,w=r.length;x<w;x++)v.setXYZ(r[x],dm.x,dm.y,dm.z)}var fm=new Po;function yl(e,t){this.object=e,t===void 0&&(t=16776960);var i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),l=new Float32Array(8*3),c=new vn;c.setIndex(new kn(i,1)),c.setAttribute("position",new kn(l,3)),Vi.call(this,c,new Ri({color:t})),this.matrixAutoUpdate=!1,this.update()}yl.prototype=Object.create(Vi.prototype),yl.prototype.constructor=yl,yl.prototype.update=function(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&fm.setFromObject(this.object),!fm.isEmpty()){var t=fm.min,i=fm.max,l=this.geometry.attributes.position,c=l.array;c[0]=i.x,c[1]=i.y,c[2]=i.z,c[3]=t.x,c[4]=i.y,c[5]=i.z,c[6]=t.x,c[7]=t.y,c[8]=i.z,c[9]=i.x,c[10]=t.y,c[11]=i.z,c[12]=i.x,c[13]=i.y,c[14]=t.z,c[15]=t.x,c[16]=i.y,c[17]=t.z,c[18]=t.x,c[19]=t.y,c[20]=t.z,c[21]=i.x,c[22]=t.y,c[23]=t.z,l.needsUpdate=!0,this.geometry.computeBoundingSphere()}},yl.prototype.setFromObject=function(e){return this.object=e,this.update(),this},yl.prototype.copy=function(e){return Vi.prototype.copy.call(this,e),this.object=e.object,this},yl.prototype.clone=function(){return new this.constructor().copy(this)};function mm(e,t){this.type="Box3Helper",this.box=e,t=t||16776960;var i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),l=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],c=new vn;c.setIndex(new kn(i,1)),c.setAttribute("position",new ln(l,3)),Vi.call(this,c,new Ri({color:t})),this.geometry.computeBoundingSphere()}mm.prototype=Object.create(Vi.prototype),mm.prototype.constructor=mm,mm.prototype.updateMatrixWorld=function(e){var t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),on.prototype.updateMatrixWorld.call(this,e))};function gm(e,t,i){this.type="PlaneHelper",this.plane=e,this.size=t===void 0?1:t;var l=i!==void 0?i:16776960,c=[1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],h=new vn;h.setAttribute("position",new ln(c,3)),h.computeBoundingSphere(),so.call(this,h,new Ri({color:l}));var f=[1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],r=new vn;r.setAttribute("position",new ln(f,3)),r.computeBoundingSphere(),this.add(new Ai(r,new cr({color:l,opacity:.2,transparent:!0,depthWrite:!1})))}gm.prototype=Object.create(so.prototype),gm.prototype.constructor=gm,gm.prototype.updateMatrixWorld=function(e){var t=-this.plane.constant;Math.abs(t)<1e-8&&(t=1e-8),this.scale.set(.5*this.size,.5*this.size,t),this.children[0].material.side=t<0?tr:nc,this.lookAt(this.plane.normal),on.prototype.updateMatrixWorld.call(this,e)};var R1=new Pe,ym,R_;function ps(e,t,i,l,c,h){on.call(this),e===void 0&&(e=new Pe(0,0,1)),t===void 0&&(t=new Pe(0,0,0)),i===void 0&&(i=1),l===void 0&&(l=16776960),c===void 0&&(c=.2*i),h===void 0&&(h=.2*c),ym===void 0&&(ym=new vn,ym.setAttribute("position",new ln([0,0,0,0,1,0],3)),R_=new cs(0,.5,1,5,1),R_.translate(0,-.5,0)),this.position.copy(t),this.line=new so(ym,new Ri({color:l})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ai(R_,new cr({color:l})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,c,h)}ps.prototype=Object.create(on.prototype),ps.prototype.constructor=ps,ps.prototype.setDirection=function(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{R1.set(e.z,0,-e.x).normalize();var t=Math.acos(e.y);this.quaternion.setFromAxisAngle(R1,t)}},ps.prototype.setLength=function(e,t,i){t===void 0&&(t=.2*e),i===void 0&&(i=.2*t),this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()},ps.prototype.setColor=function(e){this.line.material.color.set(e),this.cone.material.color.set(e)},ps.prototype.copy=function(e){return on.prototype.copy.call(this,e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this},ps.prototype.clone=function(){return new this.constructor().copy(this)};function k_(e){e=e||1;var t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],l=new vn;l.setAttribute("position",new ln(t,3)),l.setAttribute("color",new ln(i,3));var c=new Ri({vertexColors:ic});Vi.call(this,l,c)}k_.prototype=Object.create(Vi.prototype),k_.prototype.constructor=k_;var nu=4,fs=8,ta=Math.pow(2,fs),k1=[.125,.215,.35,.446,.526,.582],z1=fs-nu+1+k1.length,iu=20,na={[io]:0,[_h]:1,[py]:2,[Vx]:3,[Gx]:4,[Wx]:5,[Ux]:6},z_=new tu,_m=US(iu),ms=null,gs=null,{_lodPlanes:pd,_sizeLods:F1,_sigmas:vm}=BS(),xm=null,yi=null,F_=null,_l=(1+Math.sqrt(5))/2,ru=1/_l,B1=[new Pe(1,1,1),new Pe(-1,1,1),new Pe(1,1,-1),new Pe(-1,1,-1),new Pe(0,_l,ru),new Pe(0,_l,-ru),new Pe(ru,0,_l),new Pe(-ru,0,_l),new Pe(_l,ru,0),new Pe(-_l,ru,0)];function O1(e){yi=e,B_(_m)}O1.prototype={constructor:O1,fromScene:function(e,t=0,i=.1,l=100){F_=yi.getRenderTarget();var c=N1();return OS(e,i,l,c),t>0&&W1(c,0,0,t),G1(c),U1(c),c},fromEquirectangular:function(e){return e.magFilter=Ui,e.minFilter=Ui,e.generateMipmaps=!1,this.fromCubemap(e)},fromCubemap:function(e){F_=yi.getRenderTarget();var t=N1(e);return NS(e,t),G1(t),U1(t),t},compileCubemapShader:function(){gs==null&&(gs=$1(),B_(gs))},compileEquirectangularShader:function(){ms==null&&(ms=H1(),B_(ms))},dispose:function(){_m.dispose(),gs!=null&&gs.dispose(),ms!=null&&ms.dispose();for(var e=0;e<pd.length;e++)pd[e].dispose()}};function BS(){for(var e=[],t=[],i=[],l=fs,c=0;c<z1;c++){var h=Math.pow(2,l);t.push(h);var f=1/h;c>fs-nu?f=k1[c-fs+nu-1]:c==0&&(f=0),i.push(f);for(var r=1/(h-1),v=-r/2,x=1+r/2,w=[v,v,x,v,x,x,v,v,x,x,v,x],b=6,A=6,L=3,P=2,R=1,F=new Float32Array(L*A*b),V=new Float32Array(P*A*b),j=new Float32Array(R*A*b),J=0;J<b;J++){var ne=J%3*2/3-1,H=J>2?0:-1,Q=[ne,H,0,ne+2/3,H,0,ne+2/3,H+1,0,ne,H,0,ne+2/3,H+1,0,ne,H+1,0];F.set(Q,L*A*J),V.set(w,P*A*J);var ae=[J,J,J,J,J,J];j.set(ae,R*A*J)}var ie=new vn;ie.setAttribute("position",new kn(F,L)),ie.setAttribute("uv",new kn(V,P)),ie.setAttribute("faceIndex",new kn(j,R)),e.push(ie),l>nu&&l--}return{_lodPlanes:e,_sizeLods:t,_sigmas:i}}function N1(e){var t={magFilter:Ui,minFilter:Ui,generateMipmaps:!1,type:e?e.type:Jp,format:e?e.format:iE,encoding:e?e.encoding:py,depthBuffer:!1,stencilBuffer:!1},i=V1(t);return i.depthBuffer=!e,xm=V1(t),i}function U1(e){xm.dispose(),yi.setRenderTarget(F_),e.scissorTest=!1,e.setSize(e.width,e.height)}function OS(e,t,i,l){var c=90,h=1,f=new Xi(c,h,t,i),r=[1,1,1,1,-1,1],v=[1,1,-1,-1,-1,1],x=yi.outputEncoding,w=yi.toneMapping,b=yi.toneMappingExposure,A=yi.getClearColor(),L=yi.getClearAlpha();yi.toneMapping=ry,yi.toneMappingExposure=1,yi.outputEncoding=io,e.scale.z*=-1;var P=e.background;if(P&&P.isColor){P.convertSRGBToLinear();var R=Math.max(P.r,P.g,P.b),F=Math.min(Math.max(Math.ceil(Math.log2(R)),-128),127);P=P.multiplyScalar(Math.pow(2,-F));var V=(F+128)/255;yi.setClearColor(P,V),e.background=null}for(var j=0;j<6;j++){var J=j%3;J==0?(f.up.set(0,r[j],0),f.lookAt(v[j],0,0)):J==1?(f.up.set(0,0,r[j]),f.lookAt(0,v[j],0)):(f.up.set(0,r[j],0),f.lookAt(0,0,v[j])),O_(l,J*ta,j>2?ta:0,ta,ta),yi.setRenderTarget(l),yi.render(e,f)}yi.toneMapping=w,yi.toneMappingExposure=b,yi.outputEncoding=x,yi.setClearColor(A,L),e.scale.z*=-1}function NS(e,t){var i=new Ca;e.isCubeTexture?gs==null&&(gs=$1()):ms==null&&(ms=H1());var l=e.isCubeTexture?gs:ms;i.add(new Ai(pd[0],l));var c=l.uniforms;c.envMap.value=e,e.isCubeTexture||c.texelSize.value.set(1/e.image.width,1/e.image.height),c.inputEncoding.value=na[e.encoding],c.outputEncoding.value=na[e.encoding],O_(t,0,0,3*ta,2*ta),yi.setRenderTarget(t),yi.render(i,z_)}function B_(e){var t=new Ca;t.add(new Ai(pd[0],e)),yi.compile(t,z_)}function V1(e){var t=new Tr(3*ta,3*ta,e);return t.texture.mapping=ph,t.texture.name="PMREM.cubeUv",t.scissorTest=!0,t}function O_(e,t,i,l,c){e.viewport.set(t,i,l,c),e.scissor.set(t,i,l,c)}function G1(e){var t=yi.autoClear;yi.autoClear=!1;for(var i=1;i<z1;i++){var l=Math.sqrt(vm[i]*vm[i]-vm[i-1]*vm[i-1]),c=B1[(i-1)%B1.length];W1(e,i-1,i,l,c)}yi.autoClear=t}function W1(e,t,i,l,c){j1(e,xm,t,i,l,"latitudinal",c),j1(xm,e,i,i,l,"longitudinal",c)}function j1(e,t,i,l,c,h,f){h!=="latitudinal"&&h!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");var r=3,v=new Ca;v.add(new Ai(pd[l],_m));var x=_m.uniforms,w=F1[i]-1,b=isFinite(c)?Math.PI/(2*w):2*Math.PI/(2*iu-1),A=c/b,L=isFinite(c)?1+Math.floor(r*A):iu;L>iu&&console.warn(`sigmaRadians, ${c}, is too large and will clip, as it requested ${L} samples when the maximum is set to ${iu}`);for(var P=[],R=0,F=0;F<iu;++F){var J=F/A,V=Math.exp(-J*J/2);P.push(V),F==0?R+=V:F<L&&(R+=2*V)}for(var F=0;F<P.length;F++)P[F]=P[F]/R;x.envMap.value=e.texture,x.samples.value=L,x.weights.value=P,x.latitudinal.value=h==="latitudinal",f&&(x.poleAxis.value=f),x.dTheta.value=b,x.mipInt.value=fs-i,x.inputEncoding.value=na[e.texture.encoding],x.outputEncoding.value=na[e.texture.encoding];var j=F1[l],J=3*Math.max(0,ta-2*j),ne=(l===0?0:2*ta)+2*j*(l>fs-nu?l-fs+nu:0);O_(t,J,ne,3*j,2*j),yi.setRenderTarget(t),yi.render(v,z_)}function US(e){var t=new Float32Array(e),i=new Pe(0,1,0),l=new us({defines:{n:e},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:t},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i},inputEncoding:{value:na[io]},outputEncoding:{value:na[io]}},vertexShader:N_(),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;
- ${U_()}
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- void main() {
- gl_FragColor = vec4(0.0);
- for (int i = 0; i < n; i++) {
- if (i >= samples)
- break;
- for (int dir = -1; dir < 2; dir += 2) {
- if (i == 0 && dir == 1)
- continue;
- vec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);
- if (all(equal(axis, vec3(0.0))))
- axis = cross(vec3(0.0, 1.0, 0.0), vOutputDirection);
- axis = normalize(axis);
- float theta = dTheta * float(dir * i);
- float cosTheta = cos(theta);
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross(axis, vOutputDirection) * sin(theta)
- + axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);
- gl_FragColor.rgb +=
- weights[i] * bilinearCubeUV(envMap, sampleDirection, mipInt);
- }
- }
- gl_FragColor = linearToOutputTexel(gl_FragColor);
- }
- `,blending:es,depthTest:!1,depthWrite:!1});return l.type="SphericalGaussianBlur",l}function H1(){var e=new Lt(1,1),t=new us({uniforms:{envMap:{value:null},texelSize:{value:e},inputEncoding:{value:na[io]},outputEncoding:{value:na[io]}},vertexShader:N_(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform vec2 texelSize;
- ${U_()}
- #define RECIPROCAL_PI 0.31830988618
- #define RECIPROCAL_PI2 0.15915494
- void main() {
- gl_FragColor = vec4(0.0);
- vec3 outputDirection = normalize(vOutputDirection);
- vec2 uv;
- uv.y = asin(clamp(outputDirection.y, -1.0, 1.0)) * RECIPROCAL_PI + 0.5;
- uv.x = atan(outputDirection.z, outputDirection.x) * RECIPROCAL_PI2 + 0.5;
- vec2 f = fract(uv / texelSize - 0.5);
- uv -= f * texelSize;
- vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
- uv.x += texelSize.x;
- vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
- uv.y += texelSize.y;
- vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
- uv.x -= texelSize.x;
- vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
- vec3 tm = mix(tl, tr, f.x);
- vec3 bm = mix(bl, br, f.x);
- gl_FragColor.rgb = mix(tm, bm, f.y);
- gl_FragColor = linearToOutputTexel(gl_FragColor);
- }
- `,blending:es,depthTest:!1,depthWrite:!1});return t.type="EquirectangularToCubeUV",t}function $1(){var e=new us({uniforms:{envMap:{value:null},inputEncoding:{value:na[io]},outputEncoding:{value:na[io]}},vertexShader:N_(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- ${U_()}
- void main() {
- gl_FragColor = vec4(0.0);
- gl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ))).rgb;
- gl_FragColor = linearToOutputTexel(gl_FragColor);
- }
- `,blending:es,depthTest:!1,depthWrite:!1});return e.type="CubemapToCubeUV",e}function N_(){return`
- precision mediump float;
- precision mediump int;
- attribute vec3 position;
- attribute vec2 uv;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- 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;
- direction.z *= -1.0;
- } else if (face == 1.0) {
- direction = direction.xzy;
- direction.z *= -1.0;
- } else if (face == 3.0) {
- direction = direction.zyx;
- direction.x *= -1.0;
- } else if (face == 4.0) {
- direction = direction.xzy;
- direction.y *= -1.0;
- } else if (face == 5.0) {
- direction.xz *= -1.0;
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection(uv, faceIndex);
- gl_Position = vec4( position, 1.0 );
- }
- `}function U_(){return`
- uniform int inputEncoding;
- uniform int outputEncoding;
- #include <encodings_pars_fragment>
- vec4 inputTexelToLinear(vec4 value){
- if(inputEncoding == 0){
- return value;
- }else if(inputEncoding == 1){
- return sRGBToLinear(value);
- }else if(inputEncoding == 2){
- return RGBEToLinear(value);
- }else if(inputEncoding == 3){
- return RGBMToLinear(value, 7.0);
- }else if(inputEncoding == 4){
- return RGBMToLinear(value, 16.0);
- }else if(inputEncoding == 5){
- return RGBDToLinear(value, 256.0);
- }else{
- return GammaToLinear(value, 2.2);
- }
- }
- vec4 linearToOutputTexel(vec4 value){
- if(outputEncoding == 0){
- return value;
- }else if(outputEncoding == 1){
- return LinearTosRGB(value);
- }else if(outputEncoding == 2){
- return LinearToRGBE(value);
- }else if(outputEncoding == 3){
- return LinearToRGBM(value, 7.0);
- }else if(outputEncoding == 4){
- return LinearToRGBM(value, 16.0);
- }else if(outputEncoding == 5){
- return LinearToRGBD(value, 256.0);
- }else{
- return LinearToGamma(value, 2.2);
- }
- }
- vec4 envMapTexelToLinear(vec4 color) {
- return inputTexelToLinear(color);
- }
- `}Dn.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(Dn.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Object.assign(hs.prototype,{createPointsGeometry:function(e){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var t=this.getPoints(e);return this.createGeometry(t)},createSpacedPointsGeometry:function(e){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var t=this.getSpacedPoints(e);return this.createGeometry(t)},createGeometry:function(e){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var t=new Bn,i=0,l=e.length;i<l;i++){var c=e[i];t.vertices.push(new Pe(c.x,c.y,c.z||0))}return t}}),Object.assign(Qo.prototype,{fromPoints:function(e){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)}}),Object.create(co.prototype),Object.create(co.prototype);function q1(e){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),co.call(this,e),this.type="catmullrom"}q1.prototype=Object.create(co.prototype),Object.assign(q1.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}}),L_.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},cd.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Object.assign(ri.prototype,{extractUrlBase:function(e){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),dl.extractUrlBase(e)}}),ri.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Object.assign(M_.prototype,{setTexturePath:function(e){return console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."),this.setResourcePath(e)}}),Object.assign(T1.prototype,{center:function(e){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(e)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(e){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},size:function(e){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(e)}}),Object.assign(Po.prototype,{center:function(e){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(e)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(e){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},isIntersectionSphere:function(e){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},size:function(e){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(e)}}),Ph.prototype.setFromMatrix=function(e){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(e)},C1.prototype.center=function(e){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(e)},Object.assign(jn,{random16:function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},nearestPowerOfTwo:function(e){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),jn.floorPowerOfTwo(e)},nextPowerOfTwo:function(e){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),jn.ceilPowerOfTwo(e)}}),Object.assign(pr.prototype,{flattenToArrayOffset:function(e,t){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},multiplyVector3:function(e){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBufferAttribute:function(e){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}}),Object.assign(Hn.prototype,{extractPosition:function(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)},flattenToArrayOffset:function(e,t){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},getPosition:function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),new Pe().setFromMatrixColumn(this,3)},setRotationFromQuaternion:function(e){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(e){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},multiplyVector4:function(e){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(e){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),e.transformDirection(this)},crossVector:function(e){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBufferAttribute:function(e){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(e,t,i,l,c,h){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(e,t,l,i,c,h)}}),$o.prototype.isIntersectionLine=function(e){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)},Nr.prototype.multiplyVector3=function(e){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},Object.assign(yc.prototype,{isIntersectionBox:function(e){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},isIntersectionPlane:function(e){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)},isIntersectionSphere:function(e){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)}}),Object.assign(lr.prototype,{area:function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},barycoordFromPoint:function(e,t){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(e,t)},midpoint:function(e){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(e)},normal:function(e){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(e)},plane:function(e){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(e)}}),Object.assign(lr,{barycoordFromPoint:function(e,t,i,l,c){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),lr.getBarycoord(e,t,i,l,c)},normal:function(e,t,i,l){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),lr.getNormal(e,t,i,l)}}),Object.assign(hl.prototype,{extractAllPoints:function(e){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(e)},extrude:function(e){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new Uc(this,e)},makeGeometry:function(e){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new Gc(this,e)}}),Object.assign(Lt.prototype,{fromAttribute:function(e,t,i){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},distanceToManhattan:function(e){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},lengthManhattan:function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(Pe.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(e){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},getScaleFromMatrix:function(e){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},getColumnFromMatrix:function(e,t){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(t,e)},applyProjection:function(e){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(e)},fromAttribute:function(e,t,i){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},distanceToManhattan:function(e){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},lengthManhattan:function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(gi.prototype,{fromAttribute:function(e,t,i){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},lengthManhattan:function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(Bn.prototype,{computeTangents:function(){console.error("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")},applyMatrix:function(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}}),Object.assign(on.prototype,{getChildByName:function(e){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(e,t){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(t,e)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},applyMatrix:function(e){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}}),Object.defineProperties(on.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.assign(Ai.prototype,{setDrawMode:function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}),Object.defineProperties(Ai.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),DE},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),Object.defineProperties(Cf.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}}),Object.defineProperty(Af.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}}),Oh.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},Object.defineProperty(Dn.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(e){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=e}}),Xi.prototype.setLens=function(e,t){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),t!==void 0&&(this.filmGauge=t),this.setFocalLength(e)},Object.defineProperties(Mi.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(e){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(kn.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===vh},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(vh)}}}),Object.assign(kn.prototype,{setDynamic:function(e){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(e===!0?vh:nf),this},copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},setArray:function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(vn.prototype,{addIndex:function(e){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)},addAttribute:function(e,t){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),!(t&&t.isBufferAttribute)&&!(t&&t.isInterleavedBufferAttribute)?(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(e,new kn(arguments[1],arguments[2]))):e==="index"?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):this.setAttribute(e,t)},addDrawCall:function(e,t,i){i!==void 0&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,t)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},removeAttribute:function(e){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(e)},applyMatrix:function(e){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}}),Object.defineProperties(vn.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(ka.prototype,{dynamic:{get:function(){return console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.usage===vh},set:function(e){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.setUsage(e)}}}),Object.assign(ka.prototype,{setDynamic:function(e){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(e===!0?vh:nf),this},setArray:function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(za.prototype,{getArrays:function(){console.error("THREE.ExtrudeBufferGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("THREE.ExtrudeBufferGeometry: .addShape() has been removed.")}}),Object.defineProperties(D_.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}}),Object.defineProperties(Rn.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new tn}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=e===_x}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(e){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=e}}}),Object.defineProperties(ul.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}),Object.defineProperties(Ur.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),Object.assign(D0.prototype,{clearTarget:function(e,t,i,l){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(e),this.clear(t,i,l)},animate:function(e){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(e)},getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},getMaxAnisotropy:function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},getPrecision:function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},resetGLState:function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(e){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},allocTextureUnit:function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},setTexture:function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},setTexture2D:function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},setTextureCube:function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},getActiveMipMapLevel:function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()}}),Object.defineProperties(D0.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(e){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=e===!0?_h:io}}}),Object.defineProperties(C0.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(Tr.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),Object.defineProperties(sd.prototype,{load:{value:function(e){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");var t=this,i=new T_;return i.load(e,function(l){t.setBuffer(l)}),this}},startTime:{set:function(){console.warn("THREE.Audio: .startTime is now .play( delay ).")}}}),g1.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},Dh.prototype.updateCubeMap=function(e,t){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(e,t)},Ks.crossOrigin=void 0,Ks.loadTexture=function(e,t,i,l){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var c=new id;c.setCrossOrigin(this.crossOrigin);var h=c.load(e,i,void 0,l);return t&&(h.mapping=t),h},Ks.loadTextureCube=function(e,t,i,l){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");var c=new a_;c.setCrossOrigin(this.crossOrigin);var h=c.load(e,i,void 0,l);return t&&(h.mapping=t),h},Ks.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},Ks.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:_T}}));class bm extends X.MxDbAlignedDimension{constructor(){super()}getDimText(){var t=new Pe(this.point1.x-this.point2.x,this.point1.y-this.point2.y,0),i=t.length();return i.toFixed(2)}create(){return new bm}getTypeName(){return this.constructor.name}}function VS(){return Qe(this,null,function*(){const e=new X.MrxDbgUiPrPoint;e.setMessage(`
- 指定第一点:`),e.go(t=>{if(t!=0)return;const i=e.value();let l=new bm;l.setPoint1(i),l.setColor(65314);const c=new X.McEdGetPointWorldDrawObject;c.setDraw(h=>{l.setPoint2(h),c.drawCustomEntity(l)}),e.setBasePt(i),e.setUseBasePt(!0),e.setUserDraw(c),e.setMessage(`
- 指定第二点:`),e.setInputToucheType(X.MxType.InputToucheType.kGetEnd),e.go(h=>{if(h!=0){console.log(h);return}const f=e.value();l.setPoint2(f),X.MxFun.getCurrentDraw().addMxEntity(l),alert("测试长度是:"+l.getDimText())})})})}function GS(){const e=new X.MrxDbgUiPrPoint,t=X.MxFun.getCurrentDraw(),i=new X.MxDb2LineAngularDimension;i.color=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();const l=new X.McEdGetPointWorldDrawObject;l.setColor(M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor()),e.setMessage(`
- 指定第一点:`),e.go(c=>{c===0&&(e.setMessage(`
- 指定第二个角度点:`),i.point1=e.value(),l.setDraw((h,f)=>{i.point2=h,f.drawLine(i.point1,h)}),e.setUserDraw(l),e.go(h=>{e.setMessage(`
- 指定最后一个点:`),h===0&&(i.point2=e.value(),l.setDraw((f,r)=>{i.point3=f,l.drawCustomEntity(i)}),e.go(f=>{f===0&&t.addMxEntity(i)}))}))})}function WS(){const e=new X.MrxDbgUiPrPoint;e.setMessage(`
- 指定坐标点:`),e.go(t=>{if(t!=0)return;const i=e.value();let l=new X.MxDbCoord;l.point1=i,l.point2=i.clone(),l.color=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor(),e.setBasePt(i),e.setUseBasePt(!0),e.setUserDraw((c,h)=>{l.point2=c,h.drawCustomEntity(l)}),e.setMessage(`
- 指定标注点:`),e.go(c=>{if(c!=0){console.log(c);return}l.point2=e.value(),X.MxFun.addToCurrentSpace(l)})})}function jS(){new bm().rxInit(),X.MxFun.addCommand("Mx_Linear",VS),X.MxFun.addCommand("BR_AngleMeasure",GS),X.MxFun.addCommand("BR_CoordMeasure",WS)}function HS(){return Qe(this,null,function*(){let e=new M.MxCADUiPrEntity;e.setMessage("select entity:");let i=(yield e.go()).getMcDbEntity();if(i!==null){if(console.log("ent.objectName",i.objectName),i instanceof M.McDbBlockReference){let c=i.explode();if(c.GetCount()==0)return;let h=c.GetCount();for(let f=0;f<h;f++){let r=c.AtObject(f).val;if(r instanceof M.McDbPolyline){let v=r,x=v.numVerts();for(let w=0;w<x;w++){let b=v.getPointAt(w),A=v.getBulgeAt(w);console.log("polyline.pt"+w+":"+Cr(b.val)),console.log("polyline.bulge"+w+":"+A)}}}}else if(i instanceof M.McDbPolyline){let l=i,c=l.numVerts();for(let h=0;h<c;h++){let f=l.getPointAt(h),r=l.getBulgeAt(h);console.log("polyline.pt"+h+":"+Cr(f.val)),console.log("polyline.bulge"+h+":"+r)}}}})}function $S(){X.MxFun.addCommand("MxTest_SelectEntity",HS)}class qS{constructor(){this.m_aryColumn=[],this.m_allData=[],this.m_dColumnHeight=14,this.m_dRowHeight=10,this.m_dRowLineWdith=0,this.m_dColumnLineWidth=.5,this.m_dRowTextHeight=6,this.m_dColumnTextHeight=10}addColumn(t,i){this.m_aryColumn.push({name:t,w:i})}addRow(t){this.m_allData.push(t)}}class X1{constructor(){this.data=new qS,this.pt=new M.McGePoint3d,this.dScale=1,this.mxcad=M.MxCpp.getCurrentMxCAD()}draw(t,i){return this.pt=t,this.dScale=i,this.data.m_aryColumn.length==0||this.data.m_allData.length==0?!1:(this.DrawTableHead(),this.DrawContent(),!0)}DrawTableHead(){let t=this.data,i=this.pt.clone(),l=this.pt.clone(),c=new M.McGeVector3d(0,1,0).mult(this.Scale(this.data.m_dColumnHeight));console.log(c);let h=this.Scale(this.data.m_dColumnLineWidth),f=0,r=new M.McGeVector3d(1,0,0);for(let v=0;v<t.m_aryColumn.length;v++){let x=t.m_aryColumn[v];this.DrawLine(l,l.clone().subvec(c),h),this.DrawMCText(l.clone().addvec(r.clone().mult(this.Scale(x.w)*.5)).subvec(c.clone().mult(.5)),x.name,this.Scale(t.m_dColumnTextHeight)),l.addvec(r.clone().mult(this.Scale(x.w))),f+=this.Scale(x.w)}return this.DrawLine(l,l.clone().subvec(c),h),this.DrawLine(i,i.clone().addvec(r.clone().mult(f)),h),this.DrawLine(i.clone().subvec(c),i.addvec(r.clone().mult(f)).subvec(c),h),!0}DrawContent(){let t=this.data,i=this.pt,l=0;for(let x=0;x<t.m_aryColumn.length;x++)l+=this.Scale(t.m_aryColumn[x].w);let c=this.Scale(this.data.m_dRowLineWdith),h=new M.McGeVector3d(1,0,0),f=new M.McGeVector3d(0,1,0),r=i.clone().subvec(f.clone().mult(this.Scale(t.m_dColumnHeight))),v=f.clone().mult(this.Scale(t.m_dRowHeight));for(let x=0;x<t.m_allData.length;x++){let w=r.clone();for(let b=0;b<t.m_aryColumn.length;b++){let A=t.m_aryColumn[b];this.DrawLine(w,w.clone().subvec(v),c),this.DrawMCText(w.clone().addvec(h.clone().mult(this.Scale(A.w*.5))).subvec(v.clone().mult(.5)),t.m_allData[x][b],this.Scale(t.m_dRowTextHeight)),w.addvec(h.clone().mult(this.Scale(A.w)))}this.DrawLine(w,w.clone().subvec(v),c),this.DrawLine(r,r.clone().addvec(h.clone().mult(l)),c),this.DrawLine(r.clone().subvec(v),r.clone().addvec(h.clone().mult(l)).subvec(v),c),r.subvec(v)}return!0}DrawLine(t,i,l){this.mxcad.drawLineWidth=l,this.mxcad.drawColorIndex=M.ColorIndexType.kMagenta,this.mxcad.drawLine(t.x,t.y,i.x,i.y)}DrawMCText(t,i,l){this.mxcad.drawColorIndex=0,this.mxcad.drawColor=new M.McCmColor(0,255,0),this.mxcad.drawText(t.x,t.y,i,l,0,M.McDb.TextHorzMode.kTextMid,M.McDb.TextVertMode.kTextVertMid)}Scale(t){return t*this.dScale}}var XS=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Z1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Y1={exports:{}};(function(e,t){var i=function(){var l=function(H,Q){var ae=236,ie=17,le=H,fe=h[Q],me=null,he=0,Oe=null,Ve=[],He={},at=function(ge,Ce){he=le*4+17,me=function(Ae){for(var _e=new Array(Ae),Ne=0;Ne<Ae;Ne+=1){_e[Ne]=new Array(Ae);for(var Je=0;Je<Ae;Je+=1)_e[Ne][Je]=null}return _e}(he),At(0,0),At(he-7,0),At(0,he-7),It(),Dt(),Ie(ge,Ce),le>=7&&Nt(ge),Oe==null&&(Oe=Ge(le,fe,Ve)),be(Oe,Ce)},At=function(ge,Ce){for(var Ae=-1;Ae<=7;Ae+=1)if(!(ge+Ae<=-1||he<=ge+Ae))for(var _e=-1;_e<=7;_e+=1)Ce+_e<=-1||he<=Ce+_e||(0<=Ae&&Ae<=6&&(_e==0||_e==6)||0<=_e&&_e<=6&&(Ae==0||Ae==6)||2<=Ae&&Ae<=4&&2<=_e&&_e<=4?me[ge+Ae][Ce+_e]=!0:me[ge+Ae][Ce+_e]=!1)},yt=function(){for(var ge=0,Ce=0,Ae=0;Ae<8;Ae+=1){at(!0,Ae);var _e=r.getLostPoint(He);(Ae==0||ge>_e)&&(ge=_e,Ce=Ae)}return Ce},Dt=function(){for(var ge=8;ge<he-8;ge+=1)me[ge][6]==null&&(me[ge][6]=ge%2==0);for(var Ce=8;Ce<he-8;Ce+=1)me[6][Ce]==null&&(me[6][Ce]=Ce%2==0)},It=function(){for(var ge=r.getPatternPosition(le),Ce=0;Ce<ge.length;Ce+=1)for(var Ae=0;Ae<ge.length;Ae+=1){var _e=ge[Ce],Ne=ge[Ae];if(me[_e][Ne]==null)for(var Je=-2;Je<=2;Je+=1)for(var ct=-2;ct<=2;ct+=1)Je==-2||Je==2||ct==-2||ct==2||Je==0&&ct==0?me[_e+Je][Ne+ct]=!0:me[_e+Je][Ne+ct]=!1}},Nt=function(ge){for(var Ce=r.getBCHTypeNumber(le),Ae=0;Ae<18;Ae+=1){var _e=!ge&&(Ce>>Ae&1)==1;me[Math.floor(Ae/3)][Ae%3+he-8-3]=_e}for(var Ae=0;Ae<18;Ae+=1){var _e=!ge&&(Ce>>Ae&1)==1;me[Ae%3+he-8-3][Math.floor(Ae/3)]=_e}},Ie=function(ge,Ce){for(var Ae=fe<<3|Ce,_e=r.getBCHTypeInfo(Ae),Ne=0;Ne<15;Ne+=1){var Je=!ge&&(_e>>Ne&1)==1;Ne<6?me[Ne][8]=Je:Ne<8?me[Ne+1][8]=Je:me[he-15+Ne][8]=Je}for(var Ne=0;Ne<15;Ne+=1){var Je=!ge&&(_e>>Ne&1)==1;Ne<8?me[8][he-Ne-1]=Je:Ne<9?me[8][15-Ne-1+1]=Je:me[8][15-Ne-1]=Je}me[he-8][8]=!ge},be=function(ge,Ce){for(var Ae=-1,_e=he-1,Ne=7,Je=0,ct=r.getMaskFunction(Ce),wt=he-1;wt>0;wt-=2)for(wt==6&&(wt-=1);;){for(var Gt=0;Gt<2;Gt+=1)if(me[_e][wt-Gt]==null){var pe=!1;Je<ge.length&&(pe=(ge[Je]>>>Ne&1)==1);var Me=ct(_e,wt-Gt);Me&&(pe=!pe),me[_e][wt-Gt]=pe,Ne-=1,Ne==-1&&(Je+=1,Ne=7)}if(_e+=Ae,_e<0||he<=_e){_e-=Ae,Ae=-Ae;break}}},We=function(ge,Ce){for(var Ae=0,_e=0,Ne=0,Je=new Array(Ce.length),ct=new Array(Ce.length),wt=0;wt<Ce.length;wt+=1){var Gt=Ce[wt].dataCount,pe=Ce[wt].totalCount-Gt;_e=Math.max(_e,Gt),Ne=Math.max(Ne,pe),Je[wt]=new Array(Gt);for(var Me=0;Me<Je[wt].length;Me+=1)Je[wt][Me]=255&ge.getBuffer()[Me+Ae];Ae+=Gt;var bt=r.getErrorCorrectPolynomial(pe),gt=x(Je[wt],bt.getLength()-1),bn=gt.mod(bt);ct[wt]=new Array(bt.getLength()-1);for(var Me=0;Me<ct[wt].length;Me+=1){var hn=Me+bn.getLength()-ct[wt].length;ct[wt][Me]=hn>=0?bn.getAt(hn):0}}for(var nn=0,Me=0;Me<Ce.length;Me+=1)nn+=Ce[Me].totalCount;for(var pn=new Array(nn),wn=0,Me=0;Me<_e;Me+=1)for(var wt=0;wt<Ce.length;wt+=1)Me<Je[wt].length&&(pn[wn]=Je[wt][Me],wn+=1);for(var Me=0;Me<Ne;Me+=1)for(var wt=0;wt<Ce.length;wt+=1)Me<ct[wt].length&&(pn[wn]=ct[wt][Me],wn+=1);return pn},Ge=function(ge,Ce,Ae){for(var _e=w.getRSBlocks(ge,Ce),Ne=b(),Je=0;Je<Ae.length;Je+=1){var ct=Ae[Je];Ne.put(ct.getMode(),4),Ne.put(ct.getLength(),r.getLengthInBits(ct.getMode(),ge)),ct.write(Ne)}for(var wt=0,Je=0;Je<_e.length;Je+=1)wt+=_e[Je].dataCount;if(Ne.getLengthInBits()>wt*8)throw"code length overflow. ("+Ne.getLengthInBits()+">"+wt*8+")";for(Ne.getLengthInBits()+4<=wt*8&&Ne.put(0,4);Ne.getLengthInBits()%8!=0;)Ne.putBit(!1);for(;!(Ne.getLengthInBits()>=wt*8||(Ne.put(ae,8),Ne.getLengthInBits()>=wt*8));)Ne.put(ie,8);return We(Ne,_e)};He.addData=function(ge,Ce){Ce=Ce||"Byte";var Ae=null;switch(Ce){case"Numeric":Ae=A(ge);break;case"Alphanumeric":Ae=L(ge);break;case"Byte":Ae=P(ge);break;case"Kanji":Ae=R(ge);break;default:throw"mode:"+Ce}Ve.push(Ae),Oe=null},He.isDark=function(ge,Ce){if(ge<0||he<=ge||Ce<0||he<=Ce)throw ge+","+Ce;return me[ge][Ce]},He.getModuleCount=function(){return he},He.make=function(){if(le<1){for(var ge=1;ge<40;ge++){for(var Ce=w.getRSBlocks(ge,fe),Ae=b(),_e=0;_e<Ve.length;_e++){var Ne=Ve[_e];Ae.put(Ne.getMode(),4),Ae.put(Ne.getLength(),r.getLengthInBits(Ne.getMode(),ge)),Ne.write(Ae)}for(var Je=0,_e=0;_e<Ce.length;_e++)Je+=Ce[_e].dataCount;if(Ae.getLengthInBits()<=Je*8)break}le=ge}at(!1,yt())},He.createTableTag=function(ge,Ce){ge=ge||2,Ce=typeof Ce=="undefined"?ge*4:Ce;var Ae="";Ae+='<table style="',Ae+=" border-width: 0px; border-style: none;",Ae+=" border-collapse: collapse;",Ae+=" padding: 0px; margin: "+Ce+"px;",Ae+='">',Ae+="<tbody>";for(var _e=0;_e<He.getModuleCount();_e+=1){Ae+="<tr>";for(var Ne=0;Ne<He.getModuleCount();Ne+=1)Ae+='<td style="',Ae+=" border-width: 0px; border-style: none;",Ae+=" border-collapse: collapse;",Ae+=" padding: 0px; margin: 0px;",Ae+=" width: "+ge+"px;",Ae+=" height: "+ge+"px;",Ae+=" background-color: ",Ae+=He.isDark(_e,Ne)?"#000000":"#ffffff",Ae+=";",Ae+='"/>';Ae+="</tr>"}return Ae+="</tbody>",Ae+="</table>",Ae},He.createSvgTag=function(ge,Ce,Ae,_e){var Ne={};typeof arguments[0]=="object"&&(Ne=arguments[0],ge=Ne.cellSize,Ce=Ne.margin,Ae=Ne.alt,_e=Ne.title),ge=ge||2,Ce=typeof Ce=="undefined"?ge*4:Ce,Ae=typeof Ae=="string"?{text:Ae}:Ae||{},Ae.text=Ae.text||null,Ae.id=Ae.text?Ae.id||"qrcode-description":null,_e=typeof _e=="string"?{text:_e}:_e||{},_e.text=_e.text||null,_e.id=_e.text?_e.id||"qrcode-title":null;var Je=He.getModuleCount()*ge+Ce*2,ct,wt,Gt,pe,Me="",bt;for(bt="l"+ge+",0 0,"+ge+" -"+ge+",0 0,-"+ge+"z ",Me+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',Me+=Ne.scalable?"":' width="'+Je+'px" height="'+Je+'px"',Me+=' viewBox="0 0 '+Je+" "+Je+'" ',Me+=' preserveAspectRatio="xMinYMin meet"',Me+=_e.text||Ae.text?' role="img" aria-labelledby="'+ke([_e.id,Ae.id].join(" ").trim())+'"':"",Me+=">",Me+=_e.text?'<title id="'+ke(_e.id)+'">'+ke(_e.text)+"</title>":"",Me+=Ae.text?'<description id="'+ke(Ae.id)+'">'+ke(Ae.text)+"</description>":"",Me+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',Me+='<path d="',Gt=0;Gt<He.getModuleCount();Gt+=1)for(pe=Gt*ge+Ce,ct=0;ct<He.getModuleCount();ct+=1)He.isDark(Gt,ct)&&(wt=ct*ge+Ce,Me+="M"+wt+","+pe+bt);return Me+='" stroke="transparent" fill="black"/>',Me+="</svg>",Me},He.createDataURL=function(ge,Ce){ge=ge||2,Ce=typeof Ce=="undefined"?ge*4:Ce;var Ae=He.getModuleCount()*ge+Ce*2,_e=Ce,Ne=Ae-Ce;return ne(Ae,Ae,function(Je,ct){if(_e<=Je&&Je<Ne&&_e<=ct&&ct<Ne){var wt=Math.floor((Je-_e)/ge),Gt=Math.floor((ct-_e)/ge);return He.isDark(Gt,wt)?0:1}else return 1})},He.createImgTag=function(ge,Ce,Ae){ge=ge||2,Ce=typeof Ce=="undefined"?ge*4:Ce;var _e=He.getModuleCount()*ge+Ce*2,Ne="";return Ne+="<img",Ne+=' src="',Ne+=He.createDataURL(ge,Ce),Ne+='"',Ne+=' width="',Ne+=_e,Ne+='"',Ne+=' height="',Ne+=_e,Ne+='"',Ae&&(Ne+=' alt="',Ne+=ke(Ae),Ne+='"'),Ne+="/>",Ne};var ke=function(ge){for(var Ce="",Ae=0;Ae<ge.length;Ae+=1){var _e=ge.charAt(Ae);switch(_e){case"<":Ce+="<";break;case">":Ce+=">";break;case"&":Ce+="&";break;case'"':Ce+=""";break;default:Ce+=_e;break}}return Ce},ot=function(ge){var Ce=1;ge=typeof ge=="undefined"?Ce*2:ge;var Ae=He.getModuleCount()*Ce+ge*2,_e=ge,Ne=Ae-ge,Je,ct,wt,Gt,pe,Me={"██":"█","█ ":"▀"," █":"▄"," ":" "},bt={"██":"▀","█ ":"▀"," █":" "," ":" "},gt="";for(Je=0;Je<Ae;Je+=2){for(wt=Math.floor((Je-_e)/Ce),Gt=Math.floor((Je+1-_e)/Ce),ct=0;ct<Ae;ct+=1)pe="█",_e<=ct&&ct<Ne&&_e<=Je&&Je<Ne&&He.isDark(wt,Math.floor((ct-_e)/Ce))&&(pe=" "),_e<=ct&&ct<Ne&&_e<=Je+1&&Je+1<Ne&&He.isDark(Gt,Math.floor((ct-_e)/Ce))?pe+=" ":pe+="█",gt+=ge<1&&Je+1>=Ne?bt[pe]:Me[pe];gt+=`
- `}return Ae%2&&ge>0?gt.substring(0,gt.length-Ae-1)+Array(Ae+1).join("▀"):gt.substring(0,gt.length-1)};return He.createASCII=function(ge,Ce){if(ge=ge||1,ge<2)return ot(Ce);ge-=1,Ce=typeof Ce=="undefined"?ge*2:Ce;var Ae=He.getModuleCount()*ge+Ce*2,_e=Ce,Ne=Ae-Ce,Je,ct,wt,Gt,pe=Array(ge+1).join("██"),Me=Array(ge+1).join(" "),bt="",gt="";for(Je=0;Je<Ae;Je+=1){for(wt=Math.floor((Je-_e)/ge),gt="",ct=0;ct<Ae;ct+=1)Gt=1,_e<=ct&&ct<Ne&&_e<=Je&&Je<Ne&&He.isDark(wt,Math.floor((ct-_e)/ge))&&(Gt=0),gt+=Gt?pe:Me;for(wt=0;wt<ge;wt+=1)bt+=gt+`
- `}return bt.substring(0,bt.length-1)},He.renderTo2dContext=function(ge,Ce){Ce=Ce||2;for(var Ae=He.getModuleCount(),_e=0;_e<Ae;_e++)for(var Ne=0;Ne<Ae;Ne++)ge.fillStyle=He.isDark(_e,Ne)?"black":"white",ge.fillRect(_e*Ce,Ne*Ce,Ce,Ce)},He};l.stringToBytesFuncs={default:function(H){for(var Q=[],ae=0;ae<H.length;ae+=1){var ie=H.charCodeAt(ae);Q.push(ie&255)}return Q}},l.stringToBytes=l.stringToBytesFuncs.default,l.createStringToBytes=function(H,Q){var ae=function(){for(var le=j(H),fe=function(){var Dt=le.read();if(Dt==-1)throw"eof";return Dt},me=0,he={};;){var Oe=le.read();if(Oe==-1)break;var Ve=fe(),He=fe(),at=fe(),At=String.fromCharCode(Oe<<8|Ve),yt=He<<8|at;he[At]=yt,me+=1}if(me!=Q)throw me+" != "+Q;return he}(),ie="?".charCodeAt(0);return function(le){for(var fe=[],me=0;me<le.length;me+=1){var he=le.charCodeAt(me);if(he<128)fe.push(he);else{var Oe=ae[le.charAt(me)];typeof Oe=="number"?(Oe&255)==Oe?fe.push(Oe):(fe.push(Oe>>>8),fe.push(Oe&255)):fe.push(ie)}}return fe}};var c={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},h={L:1,M:0,Q:3,H:2},f={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},r=function(){var H=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],Q=1335,ae=7973,ie=21522,le={},fe=function(me){for(var he=0;me!=0;)he+=1,me>>>=1;return he};return le.getBCHTypeInfo=function(me){for(var he=me<<10;fe(he)-fe(Q)>=0;)he^=Q<<fe(he)-fe(Q);return(me<<10|he)^ie},le.getBCHTypeNumber=function(me){for(var he=me<<12;fe(he)-fe(ae)>=0;)he^=ae<<fe(he)-fe(ae);return me<<12|he},le.getPatternPosition=function(me){return H[me-1]},le.getMaskFunction=function(me){switch(me){case f.PATTERN000:return function(he,Oe){return(he+Oe)%2==0};case f.PATTERN001:return function(he,Oe){return he%2==0};case f.PATTERN010:return function(he,Oe){return Oe%3==0};case f.PATTERN011:return function(he,Oe){return(he+Oe)%3==0};case f.PATTERN100:return function(he,Oe){return(Math.floor(he/2)+Math.floor(Oe/3))%2==0};case f.PATTERN101:return function(he,Oe){return he*Oe%2+he*Oe%3==0};case f.PATTERN110:return function(he,Oe){return(he*Oe%2+he*Oe%3)%2==0};case f.PATTERN111:return function(he,Oe){return(he*Oe%3+(he+Oe)%2)%2==0};default:throw"bad maskPattern:"+me}},le.getErrorCorrectPolynomial=function(me){for(var he=x([1],0),Oe=0;Oe<me;Oe+=1)he=he.multiply(x([1,v.gexp(Oe)],0));return he},le.getLengthInBits=function(me,he){if(1<=he&&he<10)switch(me){case c.MODE_NUMBER:return 10;case c.MODE_ALPHA_NUM:return 9;case c.MODE_8BIT_BYTE:return 8;case c.MODE_KANJI:return 8;default:throw"mode:"+me}else if(he<27)switch(me){case c.MODE_NUMBER:return 12;case c.MODE_ALPHA_NUM:return 11;case c.MODE_8BIT_BYTE:return 16;case c.MODE_KANJI:return 10;default:throw"mode:"+me}else if(he<41)switch(me){case c.MODE_NUMBER:return 14;case c.MODE_ALPHA_NUM:return 13;case c.MODE_8BIT_BYTE:return 16;case c.MODE_KANJI:return 12;default:throw"mode:"+me}else throw"type:"+he},le.getLostPoint=function(me){for(var he=me.getModuleCount(),Oe=0,Ve=0;Ve<he;Ve+=1)for(var He=0;He<he;He+=1){for(var at=0,At=me.isDark(Ve,He),yt=-1;yt<=1;yt+=1)if(!(Ve+yt<0||he<=Ve+yt))for(var Dt=-1;Dt<=1;Dt+=1)He+Dt<0||he<=He+Dt||yt==0&&Dt==0||At==me.isDark(Ve+yt,He+Dt)&&(at+=1);at>5&&(Oe+=3+at-5)}for(var Ve=0;Ve<he-1;Ve+=1)for(var He=0;He<he-1;He+=1){var It=0;me.isDark(Ve,He)&&(It+=1),me.isDark(Ve+1,He)&&(It+=1),me.isDark(Ve,He+1)&&(It+=1),me.isDark(Ve+1,He+1)&&(It+=1),(It==0||It==4)&&(Oe+=3)}for(var Ve=0;Ve<he;Ve+=1)for(var He=0;He<he-6;He+=1)me.isDark(Ve,He)&&!me.isDark(Ve,He+1)&&me.isDark(Ve,He+2)&&me.isDark(Ve,He+3)&&me.isDark(Ve,He+4)&&!me.isDark(Ve,He+5)&&me.isDark(Ve,He+6)&&(Oe+=40);for(var He=0;He<he;He+=1)for(var Ve=0;Ve<he-6;Ve+=1)me.isDark(Ve,He)&&!me.isDark(Ve+1,He)&&me.isDark(Ve+2,He)&&me.isDark(Ve+3,He)&&me.isDark(Ve+4,He)&&!me.isDark(Ve+5,He)&&me.isDark(Ve+6,He)&&(Oe+=40);for(var Nt=0,He=0;He<he;He+=1)for(var Ve=0;Ve<he;Ve+=1)me.isDark(Ve,He)&&(Nt+=1);var Ie=Math.abs(100*Nt/he/he-50)/5;return Oe+=Ie*10,Oe},le}(),v=function(){for(var H=new Array(256),Q=new Array(256),ae=0;ae<8;ae+=1)H[ae]=1<<ae;for(var ae=8;ae<256;ae+=1)H[ae]=H[ae-4]^H[ae-5]^H[ae-6]^H[ae-8];for(var ae=0;ae<255;ae+=1)Q[H[ae]]=ae;var ie={};return ie.glog=function(le){if(le<1)throw"glog("+le+")";return Q[le]},ie.gexp=function(le){for(;le<0;)le+=255;for(;le>=256;)le-=255;return H[le]},ie}();function x(H,Q){if(typeof H.length=="undefined")throw H.length+"/"+Q;var ae=function(){for(var le=0;le<H.length&&H[le]==0;)le+=1;for(var fe=new Array(H.length-le+Q),me=0;me<H.length-le;me+=1)fe[me]=H[me+le];return fe}(),ie={};return ie.getAt=function(le){return ae[le]},ie.getLength=function(){return ae.length},ie.multiply=function(le){for(var fe=new Array(ie.getLength()+le.getLength()-1),me=0;me<ie.getLength();me+=1)for(var he=0;he<le.getLength();he+=1)fe[me+he]^=v.gexp(v.glog(ie.getAt(me))+v.glog(le.getAt(he)));return x(fe,0)},ie.mod=function(le){if(ie.getLength()-le.getLength()<0)return ie;for(var fe=v.glog(ie.getAt(0))-v.glog(le.getAt(0)),me=new Array(ie.getLength()),he=0;he<ie.getLength();he+=1)me[he]=ie.getAt(he);for(var he=0;he<le.getLength();he+=1)me[he]^=v.gexp(v.glog(le.getAt(he))+fe);return x(me,0).mod(le)},ie}var w=function(){var H=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],Q=function(le,fe){var me={};return me.totalCount=le,me.dataCount=fe,me},ae={},ie=function(le,fe){switch(fe){case h.L:return H[(le-1)*4+0];case h.M:return H[(le-1)*4+1];case h.Q:return H[(le-1)*4+2];case h.H:return H[(le-1)*4+3];default:return}};return ae.getRSBlocks=function(le,fe){var me=ie(le,fe);if(typeof me=="undefined")throw"bad rs block @ typeNumber:"+le+"/errorCorrectionLevel:"+fe;for(var he=me.length/3,Oe=[],Ve=0;Ve<he;Ve+=1)for(var He=me[Ve*3+0],at=me[Ve*3+1],At=me[Ve*3+2],yt=0;yt<He;yt+=1)Oe.push(Q(at,At));return Oe},ae}(),b=function(){var H=[],Q=0,ae={};return ae.getBuffer=function(){return H},ae.getAt=function(ie){var le=Math.floor(ie/8);return(H[le]>>>7-ie%8&1)==1},ae.put=function(ie,le){for(var fe=0;fe<le;fe+=1)ae.putBit((ie>>>le-fe-1&1)==1)},ae.getLengthInBits=function(){return Q},ae.putBit=function(ie){var le=Math.floor(Q/8);H.length<=le&&H.push(0),ie&&(H[le]|=128>>>Q%8),Q+=1},ae},A=function(H){var Q=c.MODE_NUMBER,ae=H,ie={};ie.getMode=function(){return Q},ie.getLength=function(me){return ae.length},ie.write=function(me){for(var he=ae,Oe=0;Oe+2<he.length;)me.put(le(he.substring(Oe,Oe+3)),10),Oe+=3;Oe<he.length&&(he.length-Oe==1?me.put(le(he.substring(Oe,Oe+1)),4):he.length-Oe==2&&me.put(le(he.substring(Oe,Oe+2)),7))};var le=function(me){for(var he=0,Oe=0;Oe<me.length;Oe+=1)he=he*10+fe(me.charAt(Oe));return he},fe=function(me){if("0"<=me&&me<="9")return me.charCodeAt(0)-"0".charCodeAt(0);throw"illegal char :"+me};return ie},L=function(H){var Q=c.MODE_ALPHA_NUM,ae=H,ie={};ie.getMode=function(){return Q},ie.getLength=function(fe){return ae.length},ie.write=function(fe){for(var me=ae,he=0;he+1<me.length;)fe.put(le(me.charAt(he))*45+le(me.charAt(he+1)),11),he+=2;he<me.length&&fe.put(le(me.charAt(he)),6)};var le=function(fe){if("0"<=fe&&fe<="9")return fe.charCodeAt(0)-"0".charCodeAt(0);if("A"<=fe&&fe<="Z")return fe.charCodeAt(0)-"A".charCodeAt(0)+10;switch(fe){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+fe}};return ie},P=function(H){var Q=c.MODE_8BIT_BYTE,ae=l.stringToBytes(H),ie={};return ie.getMode=function(){return Q},ie.getLength=function(le){return ae.length},ie.write=function(le){for(var fe=0;fe<ae.length;fe+=1)le.put(ae[fe],8)},ie},R=function(H){var Q=c.MODE_KANJI,ae=l.stringToBytesFuncs.SJIS;if(!ae)throw"sjis not supported.";(function(fe,me){var he=ae(fe);if(he.length!=2||(he[0]<<8|he[1])!=me)throw"sjis not supported."})("友",38726);var ie=ae(H),le={};return le.getMode=function(){return Q},le.getLength=function(fe){return~~(ie.length/2)},le.write=function(fe){for(var me=ie,he=0;he+1<me.length;){var Oe=(255&me[he])<<8|255&me[he+1];if(33088<=Oe&&Oe<=40956)Oe-=33088;else if(57408<=Oe&&Oe<=60351)Oe-=49472;else throw"illegal char at "+(he+1)+"/"+Oe;Oe=(Oe>>>8&255)*192+(Oe&255),fe.put(Oe,13),he+=2}if(he<me.length)throw"illegal char at "+(he+1)},le},F=function(){var H=[],Q={};return Q.writeByte=function(ae){H.push(ae&255)},Q.writeShort=function(ae){Q.writeByte(ae),Q.writeByte(ae>>>8)},Q.writeBytes=function(ae,ie,le){ie=ie||0,le=le||ae.length;for(var fe=0;fe<le;fe+=1)Q.writeByte(ae[fe+ie])},Q.writeString=function(ae){for(var ie=0;ie<ae.length;ie+=1)Q.writeByte(ae.charCodeAt(ie))},Q.toByteArray=function(){return H},Q.toString=function(){var ae="";ae+="[";for(var ie=0;ie<H.length;ie+=1)ie>0&&(ae+=","),ae+=H[ie];return ae+="]",ae},Q},V=function(){var H=0,Q=0,ae=0,ie="",le={},fe=function(he){ie+=String.fromCharCode(me(he&63))},me=function(he){if(!(he<0)){if(he<26)return 65+he;if(he<52)return 97+(he-26);if(he<62)return 48+(he-52);if(he==62)return 43;if(he==63)return 47}throw"n:"+he};return le.writeByte=function(he){for(H=H<<8|he&255,Q+=8,ae+=1;Q>=6;)fe(H>>>Q-6),Q-=6},le.flush=function(){if(Q>0&&(fe(H<<6-Q),H=0,Q=0),ae%3!=0)for(var he=3-ae%3,Oe=0;Oe<he;Oe+=1)ie+="="},le.toString=function(){return ie},le},j=function(H){var Q=H,ae=0,ie=0,le=0,fe={};fe.read=function(){for(;le<8;){if(ae>=Q.length){if(le==0)return-1;throw"unexpected end of file./"+le}var he=Q.charAt(ae);if(ae+=1,he=="=")return le=0,-1;if(he.match(/^\s$/))continue;ie=ie<<6|me(he.charCodeAt(0)),le+=6}var Oe=ie>>>le-8&255;return le-=8,Oe};var me=function(he){if(65<=he&&he<=90)return he-65;if(97<=he&&he<=122)return he-97+26;if(48<=he&&he<=57)return he-48+52;if(he==43)return 62;if(he==47)return 63;throw"c:"+he};return fe},J=function(H,Q){var ae=H,ie=Q,le=new Array(H*Q),fe={};fe.setPixel=function(Ve,He,at){le[He*ae+Ve]=at},fe.write=function(Ve){Ve.writeString("GIF87a"),Ve.writeShort(ae),Ve.writeShort(ie),Ve.writeByte(128),Ve.writeByte(0),Ve.writeByte(0),Ve.writeByte(0),Ve.writeByte(0),Ve.writeByte(0),Ve.writeByte(255),Ve.writeByte(255),Ve.writeByte(255),Ve.writeString(","),Ve.writeShort(0),Ve.writeShort(0),Ve.writeShort(ae),Ve.writeShort(ie),Ve.writeByte(0);var He=2,at=he(He);Ve.writeByte(He);for(var At=0;at.length-At>255;)Ve.writeByte(255),Ve.writeBytes(at,At,255),At+=255;Ve.writeByte(at.length-At),Ve.writeBytes(at,At,at.length-At),Ve.writeByte(0),Ve.writeString(";")};var me=function(Ve){var He=Ve,at=0,At=0,yt={};return yt.write=function(Dt,It){if(Dt>>>It)throw"length over";for(;at+It>=8;)He.writeByte(255&(Dt<<at|At)),It-=8-at,Dt>>>=8-at,At=0,at=0;At=Dt<<at|At,at=at+It},yt.flush=function(){at>0&&He.writeByte(At)},yt},he=function(Ve){for(var He=1<<Ve,at=(1<<Ve)+1,At=Ve+1,yt=Oe(),Dt=0;Dt<He;Dt+=1)yt.add(String.fromCharCode(Dt));yt.add(String.fromCharCode(He)),yt.add(String.fromCharCode(at));var It=F(),Nt=me(It);Nt.write(He,At);var Ie=0,be=String.fromCharCode(le[Ie]);for(Ie+=1;Ie<le.length;){var We=String.fromCharCode(le[Ie]);Ie+=1,yt.contains(be+We)?be=be+We:(Nt.write(yt.indexOf(be),At),yt.size()<4095&&(yt.size()==1<<At&&(At+=1),yt.add(be+We)),be=We)}return Nt.write(yt.indexOf(be),At),Nt.write(at,At),Nt.flush(),It.toByteArray()},Oe=function(){var Ve={},He=0,at={};return at.add=function(At){if(at.contains(At))throw"dup key:"+At;Ve[At]=He,He+=1},at.size=function(){return He},at.indexOf=function(At){return Ve[At]},at.contains=function(At){return typeof Ve[At]!="undefined"},at};return fe},ne=function(H,Q,ae){for(var ie=J(H,Q),le=0;le<Q;le+=1)for(var fe=0;fe<H;fe+=1)ie.setPixel(fe,le,ae(fe,le));var me=F();ie.write(me);for(var he=V(),Oe=me.toByteArray(),Ve=0;Ve<Oe.length;Ve+=1)he.writeByte(Oe[Ve]);return he.flush(),"data:image/gif;base64,"+he};return l}();(function(){i.stringToBytesFuncs["UTF-8"]=function(l){function c(h){for(var f=[],r=0;r<h.length;r++){var v=h.charCodeAt(r);v<128?f.push(v):v<2048?f.push(192|v>>6,128|v&63):v<55296||v>=57344?f.push(224|v>>12,128|v>>6&63,128|v&63):(r++,v=65536+((v&1023)<<10|h.charCodeAt(r)&1023),f.push(240|v>>18,128|v>>12&63,128|v>>6&63,128|v&63))}return f}return c(l)}})(),function(l){e.exports=l()}(function(){return i})})(Y1);var ZS=Y1.exports;const YS=Z1(ZS);function KS(e){let t={};if(t.ObjectName=e.objectName,t.id=e.getObjectID().id,t.handle=e.getHandle(),t.layer=e.layer,t.color=e.trueColor.getColorString(),t.colorVal=e.trueColor.getColorValue(e.layerId),t.linetype=e.linetype,t.textStyle=e.textStyle,t.type=e.objectName,t.dxf0=e.dxf0,e instanceof M.McDbText){let i=e;t.position=Cr(i.position),t.textString=i.textString}else if(e instanceof M.McDbMText){let i=e;t.contents=i.contents,t.location=Cr(i.location)}else if(e instanceof M.McDbLine){let i=e;t.startPoint=Cr(i.startPoint),t.endPoint=Cr(i.endPoint)}else if(e instanceof M.McDbCircle){let i=e;t.center=Cr(i.center),t.radius=i.radius}else if(e instanceof M.McDbArc){let i=e;t.center=Cr(i.center),t.startAngle=i.startAngle,t.endAngle=i.endAngle}else if(e instanceof M.McDbPolyline){let i=e,l=i.numVerts();t.num=l;for(let c=0;c<l;c++){let h=i.getPointAt(c),f=i.getBulgeAt(c);t["pt"+c]=Cr(h.val),t["bulge"+c]=f}}else if(e instanceof M.McDbBlockReference){let i=e;t.position=Cr(i.position),t.blockTransform=i.blockTransform,t.blockName=i.blockName}else if(e instanceof M.McDbAlignedDimension){let i=e;t.xLine1Point=Cr(i.xLine1Point),t.xLine2Point=Cr(i.xLine2Point),i.GetAllText().forEach((c,h)=>{t["txt:"+h]=c})}else if(e instanceof M.McDbRotatedDimension){let i=e;t.xLine1Point=Cr(i.xLine1Point),t.xLine2Point=Cr(i.xLine2Point),i.GetAllText().forEach((c,h)=>{t["txt:"+h]=c})}else if(e instanceof M.McDbDimension)e.GetAllText().forEach((c,h)=>{t["txt:"+h]=c});else if(e instanceof M.McDbHatch){let i=e;t.patternType=i.patternType(),t.patternName=i.patternName(),t.patternAngle=i.patternAngle,t.patternScale=i.patternScale,t.patternSpace=i.patternSpace,t.patternDouble=i.patternDouble,t.hatchStyle=i.hatchStyle(),t.isSolid=i.isSolid(),t.numLoops=i.numLoops;for(let l=0;l<t.numLoops;l++){let c=i.getLoopAt(l);c.vertices.forEach((h,f)=>{c["pt:"+f]={},c["pt:"+f].x=h.x,c["pt:"+f].y=h.y,c["pt:"+f].z=h.z}),t["loop:"+l]=c}t.numPatternDefinitions=i.numPatternDefinitions;for(let l=0;l<t.numPatternDefinitions;l++)t["patternDefinitions:"+l]=i.getPatternDefinitionAt(l)}else if(e instanceof M.McDbRasterImage){let i=e,l=i.getOrientation();t.orientation={},t.orientation.origin=l.origin.toVector3(),t.orientation.uCorner=l.uCorner.toVector3(),t.orientation.vOnPlane=l.vOnPlane.toVector3();let c=i.clipBoundary();t.clipBoundary={},c.forEach((f,r)=>{t.clipBoundary["pt"+r]=f.toVector3()}),t.clipBoundaryType=i.clipBoundaryType();let h=i.imageDefId().getMcDbRasterImageDef();h&&(t.filePath=h.sourceFileName)}return t}function JS(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet;e.allSelect(),e.forEach(t=>{let i=t.getMcDbEntity();i&&(i=KS(i),console.log(JSON.stringify(i)))})})}function QS(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet,t=new M.MxCADResbuf;t.AddString("0",8),e.allSelect(t),e.forEach(i=>{let l=i.getMcDbEntity();if(l&&l instanceof M.McDbHatch){let c={},h=l;c.patternType=h.patternType(),c.patternName=h.patternName(),c.patternAngle=h.patternAngle,c.patternScale=h.patternScale,c.patternSpace=h.patternSpace,c.patternDouble=h.patternDouble,c.hatchStyle=h.hatchStyle(),c.isSolid=h.isSolid(),c.numLoops=h.numLoops;for(let f=0;f<c.numLoops;f++){let r=h.getLoopAt(f);r.vertices.forEach((v,x)=>{r["pt:"+x]={},r["pt:"+x].x=v.x,r["pt:"+x].y=v.y,r["pt:"+x].z=v.z}),c["loop:"+f]=r}c.numPatternDefinitions=h.numPatternDefinitions;for(let f=0;f<c.numPatternDefinitions;f++)c["patternDefinitions:"+f]=h.getPatternDefinitionAt(f);console.log(c)}})})}function e3(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD(),t=e.getDatabase(),i={};i.name="GRIDMODE",i.isShow=e.getSysVarLong("GRIDMODE");let l=e.getSysVarPoint("SNAPUNIT");i.xdist=l.x,i.ydist=l.x,console.log(i);let c={};c.name="ORTHOMODE",c.isShow=e.getSysVarLong("ORTHOMODE"),console.log(c);let h={};h.name="AUTOSNAP",h.enable=(e.getSysVarLong("AUTOSNAP")&8)!=0,h.polarang=e.getSysVarDouble("POLARANG"),console.log(h);let f={};f.name="OSMODE",f.enable=(e.getSysVarLong("OSMODE")&16384)==0,f.value=e.getSysVarLong("OSMODE"),f.End=(e.getSysVarLong("OSMODE")&1)!=0,f.Mid=(e.getSysVarLong("OSMODE")&2)!=0,f.Cen=(e.getSysVarLong("OSMODE")&4)!=0,f.Node=(e.getSysVarLong("OSMODE")&8)!=0,f.Quad=(e.getSysVarLong("OSMODE")&16)!=0,f.Int=(e.getSysVarLong("OSMODE")&32)!=0,f.Ins=(e.getSysVarLong("OSMODE")&64)!=0,f.Perp=(e.getSysVarLong("OSMODE")&128)!=0,f.Tan=(e.getSysVarLong("OSMODE")&256)!=0,f.Near=(e.getSysVarLong("OSMODE")&512)!=0,console.log(f);let r={};r.name="DYNTRACE",r.enable=e.getSysVarLong("DYNTRACE")!=0,console.log(r);let v={};v.name="DYNINPUT",v.enable=e.getSysVarLong("DYNINPUT")!=0,console.log(v);let x={};x.LTSCALE=e.getSysVarDouble("LTSCALE"),x.CELTSCALE=e.getSysVarDouble("CELTSCALE"),x.CELTYPE=e.getSysVarString("CELTYPE"),x.TEXTSTYLE=e.getSysVarString("TEXTSTYLE"),x.CLAYOUTNAME=e.getSysVarString("CLAYOUTNAME"),x.CLAYER=e.getSysVarString("CLAYER"),x.CECOLOR=t.getCurrentlyTrueColor().getColorValue(),x.INSBASE=e.getSysVarPoint("INSBASE"),x.CELWEIGHT=e.getSysVarLong("CELWEIGHT"),x.PDMODE=e.getSysVarLong("PDMODE"),x.PDSIZE=e.getSysVarDouble("PDSIZE"),console.log(x)})}function t3(){return Qe(this,null,function*(){let e=new M.MxCADUiPrEntity;e.setMessage("选择对象");let t=yield e.go();if(!t.isValid())return;let i=t.getMcDbEntity();if(i===null)return;i.getxData().forEach((c,h,f)=>{console.log(JSON.stringify({val:c,type:h,dxf:f}))})})}function n3(){return Qe(this,null,function*(){let e=new M.MxCADUiPrEntity;e.setMessage("选择对象");let t=yield e.go();if(!t.isValid())return;let i=t.getMcDbEntity();i!==null&&i.setxDataString("DataName","xxxxx")})}function i3(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage(`
- 指定第一点:`);let t=yield e.go();if(t)for(e.setMessage(`
- 指定下一个点:`);;){e.setBasePt(t);let i=yield e.go();if(!i)return;let l=new M.McDbLine(t,i);M.MxCpp.getCurrentMxCAD().drawEntity(l),t=i}})}function K1(){let e=window.location.hostname;return e.substring(0,4)!="http"&&(e=document.location.protocol+"//"+e),e}function r3(){return Qe(this,null,function*(){let e="http://localhost:3000/mxcad/";e.substring(0,16)=="http://localhost"&&(e=K1()+e.substring(16));let t=e+"tree.mxweb",i=M.MxCpp.App.getCurrentMxCAD(),l=yield i.insertBlock(t,"tree");if(!l.isValid())return;let c=new M.McDbBlockReference;c.blockTableRecordId=l;let h=c.getBoundingBox();if(h.ret){let b=h.maxPt.distanceTo(h.minPt);b>1e-5&&c.setScale(i.getMxDrawObject().screenCoordLong2Doc(100)/b)}let f=new M.MxCADUiPrPoint;f.setMessage("指定插入基点"),f.setUserDraw((b,A)=>{c.position=b,A.drawMcDbEntity(c)});let r=yield f.go();if(!r)return;c.position=r;let v=i.drawEntity(c);if(!v.isValid){console.log("insert error");return}c=v.getMcDbEntity(),c.disableDisplay(!0),l.getMcDbBlockTableRecord().getAllEntityId().forEach((b,A)=>{if(!b.isKindOf("McDbAttributeDefinition"))return;let L=b.getMcDbEntity(),P=L.tag,R=L.textString,F=new M.McDbAttribute;F.position=L.position,F.alignmentPoint=L.alignmentPoint,F.height=L.height,F.trueColor=L.trueColor,F.widthFactor=L.widthFactor,R.length>0?F.textString=R:F.textString="test"+A,F.tag=P,F.isInvisible=L.isInvisible,F.transformBy(c.blockTransform),F=c.appendAttribute(F).getMcDbEntity(),F.textStyle=L.textStyle,F.layer=L.layer}),c.disableDisplay(!1)})}function o3(){let i=M.MxCpp.App.getCurrentMxCAD().getDatabase().getLayerTable().getAllRecordId(),l=[];return i.forEach(c=>{let h=c.getMcDbLayerTableRecord();if(h===null)return;console.log(h),console.log("layerRec.color:"+h.color.getColorString()),console.log("layerRec.name:"+h.name);let f={};f.name=h.name,f.color=h.color.getColorString(),l.push(f)}),X.MxFun.postMessageToParentFrame(l),l}function a3(){let t=M.MxCpp.App.getCurrentMxCAD().getDatabase().getLayerTable();if(!t.has("xxx11")){let i=new M.McDbLayerTableRecord;i.name="xxx11",t.add(i)}t.has("xxx11")&&console.log("add layer ok")}function s3(){M.MxCpp.App.getCurrentMxCAD().getDatabase().getLinetypeTable().getAllRecordId().forEach(l=>{let c=l.getMcDbLinetypeTableRecord();c!==null&&console.log(c)})}function l3(){M.MxCpp.getCurrentMxCAD().getDatabase().getTextStyleTable().getAllRecordId().forEach(l=>{let c=l.getMcDbTextStyleTableRecord();if(c===null)return;let h={};h.name=c.name,h.font=c.font(),h.fileName=c.fileName,h.bigFontFileName=c.bigFontFileName,h.textSize=c.textSize,h.xScale=c.xScale,console.log(h)})}function c3(){return Qe(this,null,function*(){let t=M.MxCpp.getCurrentMxCAD().getDatabase().getTextStyleTable(),i="MyTextStyle";t.has(i,!1)&&t.get(i,!1).erase(!1);let l=new M.McDbTextStyleTableRecord;l.fileName="txt.shx",l.bigFontFileName="hztxt.shx",l.textSize=10,l.name=i,l.xScale=.7,t.add(l).isValid()&&console.log("add ok")})}function u3(){M.MxCpp.App.getCurrentMxCAD().getDatabase().getBlockTable().getAllRecordId().forEach(l=>{let c=l.getMcDbBlockTableRecord();c!==null&&(console.log(c),console.log("blkRec.name:"+c.name),console.log("blkRec.origin:"+c.origin))})}function h3(){return Qe(this,null,function*(){let e=new X1;e.data.addColumn("序号",30),e.data.addColumn("名称",45),e.data.addColumn("材料",60),e.data.addColumn("长度",50);for(let c=0;c<10;c++){let h=""+c;e.data.addRow([h,"AAAA","BBBB","1000"])}let t=new M.MxCADUiPrPoint;t.setMessage(`
- 指定表格插入点:`);let i=yield t.go();if(!i)return;let l=X.MxFun.screenCoordLong2Doc(100)/200;e.draw(i,l)})}function d3(){return Qe(this,null,function*(){const e=new X.MrxDbgUiPrPoint;e.setMessage(`
- 指定插入点:`);let t=yield e.go();if(!t)return;let i=X.MxFun.getCurrentDraw();const l=YS(5,"L");l.addData("https://www.mxdraw3d.com"),l.make();const c=l.createDataURL(),h=new id().load(c),f=new cr({map:h});let r=X.MxFun.screenCoordLong2Doc(80),v=X.MxFun.screenCoordLong2Doc(80),x=new X.MxDbImage;x.setRenderOrder(X.MxType.MxDefaultRenderOrder.kCADMeshRenderOrder-1),x.setPoint1(t);let w=new Pe(t.x+r,t.y+v,t.z);x.setPoint2(w),x.setMaterial(f),i.addMxEntity(x),setInterval(()=>{i.updateDisplay()},100)})}function p3(){return Qe(this,null,function*(){let e="http://localhost:3000/mxcad/";e.substring(0,16)=="http://localhost"&&(e=K1()+e.substring(16));let t=e+"stamp.mxweb",i=M.MxCpp.App.getCurrentMxCAD(),l=yield i.insertBlock(t,"stamp");if(!l.isValid())return;let c=new M.McDbBlockReference;c.blockTableRecordId=l;let h=c.getBoundingBox();if(h.ret){let v=h.maxPt.distanceTo(h.minPt);v>1e-5&&c.setScale(i.getMxDrawObject().screenCoordLong2Doc(100)/v)}let f=new M.MxCADUiPrPoint;f.setMessage("指定插入基点"),f.setUserDraw((v,x)=>{c.position=v,x.drawMcDbEntity(c)});let r=yield f.go();r&&(c.position=r,i.drawEntity(c))})}function f3(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD(),t=e.database.getLinetypeTable().get("TestMyLine");t.isErase()||t.erase();let i=e.addLinetypeEx("TestMyLine",'.5,-.2,["HW",STANDARD,S=.1,R=0.0,X=-0.1,Y=-.05],-.2',"");if(!i.isValid())return;let h=(yield new M.MxCADUiPrEntity().go()).getMcDbEntity();h&&(h.linetypeId=i)})}function V_(e){e.getAllObjectName().forEach(i=>{console.log(i);let c=e.getAt(i).getMcDbObject();if(c instanceof M.McDbDictionary){let h=c;console.log(h),V_(h)}else c instanceof M.McDbXrecord&&c.getData().PrintData()})}function m3(){return Qe(this,null,function*(){let e=new M.MxCADUiPrEntity;e.setMessage("选择标注对象");let t=yield e.go();if(!t.isValid())return;let i=t.getMcDbEntity();if(i&&i.isHaveExtensionDictionary()){let l=i.getExtensionDictionary();V_(l)}})}function g3(){return Qe(this,null,function*(){let t=M.MxCpp.getCurrentMxCAD().getDatabase().getNamedObjectsDictionary();t.getAllObjectName().forEach(l=>{console.log(l);let h=t.getAt(l).getMcDbObject();if(h instanceof M.McDbDictionary){let f=h;console.log(f),V_(f)}})})}function y3(){return Qe(this,null,function*(){let t=M.MxCpp.getCurrentMxCAD().getDatabase().getNamedObjectsDictionary(),i="MyDict",l=t.getAt(i);if(l.isNull()){let h=new M.McDbDictionary;l=t.addObject(i,h)}let c=l.getMcDbDictionary();if(c){let h=new M.McDbXrecord,f=new M.MxCADResbuf;f.AddString("TestData"),h.setData(f),c.addObject("MyRecord",h),console.log("write xrecord ok")}})}function _3(){return Qe(this,null,function*(){let e=new M.MxCADUiPrEntity;e.setMessage("选择标注对象");let t=yield e.go();if(!t.isValid())return;let i=t.getMcDbEntity();i&&(i.trueColor=new M.McCmColor(255,0,255))})}let G_;function v3(){return Qe(this,null,function*(){if(G_){let e=G_.getMcDbEntity();if(!e)return;e.visible=!0}else{let e=new M.MxCADUiPrEntity;e.setMessage("选择标注对象");let t=yield e.go();if(!t.isValid())return;let i=t.getMcDbEntity();if(!i)return;i.visible=!1,G_=t}})}function x3(){return Qe(this,null,function*(){let e="WALL";M.MxCpp.getCurrentMxCAD().database.layerTable.has(e)||console.log("no have layer:"+e);let i=new M.MxCADUiPrEntity;i.setMessage("选择对象");let l=yield i.go();if(!l.isValid())return;let c=l.getMcDbEntity();c&&(c.layer=e)})}function b3(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet;if(!(yield e.userSelect(`
- 选择对象`)))return;let i=M.MxCpp.getCurrentDatabase().currentSpace.getMinMaxDrawOrder().maxDrawOrder+1;e.forEach(l=>{let c=l.getMcDbEntity();c&&(c.drawOrder=i)})})}function w3(e){let t=M.MxCpp.getCurrentMxCAD();t.mxdraw.makeCurrent(),t.loadDwgBackground(e,i=>{let l=t.getBackgroundEntity();l.setShow(e,!1);let c=l.getBackgroundDatabase(e);if(c==null)return;let h=new M.MxCompare;if(h.do(c)){let f=h.getResult();f.length>0&&l.setShow(e,!0),console.log(JSON.stringify(f))}},53962434921)}function M3(){w3("test3.mxweb")}let fd;function T3(){if(fd)fd.DoRestore(),fd=void 0;else{fd=new M.MxModifyColor;let e=new M.McCmColor;e.setColorIndex(M.ColorIndexType.kWhite),fd.Do(M.MxCpp.getCurrentDatabase(),e)}}function E3(){X.MxFun.addCommand("TestGetAllEntity",JS),X.MxFun.addCommand("MxTest_GetSysVars",e3),X.MxFun.addCommand("MxTest_ReadxData",t3),X.MxFun.addCommand("MxTest_WritexData",n3),X.MxFun.addCommand("MxTest_DrawLine",i3),X.MxFun.addCommand("MxTest_InsertBlock",r3),X.MxFun.addCommand("MxTest_GetAllLayer",o3),X.MxFun.addCommand("MxTest_AddLayer",a3),X.MxFun.addCommand("MxTest_GetAllTextStyle",l3),X.MxFun.addCommand("MxTest_GetAllBlock",u3),X.MxFun.addCommand("MxTest_GetAllLinetype",s3),X.MxFun.addCommand("Mx_Test_DrawTable",h3),X.MxFun.addCommand("Mx_Test_QRCode",d3),X.MxFun.addCommand("MxTest_InsertStamp",p3),X.MxFun.addCommand("MxTest_LineTypeTest",f3),X.MxFun.addCommand("TestGentEntityOnLayer",QS),X.MxFun.addCommand("MxTest_GetNamedObjectsDictionary",g3),X.MxFun.addCommand("MxTest_GetObjectExDictionaryData",m3),X.MxFun.addCommand("MxTest_WriteXRecord",y3),X.MxFun.addCommand("MxTest_AddTextStyleTable",c3),X.MxFun.addCommand("Mx_Test_ChangeColor",_3),X.MxFun.addCommand("Mx_Test_ChangeVisible",v3),X.MxFun.addCommand("Mx_Test_ChangeEntityLayer",x3),X.MxFun.addCommand("Mx_ChaneEntityDrawOrder",b3),X.MxFun.addCommand("Mx_MxCompare",M3),X.MxFun.addCommand("MxTest_ModifyAllEntityColor",T3)}function C3(){return Qe(this,null,function*(){let{baseUrl:e="",saveDwgUrl:t="",mxfilepath:i=""}=xl().getUploadFileConfig();M.MxCpp.getCurrentMxCAD().saveFileToUrl(t,(l,c)=>{try{let h=JSON.parse(c);if(h.ret=="ok"){let f=e+i+h.file;fetch(f).then(r=>Qe(this,null,function*(){const v=yield r.blob();M.MxTools.saveAsFileDialog({blob:v,filename:h.file,types:[{description:"dwg图纸",accept:{"application/octet-stream":[".dwg"]}}]})}))}else console.log(c)}catch(h){console.log("Mx: sserverResult error")}})})}function A3(){return Qe(this,null,function*(){let{baseUrl:e="",mxfilepath:t="",saveUrl:i=""}=xl().getUploadFileConfig();M.MxCpp.getCurrentMxCAD().saveFileToUrl(i,(l,c)=>{try{let h=JSON.parse(c);if(h.ret=="ok"){let f=e+t+h.file;M.MxTools.downloadFileFromUrl(f,h.file)}else console.log(c)}catch(h){console.log("Mx: sserverResult error")}})})}function D3(){return Qe(this,null,function*(){M.MxCpp.getCurrentMxCAD().openWebFile("http://localhost:1337/mxcad/file/8c79da20e232495888dbb0da17459399.mxweb")})}function P3(){return Qe(this,null,function*(){M.MxCpp.getCurrentMxCAD().newFile()})}function S3(){return Qe(this,null,function*(){let e=new M.MxCADUiPrPoint;e.setMessage(`
- 指定输出范围第一点:`);let t=yield e.go();if(!t)return;e.setMessage(`
- 指定输出范围第二点:`),e.setUserDraw((r,v)=>{v.setColor(16711680);let x=new M.McDbPolyline;x.addVertexAt(t),x.addVertexAt(new M.McGePoint3d(t.x,r.y)),x.addVertexAt(r),x.addVertexAt(new M.McGePoint3d(r.x,t.y)),x.constantWidth=X.MxFun.screenCoordLong2Doc(2),x.isClosed=!0,v.drawMcDbEntity(x);let w=[];w.push(t.toVector3()),w.push(new THREE.Vector3(t.x,r.y)),w.push(r.toVector3()),w.push(new THREE.Vector3(r.x,t.y)),v.setColor(12868),v.drawSolid(w,.5)}),e.setDisableOsnap(!0),e.setDisableOrthoTrace(!0),e.setDynamicInputType(X.DynamicInputType.kXYCoordInput);let i=yield e.go();if(!i)return;let{baseUrl:l="",mxfilepath:c="",printPdfUrl:h=""}=xl().getUploadFileConfig();console.log(xl().getUploadFileConfig());let f={width:"2100",height:"2970",bd_pt1_x:""+t.x,bd_pt1_y:""+t.y,bd_pt2_x:""+i.x,bd_pt2_y:""+i.y};M.MxCpp.getCurrentMxCAD().saveFileToUrl(h,(r,v)=>{try{let x=JSON.parse(v);if(x.ret=="ok"){let w=l+c+x.file;M.MxTools.downloadFileFromUrl(w,x.file)}else console.log(v)}catch(x){console.log("Mx: sserverResult error")}},void 0,JSON.stringify(f))})}function L3(){return Qe(this,null,function*(){let e=new M.MxCADUiPrPoint;e.setMessage(`
- 指定输出范围第一点:`);let t=yield e.go();if(!t)return;e.setMessage(`
- 指定输出范围第二点:`),e.setUserDraw((r,v)=>{v.setColor(16711680);let x=new M.McDbPolyline;x.addVertexAt(t),x.addVertexAt(new M.McGePoint3d(t.x,r.y)),x.addVertexAt(r),x.addVertexAt(new M.McGePoint3d(r.x,t.y)),x.constantWidth=X.MxFun.screenCoordLong2Doc(2),x.isClosed=!0,v.drawMcDbEntity(x);let w=[];w.push(t.toVector3()),w.push(new THREE.Vector3(t.x,r.y)),w.push(r.toVector3()),w.push(new THREE.Vector3(r.x,t.y)),v.setColor(12868),v.drawSolid(w,.5)}),e.setDisableOsnap(!0),e.setDisableOrthoTrace(!0),e.setDynamicInputType(X.DynamicInputType.kXYCoordInput);let i=yield e.go();if(!i)return;let{baseUrl:l="",mxfilepath:c="",cutDwgUrl:h=""}=xl().getUploadFileConfig();console.log(xl().getUploadFileConfig());let f={bd_pt1_x:""+t.x,bd_pt1_y:""+t.y,bd_pt2_x:""+i.x,bd_pt2_y:""+i.y};M.MxCpp.getCurrentMxCAD().saveFileToUrl(h,(r,v)=>{try{let x=JSON.parse(v);if(x.ret=="ok"){let w=l+c+x.file;M.MxTools.downloadFileFromUrl(w,x.file)}else console.log(v)}catch(x){console.log("Mx: sserverResult error")}},void 0,JSON.stringify(f))})}function I3(t){return Qe(this,arguments,function*({param:e}){M.MxCpp.getCurrentMxCAD().openWebFile(e)})}function R3(){return Qe(this,null,function*(){const e=M.MxCpp.getCurrentMxCAD();e.saveFile(e.getCurrentFileName(),t=>{window.parent.postMessage({cmd:"MKY_Download_Mxweb",file:t})},!1,!1)})}function k3(){X.MxFun.addCommand("Mx_Export_DWG_test",C3),X.MxFun.addCommand("Mx_Export_MxWeb",A3),X.MxFun.addCommand("Mx_Open_MxWeb",D3),X.MxFun.addCommand("MxTest_NewFile",P3),X.MxFun.addCommand("Mx_Export_Pdf",S3),X.MxFun.addCommand("Mx_Cut_Dwg",L3),X.MxFun.addCommand("MKY_Open_Mxweb",I3),X.MxFun.addCommand("MKY_Download_Mxweb",R3)}function z3(){return Qe(this,null,function*(){let e="0601",t="001A",i=new M.MxCADSelectionSet,l=new M.MxCADResbuf;l.AddMcDbEntityTypes("TEXT,MTEXT,INSERT,ACAD_PROXY_ENTITY"),i.allSelect(l);let c,h,f=i.count();for(let r=0;r<f;r++){let x=i.item(r).getMcDbEntity();if(!x)return;if(x instanceof M.McDbText){let w=x;if(w.textString==e){c=w.position,h=w.getBoundingBox();break}}else if(x instanceof M.McDbMText){let w=x;if(w.contents==e){c=w.location,h=w.getBoundingBox();break}}else if(x instanceof M.McDbBlockReference){let w=x,b=w.getAllAttribute(),A=0;if(b.forEach(L=>{let P=L.getMcDbEntity();(P.textString==e||P.textString==t)&&A++}),A==2){c=w.position,h=w.getBoundingBox();break}}else if(x instanceof M.McDbProxyEntity){let w=x,b=w.getAllTextContent(),A=0;if(b.forEach(L=>{L==e&&A++}),A>=1){h=w.getBoundingBox(),h&&h.ret&&(c=new M.McGePoint3d(h.minPt.x+(h.maxPt.x-h.minPt.x)*.5,h.minPt.y+(h.maxPt.y-h.minPt.y)*.5));break}}}if(h&&h.ret){console.log(h);let r=h.minPt.distanceTo(h.maxPt)*2;X.MxFun.getCurrentDraw().zoomW(new THREE.Vector3(h.minPt.x-r,h.minPt.y-r,0),new THREE.Vector3(h.maxPt.x+r,h.maxPt.y+r,0))}else c?X.MxFun.getCurrentDraw().zoomCenter(c.x,c.y):console.log("没有找到文字:"+e)})}function F3(){return Qe(this,null,function*(){const e=new M.MxCADUiPrEntity;e.setMessage("请选择目标文字");const t=yield e.go();if(!t.id)return;const i=t.getMcDbEntity(),l=new M.MxCADSelectionSet,c=[];l.allSelect(new M.MxCADResbuf([M.DxfCode.kEntityType,"TEXT"])),l.forEach(r=>Qe(this,null,function*(){let v=r.getMcDbEntity();if(v.textString==i.textString){const x=v.position;console.log("文字位置:X:"+x.x+"Y:"+x.y+"Z:"+x.z);const w=v.height;let{minPt:b,maxPt:A,ret:L}=v.getBoundingBox();if(!L)return;const P=M.McGeVector3d.kXAxis.normalize().mult(w*4),R=M.McGeVector3d.kYAxis.normalize().mult(w*4);b.addvec(P.negate()).addvec(R.negate()),A.subvec(P).subvec(R);let F=Math.abs(b.x-A.x),V=Math.abs(b.y-A.y);if(F<1||V<1)return;let j=200,J=j*V/F;c.push({width:j,height:J,range_pt1:b.toVector3(),range_pt2:A.toVector3()})}}));let h="";for(let r=0;r<c.length;r++){let v=yield B3(CM({},c[r]));h+='<img src="'+v+'"/>'}let f=window.open();f!=null&&f.document.write(`<div style="display:flex;align-item:center;justify-content:space-evenly;">${h}</div>`)})}function B3(e){return new Promise((t,i)=>{X.MxFun.getCurrentDraw().createCanvasImageData(l=>{t(l)},e)})}function O3(){X.MxFun.addCommand("MxTest_FindText",z3),X.MxFun.addCommand("Mx_Test_GetText",F3)}class wm extends M.McDbCustomEntity{constructor(t){super(t),this.pt1=new M.McGePoint3d,this.pt2=new M.McGePoint3d}create(t){return new wm(t)}getTypeName(){return"McDbTestLineCustomEntity"}dwgInFields(t){return this.pt1=t.readPoint("pt1").val,this.pt2=t.readPoint("pt2").val,!0}dwgOutFields(t){return t.writePoint("pt1",this.pt1),t.writePoint("pt2",this.pt2),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),t==0?(this.pt1.x+=i,this.pt1.y+=l,this.pt1.z+=c):t==1&&(this.pt2.x+=i,this.pt2.y+=l,this.pt2.z+=c)}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.pt1),t.append(this.pt2),t}worldDraw(t){let i=new M.McDbPolyline;i.addVertexAt(this.pt1),i.addVertexAt(this.pt2),t.drawEntity(i)}setPoint1(t){this.assertWrite(),this.pt1=t.clone()}setPoint2(t){this.assertWrite(),this.pt2=t.clone()}getPoint1(){return this.pt1}getPoint2(){return this.pt2}}function N3(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD();const t=new M.MxCADUiPrPoint;t.setMessage(`
- 指定一点:`);let i=yield t.go();if(!i)return;t.setBasePt(i),t.setUseBasePt(!0),t.setMessage(`
- 指定二点:`);let l=yield t.go();if(!l)return;let c=new wm;c.setPoint1(i),c.setPoint2(l),e.drawEntity(c)})}function U3(){new wm().rxInit(),X.MxFun.addCommand("MxTest_DrawCustomEntity",N3)}function V3(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet;if(!(yield e.userSelect("选择要做成块的对象:"))||e.count()==0)return;let t=M.MxCpp.getCurrentMxCAD(),l=t.getDatabase().getBlockTable().add(new M.McDbBlockTableRecord),c=l.getMcDbBlockTableRecord();if(c==null)return;let h,f,r,v;if(e.forEach(A=>{let L=A.getMcDbEntity();if(!L)return;let P=L.clone();c.appendAcDbEntity(P);let R=L.getBoundingBox();R.ret&&(h?(h>R.minPt.x&&(h=R.minPt.x),f>R.minPt.y&&(f=R.minPt.y),r<R.maxPt.x&&(r=R.maxPt.x),v<R.maxPt.y&&(v=R.maxPt.y)):(h=R.minPt.x,f=R.minPt.y,r=R.maxPt.x,v=R.maxPt.y))}),h===void 0)return;let x=h+(r-h)*.5,w=f+(v-f)*.5;c.origin=new M.McGePoint3d(x,w,0);let b=new M.McDbBlockReference;b.blockTableRecordId=l,b.position=new M.McGePoint3d(x,w,0),b=t.drawEntity(b).getMcDbEntity(),e.forEach(A=>{let L=A.getMcDbEntity();L&&L.erase()})})}function G3(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet;if(!(yield e.userSelect("选择要做成块的对象:"))||e.count()==0)return;let t=M.MxCpp.getCurrentMxCAD(),i=t.getDatabase().getBlockTable(),l=new M.McDbBlockTableRecord,c=i.add(l),h=c.getMcDbBlockTableRecord();if(h==null)return;let f,r,v,x;if(e.forEach(J=>{let ne=J.getMcDbEntity();if(!ne)return;let H=ne.clone();h.appendAcDbEntity(H);let Q=ne.getBoundingBox();Q.ret&&(f?(f>Q.minPt.x&&(f=Q.minPt.x),r>Q.minPt.y&&(r=Q.minPt.y),v<Q.maxPt.x&&(v=Q.maxPt.x),x<Q.maxPt.y&&(x=Q.maxPt.y)):(f=Q.minPt.x,r=Q.minPt.y,v=Q.maxPt.x,x=Q.maxPt.y))}),f===void 0)return;let w=f+(v-f)*.5,b=r+(x-r)*.5;h.origin=new M.McGePoint3d(w,b,0);let A=new M.McDbBlockReference;A.blockTableRecordId=c,A.position=new M.McGePoint3d(w+(v-f)*3,b+(x-r)*3,0),A=t.drawEntity(A).getMcDbEntity();let L=v-f;L<x-r&&(L=x-r),L*=.3;let P=new M.McDbCircle(w,b,0,L),R=P.getSamplePoints(L*1e-5),F=new M.McGePoint3dArray;R.forEach((J,ne,H)=>{if(H===1010){const Q=new M.McGePoint3d(J.x,J.y,J.z);F.append(Q)}}),A.createSpatialFilter(),A.scaleFactors=new M.McGePoint3d(3,3,3),A.getSpatialFilterId().getMcDbObject().setBoundary(F),P.center=A.position,P.radius=P.radius*3,t.drawEntity(P)})}function W3(){X.MxFun.addCommand("MxTest_SelectEntitysToBlock",V3),X.MxFun.addCommand("MxTest_SelectEntitysToSpatialFilterBlock",G3)}function j3(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage(`
- 指定填充区域内部一点:`),e.disableAllTrace(!0),e.setDisableOsnap(!0);let t=yield e.go();if(!t)return;let i=M.MxCADUtility.builderHatchFromPoint(t);if(!i){X.MxFun.acutPrintf(`没有找到闭合区域
- `);return}M.MxCpp.getCurrentMxCAD().drawEntity(i)})}function H3(){X.MxFun.addCommand("MxTest_DrawHatchFormPoint",j3)}const W_={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function $3(e){if(/^\d+,\s*\d+,\s*\d+$/.test(e))return e.split(",").map(Number);if(/^0x[0-9a-fA-F]{6}$/.test(e)){const t=parseInt(e,16);return[t>>16&255,t>>8&255,t&255]}else if(/^#[0-9a-fA-F]{6}$/.test(e)){const t=parseInt(e.slice(1),16);return[t>>16&255,t>>8&255,t&255]}else if(W_[e.toLowerCase()]){const t=e.toLowerCase();if(W_[t])return W_[t]}else{const t=new M.McCmColor;return t.setColorIndex(256),[t.red,t.green,t.blue]}}const q3=e=>{const t=M.MxCpp.getCurrentDatabase().layerTable;if(t.has(e))return;const i=new M.McDbLayerTableRecord;i.color=new M.McCmColor(0,0,0),i.isFrozen=!1,i.isLocked=!1,i.isOff=!1,i.lineWeight=M.McDb.LineWeight.kLnWtByLayer,i.name=e,t.add(i)},ys=[{name:"color",description:"颜色",type:"str",required:!0},{name:"layer",description:"图层",type:"str",required:!0},{name:"lineweight",description:"线重",type:"float",required:!0}],_s=(e,t)=>{t.layer&&q3(t.layer);const i=l=>{t.color?l.trueColor=new M.McCmColor(...$3(t.color)):l.trueColor=new M.McCmColor(M.MxCpp.getCurrentDatabase().getCurrentlyDrawColor()),t.layer?l.layer=t.layer:l.layer=M.MxCpp.getCurrentDatabase().getCurrentlyLayerName(),t.lineweight&&(l.lineweight=t.lineweight)};Array.isArray(e)?e.forEach(i):e&&i(e)},X3=e=>{const t=e.split(",").map(c=>Number(c)),i=[];let l=0;for(;l<t.length;){const c=t[l];l++;const h=t[l];if(l++,typeof c=="undefined"||typeof h=="undefined")return i;const f=new M.McGePoint3d(c,h);i.push(f)}return i},hr=e=>{if(typeof e=="object"&&"x"in e&&"y"in e)return new M.McGePoint3d(e.x,e.y);if(Array.isArray(e))return new M.McGePoint3d(e[0],e[1]);if(typeof e=="string"){const[t,i]=e.split(",").map(l=>Number(l));if(typeof t=="number"&&typeof i=="number")return new M.McGePoint3d(t,i)}};class Z3{call(t){if(console.log(t),t&&t.pt1&&t.pt2){let i=M.MxCpp.getCurrentMxCAD();t.pt1&&(t.pt1=hr(t.pt1)),t.pt2&&(t.pt2=hr(t.pt2));const l=i.drawLine(t.pt1.x,t.pt1.y,t.pt2.x,t.pt2.y);_s(l.getMcDbEntity(),t),i.updateDisplay()}}regist_data(){return{filename:"drawline.json",name:"draw_line",description:"根据直线的开始点和结束点绘制一个直线段",params:[{name:"pt1",description:"直线开始点",type:"tuple[float, float]",required:!0},{name:"pt2",description:"直线结束点",type:"tuple[float, float]",required:!0},...ys]}}}function Y3(){wo.regist(Z3)}class K3{call(t){if(console.log(t),t&&t.cen&&t.radius){t.cen&&(t.center=hr(t.cen));let i=M.MxCpp.getCurrentMxCAD();const l=i.drawCircle(t.center.x,t.center.y,t.radius);_s(l.getMcDbEntity(),t),i.updateDisplay()}}regist_data(){return{filename:"drawcircle.json",name:"draw_circle",description:"根据圆心和半径绘制一个圆",params:[{name:"center",description:"圆的中心点",type:"tuple[float, float]",required:!0},{name:"radius",description:"圆的半径",type:"float",required:!0},...ys]}}}const J3=()=>{wo.regist(K3)};function Wr(e,t,i,l,c){const h=e.x,f=e.y,r=t.x,v=t.y,x=i.x,w=i.y,b=l.x,A=l.y,L=(h-r)*(w-A)-(f-v)*(x-b);if(L===0)return null;const P=((h-x)*(w-A)-(f-w)*(x-b))/L,R=-((h-r)*(f-w)-(f-v)*(h-x))/L,F=h+P*(r-h),V=f+P*(v-f),j=new M.McGePoint3d(F,V,0);return c||P>0&&P<1&&R>0&&R<1?j:null}function ou(e,t){const i=t.x,l=t.y;let c=!1;for(let h=0,f=e.length-1;h<e.length;f=h++){const r=e[h].x,v=e[h].y,x=e[f].x,w=e[f].y;v>l!=w>l&&i<(x-r)*(l-v)/(w-v)+r&&(c=!c)}return c}function md(e,t,i,l){const c=e-i,h=t-l;let f=0;return c==0?f=Math.PI/2:f=Math.atan(Math.abs(h/c)),c<0&&h>=0?f=Math.PI-f:c<0&&h<0?f=Math.PI+f:c>=0&&h<0&&(f=Math.PI*2-f),f}function gd(e,t,i,l){const c=new M.McDbArc;return c.center=e,c.radius=t,c.startAngle=i,c.endAngle=l,c}class Q3{call(t){return Qe(this,null,function*(){console.log(t);let{center:i,radius:l,startAngle:c,endAngle:h,is3PDraw:f,point1:r,point2:v,point3:x}=t,w=M.MxCpp.getCurrentMxCAD();w.newFile(),w.zoomAll();const b=new M.MxCADUiPrPoint,A=new M.MxCADUiPrDist;if(f){if(r&&(r=hr(r)),v&&(v=hr(v)),x&&(x=hr(x)),b.setKeyWords(""),!r&&(b.setMessage("指定圆弧起点"),b.setUserDraw((P,R)=>{if(!v||!x)return;const F=new M.McDbArc;F.computeArc(P.x,P.y,v.x,v.y,x.x,x.y),R.drawMcDbEntity(F)}),r=yield b.go(),!r)||!v&&(b.setMessage("指定圆弧第二个点"),b.setUserDraw((P,R)=>{if(!r||!x)return;const F=new M.McDbArc;F.computeArc(r.x,r.y,P.x,P.y,x.x,x.y),R.drawMcDbEntity(F)}),v=yield b.go(),!v)||!x&&(b.setMessage("指定圆弧的端点"),b.setUserDraw((P,R)=>{if(!r||!v)return;const F=new M.McDbArc;F.computeArc(r.x,r.y,v.x,v.y,P.x,P.y),R.drawMcDbEntity(F)}),x=yield b.go(),!x))return;const L=new M.McDbArc;console.log(r.x,r.y,v.x,v.y,x.x,x.y),L.computeArc(r.x,r.y,v.x,v.y,x.x,x.y),_s(L,t),w.drawEntity(L),w.updateDisplay()}else{if(i&&(i=hr(i)),c&&(c=c*(Math.PI/180)),h&&(h=h*(Math.PI/180)),!i){b.setMessage("指定圆弧圆心"),b.setKeyWords(""),b.setUserDraw((R,F)=>{l&&F.drawMcDbEntity(gd(R,l,c||0,h||Math.PI*2))});const P=yield b.go();if(!P)return;i=P}if(!l&&(A.setBasePt(i),A.setMessage(M._ML_String("MxAiDrawCircleArc_Radius","指定圆弧半径")),A.setKeyWords(""),A.setUserDraw((P,R)=>{if(!i)return;const F=P.distanceTo(i);R.drawMcDbEntity(gd(i,F,c||0,h||Math.PI*2))}),l=yield A.go(),!l))return;if(!c){if(!i)return;A.setBasePt(i),A.setMessage(M._ML_String("MxAiDrawCircleArc_StartAngle","指定圆弧开始角")),A.setKeyWords(""),A.setUserDraw((R,F)=>{i&&l&&(c=md(i.x,i.y,R.x,R.y)-Math.PI,F.drawMcDbEntity(gd(i,l,c||0,h||Math.PI*2)))});const P=yield A.go();if(!P)return;A.getDetailedResult()===X.DetailedResult.kCoordIn&&(c=P*(Math.PI/180))}if(!h){if(!i)return;A.setBasePt(i),A.setMessage(M._ML_String("MxAiDrawCircleArc_EndAngle","指定圆弧结束角")),A.setKeyWords(""),A.setUserDraw((R,F)=>{i&&l&&(h=md(i.x,i.y,R.x,R.y)-Math.PI,F.drawMcDbEntity(gd(i,l,c||0,h||Math.PI*2)))});const P=yield A.go();if(!P)return;A.getDetailedResult()===X.DetailedResult.kCoordIn&&(h=P*(Math.PI/180))}const L=gd(i,l,c,h);_s(L,t),w.drawEntity(L),w.updateDisplay()}})}regist_data(){return{filename:"drawcirclearc.json",name:"draw_circle_arc",description:"绘制圆弧",params:[{name:"center",description:"圆弧圆心",type:"tuple[float, float]",required:!0},{name:"radius",description:"圆弧半径",type:"float",required:!0},{name:"startAngle",description:"圆弧开始角",type:"float",required:!0},{name:"endAngle",description:"圆弧结束角",type:"float",required:!0},{name:"is3PDraw",description:"是否三点绘制",type:"boolean",required:!0},{name:"point1",description:"三点绘制圆弧的第一个点(起点)",type:"tuple[float, float]",required:!0},{name:"point2",description:"三点绘制圆弧的第二个点",type:"tuple[float, float]",required:!0},{name:"point3",description:"三点绘制圆弧的第三个点(终点)",type:"tuple[float, float]",required:!0},...ys]}}}const eL=()=>{wo.regist(Q3)};function J1(e=new M.McGePoint3d,t=new M.McGePoint3d,i=3){const l=t.x,c=t.y,h=e.x,f=e.y,r=Math.max(3,i),x=Math.sqrt(fx(l-h,2)+fx(c-f,2))/Math.cos(Math.PI/r),w=Math.atan2(c-f,l-h)-Math.PI/r,b=[];for(let A=0;A<r;A++){const L=w+A*2*Math.PI/r,P=h+x*Math.cos(L),R=f+x*Math.sin(L);b.push(new M.McGePoint3d(P,R))}return b}function Q1(e=new M.McGePoint3d,t=new M.McGePoint3d,i=3){const l=[];i=Math.max(3,i),l.push(t);const c=Math.PI*2/i;for(let h=1;h<i;h++){const f=Math.cos(c*h),r=Math.sin(c*h),v=e.clone(),x=t.clone(),w=x.x-v.x,b=x.y-v.y,A=w*f-b*r+v.x,L=w*r+b*f+v.y,P=new M.McGePoint3d(A,L);l.push(P)}return l}function tL(e,t,i){let l=t.x-e.x,c=t.y-e.y,h=Math.sqrt(l*l+c*c),f=Math.atan2(c,l),r=2*Math.PI/Math.max(3,i),v=[e,t];for(let x=0;x<i;x++){let w=e.x+h*Math.cos(f+x*r),b=e.y+h*Math.sin(f+x*r);e=new M.McGePoint3d(w,b),v.push(e)}return v}class nL{call(t){return Qe(this,null,function*(){M.MxCpp.getCurrentMxCAD().newFile(),console.log(t);let{isDrawToCenter:i,sideNum:l,startPoint:c,endPoint:h,radius:f,centerPoint:r,isTangentToTheCircle:v}=t;if(!l){const x=new M.MxCADUiPrInt;x.setMessage("输入边的数目<5>"),x.setKeyWords(""),x.clearLastInputPoint(),l=(yield x.go())||5}if(i){if(r)r=hr(r);else{const A=new M.MxCADUiPrPoint;if(A.setMessage(`
- 指定正多变形的中心点`),A.setKeyWords(""),A.clearLastInputPoint(),r=yield A.go(),!r)return}let x=M.McGeVector3d.kXAxis,w;if(!f){const A=new M.MxCADUiPrDist;A.setMessage(M._ML_String("MxAiDrawPolygon_radius","指定圆的半径")),A.setKeyWords(""),A.setBasePt(r),A.setUserDraw((P,R)=>{if(v){const F=P.distanceTo(r);x=P.sub(r);const V=r.clone().addvec(P.sub(r).normalize().mult(F)),j=J1(r,V,l),J=new M.McDbPolyline;j.forEach(ne=>{J.addVertexAt(ne)}),J.isClosed=!0,R.drawMcDbEntity(J)}else{w=P;const F=new M.McDbPolyline;Q1(r,P,l).forEach(V=>{F.addVertexAt(V)}),F.isClosed=!0,R.drawMcDbEntity(F)}});const L=yield A.go();if(!L)return;f=L}const b=new M.McDbPolyline;if(b.isClosed=!0,v){const A=r.clone().addvec(x.normalize().mult(f));J1(r,A,l).forEach(P=>{b.addVertexAt(P)})}else{if(!w){const A=M.McGeVector3d.kXAxis.clone().rotateBy(Math.PI/l).mult(f);w=r.clone().addvec(A)}Q1(r,w,l).forEach(A=>{b.addVertexAt(A)})}M.MxCpp.getCurrentMxCAD().drawEntity(b)}else{const x=b=>{const A=new M.McDbPolyline;return tL(c,b,l||5).forEach(P=>{A.addVertexAt(P)}),A.isClosed=!0,A};if(c)c=hr(c);else{const b=new M.MxCADUiPrPoint;if(b.clearLastInputPoint(),b.setMessage(`
- 指定边的第一个端点`),b.setKeyWords(""),c=yield b.go(),!c)return;b.setUserDraw((A,L)=>{L.drawMcDbEntity(x(A))})}if(h)h=hr(h);else{const b=new M.MxCADUiPrPoint;b.setBasePt(c),b.setMessage(`
- 指定边的第二个端点`),h=yield b.go()}if(!h)return;const w=x(h);M.MxCpp.getCurrentMxCAD().drawEntity(w)}})}regist_data(){return{filename:"DrawPolygon.json",name:"draw_polygon",description:"绘制正多边形",params:[{name:"isDrawToCenter",description:"是否用圆绘制多边形",type:"boolean",required:!0},{name:"sideNum",description:"边数",type:"int",required:!0},{name:"startPoint",description:"边绘制提供开始点",type:"tuple[float, float]",required:!0},{name:"endPoint",description:"边绘制提供结束点",type:"tuple[float, float]",required:!0},{name:"radius",description:"圆的半径",type:"number",required:!0},{name:"centerPoint",description:"圆心",type:"tuple[float, float]",required:!0},{name:"isTangentToTheCircle",description:"外切于圆",type:"boolean",required:!0}]}}}const iL=()=>{wo.regist(nL)},eb=(e,t,i)=>{const l=Math.cos(i),c=Math.sin(i),h=t.x-e.x,f=t.y-e.y,r=h*l-f*c+e.x,v=h*c+f*l+e.y,x=t.z;return new M.McGePoint3d(r,v,x)},j_=(e,t,i=0)=>{const l=new M.McGePoint3d((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2),c=new M.McGePoint3d(e.x,t.y,e.z),h=new M.McGePoint3d(t.x,e.y,t.z),f=eb(l,c,i),r=eb(l,h,i);return[e,f,t,r]},tb=(e,t)=>[t.x>=e.x&&t.y>=e.y,t.x<e.x&&t.y>=e.y,t.x<e.x&&t.y<e.y,t.x>=e.x&&t.y<e.y];function nb(e,t,i){if(t===0&&i===0)return e;const[l,c,h,f]=e,r=l.distanceTo(f),v=l.distanceTo(c),[x,w,b,A]=tb(l,h),L=w||b?-t:t,P=b||A?-i:i;if(r-Math.abs(L)*2<=0||v-Math.abs(P)*2<=0)return e;const R=new M.McGePoint3d(l.x+L,l.y,l.z),F=new M.McGePoint3d(l.x,l.y+P,l.z),V=new M.McGePoint3d(c.x,c.y-P,c.z),j=new M.McGePoint3d(c.x+L,c.y,c.z),J=new M.McGePoint3d(h.x-L,h.y,h.z),ne=new M.McGePoint3d(h.x,c.y-P,h.z),H=new M.McGePoint3d(f.x,f.y+P,f.z),Q=new M.McGePoint3d(f.x-L,f.y,f.z);return[R,F,V,j,J,ne,H,Q]}function rL(e,t,i){if(e.isEqualTo(t))return 0;let l=e.c().addvec(t.c().sub(e).mult(.5)),c=t.c().sub(e);c.rotateBy(Math.PI/2,M.McGeVector3d.kZAxis);let h=new M.McDbLine(l,l.c().addvec(c)),f=i.c();f.rotateBy(Math.PI/2,M.McGeVector3d.kZAxis);let r=new M.McDbLine(e,e.c().addvec(f)),v=h.IntersectWith(r,M.McDb.Intersect.kExtendBoth);if(v.isEmpty())return 0;let x=v.at(0),w=x.distanceTo(e);c.normalize(),c.mult(w);let b=x.c().addvec(c),A=x.c().subvec(c),L=b.c().sub(e),P=A.c().sub(e),R=b;return L.angleTo1(i)>P.angleTo1(i)&&(R=A),M.MxCADUtility.calcBulge(e,R,t).val}class oL{call(t){return Qe(this,null,function*(){console.log(t),M.MxCpp.getCurrentMxCAD().newFile();let{pt1:i,pt2:l,chamfer1Length:c,chamfer2Length:h,filletRadius:f,lineWidth:r,area:v,rectLength:x,rectWidth:w,rotationAngle:b}=t;const A=(R,F)=>{const[V,j,J,ne]=j_(R,F,b),H=new M.McDbPolyline;return H.addVertexAt(V,0,r,r),H.addVertexAt(j,0,r,r),H.addVertexAt(J,0,r,r),H.addVertexAt(ne,0,r,r),H.isClosed=!0,r&&(H.constantWidth=r),H},L=(R,F)=>{let V;if(f){const j=nb(j_(R,F,b),f,f),[J,ne,H,Q]=tb(R,F);if(j.length===8){V||(V=new M.McDbPolyline);const ae=(he,Oe,Ve)=>{let He=new M.McGeVector3d(Ve);const at=rL(he,Oe,He);V.addVertexAt(he,at,r,r),V.addVertexAt(Oe,0,r,r)},ie=new M.McGeVector3d(-1,0),le=new M.McGeVector3d(0,1),fe=new M.McGeVector3d(1,0),me=new M.McGeVector3d(0,-1);Q&&(le.y=-1,fe.x=1,me.y=1),ne&&(ie.x=1,le.y=1,fe.x=-1,me.y=-1),H&&(ie.x=1,le.y=-1,fe.x=-1,me.y=1),ae(j[0],j[1],ie),ae(j[2],j[3],le),ae(j[4],j[5],fe),ae(j[6],j[7],me),V.isClosed=!0}}else(c||h)&&(V||(V=new M.McDbPolyline),nb(j_(R,F,b),c||h,h||c).forEach(J=>{V.addVertexAt(J)}),V.isClosed=!0);return V||(V=A(R,F)),r&&(V.constantWidth=r),V};if(i)i=hr(i);else{const R=new M.MxCADUiPrPoint;if(R.setMessage("指定第一个角点"),R.setKeyWords(""),i=yield R.go(),!i)return}if(v&&(x&&(w=v/x),w&&(x=v/w)),x&&w&&(l=new M.McGePoint3d(i.x+w,i.y+x,0)),l)l=hr(l);else{const R=new M.MxCADUiPrPoint;if(R.setMessage("指定第二个角点"),R.setKeyWords(""),R.setUserDraw((F,V)=>{V.drawMcDbEntity(L(i,F))}),l=yield R.go(),!l)return}const P=L(i,l);_s(P,t),M.MxCpp.getCurrentMxCAD().drawEntity(P)})}regist_data(){return{filename:"drawRect.json",name:"draw_rect",description:"根据一些信息绘制矩形",params:[{name:"pt1",description:"一个对角点",type:"tuple[float, float]",required:!0},{name:"pt2",description:"另一个对角点",type:"tuple[float, float]",required:!0},{name:"lineWidth",description:"矩形线的宽",type:"float",required:!0},{name:"filletRadius",description:"圆角半径",type:"float",required:!0},{name:"chamfer1Length",description:"第一个倒角距离",type:"float",required:!0},{name:"chamfer2Length",description:"第二个倒角距离",type:"float",required:!0},{name:"rectLength",description:"长度",type:"float",required:!0},{name:"rectWidth",description:"矩形宽度",type:"float",required:!0},{name:"area",description:"面积",type:"float",required:!0},{name:"rotationAngle",description:"旋转角度",type:"float",required:!0},...ys]}}}function aL(){wo.regist(oL)}const ia=(e,t,i,l,c)=>{const h=new M.McDbEllipse,f=new M.McGePoint3d((e.x+t.x)/2,(t.y+t.y)/2),r=e.sub(t),v=r,x=e.distanceTo(t)/2,b=i/2/x;return h.center=f,h.majorAxis=r,h.minorAxis=v,h.radiusRatio=b,h.startAngle=l,h.endAngle=c,h};class sL{call(t){return Qe(this,null,function*(){let{endPoint1:i,endPoint2:l,halfAxisLength:c}=t;const h=M.MxCpp.getCurrentMxCAD();h.newFile();const f=new M.MxCADUiPrPoint,r=new M.MxCADUiPrDist;if(i&&(i=hr(i)),l&&(l=hr(l)),!i&&(f.setMessage("指定椭圆的轴端点1"),f.setKeyWords(""),f.setUserDraw((x,w)=>{l&&c&&w.drawMcDbEntity(ia(x,l,c,0,Math.PI*2))}),i=yield f.go(),!i)||!l&&(f.setMessage("指定椭圆的轴端点2"),f.setKeyWords(""),f.setUserDraw((x,w)=>{i&&c&&w.drawMcDbEntity(ia(i,x,c,0,Math.PI*2))}),l=yield f.go(),!l))return;if(!c){r.setMessage("指定半轴长度"),r.setKeyWords("");const x=new M.McGePoint3d((i.x+l.x)/2,(l.y+l.y)/2);if(r.setBasePt(x),r.setUserDraw((w,b)=>{i&&b.drawMcDbEntity(ia(i,l,x.distanceTo(w),0,Math.PI*2))}),c=yield r.go(),!c)return}const v=ia(i,l,c,0,Math.PI*2);_s(v,t),h.drawEntity(v)})}regist_data(){return{filename:"drawellipse.json",name:"draw_ellipse",description:"绘制椭圆",params:[{name:"endPoint1",description:"椭圆端点1",type:"tuple[float, float]",required:!0},{name:"endPoint2",description:"椭圆端点2",type:"tuple[float, float]",required:!0},{name:"halfAxisLength",description:"半轴长度",type:"float",required:!0},...ys]}}}class lL{call(t){return Qe(this,null,function*(){let{endPoint1:i,endPoint2:l,halfAxisLength:c,startAngle:h,endAngle:f}=t;const r=M.MxCpp.getCurrentMxCAD();r.newFile();const v=new M.MxCADUiPrPoint,x=new M.MxCADUiPrDist;if(i&&(i=hr(i)),l&&(l=hr(l)),h&&(h=h*(Math.PI/180)),f&&(f=f*(Math.PI/180)),!i&&(v.setMessage("指定椭圆的轴端点1"),v.setKeyWords(""),v.setUserDraw((L,P)=>{l&&c&&P.drawMcDbEntity(ia(L,l,c,0,Math.PI*2))}),i=yield v.go(),!i)||!l&&(v.setMessage("指定椭圆的轴端点2"),v.setKeyWords(""),v.setUserDraw((L,P)=>{i&&c&&P.drawMcDbEntity(ia(i,L,c,0,Math.PI*2))}),l=yield v.go(),!l))return;const w=new M.McGePoint3d((i.x+l.x)/2,(l.y+l.y)/2);if(!c&&(x.setMessage("指定半轴长度"),x.setKeyWords(""),x.setBasePt(w),x.setUserDraw((L,P)=>{i&&P.drawMcDbEntity(ia(i,l,w.distanceTo(L),0,Math.PI*2))}),c=yield x.go(),!c))return;const b=md(w.x,w.y,i.x,i.y);if(!h){x.setMessage(M._ML_String("EllipticalArc_startAngle","指定起点角度")),x.setKeyWords(""),x.setUserDraw((P,R)=>{h=md(w.x,w.y,P.x,P.y)-b-Math.PI,R.drawMcDbEntity(ia(i,l,c,h,Math.PI*2))});const L=yield x.go();if(!L)return;x.getDetailedResult()==X.DetailedResult.kCoordIn&&(h=L*(180/Math.PI))}if(!f){x.setLastInputPoint(w),x.setMessage(M._ML_String("EllipticalArc_endAngle","指定端点角度")),x.setKeyWords(""),x.setUserDraw((P,R)=>{f=md(w.x,w.y,P.x,P.y)-b-Math.PI,R.drawMcDbEntity(ia(i,l,c,h,f))});const L=yield x.go();if(!L)return;x.getDetailedResult()===X.DetailedResult.kCoordIn&&(f=L*(180/Math.PI))}const A=ia(i,l,c,h,f);_s(A,t),r.drawEntity(A)})}regist_data(){return{filename:"drawellipseArc.json",name:"draw_ellipse_arc",description:"绘制椭圆弧",params:[{name:"endPoint1",description:"椭圆弧端点1",type:"tuple[float, float]",required:!0},{name:"endPoint2",description:"椭圆弧端点2",type:"tuple[float, float]",required:!0},{name:"halfAxisLength",description:"半轴长度",type:"float",required:!0},{name:"startAngle",description:"开始角度",type:"float",required:!0},{name:"endAngle",description:"结束角度",type:"float",required:!0},...ys]}}}const cL=()=>{wo.regist(sL),wo.regist(lL)},ib=class Ho{constructor(t,i,l=50){this.width=50,this.isDraw=!1,this.update(t,i,l)}update(t,i,l=this.width){let c=t.clone().sub(i).normalize();c=new M.McGeVector3d(-c.y,c.x,0).mult(l/2);const h=c.clone().negate();this.outsidePoints=[t.clone().addvec(c),i.clone().addvec(c)],this.insidePoints=[t.clone().addvec(h),i.clone().addvec(h)],this.width=l,this.startPoint=t.clone(),this.endPoint=i.clone(),this.outsideLine?(this.outsideLine.startPoint=this.outsidePoints[0],this.outsideLine.endPoint=this.outsidePoints[1]):this.outsideLine=new M.McDbLine(this.outsidePoints[0],this.outsidePoints[1]),this.insideLine?(this.insideLine.startPoint=this.insidePoints[0],this.insideLine.endPoint=this.insidePoints[1]):this.insideLine=new M.McDbLine(this.insidePoints[0],this.insidePoints[1]),this.startClosedLine?(this.startClosedLine.startPoint=this.outsidePoints[0],this.startClosedLine.endPoint=this.insidePoints[0]):this.startClosedLine=new M.McDbLine(this.outsidePoints[0],this.insidePoints[0]),this.endClosedLine?(this.endClosedLine.startPoint=this.outsidePoints[1],this.endClosedLine.endPoint=this.insidePoints[1]):this.endClosedLine=new M.McDbLine(this.outsidePoints[1],this.insidePoints[1])}clone(){const t=new Ho(this.startPoint,this.endPoint,this.width);return t.insideLine=this.insideLine.clone(),t.outsideLine=this.outsideLine.clone(),t}hiddenStartClosedLine(){this.startClosedLine.visible=!1}hiddenEndClosedLine(){this.endClosedLine.visible=!1}getClosedStartLineToDiffWallInsideLineIntersectionPoint(t,i=!1){return this.startClosedLine.visible?Wr(t.insideLine.startPoint,t.insideLine.endPoint,this.startClosedLine.startPoint,this.startClosedLine.endPoint,i):null}getClosedStartLineToDiffWallOutsideLineIntersectionPoint(t,i=!1){return this.startClosedLine.visible?Wr(t.outsideLine.startPoint,t.outsideLine.endPoint,this.startClosedLine.startPoint,this.startClosedLine.endPoint,i):null}getClosedEndLineToDiffWallInsideLineIntersectionPoint(t,i=!1){return this.endClosedLine.visible?Wr(t.insideLine.startPoint,t.insideLine.endPoint,this.endClosedLine.startPoint,this.endClosedLine.endPoint,i):null}getClosedEndLineToDiffWallOutsideLineIntersectionPoint(t,i=!1){return this.endClosedLine.visible?Wr(t.outsideLine.startPoint,t.outsideLine.endPoint,this.endClosedLine.startPoint,this.endClosedLine.endPoint,i):null}getInsideToDiffInsideIntersectionPoint(t,i=!1){return Wr(t.insideLine.startPoint,t.insideLine.endPoint,this.insideLine.startPoint,this.insideLine.endPoint,i)}getOutsideToDiffOutsideIntersectionPoint(t,i=!1){return Wr(t.outsideLine.startPoint,t.outsideLine.endPoint,this.outsideLine.startPoint,this.outsideLine.endPoint,i)}getInsideToDiffOutsideIntersectionPoint(t,i=!1){return Wr(t.outsideLine.startPoint,t.outsideLine.endPoint,this.insideLine.startPoint,this.insideLine.endPoint,i)}getOutsideToDiffInsideIntersectionPoint(t,i=!1){return Wr(t.insideLine.startPoint,t.insideLine.endPoint,this.outsideLine.startPoint,this.outsideLine.endPoint,i)}getClosedStartLineToDiffLineClosedStartLineIntersectionPoint(t,i=!1){return this.startClosedLine.visible?Wr(t.startClosedLine.startPoint,t.startClosedLine.endPoint,this.startClosedLine.startPoint,this.startClosedLine.endPoint,i):null}getClosedStartLineToDiffLineClosedEndLineIntersectionPoint(t,i=!1){return this.startClosedLine.visible?Wr(t.endClosedLine.startPoint,t.endClosedLine.endPoint,this.startClosedLine.startPoint,this.startClosedLine.endPoint,i):null}getClosedEndLineToDiffLineClosedStartLineIntersectionPoint(t,i=!1){return this.endClosedLine.visible?Wr(t.startClosedLine.startPoint,t.startClosedLine.endPoint,this.endClosedLine.startPoint,this.endClosedLine.endPoint,i):null}getClosedEndLineToDiffLineClosedEndLineIntersectionPoint(t,i=!1){return this.endClosedLine.visible?Wr(t.endClosedLine.startPoint,t.endClosedLine.endPoint,this.endClosedLine.startPoint,this.endClosedLine.endPoint,i):null}isCorner(t){const i=t.startPoint.sub(t.endPoint).normalize(),l=i.clone().mult(t.width),c=i.clone().mult(-t.width),h=t.insideLine.startPoint.clone().addvec(l),f=t.insideLine.startPoint.clone().addvec(c),r=t.outsideLine.startPoint.clone().addvec(c),v=t.outsideLine.startPoint.clone().addvec(l),x=t.insideLine.endPoint.clone().addvec(l),w=t.insideLine.endPoint.clone().addvec(c),b=t.outsideLine.endPoint.clone().addvec(c),A=t.outsideLine.endPoint.clone().addvec(l),L=ou([h,f,r,v],this.startPoint),P=ou([h,f,r,v],this.endPoint),R=ou([x,w,b,A],this.startPoint),F=ou([x,w,b,A],this.endPoint);return[{start:L,end:P},{start:R,end:F}]}handlingCorners(t){const[i,l]=this.isCorner(t);if(l.start){this.outsideLine.startPoint=t.outsideLine.endPoint=this.getOutsideToDiffOutsideIntersectionPoint(t,!0),this.insideLine.startPoint=t.insideLine.endPoint=this.getInsideToDiffInsideIntersectionPoint(t,!0),this.hiddenStartClosedLine(),t.hiddenEndClosedLine();return}else if(l.end){this.outsideLine.endPoint=t.insideLine.endPoint=this.getOutsideToDiffInsideIntersectionPoint(t,!0),this.insideLine.endPoint=t.outsideLine.endPoint=this.getInsideToDiffOutsideIntersectionPoint(t,!0),this.hiddenEndClosedLine(),t.hiddenEndClosedLine();return}else if(i.start){this.insideLine.startPoint=t.outsideLine.startPoint=this.getInsideToDiffOutsideIntersectionPoint(t,!0),this.outsideLine.startPoint=t.insideLine.startPoint=this.getOutsideToDiffInsideIntersectionPoint(t,!0),this.hiddenStartClosedLine(),t.hiddenStartClosedLine();return}else if(i.end){this.outsideLine.endPoint=t.outsideLine.startPoint=this.getOutsideToDiffOutsideIntersectionPoint(t,!0),this.insideLine.endPoint=t.insideLine.startPoint=this.getInsideToDiffInsideIntersectionPoint(t,!0),this.hiddenEndClosedLine(),t.hiddenStartClosedLine();return}}processingIntersection(){const t=[];Ho.lines.forEach(i=>{const l=this.getInsideToDiffInsideIntersectionPoint(i),c=this.getInsideToDiffOutsideIntersectionPoint(i),h=this.getOutsideToDiffOutsideIntersectionPoint(i),f=this.getOutsideToDiffInsideIntersectionPoint(i);(l||c||h||f)&&t.push({diffLine:i,intersectionPoints:[l,c,h,f]})}),t.forEach(({diffLine:i,intersectionPoints:l})=>{const[c,h]=this.isCorner(i);c.end||c.start||h.start||h.start;const[f,r,v,x]=l,w=[i.insideLine.startPoint,i.insideLine.endPoint,i.outsideLine.endPoint,i.outsideLine.startPoint];if(ou(w,this.startPoint),ou(w,this.endPoint),f&&r&&v&&x){const b=Wr(this.startPoint,this.endPoint,i.startPoint,i.endPoint),A=new Ho(this.startPoint,b,this.width),L=new Ho(b,this.endPoint,this.width),P=new Ho(i.startPoint,b,i.width),R=new Ho(b,i.endPoint,i.width);A.insideLine.startPoint=this.insideLine.startPoint,A.outsideLine.startPoint=this.outsideLine.startPoint,L.insideLine.endPoint=this.insideLine.endPoint,L.outsideLine.endPoint=this.outsideLine.endPoint,i.remove(),this.remove(),A.draw(),L.draw(),P.draw(),R.draw()}else if(v&&r||f&&x){const b=Wr(this.startPoint,this.endPoint,i.startPoint,i.endPoint,!0),A=new Ho(i.startPoint,b,i.width);A.hiddenEndClosedLine();const L=new Ho(b,i.endPoint,i.width);L.hiddenStartClosedLine(),i.remove(),A.draw(),L.draw()}else{if(t.length===1)return this.handlingCorners(i);h.start?(console.log("endCorner.start"),v&&(i.outsideLine.endPoint=this.outsideLine.startPoint=v),f&&(i.insideLine.endPoint=this.insideLine.startPoint=f),this.hiddenStartClosedLine(),i.hiddenEndClosedLine()):h.end?(console.log("endCorner.end"),x&&(i.insideLine.endPoint=this.outsideLine.endPoint=x),r&&(i.outsideLine.endPoint=this.insideLine.endPoint=r),this.hiddenEndClosedLine(),i.hiddenEndClosedLine()):c.start?(console.log("startCorner.start"),r&&(i.outsideLine.startPoint=this.insideLine.startPoint=r),x&&(i.insideLine.startPoint=this.outsideLine.startPoint=x),i.hiddenStartClosedLine(),this.hiddenStartClosedLine()):c.end&&(console.log("startCorner.end"),v&&(i.outsideLine.startPoint=this.outsideLine.endPoint=v),f&&(i.insideLine.startPoint=this.insideLine.endPoint=f),i.hiddenStartClosedLine(),this.hiddenEndClosedLine())}})}draw(t=!0){if(this.isDraw)return;const i=M.MxCpp.getCurrentMxCAD();if(this.outsideLine&&this.outsideLine.erase(),this.insideLine&&this.insideLine.erase(),!i)return;this.outsideLine.trueColor=new M.McCmColor(255,0,0),this.outsideId=i.drawEntity(this.outsideLine),this.insideLine.trueColor=new M.McCmColor(0,255,255),this.insideId=i.drawEntity(this.insideLine);const l=this.outsideId.getMcDbEntity();l&&(this.outsideLine=l);const c=this.insideId.getMcDbEntity();c&&(this.insideLine=c),this.startClosedId=i.drawEntity(this.startClosedLine),this.endClosedId=i.drawEntity(this.endClosedLine);const h=this.startClosedId.getMcDbEntity();h&&(this.startClosedLine=h);const f=this.endClosedId.getMcDbEntity();f&&(this.endClosedLine=f),i.updateDisplay(),Ho.lines.add(this),this.isDraw=!0,t&&this.processingIntersection()}remove(){this.endClosedId&&this.endClosedId.erase(),this.startClosedId&&this.startClosedId.erase(),this.insideId&&this.insideId.erase(),this.outsideId&&this.outsideId.erase(),Ho.lines.delete(this)}};ib.lines=new Set;let uL=ib;class hL{call(t){if(t&&t.points){let i=M.MxCpp.getCurrentMxCAD();const l=X3(t.points);if(l.length<2)return;l.forEach((c,h)=>{const f=l[h+1];if(!f)return;new uL(c,f,t.width).draw()}),i.updateDisplay()}}regist_data(){return{filename:"drawWall.json",name:"drawWall",description:"根据坐标点合集绘制墙",params:[{name:"points",description:"绘制墙的坐标点",type:"str",required:!0},{name:"width",description:"绘制墙的宽度",type:"float",required:!1},...ys]}}}class dL{call(t){return Qe(this,null,function*(){let i=M.MxCpp.App.getCurrentMxCAD();if(t.name){const c=i.getDatabase().getBlockTable().get(t.name);if(!c||!c.isValid())return;let h=new M.McDbBlockReference;h.blockTableRecordId=c;let f=h.getBoundingBox(),r=0;if(f.ret){let v=f.maxPt.distanceTo(f.minPt);v>1e-5&&(r=i.getMxDrawObject().screenCoordLong2Doc(100)/v,h.setScale(r))}h.position=new M.McGePoint3d(t.pos[0],t.pos[1]),i.drawEntity(h),i.updateDisplay()}})}regist_data(){return{filename:"insertBock.json",name:"insertBock",description:"放置插入某个物品",params:[{name:"name",description:"要放置插入的物品名称",type:"str",required:!0},{name:"pos",description:"要放置插入物品的位置",type:"tuple[float, float]",required:!0}]}}}function pL(){wo.regist(hL),wo.regist(dL)}class fL{call(t){return Qe(this,null,function*(){let i=M.MxCpp.getCurrentMxCAD();console.log(t),i.newFile();let l;const c=typeof t.isMText=="undefined"?!1:t.isMText,h=()=>{const r=new M.McDbMText;return r.textHeight=t.textSize||100,r.location=t.textPos||new M.McGePoint3d,r.contents=t.textString||"",r},f=()=>{const r=new M.McDbText;return r.height=t.textSize||100,r.textString=t.textString||"",r.position=t.textPos||new M.McGePoint3d,r};if(!t.textString){const r=new M.MxCADUiPrString;r.setMessage("请输入文字");const v=yield r.go();if(!v)return;t.textString=v}if(t.textPos)t.textPos=hr(t.textPos);else{const r=new M.MxCADUiPrPoint;r.clearLastInputPoint(),r.setMessage("请指定文字位置");const v=yield r.go();if(r.setUserDraw((x,w)=>{if(t.textPos=x,c){const b=h();w.drawMcDbEntity(b)}else{const b=f();w.drawMcDbEntity(b)}}),!v)return;t.textPos=v}if(!t.textSize){const r=new M.MxCADUiPrPoint;r.clearLastInputPoint(),r.setMessage("通过线段长度确定文字高度");const v=yield r.go();if(v){r.setUserDraw((w,b)=>{if(t.textSize=v.distanceTo(w),c){const A=h();b.drawMcDbEntity(A)}else{const A=f();b.drawMcDbEntity(A)}});const x=yield r.go();x&&(t.textSize=x.distanceTo(v))}}if(c){const r=h();l=i.drawEntity(r)}else{const r=f();l=i.drawEntity(r)}_s(l.getMcDbEntity(),t),i.updateDisplay()})}regist_data(){return{filename:"drawText.json",name:"draw_text",description:"绘制或者插入文字或者多行文字(文本)",params:[{name:"isMText",description:"绘制的文字是否为多行文字",type:"boolean",required:!0},{name:"textString",description:"绘制的文字的内容",type:"str",required:!0},{name:"textPos",description:"绘制的文字的位置",type:"tuple[float, float]",required:!0},{name:"textSize",description:"绘制的文字的高度",type:"float",required:!0},...ys]}}}function mL(){wo.regist(fL)}class gL{call(t){if(console.log(t),t.isWithdraw){typeof t.withdrawNum!="number"&&(t.withdrawNum=1);for(let i=0;i<t.withdrawNum;i++)X.MxFun.sendStringToExecute("Mx_Undo")}if(t.isRestore){typeof t.restoreNum!="number"&&(t.restoreNum=1);for(let i=0;i<t.restoreNum;i++)X.MxFun.sendStringToExecute("Mx_Redo")}}regist_data(){return{filename:"call_withdraw_restore.json",name:"call_withdraw_restore",description:"撤回撤销和恢复",params:[{name:"isWithdraw",description:"是否要撤回或撤销",type:"boolean",required:!0},{name:"isRestore",description:"是否要恢复",type:"boolean",required:!0},{name:"withdrawNum",description:"撤回撤销(上)几步",type:"int",required:!1},{name:"restoreNum",description:"恢复(前)几步",type:"int",required:!1}]}}}function yL(){wo.regist(gL)}class _L{constructor(){this.aryRegData=[]}regist(t){let i=new t,l=i.regist_data();M.MxCpp.Ai.addFunction(l.name,i.call),this.aryRegData.push(l)}regist_server(t){this.aryRegData.forEach(i=>{i.operation_code=t,M.MxCpp.Ai.registTool(i)}),M.MxCpp.Ai.reloadTools({operation_code:t})}}let wo=new _L;function vL(){return Qe(this,null,function*(){let e=new M.MxCADUiPrString;e.setMessage(`
- human:`);let t=yield e.go();t&&M.MxCpp.Ai.chat_tool(t)})}function xL(){return Qe(this,null,function*(){let e=new M.MxCADUiPrString;e.setMessage(`
- 输入 server_operate_code:`);let t=yield e.go();t&&wo.regist_server(t)})}function bL(){X.MxFun.addCommand("Mx_Ai",vL),X.MxFun.addCommand("Mx_AiRegistServer",xL),Y3(),J3(),eL(),iL(),cL(),pL(),mL(),yL(),aL()}function wL(e,t){let i=40,l=new M.MxCADResbuf;l.AddString("电杆层",0),l.AddString("INSERT",5020);let c=new M.MxCADSelectionSet;c.crossingSelect(e.x-i,e.y-i,e.x+i,e.y+i,l);let h=[];if(c.forEach(f=>{let r=f.getMcDbEntity();if(r){let v=r;t[v.getObjectID().id]&&h.push({dist:v.position.distanceTo(e),blk:t[v.getObjectID().id]})}}),h.length!=0)return h.sort((f,r)=>f.dist-r.dist),h[0].dist<i?h[0].blk:!1}function ML(e,t,i){let l=t[e],c=l.ref,h=40,f=new M.MxCADResbuf;f.AddString("0",0),f.AddString("LINE",5020);let r=new M.MxCADSelectionSet;r.crossingSelect(c.position.x-h,c.position.y-h,c.position.x+h,c.position.y+h,f),r.forEach(v=>{let x=v.getMcDbEntity();if(x){let w=x,b=w.endPoint,A=w.startPoint.distanceTo(c.position);if(A>w.endPoint.distanceTo(c.position)&&(A=w.endPoint.distanceTo(c.position),b=w.startPoint),A<h&&!w[w.getObjectID().id]){let L=wL(b,t);L&&(i[w.getObjectID().id]={tag1:l.tag,tag2:L.tag,handle:w.getHandle()})}}})}function TL(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet,t=new M.MxCADResbuf;t.AddString("电杆层",0),t.AddString("INSERT",5020),e.allSelect(t);let i={};e.forEach(c=>{let h=c.getMcDbEntity();if(h){let f=h,r=f.getAllAttribute(),v={};r.forEach(x=>{let w=x.getMcDbEntity();w.tag=="杆号"&&(v.tag=w.textString)}),v.tag&&(v.handle=f.getHandle(),i[c.id]={ref:f,tag:v.tag},console.log(v))}});let l={};Object.keys(i).forEach(c=>{ML(c,i,l)}),Object.keys(l).forEach(c=>{console.log(l[c])})})}function EL(){X.MxFun.addCommand("MxTest_UserGetData",TL)}class vs extends M.McDbCustomEntity{constructor(t){super(t),this.pt1=new M.McGePoint3d,this.pt2=new M.McGePoint3d,this._text="",this._textsize=10}create(t){return new vs(t)}getTypeName(){return"McDbLineText"}set text(t){this._text=t}get text(){return this._text}set textsize(t){this._textsize=t}get textsize(){return this._textsize}dwgInFields(t){return this.pt1=t.readPoint("pt1").val,this.pt2=t.readPoint("pt2").val,this._text=t.readString("text").val,this._textsize=t.readDouble("textsize").val,!0}dwgOutFields(t){return t.writePoint("pt1",this.pt1),t.writePoint("pt2",this.pt2),t.writeString("text",this._text),t.writeDouble("textsize",this._textsize),!0}fineLink(t){let i={},l=this.getObjectID(),c=this._textsize*.5,h=new M.MxCADResbuf;h.AddString("McDbCustomEntity",5020);let f=new M.MxCADSelectionSet;return f.crossingSelect(t.x-c,t.y-c,t.x+c,t.y+c,h),f.forEach(r=>{if(r==l)return;let v=r.getMcDbEntity();if(v&&v instanceof vs){let x=v,w=x.getPoint1(),b=0,A=x.getPoint1().distanceTo(t);A>x.getPoint2().distanceTo(t)&&(A=x.getPoint2().distanceTo(t),w=x.getPoint2(),b=1),A<c&&(i[r.id]={link_point:w,link_pos:b})}}),i}moveGripPointsAt(t,i,l,c){this.assertWrite();let h=this.pt1.clone(),f=h;if(t==0?(this.pt1.x+=i,this.pt1.y+=l,this.pt1.z+=c,f=this.pt1):t==1&&(h=this.pt2.clone(),this.pt2.x+=i,this.pt2.y+=l,this.pt2.z+=c,f=this.pt2),this.getObjectID().isValid()){let r=this.fineLink(h);Object.keys(r).forEach(v=>{let w=new M.McObjectId(v).getMcDbEntity();r[v].link_pos==0?w.setPoint1(f):w.setPoint2(f)})}}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.pt1),t.append(this.pt2),t}worldDraw(t){let i=this._textsize*.4,l=this.pt2.sub(this.pt1);l.normalize().mult(i);let c=new M.McDbLine(this.pt1.clone().addvec(l),this.pt2.clone().subvec(l));t.drawEntity(c);let h=this.pt2.sub(this.pt1).mult(.5),f=this.pt1.clone().addvec(h);h.dotProduct(M.McGeVector3d.kXAxis)<0&&h.negate();let r=h.angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis),v=this._text;v.length==0&&(v=this.pt1.distanceTo(this.pt2).toFixed(2)),h.perpVector(),h.dotProduct(M.McGeVector3d.kYAxis)<0&&h.negate(),h.normalize().mult(this._textsize*.2);let x=new M.McDbText;x.textString=v,x.position=f.clone().addvec(h),x.alignmentPoint=f.clone().addvec(h),x.rotation=r,x.verticalMode=M.McDb.TextVertMode.kTextBottom,x.horizontalMode=M.McDb.TextHorzMode.kTextCenter,x.height=this._textsize,t.drawEntity(x);let w=new M.McDbCircle;w.center=this.pt1,w.radius=i,t.drawEntity(w);let b=new M.McDbCircle;b.center=this.pt2,b.radius=i,t.drawEntity(b)}setPoint1(t){this.assertWrite(),this.pt1=t.clone()}setPoint2(t){this.assertWrite(),this.pt2=t.clone()}getPoint1(){return this.pt1}getPoint2(){return this.pt2}}function CL(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD();e.newFile();let t=new M.McGePoint3d(100,100,0),i=new M.McGePoint3d(200,150,0),l=new M.McGePoint3d(400,50,0),c=new M.McGePoint3d(600,60,0),h=new M.McGePoint3d(200,300,0),f=5,r=new vs;r.setPoint1(t),r.setPoint2(i),r.textsize=f,r.text="xxxx",e.drawEntity(r);let v=new vs;v.setPoint1(i),v.setPoint2(l),v.textsize=f,e.drawEntity(v);let x=new vs;x.setPoint1(l),x.setPoint2(c),x.textsize=f,e.drawEntity(x);let w=new vs;w.setPoint1(i),w.setPoint2(h),w.textsize=f,e.drawEntity(w),e.zoomW(new M.McGePoint3d(-300,-300,0),new M.McGePoint3d(650,500,0)),e.updateDisplay()})}function AL(){X.MxFun.addCommand("MxTest_LineText",CL),new vs().rxInit()}function DL(){EL(),AL()}class yd extends M.McDbCustomEntity{create(t){throw new Error("Method not implemented.")}getTypeName(){throw new Error("Method not implemented.")}dwgInFields(t){throw new Error("Method not implemented.")}dwgOutFields(t){throw new Error("Method not implemented.")}worldDraw(t){throw new Error("Method not implemented.")}}class _d extends yd{constructor(t){super(t),this.pt=new M.McGePoint3d}create(t){return new _d(t)}getTypeName(){return"McDbGisPoint"}dwgInFields(t){return this.pt=t.readPoint("pt").val,!0}dwgOutFields(t){return t.writePoint("pt",this.pt),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),t==0&&(this.pt.x+=i,this.pt.y+=l,this.pt.z+=c)}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.pt),t}worldDraw(t){t.drawEntity(new M.McDbPoint(this.pt))}setPoint(t){this.assertWrite(),this.pt=t.clone()}getPoint(){return this.pt}}class vd extends yd{constructor(t){super(t),this.pts=[]}create(t){return new vd(t)}getTypeName(){return"McDbGisMultiPoint"}dwgInFields(t){return this.pts=t.readPoints("pts").val,!0}dwgOutFields(t){return t.writePoints("pts",this.pts),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),t>=0&&t<this.pts.length&&(this.pts[t].x+=i,this.pts[t].y+=l,this.pts[t].z+=c)}getGripPoints(){let t=new M.McGePoint3dArray;return this.pts.forEach(i=>{t.append(i)}),t}worldDraw(t){this.pts.forEach(i=>{t.drawEntity(new M.McDbPoint(i))})}setPoint(t,i){this.assertWrite(),t>=0&&t<this.pts.length&&(this.pts[t]=i.clone())}getPoint(t){return t>=0&&t<this.pts.length?this.pts[t]:new M.McGePoint3d}addPoint(t){this.pts.push(t.clone())}removeAllPoint(){this.pts=[]}getPointCount(){return this.pts.length}}class xd extends yd{constructor(t){super(t),this.pts=[]}create(t){return new xd(t)}getTypeName(){return"McDbGisLineString"}dwgInFields(t){return this.pts=t.readPoints("pts").val,!0}dwgOutFields(t){return t.writePoints("pts",this.pts),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),t>=0&&t<this.pts.length&&(this.pts[t].x+=i,this.pts[t].y+=l,this.pts[t].z+=c)}getGripPoints(){let t=new M.McGePoint3dArray;return this.pts.forEach(i=>{t.append(i)}),t}worldDraw(t){let i=new M.McDbPolyline;this.pts.forEach(l=>{i.addVertexAt(l)}),t.drawEntity(i)}setPoint(t,i){this.assertWrite(),t>=0&&t<this.pts.length&&(this.pts[t]=i.clone())}getPoint(t){return t>=0&&t<this.pts.length?this.pts[t]:new M.McGePoint3d}addPoint(t){this.pts.push(t.clone())}removeAllPoint(){this.pts=[]}getPointCount(){return this.pts.length}}class bd extends yd{constructor(t){super(t),this.ptss=[]}create(t){return new bd(t)}getTypeName(){return"McDbGisMultiLineString"}dwgInFields(t){this.ptss=[];let i=t.readLong("ptss_n");for(let l=0;l<i.val;l++){let c=t.readPoints("ptss_"+l);c.ret&&this.ptss.push(c.val)}return!0}dwgOutFields(t){return t.writeLong("ptss_n",this.ptss.length),this.ptss.forEach((i,l)=>{t.writePoints("ptss_"+l,i)}),!0}moveGripPointsAt(t,i,l,c){this.assertWrite();let h=0;for(let f=0;f<this.ptss.length;f++){let r=this.ptss[f];for(let v=0;v<r.length;v++){if(h==t){this.ptss[f][v].x+=i,this.ptss[f][v].y+=l,this.ptss[f][v].z+=c,f=this.ptss.length;break}h++}}}getGripPoints(){let t=new M.McGePoint3dArray;return this.ptss.forEach(i=>{i.forEach(l=>{t.append(l)})}),t}worldDraw(t){for(let i=0;i<this.ptss.length;i++){let l=this.ptss[i],c=new M.McDbPolyline;l.forEach(h=>{c.addVertexAt(h)}),t.drawEntity(c)}}addPoints(t){this.ptss.push(t)}removeAllPoint(){this.ptss=[]}getPointsCount(){return this.ptss.length}getPoints(t){return t>=0&&t<this.ptss.length?this.ptss[t]:[]}}class wd extends yd{constructor(t){super(t),this.ptss=[]}create(t){return new wd(t)}getTypeName(){return"McDbGisPolygon"}dwgInFields(t){this.ptss=[];let i=t.readLong("ptss_n");for(let l=0;l<i.val;l++){let c=t.readPoints("ptss_"+l);c.ret&&this.ptss.push(c.val)}return!0}dwgOutFields(t){return t.writeLong("ptss_n",this.ptss.length),this.ptss.forEach((i,l)=>{t.writePoints("ptss_"+l,i)}),!0}moveGripPointsAt(t,i,l,c){this.assertWrite();let h=0;for(let f=0;f<this.ptss.length;f++){let r=this.ptss[f];for(let v=0;v<r.length;v++){if(h==t){this.ptss[f][v].x+=i,this.ptss[f][v].y+=l,this.ptss[f][v].z+=c,f=this.ptss.length;break}h++}}}getGripPoints(){let t=new M.McGePoint3dArray;return this.ptss.forEach(i=>{i.forEach(l=>{t.append(l)})}),t}worldDraw(t){let i=new M.McDbHatch;for(let l=0;l<this.ptss.length;l++){let c=this.ptss[l];c.length>2&&i.appendLoop(new M.McGePoint3dArray(c))}i.numLoops>0&&t.drawEntity(i)}addPoints(t){this.ptss.push(t)}removeAllPoint(){this.ptss=[]}getPointsCount(){return this.ptss.length}getPoints(t){return t>=0&&t<this.ptss.length?this.ptss[t]:[]}}function PL(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD(),t=new M.MxCADUiPrPoint;t.setMessage("点取一个点坐标");let i=yield t.go();if(i){let l=new _d;l.setPoint(i),e.drawEntity(l)}})}function SL(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD(),t=new M.MxCADUiPrPoint;t.setMessage("点取一个点坐标");let i=new vd,l=[];for(;;){t.clearLastInputPoint(),t.setDynamicInputType(X.DynamicInputType.kXYCoordInput);let c=yield t.go();if(c){i.addPoint(c);let h=new M.McDbPoint(c);l.push(e.drawEntity(h))}else break}i.getPointCount()>0&&e.drawEntity(i),l.forEach(c=>{c.erase()})})}function LL(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD(),t=new M.MxCADUiPrPoint;t.setMessage("点取一个点坐标");let i=new xd,l=[],c;for(;;){c&&(t.setBasePt(c),t.setUseBasePt(!0)),t.setDynamicInputType(X.DynamicInputType.kXYCoordInput);let h=yield t.go();if(h){if(i.addPoint(h),c){let f=new M.McDbLine;f.startPoint=c,f.endPoint=h,l.push(e.drawEntity(f))}c=h}else break}i.getPointCount()>1&&e.drawEntity(i),l.forEach(h=>{h.erase()})})}function IL(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD(),t=new M.MxCADUiPrPoint;t.setMessage("点取一个点坐标"),t.setKeyWords("[下一段线(N)]");let i=new bd,l=[],c=[],h;for(;;){h?t.setBasePt(h):t.setUseBasePt(!1),t.setDynamicInputType(X.DynamicInputType.kXYCoordInput);let f=yield t.go();if(t.isKeyWordPicked("N"))l.length>1&&i.addPoints(l),l=[],h=void 0;else if(f){if(l.push(f),h){let r=new M.McDbLine;r.startPoint=h,r.endPoint=f,c.push(e.drawEntity(r))}h=f}else break}l.length>1&&i.addPoints(l),i.getPointsCount()>0&&e.drawEntity(i),c.forEach(f=>{f.erase()})})}function RL(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD(),t=new M.MxCADUiPrPoint;t.setMessage("点取一个点坐标");let i=new wd,l=[],c=[],h;for(;;){h?t.setBasePt(h):t.setUseBasePt(!1),l.length>2&&t.setKeyWords("[闭合(C)/退出(E)]"),t.setDynamicInputType(X.DynamicInputType.kXYCoordInput);let f=yield t.go();if(t.isKeyWordPicked("C")){let r=new M.McDbLine;r.startPoint=l[0],r.endPoint=l[l.length-1],c.push(e.drawEntity(r)),l.length>2&&i.addPoints(l),l=[],h=void 0}else{if(t.isKeyWordPicked("E"))break;if(f){if(l.push(f),h){let r=new M.McDbLine;r.startPoint=h,r.endPoint=f,c.push(e.drawEntity(r))}h=f}else break}}l.length>2&&i.addPoints(l),i.getPointsCount()>0&&e.drawEntity(i),c.forEach(f=>{f.erase()})})}function kL(){let e=new M.MxCADSelectionSet,t=new M.MxCADResbuf;t.AddMcDbEntityTypes("McDbCustomEntity"),e.allSelect(t);let i={type:"FeatureCollection",features:[]};e.forEach(l=>{let c=l.getMcDbEntity();if(c){if(c instanceof _d){let f=c.getPoint(),r={type:"Feature",properties:{},geometry:{type:"Point",coordinates:[f.x,f.y,f.z]}};i.features.push(r)}else if(c instanceof vd){let h=c,f=[],r=h.getPointCount();for(let x=0;x<r;x++){let w=h.getPoint(x);f.push([w.x,w.y,w.z])}let v={type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:f}};i.features.push(v)}else if(c instanceof xd){let h=c,f=[],r=h.getPointCount();for(let x=0;x<r;x++){let w=h.getPoint(x);f.push([w.x,w.y,w.z])}let v={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:f}};i.features.push(v)}else if(c instanceof bd){let h=c,f=[],r=h.getPointsCount();for(let x=0;x<r;x++){let w=h.getPoints(x),b=[];for(let A=0;A<w.length;A++){let L=w[A];b.push([L.x,L.y,L.z])}f.push(b)}let v={type:"Feature",properties:{},geometry:{type:"MultiLineString",coordinates:f}};i.features.push(v)}else if(c instanceof wd){let h=c,f=[],r=h.getPointsCount();for(let x=0;x<r;x++){let w=h.getPoints(x),b=[];for(let A=0;A<w.length;A++){let L=w[A];b.push([L.x,L.y,L.z])}f.push(b)}let v={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:f}};i.features.push(v)}}}),console.log(JSON.stringify(i))}function zL(){X.MxFun.addCommand("MxGis_DrawPoint",PL),X.MxFun.addCommand("MxGis_DrawMultiPoint",SL),X.MxFun.addCommand("MxGis_DrawLineString",LL),X.MxFun.addCommand("MxGis_DrawMultiLineString",IL),X.MxFun.addCommand("MxGis_DrawPolygon",RL),X.MxFun.addCommand("MxGis_Get_geojson",kL),new _d().rxInit(),new vd().rxInit(),new xd().rxInit(),new bd().rxInit(),new wd().rxInit()}class Mm extends M.McDbCustomEntity{constructor(t){super(t),this._text="",this._textsize=20,this._radius=15}create(t){return new Mm(t)}getTypeName(){return"McDbRectBoxLeadComment"}set text(t){this._text=t}get text(){return this._text}set textsize(t){this._textsize=t}get textsize(){return this._textsize}set radius(t){this._radius=t}get radius(){return this._radius}dwgInFields(t){return this.pt1=t.readPoint("pt1").val,this.pt2=t.readPoint("pt2").val,this.pt3=t.readPoint("pt3").val,this._text=t.readString("text").val,this._textsize=t.readDouble("textsize").val,!0}dwgOutFields(t){return t.writePoint("pt1",this.pt1),t.writePoint("pt2",this.pt2),t.writePoint("pt3",this.pt3),t.writeString("text",this._text),t.writeDouble("textsize",this._textsize),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),t===0?(this.pt1.x+=i,this.pt1.y+=l,this.pt1.z+=c):t===1?(this.pt2.x+=i,this.pt2.y+=l,this.pt2.z+=c):t===2&&(this.pt3.x+=i,this.pt3.y+=l,this.pt3.z+=c)}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.pt1),t.append(this.pt2),t.append(this.pt3),t}worldDraw(t){const i=this._radius;if(this.pt1.x<this.pt2.x){const b=this.pt2.x-this.pt1.x,A=parseInt((b/(i*2)).toString());this.pt2.x=this.pt1.x+i*2*A}else{const b=this.pt1.x-this.pt2.x,A=parseInt((b/(i*2)).toString());this.pt1.x=this.pt2.x+i*2*A}if(this.pt1.y<this.pt2.y){const b=this.pt2.y-this.pt1.y,A=parseInt((b/(i*2)).toString());this.pt2.y=this.pt1.y+i*2*A}else{const b=this.pt1.y-this.pt2.y,A=parseInt((b/(i*2)).toString());this.pt1.y=this.pt2.y+i*2*A}const l=new M.McDbPolyline;l.isClosed=!0,l.addVertexAt(this.pt1),l.addVertexAt(new M.McGePoint3d(this.pt2.x,this.pt1.y)),l.addVertexAt(this.pt2),l.addVertexAt(new M.McGePoint3d(this.pt1.x,this.pt2.y));let h=l.getLength().val/i;const f=[];for(let b=1;b<=h;b++){const A=l.getPointAtDist(i*b).val;f.push(A)}f.forEach((b,A)=>{const L=new M.McDbCircle(b.x,b.y,b.z,i);if(A%2===0){const P=[];L.IntersectWith(l,M.McDb.Intersect.kOnBothOperands).forEach(R=>{P.push(R)}),L.splitCurves(P).forEach(R=>{const F=R.getPointAtDist(R.getLength().val/2).val;(F.x<Math.min(this.pt1.x,this.pt2.x)||F.x>Math.max(this.pt1.x,this.pt2.x))&&t.drawEntity(R),(F.y<Math.min(this.pt1.y,this.pt2.y)||F.y>Math.max(this.pt1.y,this.pt2.y))&&t.drawEntity(R)})}});const r=[];for(let b=0;b<l.numVerts();b++){const A=l.getPointAt(b).val.distanceTo(this.pt3);r.push(A)}const v=r.indexOf(Math.min(...r)),x=l.getPointAt(v).val,w=new M.McDbPolyline;if(w.addVertexAt(x),w.addVertexAt(this.pt3),this._text){const b=new M.McDbText;b.textString=this._text,b.position=b.alignmentPoint=this.pt3,b.height=20,t.drawEntity(b);const{minPt:A,maxPt:L,ret:P}=b.getBoundingBox();if(!P)return;const R=L.x-A.x;w.addVertexAt(new M.McGePoint3d(this.pt3.x+R,this.pt3.y)),t.drawEntity(w)}else t.drawEntity(w)}setPoint1(t){this.assertWrite(),this.pt1=t.clone()}setPoint2(t){this.assertWrite(),this.pt2=t.clone()}setPoint3(t){this.assertWrite(),this.pt3=t.clone()}getPoint1(){return this.pt1}getPoint2(){return this.pt2}getPoint3(){return this.pt3}}function FL(){return Qe(this,null,function*(){const e=new Mm,t=new M.MxCADUiPrString;t.setMessage("请输入审批意见");let i=yield t.go();i||(i="审批意见XXXX"),e.text=i;const l=new M.MxCADUiPrPoint;l.setMessage("指定云线框起始点");const c=yield l.go();if(!c)return;const h=new M.MxCADUiPrPoint;h.setMessage("指定云线框终止点"),h.setUserDraw((x,w)=>{e.setPoint1(c),e.setPoint2(x),e.setPoint3(x),w.drawMcDbEntity(e)});const f=yield h.go();if(!f)return;e.setPoint2(f);const r=new M.MxCADUiPrPoint;r.setMessage("指定审图标注点"),r.setUserDraw((x,w)=>{e.setPoint3(x),w.drawMcDbEntity(e)});const v=yield r.go();v&&(e.setPoint3(v),M.MxCpp.getCurrentMxCAD().drawEntity(e))})}class Tm extends M.McDbCustomEntity{constructor(t){super(t),this.pt1=new M.McGePoint3d,this.pt2=new M.McGePoint3d}create(t){return new Tm(t)}getTypeName(){return"McDbTestRectangle"}dwgInFields(t){return this.pt1=t.readPoint("pt1").val,this.pt2=t.readPoint("pt2").val,!0}dwgOutFields(t){return t.writePoint("pt1",this.pt1),t.writePoint("pt2",this.pt2),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),t==0?(this.pt1.x+=i,this.pt1.y+=l,this.pt1.z+=c):t==1&&(this.pt2.x+=i,this.pt2.y+=l,this.pt2.z+=c)}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.pt1),t.append(this.pt2),t}worldDraw(t){const i=new M.McDbPolyline;i.isClosed=!0,i.addVertexAt(this.pt1),i.addVertexAt(new M.McGePoint3d(this.pt2.x,this.pt1.y)),i.addVertexAt(this.pt2),i.addVertexAt(new M.McGePoint3d(this.pt1.x,this.pt2.y)),t.drawEntity(i);let l=M.MxCpp.getCurrentMxCAD();const c=new M.McGePoint3d(this.pt2.x,this.pt1.y);l.addDimStyle("MyDimStyle","41,0.18,141,0.09,40,200","77,1,271,3","",""),l.drawDimStyle="MyDimStyle";const h=l.drawDimAligned(this.pt1.x,this.pt1.y+20,c.x,c.y+20,(this.pt1.x+c.x)/2,this.pt1.y+20);t.drawEntity(h.getMcDbEntity()),h.erase();const f=l.drawDimAligned(this.pt2.x+20,this.pt2.y,c.x+20,c.y,c.x+20,(this.pt2.y+c.y)/2);t.drawEntity(f.getMcDbEntity()),f.erase()}setPoint1(t){this.assertWrite(),this.pt1=t.clone()}setPoint2(t){this.assertWrite(),this.pt2=t.clone()}getPoint1(){return this.pt1}getPoint2(){return this.pt2}}function BL(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD();const t=new M.MxCADUiPrPoint;t.setMessage(`
- 指定第一个角点:`);let i=yield t.go();if(!i)return;const l=new Tm;l.setPoint1(i),t.setMessage(`
- 指定第二个角点:`),t.setUserDraw((h,f)=>{l.setPoint2(h),f.drawMcDbEntity(l)});let c=yield t.go();c&&(l.setPoint2(c),e.drawEntity(l))})}class Md extends M.McDbCustomEntity{constructor(t){super(t),this.center=new M.McGePoint3d,this._radius=1}create(t){return new Md(t)}getTypeName(){return"MxDbTestDivide"}set radius(t){this._radius=t}get radius(){return this._radius}dwgInFields(t){return this.center=t.readPoint("center").val,this._radius=t.readDouble("radius").val,!0}dwgOutFields(t){return t.writePoint("center",this.center),t.writeDouble("radius",this._radius),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),this.center.x+=i,this.center.y+=l,this.center.z+=c}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.center),t}worldDraw(t){const i=new M.McDbCircle(this.center.x,this.center.y,this.center.z,this._radius);t.drawEntity(i);const{minPt:l,maxPt:c,ret:h}=i.getBoundingBox();if(!h)return;const f=new M.McDbLine(l,c),r=new M.McDbLine(new M.McGePoint3d(l.x,c.y,0),new M.McGePoint3d(c.x,l.y,0));t.drawEntity(f),t.drawEntity(r)}setCenter(t){this.assertWrite(),this.center=t.clone()}getCenter(){return this.center}}function OL(){return Qe(this,null,function*(){const e=new M.MxCADUiPrKeyWord;e.setMessage("选择要对齐水平标注或竖直标注:"),e.setKeyWords("[水平(H)/竖直(V)]");const t=yield e.go();if(!t)return;const i=new M.MxCADSelectionSet;if(!(yield i.userSelect("选择对齐标注:"))||i.count()==0)return;const l=[];if(i.forEach(x=>{const w=x.getMcDbEntity();if(w.objectName==="McDbRotatedDimension"){const b=w.clone(),A=Math.abs(b.xLine1Point.x-b.xLine2Point.x).toFixed(0),L=Math.abs(b.xLine1Point.y-b.xLine2Point.y).toFixed(0),P=Math.abs(b.dimLinePoint.x-b.xLine1Point.x)+Math.abs(b.dimLinePoint.x-b.xLine2Point.x),R=Math.abs(b.dimLinePoint.y-b.xLine1Point.y)+Math.abs(b.dimLinePoint.y-b.xLine2Point.y);t==="H"&&P.toFixed(0)==A&&l.push(w),t==="V"&&R.toFixed(0)==L&&l.push(w)}}),l.length===0)return;const c=M.MxCpp.getCurrentMxCAD(),h=new M.MxCADUiPrPoint;h.setMessage("设置尺寸线位置");const f=yield h.go();if(!f)return;l.forEach(x=>{x.dimLinePoint=f}),c.updateDisplay();const r=new M.MxCADUiPrPoint;r.setMessage("设置尺寸线界限");const v=yield r.go();v&&(l.forEach(x=>{t==="H"?(x.xLine1Point=new M.McGePoint3d(x.xLine1Point.x,v.y),x.xLine2Point=new M.McGePoint3d(x.xLine2Point.x,v.y)):t==="V"&&(x.xLine1Point=new M.McGePoint3d(v.x,x.xLine1Point.y),x.xLine2Point=new M.McGePoint3d(v.x,x.xLine2Point.y))}),c.updateDisplay())})}function NL(){new Mm().rxInit(),new Tm().rxInit(),new Md().rxInit(),X.MxFun.addCommand("Mx_Approval",FL),X.MxFun.addCommand("Mx_AnnotatedRectangle",BL),X.MxFun.addCommand("Mx_Alignment",OL)}function UL(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet;if(!(yield e.userSelect("选择对象:"))||e.count()==0)return;const t=[],i=M.MxCpp.getCurrentMxCAD(),l=new M.MxCADUiPrPoint;l.setMessage("指定基点");const c=yield l.go();if(c)for(;;){const h=new M.MxCADUiPrPoint;h.setMessage(`指定第二个点
- `),t.length>0?h.setKeyWords("[阵列(A)/退出(E)/放弃(U)]"):h.setKeyWords("[阵列(A)/退出(E)]"),h.setUserDraw((r,v)=>{v.drawLine(r.toVector3(),c.toVector3()),e.forEach(x=>{let w=x.getMcDbEntity();if(!w)return;let b=w.clone();b.move(c,r),v.drawMcDbEntity(b)})});const f=yield h.go();if(h.getStatus()===X.MrxDbgUiPrBaseReturn.kKeyWord){if(h.isKeyWordPicked("E"))return;if(h.isKeyWordPicked("U"))if(t.length>0)t[t.length-1].forEach(r=>{r.erase()}),t.pop();else return;else if(h.isKeyWordPicked("A")){const r=new M.MxCADUiPrInt;r.clearLastInputPoint(),r.setMessage(`输入要进行阵列的项目数
- `);const v=(yield r.go())||1;let x=[];if(h.setUserDraw((b,A)=>{A.drawLine(b.toVector3(),c.toVector3()),x.length=0;let L=b.clone();x.push(L);for(let P=0;P<v-1;P++)L=L.clone().addvec(b.sub(c)),x.push(L);e.forEach(P=>{let R=P.getMcDbEntity();R&&x.forEach(F=>{let V=new M.McGeMatrix3d,j=R.clone();V.clone(),V.setToTranslation(F.sub(c)),j.transformBy(V),A.drawMcDbEntity(j)})})}),!(yield h.go()))return;t.push([]),e.forEach(b=>{let A=b.getMcDbEntity();A&&x.forEach(L=>{let P=new M.McGeMatrix3d,R=A.clone();P.clone(),P.setToTranslation(L.sub(c)),R.transformBy(P),t[t.length-1].push(i.drawEntity(R))})})}}else if(h.getStatus()===X.MrxDbgUiPrBaseReturn.kOk){if(!f)return;t.push([]),e.forEach(r=>{let v=r.getMcDbEntity();if(!v)return;let x=v.clone();x.move(c,f),t[t.length-1].push(i.drawEntity(x))})}else return}})}function VL(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("ARC");let t=yield M.MxCADUtility.userSelect("选择圆弧对象",e);t.length!=0&&t.forEach(i=>Qe(this,null,function*(){let l=yield i.getMcDbEntity(),c=l,h=c.center,f=c.radius,r=new M.McDbCircle;r.center=h,r.radius=f,l.erase(),M.MxCpp.getCurrentMxCAD().drawEntity(r)}))})}function GL(){return Qe(this,null,function*(){const e=M.MxCpp.getCurrentMxCAD();let t=new M.MxCADSelectionSet;if(!(yield t.userSelect("选择复制旋转对象:"))||t.count()==0)return;const i=new M.MxCADUiPrPoint;i.setMessage("指定基点");const l=yield i.go(),c=new M.MxCADUiPrPoint;c.setMessage(`请指定目标点
- `),c.setUserDraw((w,b)=>{b.drawLine(w.toVector3(),l.toVector3()),t.forEach(A=>{let L=A.getMcDbEntity();if(!L)return;let P=L.clone();P.move(l,w),b.drawMcDbEntity(P)})});const h=yield c.go();if(!h)return;let f=[];t.forEach(w=>{let b=w.getMcDbEntity();if(!b)return;let A=b.clone();A.move(l,h),f.push(e.drawEntity(A))});let r=new M.MxCADUiPrAngle;if(r.setMessage("请指定旋转角度"),r.setBasePt(h),r.setUserDraw((w,b)=>{b.drawLine(w.toVector3(),h.toVector3()),f.forEach(A=>{let L=A.getMcDbEntity();if(!L)return;let P=L.clone(),R=w.sub(h).angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis);P.rotate(h,R),b.drawMcDbEntity(P)})}),!(yield r.go()))return;const x=r.value();f.forEach(w=>{let b=w.getMcDbEntity();if(!b)return;let A=b.clone();A.rotate(h,x),e.drawEntity(A),b.erase()})})}function WL(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("CIRCLE");let t=yield M.MxCADUtility.userSelect("选择要转成多边形的对象",e);if(t.length==0)return;let i=new M.MxCADUiPrInt;i.setMessage("设置多边形边数");let l=(yield i.go())||5;if(i.clearLastInputPoint(),!l)return;const c=new M.MxCADUiPrPoint;c.setMessage(`
- 输入选项`),c.setKeyWords("[内接于圆(I)/外切于圆(C)]"),c.clearLastInputPoint(),yield c.go();let h="inside";c.isKeyWordPicked("i")&&(h="inside"),c.isKeyWordPicked("c")&&(h="outside");let f=M.MxCpp.getCurrentMxCAD();t.forEach(r=>Qe(this,null,function*(){let v=yield r.getMcDbEntity(),x=v,w=[];if(h==="inside"){for(let A=0;A<l;A++){let L=x.getPointAtDist(x.getLength().val/l*A);L.ret&&w.push(L.val)}let b=new M.McDbPolyline;w.forEach(A=>{b.addVertexAt(A)}),b.isClosed=!0,f.drawEntity(b)}else if(h==="outside"){let b=90-360/(l*2),A=Math.sin(b*Math.PI/180),L=x.radius/A,P=new M.McDbCircle;P.center=x.center,P.radius=L;let R=[];for(let V=0;V<l;V++){let j=P.getPointAtDist(P.getLength().val/l*V);j.ret&&R.push(j.val)}let F=new M.McDbPolyline;R.forEach(V=>{F.addVertexAt(V)}),F.isClosed=!0,f.drawEntity(F)}v.erase()}))})}function jL(){return Qe(this,null,function*(){let e=yield M.MxCADUtility.userSelect("选择要修改颜色的对象");if(e.length==0)return;const t=new M.MxCADUiPrInt;t.setMessage("输入颜色索引(0~256)");let i=(yield t.go())||20,l=new M.McCmColor;l.setColorIndex(i),e.forEach(c=>Qe(this,null,function*(){let h=c.getMcDbEntity();h.trueColor=l}))})}function HL(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("ARC");let t=yield M.MxCADUtility.userSelect("选择圆弧对象",e);t.length!=0&&t.forEach(i=>Qe(this,null,function*(){let l=yield i.getMcDbEntity();if(!l)return;let c=l.clone(),h=c.getLength(),f=c.getStartPoint().val,r=M.MxCpp.getCurrentMxCAD(),v=new M.McDbCircle;v.center=c.center,v.radius=c.radius;let x=v.getDistAtPoint(f),w=v.getPointAtDist(h.val+x.val).val,b=c.getFirstDeriv(f);if(!b.ret)return;let A=f.clone();A.addvec(b.val);let L=c.getFirstDeriv(w);if(!L.ret)return;let P=w.clone();P.addvec(L.val);let R=new M.McDbLine;R.startPoint=f,R.endPoint=A;let F=new M.McDbLine;F.startPoint=w,F.endPoint=P;let V=R.IntersectWith(F,M.McDb.Intersect.kExtendBoth);if(V.length()===0)return;let j=V.at(0);R.endPoint=j,F.endPoint=j,r.drawEntity(R),r.drawEntity(F)}))})}function $L(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD();const t=new M.MxCADUiPrKeyWord;t.setMessage(`
- 输入选项`),t.setKeyWords("[隐藏(A)/隐藏未选(B)/全部显示(C)]");const i=yield t.go();if(i)if(i==="A"||i==="B"){let l=yield M.MxCADUtility.userSelect("选择目标的对象");if(l.length==0)return;let c=[];if(l.forEach(h=>c.push(h.id)),i==="A")l.forEach(h=>Qe(this,null,function*(){let f=yield h.getMcDbEntity(),r=f.clone();r.visible=!1,e.drawEntity(r),f.erase()}));else if(i==="B"){let h=new M.MxCADSelectionSet;h.allSelect(),h.forEach(f=>Qe(this,null,function*(){if(!c.includes(f.id)){let r=yield f.getMcDbEntity(),v=r.clone();v.visible=!1,e.drawEntity(v),r.erase()}}))}}else if(i==="C"){let l=new M.MxCADSelectionSet;l.allSelect(),l.forEach(c=>Qe(this,null,function*(){let h=yield c.getMcDbEntity(),f=h.clone();f.visible===!1&&(f.visible=!0,e.drawEntity(f),h.erase())}))}else return})}function qL(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;let t=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();e.setMessage(`
- 指定删除方框第一点:`);let i=yield e.go();if(!i)return;let l=M.MxCpp.getCurrentMxCAD(),c=new X.MxDbRect;c.pt1=i.toVector3(),e.setUserDraw((w,b)=>{c.pt2=w.toVector3(),c.setColor(t),b.drawCustomEntity(c)}),e.setMessage(`
- 指定删除方框第二点:`),e.setDynamicInputType(X.DynamicInputType.kXYCoordInput);let h=yield e.go();if(!h)return;c.pt2=h.toVector3();let f=new M.McDbPolyline;f.addVertexAt(i),f.addVertexAt(new M.McGePoint3d(i.x,h.y)),f.addVertexAt(h),f.addVertexAt(new M.McGePoint3d(h.x,i.y)),f.isClosed=!0;let r=l.drawEntity(f);const v=new M.MxCADSelectionSet;for(v.crossingSelect(i.x,i.y,h.x,h.y),v.getIds().forEach(w=>{if(w&&w.id!==r.id){let b=w.getMcDbEntity(),A=b.IntersectWith(f,M.McDb.Intersect.kOnBothOperands);if(A.length()===0)w.erase();else{let L=[];A.forEach(P=>L.push(P)),b.splitCurves(L).forEach(P=>{l.drawEntity(P)}),w.erase()}}});;){const w=new M.MxCADUiPrPoint;w.setMessage(`
- 选择需要精确删除的实体`);const b=yield w.go();if(!b)break;let A=M.MxCADUtility.findEntAtPoint(b.x,b.y,b.z,-1);l.addCurrentSelect(A)}M.MxCADUtility.getCurrentSelect().forEach(w=>{w.erase()}),l.mxdraw.clearMxCurrentSelect()})}function XL(){return Qe(this,null,function*(){const e=M.MxCpp.getCurrentMxCAD(),t=new M.MxCADUiPrEntity;t.setMessage(`
- 请选择角度复制对象`);const i=yield t.go();if(i===null)return;const l=yield i.getMcDbEntity(),c=new M.MxCADUiPrInt;c.setMessage(`
- 请输入角度复制数量`);const h=(yield c.go())||1,f=new M.MxCADUiPrPoint;f.setMessage(`
- 请输入角度复制的基点`);const r=yield f.go();if(!r)return;const v=new M.MxCADUiPrAngle;if(v.setMessage(`
- 请输入复制角度`),v.setBasePt(r),v.setUserDraw((b,A)=>{const L=b.sub(r).angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis);for(let P=1;P<h+1;P++){let R=l.clone();R.rotate(r,L*P),A.drawMcDbEntity(R)}}),!(yield v.go()))return;const w=v.value();for(let b=1;b<h+1;b++){let A=l.clone();A.rotate(r,w*b),e.drawEntity(A)}})}function ZL(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LWPOLYLINE");let t=yield M.MxCADUtility.userSelect("请选择顶点对象",e);if(t.length==0)return;let i=yield M.MxCADUtility.userSelect("请选择复制对象");if(i.length==0)return;const l=new M.MxCADUiPrPoint;l.setMessage("请确定复制基点");const c=yield l.go();if(!c)return;const h=M.MxCpp.getCurrentMxCAD();t.forEach(f=>{let r=f.getMcDbEntity();if(!r)return;let v=r.numVerts();for(let x=0;x<v;x++){const w=r.getPointAt(x).val;i.forEach(b=>{const L=b.getMcDbEntity().clone();L.move(c,w),h.drawEntity(L)})}})})}function YL(){return Qe(this,null,function*(){let e=new M.MxCADUiPrEntity;e.setMessage("请选择参考曲线");let t=yield e.go(),i=yield t.getMcDbEntity();if(i===null)return;const l=M.MxCpp.App.getCurrentMxCAD();let c=i.clone(),h=new M.MxCADResbuf;h.AddMcDbEntityTypes("CIRCLE,ARC,LINE,LWPOLYLINE,ELLIPSE");let f=yield M.MxCADUtility.userSelect("选择打断对象",h);if(f.length==0)return;let r=l.mxdraw.viewCoordLong2Cad(.5);f.forEach(v=>Qe(this,null,function*(){if(v.id!==t.id){let x=yield v.getMcDbEntity(),w=x.IntersectWith(c,M.McDb.Intersect.kOnBothOperands);if(w.length()!=0){let b=[];w.forEach(P=>{b.push(P)});let A=[];b.forEach(P=>{let R=x.getClosestPointTo(P,!1);if(!R.ret)return;let F=x.getFirstDeriv(R.val);if(!F.ret)return;F.val.normalize().mult(X.MxFun.viewCoordLong2Cad(10));let V=R.val.clone();V.addvec(F.val);let j=R.val.clone();j.subvec(F.val);const J=x.getPointAtDist(0).val,ne=x.getPointAtDist(x.getLength().val).val;if(J.distanceTo(R.val)<r||ne.distanceTo(R.val)<r){const H=x.getDistAtPoint(V);A.push(R.val),H.ret?A.push(V):A.push(j)}else A.push(V),A.push(j)});let L=x.splitCurves(A);if(L.empty()){x.highlight(!1);return}L.forEach((P,R)=>{R%2==0&&l.drawEntity(P)}),x.erase()}}}))})}function KL(){return Qe(this,null,function*(){let e=M.MxCpp.App.getCurrentMxCAD(),t=new M.MxCADResbuf;t.AddMcDbEntityTypes("CIRCLE,ARC,LINE,LWPOLYLINE,ELLIPSE");let i=new M.MxCADUiPrEntity;i.setFilter(t),i.setMessage("指定偏移对象");let l=yield i.go();if(!l)return;const c=new M.MxCADUiPrDist;if(c.setMessage("请输入偏移距离"),!(yield c.go()))return;const f=c.value();let r=yield l.getMcDbEntity();const v=r.getStartPoint().val,w=r.getFirstDeriv(v).val.rotateBy(M.McGeVector3d.kYAxis.angleTo1(M.McGeVector3d.kXAxis)),b=v.clone().addvec(w),A=v.clone().subvec(w);let L=r.offsetCurves(f,b);if(L.length()===0)return;L.forEach(R=>{e.drawEntity(R)});let P=r.offsetCurves(f,A);P.length()!==0&&P.forEach(R=>{e.drawEntity(R)})})}function JL(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("ARC,LINE,LWPOLYLINE");const t=new M.MxCADUiPrEntity;t.setFilter(e),t.setMessage("指定伸缩对象(选择直线、多段线、圆弧)");const i=yield t.go();if(!i)return;const l=M.MxCpp.App.getCurrentMxCAD(),c=i.getMcDbEntity();if(c instanceof M.McDbArc){const h=c.clone(),f=h.center,r=new M.MxCADUiPrPoint;r.setMessage("伸缩至"),c.visible=!1,r.setUserDraw((x,w)=>{h.endAngle=x.sub(f).angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis),w.drawMcDbEntity(h)});const v=yield r.go();if(c.visible=!0,!v)return;c.endAngle=v.sub(f).angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis),l.updateDisplay()}else if(c instanceof M.McDbLine){const h=c.clone(),f=new M.MxCADUiPrPoint;f.setMessage("伸缩至"),c.visible=!1;let r;f.setUserDraw((x,w)=>{r=h.getClosestPointTo(x,!0).val,h.endPoint=r,w.drawMcDbEntity(h)});const v=yield f.go();if(c.visible=!0,!v)return;c.endPoint=r,l.updateDisplay()}else if(c instanceof M.McDbPolyline){const h=c.clone(),f=new M.MxCADUiPrPoint;f.setMessage("伸缩至"),c.visible=!1;let r;const v=c.numVerts(),x=c.getBulgeAt(v-1),w=c.getWidthsAt(v-1);f.setUserDraw((A,L)=>{r=h.getClosestPointTo(A,!0).val,h.setPointAt(v-1,r),h.setBulgeAt(v-1,x),h.setWidthsAt(v-1,w.val1,w.val2),L.drawMcDbEntity(h)});const b=yield f.go();if(c.visible=!0,!b)return;c.setPointAt(v-1,r),c.setBulgeAt(v-1,x),c.setWidthsAt(v-1,w.val1,w.val2),l.updateDisplay()}})}function QL(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("CIRCLE");let t=yield M.MxCADUtility.userSelect("选择对象",e);if(t.length==0)return;const i=new M.MxCADUiPrDist;i.setMessage("请输入圆半径");const l=t[0].getMcDbEntity();if(i.setBasePt(l.center),i.setUserDraw((f,r)=>{const v=f.distanceTo(l.center);t.forEach(x=>{const b=x.getMcDbEntity().clone();b.radius=v,r.drawMcDbEntity(b)})}),!(yield i.go()))return;const h=i.value();t.forEach(f=>{const r=f.getMcDbEntity();r.radius=h})})}function eI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LWPOLYLINE,ARC,LINE,CIRCLE,ELLIPSE");let t=yield M.MxCADUtility.userSelect("选择要修改线型比例的对象",e);if(t.length==0)return;const i=new M.MxCADUiPrString;if(i.setMessage("请输入线型比例"),!(yield i.go()))return;const c=Number(i.value());c&&t.forEach(h=>Qe(this,null,function*(){let f=h.getMcDbEntity();f.linetypeScale=c}))})}function tI(){return Qe(this,null,function*(){const e=M.MxCpp.App.getCurrentMxCAD(),t=new M.MxCADUiPrDist;if(t.setMessage("请输入阵列间距"),!(yield t.go()))return;const l=t.value(),c=new M.MxCADResbuf;c.AddMcDbEntityTypes("ARC");const h=new M.MxCADUiPrEntity;h.setFilter(c),h.setMessage("请选择圆弧");const f=yield h.go();if(!f.id)return;const r=f.getMcDbEntity(),v=yield M.MxCADUtility.userSelect("选择排列对象");if(v.length==0)return;const x=new M.MxCADUiPrPoint;x.setMessage("指定排列基点");const w=yield x.go();w&&v.forEach(b=>Qe(this,null,function*(){let A=b.getMcDbEntity(),L=r.getLength().val/l;if(!(L<1))for(let P=0;P<L;P++){let R=A.clone(),F=r.getPointAtDist(P*l);if(!F.ret)return;let V=F.val.sub(w),j=new M.McGeMatrix3d;j.setToTranslation(V),R.transformBy(j);let H=r.getFirstDeriv(F.val).val.rotateBy(M.McGeVector3d.kYAxis.angleTo1(M.McGeVector3d.kXAxis)).negate().angleTo2(M.McGeVector3d.kYAxis,M.McGeVector3d.kNegateZAxis);R.rotate(F.val,H),e.drawEntity(R)}}))})}function nI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LWPOLYLINE");let t=new M.MxCADSelectionSet;if(!(yield t.userSelect("选择目标多段线:",e))||t.count()==0)return;const i=new M.MxCADUiPrDist;i.setMessage("请输入圆角半径<5>");let l=5;(yield i.go())&&(l=i.value());const h=M.MxCpp.getCurrentMxCAD();t.forEach(f=>{const r=f.getMcDbEntity(),v=new M.McDbPolyline;v.trueColor=r.trueColor,v.isClosed=r.isClosed,v.colorIndex=r.colorIndex,v.layerId=r.layerId;const x=r.numVerts(),w=[];for(let b=0;b<x;b++)w.push(r.getPointAt(b).val);r.isClosed===!0&&w.push(w[0],w[1]),w.forEach((b,A)=>{if(A+2>=w.length)return;const L=w[A+1],P=w[A+2],R=new M.McDbLine(L,b),F=new M.McDbLine(L,P),V=b.sub(L).angleTo2(P.sub(L),M.McGeVector3d.kNegateZAxis);let j=l*Math.sin(Math.PI/2-V/2)/Math.sin(V/2);j<0&&(j=-j);const J=R.getPointAtDist(j).val,ne=F.getPointAtDist(j).val;R.rotate(J,Math.PI/2),F.rotate(ne,Math.PI/2);const H=R.IntersectWith(F,M.McDb.Intersect.kExtendBoth);if(!H.length())return;const Q=H.at(0),ie=new M.McDbLine(Q,L).getPointAtDist(l).val;let le=M.MxCADUtility.calcBulge(J,ie,ne).val;if(A===0&&r.isClosed===!1){let me=r.getWidthsAt(A);v.addVertexAt(b,0,me.val1,me.val2)}let fe;r.isClosed===!0&&A+2===w.length-1?fe=r.getWidthsAt(A):fe=r.getWidthsAt(A+1),v.addVertexAt(J,le,fe.val1,fe.val2),v.addVertexAt(ne,0,fe.val1,fe.val2),A+2===w.length-1&&r.isClosed===!1&&v.addVertexAt(P,0,fe.val1,fe.val2)}),r.erase(),h.drawEntity(v)})})}function iI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LWPOLYLINE");const t=new M.MxCADUiPrEntity;t.setMessage("请选择线对象"),t.setFilter(e);const i=yield t.go();if(console.log(i),!i.id)return;const l=i.getMcDbEntity(),c=l.numVerts(),h=new M.McDbPolyline;for(let r=c-1;r>=0;r--){const v=l.getPointAt(r).val;if(r>0){const x=l.getWidthsAt(r-1),w=l.getBulgeAt(r-1);h.addVertexAt(v,-w,x.val2,x.val1)}else{const x=l.getWidthsAt(r),w=l.getBulgeAt(r);h.addVertexAt(v,-w,x.val2,x.val2)}}const f=M.MxCpp.getCurrentMxCAD();h.isClosed=l.isClosed,f.drawEntity(h),l.erase()})}function rI(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet;e.allSelect(new M.MxCADResbuf([M.DxfCode.kEntityType,"LINE"])),console.log("得到对象数目:"+e.count()),e.forEach(t=>{t.getMcDbEntity().highlight(!0)}),M.MxCpp.getCurrentMxCAD().updateDisplay()})}function oI(){return Qe(this,null,function*(){const e=new M.MxCADUiPrKeyWord;e.setMessage("选择等分模式"),e.setKeyWords("[定距等分(ME)/定数等分(DIV)/偏移等分(O)/复制等分(CO)]");let t=yield e.go();if(!t)return;const i=new M.MxCADResbuf;i.AddMcDbEntityTypes("LINE");const l=new M.MxCADUiPrEntity;l.setFilter(i),t==="O"?l.setMessage("请选择偏移等分对象"):t==="CO"?l.setMessage("请选择复制等分对象"):l.setMessage("请选择需要等分的线段");const c=yield l.go();if(!c.id)return;const h=c.getMcDbEntity(),f=h.getLength().val,r=M.MxCpp.getCurrentMxCAD();if(t==="ME"){const v=new M.MxCADUiPrDist;if(v.setMessage("请设置等分距离"),!(yield v.go()))return;const w=v.value(),b=f/w;for(let A=1;A<b;A++){const L=h.getPointAtDist(A*w).val,P=new Md;P.setCenter(L),r.drawEntity(P)}}else if(t==="DIV"){const v=new M.MxCADUiPrInt;if(v.setMessage("请设置等分的数量"),!(yield v.go()))return;const w=v.value(),b=f/w;for(let A=1;A<w;A++){const L=h.getPointAtDist(A*b).val,P=new Md;P.setCenter(L),r.drawEntity(P)}}else if(t==="O"){const v=new M.MxCADUiPrDist;if(v.setMessage("请设置偏移距离"),!(yield v.go()))return;const w=v.value();let b=1;for(;;){const A=new M.MxCADUiPrPoint;A.setMessage("请指定偏移点"),A.setUserDraw((P,R)=>{h.offsetCurves(w*b,P).forEach(F=>{R.drawMcDbEntity(F)})});const L=yield A.go();if(!L)return;h.offsetCurves(w*b,L).forEach(P=>{r.drawEntity(P),b++})}}else if(t==="CO"){const v=new M.MxCADUiPrPoint;v.setMessage("请指定复制基点");const x=yield v.go();if(!x)return;const w=new M.MxCADUiPrInt;if(w.setMessage("请指定复制等分数量"),!(yield w.go()))return;const A=w.value(),L=new M.MxCADUiPrPoint;L.setMessage("请指定复制等分端点"),L.setUserDraw((V,j)=>{const J=new M.McDbLine(x,V);j.drawMcDbEntity(J);const ne=J.getLength().val/A;for(let H=1;H<A+1;H++){const Q=h.clone();Q.move(x,J.getPointAtDist(ne*H).val),j.drawMcDbEntity(Q)}});const P=yield L.go();if(!P)return;const R=new M.McDbLine(x,P),F=R.getLength().val/A;for(let V=1;V<A+1;V++){const j=h.clone();j.move(x,R.getPointAtDist(F*V).val),r.drawEntity(j)}}})}function aI(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet;if(!(yield e.userSelect("请选择需要矩形缩放的实体:"))||e.count()==0)return;let t=M.MxCpp.getCurrentMxCAD(),l=t.getDatabase().getBlockTable().add(new M.McDbBlockTableRecord),c=l.getMcDbBlockTableRecord();if(c==null)return;e.forEach(j=>{const J=j.getMcDbEntity();if(!J)return;const ne=J.clone();c.appendAcDbEntity(ne)});let h=new M.McDbBlockReference;h.blockTableRecordId=l;const{ret:f,maxPt:r,minPt:v}=h.getBoundingBox();if(!f)return;const x=new M.McDbLine(v,r),w=x.getLength().val;c.origin=x.getPointAtDist(w/2).val;const b=new M.MxCADUiPrPoint;b.setMessage("请指定矩形的角点1");const A=yield b.go();if(!A)return;const L=new M.MxCADUiPrPoint;L.setMessage("请指定矩形角点2"),L.setUserDraw((j,J)=>{let ne=new M.McDbPolyline;ne.addVertexAt(A),ne.addVertexAt(new M.McGePoint3d(A.x,j.y)),ne.addVertexAt(j),ne.addVertexAt(new M.McGePoint3d(j.x,A.y)),ne.isClosed=!0,J.drawMcDbEntity(ne)});const P=yield L.go();if(!P)return;const R=Math.abs(A.x-P.x)/Math.abs(v.x-r.x),F=Math.abs(A.y-P.y)/Math.abs(v.y-r.y);h.scaleFactors=new M.McGePoint3d(R,F,0);const V=new M.McDbLine(A,P);h.position=V.getPointAtDist(V.getLength().val/2).val,t.drawEntity(h)})}class Em extends M.McDbCustomEntity{constructor(t){super(t),this.center=new M.McGePoint3d,this.radius=20,this.scale=50,this.position=new M.McGePoint3d}create(t){return new Em(t)}getTypeName(){return"McDbTestEnlarge"}set enlargeCenter(t){this.center=t}get enlargeCenter(){return this.center}set enlargeRadius(t){this.radius=t}get enlargeRadius(){return this.radius}set enlargeScale(t){this.scale=t}get enlargeScale(){return this.scale}dwgInFields(t){return this.center=t.readPoint("center").val,this.position=t.readPoint("position").val,this.radius=t.readDouble("radius").val,this.scale=t.readDouble("scale").val,!0}dwgOutFields(t){return t.writePoint("center",this.center),t.writePoint("position",this.position),t.writeDouble("radius",this.radius),t.writeDouble("scale",this.scale),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),t==0?(this.center.x+=i,this.center.y+=l,this.center.z+=c):t==1&&(this.position.x+=i,this.position.y+=l,this.position.z+=c)}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.center),t.append(this.position),t}worldDraw(t){const i=new M.McDbCircle;i.center=this.center,i.radius=this.radius,t.drawEntity(i);const{minPt:l,maxPt:c,ret:h}=i.getBoundingBox();if(!h)return;let f=new M.MxCADSelectionSet;f.crossingSelect(l.x,l.y,c.x,c.y);const r=M.MxCpp.getCurrentMxCAD();let v=r.getDatabase().getBlockTable(),x=new M.McDbBlockTableRecord,w=v.add(x),b=w.getMcDbBlockTableRecord();if(b==null)return;f.forEach(Q=>{let ae=Q.getMcDbEntity();if(!ae)return;let ie=ae.clone();b.appendAcDbEntity(ie)}),b.origin=new M.McGePoint3d(this.center.x,this.center.y,0);let A=new M.McDbBlockReference;A.blockTableRecordId=w,A.position=this.position;const L=r.drawEntity(A);A=L.getMcDbEntity();let P=i.getSamplePoints(this.radius*1e-5),R=new M.McGePoint3dArray;P.forEach((Q,ae,ie)=>{if(ie===1010){const le=new M.McGePoint3d(Q.x,Q.y,Q.z);R.append(le)}}),A.createSpatialFilter(),A.setScale(this.scale),A.getSpatialFilterId().getMcDbObject().setBoundary(R),t.drawEntity(A),L.erase();const j=this.position.sub(this.center).normalize(),J=this.center.clone().addvec(j.mult(this.radius)),ne=this.position.clone().subvec(j.mult(this.scale)),H=new M.McDbLine(J,ne);t.drawEntity(H)}setPosition(t){this.assertWrite(),this.position=t.clone()}getPosition(){return this.position}}function sI(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("请选择放大中心点");const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrDist;if(i.setMessage("请选择放大范围"),i.setBasePt(t),i.setUserDraw((L,P)=>{const R=t.distanceTo(L),F=new M.McDbCircle(t.x,t.y,t.z,R);P.drawMcDbEntity(F)}),!(yield i.go()))return;const c=i.value(),h=M.MxCpp.getCurrentMxCAD(),f=new M.McDbCircle(t.x,t.y,t.z,c),r=new M.MxCADUiPrDist;if(r.setMessage("请设置放大倍数"),r.setBasePt(t),r.setUserDraw((L,P)=>{const R=t.distanceTo(L),F=new M.McDbCircle(t.x,t.y,t.z,R);P.drawMcDbEntity(F),P.drawMcDbEntity(f)}),!(yield r.go()))return;const x=r.value(),w=new M.MxCADUiPrPoint;w.setMessage("请选择放大插入点"),w.setUserDraw((L,P)=>{const R=new M.McDbCircle(L.x,L.y,L.z,x);P.drawMcDbEntity(R),P.drawMcDbEntity(f)});const b=yield w.go();if(!b)return;const A=new Em;A.enlargeCenter=t,A.enlargeRadius=c,A.enlargeScale=x/c,A.setPosition(b),h.drawEntity(A)})}function lI(){return Qe(this,null,function*(){const e=new M.MxCADUiPrEntity;e.setMessage("请选择一条需要打断的曲线");const t=new M.MxCADResbuf([M.DxfCode.kEntityType,"LWPOLYLINE,LINE,ARC,CIRCLE,ELLIPSE"]);e.setFilter(t);const i=yield e.go();if(!i.id)return;const l=i.getMcDbEntity();l.highlight(!0);const c=new M.MxCADUiPrPoint;c.setMessage("请在曲线上选取打断点");const h=[],f=X.MxFun.screenCoordLong2Doc(5);for(;;){c.setUserDraw((x,w)=>{h.length>0&&h.forEach(b=>{const A=new M.McDbCircle;A.center=b,A.radius=f,w.drawMcDbEntity(A)}),w.drawCircle(new THREE.Vector3(x.x,x.y),f)});const v=yield c.go();if(!v)break;h.push(v)}const r=M.MxCpp.getCurrentMxCAD();h.length!==0&&(l.splitCurves(h).forEach(v=>{r.drawEntity(v)}),l.highlight(!1),i.erase(),r.updateDisplay())})}function cI(){new Em().rxInit(),X.MxFun.addCommand("Mx_Multicopy",UL),X.MxFun.addCommand("Mx_ArcToCircle",VL),X.MxFun.addCommand("Mx_CopyRotation",GL),X.MxFun.addCommand("Mx_CricleTotoll",WL),X.MxFun.addCommand("Mx_ChangeColor",jL),X.MxFun.addCommand("Mx_ArcToAngle",HL),X.MxFun.addCommand("Mx_TemHiding",$L),X.MxFun.addCommand("Mx_BoxDel",qL),X.MxFun.addCommand("Mx_AngleCopy",XL),X.MxFun.addCommand("Mx_VertexRep",ZL),X.MxFun.addCommand("Mx_IntersectBreak",YL),X.MxFun.addCommand("Mx_DoubleOff",KL),X.MxFun.addCommand("Mx_Telescoping",JL),X.MxFun.addCommand("Mx_EitCircle",QL),X.MxFun.addCommand("Mx_LayerTypeScale",eI),X.MxFun.addCommand("Mx_ArcOrder",tI),X.MxFun.addCommand("Mx_PlRoundCorners",nI),X.MxFun.addCommand("Mx_PlReverse",iI),X.MxFun.addCommand("Mx_TestGetAllLineByLayer",rI),X.MxFun.addCommand("Mx_Bisection",oI),X.MxFun.addCommand("Mx_RectangularScaling",aI),X.MxFun.addCommand("Mx_Enlarge",sI),X.MxFun.addCommand("Mx_Interrupt",lI)}function uI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LINE");const t=new M.MxCADUiPrEntity;t.setMessage("请选择目标对齐线对象(选择直线)"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity(),c=new M.MxCADUiPrEntity;let h=new M.MxCADResbuf;h.AddMcDbEntityTypes("TEXT"),c.setMessage("请选择目标文字对象"),c.setFilter(h);const f=yield c.go();if(!f.id)return;const r=f.getMcDbEntity();let x=l.getFirstDeriv(l.getStartPoint().val).val.angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis),w=r.rotation;r.rotate(r.position,x-w),M.MxCpp.App.getCurrentMxCAD().updateDisplay()})}function hI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT, MTEXT");const t=yield M.MxCADUtility.userSelect("选择文字对象",e);if(t.length==0)return;const i=new M.MxCADUiPrString;i.setMessage("请设置字高");const l=yield i.go();!l||!Number(l)||(t.forEach(c=>{const h=c.getMcDbEntity();h.height=Number(l)}),M.MxCpp.getCurrentMxCAD().updateDisplay())})}function dI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT, MTEXT");const t=yield M.MxCADUtility.userSelect("选择文字对象",e);if(t.length==0)return;const i=new M.MxCADUiPrString;i.setMessage("请设置字宽");const l=yield i.go();!l||!Number(l)||(t.forEach(c=>{const h=c.getMcDbEntity();h.widthFactor=Number(l)}),M.MxCpp.getCurrentMxCAD().updateDisplay())})}function pI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择源文字"),t.setFilter(e);const i=yield t.go();if(!(i!=null&&i.id))return;const l=i.getMcDbEntity();let c=yield M.MxCADUtility.userSelect("请选择目标文字",e);if(c.length==0)return;const h=M.MxCpp.App.getCurrentMxCAD();c.forEach(f=>{let v=f.getMcDbEntity().clone();v.textString=l.textString,h.drawEntity(v),f.erase()})})}function fI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");const t=new M.MxCADUiPrEntity;t.setFilter(e),t.setMessage("请选择第一个文字");const i=yield t.go();if(!(i!=null&&i.id))return;const l=i.getMcDbEntity(),c=M.MxCpp.App.getCurrentMxCAD(),h=new M.MxCADUiPrEntity;h.setFilter(e),h.setMessage("请选择第二个文字");const f=yield h.go();if(!(f!=null&&f.id))return;const r=f.getMcDbEntity();let v=l.textString,x=r.textString,w=l.clone(),b=r.clone();w.textString=x,b.textString=v,c.drawEntity(w),c.drawEntity(b),i.erase(),f.erase()})}function mI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=yield M.MxCADUtility.userSelect("请选择需要对齐的文字",e);if(t.length==0)return;const i=new M.MxCADUiPrKeyWord;i.setMessage("请选择对齐方式"),i.setKeyWords("[左(L)/中(M)/右(R)]");const l=yield i.go();if(!l)return;const c=new M.MxCADUiPrPoint;c.setMessage("请选择对齐基点");const h=yield c.go();if(!h)return;const f=M.MxCpp.getCurrentMxCAD();l==="L"?t.forEach(r=>{const v=r.getMcDbEntity(),x=v.clone(),w=v.alignmentPoint,b=v.position;x.horizontalMode=M.McDb.TextHorzMode.kTextLeft,x.alignmentPoint=new M.McGePoint3d(h.x,w.y),x.position=new M.McGePoint3d(h.x,b.y),f.drawEntity(x),r.erase()}):l==="R"?t.forEach(r=>{const v=r.getMcDbEntity(),x=v.clone(),w=v.alignmentPoint,b=v.position;x.horizontalMode=M.McDb.TextHorzMode.kTextRight,x.alignmentPoint=new M.McGePoint3d(h.x,w.y),x.position=new M.McGePoint3d(h.x,b.y),f.drawEntity(x),r.erase()}):l==="M"&&t.forEach(r=>{const v=r.getMcDbEntity(),x=v.clone(),w=v.alignmentPoint,b=v.position;x.horizontalMode=M.McDb.TextHorzMode.kTextCenter,x.alignmentPoint=new M.McGePoint3d(h.x,w.y),x.position=new M.McGePoint3d(h.x,b.y),f.drawEntity(x),r.erase()})})}function gI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=yield M.MxCADUtility.userSelect("请选择需要对齐的文字",e);if(t.length==0)return;const i=new M.MxCADUiPrPoint;i.setMessage("请选择对齐基点");const l=yield i.go();l&&(t.forEach(c=>{const h=c.getMcDbEntity(),f=h.position;h.alignmentPoint=h.position=new M.McGePoint3d(f.x,l.y)}),M.MxCpp.getCurrentMxCAD().updateDisplay())})}function yI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=yield M.MxCADUtility.userSelect("请选择需要反转的文字",e);if(t.length==0)return;const i=M.MxCpp.App.getCurrentMxCAD();t.forEach(l=>{const c=l.getMcDbEntity(),h=c.clone();let f=c.getBoundingBox();if(!f.ret)return;const r=f.maxPt,v=f.minPt,x=new M.McDbLine(v,r),w=x.getPointAtDist(x.getLength().val/2).val,b=M.McGeVector3d.kXAxis.angleTo1(new M.McGeVector3d(-1,0,0))+c.rotation;h.rotate(w,b),l.erase(),i.drawEntity(h)})})}function _I(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT, MTEXT");let t=yield M.MxCADUtility.userSelect("请选择需要去空格的文字",e);t.length!=0&&t.forEach(i=>{const l=i.getMcDbEntity();let c;l instanceof M.McDbText?(c=l.clone(),c.textString=l.textString.replace(/\s+/g,"")):l instanceof M.McDbMText&&(c=l.clone(),c.contents=l.contents.replace(/\s+/g,"")),i.erase(),M.MxCpp.App.getCurrentMxCAD().drawEntity(c)})})}function vI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT, MTEXT");let t=yield M.MxCADUtility.userSelect("请选择文字对象",e);t.length!=0&&t.forEach(i=>{let c=i.getMcDbEntity().getBoundingBox();if(!c.ret)return;const h=c.maxPt,f=c.minPt,r=new M.McGePoint3d(f.x,h.y),v=new M.McGePoint3d(h.x,f.y),x=f.clone().sub(h).normalize().mult(2),w=r.clone().sub(v).normalize().mult(2),b=new M.McDbPolyline;b.addVertexAt(f.addvec(x)),b.addVertexAt(r.addvec(w)),b.addVertexAt(h.subvec(x)),b.addVertexAt(v.subvec(w)),b.isClosed=!0,M.MxCpp.getCurrentMxCAD().drawEntity(b)})})}function xI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=yield M.MxCADUtility.userSelect("请选择文字对象",e);if(t.length==0)return;const i=new M.MxCADUiPrInt;i.setMessage(`请输入下划线宽度
- `);const l=(yield i.go())||0,c=new M.MxCADUiPrDist;c.setMessage(`请设置下划线距离
- `);const h=yield c.go();let f=0;h&&(f=c.value());const r=new M.MxCADUiPrDist;r.setMessage(`请设置下划线延长距离
- `);const v=yield r.go();let x=0;v&&(x=r.value()),t.forEach(w=>{let A=w.getMcDbEntity().getBoundingBox();if(!A.ret)return;const L=A.maxPt,P=A.minPt,R=new M.McDbLine(P.x,P.y,0,L.x,P.y,0),F=new M.McDbLine(L.x,P.y,0,P.x,P.y,0),V=F.getLength().val,j=R.getPointAtDist(V+x).val,J=F.getPointAtDist(V+x).val,ne=new M.McDbPolyline;ne.addVertexAt(j,0,l,l),ne.addVertexAt(J,0,l,l);const H=ne.getClosestPointTo(L,!0).val,Q=H.clone().sub(L);Q.normalize().mult(f);const ae=H.clone().addvec(Q),ie=new M.McGeMatrix3d;ie.setToTranslation(ae.sub(H)),ne.transformBy(ie),M.MxCpp.getCurrentMxCAD().drawEntity(ne)})})}function bI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=yield M.MxCADUtility.userSelect("请选择文字对象",e);t.length!=0&&t.forEach(i=>{let c=i.getMcDbEntity().getBoundingBox();if(!c.ret)return;const h=c.maxPt,f=c.minPt,r=new M.McDbPolyline;r.addVertexAt(f,0,2,2),r.addVertexAt(new M.McGePoint3d(h.x,f.y),0,2,2);const v=new M.McDbPolyline;v.addVertexAt(f),v.addVertexAt(new M.McGePoint3d(h.x,f.y));const x=r.getClosestPointTo(h,!0).val,w=x.clone().sub(h),b=x.clone().sub(h);w.normalize().mult(2),b.normalize().mult(4);const A=x.clone().addvec(w),L=x.clone().addvec(b),P=new M.McGeMatrix3d,R=new M.McGeMatrix3d;P.setToTranslation(A.sub(x)),r.transformBy(P),R.setToTranslation(L.sub(x)),v.transformBy(R),M.MxCpp.getCurrentMxCAD().drawEntity(r),M.MxCpp.getCurrentMxCAD().drawEntity(v)})})}function wI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=yield M.MxCADUtility.userSelect("请选择文字对象",e);if(t.length==0)return;const i=new M.MxCADUiPrKeyWord;i.setMessage(`请选择操作选项
- `),i.setKeyWords("[大写(C)/小写(S)/句首大写(I)]");const l=yield i.go();if(!l)return;const c=M.MxCpp.getCurrentMxCAD();l==="C"?t.forEach(h=>{const f=h.getMcDbEntity(),r=f.textString,v=f.clone();v.textString=r.toUpperCase(),console.log(v.textString),f.erase(),c.drawEntity(v)}):l==="S"?t.forEach(h=>{const f=h.getMcDbEntity(),r=f.textString,v=f.clone();v.textString=r.toLowerCase(),console.log(v.textString),f.erase(),c.drawEntity(v)}):l==="I"&&t.forEach(h=>{const f=h.getMcDbEntity(),r=f.textString,v=f.clone();v.textString=r.charAt(0).toUpperCase()+r.slice(1),f.erase(),c.drawEntity(v)})})}function MI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=yield M.MxCADUtility.userSelect("请选择数字对象",e);if(t.length==0)return;let i=[];if(t.forEach(v=>{const x=v.getMcDbEntity(),w=Number(x.textString);isNaN(w)||i.push(w)}),i.length!==t.length)return;let l=i.reduce((v,x)=>v+x,0);const c=new M.MxCADUiPrPoint,h=new M.McDbText;h.textString=l.toString(),h.height=10,c.setMessage(`请选择文字插入点
- `),c.setUserDraw((v,x)=>{h.position=v,h.alignmentPoint=v,x.drawMcDbEntity(h)});const f=yield c.go();if(!f)return;const r=M.MxCpp.getCurrentMxCAD();h.position=f,h.alignmentPoint=f,r.drawEntity(h)})}function TI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=new M.MxCADSelectionSet;if(!(yield t.userSelect("选择要查找的范围:",e))||t.count()==0)return;const i=new M.MxCADUiPrKeyWord;i.setMessage(`请选择查找模式
- `),i.setKeyWords("[等于(A)/包含(B)/前缀为(C)/后缀为(D)]");const l=yield i.go();if(!l)return;const c=new M.MxCADUiPrString;c.setMessage(`请输入关键字
- `);const h=yield c.go();if(!h)return;const f=M.MxCpp.getCurrentMxCAD();let r=[];t.forEach(v=>{const w=v.getMcDbEntity().textString;l==="A"?w===h&&r.push(v):l==="B"?w.includes(h)&&r.push(v):l==="C"?w.startsWith(h)&&r.push(v):l==="D"&&w.endsWith(h)&&r.push(v)}),r.length>0&&r.forEach(v=>{f.addCurrentSelect(v)})})}function EI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=new M.MxCADSelectionSet;if(!(yield t.userSelect("选择要操作的范围:",e))||t.count()==0)return;const i=new M.MxCADUiPrKeyWord;i.setMessage("选择操作方式"),i.setKeyWords("[添加(A)/删除(D)]");let l=yield i.go();if(!l)return;const c=new M.MxCADUiPrKeyWord;c.setMessage("选择操作位置"),c.setKeyWords("[前缀(P)/后缀(S)]");let h=yield c.go();if(!h)return;const f=new M.MxCADUiPrString;f.setMessage("请输入内容");const r=yield f.go();r&&t.forEach(v=>{const x=v.getMcDbEntity(),w=x.textString;l==="A"?h==="P"?x.textString=r+w:h==="S"&&(x.textString=w+r):l==="D"&&(h==="P"?w.startsWith(r)&&(x.textString=w.slice(r.length)):h==="S"&&w.endsWith(r)&&(x.textString=w.slice(0,-r.length)))})})}function CI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");const t=M.MxCpp.getCurrentMxCAD();for(;;){const h=new M.MxCADUiPrPoint;h.setMessage(`请选择文本
- `);const f=yield h.go();if(!f)break;let r=M.MxCADUtility.findEntAtPoint(f.x,f.y,f.z,-1,e);t.addCurrentSelect(r)}const i=M.MxCADUtility.getCurrentSelect();if(!i.length)return;let l="";i.forEach((h,f)=>{const r=h.getMcDbEntity();l+=r.textString,f!==0&&h.erase()});const c=i.at(0).getMcDbEntity();c.textString=l,t.mxdraw.clearMxCurrentSelect()})}function AI(){return Qe(this,null,function*(){new M.MxCADResbuf().AddMcDbEntityTypes("TEXT");const t=new M.MxCADUiPrEntity;t.setMessage(`请选择文本
- `);const i=yield t.go();if(!i)return;const l=i.getMcDbEntity(),c=l.textString.split("").join("\\P"),h=new M.McDbMText;h.contents=c,h.textHeight=l.height,h.location=l.position,h.trueColor=l.trueColor,h.colorIndex=l.colorIndex,h.layerId=l.layerId;const f=M.MxCpp.getCurrentMxCAD();i.erase(),f.drawEntity(h)})}function DI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");const t=new M.MxCADUiPrEntity;t.setFilter(e),t.setMessage(`请选择文本
- `);const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity();l.highlight(!0);const c=new M.MxCADResbuf;c.AddMcDbEntityTypes("ARC");const h=new M.MxCADUiPrEntity;h.setFilter(c),h.setMessage(`请选择圆弧
- `);const f=yield h.go();if(!f.id)return;const r=f.getMcDbEntity();r.highlight(!0);const v=l.textString.split("");v.reverse();const x=r.getLength().val/(v.length-1),w=M.MxCpp.getCurrentMxCAD();for(let b=0;b<v.length;b++){const A=r.getPointAtDist(x*b).val,L=new M.McDbText;L.textString=v[b],L.position=L.alignmentPoint=A,L.horizontalMode=M.McDb.TextHorzMode.kTextMid,L.trueColor=l.trueColor,L.colorIndex=l.colorIndex,L.height=l.height,L.widthFactor=l.widthFactor,L.rotation=l.rotation,w.drawEntity(L)}l.highlight(!1),r.highlight(!1)})}function PI(){return Qe(this,null,function*(){const i=M.MxCpp.getCurrentMxCAD().getDatabase().getTextStyleTable().getAllRecordId();let l="",c=[];i.forEach((v,x)=>{const w=v.getMcDbTextStyleTableRecord();l+=`${w.name}(${x})/`,c.push(v)});const h=new M.MxCADUiPrKeyWord;h.setMessage("请选择文字样式:"),h.setKeyWords(`[${l}]`);const f=yield h.go(),r=new M.MxCADSelectionSet;r.allSelect(new M.MxCADResbuf([M.DxfCode.kEntityType,"TEXT, MTEXT"])),r.forEach(v=>{let x=v.getMcDbEntity();x.textStyleId=c[Number(f)]}),M.MxCpp.getCurrentMxCAD().updateDisplay()})}function SI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf([M.DxfCode.kEntityType,"MTEXT,TEXT"]),t=new M.MxCADSelectionSet;if(!(yield t.userSelect("请设置文字提取范围",e))||t.count()==0)return;let i="";t.forEach(h=>{const f=h.getMcDbEntity(),r=f.objectName;if(r==="McDbText"){const v=f.clone();i+=`${v.textString}
- `}else if(r==="McDbMText"){const v=f.clone();i+=v.contents.replace("\\P",`
- `)}});const{isDialogVisible:l,excelText:c}=$p();l.value=!0,c.value=i})}function LI(){X.MxFun.addCommand("Mx_AlignByLine",uI),X.MxFun.addCommand("Mx_TextHeight",hI),X.MxFun.addCommand("Mx_TextWidth",dI),X.MxFun.addCommand("Mx_BrushCon",pI),X.MxFun.addCommand("Mx_ReplaceCon",fI),X.MxFun.addCommand("Mx_AlignLeft",mI),X.MxFun.addCommand("Mx_AlignUp",gI),X.MxFun.addCommand("Mx_TextReversal",yI),X.MxFun.addCommand("Mx_TextTrim",_I),X.MxFun.addCommand("Mx_TextTraming",vI),X.MxFun.addCommand("Mx_Underline",xI),X.MxFun.addCommand("Mx_TitleLine",bI),X.MxFun.addCommand("Mx_Case",wI),X.MxFun.addCommand("Mx_NumSum",MI),X.MxFun.addCommand("Mx_SSWords",TI),X.MxFun.addCommand("Mx_Prefix",EI),X.MxFun.addCommand("Mx_ConnectText",CI),X.MxFun.addCommand("Mx_VerticalText",AI),X.MxFun.addCommand("Mx_AlignByArc",DI),X.MxFun.addCommand("Mx_EditTextStyle",PI),X.MxFun.addCommand("Mx_ExtractText",SI)}function II(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择目标块对象"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const l=new M.MxCADUiPrString;l.setMessage("请输入新块名");const c=yield l.go();if(!c)return;const h=i.getMcDbEntity().blockTableRecordId.getMcDbBlockTableRecord();console.log("原块名",h.name),h.name=c,console.log("新块名",h.name)})}function RI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("选择需要修改基点的块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity(),c=new M.MxCADUiPrPoint,h=M.MxCpp.getCurrentMxCAD();c.setMessage("设置基点");const f=yield c.go();if(!f)return;let r=l.blockTableRecordId.getMcDbBlockTableRecord(),v=r.origin.clone(),x=l.blockTransform;v.transformBy(x);const w=f.sub(v);x.invert(),f.transformBy(x),r.origin=f,l.position=l.position.addvec(w),h.updateDisplay()})}function rb(e){e.getAllEntityId().forEach(t=>{let i=t.getMcDbEntity();i.colorIndex=M.ColorIndexType.kByblock,i instanceof M.McDbBlockReference&&rb(i.blockTableRecordId.getMcDbBlockTableRecord())})}function kI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("选择需要修改颜色的块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity();let c=l.blockTableRecordId.getMcDbBlockTableRecord();rb(c);const h=new M.MxCADUiPrInt;h.setMessage("输入颜色索引(0~256)");let f=(yield h.go())||0,r=new M.McCmColor;r.setColorIndex(f),l.trueColor=r,M.MxCpp.getCurrentMxCAD().updateDisplay()})}function zI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择源块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity();let c=new M.MxCADSelectionSet;(yield c.userSelect("选择要刷的目标块:",e))&&c.count()!=0&&c.forEach(h=>{const f=h.getMcDbEntity(),r=l.clone();r.position=f.position,h.erase(),M.MxCpp.getCurrentMxCAD().drawEntity(r)})})}function FI(){return Qe(this,null,function*(){const e=new M.MxCADUiPrKeyWord;e.setMessage("选择连接方式"),e.setKeyWords("[手动逐个连线(H)/自动批量连线(A)]");const t=yield e.go();if(!t)return;const i=M.MxCpp.getCurrentMxCAD();let l=new M.MxCADResbuf;if(l.AddMcDbEntityTypes("INSERT"),t==="A"){let c=new M.MxCADSelectionSet;if(!(yield c.userSelect("选择要刷的目标块:",l))||c.count()==0)return;const h=new M.McDbPolyline;c.forEach(f=>{const r=f.getMcDbEntity();h.addVertexAt(r.position)}),i.drawEntity(h)}else if(t==="H"){const c=new M.McDbPolyline;for(;;){const h=new M.MxCADUiPrEntity;h.setMessage("请选择连线的块"),h.setFilter(l),h.setUserDraw((v,x)=>{const w=c.clone();w.addVertexAt(v),x.drawMcDbEntity(w)});const f=yield h.go();if(!f.id)break;const r=f.getMcDbEntity();c.addVertexAt(r.position)}i.drawEntity(c)}})}function BI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择连线的块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;let c=i.getMcDbEntity().getBoundingBox();const h=new M.McDbPolyline;h.addVertexAt(c.minPt),h.addVertexAt(c.maxPt);const f=h.getPointAtDist(h.getLength().val/2).val,r=new M.MxCADUiPrDist;r.setMessage("设置中心线长度"),r.setBasePt(f),r.setUserDraw((L,P)=>{const R=L.distanceTo(f);let F=new M.McDbLine(f.x+R,f.y,f.z,f.x-R,f.y,f.z),V=F.clone();V.rotate(f,Math.PI/2),P.drawMcDbEntity(V),P.drawMcDbEntity(F)});const v=yield r.go();let x=10;v&&(x=r.value());const w=M.MxCpp.App.getCurrentMxCAD();let b=new M.McDbLine(f.x+x,f.y,f.z,f.x-x,f.y,f.z);b.trueColor=new M.McCmColor(255,0,0);let A=b.clone();A.rotate(f,Math.PI/2),w.drawEntity(A),w.drawEntity(b)})}function OI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");let t=new M.MxCADSelectionSet;if(!(yield t.userSelect("选择要旋转的目标块:",e))||t.count()==0)return;const i=t.item(0).getMcDbEntity(),l=new M.MxCADUiPrDist;l.setMessage("设置旋转角度"),l.setBasePt(i.position);let c=0;l.setUserDraw((r,v)=>{c=r.sub(i.position).angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis),t.forEach(x=>{const b=x.getMcDbEntity().clone();b.rotate(b.position,c),v.drawMcDbEntity(b)})});const h=yield l.go();if(!h)return;l.getDetailedResult()===X.DetailedResult.kCoordIn&&(c=h*Math.PI/180),t.forEach(r=>{const v=r.getMcDbEntity();v.rotate(v.position,c)}),M.MxCpp.getCurrentMxCAD().updateDisplay()})}function NI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");let t=new M.MxCADSelectionSet;if(!(yield t.userSelect("选择要旋转的目标块:",e))||t.count()==0)return;const i=new M.MxCADUiPrDist;i.setMessage("请设置缩放比例");let l=t.item(0).getMcDbEntity();if(i.setBasePt(l.position),i.setUserDraw((r,v)=>{const x=r.distanceTo(l.position);t.forEach(w=>{const A=w.getMcDbEntity().clone();let L=new M.McGeMatrix3d;L.setToScaling(x,A.position),A.transformBy(L),v.drawMcDbEntity(A)})}),!(yield i.go()))return;const h=i.value()||1;t.forEach(r=>{const v=r.getMcDbEntity();let x=new M.McGeMatrix3d;x.setToScaling(h,v.position),v.transformBy(x)}),M.MxCpp.getCurrentMxCAD().updateDisplay()})}function UI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择源块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const c=i.getMcDbEntity().rotation;let h=new M.MxCADSelectionSet;if(!(yield h.userSelect("选择要刷的目标块:",e))||h.count()==0)return;h.forEach(r=>{const v=r.getMcDbEntity();v.rotation=c}),M.MxCpp.getCurrentMxCAD().updateDisplay()})}function VI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择源块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const c=i.getMcDbEntity().blockName;let h=new M.MxCADSelectionSet;(yield h.userSelect("请设置选择范围:",e))&&h.count()!=0&&h.forEach(f=>{f.getMcDbEntity().blockName==c&&M.MxCpp.getCurrentMxCAD().addCurrentSelect(f)})})}function GI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择目标块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const c=i.getMcDbEntity().blockName;let h=new M.MxCADSelectionSet;h.allSelect(e),h.count()!=0&&h.forEach(f=>{f.getMcDbEntity().blockName==c&&M.MxCpp.getCurrentMxCAD().addCurrentSelect(f)})})}function WI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择目标块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const c=i.getMcDbEntity().blockName,h=new M.MxCADSelectionSet;if(!(yield h.userSelect("请设置统计范围",e))||h.count()==0)return;let f=0;h.forEach(r=>{r.getMcDbEntity().blockName==c&&(f+=1)}),console.log(`找到块${c}:共${f}个`)})}function jI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADSelectionSet;if(!(yield t.userSelect("请设置统计范围",e))||t.count()==0)return;let i=[];t.forEach(v=>{const w=v.getMcDbEntity().blockName;i.push(w)});let l=[];Array.from(new Set(i)).forEach(v=>{const x=i.filter(w=>w===v).length;l.push({blkName:v,num:x})});let c=new X1;c.data.addColumn("名称",100),c.data.addColumn("数量",30),l.forEach(v=>{c.data.addRow([v.blkName,v.num])});let h=new M.MxCADUiPrPoint;h.setMessage(`
- 指定表格插入点:`);let f=yield h.go();if(!f)return;let r=X.MxFun.screenCoordLong2Doc(100)/200;c.draw(f,r)})}function HI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择目标块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity(),c=M.MxCpp.getCurrentMxCAD(),h=c.addLayer("测试图层");l.layerId=h,console.log(l.layer),c.updateDisplay()})}function $I(){X.MxFun.addCommand("Mx_ChangeBN",II),X.MxFun.addCommand("Mx_BushBlk",zI),X.MxFun.addCommand("Mx_ConBlk",FI),X.MxFun.addCommand("Mx_BlkCenterLine",BI),X.MxFun.addCommand("Mx_BlkPt",RI),X.MxFun.addCommand("Mx_BlkColor",kI),X.MxFun.addCommand("Mx_BlkRotate",OI),X.MxFun.addCommand("Mx_BlkScale",NI),X.MxFun.addCommand("Mx_BlkAngle",UI),X.MxFun.addCommand("Mx_BlkSelect",VI),X.MxFun.addCommand("Mx_BlkAllSelect",GI),X.MxFun.addCommand("Mx_SSBlk",WI),X.MxFun.addCommand("Mx_SMBlk",jI),X.MxFun.addCommand("Mx_BlkLayer",HI)}function qI(){return Qe(this,null,function*(){const e=M.MxCpp.App.getCurrentMxCAD(),t=new M.McDbText;t.height=10;let i=new M.McGePoint3d,l=new M.MxCADResbuf;l.AddMcDbEntityTypes("CIRCLE,ARC,LINE,LWPOLYLINE,ELLIPSE");let c=yield M.MxCADUtility.userSelect("选择目标曲线",l);if(c.length==0)return;let h=0;c.forEach(r=>Qe(this,null,function*(){let v=r.getMcDbEntity();h+=v.getLength().val})),t.textString=h.toFixed(2).toString();const f=new M.MxCADUiPrPoint;f.setMessage("指定长度标注点"),f.setUserDraw((r,v)=>{t.position=r,t.alignmentPoint=r,v.drawMcDbEntity(t)}),i=yield f.go(),i&&(t.alignmentPoint=i,t.position=i,e.drawEntity(t))})}function XI(){return Qe(this,null,function*(){const e=M.MxCpp.App.getCurrentMxCAD(),t=new M.McDbText;t.height=10;let i=new M.McGePoint3d,l=new M.MxCADResbuf;l.AddMcDbEntityTypes("CIRCLE,LWPOLYLINE,ELLIPSE");let c=yield M.MxCADUtility.userSelect("选择目标对象",l);if(c.length==0)return;let h=0;c.forEach(r=>Qe(this,null,function*(){let v=r.getMcDbEntity();h+=v.getArea().val})),t.textString=h.toFixed(2).toString();const f=new M.MxCADUiPrPoint;f.setMessage("指定长度标注点"),f.setUserDraw((r,v)=>{t.position=r,t.alignmentPoint=r,v.drawMcDbEntity(t)}),i=yield f.go(),i&&(t.alignmentPoint=i,t.position=i,e.drawEntity(t))})}function ZI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LINE");const t=new M.MxCADUiPrEntity;t.setFilter(e),t.setMessage("请选择目标斜率对象");const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity(),c=new M.MxCADUiPrDist;if(c.setMessage("请设置标注文字高度"),!(yield c.go()))return;const f=c.value(),r=new M.MxCADUiPrPoint;r.setMessage("指定斜率标注点");let v=new M.McDbBlockReference;const x=M.MxCpp.getCurrentMxCAD();r.setUserDraw((b,A)=>{const L=l.getClosestPointTo(b,!0).val,P=new M.McGePoint3d(L.x,L.y+f*4),R=new M.McDbLine(L,P),F=R.clone();F.rotate(P,Math.PI*1/2);const V=l.IntersectWith(F,M.McDb.Intersect.kExtendBoth).at(0),j=l.getClosestPointTo(L,!1).val,J=new M.McDbPolyline;J.isClosed=!0,J.addVertexAt(j),J.addVertexAt(L),J.addVertexAt(P),J.addVertexAt(V);const ne=new M.McDbText;ne.height=f,ne.position=R.getPointAtDist(R.getLength().val/2).val,ne.alignmentPoint=ne.position,ne.rotation=-Math.PI/2,ne.horizontalMode=M.McDb.TextHorzMode.kTextMid,ne.textString="1000";const H=new M.McDbText,Q=new M.McDbLine(V,P);H.height=f,H.position=Q.getPointAtDist(V.distanceTo(P)/2).val,H.alignmentPoint=H.position,H.horizontalMode=M.McDb.TextHorzMode.kTextMid,H.textString=(1e3*V.distanceTo(P)/R.getLength().val).toFixed(0).toString();let ie=x.getDatabase().getBlockTable().add(new M.McDbBlockTableRecord),le=ie.getMcDbBlockTableRecord();le!=null&&(le.appendAcDbEntity(J),le.appendAcDbEntity(ne),le.appendAcDbEntity(H),le.name="斜率test",le.origin=L,v.blockTableRecordId=ie,v.position=L,A.drawMcDbEntity(v))}),(yield r.go())&&x.drawEntity(v)})}class Cm extends M.McDbCustomEntity{constructor(t){super(t),this.point=new M.McGePoint3d,this.position=new M.McGePoint3d,this.height=30}create(t){return new Cm(t)}getTypeName(){return"McDbTestCoordinateLabeling"}set coordinatePoint(t){this.point=t.clone()}get coordinatePoint(){return this.point}set coordinateHeight(t){this.height=t}get coordinateHeight(){return this.height}dwgInFields(t){return this.point=t.readPoint("point").val,this.position=t.readPoint("position").val,this.height=t.readDouble("height").val,!0}dwgOutFields(t){return t.writePoint("point",this.point),t.writePoint("position",this.position),t.writeDouble("height",this.height),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),t===0?(this.point.x+=i,this.point.y+=l,this.point.z+=c):(this.position.x+=i,this.position.y+=l,this.position.z+=c)}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.point),t.append(this.position),t}worldDraw(t){const i=new M.McDbMText;i.textHeight=X.MxFun.screenCoordLong2Doc(this.height),i.attachment=M.McDb.AttachmentPoint.kMiddleLeft,i.contents=`X=${this.point.x.toFixed(3)}\\PY=${this.point.y.toFixed(3)}`,i.location=this.position,t.drawEntity(i);const c=M.MxCpp.getCurrentMxCAD().drawEntity(i),{maxPt:h,minPt:f}=c.getMcDbEntity().getBoundingBox();c.erase();const r=Math.abs(h.x-f.x),v=new M.McGePoint3d(this.position.x+r*1.2,this.position.y),x=new M.McDbPolyline;x.addVertexAt(this.point),x.addVertexAt(this.position),x.addVertexAt(v),t.drawEntity(x)}setPosition(t){this.assertWrite(),this.position=t.clone()}getPosition(){return this.position}}function YI(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("请选择目标坐标点");const t=yield e.go();if(!t)return;const i=new Cm;i.coordinatePoint=t;const l=new M.MxCADUiPrPoint;l.setMessage("请指定标注位置"),l.setUserDraw((h,f)=>{i.setPosition(h),f.drawMcDbEntity(i)});const c=yield l.go();c&&(i.setPosition(c),M.MxCpp.getCurrentMxCAD().drawEntity(i))})}function KI(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("指定起点");const t=yield e.go();if(!t)return;const i=10,l=M.MxCpp.getCurrentMxCAD(),c=new M.McDbText;c.height=i,c.textString=t.y.toFixed(2),c.position=t;const h=l.drawEntity(c);let f,r,v;setTimeout(()=>Qe(this,null,function*(){const x=h.getMcDbEntity().getBoundingBox(),w=x.maxPt.distanceTo(new M.McGePoint3d(x.minPt.x,x.maxPt.y));h.erase();const b=new M.MxCADUiPrPoint;if(b.setMessage("指定终点"),b.setUserDraw((R,F)=>{f=new M.McDbLine(t,new M.McGePoint3d(t.x+i,t.y,0)),f.startPoint=t,f.endPoint=f.getClosestPointTo(R,!0).val,F.drawMcDbEntity(f);const V=new M.McGePoint3d(R.x,t.y+i,0),j=f.getPointAtDist(f.getLength().val-i).val,J=f.getPointAtDist(f.getLength().val-i*2).val;r=new M.McDbPolyline,r.addVertexAt(V),r.addVertexAt(j),r.addVertexAt(new M.McGePoint3d(J.x,J.y+i,0)),R.x>t.x?r.addVertexAt(new M.McGePoint3d(V.x+w,V.y,0)):r.addVertexAt(new M.McGePoint3d(V.x-w,V.y,0)),F.drawMcDbEntity(r),v=c.clone(),v.position=v.alignmentPoint=V,R.x>t.x?c.horizontalMode=M.McDb.TextHorzMode.kTextLeft:c.horizontalMode=M.McDb.TextHorzMode.kTextRight,F.drawMcDbEntity(v)}),!(yield b.go()))return;const L=new M.MxCADUiPrPoint;L.setMessage("指定标注方向"),L.setUserDraw((R,F)=>{const V=r.clone(),j=v.clone();if(R.y<f.endPoint.y){V.mirror(r.getPointAt(1).val,f.endPoint);const J=V.getPointAt(0).val;j.position=j.alignmentPoint=new M.McGePoint3d(J.x,J.y-i,0)}F.drawMcDbEntity(j),F.drawMcDbEntity(V),F.drawMcDbEntity(f)});const P=yield L.go();if(P){if(P.y<f.endPoint.y){r.mirror(r.getPointAt(1).val,f.endPoint);const R=r.getPointAt(0).val;v.position=v.alignmentPoint=new M.McGePoint3d(R.x,R.y-i,0)}l.drawEntity(f),l.drawEntity(v),l.drawEntity(r)}}),0)})}function JI(){return Qe(this,null,function*(){const e=new M.MxCADUiPrString;e.setMessage("请设置文字内容");const t=yield e.go();if(!t)return;const i=new M.McDbText;i.textString=t,i.height=10,i.position=i.alignmentPoint=new M.McGePoint3d(0,0,0),i.horizontalMode=M.McDb.TextHorzMode.kTextMid;const l=M.MxCpp.getCurrentMxCAD(),c=l.drawEntity(i);setTimeout(()=>Qe(this,null,function*(){const h=c.getMcDbEntity().getBoundingBox(),f=h.maxPt.distanceTo(new M.McGePoint3d(h.minPt.x,h.maxPt.y));c.erase();const r=new M.MxCADUiPrPoint;r.setMessage("请指定标注位置");let v,x;r.setUserDraw((b,A)=>{const L=new M.McGePoint3d(b.x,b.y+f,0),P=new M.McGePoint3d(L.x-f/2,L.y,0),R=new M.McGePoint3d(L.x+f/2,L.y,0),F=new M.McDbLine(b,R),V=F.getPointAtDist(F.getLength().val+f).val;v=new M.McDbPolyline,v.addVertexAt(R),v.addVertexAt(P),v.addVertexAt(b),v.addVertexAt(V),A.drawMcDbEntity(v),x=i.clone(),x.position=x.alignmentPoint=L,A.drawMcDbEntity(x)}),(yield r.go())&&(l.drawEntity(v),l.drawEntity(x))}),0)})}class au extends M.McDbCustomEntity{constructor(t){super(t),this.ptArr=[],this.height=30,this.dbulges=[],this.isReactFlag=!1}create(t){return new au(t)}getTypeName(){return"McDbTestAreaComment"}set textHeight(t){this.height=t}get textHeight(){return this.height}set isReact(t){this.isReactFlag=t}get isReact(){return this.isReactFlag}dwgInFields(t){this.ptArr=t.readPoints("ptArr").val,this.pt=t.readPoint("pt").val;const i=t.readString("dbulges").val;return this.dbulges=i.split(",").map(Number),this.isReactFlag=!!t.readLong("isReactFlag").val,!0}dwgOutFields(t){t.writePoints("ptArr",this.ptArr),t.writePoint("pt",this.pt);const i=this.dbulges.toString();return t.writeString("dbulges",i),t.writeLong("isReactFlag",this.isReactFlag?1:0),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),this.ptArr.forEach((h,f)=>{f===t&&(h.x+=i,h.y+=l,h.z+=c)}),t===this.ptArr.length&&(this.pt.x+=i,this.pt.y+=l,this.pt.z+=c)}getGripPoints(){let t=new M.McGePoint3dArray;return this.ptArr.forEach(i=>{t.append(i)}),t.append(this.pt),t}worldDraw(t){const i=new M.McDbPolyline;i.isClosed=!0,this.isReactFlag?(i.addVertexAt(this.ptArr[0],0,.1,.1),i.addVertexAt(new M.McGePoint3d(this.ptArr[1].x,this.ptArr[0].y),0,.1,.1),i.addVertexAt(this.ptArr[1],0,.1,.1),i.addVertexAt(new M.McGePoint3d(this.ptArr[0].x,this.ptArr[1].y),0,.1,.1)):this.ptArr.forEach((f,r)=>{i.addVertexAt(f,this.dbulges[r],.1,.1)});const l=i.getArea().val,c=i.getLength().val,h=new M.McDbMText;h.contents=`面积:${l.toFixed(2)}\\P周长:${c.toFixed(2)} `,h.attachment=M.McDb.AttachmentPoint.kMiddleCenter,h.location=this.pt,h.textHeight=X.MxFun.screenCoordLong2Doc(this.height),h.trueColor=this.trueColor,t.trueColor=this.trueColor,t.drawEntity(h),t.drawEntity(i)}setPoint(t){this.assertWrite(),this.pt=t.clone()}addVertex(t,i){this.assertWrite(),this.ptArr.push(t.clone()),this.dbulges.push(i||0)}getPoint(){return this.pt}}function QI(){return Qe(this,null,function*(){const e=[],t=new M.MxCADUiPrPoint;t.setMessage("请选择面积的第一个点");const i=yield t.go();if(!i)return;for(e.push(i);;){const r=new M.MxCADUiPrPoint;r.setMessage("请选择下一个点"),r.setKeyWords("[回退(B)/结束(O)]"),r.setUserDraw((w,b)=>{const A=new M.McDbPolyline;e.forEach(L=>{A.addVertexAt(L,0,.1,.1)}),A.addVertexAt(w),b.drawMcDbEntity(A)});const v=yield r.go(),x=r.keyWordPicked();if(x==="B")e.length>1&&e.pop();else{if(x==="O")break;if(!v)break;e.push(v)}}if(e.length<3)return;const l=M.MxCpp.getCurrentMxCAD(),c=new au;e.forEach(r=>{c.addVertex(r,0)});const h=new M.MxCADUiPrPoint;h.setMessage("请选择面积标注的位置"),h.setUserDraw((r,v)=>{v.setColor(16711680),c.setPoint(r),v.drawMcDbEntity(c)});const f=yield h.go();f&&(c.setPoint(f),c.trueColor=new M.McCmColor(255,0,0),l.drawEntity(c))})}function eR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("请选择矩形的角点1");const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrPoint;i.setMessage("请选择矩形的角点2"),i.setUserDraw((r,v)=>{const x=new M.McDbPolyline;x.isClosed=!0,x.addVertexAt(t),x.addVertexAt(new M.McGePoint3d(r.x,t.y)),x.addVertexAt(r),x.addVertexAt(new M.McGePoint3d(t.x,r.y)),v.drawMcDbEntity(x)});const l=yield i.go();if(!l)return;const c=new au;c.isReact=!0,c.addVertex(t),c.addVertex(l);const h=new M.MxCADUiPrPoint;h.setMessage("请设置面积标注的位置"),h.setUserDraw((r,v)=>{v.setColor(16711680),c.setPoint(r),v.drawMcDbEntity(c)});const f=yield h.go();f&&(c.setPoint(f),c.trueColor=new M.McCmColor(255,0,0),M.MxCpp.getCurrentMxCAD().drawEntity(c))})}function tR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("请选择一个测量点");const t=yield e.go();if(!t)return;const i=new M.MxCADResbuf([M.DxfCode.kEntityType,"LINE"]),l=new M.MxCADUiPrEntity;l.setMessage("请选择一条直线"),l.setFilter(i);const c=yield l.go();if(!c.id)return;const f=c.getMcDbEntity().getClosestPointTo(t,!0).val;let r;const v=M.MxCpp.getCurrentMxCAD(),x=new M.MxCADUiPrPoint;x.setMessage("请设置尺寸线的位置"),x.setUserDraw((b,A)=>{r&&r.erase(),r=v.drawDimAligned(t.x,t.y,f.x,f.y,b.x,b.y)});const w=yield x.go();if(!w){r&&r.erase();return}r&&r.erase(),v.drawDimAligned(t.x,t.y,f.x,f.y,w.x,w.y)})}class Am extends M.McDbCustomEntity{constructor(t){super(t),this.center=new M.McGePoint3d,this.position=new M.McGePoint3d,this.height=30}create(t){return new Am(t)}getTypeName(){return"McDbTestArcComment"}set arcCenter(t){this.center=t.clone()}get arcCenter(){return this.center}set arcRadius(t){this.radius=t}get arcRadius(){return this.radius}set textHeight(t){this.height=t}get textHeight(){return this.height}set arcStartAngle(t){this.startAngle=t}get arcStartAngle(){return this.startAngle}set arcEndAngle(t){this.endAngle=t}get arcEndAngle(){return this.endAngle}dwgInFields(t){return this.position=t.readPoint("position").val,this.center=t.readPoint("center").val,this.startAngle=t.readDouble("startAngle").val,this.endAngle=t.readDouble("endAngle").val,this.radius=t.readDouble("radius").val,this.height=t.readDouble("textHeight").val,!0}dwgOutFields(t){return t.writePoint("position",this.position),t.writePoint("center",this.center),t.writeDouble("startAngle",this.startAngle),t.writeDouble("endAngle",this.endAngle),t.writeDouble("radius",this.radius),t.writeDouble("textHeight",this.height),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),this.position.x+=i,this.position.y+=l,this.position.z+=c}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.position),t}drawLine(t,i){const l=i.sub(t).normalize().mult(X.MxFun.screenCoordLong2Doc(this.height*.4)),c=i.clone().addvec(l),h=i.clone().subvec(l),f=new M.McDbLine(c,h);return f.rotate(i,Math.PI/4),{line:f,pt:c}}worldDraw(t){const i=new M.McDbArc;i.center=this.center,i.startAngle=this.startAngle,i.endAngle=this.endAngle,i.radius=this.radius;const l=i.getLength().val,c=i.getPointAtDist(0).val,h=i.getPointAtDist(l).val,f=new M.McDbText;f.textString=`${l.toFixed(2)}`,f.height=X.MxFun.screenCoordLong2Doc(this.height),f.horizontalMode=M.McDb.TextHorzMode.kTextCenter,f.position=f.alignmentPoint=this.position;const v=i.getClosestPointTo(this.position,!0).val.distanceTo(this.position);i.offsetCurves(v,this.position).forEach(R=>{const F=R.clone(),V=F.getLength().val;this.pt1=F.getPointAtDist(0).val,this.pt2=F.getPointAtDist(V).val;const j=F.getPointAtDist(V/2).val;this.dbulge=M.MxCADUtility.calcBulge(this.pt1,j,this.pt2).val});const x=new M.McDbPolyline;x.addVertexAt(this.pt1,this.dbulge),x.addVertexAt(this.pt2);const w=this.pt1.sub(this.pt2).angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis);f.rotation=w===Math.PI?0:w;const{line:b,pt:A}=this.drawLine(c,this.pt1),{line:L,pt:P}=this.drawLine(h,this.pt2);x.trueColor=f.trueColor=b.trueColor=L.trueColor=this.trueColor,t.drawEntity(x),t.drawEntity(f),t.drawEntity(b),t.drawEntity(L),t.drawEntity(new M.McDbLine(c,A)),t.drawEntity(new M.McDbLine(h,P))}setPosition(t){this.assertWrite(),this.position=t.clone()}getPoint(){return this.position}}function nR(){return Qe(this,null,function*(){const e=new M.MxCADResbuf([M.DxfCode.kEntityType,"ARC"]),t=new M.MxCADUiPrEntity;t.setMessage("请选择一条弧线"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity(),c=new Am;c.arcCenter=l.center,c.arcStartAngle=l.startAngle,c.arcEndAngle=l.endAngle,c.arcRadius=l.radius;const h=new M.MxCADUiPrPoint;h.setMessage("请指定尺寸线位置"),h.setUserDraw((v,x)=>{x.setColor(16711680),c.setPosition(v),x.drawMcDbEntity(c)});const f=yield h.go();if(!f)return;c.setPosition(f),c.trueColor=new M.McCmColor(255,0,0),M.MxCpp.getCurrentMxCAD().drawEntity(c)})}class Dm extends M.McDbCustomEntity{constructor(t){super(t),this.center=new M.McGePoint3d,this.position=new M.McGePoint3d}create(t){return new Dm(t)}getTypeName(){return"McDbTestMeasuringCircle"}set circleRadius(t){this.radius=t}get circleRadius(){return this.radius}dwgInFields(t){return this.center=t.readPoint("center").val,this.position=t.readPoint("position").val,this.radius=t.readDouble("radius").val,!0}dwgOutFields(t){return t.writePoint("center",this.center),t.writePoint("position",this.position),t.writeDouble("radius",this.radius),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),this.position.x+=i,this.position.y+=l,this.position.z+=c}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.position),t}worldDraw(t){const i=new M.McDbCircle;i.center=this.center,i.radius=this.radius;const l=i.getLength().val,c=i.radius,h=Math.PI*c*c,f=new M.McDbMText;f.contents=`半径:${c.toFixed(2)} \\P 周长:${l.toFixed(2)} \\P 面积:${h.toFixed(2)}`,f.textHeight=c/6,f.attachment=M.McDb.AttachmentPoint.kMiddleCenter,f.location=this.position,f.trueColor=i.trueColor=this.trueColor,t.drawEntity(f),t.drawEntity(i)}setCenter(t){this.assertWrite(),this.center=t.clone()}getCenter(){return this.center}setPosition(t){this.assertWrite(),this.position=t.clone()}getPosition(){return this.position}}function iR(){return Qe(this,null,function*(){const e=new M.MxCADResbuf([M.DxfCode.kEntityType,"CIRCLE"]),t=new M.MxCADUiPrEntity;t.setMessage("请选择一个圆对象"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity();l.highlight(!0);const c=new Dm;c.setCenter(l.center),c.circleRadius=l.radius;const h=new M.MxCADUiPrPoint;h.setMessage("请指定文字位置"),h.setUserDraw((v,x)=>{x.setColor(16711680),c.setPosition(v),x.drawMcDbEntity(c)});const f=yield h.go();if(!f)return;c.setPosition(f),c.trueColor=new M.McCmColor(255,0,0),M.MxCpp.getCurrentMxCAD().drawEntity(c),l.highlight(!1)})}class Pm extends M.McDbCustomEntity{constructor(t){super(t),this.points=[],this.dbulges=[],this.position=new M.McGePoint3d,this.height=30,this.dimColor=new M.McCmColor(255,0,0),this.width=.1,this.showSegLength=!1}create(t){return new Pm(t)}getTypeName(){return"McDbTestConMeasurement"}set textHeight(t){this.height=t}get textHeight(){return this.height}set color(t){this.dimColor=t.clone()}get color(){return this.dimColor}set conWidth(t){this.width=X.MxFun.screenCoordLong2Doc(t)}get conWidth(){return this.width}set isShowSegLength(t){this.showSegLength=t}get isShowSegLength(){return this.showSegLength}dwgInFields(t){this.points=t.readPoints("points").val,this.position=t.readPoint("position").val;const i=t.readString("dbulges").val;this.dbulges=i.split(",").map(Number);const l=t.readString("dimColor").val;return this.dimColor=new M.McCmColor(...l.split(",").map(Number)),this.width=t.readDouble("conWidth").val,this.showSegLength=t.readLong("showSegLength").val===1,!0}dwgOutFields(t){const i=this.dbulges.toString(),l=`${this.dimColor.red},${this.dimColor.green},${this.dimColor.blue}`,c=this.showSegLength?1:0;return t.writePoints("points",this.points),t.writePoint("position",this.position),t.writeString("dbulges",i),t.writeString("dimColor",l),t.writeDouble("conWidth",this.width),t.writeLong("showSegLength",c),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),t<this.points.length?(this.points[t].x+=i,this.points[t].y+=l,this.points[t].z+=c):(this.position.x+=i,this.position.y+=l,this.position.z+=c)}getGripPoints(){let t=new M.McGePoint3dArray;return this.points.forEach(i=>{t.append(i)}),t.append(this.position),t}worldDraw(t){const i=new M.McDbPolyline,l=[];this.points.forEach((J,ne)=>{let H=this.width;if(ne===this.points.length-1&&(H=0),i.addVertexAt(J,this.dbulges[ne],H,H),ne>0){const Q=this.points[ne-1],ae=new M.McDbPolyline;ae.addVertexAt(Q,this.dbulges[ne-1]),ae.addVertexAt(J,this.dbulges[ne]);const ie=ae.getLength().val,le=ae.getPointAtDist(ie/2).val,fe=new M.McDbText;fe.textString=`${ie.toFixed(2)}`,fe.height=X.MxFun.screenCoordLong2Doc(this.height*.6),fe.horizontalMode=M.McDb.TextHorzMode.kTextCenter;let me;Q.x<=J.x?me=J.sub(Q):me=Q.sub(J);const he=me.clone().perpVector().normalize(),Oe=X.MxFun.screenCoordLong2Doc(this.height*.15),Ve=new M.McDbLine(Q,J);Ve.getPointAtDist(Ve.getLength().val/2).val.y>=le.y?le.addvec(he.mult(Oe)):le.subvec(he.mult(Oe)),fe.position=fe.alignmentPoint=le;const at=me.angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis);fe.rotation=at===Math.PI?0:at,l.push(fe)}});const c=M.MxCpp.getCurrentMxCAD(),h=c.drawEntity(i),f=h.getMcDbEntity().getLength().val,r=this.points[this.points.length-1],x=i.getFirstDeriv(r).val.clone();x.rotateBy(Math.PI/4).normalize().mult(this.width*5);const w=r.clone().addvec(x),b=r.clone().subvec(x),A=new M.McDbPolyline;A.addVertexAt(w,0,this.width,this.width),A.addVertexAt(b),h.erase();const L=new M.McDbText;L.textString=`${f.toFixed(2)}`,L.height=X.MxFun.screenCoordLong2Doc(this.height);const P=X.MxFun.screenCoordLong2Doc(4);L.position=L.alignmentPoint=new M.McGePoint3d(this.position.x+P,this.position.y+P),L.horizontalMode=M.McDb.TextHorzMode.kTextLeft;const R=c.drawEntity(L),{minPt:F,maxPt:V}=R.getMcDbEntity().getBoundingBox();R.erase();const j=new M.McGePoint3d(this.position.x+Math.abs(F.x-V.x)+P*6,this.position.y);i.addVertexAt(this.position),i.addVertexAt(j),this.showSegLength&&l.forEach(J=>{t.drawEntity(J)}),t.trueColor=this.dimColor,t.drawEntity(i),t.drawEntity(L),t.drawEntity(A)}addVertex(t,i){this.assertWrite(),this.dbulges.push(i),this.points.push(t)}getPoints(){return this.points}setPosition(t){this.assertWrite(),this.position=t.clone()}getPosition(){return this.position}}let ob=[];function ab(e){const t=M.MxCpp.getCurrentMxCAD();e===1?(ob.push({name:"ORTHOMODE",value:t.getSysVarLong("ORTHOMODE")},{name:"GRIDMODE",value:t.getSysVarLong("GRIDMODE")},{name:"OSMODE",value:t.getSysVarLong("OSMODE")}),t.setSysVarLong("ORTHOMODE",0),t.setSysVarLong("GRIDMODE",0),t.setSysVarLong("OSMODE",16383)):e===0&&ob.forEach(i=>{t.setSysVarLong(i.name,i.value)})}function sb(){return Qe(this,null,function*(){ab(1);let e=[],t=!1;const i=new M.MxCADResbuf([M.DxfCode.kEntityType,"ARC"]);let c=M.MxCpp.getCurrentMxCAD().mxdraw.viewCoordLong2Cad(.5),h=null;for(;;){const f=new M.MxCADUiPrPoint;f.setMessage("请选择直线的端点或弧线"),f.setKeyWords("[回退(B)/结束(O)]"),e.length>0&&f.setBasePt(e[e.length-1].pt),f.setUserDraw((x,w)=>{const b=new M.McDbPolyline;e.forEach(A=>{b.addVertexAt(A.pt,A.dbulge,.1,.1)}),w.drawMcDbEntity(b)});const r=yield f.go(),v=f.keyWordPicked();if(v==="B")e.length>1&&e.pop(),h=null;else{if(v==="O")break;{if(!r)break;const x=M.MxCADUtility.findEntAtPoint(r.x,r.y,r.z,-1,i);if(!x.id)h=null,t?e.filter(b=>b.pt.distanceTo(r)<c).length||alert("请选择连续的线段!"):e.push({pt:r,dbulge:0});else{const w=x.getMcDbEntity(),b=w.getLength().val,A=w.getPointAtDist(0).val,L=w.getPointAtDist(b).val;if(A.distanceTo(r)<c||L.distanceTo(r)<c)if(t){const P=-e[0].dbulge,R=e[e.length-2].pt,F=e[e.length-1].pt;R.distanceTo(r)<c&&(e.slice(0,e.length-2),e.push({pt:F,dbulge:P}),e.push({pt:R,dbulge:0})),t=!1,h=x}else e.push({pt:r,dbulge:0});else if(e.length>0){const P=e[e.length-1].pt;if(A.distanceTo(P)<c||L.distanceTo(P)<c)if((h==null?void 0:h.id)===x.id){console.log("点击同一个圆弧"),e.pop();const R=e[e.length-1],F=w.getDistAtPoint(R.pt).val,V=w.getDistAtPoint(r).val;let j=w.getPointAtDist(F+(V-F)/2).val,J=new M.McDbArc;if(J.computeArc(R.pt.x,R.pt.y,j.x,j.y,r.x,r.y),J.getLength().val>w.getLength().val){const ne=J.clone();J.startAngle=ne.endAngle,J.endAngle=ne.startAngle,j=J.getPointAtDist(J.getLength().val/2).val}R.dbulge=M.MxCADUtility.calcBulge(R.pt,j,r).val,e.push({pt:r,dbulge:0}),h=null}else{const R=A.distanceTo(P)<c?L:A;e[e.length-1].dbulge=M.MxCADUtility.calcBulge(P,r,R).val,e.push({pt:R,dbulge:0}),h=x}else alert("请选择连续的线段!")}else{const P=M.MxCADUtility.calcBulge(A,r,L).val;e.push({pt:A,dbulge:P}),e.push({pt:L,dbulge:0}),t=!0,h=x}}}}}return ab(0),e})}function rR(){return Qe(this,null,function*(){const e=M.MxCpp.getCurrentMxCAD(),t=yield sb();if(t.length<2)return;const i=new Pm;t.forEach(h=>{i.addVertex(h.pt,h.dbulge)});const l=new M.MxCADUiPrPoint;l.setMessage("请指定文字的位置"),l.setUserDraw((h,f)=>{i.setPosition(h),f.drawMcDbEntity(i)});const c=yield l.go();c&&(i.setPosition(c),e.drawEntity(i))})}function oR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrEntity;e.setMessage("请选择一个连续测量的标注");const t=yield e.go();if(!t.id)return;const i=t.getMcDbEntity();if(i instanceof M.McDbCustomEntity&&i.getTypeName()==="McDbTestConMeasurement"){const l=i.clone();l.isShowSegLength=!l.isShowSegLength,M.MxCpp.getCurrentMxCAD().drawEntity(l),t.erase()}})}function aR(){return Qe(this,null,function*(){const e=yield sb(),t=M.MxCpp.getCurrentMxCAD(),i=new au;e.forEach(h=>{i.addVertex(h.pt,h.dbulge)});const l=new M.MxCADUiPrPoint;l.setMessage("请选择面积标注的位置"),l.setUserDraw((h,f)=>{i.setPoint(h),f.drawMcDbEntity(i)});const c=yield l.go();c&&(i.setPoint(c),i.trueColor=new M.McCmColor(255,0,0),t.drawEntity(i))})}function sR(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LINE");const t=new M.MxCADUiPrEntity;t.setMessage("请选择一条直线"),t.setFilter(e);const i=yield t.go();if(!i)return;const l=i.getMcDbEntity();l.highlight(!0);const c=new M.MxCADUiPrEntity;c.setMessage("请选择第二条直线"),c.setFilter(e);const h=yield c.go();if(!h)return;const f=h.getMcDbEntity();f.highlight(!0);const r=new M.MxCADUiPrPoint;r.setMessage("请设置角度标注的位置");const v=M.MxCpp.getCurrentMxCAD().addDimStyle("MyDimStyle2","41,0.18,141,0.09,40,20","77,1,271,3","",""),x=new M.McDb2LineAngularDimension;x.xLine1Start=l.startPoint,x.xLine1End=l.endPoint,x.xLine2Start=f.startPoint,x.xLine2End=f.endPoint,x.dimensionStyle=v,l.highlight(!1),f.highlight(!1),r.setUserDraw((b,A)=>{x.arcPoint=b,A.drawMcDbEntity(x)});const w=yield r.go();w&&(x.arcPoint=w,M.MxCpp.getCurrentMxCAD().drawEntity(x))})}function lR(){new au().rxInit(),new Pm().rxInit(),new Dm().rxInit(),new Am().rxInit(),new Cm().rxInit(),X.MxFun.addCommand("Mx_StaLength",qI),X.MxFun.addCommand("Mx_StaArea",XI),X.MxFun.addCommand("Mx_StandardSlope",ZI),X.MxFun.addCommand("Mx_CoordAnnotation",YI),X.MxFun.addCommand("Mx_Elevation",KI),X.MxFun.addCommand("Mx_Roughness",JI),X.MxFun.addCommand("Mx_Area",QI),X.MxFun.addCommand("Mx_ReactArea",eR),X.MxFun.addCommand("Mx_DistFromPointToLine",tR),X.MxFun.addCommand("Mx_ArcLength",nR),X.MxFun.addCommand("Mx_MeasuringCircle",iR),X.MxFun.addCommand("Mx_ContinueMeasurement",rR),X.MxFun.addCommand("Mx_CountList",oR),X.MxFun.addCommand("Mx_AreaArc",aR),X.MxFun.addCommand("Mx_MeasuringAngle",sR)}function cR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrInt;e.setMessage(`
- 请输入星形顶点数:`);const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrPoint;i.setMessage(`
- 指定星形中心点:`);const l=yield i.go();if(!l)return;const c=new M.MxCADUiPrDist;c.setBasePt(l),c.setMessage("请设置星形的内半径:");const h=yield c.go();let f;h?f=c.value():f=5;const r=new M.McDbCircle(l.x,l.y,l.z,f);let v=[];const x=new M.MxCADUiPrDist;if(x.setBasePt(l),x.setMessage(`
- 指定星形的外半径:`),x.setUserDraw((L,P)=>{let R=new M.McDbCircle(l.x,l.y,l.z,L.distanceTo(l)),F=r.getLength(),V=R.getLength();if(!F||!V)return;let j=[];for(let ne=0;ne<t*2;ne++){let H=r.getPointAtDist(F.val/(t*2)*ne);if(!H.ret)return;let Q=R.getPointAtDist(V.val/(t*2)*ne);if(!Q.ret)return;ne%2===0?j.push(H.val):j.push(Q.val)}let J=new M.McDbPolyline;j.forEach(ne=>{J.addVertexAt(ne)}),J.isClosed=!0,P.drawMcDbEntity(J),v=[...j]}),!(yield x.go()))return;let b=M.MxCpp.getCurrentMxCAD(),A=new M.McDbPolyline;v.forEach(L=>{A.addVertexAt(L)}),A.isClosed=!0,b.drawEntity(A)})}function uR(){return Qe(this,null,function*(){let e=5;const t=new M.MxCADUiPrDist;t.setMessage(`
- 请输入凹凸线宽度<5>`),(yield t.go())&&(e=t.value());let l=10;const c=new M.MxCADUiPrDist;c.setMessage(`
- 请输入凹凸线高度<10>`),(yield c.go())&&(l=c.value());let f=new M.MxCADUiPrPoint;f.setMessage("请点击确定起始点");let r=yield f.go();if(!r)return;let v=new M.MxCADUiPrPoint;v.setMessage("请点击确定终点"),v.setUserDraw((fe,me)=>{let he=new M.McDbLine(r.x,r.y,r.z,fe.x,fe.y,fe.z);me.drawMcDbEntity(he)});let x=yield v.go();if(!x)return;let w=new M.McDbLine(r.x,r.y,r.z,x.x,x.y,x.z),b=w.clone(),A=w.getLength(),L=w.getPointAtDist(A.val/2).val,P=M.McGeVector3d.kYAxis.angleTo1(M.McGeVector3d.kXAxis);b.rotate(L,P);let R=b.getPointAtDist(A.val/2+l/2).val,F=b.getPointAtDist(A.val/2-l/2).val,V=w.offsetCurves(l/2,R),j=w.offsetCurves(l/2,F),J=M.MxCpp.App.getCurrentMxCAD();if(V.length()===0||j.length()===0)return;let ne,H;V.forEach(fe=>{ne=fe.clone()}),j.forEach(fe=>{H=fe.clone()});let Q=[],ae=A.val/e;for(let fe=0;fe<ae;fe++)fe%2===0?(Q.push(ne.getPointAtDist(e*fe).val),Q.push(H.getPointAtDist(e*fe).val)):(Q.push(H.getPointAtDist(e*fe).val),Q.push(ne.getPointAtDist(e*fe).val));let ie=new M.McDbPolyline;Q.forEach(fe=>{ie.addVertexAt(fe)});let le=w.getPointAtDist(e*parseInt(ae.toString())).val;ie.setPointAt(0,w.startPoint),ie.setPointAt(Q.length-1,le),J.drawEntity(ie)})}function hR(){return Qe(this,null,function*(){let e=5;const t=new M.MxCADUiPrDist;t.setMessage(`
- 请输入锯齿线宽度<5>`),(yield t.go())&&(e=t.value());let l=10;const c=new M.MxCADUiPrDist;c.setMessage(`
- 请输入锯齿线高度<10>`),(yield c.go())&&(l=c.value());let f=new M.MxCADUiPrPoint;f.setMessage("请点击确定起始点");let r=yield f.go();if(!r)return;let v=new M.MxCADUiPrPoint;v.setMessage("请点击确定终点"),v.setUserDraw((fe,me)=>{let he=new M.McDbLine(r.x,r.y,r.z,fe.x,fe.y,fe.z);me.drawMcDbEntity(he)});let x=yield v.go();if(!x)return;let w=new M.McDbLine(r.x,r.y,r.z,x.x,x.y,x.z),b=w.clone(),A=w.getLength(),L=w.getPointAtDist(A.val/2).val,P=M.McGeVector3d.kYAxis.angleTo1(M.McGeVector3d.kXAxis);b.rotate(L,P);let R=b.getPointAtDist(A.val/2+l/2).val,F=b.getPointAtDist(A.val/2-l/2).val,V=w.offsetCurves(l/2,R),j=w.offsetCurves(l/2,F),J=M.MxCpp.App.getCurrentMxCAD();if(V.length()===0||j.length()===0)return;let ne,H;V.forEach(fe=>{ne=fe.clone()}),j.forEach(fe=>{H=fe.clone()});let Q=[],ae=A.val/(e/2);for(let fe=0;fe<ae;fe++)fe%2===0?Q.push(ne.getPointAtDist(e/2*fe).val):Q.push(H.getPointAtDist(e/2*fe).val);let ie=new M.McDbPolyline;Q.forEach(fe=>{ie.addVertexAt(fe)});let le=w.getPointAtDist(e/2*parseInt(ae.toString())).val;ie.setPointAt(0,w.startPoint),ie.setPointAt(Q.length-1,le),J.drawEntity(ie)})}function dR(){return Qe(this,null,function*(){let e=5;const t=new M.MxCADUiPrDist;t.setMessage(`
- 请输入矩形宽度<5>`),(yield t.go())&&(e=t.value());let l=10;const c=new M.MxCADUiPrDist;c.setMessage(`
- 请输入矩形高度<10>`),(yield c.go())&&(l=c.value());const f=A=>{const L=[];return L.push(new M.McGePoint3d(A.x+e/2,A.y+l/2,A.z)),L.push(new M.McGePoint3d(A.x-e/2,A.y+l/2,A.z)),L.push(new M.McGePoint3d(A.x-e/2,A.y-l/2,A.z)),L.push(new M.McGePoint3d(A.x+e/2,A.y-l/2,A.z)),L},r=new M.MxCADUiPrPoint;r.setMessage("请点击确定矩形中心"),r.setUserDraw((A,L)=>{const P=f(A);let R=new M.McDbPolyline;P.forEach(F=>{R.addVertexAt(F)}),R.isClosed=!0,L.drawMcDbEntity(R)});const v=yield r.go();if(!v)return;const x=f(v);let w=new M.McDbPolyline;x.forEach(A=>{w.addVertexAt(A)});const b=M.MxCpp.App.getCurrentMxCAD();w.isClosed=!0,b.drawEntity(w)})}function pR(){return Qe(this,null,function*(){let e=10;const t=new M.MxCADUiPrDist;t.setMessage(`
- 请设置断口宽度<10>`),(yield t.go())&&(e=t.value());let l=5;const c=new M.MxCADUiPrDist;c.setMessage(`
- 请设置两头延长长度<5>`),(yield c.go())&&(l=c.value()),console.log(l);const f=new M.MxCADUiPrPoint;f.setMessage("请点击确定起点");const r=yield f.go();if(!r)return;const v=new M.MxCADUiPrPoint;v.setMessage("请点击下一个点"),v.setUserDraw((le,fe)=>{const me=new M.McDbLine(r.x,r.y,r.z,le.x,le.y,le.z);fe.drawMcDbEntity(me)});const x=yield v.go();if(!x)return;const w=new M.McDbLine(r.x,r.y,r.z,x.x,x.y,x.z),b=w.getPointAtDist(w.getLength().val/2).val;let A=w.getFirstDeriv(b),L=A.val.clone();if(!A.ret)return;A.val.normalize().mult(e/2),L.normalize().mult(l),r.subvec(L),x.addvec(L);let P=b.clone();P.addvec(A.val);let R=b.clone();R.subvec(A.val);let F=new M.McDbLine(b.x,b.y,b.z,P.x,P.y,P.z),V=M.McGeVector3d.kXAxis.angleTo1(M.McGeVector3d.kYAxis),j=F.clone();j.rotate(F.getPointAtDist(F.getLength().val/2).val,V);let J=j.getPointAtDist(2*j.getLength().val).val,H=new M.McDbLine(b.x,b.y,b.z,R.x,R.y,R.z).clone();H.rotate(H.getPointAtDist(H.getLength().val/2).val,V);let Q=H.getPointAtDist(2*H.getLength().val).val;const ae=new M.McDbPolyline;ae.addVertexAt(r),ae.addVertexAt(R),ae.addVertexAt(Q),ae.addVertexAt(J),ae.addVertexAt(P),ae.addVertexAt(x),M.MxCpp.App.getCurrentMxCAD().drawEntity(ae)})}function fR(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("CIRCLE");let t=yield M.MxCADUtility.userSelect("选择目标对象",e);t.length!=0&&t.forEach(i=>Qe(this,null,function*(){let l=yield i.getMcDbEntity(),c=l.center,h=l.radius,f=M.MxCpp.App.getCurrentMxCAD(),r=new M.McDbLine(c.x+h*1.3,c.y,c.z,c.x-h*1.3,c.y,c.z);r.trueColor=new M.McCmColor(255,0,0);let v=new M.McDbLine(c.x,c.y+h*1.3,c.z,c.x,c.y-h*1.3,c.z);v.trueColor=new M.McCmColor(255,0,0),f.drawEntity(r),f.drawEntity(v)}))})}function mR(){return Qe(this,null,function*(){let e=10;const t=new M.MxCADUiPrDist;t.setMessage(`
- 请输入管径<10>`),(yield t.go())&&(e=t.value());let l=10;const c=new M.MxCADUiPrDist;c.setMessage(`
- 请输入长出管口长度<5>`),(yield c.go())&&(l=c.value());let f=new M.MxCADUiPrPoint;f.setMessage("请点击确定起点");const r=yield f.go();if(!r)return;const v=new M.MxCADUiPrPoint;v.setMessage("请点击确定终点"),v.setUserDraw((H,Q)=>{const ae=new M.McDbLine(r.x,r.y,r.z,H.x,H.y,H.z);Q.drawMcDbEntity(ae)});const x=yield v.go();if(!x)return;const w=new M.McDbLine(r.x,r.y,r.z,x.x,x.y,x.z),b=M.MxCpp.App.getCurrentMxCAD();let A=w.getLength().val,L=w.getPointAtDist(A+l),P=w.getPointAtDist(0-l),R=w.getPointAtDist(A/2).val,F=M.McGeVector3d.kXAxis.angleTo1(M.McGeVector3d.kYAxis),V=w.clone();V.rotate(R,F);let j=V.getPointAtDist(A/2+e/2).val,J=V.getPointAtDist(A/2-e/2).val;w.offsetCurves(e/2,j).forEach(H=>{H.trueColor=new M.McCmColor(0,255,0),b.drawEntity(H)}),w.offsetCurves(e/2,J).forEach(H=>{H.trueColor=new M.McCmColor(0,255,0),b.drawEntity(H)});let ne=b.addLinetypeEx("TestMyLine","25,-5");ne.isValid()&&(w.linetypeId=ne,w.endPoint=P.val,w.startPoint=L.val,w.trueColor=new M.McCmColor(255,0,0),b.drawEntity(w))})}function gR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("指定剖管线起点");const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrPoint;i.setMessage("指定剖管线终点"),i.setUserDraw((H,Q)=>{let ae=new M.McDbLine(t.x,t.y,t.z,H.x,H.y,H.z);Q.drawMcDbEntity(ae)});const l=yield i.go();if(!l)return;const c=new M.McDbLine(t.x,t.y,t.z,l.x,l.y,l.z),h=c.getLength().val,f=h/8,r=c.getPointAtDist(h/2).val,v=c.clone();v.rotate(r,Math.PI/2);const x=v.getPointAtDist(h/2+f).val,w=v.getPointAtDist(h/2-f).val,b=M.MxCpp.App.getCurrentMxCAD();let A;c.clone().offsetCurves(f,x).forEach(H=>{A=H});let L;c.clone().offsetCurves(f,w).forEach(H=>{L=H});const P=[],R=[];for(let H=0;H<4;H++)H%2!==0&&(P.push(A.getPointAtDist(H*f*2).val),R.push(L.getPointAtDist(H*f*2).val));let F,V=new M.McDbArc;V.computeArc(t.x,t.y,P[0].x,P[0].y,r.x,r.y),b.drawEntity(V);let j=new M.McDbArc;j.computeArc(t.x,t.y,R[0].x,R[0].y,r.x,r.y),b.drawEntity(j);let J=new M.McDbArc;J.computeArc(r.x,r.y,R[1].x,R[1].y,l.x,l.y),F=b.drawEntity(J);let ne=new M.MxCADUiPrKeyWord;for(;;){ne.setMessage("选择剖管线圆弧方向"),ne.setKeyWords("[左边(L)/右边(R)]");const H=yield ne.go();if(!H)return;if(H=="L"){let Q=new M.McDbArc;F.erase(),Q.computeArc(r.x,r.y,R[1].x,R[1].y,l.x,l.y),F=b.drawEntity(Q)}else if(H=="R"){F.erase();let Q=new M.McDbArc;Q.computeArc(r.x,r.y,P[1].x,P[1].y,l.x,l.y),F=b.drawEntity(Q)}}})}function yR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrKeyWord;e.setMessage("选择模式"),e.setKeyWords("[直线焊缝(L)/弧线焊缝(A)]");const t=yield e.go();if(!t)return;let i=5;const l=new M.MxCADUiPrDist;l.setMessage(`
- 请输入焊缝半径<5>`),(yield l.go())&&(i=l.value());let h=new M.McDbCurve;if(t==="L"){let A=new M.MxCADUiPrPoint;A.setMessage("请点击确定起始点");let L=yield A.go();if(!L)return;let P=new M.MxCADUiPrPoint;P.setMessage("请点击确定终点"),P.setUserDraw((F,V)=>{let j=new M.McDbLine(L.x,L.y,L.z,F.x,F.y,F.z);V.drawMcDbEntity(j)});let R=yield P.go();if(!R)return;h=new M.McDbLine(L.x,L.y,L.z,R.x,R.y,R.z)}else if(t==="A"){let A=new M.MxCADUiPrPoint;A.setMessage("指定起点");let L=yield A.go();if(!L)return;let P=new M.MxCADUiPrPoint;P.setMessage("指定圆弧的第二个点"),P.setUserDraw((J,ne)=>{ne.drawLine(L.toVector3(),J.toVector3())});let R=yield P.go();if(!R)return;let F=new M.MxCADUiPrPoint;F.setMessage("指定圆弧的端点"),F.setUserDraw((J,ne)=>{let H=new M.McDbArc;H.computeArc(L.x,L.y,R.x,R.y,J.x,J.y),ne.drawMcDbEntity(H)});let V=yield F.go();if(!V)return;let j=new M.McDbArc;j.computeArc(L.x,L.y,R.x,R.y,V.x,V.y),h=j}const f=M.MxCpp.App.getCurrentMxCAD();let v=h.getLength().val/i,x=[],w,b;t==="A"&&(w=h.center,b=h.radius);for(let A=0;A<v;A++){let L=h.getPointAtDist(i*A).val,P=new M.McDbCircle(L.x,L.y,L.z,i);const R=P.IntersectWith(h,M.McDb.Intersect.kExtendBoth);if(!R.length())return;let F=[];R.forEach(J=>{F.push(J)});let V=[],j=[];P.splitCurves(F).forEach((J,ne)=>{if(t==="L")ne%2!==0&&x.push(J);else if(t==="A"){let H=J.clone();H.getPointAtDist(H.getLength().val/2).val.distanceTo(w)>b?V.push(H):j.push(H)}}),V.length===1&&t==="A"?x.push(V[0]):t==="A"&&V.length>1&&(j[0].rotate(P.center,Math.PI),x.push(j[0]))}x.forEach((A,L)=>{if(L===0)f.drawEntity(A);else{let P=A.IntersectWith(x[L-1],M.McDb.Intersect.kExtendThis);if(P.length()===0)return;let R=[];P.forEach(j=>{R.push(j)});let F=[];A.splitCurves(R).forEach((j,J)=>{F.push({obj_cur:j,lenth:j.getLength().val})});let V=F.map(j=>j.lenth);f.drawEntity(F[V.indexOf(Math.max(...V))].obj_cur)}})})}function _R(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LINE,LWPOLYLINE");let t=yield M.MxCADUtility.userSelect("选择对象",e);t.length!=0&&t.forEach(i=>Qe(this,null,function*(){let l=yield i.getMcDbEntity();if(!l)return;let c=l.clone(),h=c.getLength(),f=c.getPointAtDist(h.val/2).val;if(!c.getFirstDeriv(f).ret)return;let v=M.McGeVector3d.kYAxis.angleTo1(M.McGeVector3d.kXAxis);c.rotate(f,v);let x=M.MxCpp.App.getCurrentMxCAD();c.trueColor=new M.McCmColor(255,0,0),x.drawEntity(c)}))})}function vR(){return Qe(this,null,function*(){let e=25;const t=new M.MxCADUiPrDist;t.setMessage("请输入宽度<25>"),(yield t.go())&&(e=t.value());let l=15;const c=new M.MxCADUiPrDist;c.setMessage("请输入高度<15>"),(yield c.go())&&(l=c.value());const f=new M.MxCADUiPrInt;f.setMessage("请输入楼梯级数<10>");const r=(yield f.go())||10,v=Math.sqrt(e*e+l*l),x=new M.MxCADUiPrPoint;x.setMessage("请点击确定起点");const w=yield x.go();if(!w)return;const b=new M.MxCADUiPrPoint;b.setMessage("请点击确定终点"),b.setUserDraw((V,j)=>{const J=new M.McDbLine(w.x,w.y,w.z,V.x,V.y,V.z);j.drawMcDbEntity(J)});const A=yield b.go();if(!A)return;const L=new M.McDbLine(w.x,w.y,w.z,A.x,A.y,A.z),P=[];for(let V=0;V<r+1;V++){let j=L.getPointAtDist(v*V).val;P.push(j)}const R=new M.McDbPolyline;P.forEach((V,j)=>{if(R.addVertexAt(V),j!=P.length-1){let J=new M.McGePoint3d(V.x,P[j+1].y,V.z);R.addVertexAt(J)}}),M.MxCpp.App.getCurrentMxCAD().drawEntity(R)})}function xR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage(`请确定圆心位置
- `);const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrDist;if(i.setBasePt(t),i.setMessage("请输入圆半径"),i.setUserDraw((f,r)=>{const v=f.distanceTo(t),x=new M.McDbCircle;x.center=t,x.radius=v,r.drawMcDbEntity(x)}),!(yield i.go()))return;const c=i.value(),h=M.MxCpp.getCurrentMxCAD();h.pathCircle(t.x,t.y,c),h.drawPathToHatch()})}function bR(){return Qe(this,null,function*(){let e=5;const t=new M.MxCADUiPrDist;t.setMessage(`
- 请输入保温棉宽度<5>`),(yield t.go())&&(e=t.value());let l=10;const c=new M.MxCADUiPrDist;c.setMessage(`
- 请输入保温棉高度<10>`),(yield c.go())&&(l=c.value());const f=new M.MxCADUiPrPoint;f.setMessage("请点击确定起点");const r=yield f.go();if(!r)return;const v=new M.MxCADUiPrPoint;v.setMessage("请点击下一个点"),v.setUserDraw((ae,ie)=>{const le=new M.McDbLine(r.x,r.y,r.z,ae.x,ae.y,ae.z);ie.drawMcDbEntity(le)});const x=yield v.go();if(!x)return;const w=new M.McDbLine(r.x,r.y,r.z,x.x,x.y,x.z);r.y<x.y&&(w.startPoint=new M.McGePoint3d(x.x,x.y,x.z),w.endPoint=new M.McGePoint3d(r.x,r.y,r.z));const b=w.getPointAtDist(w.getLength().val/2).val,A=w.clone();A.rotate(b,Math.PI/2);const L=A.getPointAtDist(w.getLength().val/2+l/2).val,P=A.getPointAtDist(w.getLength().val/2-l/2).val;let R,F;w.offsetCurves(l/2,L).forEach(ae=>{R=ae}),w.offsetCurves(l/2,P).forEach(ae=>{F=ae});let V=w.getLength().val/e*2,j=[],J=[],ne=[];for(let ae=0;ae<V;ae++)if(ae%2==0){let ie=F.getPointAtDist(ae*(e/2)).val,le=R.getPointAtDist(ae*(e/2)).val;J.push(le),j.push(ie)}else{let ie=R.getPointAtDist(ae*(e/2)).val,le=F.getPointAtDist(ae*(e/2)).val;ne.push(le),j.push(ie)}const H=new M.McDbPolyline;j.forEach(ae=>{H.addVertexAt(ae)});const Q=M.MxCpp.App.getCurrentMxCAD();Q.drawEntity(H),J.forEach(ae=>{const ie=new M.McDbArc;ie.center=ae,ie.radius=e/2,ie.startAngle=-new M.McGeVector3d(w.endPoint.x-w.startPoint.x,w.endPoint.y-w.startPoint.y).angleTo1(M.McGeVector3d.kXAxis),ie.endAngle=new M.McGeVector3d(w.startPoint.x-w.endPoint.x,w.startPoint.y-w.endPoint.y).angleTo1(M.McGeVector3d.kXAxis),Q.drawEntity(ie)}),ne.forEach(ae=>{const ie=new M.McDbArc;ie.center=ae,ie.radius=e/2,ie.startAngle=new M.McGeVector3d(w.startPoint.x-w.endPoint.x,w.startPoint.y-w.endPoint.y).angleTo1(M.McGeVector3d.kXAxis),ie.endAngle=-new M.McGeVector3d(w.endPoint.x-w.startPoint.x,w.endPoint.y-w.startPoint.y).angleTo1(M.McGeVector3d.kXAxis),Q.drawEntity(ie)})})}function wR(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LINE");const t=new M.MxCADUiPrEntity;t.setFilter(e),t.setMessage("请选择第一条线");const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity(),c=new M.McDbLine(l.startPoint,l.endPoint),h=new M.MxCADUiPrEntity;h.setFilter(e),h.setMessage("请选择第二条线");const f=yield h.go();if(!f.id)return;const r=f.getMcDbEntity(),v=new M.McDbLine(r.startPoint,r.endPoint),x=M.MxCpp.getCurrentMxCAD();let w=l.IntersectWith(v,M.McDb.Intersect.kExtendBoth);if(console.log(w.length()),w.length()===0){const b=l.getLength().val>r.getLength().val?r.clone():l.clone(),A=l.getLength().val>r.getLength().val?c:v,L=b.clone(),P=b.getPointAtDist(b.getLength().val/2).val;if(b.rotate(P,Math.PI/2),w=b.IntersectWith(A,M.McDb.Intersect.kExtendBoth),!w.length())return;const R=w.at(0).distanceTo(P)/2;L.offsetCurves(R,w.at(0)).forEach(F=>{F.trueColor=new M.McCmColor(255,0,0),x.drawEntity(F)})}else{const b=new M.McDbCircle;let A,L=c.endPoint.distanceTo(w.at(0)),P=c.startPoint.distanceTo(w.at(0));L!==0&&P!==0&&(L>P?c.startPoint=w.at(0):c.endPoint=w.at(0));let R=v.endPoint.distanceTo(w.at(0)),F=v.startPoint.distanceTo(w.at(0));R!==0&&F!==0&&(F>R?v.startPoint=w.at(0):v.endPoint=w.at(0)),c.getLength().val>v.getLength().val?(A=v.getLength().val,new M.McDbLine(r.startPoint,v.endPoint)):(A=l.getLength().val,new M.McDbLine(c.startPoint,c.endPoint)),b.center=w.at(0),b.radius=A;let V=b.IntersectWith(c,M.McDb.Intersect.kOnBothOperands),j=b.IntersectWith(v,M.McDb.Intersect.kOnBothOperands);if(!V.length()||!j.length())return;let J=V.at(0).sub(w.at(0)).angleTo2(M.McGeVector3d.kXAxis),ne=j.at(0).sub(w.at(0)).angleTo2(M.McGeVector3d.kXAxis),H=new M.McDbArc;H.center=w.at(0),H.radius=A,H.startAngle=J,H.endAngle=ne;const Q=H.getPointAtDist(H.getLength().val/2).val,ae=new M.McDbLine(w.at(0),Q),ie=new M.MxCADUiPrPoint;ie.setMessage("请选择终点"),ie.setUserDraw((fe,me)=>{let he=ae.getClosestPointTo(fe,!0).val,Oe=ae.clone();Oe.endPoint=he,me.drawMcDbEntity(Oe)});const le=yield ie.go();if(!le)return;ae.endPoint=ae.getClosestPointTo(le,!0).val,ae.trueColor=new M.McCmColor(255,0,0),x.drawEntity(ae)}})}function MR(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LWPOLYLINE");const t=new M.MxCADUiPrEntity;t.setFilter(e),t.setMessage("请选择目标矩形");const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity();let c=[];const h=l.numVerts();for(let w=0;w<h;w++)c.push(l.getPointAt(w).val);const f=new M.MxCADUiPrPoint;let r;f.setUserDraw((w,b)=>{let A=[];c.forEach(P=>{A.push(P.distanceTo(w))}),r=A.findIndex(P=>P===Math.min(...A));let L=l.clone();L.setPointAt(r,w),b.drawMcDbEntity(L)});const v=yield f.go();if(!v)return;let x=l.clone();x.setPointAt(r,v),M.MxCpp.getCurrentMxCAD().drawEntity(x)})}function TR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("设置指北针中心点");const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrDist;if(i.setMessage("设置指北针半径"),i.setBasePt(t),i.setUserDraw((F,V)=>{const j=F.distanceTo(t);V.drawCircle(t.toVector3(),j)}),!(yield i.go()))return;const c=i.value(),h=M.MxCpp.App.getCurrentMxCAD(),f=new M.McDbCircle;f.trueColor=new M.McCmColor(0,255,0),f.center=t,f.radius=c,h.drawEntity(f);const r=new M.McGePoint3d(t.x,t.y+c),v=new M.McGePoint3d(t.x,t.y-c),x=new M.McDbLine;x.startPoint=r,x.endPoint=v;const w=x.clone();w.rotate(r,Math.PI/30);const b=x.clone();b.rotate(r,-Math.PI/30);let A,L;w.IntersectWith(f,M.McDb.Intersect.kOnBothOperands).forEach(F=>{F.x!==r.x&&F.y!==r.y&&(A=F)}),b.IntersectWith(f,M.McDb.Intersect.kOnBothOperands).forEach(F=>{F.x!==r.x&&F.y!==r.y&&(L=F)});let P=M.MxCADUtility.calcBulge(A,v,L);h.pathMoveToEx(A.x,A.y,0,0,P.val),h.pathLineTo(L.x,L.y),h.pathLineTo(r.x,r.y),h.pathLineTo(A.x,A.y),h.drawColor=new M.McCmColor(25,255,0),h.drawPathToHatch(1);const R=new M.McDbText;R.height=c/3,R.position=new M.McGePoint3d(t.x,t.y+c*1.2),R.alignmentPoint=R.position,R.textString="N",R.horizontalMode=M.McDb.TextHorzMode.kTextMid,R.trueColor=new M.McCmColor(25,255,0),h.drawEntity(R)})}function ER(){return Qe(this,null,function*(){const e=new M.MxCADUiPrKeyWord;e.setMessage("选择提示框指向"),e.setKeyWords("[向上(U)/向下(D)]");const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrPoint;let l=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();i.setMessage(`
- 指定消息框第一点:`);let c=yield i.go();if(!c)return;let h=M.MxCpp.getCurrentMxCAD(),f=new X.MxDbRect;f.pt1=c.toVector3(),i.setUserDraw((V,j)=>{f.pt2=V.toVector3(),f.setColor(l),j.drawCustomEntity(f)}),i.setMessage(`
- 指定消息框第二点:`),i.setDynamicInputType(X.DynamicInputType.kXYCoordInput);let r=yield i.go();if(!r)return;f.pt2=r.toVector3();let v=new M.McDbPolyline;v.isClosed=!0;let x;c.y>r.y&&t==="U"||c.y<r.y&&t==="D"?(x=new M.McDbLine(c,new M.McGePoint3d(r.x,c.y)),v.addVertexAt(new M.McGePoint3d(r.x,c.y)),v.addVertexAt(r),v.addVertexAt(new M.McGePoint3d(c.x,r.y)),v.addVertexAt(c)):(c.y>r.y&&t==="D"||c.y<r.y&&t==="U")&&(x=new M.McDbLine(r,new M.McGePoint3d(c.x,r.y)),v.addVertexAt(new M.McGePoint3d(c.x,r.y)),v.addVertexAt(c),v.addVertexAt(new M.McGePoint3d(r.x,c.y)),v.addVertexAt(r));const w=c.distanceTo(r)/6,b=x.getPointAtDist(w).val,A=x.getPointAtDist(x.getLength().val-w).val;x.startPoint=b,x.endPoint=A;const L=new M.MxCADUiPrPoint;L.setMessage(`
- 设置消息框指向:`);let P,R;L.setUserDraw((V,j)=>{const J=x.getClosestPointTo(V,!1).val;let ne=v.getFirstDeriv(J);if(!ne.ret)return;ne.val.normalize().mult(w/4),P=J.clone(),P.addvec(ne.val),R=J.clone(),R.subvec(ne.val);let H=v.clone();H.addVertexAt(R),H.addVertexAt(V),H.addVertexAt(P),j.drawMcDbEntity(H)});let F=yield L.go();F&&(v.addVertexAt(R),v.addVertexAt(F),v.addVertexAt(P),h.drawEntity(v))})}function CR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrString;e.setMessage("请设置基准符文字");const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrDist;if(i.setMessage("请设置文字高度"),!(yield i.go()))return;const c=i.value(),h=new M.MxCADUiPrPoint;h.setMessage("请设置基准符位置");const f=M.MxCpp.getCurrentMxCAD();let r=new M.McDbBlockReference;h.setUserDraw((x,w)=>{const b=new M.McDbPolyline;b.addVertexAt(new M.McGePoint3d(x.x+c,x.y,0),0,2,2),b.addVertexAt(new M.McGePoint3d(x.x-c,x.y,0));const A=new M.McDbLine(x,new M.McGePoint3d(x.x,x.y+c*(8/7),0)),L=new M.McDbCircle;L.center=new M.McGePoint3d(x.x,x.y+c*2.142857142857143,0),L.radius=c;const P=new M.McDbText;P.textString=t,P.height=c,P.position=P.alignmentPoint=new M.McGePoint3d(x.x,x.y+c*1.7857142857142858,0),P.horizontalMode=M.McDb.TextHorzMode.kTextMid;let F=f.getDatabase().getBlockTable().add(new M.McDbBlockTableRecord),V=F.getMcDbBlockTableRecord();V!=null&&(V.appendAcDbEntity(b),V.appendAcDbEntity(A),V.appendAcDbEntity(L),V.appendAcDbEntity(P),V.name="基准符",V.origin=x,r.blockTableRecordId=F,r.position=x,w.drawMcDbEntity(r))}),(yield h.go())&&f.drawEntity(r)})}function AR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("请设置圆心");let t=yield e.go();if(!t)return;const i=M.MxCpp.getCurrentMxCAD();for(let l=1;l<4;l++){const c=new M.McDbCircle;c.center=t,c.radius=10*l,i.drawEntity(c)}})}function DR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("请设置齿轮圆心");const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrDist;i.setBasePt(t),i.setMessage("请设置齿轮半径"),i.setUserDraw((j,J)=>{const ne=new M.McDbCircle;ne.center=t,ne.radius=j.distanceTo(t),J.drawMcDbEntity(ne)});const l=yield i.go();let c=10;l&&(c=i.value());const h=M.MxCpp.getCurrentMxCAD(),f=new M.McDbCircle;f.center=t,f.radius=c;const r=30,v=f.getLength().val/(r*2),x=new M.McGePoint3d(t.x,t.y+c,t.z),w=f.getDistAtPoint(x).val,b=f.getPointAtDist(w+v/2).val,A=f.getPointAtDist(w-v/2).val,L=[],P=new M.McDbPolyline;P.addVertexAt(b),P.addVertexAt(new M.McGePoint3d(b.x,b.y+5,b.z)),P.addVertexAt(new M.McGePoint3d(A.x,A.y+5,A.z)),P.addVertexAt(A),L.push(P);for(let j=0;j<r*2;j++){let J=P.clone(),ne=f.getPointAtDist(w+j*v);if(!ne.ret)return;let H=ne.val.sub(x),Q=new M.McGeMatrix3d;Q.setToTranslation(H),J.transformBy(Q);let le=f.getFirstDeriv(ne.val).val.rotateBy(M.McGeVector3d.kYAxis.angleTo1(M.McGeVector3d.kXAxis)).negate().angleTo2(M.McGeVector3d.kYAxis,M.McGeVector3d.kNegateZAxis);J.rotate(ne.val,le),L.push(J)}const R=[];L.forEach((j,J)=>{J%2!==0&&(j.IntersectWith(f,M.McDb.Intersect.kOnBothOperands).forEach(H=>{R.push(H)}),h.drawEntity(j))});const F=new M.McDbArc,V=new M.McGePoint3d(t.x,t.y-c,t.z);F.computeArc(b.x,b.y,V.x,V.y,A.x,A.y),F.splitCurves(R).forEach((j,J)=>{J%2!==0&&h.drawEntity(j)})})}function PR(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setFilter(e),t.setMessage("请选择目标块");const i=yield t.go();if(!i.id)return;const c=i.getMcDbEntity().getBoundingBox(),h=new M.McDbLine(c.minPt,c.maxPt),f=h.getPointAtDist(h.getLength().val/2).val,r=new M.MxCADUiPrDist;let v=10;r.setMessage(`
- 请设置中心线长度10>`),r.setBasePt(f),r.setUserDraw((V,j)=>{const J=V.distanceTo(f),ne=f.clone().addvec(M.McGeVector3d.kXAxis.normalize().mult(J)),H=f.clone().addvec(M.McGeVector3d.kXAxis.normalize().mult(J).negate()),Q=f.clone().addvec(M.McGeVector3d.kYAxis.normalize().mult(J)),ae=f.clone().addvec(M.McGeVector3d.kYAxis.normalize().mult(J).negate()),ie=new M.McDbLine(ne,H),le=new M.McDbLine(Q,ae);j.drawMcDbEntity(ie),j.drawMcDbEntity(le)}),(yield r.go())&&(v=r.value());const w=M.MxCpp.getCurrentMxCAD(),b=f.clone().addvec(M.McGeVector3d.kXAxis.normalize().mult(v)),A=f.clone().addvec(M.McGeVector3d.kXAxis.normalize().mult(v).negate()),L=f.clone().addvec(M.McGeVector3d.kYAxis.normalize().mult(v)),P=f.clone().addvec(M.McGeVector3d.kYAxis.normalize().mult(v).negate()),R=new M.McDbLine(b,A),F=new M.McDbLine(L,P);w.drawEntity(R),w.drawEntity(F)})}function SR(){X.MxFun.addCommand("Mx_DrawStart",cR),X.MxFun.addCommand("Mx_ConcavoVex",uR),X.MxFun.addCommand("Mx_ZigzagLine",hR),X.MxFun.addCommand("Mx_CenterRect",dR),X.MxFun.addCommand("Mx_BreakLine",pR),X.MxFun.addCommand("Mx_CCLine",fR),X.MxFun.addCommand("Mx_Piping",mR),X.MxFun.addCommand("Mx_CutPipeline",gR),X.MxFun.addCommand("Mx_WelLine",yR),X.MxFun.addCommand("Mx_PerpLine",_R),X.MxFun.addCommand("Mx_StairLine",vR),X.MxFun.addCommand("Mx_SolidCircle",xR),X.MxFun.addCommand("Mx_CottonInsulation",bR),X.MxFun.addCommand("Mx_CenterLine",wR),X.MxFun.addCommand("Mx_DoHole",MR),X.MxFun.addCommand("Mx_Compass",TR),X.MxFun.addCommand("Mx_MassegeBox",ER),X.MxFun.addCommand("Mx_DatumSymbol",CR),X.MxFun.addCommand("Mx_ConcentricCircles",AR),X.MxFun.addCommand("Mx_Gear",DR),X.MxFun.addCommand("Mx_BlkCenterLine",PR)}var lb={exports:{}};(function(e,t){(function(i,l){e.exports=l()})(XS,function(){var i,l,c;function h(r,v){if(!i)i=v;else if(!l)l=v;else{var x="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+i+")(sharedChunk); ("+l+")(sharedChunk); self.onerror = null;",w={};i(w),c=v(w),typeof window!="undefined"&&window&&window.URL&&window.URL.createObjectURL&&(c.workerUrl=window.URL.createObjectURL(new Blob([x],{type:"text/javascript"})))}}h(["exports"],function(r){var v="2.8.2",x=w;function w(a,n,s,u){this.cx=3*a,this.bx=3*(s-a)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*n,this.by=3*(u-n)-this.cy,this.ay=1-this.cy-this.by,this.p1x=a,this.p1y=u,this.p2x=s,this.p2y=u}w.prototype.sampleCurveX=function(a){return((this.ax*a+this.bx)*a+this.cx)*a},w.prototype.sampleCurveY=function(a){return((this.ay*a+this.by)*a+this.cy)*a},w.prototype.sampleCurveDerivativeX=function(a){return(3*this.ax*a+2*this.bx)*a+this.cx},w.prototype.solveCurveX=function(a,n){var s,u,p,g,_;for(n===void 0&&(n=1e-6),p=a,_=0;_<8;_++){if(g=this.sampleCurveX(p)-a,Math.abs(g)<n)return p;var T=this.sampleCurveDerivativeX(p);if(Math.abs(T)<1e-6)break;p-=g/T}if((p=a)<(s=0))return s;if(p>(u=1))return u;for(;s<u;){if(g=this.sampleCurveX(p),Math.abs(g-a)<n)return p;a>g?s=p:u=p,p=.5*(u-s)+s}return p},w.prototype.solve=function(a,n){return this.sampleCurveY(this.solveCurveX(a,n))};var b=A;function A(a,n){this.x=a,this.y=n}A.prototype={clone:function(){return new A(this.x,this.y)},add:function(a){return this.clone()._add(a)},sub:function(a){return this.clone()._sub(a)},multByPoint:function(a){return this.clone()._multByPoint(a)},divByPoint:function(a){return this.clone()._divByPoint(a)},mult:function(a){return this.clone()._mult(a)},div:function(a){return this.clone()._div(a)},rotate:function(a){return this.clone()._rotate(a)},rotateAround:function(a,n){return this.clone()._rotateAround(a,n)},matMult:function(a){return this.clone()._matMult(a)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(a){return this.x===a.x&&this.y===a.y},dist:function(a){return Math.sqrt(this.distSqr(a))},distSqr:function(a){var n=a.x-this.x,s=a.y-this.y;return n*n+s*s},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(a){return Math.atan2(this.y-a.y,this.x-a.x)},angleWith:function(a){return this.angleWithSep(a.x,a.y)},angleWithSep:function(a,n){return Math.atan2(this.x*n-this.y*a,this.x*a+this.y*n)},_matMult:function(a){var n=a[2]*this.x+a[3]*this.y;return this.x=a[0]*this.x+a[1]*this.y,this.y=n,this},_add:function(a){return this.x+=a.x,this.y+=a.y,this},_sub:function(a){return this.x-=a.x,this.y-=a.y,this},_mult:function(a){return this.x*=a,this.y*=a,this},_div:function(a){return this.x/=a,this.y/=a,this},_multByPoint:function(a){return this.x*=a.x,this.y*=a.y,this},_divByPoint:function(a){return this.x/=a.x,this.y/=a.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var a=this.y;return this.y=this.x,this.x=-a,this},_rotate:function(a){var n=Math.cos(a),s=Math.sin(a),u=s*this.x+n*this.y;return this.x=n*this.x-s*this.y,this.y=u,this},_rotateAround:function(a,n){var s=Math.cos(a),u=Math.sin(a),p=n.y+u*(this.x-n.x)+s*(this.y-n.y);return this.x=n.x+s*(this.x-n.x)-u*(this.y-n.y),this.y=p,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},A.convert=function(a){return a instanceof A?a:Array.isArray(a)?new A(a[0],a[1]):a};var L=typeof self!="undefined"?self:{};const P=Math.PI/180,R=180/Math.PI;function F(a){return a*P}function V(a){return a*R}const j=[[0,0],[1,0],[1,1],[0,1]];function J(a){if(a<=0)return 0;if(a>=1)return 1;const n=a*a,s=n*a;return 4*(a<.5?s:3*(a-n)+s-.75)}function ne(a,n,s,u){const p=new x(a,n,s,u);return function(g){return p.solve(g)}}const H=ne(.25,.1,.25,1);function Q(a,n,s){return Math.min(s,Math.max(n,a))}function ae(a,n,s){return(s=Q((s-a)/(n-a),0,1))*s*(3-2*s)}function ie(a,n,s){const u=s-n,p=((a-n)%u+u)%u+n;return p===n?s:p}function le(a,n,s){if(!a.length)return s(null,[]);let u=a.length;const p=new Array(a.length);let g=null;a.forEach((_,T)=>{n(_,(D,I)=>{D&&(g=D),p[T]=I,--u==0&&s(g,p)})})}function fe(a){const n=[];for(const s in a)n.push(a[s]);return n}function me(a,...n){for(const s of n)for(const u in s)a[u]=s[u];return a}let he=1;function Oe(){return he++}function Ve(){return function a(n){return n?(n^Math.random()*(16>>n/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,a)}()}function He(a){return a<=1?1:Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function at(a){return!!a&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(a)}function At(a,n){a.forEach(s=>{n[s]&&(n[s]=n[s].bind(n))})}function yt(a,n){return a.indexOf(n,a.length-n.length)!==-1}function Dt(a,n,s){const u={};for(const p in a)u[p]=n.call(s||this,a[p],p,a);return u}function It(a,n,s){const u={};for(const p in a)n.call(s||this,a[p],p,a)&&(u[p]=a[p]);return u}function Nt(a){return Array.isArray(a)?a.map(Nt):typeof a=="object"&&a?Dt(a,Nt):a}const Ie={};function be(a){Ie[a]||(typeof console!="undefined"&&console.warn(a),Ie[a]=!0)}function We(a,n,s){return(s.y-a.y)*(n.x-a.x)>(n.y-a.y)*(s.x-a.x)}function Ge(a){let n=0;for(let s,u,p=0,g=a.length,_=g-1;p<g;_=p++)s=a[p],u=a[_],n+=(u.x-s.x)*(s.y+u.y);return n}function ke(){return typeof WorkerGlobalScope!="undefined"&&typeof self!="undefined"&&self instanceof WorkerGlobalScope}function ot(a){const n={};if(a.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(s,u,p,g)=>{const _=p||g;return n[u]=!_||_.toLowerCase(),""}),n["max-age"]){const s=parseInt(n["max-age"],10);isNaN(s)?delete n["max-age"]:n["max-age"]=s}return n}let ge,Ce,Ae,_e,Ne=null;function Je(a){if(Ne==null){const n=a.navigator?a.navigator.userAgent:null;Ne=!!a.safari||!(!n||!(/\b(iPad|iPhone|iPod)\b/.test(n)||n.match("Safari")&&!n.match("Chrome")))}return Ne}function ct(a){try{const n=L[a];return n.setItem("_mapbox_test_",1),n.removeItem("_mapbox_test_"),!0}catch(n){return!1}}const wt={now:()=>Ae!==void 0?Ae:L.performance.now(),setNow(a){Ae=a},restoreNow(){Ae=void 0},frame(a){const n=L.requestAnimationFrame(a);return{cancel:()=>L.cancelAnimationFrame(n)}},getImageData(a,n=0){const{width:s,height:u}=a;_e||(_e=L.document.createElement("canvas"));const p=_e.getContext("2d");if(!p)throw new Error("failed to create canvas 2d context");return(s>_e.width||u>_e.height)&&(_e.width=s,_e.height=u),p.clearRect(-n,-n,s+2*n,u+2*n),p.drawImage(a,0,0,s,u),p.getImageData(-n,-n,s+2*n,u+2*n)},resolveURL:a=>(ge||(ge=L.document.createElement("a")),ge.href=a,ge.href),get devicePixelRatio(){return L.devicePixelRatio},get prefersReducedMotion(){return!!L.matchMedia&&(Ce==null&&(Ce=L.matchMedia("(prefers-reduced-motion: reduce)")),Ce.matches)}};let Gt;const pe={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(Gt==null){const a=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{Gt=process.env.API_URL_REGEX!=null?new RegExp(process.env.API_URL_REGEX):a}catch(n){Gt=a}}return Gt},get EVENTS_URL(){return this.API_URL?this.API_URL.indexOf("https://api.mapbox.cn")===0?"https://events.mapbox.cn/events/v2":this.API_URL.indexOf("https://api.mapbox.com")===0?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},Me={supported:!1,testSupport:function(a){!bn&>&&(hn?nn(a):bt=a)}};let bt,gt,bn=!1,hn=!1;function nn(a){const n=a.createTexture();a.bindTexture(a.TEXTURE_2D,n);try{if(a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,gt),a.isContextLost())return;Me.supported=!0}catch(s){}a.deleteTexture(n),bn=!0}L.document&&(gt=L.document.createElement("img"),gt.onload=function(){bt&&nn(bt),bt=null,hn=!0},gt.onerror=function(){bn=!0,bt=null},gt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const pn="01",wn="NO_ACCESS_TOKEN";function cn(a){return a.indexOf("mapbox:")===0}function Wt(a){return pe.API_URL_REGEX.test(a)}const sn=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Xt(a){const n=a.match(sn);if(!n)throw new Error("Unable to parse URL object");return{protocol:n[1],authority:n[2],path:n[3]||"/",params:n[4]?n[4].split("&"):[]}}function Xe(a){const n=a.params.length?`?${a.params.join("&")}`:"";return`${a.protocol}://${a.authority}${a.path}${n}`}function Ut(a){if(!a)return null;const n=a.split(".");if(!n||n.length!==3)return null;try{return JSON.parse(decodeURIComponent(L.atob(n[1]).split("").map(s=>"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(s){return null}}class en{constructor(n){this.type=n,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(n){const s=Ut(pe.ACCESS_TOKEN);let u="";return u=s&&s.u?L.btoa(encodeURIComponent(s.u).replace(/%([0-9A-F]{2})/g,(p,g)=>String.fromCharCode(+("0x"+g)))):pe.ACCESS_TOKEN||"",n?`mapbox.eventData.${n}:${u}`:`mapbox.eventData:${u}`}fetchEventData(){const n=ct("localStorage"),s=this.getStorageKey(),u=this.getStorageKey("uuid");if(n)try{const p=L.localStorage.getItem(s);p&&(this.eventData=JSON.parse(p));const g=L.localStorage.getItem(u);g&&(this.anonId=g)}catch(p){be("Unable to read from LocalStorage")}}saveEventData(){const n=ct("localStorage"),s=this.getStorageKey(),u=this.getStorageKey("uuid");if(n)try{L.localStorage.setItem(u,this.anonId),Object.keys(this.eventData).length>=1&&L.localStorage.setItem(s,JSON.stringify(this.eventData))}catch(p){be("Unable to write to LocalStorage")}}processRequests(n){}postEvent(n,s,u,p){if(!pe.EVENTS_URL)return;const g=Xt(pe.EVENTS_URL);g.params.push(`access_token=${p||pe.ACCESS_TOKEN||""}`);const _={event:this.type,created:new Date(n).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:v,skuId:pn,userId:this.anonId},T=s?me(_,s):_,D={url:Xe(g),headers:{"Content-Type":"text/plain"},body:JSON.stringify([T])};this.pendingRequest=je(D,I=>{this.pendingRequest=null,u(I),this.saveEventData(),this.processRequests(p)})}queueRequest(n,s){this.queue.push(n),this.processRequests(s)}}const Pn=new class extends en{constructor(a){super("appUserTurnstile"),this._customAccessToken=a}postTurnstileEvent(a,n){pe.EVENTS_URL&&pe.ACCESS_TOKEN&&Array.isArray(a)&&a.some(s=>cn(s)||Wt(s))&&this.queueRequest(Date.now(),n)}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const n=Ut(pe.ACCESS_TOKEN),s=n?n.u:pe.ACCESS_TOKEN;let u=s!==this.eventData.tokenU;at(this.anonId)||(this.anonId=Ve(),u=!0);const p=this.queue.shift();if(this.eventData.lastSuccess){const g=new Date(this.eventData.lastSuccess),_=new Date(p),T=(p-this.eventData.lastSuccess)/864e5;u=u||T>=1||T<-1||g.getDate()!==_.getDate()}else u=!0;u?this.postEvent(p,{"enabled.telemetry":!1},g=>{g||(this.eventData.lastSuccess=p,this.eventData.tokenU=s)},a):this.processRequests()}},fn=Pn.postTurnstileEvent.bind(Pn),On=new class extends en{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(a,n,s,u){this.skuToken=n,this.errorCb=u,pe.EVENTS_URL&&(s||pe.ACCESS_TOKEN?this.queueRequest({id:a,timestamp:Date.now()},s):this.errorCb(new Error(wn)))}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;const{id:n,timestamp:s}=this.queue.shift();n&&this.success[n]||(this.anonId||this.fetchEventData(),at(this.anonId)||(this.anonId=Ve()),this.postEvent(s,{skuToken:this.skuToken},u=>{u?this.errorCb(u):n&&(this.success[n]=!0)},a))}},Gn=On.postMapLoadEvent.bind(On),qn=new class extends en{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(a,n,s,u){if(!pe.API_URL||!pe.SESSION_PATH)return;const p=Xt(pe.API_URL+pe.SESSION_PATH);p.params.push(`sku=${n||""}`),p.params.push(`access_token=${u||pe.ACCESS_TOKEN||""}`);const g={url:Xe(p),headers:{"Content-Type":"text/plain"}};this.pendingRequest=et(g,_=>{this.pendingRequest=null,s(_),this.saveEventData(),this.processRequests(u)})}getSessionAPI(a,n,s,u){this.skuToken=n,this.errorCb=u,pe.SESSION_PATH&&pe.API_URL&&(s||pe.ACCESS_TOKEN?this.queueRequest({id:a,timestamp:Date.now()},s):this.errorCb(new Error(wn)))}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;const{id:n,timestamp:s}=this.queue.shift();n&&this.success[n]||this.getSession(s,this.skuToken,u=>{u?this.errorCb(u):n&&(this.success[n]=!0)},a)}},ji=qn.getSessionAPI.bind(qn),Nn=new Set,Di="mapbox-tiles";let ei,Ji,_i=500,jr=50;function zi(){L.caches&&!ei&&(ei=L.caches.open(Di))}function Hr(a){const n=a.indexOf("?");return n<0?a:a.slice(0,n)}let Ar=1/0;const we={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};typeof Object.freeze=="function"&&Object.freeze(we);class $ extends Error{constructor(n,s,u){s===401&&Wt(u)&&(n+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(n),this.status=s,this.url=u}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const ee=ke()?()=>self.worker&&self.worker.referrer:()=>(L.location.protocol==="blob:"?L.parent:L).location.href,ye=function(a,n){if(!(/^file:/.test(s=a.url)||/^file:/.test(ee())&&!/^\w+:/.test(s))){if(L.fetch&&L.Request&&L.AbortController&&L.Request.prototype.hasOwnProperty("signal"))return function(u,p){const g=new L.AbortController,_=new L.Request(u.url,{method:u.method||"GET",body:u.body,credentials:u.credentials,headers:u.headers,referrer:ee(),signal:g.signal});let T=!1,D=!1;const I=(z=_.url).indexOf("sku=")>0&&Wt(z);var z;u.type==="json"&&_.headers.set("Accept","application/json");const B=(W,K,oe)=>{if(D)return;if(W&&W.message!=="SecurityError"&&be(W),K&&oe)return N(K);const ue=Date.now();L.fetch(_).then(xe=>{if(xe.ok){const Be=I?xe.clone():null;return N(xe,Be,ue)}return p(new $(xe.statusText,xe.status,u.url))}).catch(xe=>{xe.code!==20&&p(new Error(xe.message))})},N=(W,K,oe)=>{(u.type==="arrayBuffer"?W.arrayBuffer():u.type==="json"?W.json():W.text()).then(ue=>{D||(K&&oe&&function(xe,Be,$e){if(zi(),!ei)return;const Ze={status:Be.status,statusText:Be.statusText,headers:new L.Headers};Be.headers.forEach((ut,dt)=>Ze.headers.set(dt,ut));const Ye=ot(Be.headers.get("Cache-Control")||"");if(Ye["no-store"])return;Ye["max-age"]&&Ze.headers.set("Expires",new Date($e+1e3*Ye["max-age"]).toUTCString());const Ke=Ze.headers.get("Expires");Ke&&(new Date(Ke).getTime()-$e<42e4||function(ut,dt){if(Ji===void 0)try{new Response(new ReadableStream),Ji=!0}catch(xt){Ji=!1}Ji?dt(ut.body):ut.blob().then(dt)}(Be,ut=>{const dt=new L.Response(ut,Ze);zi(),ei&&ei.then(xt=>xt.put(Hr(xe.url),dt)).catch(xt=>be(xt.message))}))}(_,K,oe),T=!0,p(null,ue,W.headers.get("Cache-Control"),W.headers.get("Expires")))}).catch(ue=>{D||p(new Error(ue.message))})};return I?function(W,K){if(zi(),!ei)return K(null);const oe=Hr(W.url);ei.then(ue=>{ue.match(oe).then(xe=>{const Be=function($e){if(!$e)return!1;const Ze=new Date($e.headers.get("Expires")||0),Ye=ot($e.headers.get("Cache-Control")||"");return Ze>Date.now()&&!Ye["no-cache"]}(xe);ue.delete(oe),Be&&ue.put(oe,xe.clone()),K(null,xe,Be)}).catch(K)}).catch(K)}(_,B):B(null,null),{cancel:()=>{D=!0,T||g.abort()}}}(a,n);if(ke()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",a,n,void 0,!0)}var s;return function(u,p){const g=new L.XMLHttpRequest;g.open(u.method||"GET",u.url,!0),u.type==="arrayBuffer"&&(g.responseType="arraybuffer");for(const _ in u.headers)g.setRequestHeader(_,u.headers[_]);return u.type==="json"&&(g.responseType="text",g.setRequestHeader("Accept","application/json")),g.withCredentials=u.credentials==="include",g.onerror=()=>{p(new Error(g.statusText))},g.onload=()=>{if((g.status>=200&&g.status<300||g.status===0)&&g.response!==null){let _=g.response;if(u.type==="json")try{_=JSON.parse(g.response)}catch(T){return p(T)}p(null,_,g.getResponseHeader("Cache-Control"),g.getResponseHeader("Expires"))}else p(new $(g.statusText,g.status,u.url))},g.send(u.body),{cancel:()=>g.abort()}}(a,n)},Re=function(a,n){return ye(me(a,{type:"arrayBuffer"}),n)},je=function(a,n){return ye(me(a,{method:"POST"}),n)},et=function(a,n){return ye(me(a,{method:"GET"}),n)};function tt(a){const n=L.document.createElement("a");return n.href=a,n.protocol===L.document.location.protocol&&n.host===L.document.location.host}const qe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let rt,vt;rt=[],vt=0;const Vt=function(a,n){if(Me.supported&&(a.headers||(a.headers={}),a.headers.accept="image/webp,*/*"),vt>=pe.MAX_PARALLEL_IMAGE_REQUESTS){const g={requestParameters:a,callback:n,cancelled:!1,cancel(){this.cancelled=!0}};return rt.push(g),g}vt++;let s=!1;const u=()=>{if(!s)for(s=!0,vt--;rt.length&&vt<pe.MAX_PARALLEL_IMAGE_REQUESTS;){const g=rt.shift(),{requestParameters:_,callback:T,cancelled:D}=g;D||(g.cancel=Vt(_,T).cancel)}},p=Re(a,(g,_,T,D)=>{u(),g?n(g):_&&(L.createImageBitmap?function(I,z){const B=new L.Blob([new Uint8Array(I)],{type:"image/png"});L.createImageBitmap(B).then(N=>{z(null,N)}).catch(N=>{z(new Error(`Could not load image because of ${N.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(_,(I,z)=>n(I,z,T,D)):function(I,z){const B=new L.Image,N=L.URL;B.onload=()=>{z(null,B),N.revokeObjectURL(B.src),B.onload=null,L.requestAnimationFrame(()=>{B.src=qe})},B.onerror=()=>z(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const W=new L.Blob([new Uint8Array(I)],{type:"image/png"});B.src=I.byteLength?N.createObjectURL(W):qe}(_,(I,z)=>n(I,z,T,D)))});return{cancel:()=>{p.cancel(),u()}}};function Ct(a,n,s){s[a]&&s[a].indexOf(n)!==-1||(s[a]=s[a]||[],s[a].push(n))}function _n(a,n,s){if(s&&s[a]){const u=s[a].indexOf(n);u!==-1&&s[a].splice(u,1)}}class Y{constructor(n,s={}){me(this,s),this.type=n}}class re extends Y{constructor(n,s={}){super("error",me({error:n},s))}}class Fe{on(n,s){return this._listeners=this._listeners||{},Ct(n,s,this._listeners),this}off(n,s){return _n(n,s,this._listeners),_n(n,s,this._oneTimeListeners),this}once(n,s){return s?(this._oneTimeListeners=this._oneTimeListeners||{},Ct(n,s,this._oneTimeListeners),this):new Promise(u=>this.once(n,u))}fire(n,s){typeof n=="string"&&(n=new Y(n,s||{}));const u=n.type;if(this.listens(u)){n.target=this;const p=this._listeners&&this._listeners[u]?this._listeners[u].slice():[];for(const T of p)T.call(this,n);const g=this._oneTimeListeners&&this._oneTimeListeners[u]?this._oneTimeListeners[u].slice():[];for(const T of g)_n(u,T,this._oneTimeListeners),T.call(this,n);const _=this._eventedParent;_&&(me(n,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),_.fire(n))}else n instanceof re&&console.error(n.error);return this}listens(n){return!!(this._listeners&&this._listeners[n]&&this._listeners[n].length>0||this._oneTimeListeners&&this._oneTimeListeners[n]&&this._oneTimeListeners[n].length>0||this._eventedParent&&this._eventedParent.listens(n))}setEventedParent(n,s){return this._eventedParent=n,this._eventedParentData=s,this}}var Te=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":0.1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function Tt(a,...n){for(const s of n)for(const u in s)a[u]=s[u];return a}function _t(a){return a instanceof Number||a instanceof String||a instanceof Boolean?a.valueOf():a}function Ot(a){if(Array.isArray(a))return a.map(Ot);if(a instanceof Object&&!(a instanceof Number||a instanceof String||a instanceof Boolean)){const n={};for(const s in a)n[s]=Ot(a[s]);return n}return _t(a)}class rn extends Error{constructor(n,s){super(s),this.message=s,this.key=n}}class Sn{constructor(n,s=[]){this.parent=n,this.bindings={};for(const[u,p]of s)this.bindings[u]=p}concat(n){return new Sn(this,n)}get(n){if(this.bindings[n])return this.bindings[n];if(this.parent)return this.parent.get(n);throw new Error(`${n} not found in scope.`)}has(n){return!!this.bindings[n]||!!this.parent&&this.parent.has(n)}}const Ln={kind:"null"},Mt={kind:"number"},un={kind:"string"},Kt={kind:"boolean"},mn={kind:"color"},Tn={kind:"object"},Cn={kind:"value"},di={kind:"collator"},Dr={kind:"formatted"},oi={kind:"resolvedImage"};function li(a,n){return{kind:"array",itemType:a,N:n}}function ai(a){if(a.kind==="array"){const n=ai(a.itemType);return typeof a.N=="number"?`array<${n}, ${a.N}>`:a.itemType.kind==="value"?"array":`array<${n}>`}return a.kind}const xs=[Ln,Mt,un,Kt,mn,Dr,Tn,li(Cn),oi];function ko(a,n){if(n.kind==="error")return null;if(a.kind==="array"){if(n.kind==="array"&&(n.N===0&&n.itemType.kind==="value"||!ko(a.itemType,n.itemType))&&(typeof a.N!="number"||a.N===n.N))return null}else{if(a.kind===n.kind)return null;if(a.kind==="value"){for(const s of xs)if(!ko(s,n))return null}}return`Expected ${ai(a)} but found ${ai(n)} instead.`}function uu(a,n){return n.some(s=>s.kind===a.kind)}function bs(a,n){return n.some(s=>s==="null"?a===null:s==="array"?Array.isArray(a):s==="object"?a&&!Array.isArray(a)&&typeof a=="object":s===typeof a)}function hu(a){var n={exports:{}};return a(n,n.exports),n.exports}var Cd=hu(function(a,n){var s={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function u(T){return(T=Math.round(T))<0?0:T>255?255:T}function p(T){return u(T[T.length-1]==="%"?parseFloat(T)/100*255:parseInt(T))}function g(T){return(D=T[T.length-1]==="%"?parseFloat(T)/100:parseFloat(T))<0?0:D>1?1:D;var D}function _(T,D,I){return I<0?I+=1:I>1&&(I-=1),6*I<1?T+(D-T)*I*6:2*I<1?D:3*I<2?T+(D-T)*(2/3-I)*6:T}try{n.parseCSSColor=function(T){var D,I=T.replace(/ /g,"").toLowerCase();if(I in s)return s[I].slice();if(I[0]==="#")return I.length===4?(D=parseInt(I.substr(1),16))>=0&&D<=4095?[(3840&D)>>4|(3840&D)>>8,240&D|(240&D)>>4,15&D|(15&D)<<4,1]:null:I.length===7&&(D=parseInt(I.substr(1),16))>=0&&D<=16777215?[(16711680&D)>>16,(65280&D)>>8,255&D,1]:null;var z=I.indexOf("("),B=I.indexOf(")");if(z!==-1&&B+1===I.length){var N=I.substr(0,z),W=I.substr(z+1,B-(z+1)).split(","),K=1;switch(N){case"rgba":if(W.length!==4)return null;K=g(W.pop());case"rgb":return W.length!==3?null:[p(W[0]),p(W[1]),p(W[2]),K];case"hsla":if(W.length!==4)return null;K=g(W.pop());case"hsl":if(W.length!==3)return null;var oe=(parseFloat(W[0])%360+360)%360/360,ue=g(W[1]),xe=g(W[2]),Be=xe<=.5?xe*(ue+1):xe+ue-xe*ue,$e=2*xe-Be;return[u(255*_($e,Be,oe+1/3)),u(255*_($e,Be,oe)),u(255*_($e,Be,oe-1/3)),K];default:return null}}return null}}catch(T){}});class Xn{constructor(n,s,u,p=1){this.r=n,this.g=s,this.b=u,this.a=p}static parse(n){if(!n)return;if(n instanceof Xn)return n;if(typeof n!="string")return;const s=Cd.parseCSSColor(n);return s?new Xn(s[0]/255*s[3],s[1]/255*s[3],s[2]/255*s[3],s[3]):void 0}toString(){const[n,s,u,p]=this.toArray();return`rgba(${Math.round(n)},${Math.round(s)},${Math.round(u)},${p})`}toArray(){const{r:n,g:s,b:u,a:p}=this;return p===0?[0,0,0,0]:[255*n/p,255*s/p,255*u/p,p]}}Xn.black=new Xn(0,0,0,1),Xn.white=new Xn(1,1,1,1),Xn.transparent=new Xn(0,0,0,0),Xn.red=new Xn(1,0,0,1),Xn.blue=new Xn(0,0,1,1);class ws{constructor(n,s,u){this.sensitivity=n?s?"variant":"case":s?"accent":"base",this.locale=u,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(n,s){return this.collator.compare(n,s)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Ad{constructor(n,s,u,p,g){this.text=n.normalize?n.normalize():n,this.image=s,this.scale=u,this.fontStack=p,this.textColor=g}}class Fi{constructor(n){this.sections=n}static fromString(n){return new Fi([new Ad(n,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(n=>n.text.length!==0||n.image&&n.image.name.length!==0)}static factory(n){return n instanceof Fi?n:Fi.fromString(n)}toString(){return this.sections.length===0?"":this.sections.map(n=>n.text).join("")}serialize(){const n=["format"];for(const s of this.sections){if(s.image){n.push(["image",s.image.name]);continue}n.push(s.text);const u={};s.fontStack&&(u["text-font"]=["literal",s.fontStack.split(",")]),s.scale&&(u["font-scale"]=s.scale),s.textColor&&(u["text-color"]=["rgba"].concat(s.textColor.toArray())),n.push(u)}return n}}class Pr{constructor(n){this.name=n.name,this.available=n.available}toString(){return this.name}static fromString(n){return n?new Pr({name:n,available:!1}):null}serialize(){return["image",this.name]}}function ho(a,n,s,u){return typeof a=="number"&&a>=0&&a<=255&&typeof n=="number"&&n>=0&&n<=255&&typeof s=="number"&&s>=0&&s<=255?u===void 0||typeof u=="number"&&u>=0&&u<=1?null:`Invalid rgba value [${[a,n,s,u].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof u=="number"?[a,n,s,u]:[a,n,s]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function du(a){if(a===null||typeof a=="string"||typeof a=="boolean"||typeof a=="number"||a instanceof Xn||a instanceof ws||a instanceof Fi||a instanceof Pr)return!0;if(Array.isArray(a)){for(const n of a)if(!du(n))return!1;return!0}if(typeof a=="object"){for(const n in a)if(!du(a[n]))return!1;return!0}return!1}function Pi(a){if(a===null)return Ln;if(typeof a=="string")return un;if(typeof a=="boolean")return Kt;if(typeof a=="number")return Mt;if(a instanceof Xn)return mn;if(a instanceof ws)return di;if(a instanceof Fi)return Dr;if(a instanceof Pr)return oi;if(Array.isArray(a)){const n=a.length;let s;for(const u of a){const p=Pi(u);if(s){if(s===p)continue;s=Cn;break}s=p}return li(s||Cn,n)}return Tn}function zo(a){const n=typeof a;return a===null?"":n==="string"||n==="number"||n==="boolean"?String(a):a instanceof Xn||a instanceof Fi||a instanceof Pr?a.toString():JSON.stringify(a)}class Fo{constructor(n,s){this.type=n,this.value=s}static parse(n,s){if(n.length!==2)return s.error(`'literal' expression requires exactly one argument, but found ${n.length-1} instead.`);if(!du(n[1]))return s.error("invalid value");const u=n[1];let p=Pi(u);const g=s.expectedType;return p.kind!=="array"||p.N!==0||!g||g.kind!=="array"||typeof g.N=="number"&&g.N!==0||(p=g),new Fo(p,u)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof Xn?["rgba"].concat(this.value.toArray()):this.value instanceof Fi?this.value.serialize():this.value}}class Qi{constructor(n){this.name="ExpressionEvaluationError",this.message=n}toJSON(){return this.message}}const Dd={string:un,number:Mt,boolean:Kt,object:Tn};class po{constructor(n,s){this.type=n,this.args=s}static parse(n,s){if(n.length<2)return s.error("Expected at least one argument.");let u,p=1;const g=n[0];if(g==="array"){let T,D;if(n.length>2){const I=n[1];if(typeof I!="string"||!(I in Dd)||I==="object")return s.error('The item type argument of "array" must be one of string, number, boolean',1);T=Dd[I],p++}else T=Cn;if(n.length>3){if(n[2]!==null&&(typeof n[2]!="number"||n[2]<0||n[2]!==Math.floor(n[2])))return s.error('The length argument to "array" must be a positive integer literal',2);D=n[2],p++}u=li(T,D)}else u=Dd[g];const _=[];for(;p<n.length;p++){const T=s.parse(n[p],p,Cn);if(!T)return null;_.push(T)}return new po(u,_)}evaluate(n){for(let s=0;s<this.args.length;s++){const u=this.args[s].evaluate(n);if(!ko(this.type,Pi(u)))return u;if(s===this.args.length-1)throw new Qi(`Expected value to be of type ${ai(this.type)}, but found ${ai(Pi(u))} instead.`)}return null}eachChild(n){this.args.forEach(n)}outputDefined(){return this.args.every(n=>n.outputDefined())}serialize(){const n=this.type,s=[n.kind];if(n.kind==="array"){const u=n.itemType;if(u.kind==="string"||u.kind==="number"||u.kind==="boolean"){s.push(u.kind);const p=n.N;(typeof p=="number"||this.args.length>1)&&s.push(p)}}return s.concat(this.args.map(u=>u.serialize()))}}class Ms{constructor(n){this.type=Dr,this.sections=n}static parse(n,s){if(n.length<2)return s.error("Expected at least one argument.");const u=n[1];if(!Array.isArray(u)&&typeof u=="object")return s.error("First argument must be an image or text section.");const p=[];let g=!1;for(let _=1;_<=n.length-1;++_){const T=n[_];if(g&&typeof T=="object"&&!Array.isArray(T)){g=!1;let D=null;if(T["font-scale"]&&(D=s.parse(T["font-scale"],1,Mt),!D))return null;let I=null;if(T["text-font"]&&(I=s.parse(T["text-font"],1,li(un)),!I))return null;let z=null;if(T["text-color"]&&(z=s.parse(T["text-color"],1,mn),!z))return null;const B=p[p.length-1];B.scale=D,B.font=I,B.textColor=z}else{const D=s.parse(n[_],1,Cn);if(!D)return null;const I=D.type.kind;if(I!=="string"&&I!=="value"&&I!=="null"&&I!=="resolvedImage")return s.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");g=!0,p.push({content:D,scale:null,font:null,textColor:null})}}return new Ms(p)}evaluate(n){return new Fi(this.sections.map(s=>{const u=s.content.evaluate(n);return Pi(u)===oi?new Ad("",u,null,null,null):new Ad(zo(u),null,s.scale?s.scale.evaluate(n):null,s.font?s.font.evaluate(n).join(","):null,s.textColor?s.textColor.evaluate(n):null)}))}eachChild(n){for(const s of this.sections)n(s.content),s.scale&&n(s.scale),s.font&&n(s.font),s.textColor&&n(s.textColor)}outputDefined(){return!1}serialize(){const n=["format"];for(const s of this.sections){n.push(s.content.serialize());const u={};s.scale&&(u["font-scale"]=s.scale.serialize()),s.font&&(u["text-font"]=s.font.serialize()),s.textColor&&(u["text-color"]=s.textColor.serialize()),n.push(u)}return n}}class Ts{constructor(n){this.type=oi,this.input=n}static parse(n,s){if(n.length!==2)return s.error("Expected two arguments.");const u=s.parse(n[1],1,un);return u?new Ts(u):s.error("No image name provided.")}evaluate(n){const s=this.input.evaluate(n),u=Pr.fromString(s);return u&&n.availableImages&&(u.available=n.availableImages.indexOf(s)>-1),u}eachChild(n){n(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const $_={"to-boolean":Kt,"to-color":mn,"to-number":Mt,"to-string":un};class fo{constructor(n,s){this.type=n,this.args=s}static parse(n,s){if(n.length<2)return s.error("Expected at least one argument.");const u=n[0];if((u==="to-boolean"||u==="to-string")&&n.length!==2)return s.error("Expected one argument.");const p=$_[u],g=[];for(let _=1;_<n.length;_++){const T=s.parse(n[_],_,Cn);if(!T)return null;g.push(T)}return new fo(p,g)}evaluate(n){if(this.type.kind==="boolean")return!!this.args[0].evaluate(n);if(this.type.kind==="color"){let s,u;for(const p of this.args){if(s=p.evaluate(n),u=null,s instanceof Xn)return s;if(typeof s=="string"){const g=n.parseColor(s);if(g)return g}else if(Array.isArray(s)&&(u=s.length<3||s.length>4?`Invalid rbga value ${JSON.stringify(s)}: expected an array containing either three or four numeric values.`:ho(s[0],s[1],s[2],s[3]),!u))return new Xn(s[0]/255,s[1]/255,s[2]/255,s[3])}throw new Qi(u||`Could not parse color from value '${typeof s=="string"?s:String(JSON.stringify(s))}'`)}if(this.type.kind==="number"){let s=null;for(const u of this.args){if(s=u.evaluate(n),s===null)return 0;const p=Number(s);if(!isNaN(p))return p}throw new Qi(`Could not convert ${JSON.stringify(s)} to number.`)}return this.type.kind==="formatted"?Fi.fromString(zo(this.args[0].evaluate(n))):this.type.kind==="resolvedImage"?Pr.fromString(zo(this.args[0].evaluate(n))):zo(this.args[0].evaluate(n))}eachChild(n){this.args.forEach(n)}outputDefined(){return this.args.every(n=>n.outputDefined())}serialize(){if(this.type.kind==="formatted")return new Ms([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Ts(this.args[0]).serialize();const n=[`to-${this.type.kind}`];return this.eachChild(s=>{n.push(s.serialize())}),n}}const q_=["Unknown","Point","LineString","Polygon"];class Lm{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&"id"in this.feature&&this.feature.id?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?q_[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const n=this.featureDistanceData.center,s=this.featureDistanceData.scale,{x:u,y:p}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(u*s-n[0])+this.featureDistanceData.bearing[1]*(p*s-n[1])}return 0}parseColor(n){let s=this._parseColorCache[n];return s||(s=this._parseColorCache[n]=Xn.parse(n)),s}}class Sr{constructor(n,s,u,p){this.name=n,this.type=s,this._evaluate=u,this.args=p}evaluate(n){return this._evaluate(n,this.args)}eachChild(n){this.args.forEach(n)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(n=>n.serialize()))}static parse(n,s){const u=n[0],p=Sr.definitions[u];if(!p)return s.error(`Unknown expression "${u}". If you wanted a literal array, use ["literal", [...]].`,0);const g=Array.isArray(p)?p[0]:p.type,_=Array.isArray(p)?[[p[1],p[2]]]:p.overloads,T=_.filter(([I])=>!Array.isArray(I)||I.length===n.length-1);let D=null;for(const[I,z]of T){D=new oa(s.registry,s.path,null,s.scope);const B=[];let N=!1;for(let W=1;W<n.length;W++){const K=n[W],oe=Array.isArray(I)?I[W-1]:I.type,ue=D.parse(K,1+B.length,oe);if(!ue){N=!0;break}B.push(ue)}if(!N)if(Array.isArray(I)&&I.length!==B.length)D.error(`Expected ${I.length} arguments, but found ${B.length} instead.`);else{for(let W=0;W<B.length;W++){const K=Array.isArray(I)?I[W]:I.type,oe=B[W];D.concat(W+1).checkSubtype(K,oe.type)}if(D.errors.length===0)return new Sr(u,g,z,B)}}if(T.length===1)s.errors.push(...D.errors);else{const I=(T.length?T:_).map(([B])=>{return N=B,Array.isArray(N)?`(${N.map(ai).join(", ")})`:`(${ai(N.type)}...)`;var N}).join(" | "),z=[];for(let B=1;B<n.length;B++){const N=s.parse(n[B],1+z.length);if(!N)return null;z.push(ai(N.type))}s.error(`Expected arguments of type ${I}, but found (${z.join(", ")}) instead.`)}return null}static register(n,s){Sr.definitions=s;for(const u in s)n[u]=Sr}}class pu{constructor(n,s,u){this.type=di,this.locale=u,this.caseSensitive=n,this.diacriticSensitive=s}static parse(n,s){if(n.length!==2)return s.error("Expected one argument.");const u=n[1];if(typeof u!="object"||Array.isArray(u))return s.error("Collator options argument must be an object.");const p=s.parse(u["case-sensitive"]!==void 0&&u["case-sensitive"],1,Kt);if(!p)return null;const g=s.parse(u["diacritic-sensitive"]!==void 0&&u["diacritic-sensitive"],1,Kt);if(!g)return null;let _=null;return u.locale&&(_=s.parse(u.locale,1,un),!_)?null:new pu(p,g,_)}evaluate(n){return new ws(this.caseSensitive.evaluate(n),this.diacriticSensitive.evaluate(n),this.locale?this.locale.evaluate(n):null)}eachChild(n){n(this.caseSensitive),n(this.diacriticSensitive),this.locale&&n(this.locale)}outputDefined(){return!1}serialize(){const n={};return n["case-sensitive"]=this.caseSensitive.serialize(),n["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(n.locale=this.locale.serialize()),["collator",n]}}const ra=8192;function Pd(a,n){a[0]=Math.min(a[0],n[0]),a[1]=Math.min(a[1],n[1]),a[2]=Math.max(a[2],n[0]),a[3]=Math.max(a[3],n[1])}function fu(a,n){return!(a[0]<=n[0]||a[2]>=n[2]||a[1]<=n[1]||a[3]>=n[3])}function Im(a,n){const s=(180+a[0])/360,u=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a[1]*Math.PI/360)))/360,p=Math.pow(2,n.z);return[Math.round(s*p*ra),Math.round(u*p*ra)]}function mu(a,n,s){const u=a[0]-n[0],p=a[1]-n[1],g=a[0]-s[0],_=a[1]-s[1];return u*_-g*p==0&&u*g<=0&&p*_<=0}function Sd(a,n){let s=!1;for(let _=0,T=n.length;_<T;_++){const D=n[_];for(let I=0,z=D.length;I<z-1;I++){if(mu(a,D[I],D[I+1]))return!1;(p=D[I])[1]>(u=a)[1]!=(g=D[I+1])[1]>u[1]&&u[0]<(g[0]-p[0])*(u[1]-p[1])/(g[1]-p[1])+p[0]&&(s=!s)}}var u,p,g;return s}function X_(a,n){for(let s=0;s<n.length;s++)if(Sd(a,n[s]))return!0;return!1}function Rm(a,n,s,u){const p=u[0]-s[0],g=u[1]-s[1],_=(a[0]-s[0])*g-p*(a[1]-s[1]),T=(n[0]-s[0])*g-p*(n[1]-s[1]);return _>0&&T<0||_<0&&T>0}function Z_(a,n,s){for(const I of s)for(let z=0;z<I.length-1;++z)if((T=[(_=I[z+1])[0]-(g=I[z])[0],_[1]-g[1]])[0]*(D=[(p=n)[0]-(u=a)[0],p[1]-u[1]])[1]-T[1]*D[0]!=0&&Rm(u,p,g,_)&&Rm(g,_,u,p))return!0;var u,p,g,_,T,D;return!1}function km(a,n){for(let s=0;s<a.length;++s)if(!Sd(a[s],n))return!1;for(let s=0;s<a.length-1;++s)if(Z_(a[s],a[s+1],n))return!1;return!0}function Y_(a,n){for(let s=0;s<n.length;s++)if(km(a,n[s]))return!0;return!1}function gu(a,n,s){const u=[];for(let p=0;p<a.length;p++){const g=[];for(let _=0;_<a[p].length;_++){const T=Im(a[p][_],s);Pd(n,T),g.push(T)}u.push(g)}return u}function bl(a,n,s){const u=[];for(let p=0;p<a.length;p++){const g=gu(a[p],n,s);u.push(g)}return u}function zm(a,n,s,u){if(a[0]<s[0]||a[0]>s[2]){const p=.5*u;let g=a[0]-s[0]>p?-u:s[0]-a[0]>p?u:0;g===0&&(g=a[0]-s[2]>p?-u:s[2]-a[0]>p?u:0),a[0]+=g}Pd(n,a)}function Fm(a,n,s,u){const p=Math.pow(2,u.z)*ra,g=[u.x*ra,u.y*ra],_=[];if(!a)return _;for(const T of a)for(const D of T){const I=[D.x+g[0],D.y+g[1]];zm(I,n,s,p),_.push(I)}return _}function Bm(a,n,s,u){const p=Math.pow(2,u.z)*ra,g=[u.x*ra,u.y*ra],_=[];if(!a)return _;for(const D of a){const I=[];for(const z of D){const B=[z.x+g[0],z.y+g[1]];Pd(n,B),I.push(B)}_.push(I)}if(n[2]-n[0]<=p/2){(T=n)[0]=T[1]=1/0,T[2]=T[3]=-1/0;for(const D of _)for(const I of D)zm(I,n,s,p)}var T;return _}class Na{constructor(n,s){this.type=Kt,this.geojson=n,this.geometries=s}static parse(n,s){if(n.length!==2)return s.error(`'within' expression requires exactly one argument, but found ${n.length-1} instead.`);if(du(n[1])){const u=n[1];if(u.type==="FeatureCollection")for(let p=0;p<u.features.length;++p){const g=u.features[p].geometry.type;if(g==="Polygon"||g==="MultiPolygon")return new Na(u,u.features[p].geometry)}else if(u.type==="Feature"){const p=u.geometry.type;if(p==="Polygon"||p==="MultiPolygon")return new Na(u,u.geometry)}else if(u.type==="Polygon"||u.type==="MultiPolygon")return new Na(u,u)}return s.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(n){if(n.geometry()!=null&&n.canonicalID()!=null){if(n.geometryType()==="Point")return function(s,u){const p=[1/0,1/0,-1/0,-1/0],g=[1/0,1/0,-1/0,-1/0],_=s.canonicalID();if(!_)return!1;if(u.type==="Polygon"){const T=gu(u.coordinates,g,_),D=Fm(s.geometry(),p,g,_);if(!fu(p,g))return!1;for(const I of D)if(!Sd(I,T))return!1}if(u.type==="MultiPolygon"){const T=bl(u.coordinates,g,_),D=Fm(s.geometry(),p,g,_);if(!fu(p,g))return!1;for(const I of D)if(!X_(I,T))return!1}return!0}(n,this.geometries);if(n.geometryType()==="LineString")return function(s,u){const p=[1/0,1/0,-1/0,-1/0],g=[1/0,1/0,-1/0,-1/0],_=s.canonicalID();if(!_)return!1;if(u.type==="Polygon"){const T=gu(u.coordinates,g,_),D=Bm(s.geometry(),p,g,_);if(!fu(p,g))return!1;for(const I of D)if(!km(I,T))return!1}if(u.type==="MultiPolygon"){const T=bl(u.coordinates,g,_),D=Bm(s.geometry(),p,g,_);if(!fu(p,g))return!1;for(const I of D)if(!Y_(I,T))return!1}return!0}(n,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}function yr(a){if(a instanceof Sr&&(a.name==="get"&&a.args.length===1||a.name==="feature-state"||a.name==="has"&&a.args.length===1||a.name==="properties"||a.name==="geometry-type"||a.name==="id"||/^filter-/.test(a.name))||a instanceof Na)return!1;let n=!0;return a.eachChild(s=>{n&&!yr(s)&&(n=!1)}),n}function wl(a){if(a instanceof Sr&&a.name==="feature-state")return!1;let n=!0;return a.eachChild(s=>{n&&!wl(s)&&(n=!1)}),n}function Ml(a,n){if(a instanceof Sr&&n.indexOf(a.name)>=0)return!1;let s=!0;return a.eachChild(u=>{s&&!Ml(u,n)&&(s=!1)}),s}class Ua{constructor(n,s){this.type=s.type,this.name=n,this.boundExpression=s}static parse(n,s){if(n.length!==2||typeof n[1]!="string")return s.error("'var' expression requires exactly one string literal argument.");const u=n[1];return s.scope.has(u)?new Ua(u,s.scope.get(u)):s.error(`Unknown variable "${u}". Make sure "${u}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(n){return this.boundExpression.evaluate(n)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class oa{constructor(n,s=[],u,p=new Sn,g=[]){this.registry=n,this.path=s,this.key=s.map(_=>`[${_}]`).join(""),this.scope=p,this.errors=g,this.expectedType=u}parse(n,s,u,p,g={}){return s?this.concat(s,u,p)._parse(n,g):this._parse(n,g)}_parse(n,s){function u(p,g,_){return _==="assert"?new po(g,[p]):_==="coerce"?new fo(g,[p]):p}if(n!==null&&typeof n!="string"&&typeof n!="boolean"&&typeof n!="number"||(n=["literal",n]),Array.isArray(n)){if(n.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const p=n[0];if(typeof p!="string")return this.error(`Expression name must be a string, but found ${typeof p} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const g=this.registry[p];if(g){let _=g.parse(n,this);if(!_)return null;if(this.expectedType){const T=this.expectedType,D=_.type;if(T.kind!=="string"&&T.kind!=="number"&&T.kind!=="boolean"&&T.kind!=="object"&&T.kind!=="array"||D.kind!=="value")if(T.kind!=="color"&&T.kind!=="formatted"&&T.kind!=="resolvedImage"||D.kind!=="value"&&D.kind!=="string"){if(this.checkSubtype(T,D))return null}else _=u(_,T,s.typeAnnotation||"coerce");else _=u(_,T,s.typeAnnotation||"assert")}if(!(_ instanceof Fo)&&_.type.kind!=="resolvedImage"&&yu(_)){const T=new Lm;try{_=new Fo(_.type,_.evaluate(T))}catch(D){return this.error(D.message),null}}return _}return this.error(`Unknown expression "${p}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(n===void 0?"'undefined' value invalid. Use null instead.":typeof n=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof n} instead.`)}concat(n,s,u){const p=typeof n=="number"?this.path.concat(n):this.path,g=u?this.scope.concat(u):this.scope;return new oa(this.registry,p,s||null,g,this.errors)}error(n,...s){const u=`${this.key}${s.map(p=>`[${p}]`).join("")}`;this.errors.push(new rn(u,n))}checkSubtype(n,s){const u=ko(n,s);return u&&this.error(u),u}}function yu(a){if(a instanceof Ua)return yu(a.boundExpression);if(a instanceof Sr&&a.name==="error"||a instanceof pu||a instanceof Na)return!1;const n=a instanceof fo||a instanceof po;let s=!0;return a.eachChild(u=>{s=n?s&&yu(u):s&&u instanceof Fo}),!!s&&yr(a)&&Ml(a,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function Tl(a,n){const s=a.length-1;let u,p,g=0,_=s,T=0;for(;g<=_;)if(T=Math.floor((g+_)/2),u=a[T],p=a[T+1],u<=n){if(T===s||n<p)return T;g=T+1}else{if(!(u>n))throw new Qi("Input is not a number.");_=T-1}return 0}class El{constructor(n,s,u){this.type=n,this.input=s,this.labels=[],this.outputs=[];for(const[p,g]of u)this.labels.push(p),this.outputs.push(g)}static parse(n,s){if(n.length-1<4)return s.error(`Expected at least 4 arguments, but found only ${n.length-1}.`);if((n.length-1)%2!=0)return s.error("Expected an even number of arguments.");const u=s.parse(n[1],1,Mt);if(!u)return null;const p=[];let g=null;s.expectedType&&s.expectedType.kind!=="value"&&(g=s.expectedType);for(let _=1;_<n.length;_+=2){const T=_===1?-1/0:n[_],D=n[_+1],I=_,z=_+1;if(typeof T!="number")return s.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',I);if(p.length&&p[p.length-1][0]>=T)return s.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',I);const B=s.parse(D,z,g);if(!B)return null;g=g||B.type,p.push([T,B])}return new El(g,u,p)}evaluate(n){const s=this.labels,u=this.outputs;if(s.length===1)return u[0].evaluate(n);const p=this.input.evaluate(n);if(p<=s[0])return u[0].evaluate(n);const g=s.length;return p>=s[g-1]?u[g-1].evaluate(n):u[Tl(s,p)].evaluate(n)}eachChild(n){n(this.input);for(const s of this.outputs)n(s)}outputDefined(){return this.outputs.every(n=>n.outputDefined())}serialize(){const n=["step",this.input.serialize()];for(let s=0;s<this.labels.length;s++)s>0&&n.push(this.labels[s]),n.push(this.outputs[s].serialize());return n}}function yn(a,n,s){return a*(1-s)+n*s}var _u=Object.freeze({__proto__:null,number:yn,color:function(a,n,s){return new Xn(yn(a.r,n.r,s),yn(a.g,n.g,s),yn(a.b,n.b,s),yn(a.a,n.a,s))},array:function(a,n,s){return a.map((u,p)=>yn(u,n[p],s))}});const Om=.95047,Nm=1.08883,Ld=4/29,Id=6/29,Rd=3*Id*Id,Um=Math.PI/180,Vm=180/Math.PI;function vu(a){return a>.008856451679035631?Math.pow(a,.3333333333333333):a/Rd+Ld}function aa(a){return a>Id?a*a*a:Rd*(a-Ld)}function Es(a){return 255*(a<=.0031308?12.92*a:1.055*Math.pow(a,.4166666666666667)-.055)}function kd(a){return(a/=255)<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}function xu(a){const n=kd(a.r),s=kd(a.g),u=kd(a.b),p=vu((.4124564*n+.3575761*s+.1804375*u)/Om),g=vu((.2126729*n+.7151522*s+.072175*u)/1);return{l:116*g-16,a:500*(p-g),b:200*(g-vu((.0193339*n+.119192*s+.9503041*u)/Nm)),alpha:a.a}}function zd(a){let n=(a.l+16)/116,s=isNaN(a.a)?n:n+a.a/500,u=isNaN(a.b)?n:n-a.b/200;return n=1*aa(n),s=Om*aa(s),u=Nm*aa(u),new Xn(Es(3.2404542*s-1.5371385*n-.4985314*u),Es(-.969266*s+1.8760108*n+.041556*u),Es(.0556434*s-.2040259*n+1.0572252*u),a.alpha)}function K_(a,n,s){const u=n-a;return a+s*(u>180||u<-180?u-360*Math.round(u/360):u)}const Cl={forward:xu,reverse:zd,interpolate:function(a,n,s){return{l:yn(a.l,n.l,s),a:yn(a.a,n.a,s),b:yn(a.b,n.b,s),alpha:yn(a.alpha,n.alpha,s)}}},Al={forward:function(a){const{l:n,a:s,b:u}=xu(a),p=Math.atan2(u,s)*Vm;return{h:p<0?p+360:p,c:Math.sqrt(s*s+u*u),l:n,alpha:a.a}},reverse:function(a){const n=a.h*Um,s=a.c;return zd({l:a.l,a:Math.cos(n)*s,b:Math.sin(n)*s,alpha:a.alpha})},interpolate:function(a,n,s){return{h:K_(a.h,n.h,s),c:yn(a.c,n.c,s),l:yn(a.l,n.l,s),alpha:yn(a.alpha,n.alpha,s)}}};var Fd=Object.freeze({__proto__:null,lab:Cl,hcl:Al});class Lr{constructor(n,s,u,p,g){this.type=n,this.operator=s,this.interpolation=u,this.input=p,this.labels=[],this.outputs=[];for(const[_,T]of g)this.labels.push(_),this.outputs.push(T)}static interpolationFactor(n,s,u,p){let g=0;if(n.name==="exponential")g=bu(s,n.base,u,p);else if(n.name==="linear")g=bu(s,1,u,p);else if(n.name==="cubic-bezier"){const _=n.controlPoints;g=new x(_[0],_[1],_[2],_[3]).solve(bu(s,1,u,p))}return g}static parse(n,s){let[u,p,g,..._]=n;if(!Array.isArray(p)||p.length===0)return s.error("Expected an interpolation type expression.",1);if(p[0]==="linear")p={name:"linear"};else if(p[0]==="exponential"){const I=p[1];if(typeof I!="number")return s.error("Exponential interpolation requires a numeric base.",1,1);p={name:"exponential",base:I}}else{if(p[0]!=="cubic-bezier")return s.error(`Unknown interpolation type ${String(p[0])}`,1,0);{const I=p.slice(1);if(I.length!==4||I.some(z=>typeof z!="number"||z<0||z>1))return s.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);p={name:"cubic-bezier",controlPoints:I}}}if(n.length-1<4)return s.error(`Expected at least 4 arguments, but found only ${n.length-1}.`);if((n.length-1)%2!=0)return s.error("Expected an even number of arguments.");if(g=s.parse(g,2,Mt),!g)return null;const T=[];let D=null;u==="interpolate-hcl"||u==="interpolate-lab"?D=mn:s.expectedType&&s.expectedType.kind!=="value"&&(D=s.expectedType);for(let I=0;I<_.length;I+=2){const z=_[I],B=_[I+1],N=I+3,W=I+4;if(typeof z!="number")return s.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',N);if(T.length&&T[T.length-1][0]>=z)return s.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',N);const K=s.parse(B,W,D);if(!K)return null;D=D||K.type,T.push([z,K])}return D.kind==="number"||D.kind==="color"||D.kind==="array"&&D.itemType.kind==="number"&&typeof D.N=="number"?new Lr(D,u,p,g,T):s.error(`Type ${ai(D)} is not interpolatable.`)}evaluate(n){const s=this.labels,u=this.outputs;if(s.length===1)return u[0].evaluate(n);const p=this.input.evaluate(n);if(p<=s[0])return u[0].evaluate(n);const g=s.length;if(p>=s[g-1])return u[g-1].evaluate(n);const _=Tl(s,p),T=Lr.interpolationFactor(this.interpolation,p,s[_],s[_+1]),D=u[_].evaluate(n),I=u[_+1].evaluate(n);return this.operator==="interpolate"?_u[this.type.kind.toLowerCase()](D,I,T):this.operator==="interpolate-hcl"?Al.reverse(Al.interpolate(Al.forward(D),Al.forward(I),T)):Cl.reverse(Cl.interpolate(Cl.forward(D),Cl.forward(I),T))}eachChild(n){n(this.input);for(const s of this.outputs)n(s)}outputDefined(){return this.outputs.every(n=>n.outputDefined())}serialize(){let n;n=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const s=[this.operator,n,this.input.serialize()];for(let u=0;u<this.labels.length;u++)s.push(this.labels[u],this.outputs[u].serialize());return s}}function bu(a,n,s,u){const p=u-s,g=a-s;return p===0?0:n===1?g/p:(Math.pow(n,g)-1)/(Math.pow(n,p)-1)}class Dl{constructor(n,s){this.type=n,this.args=s}static parse(n,s){if(n.length<2)return s.error("Expectected at least one argument.");let u=null;const p=s.expectedType;p&&p.kind!=="value"&&(u=p);const g=[];for(const T of n.slice(1)){const D=s.parse(T,1+g.length,u,void 0,{typeAnnotation:"omit"});if(!D)return null;u=u||D.type,g.push(D)}const _=p&&g.some(T=>ko(p,T.type));return new Dl(_?Cn:u,g)}evaluate(n){let s,u=null,p=0;for(const g of this.args){if(p++,u=g.evaluate(n),u&&u instanceof Pr&&!u.available&&(s||(s=u),u=null,p===this.args.length))return s;if(u!==null)break}return u}eachChild(n){this.args.forEach(n)}outputDefined(){return this.args.every(n=>n.outputDefined())}serialize(){const n=["coalesce"];return this.eachChild(s=>{n.push(s.serialize())}),n}}class Pl{constructor(n,s){this.type=s.type,this.bindings=[].concat(n),this.result=s}evaluate(n){return this.result.evaluate(n)}eachChild(n){for(const s of this.bindings)n(s[1]);n(this.result)}static parse(n,s){if(n.length<4)return s.error(`Expected at least 3 arguments, but found ${n.length-1} instead.`);const u=[];for(let g=1;g<n.length-1;g+=2){const _=n[g];if(typeof _!="string")return s.error(`Expected string, but found ${typeof _} instead.`,g);if(/[^a-zA-Z0-9_]/.test(_))return s.error("Variable names must contain only alphanumeric characters or '_'.",g);const T=s.parse(n[g+1],g+1);if(!T)return null;u.push([_,T])}const p=s.parse(n[n.length-1],n.length-1,s.expectedType,u);return p?new Pl(u,p):null}outputDefined(){return this.result.outputDefined()}serialize(){const n=["let"];for(const[s,u]of this.bindings)n.push(s,u.serialize());return n.push(this.result.serialize()),n}}class Bd{constructor(n,s,u){this.type=n,this.index=s,this.input=u}static parse(n,s){if(n.length!==3)return s.error(`Expected 2 arguments, but found ${n.length-1} instead.`);const u=s.parse(n[1],1,Mt),p=s.parse(n[2],2,li(s.expectedType||Cn));return u&&p?new Bd(p.type.itemType,u,p):null}evaluate(n){const s=this.index.evaluate(n),u=this.input.evaluate(n);if(s<0)throw new Qi(`Array index out of bounds: ${s} < 0.`);if(s>=u.length)throw new Qi(`Array index out of bounds: ${s} > ${u.length-1}.`);if(s!==Math.floor(s))throw new Qi(`Array index must be an integer, but found ${s} instead.`);return u[s]}eachChild(n){n(this.index),n(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class wu{constructor(n,s){this.type=Kt,this.needle=n,this.haystack=s}static parse(n,s){if(n.length!==3)return s.error(`Expected 2 arguments, but found ${n.length-1} instead.`);const u=s.parse(n[1],1,Cn),p=s.parse(n[2],2,Cn);return u&&p?uu(u.type,[Kt,un,Mt,Ln,Cn])?new wu(u,p):s.error(`Expected first argument to be of type boolean, string, number or null, but found ${ai(u.type)} instead`):null}evaluate(n){const s=this.needle.evaluate(n),u=this.haystack.evaluate(n);if(u==null)return!1;if(!bs(s,["boolean","string","number","null"]))throw new Qi(`Expected first argument to be of type boolean, string, number or null, but found ${ai(Pi(s))} instead.`);if(!bs(u,["string","array"]))throw new Qi(`Expected second argument to be of type array or string, but found ${ai(Pi(u))} instead.`);return u.indexOf(s)>=0}eachChild(n){n(this.needle),n(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class Mu{constructor(n,s,u){this.type=Mt,this.needle=n,this.haystack=s,this.fromIndex=u}static parse(n,s){if(n.length<=2||n.length>=5)return s.error(`Expected 3 or 4 arguments, but found ${n.length-1} instead.`);const u=s.parse(n[1],1,Cn),p=s.parse(n[2],2,Cn);if(!u||!p)return null;if(!uu(u.type,[Kt,un,Mt,Ln,Cn]))return s.error(`Expected first argument to be of type boolean, string, number or null, but found ${ai(u.type)} instead`);if(n.length===4){const g=s.parse(n[3],3,Mt);return g?new Mu(u,p,g):null}return new Mu(u,p)}evaluate(n){const s=this.needle.evaluate(n),u=this.haystack.evaluate(n);if(!bs(s,["boolean","string","number","null"]))throw new Qi(`Expected first argument to be of type boolean, string, number or null, but found ${ai(Pi(s))} instead.`);if(!bs(u,["string","array"]))throw new Qi(`Expected second argument to be of type array or string, but found ${ai(Pi(u))} instead.`);if(this.fromIndex){const p=this.fromIndex.evaluate(n);return u.indexOf(s,p)}return u.indexOf(s)}eachChild(n){n(this.needle),n(this.haystack),this.fromIndex&&n(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const n=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),n]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class Tu{constructor(n,s,u,p,g,_){this.inputType=n,this.type=s,this.input=u,this.cases=p,this.outputs=g,this.otherwise=_}static parse(n,s){if(n.length<5)return s.error(`Expected at least 4 arguments, but found only ${n.length-1}.`);if(n.length%2!=1)return s.error("Expected an even number of arguments.");let u,p;s.expectedType&&s.expectedType.kind!=="value"&&(p=s.expectedType);const g={},_=[];for(let I=2;I<n.length-1;I+=2){let z=n[I];const B=n[I+1];Array.isArray(z)||(z=[z]);const N=s.concat(I);if(z.length===0)return N.error("Expected at least one branch label.");for(const K of z){if(typeof K!="number"&&typeof K!="string")return N.error("Branch labels must be numbers or strings.");if(typeof K=="number"&&Math.abs(K)>Number.MAX_SAFE_INTEGER)return N.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof K=="number"&&Math.floor(K)!==K)return N.error("Numeric branch labels must be integer values.");if(u){if(N.checkSubtype(u,Pi(K)))return null}else u=Pi(K);if(g[String(K)]!==void 0)return N.error("Branch labels must be unique.");g[String(K)]=_.length}const W=s.parse(B,I,p);if(!W)return null;p=p||W.type,_.push(W)}const T=s.parse(n[1],1,Cn);if(!T)return null;const D=s.parse(n[n.length-1],n.length-1,p);return D?T.type.kind!=="value"&&s.concat(1).checkSubtype(u,T.type)?null:new Tu(u,p,T,g,_,D):null}evaluate(n){const s=this.input.evaluate(n);return(Pi(s)===this.inputType&&this.outputs[this.cases[s]]||this.otherwise).evaluate(n)}eachChild(n){n(this.input),this.outputs.forEach(n),n(this.otherwise)}outputDefined(){return this.outputs.every(n=>n.outputDefined())&&this.otherwise.outputDefined()}serialize(){const n=["match",this.input.serialize()],s=Object.keys(this.cases).sort(),u=[],p={};for(const _ of s){const T=p[this.cases[_]];T===void 0?(p[this.cases[_]]=u.length,u.push([this.cases[_],[_]])):u[T][1].push(_)}const g=_=>this.inputType.kind==="number"?Number(_):_;for(const[_,T]of u)n.push(T.length===1?g(T[0]):T.map(g)),n.push(this.outputs[_].serialize());return n.push(this.otherwise.serialize()),n}}class Eu{constructor(n,s,u){this.type=n,this.branches=s,this.otherwise=u}static parse(n,s){if(n.length<4)return s.error(`Expected at least 3 arguments, but found only ${n.length-1}.`);if(n.length%2!=0)return s.error("Expected an odd number of arguments.");let u;s.expectedType&&s.expectedType.kind!=="value"&&(u=s.expectedType);const p=[];for(let _=1;_<n.length-1;_+=2){const T=s.parse(n[_],_,Kt);if(!T)return null;const D=s.parse(n[_+1],_+1,u);if(!D)return null;p.push([T,D]),u=u||D.type}const g=s.parse(n[n.length-1],n.length-1,u);return g?new Eu(u,p,g):null}evaluate(n){for(const[s,u]of this.branches)if(s.evaluate(n))return u.evaluate(n);return this.otherwise.evaluate(n)}eachChild(n){for(const[s,u]of this.branches)n(s),n(u);n(this.otherwise)}outputDefined(){return this.branches.every(([n,s])=>s.outputDefined())&&this.otherwise.outputDefined()}serialize(){const n=["case"];return this.eachChild(s=>{n.push(s.serialize())}),n}}class Cu{constructor(n,s,u,p){this.type=n,this.input=s,this.beginIndex=u,this.endIndex=p}static parse(n,s){if(n.length<=2||n.length>=5)return s.error(`Expected 3 or 4 arguments, but found ${n.length-1} instead.`);const u=s.parse(n[1],1,Cn),p=s.parse(n[2],2,Mt);if(!u||!p)return null;if(!uu(u.type,[li(Cn),un,Cn]))return s.error(`Expected first argument to be of type array or string, but found ${ai(u.type)} instead`);if(n.length===4){const g=s.parse(n[3],3,Mt);return g?new Cu(u.type,u,p,g):null}return new Cu(u.type,u,p)}evaluate(n){const s=this.input.evaluate(n),u=this.beginIndex.evaluate(n);if(!bs(s,["string","array"]))throw new Qi(`Expected first argument to be of type array or string, but found ${ai(Pi(s))} instead.`);if(this.endIndex){const p=this.endIndex.evaluate(n);return s.slice(u,p)}return s.slice(u)}eachChild(n){n(this.input),n(this.beginIndex),this.endIndex&&n(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const n=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),n]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function Gm(a,n){return a==="=="||a==="!="?n.kind==="boolean"||n.kind==="string"||n.kind==="number"||n.kind==="null"||n.kind==="value":n.kind==="string"||n.kind==="number"||n.kind==="value"}function Wm(a,n,s,u){return u.compare(n,s)===0}function Cs(a,n,s){const u=a!=="=="&&a!=="!=";return class AM{constructor(g,_,T){this.type=Kt,this.lhs=g,this.rhs=_,this.collator=T,this.hasUntypedArgument=g.type.kind==="value"||_.type.kind==="value"}static parse(g,_){if(g.length!==3&&g.length!==4)return _.error("Expected two or three arguments.");const T=g[0];let D=_.parse(g[1],1,Cn);if(!D)return null;if(!Gm(T,D.type))return _.concat(1).error(`"${T}" comparisons are not supported for type '${ai(D.type)}'.`);let I=_.parse(g[2],2,Cn);if(!I)return null;if(!Gm(T,I.type))return _.concat(2).error(`"${T}" comparisons are not supported for type '${ai(I.type)}'.`);if(D.type.kind!==I.type.kind&&D.type.kind!=="value"&&I.type.kind!=="value")return _.error(`Cannot compare types '${ai(D.type)}' and '${ai(I.type)}'.`);u&&(D.type.kind==="value"&&I.type.kind!=="value"?D=new po(I.type,[D]):D.type.kind!=="value"&&I.type.kind==="value"&&(I=new po(D.type,[I])));let z=null;if(g.length===4){if(D.type.kind!=="string"&&I.type.kind!=="string"&&D.type.kind!=="value"&&I.type.kind!=="value")return _.error("Cannot use collator to compare non-string types.");if(z=_.parse(g[3],3,di),!z)return null}return new AM(D,I,z)}evaluate(g){const _=this.lhs.evaluate(g),T=this.rhs.evaluate(g);if(u&&this.hasUntypedArgument){const D=Pi(_),I=Pi(T);if(D.kind!==I.kind||D.kind!=="string"&&D.kind!=="number")throw new Qi(`Expected arguments for "${a}" to be (string, string) or (number, number), but found (${D.kind}, ${I.kind}) instead.`)}if(this.collator&&!u&&this.hasUntypedArgument){const D=Pi(_),I=Pi(T);if(D.kind!=="string"||I.kind!=="string")return n(g,_,T)}return this.collator?s(g,_,T,this.collator.evaluate(g)):n(g,_,T)}eachChild(g){g(this.lhs),g(this.rhs),this.collator&&g(this.collator)}outputDefined(){return!0}serialize(){const g=[a];return this.eachChild(_=>{g.push(_.serialize())}),g}}}const J_=Cs("==",function(a,n,s){return n===s},Wm),Q_=Cs("!=",function(a,n,s){return n!==s},function(a,n,s,u){return!Wm(0,n,s,u)}),jm=Cs("<",function(a,n,s){return n<s},function(a,n,s,u){return u.compare(n,s)<0}),ev=Cs(">",function(a,n,s){return n>s},function(a,n,s,u){return u.compare(n,s)>0}),tv=Cs("<=",function(a,n,s){return n<=s},function(a,n,s,u){return u.compare(n,s)<=0}),nv=Cs(">=",function(a,n,s){return n>=s},function(a,n,s,u){return u.compare(n,s)>=0});class Od{constructor(n,s,u,p,g){this.type=un,this.number=n,this.locale=s,this.currency=u,this.minFractionDigits=p,this.maxFractionDigits=g}static parse(n,s){if(n.length!==3)return s.error("Expected two arguments.");const u=s.parse(n[1],1,Mt);if(!u)return null;const p=n[2];if(typeof p!="object"||Array.isArray(p))return s.error("NumberFormat options argument must be an object.");let g=null;if(p.locale&&(g=s.parse(p.locale,1,un),!g))return null;let _=null;if(p.currency&&(_=s.parse(p.currency,1,un),!_))return null;let T=null;if(p["min-fraction-digits"]&&(T=s.parse(p["min-fraction-digits"],1,Mt),!T))return null;let D=null;return p["max-fraction-digits"]&&(D=s.parse(p["max-fraction-digits"],1,Mt),!D)?null:new Od(u,g,_,T,D)}evaluate(n){return new Intl.NumberFormat(this.locale?this.locale.evaluate(n):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(n):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(n):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(n):void 0}).format(this.number.evaluate(n))}eachChild(n){n(this.number),this.locale&&n(this.locale),this.currency&&n(this.currency),this.minFractionDigits&&n(this.minFractionDigits),this.maxFractionDigits&&n(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const n={};return this.locale&&(n.locale=this.locale.serialize()),this.currency&&(n.currency=this.currency.serialize()),this.minFractionDigits&&(n["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(n["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),n]}}class Au{constructor(n){this.type=Mt,this.input=n}static parse(n,s){if(n.length!==2)return s.error(`Expected 1 argument, but found ${n.length-1} instead.`);const u=s.parse(n[1],1);return u?u.type.kind!=="array"&&u.type.kind!=="string"&&u.type.kind!=="value"?s.error(`Expected argument of type string or array, but found ${ai(u.type)} instead.`):new Au(u):null}evaluate(n){const s=this.input.evaluate(n);if(typeof s=="string"||Array.isArray(s))return s.length;throw new Qi(`Expected value to be of type string or array, but found ${ai(Pi(s))} instead.`)}eachChild(n){n(this.input)}outputDefined(){return!1}serialize(){const n=["length"];return this.eachChild(s=>{n.push(s.serialize())}),n}}const Va={"==":J_,"!=":Q_,">":ev,"<":jm,">=":nv,"<=":tv,array:po,at:Bd,boolean:po,case:Eu,coalesce:Dl,collator:pu,format:Ms,image:Ts,in:wu,"index-of":Mu,interpolate:Lr,"interpolate-hcl":Lr,"interpolate-lab":Lr,length:Au,let:Pl,literal:Fo,match:Tu,number:po,"number-format":Od,object:po,slice:Cu,step:El,string:po,"to-boolean":fo,"to-color":fo,"to-number":fo,"to-string":fo,var:Ua,within:Na};function Nd(a,[n,s,u,p]){n=n.evaluate(a),s=s.evaluate(a),u=u.evaluate(a);const g=p?p.evaluate(a):1,_=ho(n,s,u,g);if(_)throw new Qi(_);return new Xn(n/255*g,s/255*g,u/255*g,g)}function Hm(a,n){return a in n}function Ud(a,n){const s=n[a];return s===void 0?null:s}function sa(a){return{type:a}}function Vd(a){return{result:"success",value:a}}function Ga(a){return{result:"error",value:a}}function As(a){return a["property-type"]==="data-driven"||a["property-type"]==="cross-faded-data-driven"}function $m(a){return!!a.expression&&a.expression.parameters.indexOf("zoom")>-1}function Gd(a){return!!a.expression&&a.expression.interpolated}function Qn(a){return a instanceof Number?"number":a instanceof String?"string":a instanceof Boolean?"boolean":Array.isArray(a)?"array":a===null?"null":typeof a}function Wa(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}function qm(a){return a}function Wd(a,n){const s=n.type==="color",u=a.stops&&typeof a.stops[0][0]=="object",p=u||!(u||a.property!==void 0),g=a.type||(Gd(n)?"exponential":"interval");if(s&&((a=Tt({},a)).stops&&(a.stops=a.stops.map(I=>[I[0],Xn.parse(I[1])])),a.default=Xn.parse(a.default?a.default:n.default)),a.colorSpace&&a.colorSpace!=="rgb"&&!Fd[a.colorSpace])throw new Error(`Unknown color space: ${a.colorSpace}`);let _,T,D;if(g==="exponential")_=jd;else if(g==="interval")_=rv;else if(g==="categorical"){_=iv,T=Object.create(null);for(const I of a.stops)T[I[0]]=I[1];D=typeof a.stops[0][0]}else{if(g!=="identity")throw new Error(`Unknown function type "${g}"`);_=Xm}if(u){const I={},z=[];for(let W=0;W<a.stops.length;W++){const K=a.stops[W],oe=K[0].zoom;I[oe]===void 0&&(I[oe]={zoom:oe,type:a.type,property:a.property,default:a.default,stops:[]},z.push(oe)),I[oe].stops.push([K[0].value,K[1]])}const B=[];for(const W of z)B.push([I[W].zoom,Wd(I[W],n)]);const N={name:"linear"};return{kind:"composite",interpolationType:N,interpolationFactor:Lr.interpolationFactor.bind(void 0,N),zoomStops:B.map(W=>W[0]),evaluate:({zoom:W},K)=>jd({stops:B,base:a.base},n,W).evaluate(W,K)}}if(p){const I=g==="exponential"?{name:"exponential",base:a.base!==void 0?a.base:1}:null;return{kind:"camera",interpolationType:I,interpolationFactor:Lr.interpolationFactor.bind(void 0,I),zoomStops:a.stops.map(z=>z[0]),evaluate:({zoom:z})=>_(a,n,z,T,D)}}return{kind:"source",evaluate(I,z){const B=z&&z.properties?z.properties[a.property]:void 0;return B===void 0?Sl(a.default,n.default):_(a,n,B,T,D)}}}function Sl(a,n,s){return a!==void 0?a:n!==void 0?n:s!==void 0?s:void 0}function iv(a,n,s,u,p){return Sl(typeof s===p?u[s]:void 0,a.default,n.default)}function rv(a,n,s){if(Qn(s)!=="number")return Sl(a.default,n.default);const u=a.stops.length;if(u===1||s<=a.stops[0][0])return a.stops[0][1];if(s>=a.stops[u-1][0])return a.stops[u-1][1];const p=Tl(a.stops.map(g=>g[0]),s);return a.stops[p][1]}function jd(a,n,s){const u=a.base!==void 0?a.base:1;if(Qn(s)!=="number")return Sl(a.default,n.default);const p=a.stops.length;if(p===1||s<=a.stops[0][0])return a.stops[0][1];if(s>=a.stops[p-1][0])return a.stops[p-1][1];const g=Tl(a.stops.map(z=>z[0]),s),_=function(z,B,N,W){const K=W-N,oe=z-N;return K===0?0:B===1?oe/K:(Math.pow(B,oe)-1)/(Math.pow(B,K)-1)}(s,u,a.stops[g][0],a.stops[g+1][0]),T=a.stops[g][1],D=a.stops[g+1][1];let I=_u[n.type]||qm;if(a.colorSpace&&a.colorSpace!=="rgb"){const z=Fd[a.colorSpace];I=(B,N)=>z.reverse(z.interpolate(z.forward(B),z.forward(N),_))}return typeof T.evaluate=="function"?{evaluate(...z){const B=T.evaluate.apply(void 0,z),N=D.evaluate.apply(void 0,z);if(B!==void 0&&N!==void 0)return I(B,N,_)}}:I(T,D,_)}function Xm(a,n,s){return n.type==="color"?s=Xn.parse(s):n.type==="formatted"?s=Fi.fromString(s.toString()):n.type==="resolvedImage"?s=Pr.fromString(s.toString()):Qn(s)===n.type||n.type==="enum"&&n.values[s]||(s=void 0),Sl(s,a.default,n.default)}Sr.register(Va,{error:[{kind:"error"},[un],(a,[n])=>{throw new Qi(n.evaluate(a))}],typeof:[un,[Cn],(a,[n])=>ai(Pi(n.evaluate(a)))],"to-rgba":[li(Mt,4),[mn],(a,[n])=>n.evaluate(a).toArray()],rgb:[mn,[Mt,Mt,Mt],Nd],rgba:[mn,[Mt,Mt,Mt,Mt],Nd],has:{type:Kt,overloads:[[[un],(a,[n])=>Hm(n.evaluate(a),a.properties())],[[un,Tn],(a,[n,s])=>Hm(n.evaluate(a),s.evaluate(a))]]},get:{type:Cn,overloads:[[[un],(a,[n])=>Ud(n.evaluate(a),a.properties())],[[un,Tn],(a,[n,s])=>Ud(n.evaluate(a),s.evaluate(a))]]},"feature-state":[Cn,[un],(a,[n])=>Ud(n.evaluate(a),a.featureState||{})],properties:[Tn,[],a=>a.properties()],"geometry-type":[un,[],a=>a.geometryType()],id:[Cn,[],a=>a.id()],zoom:[Mt,[],a=>a.globals.zoom],pitch:[Mt,[],a=>a.globals.pitch||0],"distance-from-center":[Mt,[],a=>a.distanceFromCenter()],"heatmap-density":[Mt,[],a=>a.globals.heatmapDensity||0],"line-progress":[Mt,[],a=>a.globals.lineProgress||0],"sky-radial-progress":[Mt,[],a=>a.globals.skyRadialProgress||0],accumulated:[Cn,[],a=>a.globals.accumulated===void 0?null:a.globals.accumulated],"+":[Mt,sa(Mt),(a,n)=>{let s=0;for(const u of n)s+=u.evaluate(a);return s}],"*":[Mt,sa(Mt),(a,n)=>{let s=1;for(const u of n)s*=u.evaluate(a);return s}],"-":{type:Mt,overloads:[[[Mt,Mt],(a,[n,s])=>n.evaluate(a)-s.evaluate(a)],[[Mt],(a,[n])=>-n.evaluate(a)]]},"/":[Mt,[Mt,Mt],(a,[n,s])=>n.evaluate(a)/s.evaluate(a)],"%":[Mt,[Mt,Mt],(a,[n,s])=>n.evaluate(a)%s.evaluate(a)],ln2:[Mt,[],()=>Math.LN2],pi:[Mt,[],()=>Math.PI],e:[Mt,[],()=>Math.E],"^":[Mt,[Mt,Mt],(a,[n,s])=>Math.pow(n.evaluate(a),s.evaluate(a))],sqrt:[Mt,[Mt],(a,[n])=>Math.sqrt(n.evaluate(a))],log10:[Mt,[Mt],(a,[n])=>Math.log(n.evaluate(a))/Math.LN10],ln:[Mt,[Mt],(a,[n])=>Math.log(n.evaluate(a))],log2:[Mt,[Mt],(a,[n])=>Math.log(n.evaluate(a))/Math.LN2],sin:[Mt,[Mt],(a,[n])=>Math.sin(n.evaluate(a))],cos:[Mt,[Mt],(a,[n])=>Math.cos(n.evaluate(a))],tan:[Mt,[Mt],(a,[n])=>Math.tan(n.evaluate(a))],asin:[Mt,[Mt],(a,[n])=>Math.asin(n.evaluate(a))],acos:[Mt,[Mt],(a,[n])=>Math.acos(n.evaluate(a))],atan:[Mt,[Mt],(a,[n])=>Math.atan(n.evaluate(a))],min:[Mt,sa(Mt),(a,n)=>Math.min(...n.map(s=>s.evaluate(a)))],max:[Mt,sa(Mt),(a,n)=>Math.max(...n.map(s=>s.evaluate(a)))],abs:[Mt,[Mt],(a,[n])=>Math.abs(n.evaluate(a))],round:[Mt,[Mt],(a,[n])=>{const s=n.evaluate(a);return s<0?-Math.round(-s):Math.round(s)}],floor:[Mt,[Mt],(a,[n])=>Math.floor(n.evaluate(a))],ceil:[Mt,[Mt],(a,[n])=>Math.ceil(n.evaluate(a))],"filter-==":[Kt,[un,Cn],(a,[n,s])=>a.properties()[n.value]===s.value],"filter-id-==":[Kt,[Cn],(a,[n])=>a.id()===n.value],"filter-type-==":[Kt,[un],(a,[n])=>a.geometryType()===n.value],"filter-<":[Kt,[un,Cn],(a,[n,s])=>{const u=a.properties()[n.value],p=s.value;return typeof u==typeof p&&u<p}],"filter-id-<":[Kt,[Cn],(a,[n])=>{const s=a.id(),u=n.value;return typeof s==typeof u&&s<u}],"filter->":[Kt,[un,Cn],(a,[n,s])=>{const u=a.properties()[n.value],p=s.value;return typeof u==typeof p&&u>p}],"filter-id->":[Kt,[Cn],(a,[n])=>{const s=a.id(),u=n.value;return typeof s==typeof u&&s>u}],"filter-<=":[Kt,[un,Cn],(a,[n,s])=>{const u=a.properties()[n.value],p=s.value;return typeof u==typeof p&&u<=p}],"filter-id-<=":[Kt,[Cn],(a,[n])=>{const s=a.id(),u=n.value;return typeof s==typeof u&&s<=u}],"filter->=":[Kt,[un,Cn],(a,[n,s])=>{const u=a.properties()[n.value],p=s.value;return typeof u==typeof p&&u>=p}],"filter-id->=":[Kt,[Cn],(a,[n])=>{const s=a.id(),u=n.value;return typeof s==typeof u&&s>=u}],"filter-has":[Kt,[Cn],(a,[n])=>n.value in a.properties()],"filter-has-id":[Kt,[],a=>a.id()!==null&&a.id()!==void 0],"filter-type-in":[Kt,[li(un)],(a,[n])=>n.value.indexOf(a.geometryType())>=0],"filter-id-in":[Kt,[li(Cn)],(a,[n])=>n.value.indexOf(a.id())>=0],"filter-in-small":[Kt,[un,li(Cn)],(a,[n,s])=>s.value.indexOf(a.properties()[n.value])>=0],"filter-in-large":[Kt,[un,li(Cn)],(a,[n,s])=>function(u,p,g,_){for(;g<=_;){const T=g+_>>1;if(p[T]===u)return!0;p[T]>u?_=T-1:g=T+1}return!1}(a.properties()[n.value],s.value,0,s.value.length-1)],all:{type:Kt,overloads:[[[Kt,Kt],(a,[n,s])=>n.evaluate(a)&&s.evaluate(a)],[sa(Kt),(a,n)=>{for(const s of n)if(!s.evaluate(a))return!1;return!0}]]},any:{type:Kt,overloads:[[[Kt,Kt],(a,[n,s])=>n.evaluate(a)||s.evaluate(a)],[sa(Kt),(a,n)=>{for(const s of n)if(s.evaluate(a))return!0;return!1}]]},"!":[Kt,[Kt],(a,[n])=>!n.evaluate(a)],"is-supported-script":[Kt,[un],(a,[n])=>{const s=a.globals&&a.globals.isSupportedScript;return!s||s(n.evaluate(a))}],upcase:[un,[un],(a,[n])=>n.evaluate(a).toUpperCase()],downcase:[un,[un],(a,[n])=>n.evaluate(a).toLowerCase()],concat:[un,sa(Cn),(a,n)=>n.map(s=>zo(s.evaluate(a))).join("")],"resolved-locale":[un,[di],(a,[n])=>n.evaluate(a).resolvedLocale()]});class Du{constructor(n,s){this.expression=n,this._warningHistory={},this._evaluator=new Lm,this._defaultValue=s?function(u){return u.type==="color"&&Wa(u.default)?new Xn(0,0,0,0):u.type==="color"?Xn.parse(u.default)||null:u.default===void 0?null:u.default}(s):null,this._enumValues=s&&s.type==="enum"?s.values:null}evaluateWithoutErrorHandling(n,s,u,p,g,_,T,D){return this._evaluator.globals=n,this._evaluator.feature=s,this._evaluator.featureState=u,this._evaluator.canonical=p||null,this._evaluator.availableImages=g||null,this._evaluator.formattedSection=_,this._evaluator.featureTileCoord=T||null,this._evaluator.featureDistanceData=D||null,this.expression.evaluate(this._evaluator)}evaluate(n,s,u,p,g,_,T,D){this._evaluator.globals=n,this._evaluator.feature=s||null,this._evaluator.featureState=u||null,this._evaluator.canonical=p||null,this._evaluator.availableImages=g||null,this._evaluator.formattedSection=_||null,this._evaluator.featureTileCoord=T||null,this._evaluator.featureDistanceData=D||null;try{const I=this.expression.evaluate(this._evaluator);if(I==null||typeof I=="number"&&I!=I)return this._defaultValue;if(this._enumValues&&!(I in this._enumValues))throw new Qi(`Expected value to be one of ${Object.keys(this._enumValues).map(z=>JSON.stringify(z)).join(", ")}, but found ${JSON.stringify(I)} instead.`);return I}catch(I){return this._warningHistory[I.message]||(this._warningHistory[I.message]=!0,typeof console!="undefined"&&console.warn(I.message)),this._defaultValue}}}function Ds(a){return Array.isArray(a)&&a.length>0&&typeof a[0]=="string"&&a[0]in Va}function Ll(a,n){const s=new oa(Va,[],n?function(p){const g={color:mn,string:un,number:Mt,enum:un,boolean:Kt,formatted:Dr,resolvedImage:oi};return p.type==="array"?li(g[p.value]||Cn,p.length):g[p.type]}(n):void 0),u=s.parse(a,void 0,void 0,void 0,n&&n.type==="string"?{typeAnnotation:"coerce"}:void 0);return u?Vd(new Du(u,n)):Ga(s.errors)}class Hd{constructor(n,s){this.kind=n,this._styleExpression=s,this.isStateDependent=n!=="constant"&&!wl(s.expression)}evaluateWithoutErrorHandling(n,s,u,p,g,_){return this._styleExpression.evaluateWithoutErrorHandling(n,s,u,p,g,_)}evaluate(n,s,u,p,g,_){return this._styleExpression.evaluate(n,s,u,p,g,_)}}class $d{constructor(n,s,u,p){this.kind=n,this.zoomStops=u,this._styleExpression=s,this.isStateDependent=n!=="camera"&&!wl(s.expression),this.interpolationType=p}evaluateWithoutErrorHandling(n,s,u,p,g,_){return this._styleExpression.evaluateWithoutErrorHandling(n,s,u,p,g,_)}evaluate(n,s,u,p,g,_){return this._styleExpression.evaluate(n,s,u,p,g,_)}interpolationFactor(n,s,u){return this.interpolationType?Lr.interpolationFactor(this.interpolationType,n,s,u):0}}function Zm(a,n){if((a=Ll(a,n)).result==="error")return a;const s=a.value.expression,u=yr(s);if(!u&&!As(n))return Ga([new rn("","data expressions not supported")]);const p=Ml(s,["zoom","pitch","distance-from-center"]);if(!p&&!$m(n))return Ga([new rn("","zoom expressions not supported")]);const g=Su(s);return g||p?g instanceof rn?Ga([g]):g instanceof Lr&&!Gd(n)?Ga([new rn("",'"interpolate" expressions cannot be used with this property')]):Vd(g?new $d(u?"camera":"composite",a.value,g.labels,g instanceof Lr?g.interpolation:void 0):new Hd(u?"constant":"source",a.value)):Ga([new rn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Pu{constructor(n,s){this._parameters=n,this._specification=s,Tt(this,Wd(this._parameters,this._specification))}static deserialize(n){return new Pu(n._parameters,n._specification)}static serialize(n){return{_parameters:n._parameters,_specification:n._specification}}}function Su(a){let n=null;if(a instanceof Pl)n=Su(a.result);else if(a instanceof Dl){for(const s of a.args)if(n=Su(s),n)break}else(a instanceof El||a instanceof Lr)&&a.input instanceof Sr&&a.input.name==="zoom"&&(n=a);return n instanceof rn||a.eachChild(s=>{const u=Su(s);u instanceof rn?n=u:!n&&u?n=new rn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):n&&u&&n!==u&&(n=new rn("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),n}class jt{constructor(n,s,u,p){this.message=(n?`${n}: `:"")+u,p&&(this.identifier=p),s!=null&&s.__line__&&(this.line=s.__line__)}}function $r(a){const n=a.key,s=a.value,u=a.valueSpec||{},p=a.objectElementValidators||{},g=a.style,_=a.styleSpec;let T=[];const D=Qn(s);if(D!=="object")return[new jt(n,s,`object expected, ${D} found`)];for(const I in s){const z=I.split(".")[0],B=u[z]||u["*"];let N;p[z]?N=p[z]:u[z]?N=Hi:p["*"]?N=p["*"]:u["*"]&&(N=Hi),N?T=T.concat(N({key:(n&&`${n}.`)+I,value:s[I],valueSpec:B,style:g,styleSpec:_,object:s,objectKey:I},s)):T.push(new jt(n,s[I],`unknown property "${I}"`))}for(const I in u)p[I]||u[I].required&&u[I].default===void 0&&s[I]===void 0&&T.push(new jt(n,s,`missing required property "${I}"`));return T}function Il(a){const n=a.value,s=a.valueSpec,u=a.style,p=a.styleSpec,g=a.key,_=a.arrayElementValidator||Hi;if(Qn(n)!=="array")return[new jt(g,n,`array expected, ${Qn(n)} found`)];if(s.length&&n.length!==s.length)return[new jt(g,n,`array length ${s.length} expected, length ${n.length} found`)];if(s["min-length"]&&n.length<s["min-length"])return[new jt(g,n,`array length at least ${s["min-length"]} expected, length ${n.length} found`)];let T={type:s.value,values:s.values,minimum:s.minimum,maximum:s.maximum,function:void 0};p.$version<7&&(T.function=s.function),Qn(s.value)==="object"&&(T=s.value);let D=[];for(let I=0;I<n.length;I++)D=D.concat(_({array:n,arrayIndex:I,value:n[I],valueSpec:T,style:u,styleSpec:p,key:`${g}[${I}]`}));return D}function Ym(a){const n=a.key,s=a.value,u=a.valueSpec;let p=Qn(s);if(p==="number"&&s!=s&&(p="NaN"),p!=="number")return[new jt(n,s,`number expected, ${p} found`)];if("minimum"in u){let g=u.minimum;if(Qn(u.minimum)==="array"&&(g=u.minimum[a.arrayIndex]),s<g)return[new jt(n,s,`${s} is less than the minimum value ${g}`)]}if("maximum"in u){let g=u.maximum;if(Qn(u.maximum)==="array"&&(g=u.maximum[a.arrayIndex]),s>g)return[new jt(n,s,`${s} is greater than the maximum value ${g}`)]}return[]}function Km(a){const n=a.valueSpec,s=_t(a.value.type);let u,p,g,_={};const T=s!=="categorical"&&a.value.property===void 0,D=!T,I=Qn(a.value.stops)==="array"&&Qn(a.value.stops[0])==="array"&&Qn(a.value.stops[0][0])==="object",z=$r({key:a.key,value:a.value,valueSpec:a.styleSpec.function,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{stops:function(W){if(s==="identity")return[new jt(W.key,W.value,'identity function may not have a "stops" property')];let K=[];const oe=W.value;return K=K.concat(Il({key:W.key,value:oe,valueSpec:W.valueSpec,style:W.style,styleSpec:W.styleSpec,arrayElementValidator:B})),Qn(oe)==="array"&&oe.length===0&&K.push(new jt(W.key,oe,"array must have at least one stop")),K},default:function(W){return Hi({key:W.key,value:W.value,valueSpec:n,style:W.style,styleSpec:W.styleSpec})}}});return s==="identity"&&T&&z.push(new jt(a.key,a.value,'missing required property "property"')),s==="identity"||a.value.stops||z.push(new jt(a.key,a.value,'missing required property "stops"')),s==="exponential"&&a.valueSpec.expression&&!Gd(a.valueSpec)&&z.push(new jt(a.key,a.value,"exponential functions not supported")),a.styleSpec.$version>=8&&(D&&!As(a.valueSpec)?z.push(new jt(a.key,a.value,"property functions not supported")):T&&!$m(a.valueSpec)&&z.push(new jt(a.key,a.value,"zoom functions not supported"))),s!=="categorical"&&!I||a.value.property!==void 0||z.push(new jt(a.key,a.value,'"property" property is required')),z;function B(W){let K=[];const oe=W.value,ue=W.key;if(Qn(oe)!=="array")return[new jt(ue,oe,`array expected, ${Qn(oe)} found`)];if(oe.length!==2)return[new jt(ue,oe,`array length 2 expected, length ${oe.length} found`)];if(I){if(Qn(oe[0])!=="object")return[new jt(ue,oe,`object expected, ${Qn(oe[0])} found`)];if(oe[0].zoom===void 0)return[new jt(ue,oe,"object stop key must have zoom")];if(oe[0].value===void 0)return[new jt(ue,oe,"object stop key must have value")];const xe=_t(oe[0].zoom);if(typeof xe!="number")return[new jt(ue,oe[0].zoom,"stop zoom values must be numbers")];if(g&&g>xe)return[new jt(ue,oe[0].zoom,"stop zoom values must appear in ascending order")];xe!==g&&(g=xe,p=void 0,_={}),K=K.concat($r({key:`${ue}[0]`,value:oe[0],valueSpec:{zoom:{}},style:W.style,styleSpec:W.styleSpec,objectElementValidators:{zoom:Ym,value:N}}))}else K=K.concat(N({key:`${ue}[0]`,value:oe[0],valueSpec:{},style:W.style,styleSpec:W.styleSpec},oe));return Ds(Ot(oe[1]))?K.concat([new jt(`${ue}[1]`,oe[1],"expressions are not allowed in function stops.")]):K.concat(Hi({key:`${ue}[1]`,value:oe[1],valueSpec:n,style:W.style,styleSpec:W.styleSpec}))}function N(W,K){const oe=Qn(W.value),ue=_t(W.value),xe=W.value!==null?W.value:K;if(u){if(oe!==u)return[new jt(W.key,xe,`${oe} stop domain type must match previous stop domain type ${u}`)]}else u=oe;if(oe!=="number"&&oe!=="string"&&oe!=="boolean"&&typeof ue!="number"&&typeof ue!="string"&&typeof ue!="boolean")return[new jt(W.key,xe,"stop domain value must be a number, string, or boolean")];if(oe!=="number"&&s!=="categorical"){let Be=`number expected, ${oe} found`;return As(n)&&s===void 0&&(Be+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new jt(W.key,xe,Be)]}return s!=="categorical"||oe!=="number"||typeof ue=="number"&&isFinite(ue)&&Math.floor(ue)===ue?s!=="categorical"&&oe==="number"&&typeof ue=="number"&&typeof p=="number"&&p!==void 0&&ue<p?[new jt(W.key,xe,"stop domain values must appear in ascending order")]:(p=ue,s==="categorical"&&ue in _?[new jt(W.key,xe,"stop domain values must be unique")]:(_[ue]=!0,[])):[new jt(W.key,xe,`integer expected, found ${String(ue)}`)]}}function Ps(a){const n=(a.expressionContext==="property"?Zm:Ll)(Ot(a.value),a.valueSpec);if(n.result==="error")return n.value.map(u=>new jt(`${a.key}${u.key}`,a.value,u.message));const s=n.value.expression||n.value._styleExpression.expression;if(a.expressionContext==="property"&&a.propertyKey==="text-font"&&!s.outputDefined())return[new jt(a.key,a.value,`Invalid data expression for "${a.propertyKey}". Output values must be contained as literals within the expression.`)];if(a.expressionContext==="property"&&a.propertyType==="layout"&&!wl(s))return[new jt(a.key,a.value,'"feature-state" data expressions are not supported with layout properties.')];if(a.expressionContext==="filter")return Bo(s,a);if(a.expressionContext&&a.expressionContext.indexOf("cluster")===0){if(!Ml(s,["zoom","feature-state"]))return[new jt(a.key,a.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(a.expressionContext==="cluster-initial"&&!yr(s))return[new jt(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Bo(a,n){const s=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(n.valueSpec&&n.valueSpec.expression)for(const p of n.valueSpec.expression.parameters)s.delete(p);if(s.size===0)return[];const u=[];return a instanceof Sr&&s.has(a.name)?[new jt(n.key,n.value,`["${a.name}"] expression is not supported in a filter for a ${n.object.type} layer with id: ${n.object.id}`)]:(a.eachChild(p=>{u.push(...Bo(p,n))}),u)}function Rl(a){const n=a.key,s=a.value,u=a.valueSpec,p=[];return Array.isArray(u.values)?u.values.indexOf(_t(s))===-1&&p.push(new jt(n,s,`expected one of [${u.values.join(", ")}], ${JSON.stringify(s)} found`)):Object.keys(u.values).indexOf(_t(s))===-1&&p.push(new jt(n,s,`expected one of [${Object.keys(u.values).join(", ")}], ${JSON.stringify(s)} found`)),p}function la(a){if(a===!0||a===!1)return!0;if(!Array.isArray(a)||a.length===0)return!1;switch(a[0]){case"has":return a.length>=2&&a[1]!=="$id"&&a[1]!=="$type";case"in":return a.length>=3&&(typeof a[1]!="string"||Array.isArray(a[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return a.length!==3||Array.isArray(a[1])||Array.isArray(a[2]);case"any":case"all":for(const n of a.slice(1))if(!la(n)&&typeof n!="boolean")return!1;return!0;default:return!0}}function ca(a,n="fill"){if(a==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};la(a)||(a=kl(a));const s=a;let u=!0;try{u=function(I){if(!ua(I))return I;let z=Ot(I);return Jm(z),z=qd(z),z}(s)}catch(I){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
- This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md
- and paste the contents of this message in the report.
- Thank you!
- Filter Expression:
- ${JSON.stringify(s,null,2)}
- `)}const p=Te[`filter_${n}`],g=Ll(u,p);let _=null;if(g.result==="error")throw new Error(g.value.map(I=>`${I.key}: ${I.message}`).join(", "));_=(I,z,B)=>g.value.evaluate(I,z,{},B);let T=null,D=null;if(u!==s){const I=Ll(s,p);if(I.result==="error")throw new Error(I.value.map(z=>`${z.key}: ${z.message}`).join(", "));T=(z,B,N,W,K)=>I.value.evaluate(z,B,{},N,void 0,void 0,W,K),D=!yr(I.value.expression)}return _=_,{filter:_,dynamicFilter:T||void 0,needGeometry:Lu(u),needFeature:!!D}}function qd(a){if(!Array.isArray(a))return a;const n=function(s){if(Qm.has(s[0])){for(let u=1;u<s.length;u++)if(ua(s[u]))return!0}return s}(a);return n===!0?n:n.map(s=>qd(s))}function Jm(a){let n=!1;const s=[];if(a[0]==="case"){for(let u=1;u<a.length-1;u+=2)n=n||ua(a[u]),s.push(a[u+1]);s.push(a[a.length-1])}else if(a[0]==="match"){n=n||ua(a[1]);for(let u=2;u<a.length-1;u+=2)s.push(a[u+1]);s.push(a[a.length-1])}else if(a[0]==="step"){n=n||ua(a[1]);for(let u=1;u<a.length-1;u+=2)s.push(a[u+1])}n&&(a.length=0,a.push("any",...s));for(let u=1;u<a.length;u++)Jm(a[u])}function ua(a){if(!Array.isArray(a))return!1;if((n=a[0])==="pitch"||n==="distance-from-center")return!0;var n;for(let s=1;s<a.length;s++)if(ua(a[s]))return!0;return!1}const Qm=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function Xd(a,n){return a<n?-1:a>n?1:0}function Lu(a){if(!Array.isArray(a))return!1;if(a[0]==="within")return!0;for(let n=1;n<a.length;n++)if(Lu(a[n]))return!0;return!1}function kl(a){if(!a)return!0;const n=a[0];return a.length<=1?n!=="any":n==="=="?zl(a[1],a[2],"=="):n==="!="?Fl(zl(a[1],a[2],"==")):n==="<"||n===">"||n==="<="||n===">="?zl(a[1],a[2],n):n==="any"?(s=a.slice(1),["any"].concat(s.map(kl))):n==="all"?["all"].concat(a.slice(1).map(kl)):n==="none"?["all"].concat(a.slice(1).map(kl).map(Fl)):n==="in"?Zd(a[1],a.slice(2)):n==="!in"?Fl(Zd(a[1],a.slice(2))):n==="has"?Yd(a[1]):n==="!has"?Fl(Yd(a[1])):n!=="within"||a;var s}function zl(a,n,s){switch(a){case"$type":return[`filter-type-${s}`,n];case"$id":return[`filter-id-${s}`,n];default:return[`filter-${s}`,a,n]}}function Zd(a,n){if(n.length===0)return!1;switch(a){case"$type":return["filter-type-in",["literal",n]];case"$id":return["filter-id-in",["literal",n]];default:return n.length>200&&!n.some(s=>typeof s!=typeof n[0])?["filter-in-large",a,["literal",n.sort(Xd)]]:["filter-in-small",a,["literal",n]]}}function Yd(a){switch(a){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",a]}}function Fl(a){return["!",a]}function ha(a){return la(Ot(a.value))?Ps(Tt({},a,{expressionContext:"filter",valueSpec:a.styleSpec[`filter_${a.layerType||"fill"}`]})):Kd(a)}function Kd(a){const n=a.value,s=a.key;if(Qn(n)!=="array")return[new jt(s,n,`array expected, ${Qn(n)} found`)];const u=a.styleSpec;let p,g=[];if(n.length<1)return[new jt(s,n,"filter array must have at least 1 element")];switch(g=g.concat(Rl({key:`${s}[0]`,value:n[0],valueSpec:u.filter_operator,style:a.style,styleSpec:a.styleSpec})),_t(n[0])){case"<":case"<=":case">":case">=":n.length>=2&&_t(n[1])==="$type"&&g.push(new jt(s,n,`"$type" cannot be use with operator "${n[0]}"`));case"==":case"!=":n.length!==3&&g.push(new jt(s,n,`filter array for operator "${n[0]}" must have 3 elements`));case"in":case"!in":n.length>=2&&(p=Qn(n[1]),p!=="string"&&g.push(new jt(`${s}[1]`,n[1],`string expected, ${p} found`)));for(let _=2;_<n.length;_++)p=Qn(n[_]),_t(n[1])==="$type"?g=g.concat(Rl({key:`${s}[${_}]`,value:n[_],valueSpec:u.geometry_type,style:a.style,styleSpec:a.styleSpec})):p!=="string"&&p!=="number"&&p!=="boolean"&&g.push(new jt(`${s}[${_}]`,n[_],`string, number, or boolean expected, ${p} found`));break;case"any":case"all":case"none":for(let _=1;_<n.length;_++)g=g.concat(Kd({key:`${s}[${_}]`,value:n[_],style:a.style,styleSpec:a.styleSpec}));break;case"has":case"!has":p=Qn(n[1]),n.length!==2?g.push(new jt(s,n,`filter array for "${n[0]}" operator must have 2 elements`)):p!=="string"&&g.push(new jt(`${s}[1]`,n[1],`string expected, ${p} found`));break;case"within":p=Qn(n[1]),n.length!==2?g.push(new jt(s,n,`filter array for "${n[0]}" operator must have 2 elements`)):p!=="object"&&g.push(new jt(`${s}[1]`,n[1],`object expected, ${p} found`))}return g}function Jd(a,n){const s=a.key,u=a.style,p=a.styleSpec,g=a.value,_=a.objectKey,T=p[`${n}_${a.layerType}`];if(!T)return[];const D=_.match(/^(.*)-transition$/);if(n==="paint"&&D&&T[D[1]]&&T[D[1]].transition)return Hi({key:s,value:g,valueSpec:p.transition,style:u,styleSpec:p});const I=a.valueSpec||T[_];if(!I)return[new jt(s,g,`unknown property "${_}"`)];let z;if(Qn(g)==="string"&&As(I)&&!I.tokens&&(z=/^{([^}]+)}$/.exec(g)))return[new jt(s,g,`"${_}" does not support interpolation syntax
- Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(z[1])} }\`.`)];const B=[];return a.layerType==="symbol"&&(_==="text-field"&&u&&!u.glyphs&&B.push(new jt(s,g,'use of "text-field" requires a style "glyphs" property')),_==="text-font"&&Wa(Ot(g))&&_t(g.type)==="identity"&&B.push(new jt(s,g,'"text-font" does not support identity functions'))),B.concat(Hi({key:a.key,value:g,valueSpec:I,style:u,styleSpec:p,expressionContext:"property",propertyType:n,propertyKey:_}))}function Iu(a){return Jd(a,"paint")}function Qd(a){return Jd(a,"layout")}function eg(a){let n=[];const s=a.value,u=a.key,p=a.style,g=a.styleSpec;s.type||s.ref||n.push(new jt(u,s,'either "type" or "ref" is required'));let _=_t(s.type);const T=_t(s.ref);if(s.id){const D=_t(s.id);for(let I=0;I<a.arrayIndex;I++){const z=p.layers[I];_t(z.id)===D&&n.push(new jt(u,s.id,`duplicate layer id "${s.id}", previously used at line ${z.id.__line__}`))}}if("ref"in s){let D;["type","source","source-layer","filter","layout"].forEach(I=>{I in s&&n.push(new jt(u,s[I],`"${I}" is prohibited for ref layers`))}),p.layers.forEach(I=>{_t(I.id)===T&&(D=I)}),D?D.ref?n.push(new jt(u,s.ref,"ref cannot reference another ref layer")):_=_t(D.type):typeof T=="string"&&n.push(new jt(u,s.ref,`ref layer "${T}" not found`))}else if(_!=="background"&&_!=="sky")if(s.source){const D=p.sources&&p.sources[s.source],I=D&&_t(D.type);D?I==="vector"&&_==="raster"?n.push(new jt(u,s.source,`layer "${s.id}" requires a raster source`)):I==="raster"&&_!=="raster"?n.push(new jt(u,s.source,`layer "${s.id}" requires a vector source`)):I!=="vector"||s["source-layer"]?I==="raster-dem"&&_!=="hillshade"?n.push(new jt(u,s.source,"raster-dem source can only be used with layer type 'hillshade'.")):_!=="line"||!s.paint||!s.paint["line-gradient"]||I==="geojson"&&D.lineMetrics||n.push(new jt(u,s,`layer "${s.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):n.push(new jt(u,s,`layer "${s.id}" must specify a "source-layer"`)):n.push(new jt(u,s.source,`source "${s.source}" not found`))}else n.push(new jt(u,s,'missing required property "source"'));return n=n.concat($r({key:u,value:s,valueSpec:g.layer,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Hi({key:`${u}.type`,value:s.type,valueSpec:g.layer.type,style:a.style,styleSpec:a.styleSpec,object:s,objectKey:"type"}),filter:D=>ha(Tt({layerType:_},D)),layout:D=>$r({layer:s,key:D.key,value:D.value,valueSpec:{},style:D.style,styleSpec:D.styleSpec,objectElementValidators:{"*":I=>Qd(Tt({layerType:_},I))}}),paint:D=>$r({layer:s,key:D.key,value:D.value,valueSpec:{},style:D.style,styleSpec:D.styleSpec,objectElementValidators:{"*":I=>Iu(Tt({layerType:_},I))}})}})),n}function Oo(a){const n=a.value,s=a.key,u=Qn(n);return u!=="string"?[new jt(s,n,`string expected, ${u} found`)]:[]}const tg={promoteId:function({key:a,value:n}){if(Qn(n)==="string")return Oo({key:a,value:n});{const s=[];for(const u in n)s.push(...Oo({key:`${a}.${u}`,value:n[u]}));return s}}};function ng(a){const n=a.value,s=a.key,u=a.styleSpec,p=a.style;if(!n.type)return[new jt(s,n,'"type" is required')];const g=_t(n.type);let _;switch(g){case"vector":case"raster":case"raster-dem":return _=$r({key:s,value:n,valueSpec:u[`source_${g.replace("-","_")}`],style:a.style,styleSpec:u,objectElementValidators:tg}),_;case"geojson":if(_=$r({key:s,value:n,valueSpec:u.source_geojson,style:p,styleSpec:u,objectElementValidators:tg}),n.cluster)for(const T in n.clusterProperties){const[D,I]=n.clusterProperties[T],z=typeof D=="string"?[D,["accumulated"],["get",T]]:D;_.push(...Ps({key:`${s}.${T}.map`,value:I,expressionContext:"cluster-map"})),_.push(...Ps({key:`${s}.${T}.reduce`,value:z,expressionContext:"cluster-reduce"}))}return _;case"video":return $r({key:s,value:n,valueSpec:u.source_video,style:p,styleSpec:u});case"image":return $r({key:s,value:n,valueSpec:u.source_image,style:p,styleSpec:u});case"canvas":return[new jt(s,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Rl({key:`${s}.type`,value:n.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:p,styleSpec:u})}}function ig(a){const n=a.value,s=a.styleSpec,u=s.light,p=a.style;let g=[];const _=Qn(n);if(n===void 0)return g;if(_!=="object")return g=g.concat([new jt("light",n,`object expected, ${_} found`)]),g;for(const T in n){const D=T.match(/^(.*)-transition$/);g=g.concat(D&&u[D[1]]&&u[D[1]].transition?Hi({key:T,value:n[T],valueSpec:s.transition,style:p,styleSpec:s}):u[T]?Hi({key:T,value:n[T],valueSpec:u[T],style:p,styleSpec:s}):[new jt(T,n[T],`unknown property "${T}"`)])}return g}function rg(a){const n=a.value,s=a.key,u=a.style,p=a.styleSpec,g=p.terrain;let _=[];const T=Qn(n);if(n===void 0)return _;if(T!=="object")return _=_.concat([new jt("terrain",n,`object expected, ${T} found`)]),_;for(const D in n){const I=D.match(/^(.*)-transition$/);_=_.concat(I&&g[I[1]]&&g[I[1]].transition?Hi({key:D,value:n[D],valueSpec:p.transition,style:u,styleSpec:p}):g[D]?Hi({key:D,value:n[D],valueSpec:g[D],style:u,styleSpec:p}):[new jt(D,n[D],`unknown property "${D}"`)])}if(n.source){const D=u.sources&&u.sources[n.source],I=D&&_t(D.type);D?I!=="raster-dem"&&_.push(new jt(s,n.source,`terrain cannot be used with a source of type ${String(I)}, it only be used with a "raster-dem" source type`)):_.push(new jt(s,n.source,`source "${n.source}" not found`))}else _.push(new jt(s,n,'terrain is missing required property "source"'));return _}function og(a){const n=a.value,s=a.style,u=a.styleSpec,p=u.fog;let g=[];const _=Qn(n);if(n===void 0)return g;if(_!=="object")return g=g.concat([new jt("fog",n,`object expected, ${_} found`)]),g;for(const T in n){const D=T.match(/^(.*)-transition$/);g=g.concat(D&&p[D[1]]&&p[D[1]].transition?Hi({key:T,value:n[T],valueSpec:u.transition,style:s,styleSpec:u}):p[T]?Hi({key:T,value:n[T],valueSpec:p[T],style:s,styleSpec:u}):[new jt(T,n[T],`unknown property "${T}"`)])}return g}const Bl={"*":()=>[],array:Il,boolean:function(a){const n=a.value,s=a.key,u=Qn(n);return u!=="boolean"?[new jt(s,n,`boolean expected, ${u} found`)]:[]},number:Ym,color:function(a){const n=a.key,s=a.value,u=Qn(s);return u!=="string"?[new jt(n,s,`color expected, ${u} found`)]:Cd.parseCSSColor(s)===null?[new jt(n,s,`color expected, "${s}" found`)]:[]},enum:Rl,filter:ha,function:Km,layer:eg,object:$r,source:ng,light:ig,terrain:rg,fog:og,string:Oo,formatted:function(a){return Oo(a).length===0?[]:Ps(a)},resolvedImage:function(a){return Oo(a).length===0?[]:Ps(a)},projection:function(a){const n=a.value,s=a.styleSpec,u=s.projection,p=a.style;let g=[];const _=Qn(n);if(_==="object")for(const T in n)g=g.concat(Hi({key:T,value:n[T],valueSpec:u[T],style:p,styleSpec:s}));else _!=="string"&&(g=g.concat([new jt("projection",n,`object or string expected, ${_} found`)]));return g}};function Hi(a){const n=a.value,s=a.valueSpec,u=a.styleSpec;return s.expression&&Wa(_t(n))?Km(a):s.expression&&Ds(Ot(n))?Ps(a):s.type&&Bl[s.type]?Bl[s.type](a):$r(Tt({},a,{valueSpec:s.type?u[s.type]:s}))}function Ir(a){const n=a.value,s=a.key,u=Oo(a);return u.length||(n.indexOf("{fontstack}")===-1&&u.push(new jt(s,n,'"glyphs" url must include a "{fontstack}" token')),n.indexOf("{range}")===-1&&u.push(new jt(s,n,'"glyphs" url must include a "{range}" token'))),u}function Ol(a,n=Te){return No(Hi({key:"",value:a,valueSpec:n.$root,styleSpec:n,style:a,objectElementValidators:{glyphs:Ir,"*":()=>[]}}))}const ov=a=>No(Iu(a)),av=a=>No(Qd(a));function No(a){return a.slice().sort((n,s)=>n.line&&s.line?n.line-s.line:0)}function ag(a,n){let s=!1;if(n&&n.length)for(const u of n)a.fire(new re(new Error(u.message))),s=!0;return s}var da=Mo;function Mo(a,n,s){var u=this.cells=[];if(a instanceof ArrayBuffer){this.arrayBuffer=a;var p=new Int32Array(this.arrayBuffer);a=p[0],this.d=(n=p[1])+2*(s=p[2]);for(var g=0;g<this.d*this.d;g++){var _=p[3+g],T=p[3+g+1];u.push(_===T?null:p.subarray(_,T))}var D=p[3+u.length+1];this.keys=p.subarray(p[3+u.length],D),this.bboxes=p.subarray(D),this.insert=this._insertReadonly}else{this.d=n+2*s;for(var I=0;I<this.d*this.d;I++)u.push([]);this.keys=[],this.bboxes=[]}this.n=n,this.extent=a,this.padding=s,this.scale=n/a,this.uid=0;var z=s/n*a;this.min=-z,this.max=a+z}Mo.prototype.insert=function(a,n,s,u,p){this._forEachCell(n,s,u,p,this._insertCell,this.uid++),this.keys.push(a),this.bboxes.push(n),this.bboxes.push(s),this.bboxes.push(u),this.bboxes.push(p)},Mo.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},Mo.prototype._insertCell=function(a,n,s,u,p,g){this.cells[p].push(g)},Mo.prototype.query=function(a,n,s,u,p){var g=this.min,_=this.max;if(a<=g&&n<=g&&_<=s&&_<=u&&!p)return Array.prototype.slice.call(this.keys);var T=[];return this._forEachCell(a,n,s,u,this._queryCell,T,{},p),T},Mo.prototype._queryCell=function(a,n,s,u,p,g,_,T){var D=this.cells[p];if(D!==null)for(var I=this.keys,z=this.bboxes,B=0;B<D.length;B++){var N=D[B];if(_[N]===void 0){var W=4*N;(T?T(z[W+0],z[W+1],z[W+2],z[W+3]):a<=z[W+2]&&n<=z[W+3]&&s>=z[W+0]&&u>=z[W+1])?(_[N]=!0,g.push(I[N])):_[N]=!1}}},Mo.prototype._forEachCell=function(a,n,s,u,p,g,_,T){for(var D=this._convertToCellCoord(a),I=this._convertToCellCoord(n),z=this._convertToCellCoord(s),B=this._convertToCellCoord(u),N=D;N<=z;N++)for(var W=I;W<=B;W++){var K=this.d*W+N;if((!T||T(this._convertFromCellCoord(N),this._convertFromCellCoord(W),this._convertFromCellCoord(N+1),this._convertFromCellCoord(W+1)))&&p.call(this,a,n,s,u,K,g,_,T))return}},Mo.prototype._convertFromCellCoord=function(a){return(a-this.padding)/this.scale},Mo.prototype._convertToCellCoord=function(a){return Math.max(0,Math.min(this.d-1,Math.floor(a*this.scale)+this.padding))},Mo.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var a=this.cells,n=3+this.cells.length+1+1,s=0,u=0;u<this.cells.length;u++)s+=this.cells[u].length;var p=new Int32Array(n+s+this.keys.length+this.bboxes.length);p[0]=this.extent,p[1]=this.n,p[2]=this.padding;for(var g=n,_=0;_<a.length;_++){var T=a[_];p[3+_]=g,p.set(T,g),g+=T.length}return p[3+a.length]=g,p.set(this.keys,g),p[3+a.length+1]=g+=this.keys.length,p.set(this.bboxes,g),g+=this.bboxes.length,p.buffer};const Ss={};function $t(a,n,s={}){Object.defineProperty(a,"_classRegistryKey",{value:n,writeable:!1}),Ss[n]={klass:a,omit:s.omit||[]}}$t(Object,"Object"),da.serialize=function(a,n){const s=a.toArrayBuffer();return n&&n.push(s),{buffer:s}},da.deserialize=function(a){return new da(a.buffer)},Object.defineProperty(da,"name",{value:"Grid"}),$t(da,"Grid"),$t(Xn,"Color"),$t(Error,"Error"),$t($,"AJAXError"),$t(Pr,"ResolvedImage"),$t(Pu,"StylePropertyFunction"),$t(Du,"StyleExpression",{omit:["_evaluator"]}),$t($d,"ZoomDependentExpression"),$t(Hd,"ZoomConstantExpression"),$t(Sr,"CompoundExpression",{omit:["_evaluate"]});for(const a in Va)Ss[Va[a]._classRegistryKey]||$t(Va[a],`Expression${a}`);function sg(a){return a&&typeof ArrayBuffer!="undefined"&&(a instanceof ArrayBuffer||a.constructor&&a.constructor.name==="ArrayBuffer")}function Ru(a){return L.ImageBitmap&&a instanceof L.ImageBitmap}function Nl(a,n){if(a==null||typeof a=="boolean"||typeof a=="number"||typeof a=="string"||a instanceof Boolean||a instanceof Number||a instanceof String||a instanceof Date||a instanceof RegExp)return a;if(sg(a)||Ru(a))return n&&n.push(a),a;if(ArrayBuffer.isView(a)){const s=a;return n&&n.push(s.buffer),s}if(a instanceof L.ImageData)return n&&n.push(a.data.buffer),a;if(Array.isArray(a)){const s=[];for(const u of a)s.push(Nl(u,n));return s}if(typeof a=="object"){const s=a.constructor,u=s._classRegistryKey;if(!u)throw new Error(`can't serialize object of unregistered class ${u}`);const p=s.serialize?s.serialize(a,n):{};if(!s.serialize){for(const g in a)a.hasOwnProperty(g)&&(Ss[u].omit.indexOf(g)>=0||(p[g]=Nl(a[g],n)));a instanceof Error&&(p.message=a.message)}if(p.$name)throw new Error("$name property is reserved for worker serialization logic.");return u!=="Object"&&(p.$name=u),p}throw new Error("can't serialize object of type "+typeof a)}function Ls(a){if(a==null||typeof a=="boolean"||typeof a=="number"||typeof a=="string"||a instanceof Boolean||a instanceof Number||a instanceof String||a instanceof Date||a instanceof RegExp||sg(a)||Ru(a)||ArrayBuffer.isView(a)||a instanceof L.ImageData)return a;if(Array.isArray(a))return a.map(Ls);if(typeof a=="object"){const n=a.$name||"Object",{klass:s}=Ss[n];if(!s)throw new Error(`can't deserialize unregistered class ${n}`);if(s.deserialize)return s.deserialize(a);const u=Object.create(s.prototype);for(const p of Object.keys(a))p!=="$name"&&(u[p]=Ls(a[p]));return u}throw new Error("can't deserialize object of type "+typeof a)}class ep{constructor(){this.first=!0}update(n,s){const u=Math.floor(n);return this.first?(this.first=!1,this.lastIntegerZoom=u,this.lastIntegerZoomTime=0,this.lastZoom=n,this.lastFloorZoom=u,!0):(this.lastFloorZoom>u?(this.lastIntegerZoom=u+1,this.lastIntegerZoomTime=s):this.lastFloorZoom<u&&(this.lastIntegerZoom=u,this.lastIntegerZoomTime=s),n!==this.lastZoom&&(this.lastZoom=n,this.lastFloorZoom=u,!0))}}const lg=a=>a>=1536&&a<=1791,ku=a=>a>=1872&&a<=1919,Ul=a=>a>=2208&&a<=2303,tp=a=>a>=11904&&a<=12031,cg=a=>a>=12032&&a<=12255,np=a=>a>=12272&&a<=12287,zu=a=>a>=12288&&a<=12351,Vl=a=>a>=12352&&a<=12447,Fu=a=>a>=12448&&a<=12543,ug=a=>a>=12544&&a<=12591,hg=a=>a>=12704&&a<=12735,dg=a=>a>=12736&&a<=12783,ip=a=>a>=12784&&a<=12799,pg=a=>a>=12800&&a<=13055,fg=a=>a>=13056&&a<=13311,mg=a=>a>=13312&&a<=19903,rp=a=>a>=19968&&a<=40959,gg=a=>a>=40960&&a<=42127,yg=a=>a>=42128&&a<=42191,_g=a=>a>=44032&&a<=55215,Gl=a=>a>=63744&&a<=64255,op=a=>a>=64336&&a<=65023,vg=a=>a>=65040&&a<=65055,Is=a=>a>=65072&&a<=65103,xg=a=>a>=65104&&a<=65135,Bu=a=>a>=65136&&a<=65279,ap=a=>a>=65280&&a<=65519;function Ou(a){for(const n of a)if(Nu(n.charCodeAt(0)))return!0;return!1}function bg(a){for(const n of a)if(!wg(n.charCodeAt(0)))return!1;return!0}function wg(a){return!(lg(a)||ku(a)||Ul(a)||op(a)||Bu(a))}function Nu(a){return!(a!==746&&a!==747&&(a<4352||!(hg(a)||ug(a)||Is(a)&&!(a>=65097&&a<=65103)||Gl(a)||fg(a)||tp(a)||dg(a)||!(!zu(a)||a>=12296&&a<=12305||a>=12308&&a<=12319||a===12336)||mg(a)||rp(a)||pg(a)||(n=>n>=12592&&n<=12687)(a)||(n=>n>=43360&&n<=43391)(a)||(n=>n>=55216&&n<=55295)(a)||(n=>n>=4352&&n<=4607)(a)||_g(a)||Vl(a)||np(a)||(n=>n>=12688&&n<=12703)(a)||cg(a)||ip(a)||Fu(a)&&a!==12540||!(!ap(a)||a===65288||a===65289||a===65293||a>=65306&&a<=65310||a===65339||a===65341||a===65343||a>=65371&&a<=65503||a===65507||a>=65512&&a<=65519)||!(!xg(a)||a>=65112&&a<=65118||a>=65123&&a<=65126)||(n=>n>=5120&&n<=5759)(a)||(n=>n>=6320&&n<=6399)(a)||vg(a)||(n=>n>=19904&&n<=19967)(a)||gg(a)||yg(a))))}function Uu(a){return!(Nu(a)||function(n){return!!((s=>s>=128&&s<=255)(n)&&(n===167||n===169||n===174||n===177||n===188||n===189||n===190||n===215||n===247)||(s=>s>=8192&&s<=8303)(n)&&(n===8214||n===8224||n===8225||n===8240||n===8241||n===8251||n===8252||n===8258||n===8263||n===8264||n===8265||n===8273)||(s=>s>=8448&&s<=8527)(n)||(s=>s>=8528&&s<=8591)(n)||(s=>s>=8960&&s<=9215)(n)&&(n>=8960&&n<=8967||n>=8972&&n<=8991||n>=8996&&n<=9e3||n===9003||n>=9085&&n<=9114||n>=9150&&n<=9165||n===9167||n>=9169&&n<=9179||n>=9186&&n<=9215)||(s=>s>=9216&&s<=9279)(n)&&n!==9251||(s=>s>=9280&&s<=9311)(n)||(s=>s>=9312&&s<=9471)(n)||(s=>s>=9632&&s<=9727)(n)||(s=>s>=9728&&s<=9983)(n)&&!(n>=9754&&n<=9759)||(s=>s>=11008&&s<=11263)(n)&&(n>=11026&&n<=11055||n>=11088&&n<=11097||n>=11192&&n<=11243)||zu(n)||Fu(n)||(s=>s>=57344&&s<=63743)(n)||Is(n)||xg(n)||ap(n)||n===8734||n===8756||n===8757||n>=9984&&n<=10087||n>=10102&&n<=10131||n===65532||n===65533)}(a))}function Vu(a){return a>=1424&&a<=2303||op(a)||Bu(a)}function sv(a,n){return!(!n&&Vu(a)||a>=2304&&a<=3583||a>=3840&&a<=4255||(s=>s>=6016&&s<=6143)(a))}function lv(a){for(const n of a)if(Vu(n.charCodeAt(0)))return!0;return!1}const sp="deferred",Wl="loading",lp="loaded";let cp=null,_r="unavailable",Rr=null;const jl=function(a){a&&typeof a=="string"&&a.indexOf("NetworkError")>-1&&(_r="error"),cp&&cp(a)};function ja(){up.fire(new Y("pluginStateChange",{pluginStatus:_r,pluginURL:Rr}))}const up=new Fe,Gu=function(){return _r},Rs=function(){if(_r!==sp||!Rr)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");_r=Wl,ja(),Rr&&Re({url:Rr},a=>{a?jl(a):(_r=lp,ja())})},qr={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>_r===lp||qr.applyArabicShaping!=null,isLoading:()=>_r===Wl,setState(a){_r=a.pluginStatus,Rr=a.pluginURL},isParsed:()=>qr.applyArabicShaping!=null&&qr.processBidirectionalText!=null&&qr.processStyledBidirectionalText!=null,getPluginURL:()=>Rr};class ci{constructor(n,s){this.zoom=n,s?(this.now=s.now,this.fadeDuration=s.fadeDuration,this.zoomHistory=s.zoomHistory,this.transition=s.transition,this.pitch=s.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ep,this.transition={},this.pitch=0)}isSupportedScript(n){return function(s,u){for(const p of s)if(!sv(p.charCodeAt(0),u))return!1;return!0}(n,qr.isLoaded())}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const n=this.zoom,s=n-Math.floor(n),u=this.crossFadingFactor();return n>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:s+(1-s)*u}:{fromScale:.5,toScale:1,t:1-(1-u)*s}}}class Hl{constructor(n,s){this.property=n,this.value=s,this.expression=function(u,p){if(Wa(u))return new Pu(u,p);if(Ds(u)){const g=Zm(u,p);if(g.result==="error")throw new Error(g.value.map(_=>`${_.key}: ${_.message}`).join(", "));return g.value}{let g=u;return typeof u=="string"&&p.type==="color"&&(g=Xn.parse(u)),{kind:"constant",evaluate:()=>g}}}(s===void 0?n.specification.default:s,n.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(n,s,u){return this.property.possiblyEvaluate(this,n,s,u)}}class ks{constructor(n){this.property=n,this.value=new Hl(n,void 0)}transitioned(n,s){return new o(this.property,this.value,s,me({},n.transition,this.transition),n.now)}untransitioned(){return new o(this.property,this.value,null,{},0)}}class m{constructor(n){this._properties=n,this._values=Object.create(n.defaultTransitionablePropertyValues)}getValue(n){return Nt(this._values[n].value.value)}setValue(n,s){this._values.hasOwnProperty(n)||(this._values[n]=new ks(this._values[n].property)),this._values[n].value=new Hl(this._values[n].property,s===null?void 0:Nt(s))}getTransition(n){return Nt(this._values[n].transition)}setTransition(n,s){this._values.hasOwnProperty(n)||(this._values[n]=new ks(this._values[n].property)),this._values[n].transition=Nt(s)||void 0}serialize(){const n={};for(const s of Object.keys(this._values)){const u=this.getValue(s);u!==void 0&&(n[s]=u);const p=this.getTransition(s);p!==void 0&&(n[`${s}-transition`]=p)}return n}transitioned(n,s){const u=new d(this._properties);for(const p of Object.keys(this._values))u._values[p]=this._values[p].transitioned(n,s._values[p]);return u}untransitioned(){const n=new d(this._properties);for(const s of Object.keys(this._values))n._values[s]=this._values[s].untransitioned();return n}}class o{constructor(n,s,u,p,g){const _=p.delay||0,T=p.duration||0;g=g||0,this.property=n,this.value=s,this.begin=g+_,this.end=this.begin+T,n.specification.transition&&(p.delay||p.duration)&&(this.prior=u)}possiblyEvaluate(n,s,u){const p=n.now||0,g=this.value.possiblyEvaluate(n,s,u),_=this.prior;if(_){if(p>this.end)return this.prior=null,g;if(this.value.isDataDriven())return this.prior=null,g;if(p<this.begin)return _.possiblyEvaluate(n,s,u);{const T=(p-this.begin)/(this.end-this.begin);return this.property.interpolate(_.possiblyEvaluate(n,s,u),g,J(T))}}return g}}class d{constructor(n){this._properties=n,this._values=Object.create(n.defaultTransitioningPropertyValues)}possiblyEvaluate(n,s,u){const p=new C(this._properties);for(const g of Object.keys(this._values))p._values[g]=this._values[g].possiblyEvaluate(n,s,u);return p}hasTransition(){for(const n of Object.keys(this._values))if(this._values[n].prior)return!0;return!1}}class y{constructor(n){this._properties=n,this._values=Object.create(n.defaultPropertyValues)}getValue(n){return Nt(this._values[n].value)}setValue(n,s){this._values[n]=new Hl(this._values[n].property,s===null?void 0:Nt(s))}serialize(){const n={};for(const s of Object.keys(this._values)){const u=this.getValue(s);u!==void 0&&(n[s]=u)}return n}possiblyEvaluate(n,s,u){const p=new C(this._properties);for(const g of Object.keys(this._values))p._values[g]=this._values[g].possiblyEvaluate(n,s,u);return p}}class E{constructor(n,s,u){this.property=n,this.value=s,this.parameters=u}isConstant(){return this.value.kind==="constant"}constantOr(n){return this.value.kind==="constant"?this.value.value:n}evaluate(n,s,u,p){return this.property.evaluate(this.value,this.parameters,n,s,u,p)}}class C{constructor(n){this._properties=n,this._values=Object.create(n.defaultPossiblyEvaluatedValues)}get(n){return this._values[n]}}class S{constructor(n){this.specification=n}possiblyEvaluate(n,s){return n.expression.evaluate(s)}interpolate(n,s,u){const p=_u[this.specification.type];return p?p(n,s,u):n}}class k{constructor(n,s){this.specification=n,this.overrides=s}possiblyEvaluate(n,s,u,p){return new E(this,n.expression.kind==="constant"||n.expression.kind==="camera"?{kind:"constant",value:n.expression.evaluate(s,null,{},u,p)}:n.expression,s)}interpolate(n,s,u){if(n.value.kind!=="constant"||s.value.kind!=="constant")return n;if(n.value.value===void 0||s.value.value===void 0)return new E(this,{kind:"constant",value:void 0},n.parameters);const p=_u[this.specification.type];return p?new E(this,{kind:"constant",value:p(n.value.value,s.value.value,u)},n.parameters):n}evaluate(n,s,u,p,g,_){return n.kind==="constant"?n.value:n.evaluate(s,u,p,g,_)}}class O extends k{possiblyEvaluate(n,s,u,p){if(n.value===void 0)return new E(this,{kind:"constant",value:void 0},s);if(n.expression.kind==="constant"){const g=n.expression.evaluate(s,null,{},u,p),_=n.property.specification.type==="resolvedImage"&&typeof g!="string"?g.name:g,T=this._calculate(_,_,_,s);return new E(this,{kind:"constant",value:T},s)}if(n.expression.kind==="camera"){const g=this._calculate(n.expression.evaluate({zoom:s.zoom-1}),n.expression.evaluate({zoom:s.zoom}),n.expression.evaluate({zoom:s.zoom+1}),s);return new E(this,{kind:"constant",value:g},s)}return new E(this,n.expression,s)}evaluate(n,s,u,p,g,_){if(n.kind==="source"){const T=n.evaluate(s,u,p,g,_);return this._calculate(T,T,T,s)}return n.kind==="composite"?this._calculate(n.evaluate({zoom:Math.floor(s.zoom)-1},u,p),n.evaluate({zoom:Math.floor(s.zoom)},u,p),n.evaluate({zoom:Math.floor(s.zoom)+1},u,p),s):n.value}_calculate(n,s,u,p){return p.zoom>p.zoomHistory.lastIntegerZoom?{from:n,to:s,other:u}:{from:u,to:s,other:n}}interpolate(n){return n}}class U{constructor(n){this.specification=n}possiblyEvaluate(n,s,u,p){if(n.value!==void 0){if(n.expression.kind==="constant"){const g=n.expression.evaluate(s,null,{},u,p);return this._calculate(g,g,g,s)}return this._calculate(n.expression.evaluate(new ci(Math.floor(s.zoom-1),s)),n.expression.evaluate(new ci(Math.floor(s.zoom),s)),n.expression.evaluate(new ci(Math.floor(s.zoom+1),s)),s)}}_calculate(n,s,u,p){return p.zoom>p.zoomHistory.lastIntegerZoom?{from:n,to:s}:{from:u,to:s}}interpolate(n){return n}}class G{constructor(n){this.specification=n}possiblyEvaluate(n,s,u,p){return!!n.expression.evaluate(s,null,{},u,p)}interpolate(){return!1}}class Z{constructor(n){this.properties=n,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const s in n){const u=n[s];u.specification.overridable&&this.overridableProperties.push(s);const p=this.defaultPropertyValues[s]=new Hl(u,void 0),g=this.defaultTransitionablePropertyValues[s]=new ks(u);this.defaultTransitioningPropertyValues[s]=g.untransitioned(),this.defaultPossiblyEvaluatedValues[s]=p.possiblyEvaluate({})}}}function se(a,n){return 256*(a=Q(Math.floor(a),0,255))+Q(Math.floor(n),0,255)}$t(k,"DataDrivenProperty"),$t(S,"DataConstantProperty"),$t(O,"CrossFadedDataDrivenProperty"),$t(U,"CrossFadedProperty"),$t(G,"ColorRampProperty");const de={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class ce{constructor(n,s){this._structArray=n,this._pos1=s*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class te{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(n,s){return n._trim(),s&&(n.isTransferred=!0,s.push(n.arrayBuffer)),{length:n.length,arrayBuffer:n.arrayBuffer}}static deserialize(n){const s=Object.create(this.prototype);return s.arrayBuffer=n.arrayBuffer,s.length=n.length,s.capacity=n.arrayBuffer.byteLength/s.bytesPerElement,s._refreshViews(),s}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(n){this.reserve(n),this.length=n}reserve(n){if(n>this.capacity){this.capacity=Math.max(n,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const s=this.uint8;this._refreshViews(),s&&this.uint8.set(s)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Le(a,n=1){let s=0,u=0;return{members:a.map(p=>{const g=de[p.type].BYTES_PER_ELEMENT,_=s=ve(s,Math.max(n,g)),T=p.components||1;return u=Math.max(u,g),s+=g*T,{name:p.name,type:p.type,components:T,offset:_}}),size:ve(s,Math.max(u,n)),alignment:n}}function ve(a,n){return Math.ceil(a/n)*n}class De extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,s){const u=this.length;return this.resize(u+1),this.emplace(u,n,s)}emplace(n,s,u){const p=2*n;return this.int16[p+0]=s,this.int16[p+1]=u,n}}De.prototype.bytesPerElement=4,$t(De,"StructArrayLayout2i4");class Se extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,s,u){const p=this.length;return this.resize(p+1),this.emplace(p,n,s,u)}emplace(n,s,u,p){const g=3*n;return this.int16[g+0]=s,this.int16[g+1]=u,this.int16[g+2]=p,n}}Se.prototype.bytesPerElement=6,$t(Se,"StructArrayLayout3i6");class ze extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,s,u,p){const g=this.length;return this.resize(g+1),this.emplace(g,n,s,u,p)}emplace(n,s,u,p,g){const _=4*n;return this.int16[_+0]=s,this.int16[_+1]=u,this.int16[_+2]=p,this.int16[_+3]=g,n}}ze.prototype.bytesPerElement=8,$t(ze,"StructArrayLayout4i8");class Ee extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_,T){const D=this.length;return this.resize(D+1),this.emplace(D,n,s,u,p,g,_,T)}emplace(n,s,u,p,g,_,T,D){const I=6*n,z=12*n,B=3*n;return this.int16[I+0]=s,this.int16[I+1]=u,this.uint8[z+4]=p,this.uint8[z+5]=g,this.uint8[z+6]=_,this.uint8[z+7]=T,this.float32[B+2]=D,n}}Ee.prototype.bytesPerElement=12,$t(Ee,"StructArrayLayout2i4ub1f12");class Ue extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,s,u,p){const g=this.length;return this.resize(g+1),this.emplace(g,n,s,u,p)}emplace(n,s,u,p,g){const _=4*n;return this.float32[_+0]=s,this.float32[_+1]=u,this.float32[_+2]=p,this.float32[_+3]=g,n}}Ue.prototype.bytesPerElement=16,$t(Ue,"StructArrayLayout4f16");class nt extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_,T,D,I,z){const B=this.length;return this.resize(B+1),this.emplace(B,n,s,u,p,g,_,T,D,I,z)}emplace(n,s,u,p,g,_,T,D,I,z,B){const N=10*n;return this.uint16[N+0]=s,this.uint16[N+1]=u,this.uint16[N+2]=p,this.uint16[N+3]=g,this.uint16[N+4]=_,this.uint16[N+5]=T,this.uint16[N+6]=D,this.uint16[N+7]=I,this.uint16[N+8]=z,this.uint16[N+9]=B,n}}nt.prototype.bytesPerElement=20,$t(nt,"StructArrayLayout10ui20");class lt extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_,T,D){const I=this.length;return this.resize(I+1),this.emplace(I,n,s,u,p,g,_,T,D)}emplace(n,s,u,p,g,_,T,D,I){const z=8*n;return this.uint16[z+0]=s,this.uint16[z+1]=u,this.uint16[z+2]=p,this.uint16[z+3]=g,this.uint16[z+4]=_,this.uint16[z+5]=T,this.uint16[z+6]=D,this.uint16[z+7]=I,n}}lt.prototype.bytesPerElement=16,$t(lt,"StructArrayLayout8ui16");class pt extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_){const T=this.length;return this.resize(T+1),this.emplace(T,n,s,u,p,g,_)}emplace(n,s,u,p,g,_,T){const D=6*n;return this.int16[D+0]=s,this.int16[D+1]=u,this.int16[D+2]=p,this.int16[D+3]=g,this.int16[D+4]=_,this.int16[D+5]=T,n}}pt.prototype.bytesPerElement=12,$t(pt,"StructArrayLayout6i12");class ht extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue){const xe=this.length;return this.resize(xe+1),this.emplace(xe,n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue)}emplace(n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue,xe){const Be=16*n;return this.int16[Be+0]=s,this.int16[Be+1]=u,this.int16[Be+2]=p,this.int16[Be+3]=g,this.uint16[Be+4]=_,this.uint16[Be+5]=T,this.uint16[Be+6]=D,this.uint16[Be+7]=I,this.int16[Be+8]=z,this.int16[Be+9]=B,this.int16[Be+10]=N,this.int16[Be+11]=W,this.int16[Be+12]=K,this.int16[Be+13]=oe,this.int16[Be+14]=ue,this.int16[Be+15]=xe,n}}ht.prototype.bytesPerElement=32,$t(ht,"StructArrayLayout4i4ui4i4i32");class kt extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,s,u){const p=this.length;return this.resize(p+1),this.emplace(p,n,s,u)}emplace(n,s,u,p){const g=3*n;return this.float32[g+0]=s,this.float32[g+1]=u,this.float32[g+2]=p,n}}kt.prototype.bytesPerElement=12,$t(kt,"StructArrayLayout3f12");class it extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(n){const s=this.length;return this.resize(s+1),this.emplace(s,n)}emplace(n,s){return this.uint32[1*n+0]=s,n}}it.prototype.bytesPerElement=4,$t(it,"StructArrayLayout1ul4");class zt extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_,T,D,I,z,B,N,W){const K=this.length;return this.resize(K+1),this.emplace(K,n,s,u,p,g,_,T,D,I,z,B,N,W)}emplace(n,s,u,p,g,_,T,D,I,z,B,N,W,K){const oe=20*n,ue=10*n;return this.int16[oe+0]=s,this.int16[oe+1]=u,this.int16[oe+2]=p,this.int16[oe+3]=g,this.int16[oe+4]=_,this.float32[ue+3]=T,this.float32[ue+4]=D,this.float32[ue+5]=I,this.float32[ue+6]=z,this.int16[oe+14]=B,this.uint32[ue+8]=N,this.uint16[oe+18]=W,this.uint16[oe+19]=K,n}}zt.prototype.bytesPerElement=40,$t(zt,"StructArrayLayout5i4f1i1ul2ui40");class St extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_,T){const D=this.length;return this.resize(D+1),this.emplace(D,n,s,u,p,g,_,T)}emplace(n,s,u,p,g,_,T,D){const I=8*n;return this.int16[I+0]=s,this.int16[I+1]=u,this.int16[I+2]=p,this.int16[I+4]=g,this.int16[I+5]=_,this.int16[I+6]=T,this.int16[I+7]=D,n}}St.prototype.bytesPerElement=16,$t(St,"StructArrayLayout3i2i2i16");class Jt extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g){const _=this.length;return this.resize(_+1),this.emplace(_,n,s,u,p,g)}emplace(n,s,u,p,g,_){const T=4*n,D=8*n;return this.float32[T+0]=s,this.float32[T+1]=u,this.float32[T+2]=p,this.int16[D+6]=g,this.int16[D+7]=_,n}}Jt.prototype.bytesPerElement=16,$t(Jt,"StructArrayLayout2f1f2i16");class ft extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,s,u,p){const g=this.length;return this.resize(g+1),this.emplace(g,n,s,u,p)}emplace(n,s,u,p,g){const _=12*n,T=3*n;return this.uint8[_+0]=s,this.uint8[_+1]=u,this.float32[T+1]=p,this.float32[T+2]=g,n}}ft.prototype.bytesPerElement=12,$t(ft,"StructArrayLayout2ub2f12");class qt extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,s,u){const p=this.length;return this.resize(p+1),this.emplace(p,n,s,u)}emplace(n,s,u,p){const g=3*n;return this.uint16[g+0]=s,this.uint16[g+1]=u,this.uint16[g+2]=p,n}}qt.prototype.bytesPerElement=6,$t(qt,"StructArrayLayout3ui6");class gn extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue,xe,Be,$e,Ze,Ye){const Ke=this.length;return this.resize(Ke+1),this.emplace(Ke,n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue,xe,Be,$e,Ze,Ye)}emplace(n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue,xe,Be,$e,Ze,Ye,Ke){const ut=30*n,dt=15*n,xt=60*n;return this.int16[ut+0]=s,this.int16[ut+1]=u,this.int16[ut+2]=p,this.float32[dt+2]=g,this.float32[dt+3]=_,this.uint16[ut+8]=T,this.uint16[ut+9]=D,this.uint32[dt+5]=I,this.uint32[dt+6]=z,this.uint32[dt+7]=B,this.uint16[ut+16]=N,this.uint16[ut+17]=W,this.uint16[ut+18]=K,this.float32[dt+10]=oe,this.float32[dt+11]=ue,this.uint8[xt+48]=xe,this.uint8[xt+49]=Be,this.uint8[xt+50]=$e,this.uint32[dt+13]=Ze,this.int16[ut+28]=Ye,this.uint8[xt+58]=Ke,n}}gn.prototype.bytesPerElement=60,$t(gn,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Zt extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue,xe,Be,$e,Ze,Ye,Ke,ut,dt,xt,Et,st,mt,Pt,Bt){const Rt=this.length;return this.resize(Rt+1),this.emplace(Rt,n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue,xe,Be,$e,Ze,Ye,Ke,ut,dt,xt,Et,st,mt,Pt,Bt)}emplace(n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue,xe,Be,$e,Ze,Ye,Ke,ut,dt,xt,Et,st,mt,Pt,Bt,Rt){const Ft=38*n,En=19*n;return this.int16[Ft+0]=s,this.int16[Ft+1]=u,this.int16[Ft+2]=p,this.float32[En+2]=g,this.float32[En+3]=_,this.int16[Ft+8]=T,this.int16[Ft+9]=D,this.int16[Ft+10]=I,this.int16[Ft+11]=z,this.int16[Ft+12]=B,this.int16[Ft+13]=N,this.uint16[Ft+14]=W,this.uint16[Ft+15]=K,this.uint16[Ft+16]=oe,this.uint16[Ft+17]=ue,this.uint16[Ft+18]=xe,this.uint16[Ft+19]=Be,this.uint16[Ft+20]=$e,this.uint16[Ft+21]=Ze,this.uint16[Ft+22]=Ye,this.uint16[Ft+23]=Ke,this.uint16[Ft+24]=ut,this.uint16[Ft+25]=dt,this.uint16[Ft+26]=xt,this.uint16[Ft+27]=Et,this.uint16[Ft+28]=st,this.uint32[En+15]=mt,this.float32[En+16]=Pt,this.float32[En+17]=Bt,this.float32[En+18]=Rt,n}}Zt.prototype.bytesPerElement=76,$t(Zt,"StructArrayLayout3i2f6i15ui1ul3f76");class Yt extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n){const s=this.length;return this.resize(s+1),this.emplace(s,n)}emplace(n,s){return this.float32[1*n+0]=s,n}}Yt.prototype.bytesPerElement=4,$t(Yt,"StructArrayLayout1f4");class xn extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_,T){const D=this.length;return this.resize(D+1),this.emplace(D,n,s,u,p,g,_,T)}emplace(n,s,u,p,g,_,T,D){const I=7*n;return this.float32[I+0]=s,this.float32[I+1]=u,this.float32[I+2]=p,this.float32[I+3]=g,this.float32[I+4]=_,this.float32[I+5]=T,this.float32[I+6]=D,n}}xn.prototype.bytesPerElement=28,$t(xn,"StructArrayLayout7f28");class zn extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g){const _=this.length;return this.resize(_+1),this.emplace(_,n,s,u,p,g)}emplace(n,s,u,p,g,_){const T=5*n;return this.float32[T+0]=s,this.float32[T+1]=u,this.float32[T+2]=p,this.float32[T+3]=g,this.float32[T+4]=_,n}}zn.prototype.bytesPerElement=20,$t(zn,"StructArrayLayout5f20");class dn extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,s,u,p){const g=this.length;return this.resize(g+1),this.emplace(g,n,s,u,p)}emplace(n,s,u,p,g){const _=6*n;return this.uint32[3*n+0]=s,this.uint16[_+2]=u,this.uint16[_+3]=p,this.uint16[_+4]=g,n}}dn.prototype.bytesPerElement=12,$t(dn,"StructArrayLayout1ul3ui12");class Mn extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,s){const u=this.length;return this.resize(u+1),this.emplace(u,n,s)}emplace(n,s,u){const p=2*n;return this.uint16[p+0]=s,this.uint16[p+1]=u,n}}Mn.prototype.bytesPerElement=4,$t(Mn,"StructArrayLayout2ui4");class $n extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n){const s=this.length;return this.resize(s+1),this.emplace(s,n)}emplace(n,s){return this.uint16[1*n+0]=s,n}}$n.prototype.bytesPerElement=2,$t($n,"StructArrayLayout1ui2");class vi extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,s){const u=this.length;return this.resize(u+1),this.emplace(u,n,s)}emplace(n,s,u){const p=2*n;return this.float32[p+0]=s,this.float32[p+1]=u,n}}vi.prototype.bytesPerElement=8,$t(vi,"StructArrayLayout2f8");class nr extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_,T){const D=this.length;return this.resize(D+1),this.emplace(D,n,s,u,p,g,_,T)}emplace(n,s,u,p,g,_,T,D){const I=8*n,z=4*n;return this.int16[I+0]=s,this.int16[I+1]=u,this.int16[I+2]=p,this.int16[I+3]=g,this.int16[I+4]=_,this.int16[I+5]=T,this.float32[z+3]=D,n}}nr.prototype.bytesPerElement=16,$t(nr,"StructArrayLayout6i1f16");class ir extends ce{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}ir.prototype.size=12;class kr extends pt{get(n){return new ir(this,n)}}$t(kr,"FillExtrusionExtArray");class mo extends ce{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}mo.prototype.size=40;class Uo extends zt{get(n){return new mo(this,n)}}$t(Uo,"CollisionBoxArray");class pa extends ce{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(n){this._structArray.uint8[this._pos1+49]=n}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(n){this._structArray.uint8[this._pos1+50]=n}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(n){this._structArray.uint32[this._pos4+13]=n}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(n){this._structArray.uint8[this._pos1+58]=n}}pa.prototype.size=60;class Vo extends gn{get(n){return new pa(this,n)}}$t(Vo,"PlacedSymbolArray");class bi extends ce{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(n){this._structArray.uint32[this._pos4+15]=n}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}bi.prototype.size=76;class Ti extends Zt{get(n){return new bi(this,n)}}$t(Ti,"SymbolInstanceArray");class Yn extends Yt{getoffsetX(n){return this.float32[1*n+0]}}$t(Yn,"GlyphOffsetArray");class Si extends Se{getx(n){return this.int16[3*n+0]}gety(n){return this.int16[3*n+1]}gettileUnitDistanceFromAnchor(n){return this.int16[3*n+2]}}$t(Si,"SymbolLineVertexArray");class zr extends ce{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}zr.prototype.size=12;class xi extends dn{get(n){return new zr(this,n)}}$t(xi,"FeatureIndexArray");class Xr extends ce{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}Xr.prototype.size=4;class $l extends Mn{get(n){return new Xr(this,n)}}$t($l,"FillExtrusionCentroidArray");class Fr extends ce{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}get a_scale(){return this._structArray.float32[this._pos4+3]}}Fr.prototype.size=16;class Ha extends nr{get(n){return new Fr(this,n)}}$t(Ha,"CircleGlobeExtArray");const Mg=Le([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"}]),hp=Le([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var zs=hu(function(a){a.exports=function(n,s){var u,p,g,_,T,D,I,z;for(p=n.length-(u=3&n.length),g=s,T=3432918353,D=461845907,z=0;z<p;)I=255&n.charCodeAt(z)|(255&n.charCodeAt(++z))<<8|(255&n.charCodeAt(++z))<<16|(255&n.charCodeAt(++z))<<24,++z,g=27492+(65535&(_=5*(65535&(g=(g^=I=(65535&(I=(I=(65535&I)*T+(((I>>>16)*T&65535)<<16)&4294967295)<<15|I>>>17))*D+(((I>>>16)*D&65535)<<16)&4294967295)<<13|g>>>19))+((5*(g>>>16)&65535)<<16)&4294967295))+((58964+(_>>>16)&65535)<<16);switch(I=0,u){case 3:I^=(255&n.charCodeAt(z+2))<<16;case 2:I^=(255&n.charCodeAt(z+1))<<8;case 1:g^=I=(65535&(I=(I=(65535&(I^=255&n.charCodeAt(z)))*T+(((I>>>16)*T&65535)<<16)&4294967295)<<15|I>>>17))*D+(((I>>>16)*D&65535)<<16)&4294967295}return g^=n.length,g=2246822507*(65535&(g^=g>>>16))+((2246822507*(g>>>16)&65535)<<16)&4294967295,g=3266489909*(65535&(g^=g>>>13))+((3266489909*(g>>>16)&65535)<<16)&4294967295,(g^=g>>>16)>>>0}}),cv=hu(function(a){a.exports=function(n,s){for(var u,p=n.length,g=s^p,_=0;p>=4;)u=1540483477*(65535&(u=255&n.charCodeAt(_)|(255&n.charCodeAt(++_))<<8|(255&n.charCodeAt(++_))<<16|(255&n.charCodeAt(++_))<<24))+((1540483477*(u>>>16)&65535)<<16),g=1540483477*(65535&g)+((1540483477*(g>>>16)&65535)<<16)^(u=1540483477*(65535&(u^=u>>>24))+((1540483477*(u>>>16)&65535)<<16)),p-=4,++_;switch(p){case 3:g^=(255&n.charCodeAt(_+2))<<16;case 2:g^=(255&n.charCodeAt(_+1))<<8;case 1:g=1540483477*(65535&(g^=255&n.charCodeAt(_)))+((1540483477*(g>>>16)&65535)<<16)}return g=1540483477*(65535&(g^=g>>>13))+((1540483477*(g>>>16)&65535)<<16),(g^=g>>>15)>>>0}}),fa=zs,dp=cv;fa.murmur3=zs,fa.murmur2=dp;class Tg{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(n,s,u,p){this.ids.push(vb(n)),this.positions.push(s,u,p)}getPositions(n){const s=vb(n);let u=0,p=this.ids.length-1;for(;u<p;){const _=u+p>>1;this.ids[_]>=s?p=_:u=_+1}const g=[];for(;this.ids[u]===s;)g.push({index:this.positions[3*u],start:this.positions[3*u+1],end:this.positions[3*u+2]}),u++;return g}static serialize(n,s){const u=new Float64Array(n.ids),p=new Uint32Array(n.positions);return uv(u,p,0,u.length-1),s&&s.push(u.buffer,p.buffer),{ids:u,positions:p}}static deserialize(n){const s=new Tg;return s.ids=n.ids,s.positions=n.positions,s.indexed=!0,s}}function vb(a){const n=+a;return!isNaN(n)&&Number.MIN_SAFE_INTEGER<=n&&n<=Number.MAX_SAFE_INTEGER?n:fa(String(a))}function uv(a,n,s,u){for(;s<u;){const p=a[s+u>>1];let g=s-1,_=u+1;for(;;){do g++;while(a[g]<p);do _--;while(a[_]>p);if(g>=_)break;Eg(a,g,_),Eg(n,3*g,3*_),Eg(n,3*g+1,3*_+1),Eg(n,3*g+2,3*_+2)}_-s<u-_?(uv(a,n,s,_),s=_+1):(uv(a,n,_+1,u),u=_)}}function Eg(a,n,s){const u=a[n];a[n]=a[s],a[s]=u}$t(Tg,"FeaturePositionMap");class $a{constructor(n,s){this.gl=n.gl,this.location=s}}class Cg extends $a{constructor(n,s){super(n,s),this.current=0}set(n){this.current!==n&&(this.current=n,this.gl.uniform1f(this.location,n))}}class xb extends $a{constructor(n,s){super(n,s),this.current=[0,0,0,0]}set(n){n[0]===this.current[0]&&n[1]===this.current[1]&&n[2]===this.current[2]&&n[3]===this.current[3]||(this.current=n,this.gl.uniform4f(this.location,n[0],n[1],n[2],n[3]))}}class bb extends $a{constructor(n,s){super(n,s),this.current=Xn.transparent}set(n){n.r===this.current.r&&n.g===this.current.g&&n.b===this.current.b&&n.a===this.current.a||(this.current=n,this.gl.uniform4f(this.location,n.r,n.g,n.b,n.a))}}const Mk=new Float32Array(16),Tk=new Float32Array(9),Ek=new Float32Array(4);function hv(a){return[se(255*a.r,255*a.g),se(255*a.b,255*a.a)]}class pp{constructor(n,s,u){this.value=n,this.uniformNames=s.map(p=>`u_${p}`),this.type=u}setUniform(n,s,u){n.set(u.constantOr(this.value))}getBinding(n,s,u){return this.type==="color"?new bb(n,s):new Cg(n,s)}}class Wu{constructor(n,s){this.uniformNames=s.map(u=>`u_${u}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(n,s){this.pixelRatioFrom=s.pixelRatio||1,this.pixelRatioTo=n.pixelRatio||1,this.patternFrom=s.tl.concat(s.br),this.patternTo=n.tl.concat(n.br)}setUniform(n,s,u,p){const g=p==="u_pattern_to"||p==="u_dash_to"?this.patternTo:p==="u_pattern_from"||p==="u_dash_from"?this.patternFrom:p==="u_pixel_ratio_to"?this.pixelRatioTo:p==="u_pixel_ratio_from"?this.pixelRatioFrom:null;g&&n.set(g)}getBinding(n,s,u){return u==="u_pattern_from"||u==="u_pattern_to"||u==="u_dash_from"||u==="u_dash_to"?new xb(n,s):new Cg(n,s)}}class qa{constructor(n,s,u,p){this.expression=n,this.type=u,this.maxValue=0,this.paintVertexAttributes=s.map(g=>({name:`a_${g}`,type:"Float32",components:u==="color"?2:1,offset:0})),this.paintVertexArray=new p}populatePaintArray(n,s,u,p,g,_){const T=this.paintVertexArray.length,D=this.expression.evaluate(new ci(0),s,{},g,p,_);this.paintVertexArray.resize(n),this._setPaintValue(T,n,D)}updatePaintArray(n,s,u,p,g){const _=this.expression.evaluate({zoom:0},u,p,void 0,g);this._setPaintValue(n,s,_)}_setPaintValue(n,s,u){if(this.type==="color"){const p=hv(u);for(let g=n;g<s;g++)this.paintVertexArray.emplace(g,p[0],p[1])}else{for(let p=n;p<s;p++)this.paintVertexArray.emplace(p,u);this.maxValue=Math.max(this.maxValue,Math.abs(u))}}upload(n){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=n.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Go{constructor(n,s,u,p,g,_){this.expression=n,this.uniformNames=s.map(T=>`u_${T}_t`),this.type=u,this.useIntegerZoom=p,this.zoom=g,this.maxValue=0,this.paintVertexAttributes=s.map(T=>({name:`a_${T}`,type:"Float32",components:u==="color"?4:2,offset:0})),this.paintVertexArray=new _}populatePaintArray(n,s,u,p,g,_){const T=this.expression.evaluate(new ci(this.zoom),s,{},g,p,_),D=this.expression.evaluate(new ci(this.zoom+1),s,{},g,p,_),I=this.paintVertexArray.length;this.paintVertexArray.resize(n),this._setPaintValue(I,n,T,D)}updatePaintArray(n,s,u,p,g){const _=this.expression.evaluate({zoom:this.zoom},u,p,void 0,g),T=this.expression.evaluate({zoom:this.zoom+1},u,p,void 0,g);this._setPaintValue(n,s,_,T)}_setPaintValue(n,s,u,p){if(this.type==="color"){const g=hv(u),_=hv(p);for(let T=n;T<s;T++)this.paintVertexArray.emplace(T,g[0],g[1],_[0],_[1])}else{for(let g=n;g<s;g++)this.paintVertexArray.emplace(g,u,p);this.maxValue=Math.max(this.maxValue,Math.abs(u),Math.abs(p))}}upload(n){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=n.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(n,s){const u=this.useIntegerZoom?Math.floor(s.zoom):s.zoom,p=Q(this.expression.interpolationFactor(u,this.zoom,this.zoom+1),0,1);n.set(p)}getBinding(n,s,u){return new Cg(n,s)}}class Fs{constructor(n,s,u,p,g,_,T){this.expression=n,this.type=u,this.useIntegerZoom=p,this.zoom=g,this.layerId=T,this.paintVertexAttributes=(u==="array"?hp:Mg).members;for(let D=0;D<s.length;++D);this.zoomInPaintVertexArray=new _,this.zoomOutPaintVertexArray=new _}populatePaintArray(n,s,u){const p=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(n),this.zoomOutPaintVertexArray.resize(n),this._setPaintValues(p,n,s.patterns&&s.patterns[this.layerId],u)}updatePaintArray(n,s,u,p,g,_){this._setPaintValues(n,s,u.patterns&&u.patterns[this.layerId],_)}_setPaintValues(n,s,u,p){if(!p||!u)return;const{min:g,mid:_,max:T}=u,D=p[g],I=p[_],z=p[T];if(D&&I&&z)for(let B=n;B<s;B++)this._setPaintValue(this.zoomInPaintVertexArray,B,I,D),this._setPaintValue(this.zoomOutPaintVertexArray,B,I,z)}_setPaintValue(n,s,u,p){n.emplace(s,u.tl[0],u.tl[1],u.br[0],u.br[1],p.tl[0],p.tl[1],p.br[0],p.br[1],u.pixelRatio,p.pixelRatio)}upload(n){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=n.createVertexBuffer(this.zoomInPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=n.createVertexBuffer(this.zoomOutPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class Bs{constructor(n,s,u=()=>!0){this.binders={},this._buffers=[];const p=[];for(const g in n.paint._values){if(!u(g))continue;const _=n.paint.get(g);if(!(_ instanceof E&&As(_.property.specification)))continue;const T=Ak(g,n.type),D=_.value,I=_.property.specification.type,z=_.property.useIntegerZoom,B=_.property.specification["property-type"],N=B==="cross-faded"||B==="cross-faded-data-driven",W=String(g)==="line-dasharray"&&n.layout.get("line-cap").value.kind!=="constant";if(D.kind!=="constant"||W)if(D.kind==="source"||W||N){const K=wb(g,I,"source");this.binders[g]=N?new Fs(D,T,I,z,s,K,n.id):new qa(D,T,I,K),p.push(`/a_${g}`)}else{const K=wb(g,I,"composite");this.binders[g]=new Go(D,T,I,z,s,K),p.push(`/z_${g}`)}else this.binders[g]=N?new Wu(D.value,T):new pp(D.value,T,I),p.push(`/u_${g}`)}this.cacheKey=p.sort().join("")}getMaxValue(n){const s=this.binders[n];return s instanceof qa||s instanceof Go?s.maxValue:0}populatePaintArrays(n,s,u,p,g,_){for(const T in this.binders){const D=this.binders[T];(D instanceof qa||D instanceof Go||D instanceof Fs)&&D.populatePaintArray(n,s,u,p,g,_)}}setConstantPatternPositions(n,s){for(const u in this.binders){const p=this.binders[u];p instanceof Wu&&p.setConstantPatternPositions(n,s)}}updatePaintArrays(n,s,u,p,g,_){let T=!1;for(const D in n){const I=s.getPositions(D);for(const z of I){const B=u.feature(z.index);for(const N in this.binders){const W=this.binders[N];if((W instanceof qa||W instanceof Go||W instanceof Fs)&&W.expression.isStateDependent===!0){const K=p.paint.get(N);W.expression=K.value,W.updatePaintArray(z.start,z.end,B,n[D],g,_),T=!0}}}}return T}defines(){const n=[];for(const s in this.binders){const u=this.binders[s];(u instanceof pp||u instanceof Wu)&&n.push(...u.uniformNames.map(p=>`#define HAS_UNIFORM_${p}`))}return n}getBinderAttributes(){const n=[];for(const s in this.binders){const u=this.binders[s];if(u instanceof qa||u instanceof Go||u instanceof Fs)for(let p=0;p<u.paintVertexAttributes.length;p++)n.push(u.paintVertexAttributes[p].name)}return n}getBinderUniforms(){const n=[];for(const s in this.binders){const u=this.binders[s];if(u instanceof pp||u instanceof Wu||u instanceof Go)for(const p of u.uniformNames)n.push(p)}return n}getPaintVertexBuffers(){return this._buffers}getUniforms(n,s){const u=[];for(const p in this.binders){const g=this.binders[p];if(g instanceof pp||g instanceof Wu||g instanceof Go){for(const _ of g.uniformNames)if(s[_]){const T=g.getBinding(n,s[_],_);u.push({name:_,property:p,binding:T})}}}return u}setUniforms(n,s,u,p){for(const{name:g,property:_,binding:T}of s)this.binders[_].setUniform(T,p,u.get(_),g)}updatePaintBuffers(n){this._buffers=[];for(const s in this.binders){const u=this.binders[s];if(n&&u instanceof Fs){const p=n.fromScale===2?u.zoomInPaintVertexBuffer:u.zoomOutPaintVertexBuffer;p&&this._buffers.push(p)}else(u instanceof qa||u instanceof Go)&&u.paintVertexBuffer&&this._buffers.push(u.paintVertexBuffer)}}upload(n){for(const s in this.binders){const u=this.binders[s];(u instanceof qa||u instanceof Go||u instanceof Fs)&&u.upload(n)}this.updatePaintBuffers()}destroy(){for(const n in this.binders){const s=this.binders[n];(s instanceof qa||s instanceof Go||s instanceof Fs)&&s.destroy()}}}class ql{constructor(n,s,u=()=>!0){this.programConfigurations={};for(const p of n)this.programConfigurations[p.id]=new Bs(p,s,u);this.needsUpload=!1,this._featureMap=new Tg,this._bufferOffset=0}populatePaintArrays(n,s,u,p,g,_,T){for(const D in this.programConfigurations)this.programConfigurations[D].populatePaintArrays(n,s,p,g,_,T);s.id!==void 0&&this._featureMap.add(s.id,u,this._bufferOffset,n),this._bufferOffset=n,this.needsUpload=!0}updatePaintArrays(n,s,u,p,g){for(const _ of u)this.needsUpload=this.programConfigurations[_.id].updatePaintArrays(n,this._featureMap,s,_,p,g)||this.needsUpload}get(n){return this.programConfigurations[n]}upload(n){if(this.needsUpload){for(const s in this.programConfigurations)this.programConfigurations[s].upload(n);this.needsUpload=!1}}destroy(){for(const n in this.programConfigurations)this.programConfigurations[n].destroy()}}const Ck={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"line-dasharray":["dash_to","dash_from"]};function Ak(a,n){return Ck[a]||[a.replace(`${n}-`,"").replace(/-/g,"_")]}const Dk={"line-pattern":{source:nt,composite:nt},"fill-pattern":{source:nt,composite:nt},"fill-extrusion-pattern":{source:nt,composite:nt},"line-dasharray":{source:lt,composite:lt}},Pk={color:{source:vi,composite:Ue},number:{source:Yt,composite:vi}};function wb(a,n,s){const u=Dk[a];return u&&u[s]||Pk[n][s]}$t(pp,"ConstantBinder"),$t(Wu,"CrossFadedConstantBinder"),$t(qa,"SourceExpressionBinder"),$t(Fs,"CrossFadedCompositeBinder"),$t(Go,"CompositeExpressionBinder"),$t(Bs,"ProgramConfiguration",{omit:["_buffers"]}),$t(ql,"ProgramConfigurationSet");const Ag="-transition";class Wo extends Fe{constructor(n,s){if(super(),this.id=n.id,this.type=n.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,n.type!=="custom"&&(this.metadata=(n=n).metadata,this.minzoom=n.minzoom,this.maxzoom=n.maxzoom,n.type!=="background"&&n.type!=="sky"&&(this.source=n.source,this.sourceLayer=n["source-layer"],this.filter=n.filter),s.layout&&(this._unevaluatedLayout=new y(s.layout)),s.paint)){this._transitionablePaint=new m(s.paint);for(const u in n.paint)this.setPaintProperty(u,n.paint[u],{validate:!1});for(const u in n.layout)this.setLayoutProperty(u,n.layout[u],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new C(s.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(n){return n==="visibility"?this.visibility:this._unevaluatedLayout.getValue(n)}setLayoutProperty(n,s,u={}){s!=null&&this._validate(av,`layers.${this.id}.layout.${n}`,n,s,u)||(n!=="visibility"?this._unevaluatedLayout.setValue(n,s):this.visibility=s)}getPaintProperty(n){return yt(n,Ag)?this._transitionablePaint.getTransition(n.slice(0,-Ag.length)):this._transitionablePaint.getValue(n)}setPaintProperty(n,s,u={}){if(s!=null&&this._validate(ov,`layers.${this.id}.paint.${n}`,n,s,u))return!1;if(yt(n,Ag))return this._transitionablePaint.setTransition(n.slice(0,-Ag.length),s||void 0),!1;{const p=this._transitionablePaint._values[n],g=p.property.specification["property-type"]==="cross-faded-data-driven",_=p.value.isDataDriven(),T=p.value;this._transitionablePaint.setValue(n,s),this._handleSpecialPaintPropertyUpdate(n);const D=this._transitionablePaint._values[n].value;return D.isDataDriven()||_||g||this._handleOverridablePaintPropertyUpdate(n,T,D)}}_handleSpecialPaintPropertyUpdate(n){}getProgramIds(){return null}getProgramConfiguration(n){return null}_handleOverridablePaintPropertyUpdate(n,s,u){return!1}isHidden(n){return!!(this.minzoom&&n<this.minzoom)||!!(this.maxzoom&&n>=this.maxzoom)||this.visibility==="none"}updateTransitions(n){this._transitioningPaint=this._transitionablePaint.transitioned(n,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(n,s){n.getCrossfadeParameters&&(this._crossfadeParameters=n.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(n,void 0,s)),this.paint=this._transitioningPaint.possiblyEvaluate(n,void 0,s)}serialize(){const n={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(n.layout=n.layout||{},n.layout.visibility=this.visibility),It(n,(s,u)=>!(s===void 0||u==="layout"&&!Object.keys(s).length||u==="paint"&&!Object.keys(s).length))}_validate(n,s,u,p,g={}){return(!g||g.validate!==!1)&&ag(this,n.call(Ol,{key:s,layerType:this.type,objectKey:u,value:p,styleSpec:Te,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const n in this.paint._values){const s=this.paint.get(n);if(s instanceof E&&As(s.property.specification)&&(s.value.kind==="source"||s.value.kind==="composite")&&s.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=ca(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const Sk=Le([{name:"a_pos",components:2,type:"Int16"}],4),Lk=Le([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"},{name:"a_scale",components:1,type:"Float32"}]);class Ei{constructor(n=[]){this.segments=n}prepareSegment(n,s,u,p){let g=this.segments[this.segments.length-1];return n>Ei.MAX_VERTEX_ARRAY_LENGTH&&be(`Max vertices per segment is ${Ei.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${n}`),(!g||g.vertexLength+n>Ei.MAX_VERTEX_ARRAY_LENGTH||g.sortKey!==p)&&(g={vertexOffset:s.length,primitiveOffset:u.length,vertexLength:0,primitiveLength:0},p!==void 0&&(g.sortKey=p),this.segments.push(g)),g}get(){return this.segments}destroy(){for(const n of this.segments)for(const s in n.vaos)n.vaos[s].destroy()}static simpleSegment(n,s,u,p){return new Ei([{vertexOffset:n,primitiveOffset:s,vertexLength:u,primitiveLength:p,vaos:{},sortKey:0}])}}Ei.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,$t(Ei,"SegmentVector");var In=8192;class Os{constructor(n,s){n&&(s?this.setSouthWest(n).setNorthEast(s):n.length===4?this.setSouthWest([n[0],n[1]]).setNorthEast([n[2],n[3]]):this.setSouthWest(n[0]).setNorthEast(n[1]))}setNorthEast(n){return this._ne=n instanceof ti?new ti(n.lng,n.lat):ti.convert(n),this}setSouthWest(n){return this._sw=n instanceof ti?new ti(n.lng,n.lat):ti.convert(n),this}extend(n){const s=this._sw,u=this._ne;let p,g;if(n instanceof ti)p=n,g=n;else{if(!(n instanceof Os))return Array.isArray(n)?n.length===4||n.every(Array.isArray)?this.extend(Os.convert(n)):this.extend(ti.convert(n)):this;if(p=n._sw,g=n._ne,!p||!g)return this}return s||u?(s.lng=Math.min(p.lng,s.lng),s.lat=Math.min(p.lat,s.lat),u.lng=Math.max(g.lng,u.lng),u.lat=Math.max(g.lat,u.lat)):(this._sw=new ti(p.lng,p.lat),this._ne=new ti(g.lng,g.lat)),this}getCenter(){return new ti((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new ti(this.getWest(),this.getNorth())}getSouthEast(){return new ti(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(n){const{lng:s,lat:u}=ti.convert(n);let p=this._sw.lng<=s&&s<=this._ne.lng;return this._sw.lng>this._ne.lng&&(p=this._sw.lng>=s&&s>=this._ne.lng),this._sw.lat<=u&&u<=this._ne.lat&&p}static convert(n){return!n||n instanceof Os?n:new Os(n)}}const dv=63710088e-1;class ti{constructor(n,s){if(isNaN(n)||isNaN(s))throw new Error(`Invalid LngLat object: (${n}, ${s})`);if(this.lng=+n,this.lat=+s,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new ti(ie(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(n){const s=Math.PI/180,u=this.lat*s,p=n.lat*s,g=Math.sin(u)*Math.sin(p)+Math.cos(u)*Math.cos(p)*Math.cos((n.lng-this.lng)*s);return dv*Math.acos(Math.min(g,1))}toBounds(n=0){const s=360*n/40075017,u=s/Math.cos(Math.PI/180*this.lat);return new Os(new ti(this.lng-u,this.lat-s),new ti(this.lng+u,this.lat+s))}static convert(n){if(n instanceof ti)return n;if(Array.isArray(n)&&(n.length===2||n.length===3))return new ti(Number(n[0]),Number(n[1]));if(!Array.isArray(n)&&typeof n=="object"&&n!==null)return new ti(Number("lng"in n?n.lng:n.lon),Number(n.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const Mb=2*Math.PI*dv;function pv(a){return Mb*Math.cos(a*Math.PI/180)}function fp(a){return(180+a)/360}function ju(a){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a*Math.PI/360)))/360}function Hu(a,n){return a/pv(n)}function To(a){return 360*a-180}function rr(a){return 360/Math.PI*Math.atan(Math.exp((180-360*a)*Math.PI/180))-90}function Tb(a,n){return a*pv(rr(n))}const ma=85.051129;class Dg{constructor(n,s,u=0){this.x=+n,this.y=+s,this.z=+u}static fromLngLat(n,s=0){const u=ti.convert(n);return new Dg(fp(u.lng),ju(u.lat),Hu(s,u.lat))}toLngLat(){return new ti(To(this.x),rr(this.y))}toAltitude(){return Tb(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Mb*(n=rr(this.y),1/Math.cos(n*Math.PI/180));var n}}function fv(a,n,s,u,p,g,_,T,D){const I=(n+u)/2,z=(s+p)/2,B=new b(I,z);T(B),function(N,W,K,oe,ue,xe){const Be=K-ue,$e=oe-xe;return Math.abs((oe-W)*Be-(K-N)*$e)/Math.hypot(Be,$e)}(B.x,B.y,g.x,g.y,_.x,_.y)>=D?(fv(a,n,s,I,z,g,B,T,D),fv(a,I,z,u,p,B,_,T,D)):a.push(_)}function Ik(a,n,s){let u=a[0],p=u.x,g=u.y;n(u);const _=[u];for(let T=1;T<a.length;T++){const D=a[T],{x:I,y:z}=D;n(D),fv(_,p,g,I,z,u,D,n,s),p=I,g=z,u=D}return _}const mv=Math.pow(2,14)-1,Eb=-mv-1;function Rk(a,n){const s=Math.round(a.x*n),u=Math.round(a.y*n);return a.x=Q(s,Eb,mv),a.y=Q(u,Eb,mv),(s<a.x||s>a.x+1||u<a.y||u>a.y+1)&&be("Geometry exceeds allowed extent, reduce your vector tile buffer size"),a}function Xa(a,n,s){const u=a.loadGeometry(),p=a.extent,g=In/p;if(n&&s&&s.projection.isReprojectedInTileSpace){const _=1<<n.z,{scale:T,x:D,y:I,projection:z}=s,B=N=>{const W=To((n.x+N.x/p)/_),K=rr((n.y+N.y/p)/_),oe=z.project(W,K);N.x=(oe.x*T-D)*p,N.y=(oe.y*T-I)*p};for(let N=0;N<u.length;N++)if(a.type!==1)u[N]=Ik(u[N],B,1);else{const W=[];for(const K of u[N])K.x<0||K.x>=p||K.y<0||K.y>=p||(B(K),W.push(K));u[N]=W}}for(const _ of u)for(const T of _)Rk(T,g);return u}function Xl(a,n){return{type:a.type,id:a.id,properties:a.properties,geometry:n?Xa(a):[]}}function Pg(a,n,s,u,p){a.emplaceBack(2*n+(u+1)/2,2*s+(p+1)/2)}function Sg(a,n,s,u){a.emplaceBack(n.x,n.y,n.z,s[0]*16384,s[1]*16384,s[2]*16384,u)}class gv{constructor(n){this.zoom=n.zoom,this.overscaling=n.overscaling,this.layers=n.layers,this.layerIds=this.layers.map(s=>s.id),this.index=n.index,this.hasPattern=!1,this.projection=n.projection,this.layoutVertexArray=new De,this.indexArray=new qt,this.segments=new Ei,this.programConfigurations=new ql(n.layers,n.zoom),this.stateDependentLayerIds=this.layers.filter(s=>s.isStateDependent()).map(s=>s.id)}populate(n,s,u,p){const g=this.layers[0],_=[];let T=null;g.type==="circle"&&(T=g.layout.get("circle-sort-key"));for(const{feature:I,id:z,index:B,sourceLayerIndex:N}of n){const W=this.layers[0]._featureFilter.needGeometry,K=Xl(I,W);if(!this.layers[0]._featureFilter.filter(new ci(this.zoom),K,u))continue;const oe=T?T.evaluate(K,{},u):void 0,ue={id:z,properties:I.properties,type:I.type,sourceLayerIndex:N,index:B,geometry:W?K.geometry:Xa(I,u,p),patterns:{},sortKey:oe};_.push(ue)}T&&_.sort((I,z)=>I.sortKey-z.sortKey);let D=null;p.projection.name==="globe"&&(this.globeExtVertexArray=new Ha,D=p.projection);for(const I of _){const{geometry:z,index:B,sourceLayerIndex:N}=I,W=n[B].feature;this.addFeature(I,z,B,s.availableImages,u,D),s.featureIndex.insert(W,z,B,N,this.index)}}update(n,s,u,p){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(n,s,this.stateDependentLayers,u,p)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(n){this.uploaded||(this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,Sk.members),this.indexBuffer=n.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=n.createVertexBuffer(this.globeExtVertexArray,Lk.members))),this.programConfigurations.upload(n),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(n,s,u,p,g,_){for(const T of s)for(const D of T){const I=D.x,z=D.y;if(I<0||I>=In||z<0||z>=In)continue;if(_){const W=_.projectTilePoint(I,z,g),K=_.upVector(g,I,z),oe=rr((z/In+g.y)/(1<<g.z)),ue=_.pixelsPerMeter(oe,1)/Hu(1,oe),xe=this.globeExtVertexArray;Sg(xe,W,K,ue),Sg(xe,W,K,ue),Sg(xe,W,K,ue),Sg(xe,W,K,ue)}const B=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,n.sortKey),N=B.vertexLength;Pg(this.layoutVertexArray,I,z,-1,-1),Pg(this.layoutVertexArray,I,z,1,-1),Pg(this.layoutVertexArray,I,z,1,1),Pg(this.layoutVertexArray,I,z,-1,1),this.indexArray.emplaceBack(N,N+1,N+2),this.indexArray.emplaceBack(N,N+3,N+2),B.vertexLength+=4,B.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,n,u,{},p,g)}}function Cb(a,n){for(let s=0;s<a.length;s++)if($u(n,a[s]))return!0;for(let s=0;s<n.length;s++)if($u(a,n[s]))return!0;return!!yv(a,n)}function kk(a,n,s){return!!$u(a,n)||!!_v(n,a,s)}function Ab(a,n){if(a.length===1)return Pb(n,a[0]);for(let s=0;s<n.length;s++){const u=n[s];for(let p=0;p<u.length;p++)if($u(a,u[p]))return!0}for(let s=0;s<a.length;s++)if(Pb(n,a[s]))return!0;for(let s=0;s<n.length;s++)if(yv(a,n[s]))return!0;return!1}function zk(a,n,s){if(a.length>1){if(yv(a,n))return!0;for(let u=0;u<n.length;u++)if(_v(n[u],a,s))return!0}for(let u=0;u<a.length;u++)if(_v(a[u],n,s))return!0;return!1}function yv(a,n){if(a.length===0||n.length===0)return!1;for(let s=0;s<a.length-1;s++){const u=a[s],p=a[s+1];for(let g=0;g<n.length-1;g++)if(Fk(u,p,n[g],n[g+1]))return!0}return!1}function Fk(a,n,s,u){return We(a,s,u)!==We(n,s,u)&&We(a,n,s)!==We(a,n,u)}function _v(a,n,s){const u=s*s;if(n.length===1)return a.distSqr(n[0])<u;for(let p=1;p<n.length;p++)if(Db(a,n[p-1],n[p])<u)return!0;return!1}function Db(a,n,s){const u=n.distSqr(s);if(u===0)return a.distSqr(n);const p=((a.x-n.x)*(s.x-n.x)+(a.y-n.y)*(s.y-n.y))/u;return a.distSqr(p<0?n:p>1?s:s.sub(n)._mult(p)._add(n))}function Pb(a,n){let s,u,p,g=!1;for(let _=0;_<a.length;_++){s=a[_];for(let T=0,D=s.length-1;T<s.length;D=T++)u=s[T],p=s[D],u.y>n.y!=p.y>n.y&&n.x<(p.x-u.x)*(n.y-u.y)/(p.y-u.y)+u.x&&(g=!g)}return g}function $u(a,n){let s=!1;for(let u=0,p=a.length-1;u<a.length;p=u++){const g=a[u],_=a[p];g.y>n.y!=_.y>n.y&&n.x<(_.x-g.x)*(n.y-g.y)/(_.y-g.y)+g.x&&(s=!s)}return s}function Sb(a,n,s,u,p){for(const _ of a)if(n<=_.x&&s<=_.y&&u>=_.x&&p>=_.y)return!0;const g=[new b(n,s),new b(n,p),new b(u,p),new b(u,s)];if(a.length>2){for(const _ of g)if($u(a,_))return!0}for(let _=0;_<a.length-1;_++)if(Bk(a[_],a[_+1],g))return!0;return!1}function Bk(a,n,s){const u=s[0],p=s[2];if(a.x<u.x&&n.x<u.x||a.x>p.x&&n.x>p.x||a.y<u.y&&n.y<u.y||a.y>p.y&&n.y>p.y)return!1;const g=We(a,n,s[0]);return g!==We(a,n,s[1])||g!==We(a,n,s[2])||g!==We(a,n,s[3])}function qu(a,n,s){const u=n.paint.get(a).value;return u.kind==="constant"?u.value:s.programConfigurations.get(n.id).getMaxValue(a)}function Lg(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1])}function Lb(a,n,s,u,p){if(!n[0]&&!n[1])return a;const g=b.convert(n)._mult(p);s==="viewport"&&g._rotate(-u);const _=[];for(let T=0;T<a.length;T++)_.push(a[T].sub(g));return _}function Ib(a,n,s,u){const p=b.convert(a)._mult(u);return n==="viewport"&&p._rotate(-s),p}$t(gv,"CircleBucket",{omit:["layers"]});const Ok=new Z({"circle-sort-key":new k(Te.layout_circle["circle-sort-key"])});var Nk={paint:new Z({"circle-radius":new k(Te.paint_circle["circle-radius"]),"circle-color":new k(Te.paint_circle["circle-color"]),"circle-blur":new k(Te.paint_circle["circle-blur"]),"circle-opacity":new k(Te.paint_circle["circle-opacity"]),"circle-translate":new S(Te.paint_circle["circle-translate"]),"circle-translate-anchor":new S(Te.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new S(Te.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new S(Te.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new k(Te.paint_circle["circle-stroke-width"]),"circle-stroke-color":new k(Te.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new k(Te.paint_circle["circle-stroke-opacity"])}),layout:Ok},vv=1e-6,Zr=typeof Float32Array!="undefined"?Float32Array:Array;function Rb(){var a=new Zr(9);return Zr!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[5]=0,a[6]=0,a[7]=0),a[0]=1,a[4]=1,a[8]=1,a}function ga(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a}function xv(a,n,s){var u=n[0],p=n[1],g=n[2],_=n[3],T=n[4],D=n[5],I=n[6],z=n[7],B=n[8],N=n[9],W=n[10],K=n[11],oe=n[12],ue=n[13],xe=n[14],Be=n[15],$e=s[0],Ze=s[1],Ye=s[2],Ke=s[3];return a[0]=$e*u+Ze*T+Ye*B+Ke*oe,a[1]=$e*p+Ze*D+Ye*N+Ke*ue,a[2]=$e*g+Ze*I+Ye*W+Ke*xe,a[3]=$e*_+Ze*z+Ye*K+Ke*Be,a[4]=($e=s[4])*u+(Ze=s[5])*T+(Ye=s[6])*B+(Ke=s[7])*oe,a[5]=$e*p+Ze*D+Ye*N+Ke*ue,a[6]=$e*g+Ze*I+Ye*W+Ke*xe,a[7]=$e*_+Ze*z+Ye*K+Ke*Be,a[8]=($e=s[8])*u+(Ze=s[9])*T+(Ye=s[10])*B+(Ke=s[11])*oe,a[9]=$e*p+Ze*D+Ye*N+Ke*ue,a[10]=$e*g+Ze*I+Ye*W+Ke*xe,a[11]=$e*_+Ze*z+Ye*K+Ke*Be,a[12]=($e=s[12])*u+(Ze=s[13])*T+(Ye=s[14])*B+(Ke=s[15])*oe,a[13]=$e*p+Ze*D+Ye*N+Ke*ue,a[14]=$e*g+Ze*I+Ye*W+Ke*xe,a[15]=$e*_+Ze*z+Ye*K+Ke*Be,a}function Zl(a,n,s){var u,p,g,_,T,D,I,z,B,N,W,K,oe=s[0],ue=s[1],xe=s[2];return n===a?(a[12]=n[0]*oe+n[4]*ue+n[8]*xe+n[12],a[13]=n[1]*oe+n[5]*ue+n[9]*xe+n[13],a[14]=n[2]*oe+n[6]*ue+n[10]*xe+n[14],a[15]=n[3]*oe+n[7]*ue+n[11]*xe+n[15]):(p=n[1],g=n[2],_=n[3],T=n[4],D=n[5],I=n[6],z=n[7],B=n[8],N=n[9],W=n[10],K=n[11],a[0]=u=n[0],a[1]=p,a[2]=g,a[3]=_,a[4]=T,a[5]=D,a[6]=I,a[7]=z,a[8]=B,a[9]=N,a[10]=W,a[11]=K,a[12]=u*oe+T*ue+B*xe+n[12],a[13]=p*oe+D*ue+N*xe+n[13],a[14]=g*oe+I*ue+W*xe+n[14],a[15]=_*oe+z*ue+K*xe+n[15]),a}function Ns(a,n,s){var u=s[0],p=s[1],g=s[2];return a[0]=n[0]*u,a[1]=n[1]*u,a[2]=n[2]*u,a[3]=n[3]*u,a[4]=n[4]*p,a[5]=n[5]*p,a[6]=n[6]*p,a[7]=n[7]*p,a[8]=n[8]*g,a[9]=n[9]*g,a[10]=n[10]*g,a[11]=n[11]*g,a[12]=n[12],a[13]=n[13],a[14]=n[14],a[15]=n[15],a}function bv(a,n,s){var u=Math.sin(s),p=Math.cos(s),g=n[4],_=n[5],T=n[6],D=n[7],I=n[8],z=n[9],B=n[10],N=n[11];return n!==a&&(a[0]=n[0],a[1]=n[1],a[2]=n[2],a[3]=n[3],a[12]=n[12],a[13]=n[13],a[14]=n[14],a[15]=n[15]),a[4]=g*p+I*u,a[5]=_*p+z*u,a[6]=T*p+B*u,a[7]=D*p+N*u,a[8]=I*p-g*u,a[9]=z*p-_*u,a[10]=B*p-T*u,a[11]=N*p-D*u,a}function wv(a,n,s){var u=Math.sin(s),p=Math.cos(s),g=n[0],_=n[1],T=n[2],D=n[3],I=n[8],z=n[9],B=n[10],N=n[11];return n!==a&&(a[4]=n[4],a[5]=n[5],a[6]=n[6],a[7]=n[7],a[12]=n[12],a[13]=n[13],a[14]=n[14],a[15]=n[15]),a[0]=g*p-I*u,a[1]=_*p-z*u,a[2]=T*p-B*u,a[3]=D*p-N*u,a[8]=g*u+I*p,a[9]=_*u+z*p,a[10]=T*u+B*p,a[11]=D*u+N*p,a}Math.hypot||(Math.hypot=function(){for(var a=0,n=arguments.length;n--;)a+=arguments[n]*arguments[n];return Math.sqrt(a)});var Uk=xv;function Mv(){var a=new Zr(3);return Zr!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a}function kb(a){var n=new Zr(3);return n[0]=a[0],n[1]=a[1],n[2]=a[2],n}function zb(a){return Math.hypot(a[0],a[1],a[2])}function mp(a,n,s){var u=new Zr(3);return u[0]=a,u[1]=n,u[2]=s,u}function Fb(a,n,s){return a[0]=n[0]+s[0],a[1]=n[1]+s[1],a[2]=n[2]+s[2],a}function Bb(a,n,s){return a[0]=n[0]-s[0],a[1]=n[1]-s[1],a[2]=n[2]-s[2],a}function Ob(a,n,s){return a[0]=n[0]*s[0],a[1]=n[1]*s[1],a[2]=n[2]*s[2],a}function Tv(a,n,s){return a[0]=Math.min(n[0],s[0]),a[1]=Math.min(n[1],s[1]),a[2]=Math.min(n[2],s[2]),a}function Ev(a,n,s){return a[0]=Math.max(n[0],s[0]),a[1]=Math.max(n[1],s[1]),a[2]=Math.max(n[2],s[2]),a}function gp(a,n,s){return a[0]=n[0]*s,a[1]=n[1]*s,a[2]=n[2]*s,a}function Cv(a,n,s,u){return a[0]=n[0]+s[0]*u,a[1]=n[1]+s[1]*u,a[2]=n[2]+s[2]*u,a}function yp(a,n){var s=n[0],u=n[1],p=n[2],g=s*s+u*u+p*p;return g>0&&(g=1/Math.sqrt(g)),a[0]=n[0]*g,a[1]=n[1]*g,a[2]=n[2]*g,a}function _p(a,n){return a[0]*n[0]+a[1]*n[1]+a[2]*n[2]}function Nb(a,n,s){var u=n[0],p=n[1],g=n[2],_=s[0],T=s[1],D=s[2];return a[0]=p*D-g*T,a[1]=g*_-u*D,a[2]=u*T-p*_,a}function Yl(a,n,s){var u=n[0],p=n[1],g=n[2],_=s[3]*u+s[7]*p+s[11]*g+s[15];return a[0]=(s[0]*u+s[4]*p+s[8]*g+s[12])/(_=_||1),a[1]=(s[1]*u+s[5]*p+s[9]*g+s[13])/_,a[2]=(s[2]*u+s[6]*p+s[10]*g+s[14])/_,a}function Ub(a,n,s){var u=s[0],p=s[1],g=s[2],_=n[0],T=n[1],D=n[2],I=p*D-g*T,z=g*_-u*D,B=u*T-p*_,N=p*B-g*z,W=g*I-u*B,K=u*z-p*I,oe=2*s[3];return z*=oe,B*=oe,W*=2,K*=2,a[0]=_+(I*=oe)+(N*=2),a[1]=T+z+W,a[2]=D+B+K,a}var vp,Xu=Bb,Vk=Ob,Gk=zb;function Zu(a,n,s){var u=n[0],p=n[1],g=n[2],_=n[3];return a[0]=s[0]*u+s[4]*p+s[8]*g+s[12]*_,a[1]=s[1]*u+s[5]*p+s[9]*g+s[13]*_,a[2]=s[2]*u+s[6]*p+s[10]*g+s[14]*_,a[3]=s[3]*u+s[7]*p+s[11]*g+s[15]*_,a}function Vb(){var a=new Zr(4);return Zr!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a[3]=1,a}function Gb(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a}function Wb(a,n,s){s*=.5;var u=n[0],p=n[1],g=n[2],_=n[3],T=Math.sin(s),D=Math.cos(s);return a[0]=u*D+_*T,a[1]=p*D+g*T,a[2]=g*D-p*T,a[3]=_*D-u*T,a}Mv(),vp=new Zr(4),Zr!=Float32Array&&(vp[0]=0,vp[1]=0,vp[2]=0,vp[3]=0),Mv(),mp(1,0,0),mp(0,1,0),Vb(),Vb(),Rb();class Av{constructor(n,s){this.points=n,this.planes=s}static fromInvProjectionMatrix(n,s,u,p){const g=Math.pow(2,u),_=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(D=>{const I=Zu([],D,n),z=1/I[3]/s*g;return function(B,N,W){return B[0]=N[0]*W[0],B[1]=N[1]*W[1],B[2]=N[2]*W[2],B[3]=N[3]*W[3],B}(I,I,[z,z,p?1/I[3]:z,z])}),T=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(D=>{const I=yp([],Nb([],Xu([],_[D[0]],_[D[1]]),Xu([],_[D[2]],_[D[1]]))),z=-_p(I,_[D[1]]);return I.concat(z)});return new Av(_,T)}}class go{constructor(n,s){this.min=n,this.max=s,this.center=gp([],Fb([],this.min,this.max),.5)}quadrant(n){const s=[n%2==0,n<2],u=kb(this.min),p=kb(this.max);for(let g=0;g<s.length;g++)u[g]=s[g]?this.min[g]:this.center[g],p[g]=s[g]?this.center[g]:this.max[g];return p[2]=this.max[2],new go(u,p)}distanceX(n){return Math.max(Math.min(this.max[0],n[0]),this.min[0])-n[0]}distanceY(n){return Math.max(Math.min(this.max[1],n[1]),this.min[1])-n[1]}distanceZ(n){return Math.max(Math.min(this.max[2],n[2]),this.min[2])-n[2]}getCorners(){const n=this.min,s=this.max;return[[n[0],n[1],n[2]],[s[0],n[1],n[2]],[s[0],s[1],n[2]],[n[0],s[1],n[2]],[n[0],n[1],s[2]],[s[0],n[1],s[2]],[s[0],s[1],s[2]],[n[0],s[1],s[2]]]}intersects(n){const s=this.getCorners();let u=!0;for(let p=0;p<n.planes.length;p++){const g=n.planes[p];let _=0;for(let T=0;T<s.length;T++)_+=_p(g,s[T])+g[3]>=0;if(_===0)return 0;_!==s.length&&(u=!1)}if(u)return 2;for(let p=0;p<3;p++){let g=Number.MAX_VALUE,_=-Number.MAX_VALUE;for(let T=0;T<n.points.length;T++){const D=n.points[T][p]-this.min[p];g=Math.min(g,D),_=Math.max(_,D)}if(_<0||g>this.max[p]-this.min[p])return 0}return 1}}function jb(a,n,s,u,p,g,_,T,D){if(g&&a.queryGeometry.isAboveHorizon)return!1;g&&(D*=a.pixelToTileUnitsFactor);for(const I of n)for(const z of I){const B=z.add(T),N=p&&s.elevation?s.elevation.exaggeration()*p.getElevationAt(B.x,B.y,!0):0,W=g?B:Wk(B,N,u),K=g?a.tilespaceRays.map(ue=>Hk(ue,N)):a.queryGeometry.screenGeometry,oe=Zu([],[z.x,z.y,N,1],u);if(!_&&g?D*=oe[3]/s.cameraToCenterDistance:_&&!g&&(D*=s.cameraToCenterDistance/oe[3]),kk(K,W,D))return!0}return!1}function Wk(a,n,s){const u=Zu([],[a.x,a.y,n,1],s);return new b(u[0]/u[3],u[1]/u[3])}const Hb=mp(0,0,0),jk=mp(0,0,1);function Hk(a,n){const s=Mv();return Hb[2]=n,a.intersectsPlane(Hb,jk,s),new b(s[0],s[1])}class $b extends gv{}function qb(a,{width:n,height:s},u,p){if(p){if(p instanceof Uint8ClampedArray)p=new Uint8Array(p.buffer);else if(p.length!==n*s*u)throw new RangeError("mismatched image size")}else p=new Uint8Array(n*s*u);return a.width=n,a.height=s,a.data=p,a}function Xb(a,n,s){const{width:u,height:p}=n;u===a.width&&p===a.height||(Dv(a,n,{x:0,y:0},{x:0,y:0},{width:Math.min(a.width,u),height:Math.min(a.height,p)},s),a.width=u,a.height=p,a.data=n.data)}function Dv(a,n,s,u,p,g){if(p.width===0||p.height===0)return n;if(p.width>a.width||p.height>a.height||s.x>a.width-p.width||s.y>a.height-p.height)throw new RangeError("out of range source coordinates for image copy");if(p.width>n.width||p.height>n.height||u.x>n.width-p.width||u.y>n.height-p.height)throw new RangeError("out of range destination coordinates for image copy");const _=a.data,T=n.data;for(let D=0;D<p.height;D++){const I=((s.y+D)*a.width+s.x)*g,z=((u.y+D)*n.width+u.x)*g;for(let B=0;B<p.width*g;B++)T[z+B]=_[I+B]}return n}$t($b,"HeatmapBucket",{omit:["layers"]});class Za{constructor(n,s){qb(this,n,1,s)}resize(n){Xb(this,new Za(n),1)}clone(){return new Za({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(n,s,u,p,g){Dv(n,s,u,p,g,1)}}class Yr{constructor(n,s){qb(this,n,4,s)}resize(n){Xb(this,new Yr(n),4)}replace(n,s){s?this.data.set(n):this.data=n instanceof Uint8ClampedArray?new Uint8Array(n.buffer):n}clone(){return new Yr({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(n,s,u,p,g){Dv(n,s,u,p,g,4)}}$t(Za,"AlphaImage"),$t(Yr,"RGBAImage");var $k={paint:new Z({"heatmap-radius":new k(Te.paint_heatmap["heatmap-radius"]),"heatmap-weight":new k(Te.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new S(Te.paint_heatmap["heatmap-intensity"]),"heatmap-color":new G(Te.paint_heatmap["heatmap-color"]),"heatmap-opacity":new S(Te.paint_heatmap["heatmap-opacity"])})};function Pv(a){const n={},s=a.resolution||256,u=a.clips?a.clips.length:1,p=a.image||new Yr({width:s,height:u}),g=(_,T,D)=>{n[a.evaluationKey]=D;const I=a.expression.evaluate(n);p.data[_+T+0]=Math.floor(255*I.r/I.a),p.data[_+T+1]=Math.floor(255*I.g/I.a),p.data[_+T+2]=Math.floor(255*I.b/I.a),p.data[_+T+3]=Math.floor(255*I.a)};if(a.clips)for(let _=0,T=0;_<u;++_,T+=4*s)for(let D=0,I=0;D<s;D++,I+=4){const z=D/(s-1),{start:B,end:N}=a.clips[_];g(T,I,B*(1-z)+N*z)}else for(let _=0,T=0;_<s;_++,T+=4)g(0,T,_/(s-1));return p}var qk={paint:new Z({"hillshade-illumination-direction":new S(Te.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new S(Te.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new S(Te.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new S(Te.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new S(Te.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new S(Te.paint_hillshade["hillshade-accent-color"])})};const Xk=Le([{name:"a_pos",components:2,type:"Int16"}],4),{members:Zk}=Xk;var Ig=Rg,Yk=Rg;function Rg(a,n,s){s=s||2;var u,p,g,_,T,D,I,z=n&&n.length,B=z?n[0]*s:a.length,N=Zb(a,0,B,s,!0),W=[];if(!N||N.next===N.prev)return W;if(z&&(N=function(oe,ue,xe,Be){var $e,Ze,Ye,Ke=[];for($e=0,Ze=ue.length;$e<Ze;$e++)(Ye=Zb(oe,ue[$e]*Be,$e<Ze-1?ue[$e+1]*Be:oe.length,Be,!1))===Ye.next&&(Ye.steiner=!0),Ke.push(rz(Ye));for(Ke.sort(tz),$e=0;$e<Ke.length;$e++)xe=Us(xe=nz(Ke[$e],xe),xe.next);return xe}(a,n,N,s)),a.length>80*s){u=g=a[0],p=_=a[1];for(var K=s;K<B;K+=s)(T=a[K])<u&&(u=T),(D=a[K+1])<p&&(p=D),T>g&&(g=T),D>_&&(_=D);I=(I=Math.max(g-u,_-p))!==0?1/I:0}return xp(N,W,s,u,p,I),W}function Zb(a,n,s,u,p){var g,_;if(p===Iv(a,n,s,u)>0)for(g=n;g<s;g+=u)_=Jb(g,a[g],a[g+1],_);else for(g=s-u;g>=n;g-=u)_=Jb(g,a[g],a[g+1],_);return _&&kg(_,_.next)&&(wp(_),_=_.next),_}function Us(a,n){if(!a)return a;n||(n=a);var s,u=a;do if(s=!1,u.steiner||!kg(u,u.next)&&Li(u.prev,u,u.next)!==0)u=u.next;else{if(wp(u),(u=n=u.prev)===u.next)break;s=!0}while(s||u!==n);return n}function xp(a,n,s,u,p,g,_){if(a){!_&&g&&function(z,B,N,W){var K=z;do K.z===null&&(K.z=Sv(K.x,K.y,B,N,W)),K.prevZ=K.prev,K.nextZ=K.next,K=K.next;while(K!==z);K.prevZ.nextZ=null,K.prevZ=null,function(oe){var ue,xe,Be,$e,Ze,Ye,Ke,ut,dt=1;do{for(xe=oe,oe=null,Ze=null,Ye=0;xe;){for(Ye++,Be=xe,Ke=0,ue=0;ue<dt&&(Ke++,Be=Be.nextZ);ue++);for(ut=dt;Ke>0||ut>0&&Be;)Ke!==0&&(ut===0||!Be||xe.z<=Be.z)?($e=xe,xe=xe.nextZ,Ke--):($e=Be,Be=Be.nextZ,ut--),Ze?Ze.nextZ=$e:oe=$e,$e.prevZ=Ze,Ze=$e;xe=Be}Ze.nextZ=null,dt*=2}while(Ye>1)}(K)}(a,u,p,g);for(var T,D,I=a;a.prev!==a.next;)if(T=a.prev,D=a.next,g?Jk(a,u,p,g):Kk(a))n.push(T.i/s),n.push(a.i/s),n.push(D.i/s),wp(a),a=D.next,I=D.next;else if((a=D)===I){_?_===1?xp(a=Qk(Us(a),n,s),n,s,u,p,g,2):_===2&&ez(a,n,s,u,p,g):xp(Us(a),n,s,u,p,g,1);break}}}function Kk(a){var n=a.prev,s=a,u=a.next;if(Li(n,s,u)>=0)return!1;for(var p=a.next.next;p!==a.prev;){if(Yu(n.x,n.y,s.x,s.y,u.x,u.y,p.x,p.y)&&Li(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Jk(a,n,s,u){var p=a.prev,g=a,_=a.next;if(Li(p,g,_)>=0)return!1;for(var T=p.x>g.x?p.x>_.x?p.x:_.x:g.x>_.x?g.x:_.x,D=p.y>g.y?p.y>_.y?p.y:_.y:g.y>_.y?g.y:_.y,I=Sv(p.x<g.x?p.x<_.x?p.x:_.x:g.x<_.x?g.x:_.x,p.y<g.y?p.y<_.y?p.y:_.y:g.y<_.y?g.y:_.y,n,s,u),z=Sv(T,D,n,s,u),B=a.prevZ,N=a.nextZ;B&&B.z>=I&&N&&N.z<=z;){if(B!==a.prev&&B!==a.next&&Yu(p.x,p.y,g.x,g.y,_.x,_.y,B.x,B.y)&&Li(B.prev,B,B.next)>=0||(B=B.prevZ,N!==a.prev&&N!==a.next&&Yu(p.x,p.y,g.x,g.y,_.x,_.y,N.x,N.y)&&Li(N.prev,N,N.next)>=0))return!1;N=N.nextZ}for(;B&&B.z>=I;){if(B!==a.prev&&B!==a.next&&Yu(p.x,p.y,g.x,g.y,_.x,_.y,B.x,B.y)&&Li(B.prev,B,B.next)>=0)return!1;B=B.prevZ}for(;N&&N.z<=z;){if(N!==a.prev&&N!==a.next&&Yu(p.x,p.y,g.x,g.y,_.x,_.y,N.x,N.y)&&Li(N.prev,N,N.next)>=0)return!1;N=N.nextZ}return!0}function Qk(a,n,s){var u=a;do{var p=u.prev,g=u.next.next;!kg(p,g)&&Yb(p,u,u.next,g)&&bp(p,g)&&bp(g,p)&&(n.push(p.i/s),n.push(u.i/s),n.push(g.i/s),wp(u),wp(u.next),u=a=g),u=u.next}while(u!==a);return Us(u)}function ez(a,n,s,u,p,g){var _=a;do{for(var T=_.next.next;T!==_.prev;){if(_.i!==T.i&&oz(_,T)){var D=Kb(_,T);return _=Us(_,_.next),D=Us(D,D.next),xp(_,n,s,u,p,g),void xp(D,n,s,u,p,g)}T=T.next}_=_.next}while(_!==a)}function tz(a,n){return a.x-n.x}function nz(a,n){var s=function(g,_){var T,D=_,I=g.x,z=g.y,B=-1/0;do{if(z<=D.y&&z>=D.next.y&&D.next.y!==D.y){var N=D.x+(z-D.y)*(D.next.x-D.x)/(D.next.y-D.y);if(N<=I&&N>B){if(B=N,N===I){if(z===D.y)return D;if(z===D.next.y)return D.next}T=D.x<D.next.x?D:D.next}}D=D.next}while(D!==_);if(!T)return null;if(I===B)return T;var W,K=T,oe=T.x,ue=T.y,xe=1/0;D=T;do I>=D.x&&D.x>=oe&&I!==D.x&&Yu(z<ue?I:B,z,oe,ue,z<ue?B:I,z,D.x,D.y)&&(W=Math.abs(z-D.y)/(I-D.x),bp(D,g)&&(W<xe||W===xe&&(D.x>T.x||D.x===T.x&&iz(T,D)))&&(T=D,xe=W)),D=D.next;while(D!==K);return T}(a,n);if(!s)return n;var u=Kb(s,a),p=Us(s,s.next);return Us(u,u.next),n===s?p:n}function iz(a,n){return Li(a.prev,a,n.prev)<0&&Li(n.next,a,a.next)<0}function Sv(a,n,s,u,p){return(a=1431655765&((a=858993459&((a=252645135&((a=16711935&((a=32767*(a-s)*p)|a<<8))|a<<4))|a<<2))|a<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=32767*(n-u)*p)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function rz(a){var n=a,s=a;do(n.x<s.x||n.x===s.x&&n.y<s.y)&&(s=n),n=n.next;while(n!==a);return s}function Yu(a,n,s,u,p,g,_,T){return(p-_)*(n-T)-(a-_)*(g-T)>=0&&(a-_)*(u-T)-(s-_)*(n-T)>=0&&(s-_)*(g-T)-(p-_)*(u-T)>=0}function oz(a,n){return a.next.i!==n.i&&a.prev.i!==n.i&&!function(s,u){var p=s;do{if(p.i!==s.i&&p.next.i!==s.i&&p.i!==u.i&&p.next.i!==u.i&&Yb(p,p.next,s,u))return!0;p=p.next}while(p!==s);return!1}(a,n)&&(bp(a,n)&&bp(n,a)&&function(s,u){var p=s,g=!1,_=(s.x+u.x)/2,T=(s.y+u.y)/2;do p.y>T!=p.next.y>T&&p.next.y!==p.y&&_<(p.next.x-p.x)*(T-p.y)/(p.next.y-p.y)+p.x&&(g=!g),p=p.next;while(p!==s);return g}(a,n)&&(Li(a.prev,a,n.prev)||Li(a,n.prev,n))||kg(a,n)&&Li(a.prev,a,a.next)>0&&Li(n.prev,n,n.next)>0)}function Li(a,n,s){return(n.y-a.y)*(s.x-n.x)-(n.x-a.x)*(s.y-n.y)}function kg(a,n){return a.x===n.x&&a.y===n.y}function Yb(a,n,s,u){var p=Fg(Li(a,n,s)),g=Fg(Li(a,n,u)),_=Fg(Li(s,u,a)),T=Fg(Li(s,u,n));return p!==g&&_!==T||!(p!==0||!zg(a,s,n))||!(g!==0||!zg(a,u,n))||!(_!==0||!zg(s,a,u))||!(T!==0||!zg(s,n,u))}function zg(a,n,s){return n.x<=Math.max(a.x,s.x)&&n.x>=Math.min(a.x,s.x)&&n.y<=Math.max(a.y,s.y)&&n.y>=Math.min(a.y,s.y)}function Fg(a){return a>0?1:a<0?-1:0}function bp(a,n){return Li(a.prev,a,a.next)<0?Li(a,n,a.next)>=0&&Li(a,a.prev,n)>=0:Li(a,n,a.prev)<0||Li(a,a.next,n)<0}function Kb(a,n){var s=new Lv(a.i,a.x,a.y),u=new Lv(n.i,n.x,n.y),p=a.next,g=n.prev;return a.next=n,n.prev=a,s.next=p,p.prev=s,u.next=s,s.prev=u,g.next=u,u.prev=g,u}function Jb(a,n,s,u){var p=new Lv(a,n,s);return u?(p.next=u.next,p.prev=u,u.next.prev=p,u.next=p):(p.prev=p,p.next=p),p}function wp(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function Lv(a,n,s){this.i=a,this.x=n,this.y=s,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Iv(a,n,s,u){for(var p=0,g=n,_=s-u;g<s;g+=u)p+=(a[_]-a[g])*(a[g+1]+a[_+1]),_=g;return p}function az(a,n,s,u,p){Qb(a,n,s||0,u||a.length-1,p||sz)}function Qb(a,n,s,u,p){for(;u>s;){if(u-s>600){var g=u-s+1,_=n-s+1,T=Math.log(g),D=.5*Math.exp(2*T/3),I=.5*Math.sqrt(T*D*(g-D)/g)*(_-g/2<0?-1:1);Qb(a,n,Math.max(s,Math.floor(n-_*D/g+I)),Math.min(u,Math.floor(n+(g-_)*D/g+I)),p)}var z=a[n],B=s,N=u;for(Mp(a,s,n),p(a[u],z)>0&&Mp(a,s,u);B<N;){for(Mp(a,B,N),B++,N--;p(a[B],z)<0;)B++;for(;p(a[N],z)>0;)N--}p(a[s],z)===0?Mp(a,s,N):Mp(a,++N,u),N<=n&&(s=N+1),n<=N&&(u=N-1)}}function Mp(a,n,s){var u=a[n];a[n]=a[s],a[s]=u}function sz(a,n){return a<n?-1:a>n?1:0}function Rv(a,n){const s=a.length;if(s<=1)return[a];const u=[];let p,g;for(let _=0;_<s;_++){const T=Ge(a[_]);T!==0&&(a[_].area=Math.abs(T),g===void 0&&(g=T<0),g===T<0?(p&&u.push(p),p=[a[_]]):p.push(a[_]))}if(p&&u.push(p),n>1)for(let _=0;_<u.length;_++)u[_].length<=n||(az(u[_],n,1,u[_].length-1,lz),u[_]=u[_].slice(0,n));return u}function lz(a,n){return n.area-a.area}function kv(a,n,s){const u=s.patternDependencies;let p=!1;for(const g of n){const _=g.paint.get(`${a}-pattern`);_.isConstant()||(p=!0);const T=_.constantOr(null);T&&(p=!0,u[T.to]=!0,u[T.from]=!0)}return p}function zv(a,n,s,u,p){const g=p.patternDependencies;for(const _ of n){const T=_.paint.get(`${a}-pattern`).value;if(T.kind!=="constant"){let D=T.evaluate({zoom:u-1},s,{},p.availableImages),I=T.evaluate({zoom:u},s,{},p.availableImages),z=T.evaluate({zoom:u+1},s,{},p.availableImages);D=D&&D.name?D.name:D,I=I&&I.name?I.name:I,z=z&&z.name?z.name:z,g[D]=!0,g[I]=!0,g[z]=!0,s.patterns[_.id]={min:D,mid:I,max:z}}}return s}Rg.deviation=function(a,n,s,u){var p=n&&n.length,g=Math.abs(Iv(a,0,p?n[0]*s:a.length,s));if(p)for(var _=0,T=n.length;_<T;_++)g-=Math.abs(Iv(a,n[_]*s,_<T-1?n[_+1]*s:a.length,s));var D=0;for(_=0;_<u.length;_+=3){var I=u[_]*s,z=u[_+1]*s,B=u[_+2]*s;D+=Math.abs((a[I]-a[B])*(a[z+1]-a[I+1])-(a[I]-a[z])*(a[B+1]-a[I+1]))}return g===0&&D===0?0:Math.abs((D-g)/g)},Rg.flatten=function(a){for(var n=a[0][0].length,s={vertices:[],holes:[],dimensions:n},u=0,p=0;p<a.length;p++){for(var g=0;g<a[p].length;g++)for(var _=0;_<n;_++)s.vertices.push(a[p][g][_]);p>0&&s.holes.push(u+=a[p-1].length)}return s},Ig.default=Yk;class Bg{constructor(n){this.zoom=n.zoom,this.overscaling=n.overscaling,this.layers=n.layers,this.layerIds=this.layers.map(s=>s.id),this.index=n.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new De,this.indexArray=new qt,this.indexArray2=new Mn,this.programConfigurations=new ql(n.layers,n.zoom),this.segments=new Ei,this.segments2=new Ei,this.stateDependentLayerIds=this.layers.filter(s=>s.isStateDependent()).map(s=>s.id),this.projection=n.projection}populate(n,s,u,p){this.hasPattern=kv("fill",this.layers,s);const g=this.layers[0].layout.get("fill-sort-key"),_=[];for(const{feature:T,id:D,index:I,sourceLayerIndex:z}of n){const B=this.layers[0]._featureFilter.needGeometry,N=Xl(T,B);if(!this.layers[0]._featureFilter.filter(new ci(this.zoom),N,u))continue;const W=g?g.evaluate(N,{},u,s.availableImages):void 0,K={id:D,properties:T.properties,type:T.type,sourceLayerIndex:z,index:I,geometry:B?N.geometry:Xa(T,u,p),patterns:{},sortKey:W};_.push(K)}g&&_.sort((T,D)=>T.sortKey-D.sortKey);for(const T of _){const{geometry:D,index:I,sourceLayerIndex:z}=T;if(this.hasPattern){const B=zv("fill",this.layers,T,this.zoom,s);this.patternFeatures.push(B)}else this.addFeature(T,D,I,u,{},s.availableImages);s.featureIndex.insert(n[I].feature,D,I,z,this.index)}}update(n,s,u,p){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(n,s,this.stateDependentLayers,u,p)}addFeatures(n,s,u,p,g){for(const _ of this.patternFeatures)this.addFeature(_,_.geometry,_.index,s,u,p)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(n){this.uploaded||(this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,Zk),this.indexBuffer=n.createIndexBuffer(this.indexArray),this.indexBuffer2=n.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(n),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(n,s,u,p,g,_=[]){for(const T of Rv(s,500)){let D=0;for(const K of T)D+=K.length;const I=this.segments.prepareSegment(D,this.layoutVertexArray,this.indexArray),z=I.vertexLength,B=[],N=[];for(const K of T){if(K.length===0)continue;K!==T[0]&&N.push(B.length/2);const oe=this.segments2.prepareSegment(K.length,this.layoutVertexArray,this.indexArray2),ue=oe.vertexLength;this.layoutVertexArray.emplaceBack(K[0].x,K[0].y),this.indexArray2.emplaceBack(ue+K.length-1,ue),B.push(K[0].x),B.push(K[0].y);for(let xe=1;xe<K.length;xe++)this.layoutVertexArray.emplaceBack(K[xe].x,K[xe].y),this.indexArray2.emplaceBack(ue+xe-1,ue+xe),B.push(K[xe].x),B.push(K[xe].y);oe.vertexLength+=K.length,oe.primitiveLength+=K.length}const W=Ig(B,N);for(let K=0;K<W.length;K+=3)this.indexArray.emplaceBack(z+W[K],z+W[K+1],z+W[K+2]);I.vertexLength+=D,I.primitiveLength+=W.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,n,u,g,_,p)}}$t(Bg,"FillBucket",{omit:["layers","patternFeatures"]});const cz=new Z({"fill-sort-key":new k(Te.layout_fill["fill-sort-key"])});var uz={paint:new Z({"fill-antialias":new S(Te.paint_fill["fill-antialias"]),"fill-opacity":new k(Te.paint_fill["fill-opacity"]),"fill-color":new k(Te.paint_fill["fill-color"]),"fill-outline-color":new k(Te.paint_fill["fill-outline-color"]),"fill-translate":new S(Te.paint_fill["fill-translate"]),"fill-translate-anchor":new S(Te.paint_fill["fill-translate-anchor"]),"fill-pattern":new O(Te.paint_fill["fill-pattern"])}),layout:cz};const hz=Le([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),dz=Le([{name:"a_centroid_pos",components:2,type:"Uint16"}]),pz=Le([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:fz}=hz;var ew=Ku;function Ku(a,n,s,u,p){this.properties={},this.extent=s,this.type=0,this._pbf=a,this._geometry=-1,this._keys=u,this._values=p,a.readFields(mz,this,n)}function mz(a,n,s){a==1?n.id=s.readVarint():a==2?function(u,p){for(var g=u.readVarint()+u.pos;u.pos<g;){var _=p._keys[u.readVarint()],T=p._values[u.readVarint()];p.properties[_]=T}}(s,n):a==3?n.type=s.readVarint():a==4&&(n._geometry=s.pos)}function gz(a){for(var n,s,u=0,p=0,g=a.length,_=g-1;p<g;_=p++)u+=((s=a[_]).x-(n=a[p]).x)*(n.y+s.y);return u}Ku.types=["Unknown","Point","LineString","Polygon"],Ku.prototype.loadGeometry=function(){var a=this._pbf;a.pos=this._geometry;for(var n,s=a.readVarint()+a.pos,u=1,p=0,g=0,_=0,T=[];a.pos<s;){if(p<=0){var D=a.readVarint();u=7&D,p=D>>3}if(p--,u===1||u===2)g+=a.readSVarint(),_+=a.readSVarint(),u===1&&(n&&T.push(n),n=[]),n.push(new b(g,_));else{if(u!==7)throw new Error("unknown command "+u);n&&n.push(n[0].clone())}}return n&&T.push(n),T},Ku.prototype.bbox=function(){var a=this._pbf;a.pos=this._geometry;for(var n=a.readVarint()+a.pos,s=1,u=0,p=0,g=0,_=1/0,T=-1/0,D=1/0,I=-1/0;a.pos<n;){if(u<=0){var z=a.readVarint();s=7&z,u=z>>3}if(u--,s===1||s===2)(p+=a.readSVarint())<_&&(_=p),p>T&&(T=p),(g+=a.readSVarint())<D&&(D=g),g>I&&(I=g);else if(s!==7)throw new Error("unknown command "+s)}return[_,D,T,I]},Ku.prototype.toGeoJSON=function(a,n,s){var u,p,g=this.extent*Math.pow(2,s),_=this.extent*a,T=this.extent*n,D=this.loadGeometry(),I=Ku.types[this.type];function z(W){for(var K=0;K<W.length;K++){var oe=W[K];W[K]=[360*(oe.x+_)/g-180,360/Math.PI*Math.atan(Math.exp((180-360*(oe.y+T)/g)*Math.PI/180))-90]}}switch(this.type){case 1:var B=[];for(u=0;u<D.length;u++)B[u]=D[u][0];z(D=B);break;case 2:for(u=0;u<D.length;u++)z(D[u]);break;case 3:for(D=function(W){var K=W.length;if(K<=1)return[W];for(var oe,ue,xe=[],Be=0;Be<K;Be++){var $e=gz(W[Be]);$e!==0&&(ue===void 0&&(ue=$e<0),ue===$e<0?(oe&&xe.push(oe),oe=[W[Be]]):oe.push(W[Be]))}return oe&&xe.push(oe),xe}(D),u=0;u<D.length;u++)for(p=0;p<D[u].length;p++)z(D[u][p])}D.length===1?D=D[0]:I="Multi"+I;var N={type:"Feature",geometry:{type:I,coordinates:D},properties:this.properties};return"id"in this&&(N.id=this.id),N};var tw=nw;function nw(a,n){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=a,this._keys=[],this._values=[],this._features=[],a.readFields(yz,this,n),this.length=this._features.length}function yz(a,n,s){a===15?n.version=s.readVarint():a===1?n.name=s.readString():a===5?n.extent=s.readVarint():a===2?n._features.push(s.pos):a===3?n._keys.push(s.readString()):a===4&&n._values.push(function(u){for(var p=null,g=u.readVarint()+u.pos;u.pos<g;){var _=u.readVarint()>>3;p=_===1?u.readString():_===2?u.readFloat():_===3?u.readDouble():_===4?u.readVarint64():_===5?u.readVarint():_===6?u.readSVarint():_===7?u.readBoolean():null}return p}(s))}function _z(a,n,s){if(a===3){var u=new tw(s,s.readVarint()+s.pos);u.length&&(n[u.name]=u)}}nw.prototype.feature=function(a){if(a<0||a>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[a];var n=this._pbf.readVarint()+this._pbf.pos;return new ew(this._pbf,n,this.extent,this._keys,this._values)};var Kl={VectorTile:function(a,n){this.layers=a.readFields(_z,{},n)},VectorTileFeature:ew,VectorTileLayer:tw};function Og(a,n,s,u){const p=[],g=u===0?(_,T,D,I,z,B)=>{_.push(new b(B,D+(B-T)/(I-T)*(z-D)))}:(_,T,D,I,z,B)=>{_.push(new b(T+(B-D)/(z-D)*(I-T),B))};for(const _ of a){const T=[];for(const D of _){if(D.length<=2)continue;const I=[];for(let N=0;N<D.length-1;N++){const W=D[N].x,K=D[N].y,oe=D[N+1].x,ue=D[N+1].y,xe=u===0?W:K,Be=u===0?oe:ue;xe<n?Be>n&&g(I,W,K,oe,ue,n):xe>s?Be<s&&g(I,W,K,oe,ue,s):I.push(D[N]),Be<n&&xe>=n&&g(I,W,K,oe,ue,n),Be>s&&xe<=s&&g(I,W,K,oe,ue,s)}let z=D[D.length-1];const B=u===0?z.x:z.y;B>=n&&B<=s&&I.push(z),I.length&&(z=I[I.length-1],I[0].x===z.x&&I[0].y===z.y||I.push(I[0]),T.push(I))}T.length&&p.push(T)}return p}const vz=Kl.VectorTileFeature.types,xz=Math.pow(2,13);function Tp(a,n,s,u,p,g,_,T){a.emplaceBack((n<<1)+_,(s<<1)+g,(Math.floor(u*xz)<<1)+p,Math.round(T))}function Ep(a,n,s){a.emplaceBack(n.x,n.y,n.z,s[0]*16384,s[1]*16384,s[2]*16384)}class iw{constructor(){this.acc=new b(0,0),this.polyCount=[]}startRing(n){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new b(n.x,n.y),this.max=new b(n.x,n.y))}append(n,s){this.currentPolyCount.edges++,this.acc._add(n);const u=this.min,p=this.max;n.x<u.x?u.x=n.x:n.x>p.x&&(p.x=n.x),n.y<u.y?u.y=n.y:n.y>p.y&&(p.y=n.y),((n.x===0||n.x===In)&&n.x===s.x)!=((n.y===0||n.y===In)&&n.y===s.y)&&this.processBorderOverlap(n,s),s.x<0!=n.x<0&&this.addBorderIntersection(0,yn(s.y,n.y,(0-s.x)/(n.x-s.x))),s.x>In!=n.x>In&&this.addBorderIntersection(1,yn(s.y,n.y,(In-s.x)/(n.x-s.x))),s.y<0!=n.y<0&&this.addBorderIntersection(2,yn(s.x,n.x,(0-s.y)/(n.y-s.y))),s.y>In!=n.y>In&&this.addBorderIntersection(3,yn(s.x,n.x,(In-s.y)/(n.y-s.y)))}addBorderIntersection(n,s){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const u=this.borders[n];s<u[0]&&(u[0]=s),s>u[1]&&(u[1]=s)}processBorderOverlap(n,s){if(n.x===s.x){if(n.y===s.y)return;const u=n.x===0?0:1;this.addBorderIntersection(u,s.y),this.addBorderIntersection(u,n.y)}else{const u=n.y===0?2:3;this.addBorderIntersection(u,s.x),this.addBorderIntersection(u,n.x)}}centroid(){const n=this.polyCount.reduce((s,u)=>s+u.edges,0);return n!==0?this.acc.div(n)._round():new b(0,0)}span(){return new b(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((n,s)=>n+ +(s[0]!==Number.MAX_VALUE),0)}}class Cp{constructor(n){this.zoom=n.zoom,this.canonical=n.canonical,this.overscaling=n.overscaling,this.layers=n.layers,this.layerIds=this.layers.map(s=>s.id),this.index=n.index,this.hasPattern=!1,this.projection=n.projection,this.layoutVertexArray=new ze,this.centroidVertexArray=new $l,this.indexArray=new qt,this.programConfigurations=new ql(n.layers,n.zoom),this.segments=new Ei,this.stateDependentLayerIds=this.layers.filter(s=>s.isStateDependent()).map(s=>s.id),this.enableTerrain=n.enableTerrain}populate(n,s,u,p){this.features=[],this.hasPattern=kv("fill-extrusion",this.layers,s),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(g){const _=Math.exp(Math.PI*(1-g.y/(1<<g.z)*2));return 80150034*_/(_*_+1)/In/(1<<g.z)}(u);for(const{feature:g,id:_,index:T,sourceLayerIndex:D}of n){const I=this.layers[0]._featureFilter.needGeometry,z=Xl(g,I);if(!this.layers[0]._featureFilter.filter(new ci(this.zoom),z,u))continue;const B={id:_,sourceLayerIndex:D,index:T,geometry:I?z.geometry:Xa(g,u,p),properties:g.properties,type:g.type,patterns:{}},N=this.layoutVertexArray.length;this.hasPattern?this.features.push(zv("fill-extrusion",this.layers,B,this.zoom,s)):this.addFeature(B,B.geometry,T,u,{},s.availableImages,p),s.featureIndex.insert(g,B.geometry,T,D,this.index,N)}this.sortBorders()}addFeatures(n,s,u,p,g){for(const _ of this.features){const{geometry:T}=_;this.addFeature(_,T,_.index,s,u,p,g)}this.sortBorders()}update(n,s,u,p){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(n,s,this.stateDependentLayers,u,p)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(n){this.uploaded||(this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,fz),this.indexBuffer=n.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=n.createVertexBuffer(this.layoutVertexExtArray,pz.members,!0))),this.programConfigurations.upload(n),this.uploaded=!0}uploadCentroid(n){this.centroidVertexArray.length!==0&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=n.createVertexBuffer(this.centroidVertexArray,dz.members,!0),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(n,s,u,p,g,_,T){const D=[new b(0,0),new b(In,In)],I=T.projection,z=I.name==="globe",B=this.enableTerrain&&!z?new iw:null;z&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new kr);const N=Rv(s,500);for(let oe=N.length-1;oe>=0;oe--){const ue=N[oe];(ue.length===0||(W=ue[0]).every(xe=>xe.x<=0)||W.every(xe=>xe.x>=In)||W.every(xe=>xe.y<=0)||W.every(xe=>xe.y>=In))&&N.splice(oe,1)}var W;let K;if(z){const ue=1<<p.z,xe=To(p.x/ue),Be=To((p.x+1)/ue),$e=rr(p.y/ue),Ze=rr((p.y+1)/ue);K=function(Ye,Ke,ut,dt,xt=0,Et){const st=[];if(!Ye.length||!ut||!dt)return st;const mt=(An,Fn)=>{for(const Qt of An)st.push({polygon:Qt,bounds:Fn})},Pt=Math.ceil(Math.log2(ut)),Bt=Math.ceil(Math.log2(dt)),Rt=Pt-Bt,Ft=[];for(let An=0;An<Math.abs(Rt);An++)Ft.push(Rt>0?0:1);for(let An=0;An<Math.min(Pt,Bt);An++)Ft.push(0),Ft.push(1);let En=Ye;if(En=Og(En,Ke[0].y-xt,Ke[1].y+xt,1),En=Og(En,Ke[0].x-xt,Ke[1].x+xt,0),!En.length)return st;const Un=[];for(Ft.length?Un.push({polygons:En,bounds:Ke,depth:0}):mt(En,Ke);Un.length;){const An=Un.pop(),Fn=An.depth,Qt=Ft[Fn],Ht=An.bounds[0],Vn=An.bounds[1],Kn=Qt===0?Ht.x:Ht.y,Bi=Qt===0?Vn.x:Vn.y,ui=Et?Et(Qt,Kn,Bi):.5*(Kn+Bi),Oi=Og(An.polygons,Kn-xt,ui+xt,Qt),Jn=Og(An.polygons,ui-xt,Bi+xt,Qt);if(Oi.length){const Wn=[Ht,new b(Qt===0?ui:Vn.x,Qt===1?ui:Vn.y)];Ft.length>Fn+1?Un.push({polygons:Oi,bounds:Wn,depth:Fn+1}):mt(Oi,Wn)}if(Jn.length){const Wn=[new b(Qt===0?ui:Ht.x,Qt===1?ui:Ht.y),Vn];Ft.length>Fn+1?Un.push({polygons:Jn,bounds:Wn,depth:Fn+1}):mt(Jn,Wn)}}return st}(N,D,Math.ceil((Be-xe)/11.25),Math.ceil(($e-Ze)/11.25),1,(Ye,Ke,ut)=>{if(Ye===0)return .5*(Ke+ut);{const dt=rr((p.y+Ke/In)/ue);return(ju(.5*(rr((p.y+ut/In)/ue)+dt))*ue-p.y)*In}})}else{K=[];for(const oe of N)K.push({polygon:oe,bounds:D})}for(const oe of K){const ue=oe.polygon;let xe=0,Be=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let ut=0;ut<ue.length;ut++){const dt=ue[ut];if(dt.length===0)continue;xe+=dt.length;let xt=0;B&&B.startRing(dt[0]);for(let Et=0;Et<dt.length;Et++){const st=dt[Et];if(Et>=1){const mt=dt[Et-1];if(!bz(st,mt,oe.bounds)){B&&B.append(st,mt),Be.vertexLength+4>Ei.MAX_VERTEX_ARRAY_LENGTH&&(Be=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const Pt=st.sub(mt)._perp(),Bt=Pt.x/(Math.abs(Pt.x)+Math.abs(Pt.y)),Rt=Pt.y>0?1:0,Ft=mt.dist(st);xt+Ft>32768&&(xt=0),Tp(this.layoutVertexArray,st.x,st.y,Bt,Rt,0,0,xt),Tp(this.layoutVertexArray,st.x,st.y,Bt,Rt,0,1,xt),xt+=Ft,Tp(this.layoutVertexArray,mt.x,mt.y,Bt,Rt,0,0,xt),Tp(this.layoutVertexArray,mt.x,mt.y,Bt,Rt,0,1,xt);const En=Be.vertexLength;if(this.indexArray.emplaceBack(En,En+2,En+1),this.indexArray.emplaceBack(En+1,En+2,En+3),Be.vertexLength+=4,Be.primitiveLength+=2,z){const Un=this.layoutVertexExtArray,An=I.projectTilePoint(st.x,st.y,p),Fn=I.projectTilePoint(mt.x,mt.y,p),Qt=I.upVector(p,st.x,st.y),Ht=I.upVector(p,mt.x,mt.y);Ep(Un,An,Qt),Ep(Un,An,Qt),Ep(Un,Fn,Ht),Ep(Un,Fn,Ht)}}}}}if(Be.vertexLength+xe>Ei.MAX_VERTEX_ARRAY_LENGTH&&(Be=this.segments.prepareSegment(xe,this.layoutVertexArray,this.indexArray)),vz[n.type]!=="Polygon")continue;const $e=[],Ze=[],Ye=Be.vertexLength;for(let ut=0;ut<ue.length;ut++){const dt=ue[ut];if(dt.length!==0){dt!==ue[0]&&Ze.push($e.length/2);for(let xt=0;xt<dt.length;xt++){const Et=dt[xt];Tp(this.layoutVertexArray,Et.x,Et.y,0,0,1,1,0),$e.push(Et.x),$e.push(Et.y),B&&B.currentPolyCount.top++,z&&Ep(this.layoutVertexExtArray,I.projectTilePoint(Et.x,Et.y,p),I.upVector(p,Et.x,Et.y))}}}const Ke=Ig($e,Ze);for(let ut=0;ut<Ke.length;ut+=3)this.indexArray.emplaceBack(Ye+Ke[ut],Ye+Ke[ut+2],Ye+Ke[ut+1]);Be.primitiveLength+=Ke.length/3,Be.vertexLength+=xe}if(B&&B.polyCount.length>0){if(B.borders){B.vertexArrayOffset=this.centroidVertexArray.length;const oe=B.borders,ue=this.featuresOnBorder.push(B)-1;for(let xe=0;xe<4;xe++)oe[xe][0]!==Number.MAX_VALUE&&this.borders[xe].push(ue)}this.encodeCentroid(B.borders?void 0:B.centroid(),B)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,n,u,g,_,p)}sortBorders(){for(let n=0;n<4;n++)this.borders[n].sort((s,u)=>this.featuresOnBorder[s].borders[n][0]-this.featuresOnBorder[u].borders[n][0])}encodeCentroid(n,s,u=!0){let p,g;if(n)if(n.y!==0){const T=s.span()._mult(this.tileToMeter);p=(Math.max(n.x,1)<<3)+Math.min(7,Math.round(T.x/10)),g=(Math.max(n.y,1)<<3)+Math.min(7,Math.round(T.y/10))}else p=Math.ceil(7*(n.x+450)),g=0;else p=0,g=+u;let _=u?this.centroidVertexArray.length:s.vertexArrayOffset;for(const T of s.polyCount){u&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*T.edges+T.top);for(let D=0;D<2*T.edges;D++)this.centroidVertexArray.emplace(_++,0,g),this.centroidVertexArray.emplace(_++,p,g);for(let D=0;D<T.top;D++)this.centroidVertexArray.emplace(_++,p,g)}}}function bz(a,n,s){return a.x===n.x&&(a.x<s[0].x||a.x>s[1].x)||a.y===n.y&&(a.y<s[0].y||a.y>s[1].y)}$t(Cp,"FillExtrusionBucket",{omit:["layers","features"]}),$t(iw,"PartMetadata");var wz={paint:new Z({"fill-extrusion-opacity":new S(Te["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new k(Te["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new S(Te["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new S(Te["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new O(Te["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new k(Te["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new k(Te["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new S(Te["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function Ap(a,n){return a.x*n.x+a.y*n.y}function rw(a,n){if(a.length===1){let s=0;const u=n[s++];let p;for(;!p||u.equals(p);)if(p=n[s++],!p)return 1/0;for(;s<n.length;s++){const g=n[s],_=a[0],T=p.sub(u),D=g.sub(u),I=_.sub(u),z=Ap(T,T),B=Ap(T,D),N=Ap(D,D),W=Ap(I,T),K=Ap(I,D),oe=z*N-B*B,ue=(N*W-B*K)/oe,xe=(z*K-B*W)/oe,Be=u.z*(1-ue-xe)+p.z*ue+g.z*xe;if(isFinite(Be))return Be}return 1/0}{let s=1/0;for(const u of n)s=Math.min(s,u.z);return s}}function ow(a){const n=new b(a[0],a[1]);return n.z=a[2],n}function Mz(a,n,s,u,p,g,_,T){const D=_*p.getElevationAt(a,n,!0,!0),I=g[0]!==0,z=I?g[1]===0?_*(g[0]/7-450):_*function(B,N,W){const K=Math.floor(N[0]/8),oe=Math.floor(N[1]/8),ue=10*(N[0]-8*K),xe=10*(N[1]-8*oe),Be=B.getElevationAt(K,oe,!0,!0),$e=B.getMeterToDEM(W),Ze=Math.floor(.5*(ue*$e-1)),Ye=Math.floor(.5*(xe*$e-1)),Ke=B.tileCoordToPixel(K,oe),ut=2*Ze+1,dt=2*Ye+1,xt=function(Rt,Ft,En,Un,An){return[Rt.getElevationAtPixel(Ft,En,!0),Rt.getElevationAtPixel(Ft+An,En,!0),Rt.getElevationAtPixel(Ft,En+An,!0),Rt.getElevationAtPixel(Ft+Un,En+An,!0)]}(B,Ke.x-Ze,Ke.y-Ye,ut,dt),Et=Math.abs(xt[0]-xt[1]),st=Math.abs(xt[2]-xt[3]),mt=Math.abs(xt[0]-xt[2])+Math.abs(xt[1]-xt[3]),Pt=Math.min(.25,.5*$e*(Et+st)/ut),Bt=Math.min(.25,.5*$e*mt/dt);return Be+Math.max(Pt*ue,Bt*xe)}(p,g,T):D;return{base:D+(s===0)?-1:s,top:I?Math.max(z+u,D+s+2):D+u}}const Tz=Le([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:Ez}=Tz,Cz=Le([{name:"a_packed",components:3,type:"Float32"}]),{members:Az}=Cz,Dz=Kl.VectorTileFeature.types,Pz=Math.cos(Math.PI/180*37.5);class Ng{constructor(n){this.zoom=n.zoom,this.overscaling=n.overscaling,this.layers=n.layers,this.layerIds=this.layers.map(s=>s.id),this.index=n.index,this.projection=n.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(s=>{this.gradients[s.id]={}}),this.layoutVertexArray=new Ee,this.layoutVertexArray2=new kt,this.indexArray=new qt,this.programConfigurations=new ql(n.layers,n.zoom),this.segments=new Ei,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(s=>s.isStateDependent()).map(s=>s.id)}populate(n,s,u,p){this.hasPattern=kv("line",this.layers,s);const g=this.layers[0].layout.get("line-sort-key"),_=[];for(const{feature:z,id:B,index:N,sourceLayerIndex:W}of n){const K=this.layers[0]._featureFilter.needGeometry,oe=Xl(z,K);if(!this.layers[0]._featureFilter.filter(new ci(this.zoom),oe,u))continue;const ue=g?g.evaluate(oe,{},u):void 0,xe={id:B,properties:z.properties,type:z.type,sourceLayerIndex:W,index:N,geometry:K?oe.geometry:Xa(z,u,p),patterns:{},sortKey:ue};_.push(xe)}g&&_.sort((z,B)=>z.sortKey-B.sortKey);const{lineAtlas:T,featureIndex:D}=s,I=this.addConstantDashes(T);for(const z of _){const{geometry:B,index:N,sourceLayerIndex:W}=z;if(I&&this.addFeatureDashes(z,T),this.hasPattern){const K=zv("line",this.layers,z,this.zoom,s);this.patternFeatures.push(K)}else this.addFeature(z,B,N,u,T.positions,s.availableImages);D.insert(n[N].feature,B,N,W,this.index)}}addConstantDashes(n){let s=!1;for(const u of this.layers){const p=u.paint.get("line-dasharray").value,g=u.layout.get("line-cap").value;if(p.kind!=="constant"||g.kind!=="constant")s=!0;else{const _=g.value,T=p.value;if(!T)continue;n.addDash(T.from,_),n.addDash(T.to,_),T.other&&n.addDash(T.other,_)}}return s}addFeatureDashes(n,s){const u=this.zoom;for(const p of this.layers){const g=p.paint.get("line-dasharray").value,_=p.layout.get("line-cap").value;if(g.kind==="constant"&&_.kind==="constant")continue;let T,D,I,z,B,N;if(g.kind==="constant"){const ue=g.value;if(!ue)continue;T=ue.other||ue.to,D=ue.to,I=ue.from}else T=g.evaluate({zoom:u-1},n),D=g.evaluate({zoom:u},n),I=g.evaluate({zoom:u+1},n);_.kind==="constant"?z=B=N=_.value:(z=_.evaluate({zoom:u-1},n),B=_.evaluate({zoom:u},n),N=_.evaluate({zoom:u+1},n)),s.addDash(T,z),s.addDash(D,B),s.addDash(I,N);const W=s.getKey(T,z),K=s.getKey(D,B),oe=s.getKey(I,N);n.patterns[p.id]={min:W,mid:K,max:oe}}}update(n,s,u,p){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(n,s,this.stateDependentLayers,u,p)}addFeatures(n,s,u,p,g){for(const _ of this.patternFeatures)this.addFeature(_,_.geometry,_.index,s,u,p)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(n){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=n.createVertexBuffer(this.layoutVertexArray2,Az)),this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,Ez),this.indexBuffer=n.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(n),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(n){if(n.properties&&n.properties.hasOwnProperty("mapbox_clip_start")&&n.properties.hasOwnProperty("mapbox_clip_end"))return{start:+n.properties.mapbox_clip_start,end:+n.properties.mapbox_clip_end}}addFeature(n,s,u,p,g,_){const T=this.layers[0].layout,D=T.get("line-join").evaluate(n,{}),I=T.get("line-cap").evaluate(n,{}),z=T.get("line-miter-limit"),B=T.get("line-round-limit");this.lineClips=this.lineFeatureClips(n);for(const N of s)this.addLine(N,n,D,I,z,B);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,n,u,g,_,p)}addLine(n,s,u,p,g,_){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let xe=0;xe<n.length-1;xe++)this.totalDistance+=n[xe].dist(n[xe+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const T=Dz[s.type]==="Polygon";let D=n.length;for(;D>=2&&n[D-1].equals(n[D-2]);)D--;let I=0;for(;I<D-1&&n[I].equals(n[I+1]);)I++;if(D<(T?3:2))return;u==="bevel"&&(g=1.05);const z=this.overscaling<=16?122880/(512*this.overscaling):0,B=this.segments.prepareSegment(10*D,this.layoutVertexArray,this.indexArray);let N,W,K,oe,ue;this.e1=this.e2=-1,T&&(N=n[D-2],ue=n[I].sub(N)._unit()._perp());for(let xe=I;xe<D;xe++){if(K=xe===D-1?T?n[I+1]:void 0:n[xe+1],K&&n[xe].equals(K))continue;ue&&(oe=ue),N&&(W=N),N=n[xe],ue=K?K.sub(N)._unit()._perp():oe,oe=oe||ue;let Be=oe.add(ue);Be.x===0&&Be.y===0||Be._unit();const $e=oe.x*ue.x+oe.y*ue.y,Ze=Be.x*ue.x+Be.y*ue.y,Ye=Ze!==0?1/Ze:1/0,Ke=2*Math.sqrt(2-2*Ze),ut=Ze<Pz&&W&&K,dt=oe.x*ue.y-oe.y*ue.x>0;if(ut&&xe>I){const st=N.dist(W);if(st>2*z){const mt=N.sub(N.sub(W)._mult(z/st)._round());this.updateDistance(W,mt),this.addCurrentVertex(mt,oe,0,0,B),W=mt}}const xt=W&&K;let Et=xt?u:T?"butt":p;if(xt&&Et==="round"&&(Ye<_?Et="miter":Ye<=2&&(Et="fakeround")),Et==="miter"&&Ye>g&&(Et="bevel"),Et==="bevel"&&(Ye>2&&(Et="flipbevel"),Ye<g&&(Et="miter")),W&&this.updateDistance(W,N),Et==="miter")Be._mult(Ye),this.addCurrentVertex(N,Be,0,0,B);else if(Et==="flipbevel"){if(Ye>100)Be=ue.mult(-1);else{const st=Ye*oe.add(ue).mag()/oe.sub(ue).mag();Be._perp()._mult(st*(dt?-1:1))}this.addCurrentVertex(N,Be,0,0,B),this.addCurrentVertex(N,Be.mult(-1),0,0,B)}else if(Et==="bevel"||Et==="fakeround"){const st=-Math.sqrt(Ye*Ye-1),mt=dt?st:0,Pt=dt?0:st;if(W&&this.addCurrentVertex(N,oe,mt,Pt,B),Et==="fakeround"){const Bt=Math.round(180*Ke/Math.PI/20);for(let Rt=1;Rt<Bt;Rt++){let Ft=Rt/Bt;if(Ft!==.5){const Un=Ft-.5;Ft+=Ft*Un*(Ft-1)*((1.0904+$e*($e*(3.55645-1.43519*$e)-3.2452))*Un*Un+(.848013+$e*(.215638*$e-1.06021)))}const En=ue.sub(oe)._mult(Ft)._add(oe)._unit()._mult(dt?-1:1);this.addHalfVertex(N,En.x,En.y,!1,dt,0,B)}}K&&this.addCurrentVertex(N,ue,-mt,-Pt,B)}else if(Et==="butt")this.addCurrentVertex(N,Be,0,0,B);else if(Et==="square"){const st=W?1:-1;W||this.addCurrentVertex(N,Be,st,st,B),this.addCurrentVertex(N,Be,0,0,B),W&&this.addCurrentVertex(N,Be,st,st,B)}else Et==="round"&&(W&&(this.addCurrentVertex(N,oe,0,0,B),this.addCurrentVertex(N,oe,1,1,B,!0)),K&&(this.addCurrentVertex(N,ue,-1,-1,B,!0),this.addCurrentVertex(N,ue,0,0,B)));if(ut&&xe<D-1){const st=N.dist(K);if(st>2*z){const mt=N.add(K.sub(N)._mult(z/st)._round());this.updateDistance(N,mt),this.addCurrentVertex(mt,ue,0,0,B),N=mt}}}}addCurrentVertex(n,s,u,p,g,_=!1){const T=s.y*p-s.x,D=-s.y-s.x*p;this.addHalfVertex(n,s.x+s.y*u,s.y-s.x*u,_,!1,u,g),this.addHalfVertex(n,T,D,_,!0,-p,g)}addHalfVertex({x:n,y:s},u,p,g,_,T,D){this.layoutVertexArray.emplaceBack((n<<1)+(g?1:0),(s<<1)+(_?1:0),Math.round(63*u)+128,Math.round(63*p)+128,1+(T===0?0:T<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const I=D.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,I),D.primitiveLength++),_?this.e2=I:this.e1=I}updateScaledDistance(){if(this.lineClips){const n=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=n*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(n,s){this.distance+=n.dist(s),this.updateScaledDistance()}}$t(Ng,"LineBucket",{omit:["layers","patternFeatures"]});const Sz=new Z({"line-cap":new k(Te.layout_line["line-cap"]),"line-join":new k(Te.layout_line["line-join"]),"line-miter-limit":new S(Te.layout_line["line-miter-limit"]),"line-round-limit":new S(Te.layout_line["line-round-limit"]),"line-sort-key":new k(Te.layout_line["line-sort-key"])});var aw={paint:new Z({"line-opacity":new k(Te.paint_line["line-opacity"]),"line-color":new k(Te.paint_line["line-color"]),"line-translate":new S(Te.paint_line["line-translate"]),"line-translate-anchor":new S(Te.paint_line["line-translate-anchor"]),"line-width":new k(Te.paint_line["line-width"]),"line-gap-width":new k(Te.paint_line["line-gap-width"]),"line-offset":new k(Te.paint_line["line-offset"]),"line-blur":new k(Te.paint_line["line-blur"]),"line-dasharray":new O(Te.paint_line["line-dasharray"]),"line-pattern":new O(Te.paint_line["line-pattern"]),"line-gradient":new G(Te.paint_line["line-gradient"])}),layout:Sz};const sw=new class extends k{possiblyEvaluate(a,n){return n=new ci(Math.floor(n.zoom),{now:n.now,fadeDuration:n.fadeDuration,zoomHistory:n.zoomHistory,transition:n.transition}),super.possiblyEvaluate(a,n)}evaluate(a,n,s,u){return n=me({},n,{zoom:Math.floor(n.zoom)}),super.evaluate(a,n,s,u)}}(aw.paint.properties["line-width"].specification);function lw(a,n){return n>0?n+2*a:a}sw.useIntegerZoom=!0;const Lz=Le([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_z_tile_anchor",components:4,type:"Int16"}],4),Iz=Le([{name:"a_projected_pos",components:3,type:"Float32"}],4);Le([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Rz=Le([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),kz=Le([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Le([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const cw=Le([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),zz=Le([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Le([{name:"triangle",components:3,type:"Uint16"}]),Le([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),Le([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Le([{type:"Float32",name:"offsetX"}]),Le([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var or=24;const ya=128;function Fv(a,n){const{expression:s}=n;if(s.kind==="constant")return{kind:"constant",layoutSize:s.evaluate(new ci(a+1))};if(s.kind==="source")return{kind:"source"};{const{zoomStops:u,interpolationType:p}=s;let g=0;for(;g<u.length&&u[g]<=a;)g++;g=Math.max(0,g-1);let _=g;for(;_<u.length&&u[_]<a+1;)_++;_=Math.min(u.length-1,_);const T=u[g],D=u[_];return s.kind==="composite"?{kind:"composite",minZoom:T,maxZoom:D,interpolationType:p}:{kind:"camera",minZoom:T,maxZoom:D,minSize:s.evaluate(new ci(T)),maxSize:s.evaluate(new ci(D)),interpolationType:p}}}function Ug(a,{uSize:n,uSizeT:s},{lowerSize:u,upperSize:p}){return a.kind==="source"?u/ya:a.kind==="composite"?yn(u/ya,p/ya,s):n}function Ju(a,n){let s=0,u=0;if(a.kind==="constant")u=a.layoutSize;else if(a.kind!=="source"){const{interpolationType:p,minZoom:g,maxZoom:_}=a,T=p?Q(Lr.interpolationFactor(p,n,g,_),0,1):0;a.kind==="camera"?u=yn(a.minSize,a.maxSize,T):s=T}return{uSizeT:s,uSize:u}}var Fz=Object.freeze({__proto__:null,getSizeData:Fv,evaluateSizeForFeature:Ug,evaluateSizeForZoom:Ju,SIZE_PACK_FACTOR:ya});function Bz(a,n,s){return a.sections.forEach(u=>{u.text=function(p,g,_){const T=g.layout.get("text-transform").evaluate(_,{});return T==="uppercase"?p=p.toLocaleUpperCase():T==="lowercase"&&(p=p.toLocaleLowerCase()),qr.applyArabicShaping&&(p=qr.applyArabicShaping(p)),p}(u.text,n,s)}),a}const Dp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function Oz(a){return a==="︶"||a==="﹈"||a==="︸"||a==="﹄"||a==="﹂"||a==="︾"||a==="︼"||a==="︺"||a==="︘"||a==="﹀"||a==="︐"||a==="︓"||a==="︔"||a==="`"||a===" ̄"||a==="︑"||a==="︒"}function Nz(a){return a==="︵"||a==="﹇"||a==="︷"||a==="﹃"||a==="﹁"||a==="︽"||a==="︻"||a==="︹"||a==="︗"||a==="︿"}var uw=function(a,n,s,u,p){var g,_,T=8*p-u-1,D=(1<<T)-1,I=D>>1,z=-7,B=s?p-1:0,N=s?-1:1,W=a[n+B];for(B+=N,g=W&(1<<-z)-1,W>>=-z,z+=T;z>0;g=256*g+a[n+B],B+=N,z-=8);for(_=g&(1<<-z)-1,g>>=-z,z+=u;z>0;_=256*_+a[n+B],B+=N,z-=8);if(g===0)g=1-I;else{if(g===D)return _?NaN:1/0*(W?-1:1);_+=Math.pow(2,u),g-=I}return(W?-1:1)*_*Math.pow(2,g-u)},hw=function(a,n,s,u,p,g){var _,T,D,I=8*g-p-1,z=(1<<I)-1,B=z>>1,N=p===23?Math.pow(2,-24)-Math.pow(2,-77):0,W=u?0:g-1,K=u?1:-1,oe=n<0||n===0&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(T=isNaN(n)?1:0,_=z):(_=Math.floor(Math.log(n)/Math.LN2),n*(D=Math.pow(2,-_))<1&&(_--,D*=2),(n+=_+B>=1?N/D:N*Math.pow(2,1-B))*D>=2&&(_++,D/=2),_+B>=z?(T=0,_=z):_+B>=1?(T=(n*D-1)*Math.pow(2,p),_+=B):(T=n*Math.pow(2,B-1)*Math.pow(2,p),_=0));p>=8;a[s+W]=255&T,W+=K,T/=256,p-=8);for(_=_<<p|T,I+=p;I>0;a[s+W]=255&_,W+=K,_/=256,I-=8);a[s+W-K]|=128*oe},Pp=si;function si(a){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(a)?a:new Uint8Array(a||0),this.pos=0,this.type=0,this.length=this.buf.length}si.Varint=0,si.Fixed64=1,si.Bytes=2,si.Fixed32=5;var Bv=4294967296,dw=1/Bv,pw=typeof TextDecoder=="undefined"?null:new TextDecoder("utf8");function Ya(a){return a.type===si.Bytes?a.readVarint()+a.pos:a.pos+1}function Qu(a,n,s){return s?4294967296*n+(a>>>0):4294967296*(n>>>0)+(a>>>0)}function fw(a,n,s){var u=n<=16383?1:n<=2097151?2:n<=268435455?3:Math.floor(Math.log(n)/(7*Math.LN2));s.realloc(u);for(var p=s.pos-1;p>=a;p--)s.buf[p+u]=s.buf[p]}function Uz(a,n){for(var s=0;s<a.length;s++)n.writeVarint(a[s])}function Vz(a,n){for(var s=0;s<a.length;s++)n.writeSVarint(a[s])}function Gz(a,n){for(var s=0;s<a.length;s++)n.writeFloat(a[s])}function Wz(a,n){for(var s=0;s<a.length;s++)n.writeDouble(a[s])}function jz(a,n){for(var s=0;s<a.length;s++)n.writeBoolean(a[s])}function Hz(a,n){for(var s=0;s<a.length;s++)n.writeFixed32(a[s])}function $z(a,n){for(var s=0;s<a.length;s++)n.writeSFixed32(a[s])}function qz(a,n){for(var s=0;s<a.length;s++)n.writeFixed64(a[s])}function Xz(a,n){for(var s=0;s<a.length;s++)n.writeSFixed64(a[s])}function Vg(a,n){return(a[n]|a[n+1]<<8|a[n+2]<<16)+16777216*a[n+3]}function eh(a,n,s){a[s]=n,a[s+1]=n>>>8,a[s+2]=n>>>16,a[s+3]=n>>>24}function mw(a,n){return(a[n]|a[n+1]<<8|a[n+2]<<16)+(a[n+3]<<24)}function Zz(a,n,s){n.glyphs=[],a===1&&s.readMessage(Yz,n)}function Yz(a,n,s){if(a===3){const{id:u,bitmap:p,width:g,height:_,left:T,top:D,advance:I}=s.readMessage(Kz,{});n.glyphs.push({id:u,bitmap:new Za({width:g+6,height:_+6},p),metrics:{width:g,height:_,left:T,top:D,advance:I}})}else a===4?n.ascender=s.readSVarint():a===5&&(n.descender=s.readSVarint())}function Kz(a,n,s){a===1?n.id=s.readVarint():a===2?n.bitmap=s.readBytes():a===3?n.width=s.readVarint():a===4?n.height=s.readVarint():a===5?n.left=s.readSVarint():a===6?n.top=s.readSVarint():a===7&&(n.advance=s.readVarint())}function Ov(a){let n=0,s=0;for(const _ of a)n+=_.w*_.h,s=Math.max(s,_.w);a.sort((_,T)=>T.h-_.h);const u=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(n/.95)),s),h:1/0}];let p=0,g=0;for(const _ of a)for(let T=u.length-1;T>=0;T--){const D=u[T];if(!(_.w>D.w||_.h>D.h)){if(_.x=D.x,_.y=D.y,g=Math.max(g,_.y+_.h),p=Math.max(p,_.x+_.w),_.w===D.w&&_.h===D.h){const I=u.pop();T<u.length&&(u[T]=I)}else _.h===D.h?(D.x+=_.w,D.w-=_.w):_.w===D.w?(D.y+=_.h,D.h-=_.h):(u.push({x:D.x+_.w,y:D.y,w:D.w-_.w,h:_.h}),D.y+=_.h,D.h-=_.h);break}}return{w:p,h:g,fill:n/(p*g)||0}}si.prototype={destroy:function(){this.buf=null},readFields:function(a,n,s){for(s=s||this.length;this.pos<s;){var u=this.readVarint(),p=u>>3,g=this.pos;this.type=7&u,a(p,n,this),this.pos===g&&this.skip(u)}return n},readMessage:function(a,n){return this.readFields(a,n,this.readVarint()+this.pos)},readFixed32:function(){var a=Vg(this.buf,this.pos);return this.pos+=4,a},readSFixed32:function(){var a=mw(this.buf,this.pos);return this.pos+=4,a},readFixed64:function(){var a=Vg(this.buf,this.pos)+Vg(this.buf,this.pos+4)*Bv;return this.pos+=8,a},readSFixed64:function(){var a=Vg(this.buf,this.pos)+mw(this.buf,this.pos+4)*Bv;return this.pos+=8,a},readFloat:function(){var a=uw(this.buf,this.pos,!0,23,4);return this.pos+=4,a},readDouble:function(){var a=uw(this.buf,this.pos,!0,52,8);return this.pos+=8,a},readVarint:function(a){var n,s,u=this.buf;return n=127&(s=u[this.pos++]),s<128?n:(n|=(127&(s=u[this.pos++]))<<7,s<128?n:(n|=(127&(s=u[this.pos++]))<<14,s<128?n:(n|=(127&(s=u[this.pos++]))<<21,s<128?n:function(p,g,_){var T,D,I=_.buf;if(T=(112&(D=I[_.pos++]))>>4,D<128||(T|=(127&(D=I[_.pos++]))<<3,D<128)||(T|=(127&(D=I[_.pos++]))<<10,D<128)||(T|=(127&(D=I[_.pos++]))<<17,D<128)||(T|=(127&(D=I[_.pos++]))<<24,D<128)||(T|=(1&(D=I[_.pos++]))<<31,D<128))return Qu(p,T,g);throw new Error("Expected varint not more than 10 bytes")}(n|=(15&(s=u[this.pos]))<<28,a,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var a=this.readVarint();return a%2==1?(a+1)/-2:a/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var a=this.readVarint()+this.pos,n=this.pos;return this.pos=a,a-n>=12&&pw?function(s,u,p){return pw.decode(s.subarray(u,p))}(this.buf,n,a):function(s,u,p){for(var g="",_=u;_<p;){var T,D,I,z=s[_],B=null,N=z>239?4:z>223?3:z>191?2:1;if(_+N>p)break;N===1?z<128&&(B=z):N===2?(192&(T=s[_+1]))==128&&(B=(31&z)<<6|63&T)<=127&&(B=null):N===3?(D=s[_+2],(192&(T=s[_+1]))==128&&(192&D)==128&&((B=(15&z)<<12|(63&T)<<6|63&D)<=2047||B>=55296&&B<=57343)&&(B=null)):N===4&&(D=s[_+2],I=s[_+3],(192&(T=s[_+1]))==128&&(192&D)==128&&(192&I)==128&&((B=(15&z)<<18|(63&T)<<12|(63&D)<<6|63&I)<=65535||B>=1114112)&&(B=null)),B===null?(B=65533,N=1):B>65535&&(B-=65536,g+=String.fromCharCode(B>>>10&1023|55296),B=56320|1023&B),g+=String.fromCharCode(B),_+=N}return g}(this.buf,n,a)},readBytes:function(){var a=this.readVarint()+this.pos,n=this.buf.subarray(this.pos,a);return this.pos=a,n},readPackedVarint:function(a,n){if(this.type!==si.Bytes)return a.push(this.readVarint(n));var s=Ya(this);for(a=a||[];this.pos<s;)a.push(this.readVarint(n));return a},readPackedSVarint:function(a){if(this.type!==si.Bytes)return a.push(this.readSVarint());var n=Ya(this);for(a=a||[];this.pos<n;)a.push(this.readSVarint());return a},readPackedBoolean:function(a){if(this.type!==si.Bytes)return a.push(this.readBoolean());var n=Ya(this);for(a=a||[];this.pos<n;)a.push(this.readBoolean());return a},readPackedFloat:function(a){if(this.type!==si.Bytes)return a.push(this.readFloat());var n=Ya(this);for(a=a||[];this.pos<n;)a.push(this.readFloat());return a},readPackedDouble:function(a){if(this.type!==si.Bytes)return a.push(this.readDouble());var n=Ya(this);for(a=a||[];this.pos<n;)a.push(this.readDouble());return a},readPackedFixed32:function(a){if(this.type!==si.Bytes)return a.push(this.readFixed32());var n=Ya(this);for(a=a||[];this.pos<n;)a.push(this.readFixed32());return a},readPackedSFixed32:function(a){if(this.type!==si.Bytes)return a.push(this.readSFixed32());var n=Ya(this);for(a=a||[];this.pos<n;)a.push(this.readSFixed32());return a},readPackedFixed64:function(a){if(this.type!==si.Bytes)return a.push(this.readFixed64());var n=Ya(this);for(a=a||[];this.pos<n;)a.push(this.readFixed64());return a},readPackedSFixed64:function(a){if(this.type!==si.Bytes)return a.push(this.readSFixed64());var n=Ya(this);for(a=a||[];this.pos<n;)a.push(this.readSFixed64());return a},skip:function(a){var n=7&a;if(n===si.Varint)for(;this.buf[this.pos++]>127;);else if(n===si.Bytes)this.pos=this.readVarint()+this.pos;else if(n===si.Fixed32)this.pos+=4;else{if(n!==si.Fixed64)throw new Error("Unimplemented type: "+n);this.pos+=8}},writeTag:function(a,n){this.writeVarint(a<<3|n)},realloc:function(a){for(var n=this.length||16;n<this.pos+a;)n*=2;if(n!==this.length){var s=new Uint8Array(n);s.set(this.buf),this.buf=s,this.length=n}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(a){this.realloc(4),eh(this.buf,a,this.pos),this.pos+=4},writeSFixed32:function(a){this.realloc(4),eh(this.buf,a,this.pos),this.pos+=4},writeFixed64:function(a){this.realloc(8),eh(this.buf,-1&a,this.pos),eh(this.buf,Math.floor(a*dw),this.pos+4),this.pos+=8},writeSFixed64:function(a){this.realloc(8),eh(this.buf,-1&a,this.pos),eh(this.buf,Math.floor(a*dw),this.pos+4),this.pos+=8},writeVarint:function(a){(a=+a||0)>268435455||a<0?function(n,s){var u,p;if(n>=0?(u=n%4294967296|0,p=n/4294967296|0):(p=~(-n/4294967296),4294967295^(u=~(-n%4294967296))?u=u+1|0:(u=0,p=p+1|0)),n>=18446744073709552e3||n<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");s.realloc(10),function(g,_,T){T.buf[T.pos++]=127&g|128,g>>>=7,T.buf[T.pos++]=127&g|128,g>>>=7,T.buf[T.pos++]=127&g|128,g>>>=7,T.buf[T.pos++]=127&g|128,T.buf[T.pos]=127&(g>>>=7)}(u,0,s),function(g,_){var T=(7&g)<<4;_.buf[_.pos++]|=T|((g>>>=3)?128:0),g&&(_.buf[_.pos++]=127&g|((g>>>=7)?128:0),g&&(_.buf[_.pos++]=127&g|((g>>>=7)?128:0),g&&(_.buf[_.pos++]=127&g|((g>>>=7)?128:0),g&&(_.buf[_.pos++]=127&g|((g>>>=7)?128:0),g&&(_.buf[_.pos++]=127&g)))))}(p,s)}(a,this):(this.realloc(4),this.buf[this.pos++]=127&a|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=a>>>7&127))))},writeSVarint:function(a){this.writeVarint(a<0?2*-a-1:2*a)},writeBoolean:function(a){this.writeVarint(!!a)},writeString:function(a){a=String(a),this.realloc(4*a.length),this.pos++;var n=this.pos;this.pos=function(u,p,g){for(var _,T,D=0;D<p.length;D++){if((_=p.charCodeAt(D))>55295&&_<57344){if(!T){_>56319||D+1===p.length?(u[g++]=239,u[g++]=191,u[g++]=189):T=_;continue}if(_<56320){u[g++]=239,u[g++]=191,u[g++]=189,T=_;continue}_=T-55296<<10|_-56320|65536,T=null}else T&&(u[g++]=239,u[g++]=191,u[g++]=189,T=null);_<128?u[g++]=_:(_<2048?u[g++]=_>>6|192:(_<65536?u[g++]=_>>12|224:(u[g++]=_>>18|240,u[g++]=_>>12&63|128),u[g++]=_>>6&63|128),u[g++]=63&_|128)}return g}(this.buf,a,this.pos);var s=this.pos-n;s>=128&&fw(n,s,this),this.pos=n-1,this.writeVarint(s),this.pos+=s},writeFloat:function(a){this.realloc(4),hw(this.buf,a,this.pos,!0,23,4),this.pos+=4},writeDouble:function(a){this.realloc(8),hw(this.buf,a,this.pos,!0,52,8),this.pos+=8},writeBytes:function(a){var n=a.length;this.writeVarint(n),this.realloc(n);for(var s=0;s<n;s++)this.buf[this.pos++]=a[s]},writeRawMessage:function(a,n){this.pos++;var s=this.pos;a(n,this);var u=this.pos-s;u>=128&&fw(s,u,this),this.pos=s-1,this.writeVarint(u),this.pos+=u},writeMessage:function(a,n,s){this.writeTag(a,si.Bytes),this.writeRawMessage(n,s)},writePackedVarint:function(a,n){n.length&&this.writeMessage(a,Uz,n)},writePackedSVarint:function(a,n){n.length&&this.writeMessage(a,Vz,n)},writePackedBoolean:function(a,n){n.length&&this.writeMessage(a,jz,n)},writePackedFloat:function(a,n){n.length&&this.writeMessage(a,Gz,n)},writePackedDouble:function(a,n){n.length&&this.writeMessage(a,Wz,n)},writePackedFixed32:function(a,n){n.length&&this.writeMessage(a,Hz,n)},writePackedSFixed32:function(a,n){n.length&&this.writeMessage(a,$z,n)},writePackedFixed64:function(a,n){n.length&&this.writeMessage(a,qz,n)},writePackedSFixed64:function(a,n){n.length&&this.writeMessage(a,Xz,n)},writeBytesField:function(a,n){this.writeTag(a,si.Bytes),this.writeBytes(n)},writeFixed32Field:function(a,n){this.writeTag(a,si.Fixed32),this.writeFixed32(n)},writeSFixed32Field:function(a,n){this.writeTag(a,si.Fixed32),this.writeSFixed32(n)},writeFixed64Field:function(a,n){this.writeTag(a,si.Fixed64),this.writeFixed64(n)},writeSFixed64Field:function(a,n){this.writeTag(a,si.Fixed64),this.writeSFixed64(n)},writeVarintField:function(a,n){this.writeTag(a,si.Varint),this.writeVarint(n)},writeSVarintField:function(a,n){this.writeTag(a,si.Varint),this.writeSVarint(n)},writeStringField:function(a,n){this.writeTag(a,si.Bytes),this.writeString(n)},writeFloatField:function(a,n){this.writeTag(a,si.Fixed32),this.writeFloat(n)},writeDoubleField:function(a,n){this.writeTag(a,si.Fixed64),this.writeDouble(n)},writeBooleanField:function(a,n){this.writeVarintField(a,!!n)}};class Nv{constructor(n,{pixelRatio:s,version:u,stretchX:p,stretchY:g,content:_}){this.paddedRect=n,this.pixelRatio=s,this.stretchX=p,this.stretchY=g,this.content=_,this.version=u}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class gw{constructor(n,s){const u={},p={};this.haveRenderCallbacks=[];const g=[];this.addImages(n,u,g),this.addImages(s,p,g);const{w:_,h:T}=Ov(g),D=new Yr({width:_||1,height:T||1});for(const I in n){const z=n[I],B=u[I].paddedRect;Yr.copy(z.data,D,{x:0,y:0},{x:B.x+1,y:B.y+1},z.data)}for(const I in s){const z=s[I],B=p[I].paddedRect,N=B.x+1,W=B.y+1,K=z.data.width,oe=z.data.height;Yr.copy(z.data,D,{x:0,y:0},{x:N,y:W},z.data),Yr.copy(z.data,D,{x:0,y:oe-1},{x:N,y:W-1},{width:K,height:1}),Yr.copy(z.data,D,{x:0,y:0},{x:N,y:W+oe},{width:K,height:1}),Yr.copy(z.data,D,{x:K-1,y:0},{x:N-1,y:W},{width:1,height:oe}),Yr.copy(z.data,D,{x:0,y:0},{x:N+K,y:W},{width:1,height:oe})}this.image=D,this.iconPositions=u,this.patternPositions=p}addImages(n,s,u){for(const p in n){const g=n[p],_={x:0,y:0,w:g.data.width+2,h:g.data.height+2};u.push(_),s[p]=new Nv(_,g),g.hasRenderCallback&&this.haveRenderCallbacks.push(p)}}patchUpdatedImages(n,s){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(u=>n.hasImage(u)),n.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const u in n.updatedImages)this.patchUpdatedImage(this.iconPositions[u],n.getImage(u),s),this.patchUpdatedImage(this.patternPositions[u],n.getImage(u),s)}patchUpdatedImage(n,s,u){if(!n||!s||n.version===s.version)return;n.version=s.version;const[p,g]=n.tl;u.update(s.data,void 0,{x:p,y:g})}}$t(Nv,"ImagePosition"),$t(gw,"ImageAtlas");const yo={horizontal:1,vertical:2,horizontalOnly:3};class Sp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(n,s){const u=new Sp;return u.scale=n||1,u.fontStack=s,u}static forImage(n){const s=new Sp;return s.imageName=n,s}}class th{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(n,s){const u=new th;for(let p=0;p<n.sections.length;p++){const g=n.sections[p];g.image?u.addImageSection(g):u.addTextSection(g,s)}return u}length(){return this.text.length}getSection(n){return this.sections[this.sectionIndex[n]]}getSections(){return this.sections}getSectionIndex(n){return this.sectionIndex[n]}getCharCode(n){return this.text.charCodeAt(n)}verticalizePunctuation(n){this.text=function(s,u){let p="";for(let g=0;g<s.length;g++){const _=s.charCodeAt(g+1)||null,T=s.charCodeAt(g-1)||null;p+=!u&&(_&&Uu(_)&&!Dp[s[g+1]]||T&&Uu(T)&&!Dp[s[g-1]])||!Dp[s[g]]?s[g]:Dp[s[g]]}return p}(this.text,n)}trim(){let n=0;for(let u=0;u<this.text.length&&Gg[this.text.charCodeAt(u)];u++)n++;let s=this.text.length;for(let u=this.text.length-1;u>=0&&u>=n&&Gg[this.text.charCodeAt(u)];u--)s--;this.text=this.text.substring(n,s),this.sectionIndex=this.sectionIndex.slice(n,s)}substring(n,s){const u=new th;return u.text=this.text.substring(n,s),u.sectionIndex=this.sectionIndex.slice(n,s),u.sections=this.sections,u}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((n,s)=>Math.max(n,this.sections[s].scale),0)}addTextSection(n,s){this.text+=n.text,this.sections.push(Sp.forText(n.scale,n.fontStack||s));const u=this.sections.length-1;for(let p=0;p<n.text.length;++p)this.sectionIndex.push(u)}addImageSection(n){const s=n.image?n.image.name:"";if(s.length===0)return void be("Can't add FormattedSection with an empty image.");const u=this.getNextImageSectionCharCode();u?(this.text+=String.fromCharCode(u),this.sections.push(Sp.forImage(s)),this.sectionIndex.push(this.sections.length-1)):be("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Uv(a,n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe){const ue=th.fromFeature(a,p);let xe;B===yo.vertical&&ue.verticalizePunctuation(N);const{processBidirectionalText:Be,processStyledBidirectionalText:$e}=qr;if(Be&&ue.sections.length===1){xe=[];const Ke=Be(ue.toString(),Vv(ue,I,g,n,u,W,K));for(const ut of Ke){const dt=new th;dt.text=ut,dt.sections=ue.sections;for(let xt=0;xt<ut.length;xt++)dt.sectionIndex.push(0);xe.push(dt)}}else if($e){xe=[];const Ke=$e(ue.text,ue.sectionIndex,Vv(ue,I,g,n,u,W,K));for(const ut of Ke){const dt=new th;dt.text=ut[0],dt.sectionIndex=ut[1],dt.sections=ue.sections,xe.push(dt)}}else xe=function(Ke,ut){const dt=[],xt=Ke.text;let Et=0;for(const st of ut)dt.push(Ke.substring(Et,st)),Et=st;return Et<xt.length&&dt.push(Ke.substring(Et,xt.length)),dt}(ue,Vv(ue,I,g,n,u,W,K));const Ze=[],Ye={positionedLines:Ze,text:ue.toString(),top:z[1],bottom:z[1],left:z[0],right:z[0],writingMode:B,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(Ke,ut,dt,xt,Et,st,mt,Pt,Bt,Rt,Ft,En){let Un=0,An=0,Fn=0;const Qt=Pt==="right"?1:Pt==="left"?0:.5;let Ht=!1;for(const Jn of Et){const Wn=Jn.getSections();for(const ni of Wn){if(ni.imageName)continue;const wi=ut[ni.fontStack];if(wi&&(Ht=wi.ascender!==void 0&&wi.descender!==void 0,!Ht))break}if(!Ht)break}let Vn=0;for(const Jn of Et){Jn.trim();const Wn=Jn.getMaxScale(),ni=(Wn-1)*or,wi={positionedGlyphs:[],lineOffset:0};Ke.positionedLines[Vn]=wi;const Ci=wi.positionedGlyphs;let Ni=0;if(!Jn.length()){An+=st,++Vn;continue}let Zi=0,Qr=0;for(let ii=0;ii<Jn.length();ii++){const xr=Jn.getSection(ii),eo=Jn.getSectionIndex(ii),er=Jn.getCharCode(ii);let Yi=xr.scale,fi=null,hi=null,Or=null,br=or,Ii=0;const wr=!(Bt===yo.horizontal||!Ft&&!Nu(er)||Ft&&(Gg[er]||(Kn=er,lg(Kn)||ku(Kn)||Ul(Kn)||op(Kn)||Bu(Kn))));if(xr.imageName){const dr=xt[xr.imageName];if(!dr)continue;Or=xr.imageName,Ke.iconsInText=Ke.iconsInText||!0,hi=dr.paddedRect;const Ki=dr.displaySize;Yi=Yi*or/En,fi={width:Ki[0],height:Ki[1],left:1,top:-3,advance:wr?Ki[1]:Ki[0],localGlyph:!1},Ii=Ht?-fi.height*Yi:Wn*or-17-Ki[1]*Yi,br=fi.advance;const Co=(wr?Ki[0]:Ki[1])*Yi-or*Wn;Co>0&&Co>Ni&&(Ni=Co)}else{const dr=dt[xr.fontStack];if(!dr)continue;dr[er]&&(hi=dr[er]);const Ki=ut[xr.fontStack];if(!Ki)continue;const Co=Ki.glyphs[er];if(!Co)continue;if(fi=Co.metrics,br=er!==8203?or:0,Ht){const qs=Ki.ascender!==void 0?Math.abs(Ki.ascender):0,Up=Ki.descender!==void 0?Math.abs(Ki.descender):0,Vp=(qs+Up)*Yi;Zi<Vp&&(Zi=Vp,Qr=(qs-Up)/2*Yi),Ii=-qs*Yi}else Ii=(Wn-Yi)*or-17}wr?(Ke.verticalizable=!0,Ci.push({glyph:er,imageName:Or,x:Un,y:An+Ii,vertical:wr,scale:Yi,localGlyph:fi.localGlyph,fontStack:xr.fontStack,sectionIndex:eo,metrics:fi,rect:hi}),Un+=br*Yi+Rt):(Ci.push({glyph:er,imageName:Or,x:Un,y:An+Ii,vertical:wr,scale:Yi,localGlyph:fi.localGlyph,fontStack:xr.fontStack,sectionIndex:eo,metrics:fi,rect:hi}),Un+=fi.advance*Yi+Rt)}Ci.length!==0&&(Fn=Math.max(Un-Rt,Fn),Ht?bw(Ci,Qt,Ni,Qr,st*Wn/2):bw(Ci,Qt,Ni,0,st/2)),Un=0;const Br=st*Wn+Ni;wi.lineOffset=Math.max(Ni,ni),An+=Br,++Vn}var Kn;const Bi=An,{horizontalAlign:ui,verticalAlign:Oi}=Gv(mt);(function(Jn,Wn,ni,wi,Ci,Ni){const Zi=(Wn-ni)*Ci,Qr=-Ni*wi;for(const Br of Jn)for(const ii of Br.positionedGlyphs)ii.x+=Zi,ii.y+=Qr})(Ke.positionedLines,Qt,ui,Oi,Fn,Bi),Ke.top+=-Oi*Bi,Ke.bottom=Ke.top+Bi,Ke.left+=-ui*Fn,Ke.right=Ke.left+Fn,Ke.hasBaseline=Ht}(Ye,n,s,u,xe,_,T,D,B,I,N,oe),!function(Ke){for(const ut of Ke)if(ut.positionedGlyphs.length!==0)return!1;return!0}(Ze)&&Ye}const Gg={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Jz={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function yw(a,n,s,u,p,g){if(n.imageName){const _=u[n.imageName];return _?_.displaySize[0]*n.scale*or/g+p:0}{const _=s[n.fontStack],T=_&&_.glyphs[a];return T?T.metrics.advance*n.scale+p:0}}function _w(a,n,s,u){const p=Math.pow(a-n,2);return u?a<n?p/2:2*p:p+Math.abs(s)*s}function Qz(a,n,s){let u=0;return a===10&&(u-=1e4),s&&(u+=150),a!==40&&a!==65288||(u+=50),n!==41&&n!==65289||(u+=50),u}function vw(a,n,s,u,p,g){let _=null,T=_w(n,s,p,g);for(const D of u){const I=_w(n-D.x,s,p,g)+D.badness;I<=T&&(_=D,T=I)}return{index:a,x:n,priorBreak:_,badness:T}}function xw(a){return a?xw(a.priorBreak).concat(a.index):[]}function Vv(a,n,s,u,p,g,_){if(g!=="point")return[];if(!a)return[];const T=[],D=function(N,W,K,oe,ue,xe){let Be=0;for(let $e=0;$e<N.length();$e++){const Ze=N.getSection($e);Be+=yw(N.getCharCode($e),Ze,oe,ue,W,xe)}return Be/Math.max(1,Math.ceil(Be/K))}(a,n,s,u,p,_),I=a.text.indexOf("")>=0;let z=0;for(let N=0;N<a.length();N++){const W=a.getSection(N),K=a.getCharCode(N);if(Gg[K]||(z+=yw(K,W,u,p,n,_)),N<a.length()-1){const oe=!((B=K)<11904||!(hg(B)||ug(B)||Is(B)||Gl(B)||fg(B)||tp(B)||dg(B)||zu(B)||mg(B)||rp(B)||pg(B)||ap(B)||Vl(B)||np(B)||cg(B)||ip(B)||Fu(B)||vg(B)||yg(B)||gg(B)));(Jz[K]||oe||W.imageName)&&T.push(vw(N+1,z,D,T,Qz(K,a.getCharCode(N+1),oe&&I),!1))}}var B;return xw(vw(a.length(),z,D,T,0,!0))}function Gv(a){let n=.5,s=.5;switch(a){case"right":case"top-right":case"bottom-right":n=1;break;case"left":case"top-left":case"bottom-left":n=0}switch(a){case"bottom":case"bottom-right":case"bottom-left":s=1;break;case"top":case"top-right":case"top-left":s=0}return{horizontalAlign:n,verticalAlign:s}}function bw(a,n,s,u,p){if(!(n||s||u||p))return;const g=a.length-1,_=a[g],T=(_.x+_.metrics.advance*_.scale)*n;for(let D=0;D<=g;D++)a[D].x-=T,a[D].y+=s+u+p}function eF(a,n,s){const{horizontalAlign:u,verticalAlign:p}=Gv(s),g=n[0]-a.displaySize[0]*u,_=n[1]-a.displaySize[1]*p;return{image:a,top:_,bottom:_+a.displaySize[1],left:g,right:g+a.displaySize[0]}}function ww(a,n,s,u,p,g){const _=a.image;let T;if(_.content){const ue=_.content,xe=_.pixelRatio||1;T=[ue[0]/xe,ue[1]/xe,_.displaySize[0]-ue[2]/xe,_.displaySize[1]-ue[3]/xe]}const D=n.left*g,I=n.right*g;let z,B,N,W;s==="width"||s==="both"?(W=p[0]+D-u[3],B=p[0]+I+u[1]):(W=p[0]+(D+I-_.displaySize[0])/2,B=W+_.displaySize[0]);const K=n.top*g,oe=n.bottom*g;return s==="height"||s==="both"?(z=p[1]+K-u[0],N=p[1]+oe+u[2]):(z=p[1]+(K+oe-_.displaySize[1])/2,N=z+_.displaySize[1]),{image:_,top:z,right:B,bottom:N,left:W,collisionPadding:T}}class Ka extends b{constructor(n,s,u,p,g){super(n,s),this.angle=p,this.z=u,g!==void 0&&(this.segment=g)}clone(){return new Ka(this.x,this.y,this.z,this.angle,this.segment)}}function Mw(a,n,s,u,p){if(n.segment===void 0)return!0;let g=n,_=n.segment+1,T=0;for(;T>-s/2;){if(_--,_<0)return!1;T-=a[_].dist(g),g=a[_]}T+=a[_].dist(a[_+1]),_++;const D=[];let I=0;for(;T<s/2;){const z=a[_],B=a[_+1];if(!B)return!1;let N=a[_-1].angleTo(z)-z.angleTo(B);for(N=Math.abs((N+3*Math.PI)%(2*Math.PI)-Math.PI),D.push({distance:T,angleDelta:N}),I+=N;T-D[0].distance>u;)I-=D.shift().angleDelta;if(I>p)return!1;_++,T+=z.dist(B)}return!0}function Tw(a){let n=0;for(let s=0;s<a.length-1;s++)n+=a[s].dist(a[s+1]);return n}function Ew(a,n,s){return a?.6*n*s:0}function Cw(a,n){return Math.max(a?a.right-a.left:0,n?n.right-n.left:0)}function tF(a,n,s,u,p,g){const _=Ew(s,p,g),T=Cw(s,u)*g;let D=0;const I=Tw(a)/2;for(let z=0;z<a.length-1;z++){const B=a[z],N=a[z+1],W=B.dist(N);if(D+W>I){const K=(I-D)/W,oe=yn(B.x,N.x,K),ue=yn(B.y,N.y,K),xe=new Ka(oe,ue,0,N.angleTo(B),z);return!_||Mw(a,xe,T,_,n)?xe:void 0}D+=W}}function nF(a,n,s,u,p,g,_,T,D){const I=Ew(u,g,_),z=Cw(u,p),B=z*_,N=a[0].x===0||a[0].x===D||a[0].y===0||a[0].y===D;return n-B<n/4&&(n=B+n/4),Aw(a,N?n/2*T%n:(z/2+2*g)*_*T%n,n,I,s,B,N,!1,D)}function Aw(a,n,s,u,p,g,_,T,D){const I=g/2,z=Tw(a);let B=0,N=n-s,W=[];for(let K=0;K<a.length-1;K++){const oe=a[K],ue=a[K+1],xe=oe.dist(ue),Be=ue.angleTo(oe);for(;N+s<B+xe;){N+=s;const $e=(N-B)/xe,Ze=yn(oe.x,ue.x,$e),Ye=yn(oe.y,ue.y,$e);if(Ze>=0&&Ze<D&&Ye>=0&&Ye<D&&N-I>=0&&N+I<=z){const Ke=new Ka(Ze,Ye,0,Be,K);Ke._round(),u&&!Mw(a,Ke,g,u,p)||W.push(Ke)}}B+=xe}return T||W.length||_||(W=Aw(a,B/2,s,u,p,g,_,!0,D)),W}function Dw(a,n,s,u,p){const g=[];for(let _=0;_<a.length;_++){const T=a[_];let D;for(let I=0;I<T.length-1;I++){let z=T[I],B=T[I+1];z.x<n&&B.x<n||(z.x<n?z=new b(n,z.y+(n-z.x)/(B.x-z.x)*(B.y-z.y))._round():B.x<n&&(B=new b(n,z.y+(n-z.x)/(B.x-z.x)*(B.y-z.y))._round()),z.y<s&&B.y<s||(z.y<s?z=new b(z.x+(s-z.y)/(B.y-z.y)*(B.x-z.x),s)._round():B.y<s&&(B=new b(z.x+(s-z.y)/(B.y-z.y)*(B.x-z.x),s)._round()),z.x>=u&&B.x>=u||(z.x>=u?z=new b(u,z.y+(u-z.x)/(B.x-z.x)*(B.y-z.y))._round():B.x>=u&&(B=new b(u,z.y+(u-z.x)/(B.x-z.x)*(B.y-z.y))._round()),z.y>=p&&B.y>=p||(z.y>=p?z=new b(z.x+(p-z.y)/(B.y-z.y)*(B.x-z.x),p)._round():B.y>=p&&(B=new b(z.x+(p-z.y)/(B.y-z.y)*(B.x-z.x),p)._round()),D&&z.equals(D[D.length-1])||(D=[z],g.push(D)),D.push(B)))))}}return g}$t(Ka,"Anchor");const Lp=1e20;function Pw(a,n,s,u,p,g,_,T,D){for(let I=n;I<n+u;I++)Sw(a,s*g+I,g,p,_,T,D);for(let I=s;I<s+p;I++)Sw(a,I*g+n,1,u,_,T,D)}function Sw(a,n,s,u,p,g,_){g[0]=0,_[0]=-Lp,_[1]=Lp,p[0]=a[n];for(let T=1,D=0,I=0;T<u;T++){p[T]=a[n+T*s];const z=T*T;do{const B=g[D];I=(p[T]-p[B]+z-B*B)/(T-B)/2}while(I<=_[D]&&--D>-1);D++,g[D]=T,_[D]=I,_[D+1]=Lp}for(let T=0,D=0;T<u;T++){for(;_[D+1]<T;)D++;const I=g[D],z=T-I;a[n+T*s]=p[I]+z*z}}const Wv={none:0,ideographs:1,all:2};class nh{constructor(n,s,u){this.requestManager=n,this.localGlyphMode=s,this.localFontFamily=u,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(n){this.url=n}getGlyphs(n,s){const u=[];for(const p in n)for(const g of n[p])u.push({stack:p,id:g});le(u,({stack:p,id:g},_)=>{let T=this.entries[p];T||(T=this.entries[p]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let D=T.glyphs[g];if(D!==void 0)return void _(null,{stack:p,id:g,glyph:D});if(D=this._tinySDF(T,p,g),D)return T.glyphs[g]=D,void _(null,{stack:p,id:g,glyph:D});const I=Math.floor(g/256);if(256*I>65535)return void _(new Error("glyphs > 65535 not supported"));if(T.ranges[I])return void _(null,{stack:p,id:g,glyph:D});let z=T.requests[I];z||(z=T.requests[I]=[],nh.loadGlyphRange(p,I,this.url,this.requestManager,(B,N)=>{if(N){T.ascender=N.ascender,T.descender=N.descender;for(const W in N.glyphs)this._doesCharSupportLocalGlyph(+W)||(T.glyphs[+W]=N.glyphs[+W]);T.ranges[I]=!0}for(const W of z)W(B,N);delete T.requests[I]})),z.push((B,N)=>{B?_(B):N&&_(null,{stack:p,id:g,glyph:N.glyphs[g]||null})})},(p,g)=>{if(p)s(p);else if(g){const _={};for(const{stack:T,id:D,glyph:I}of g)_[T]===void 0&&(_[T]={}),_[T].glyphs===void 0&&(_[T].glyphs={}),_[T].glyphs[D]=I&&{id:I.id,bitmap:I.bitmap.clone(),metrics:I.metrics},_[T].ascender=this.entries[T].ascender,_[T].descender=this.entries[T].descender;s(null,_)}})}_doesCharSupportLocalGlyph(n){return this.localGlyphMode!==Wv.none&&(this.localGlyphMode===Wv.all?!!this.localFontFamily:!!this.localFontFamily&&(rp(n)||_g(n)||Vl(n)||Fu(n)||zu(n)))}_tinySDF(n,s,u){const p=this.localFontFamily;if(!p||!this._doesCharSupportLocalGlyph(u))return;let g=n.tinySDF;if(!g){let oe="400";/bold/i.test(s)?oe="900":/medium/i.test(s)?oe="500":/light/i.test(s)&&(oe="200"),g=n.tinySDF=new nh.TinySDF({fontFamily:p,fontWeight:oe,fontSize:48,buffer:6,radius:16}),g.fontWeight=oe}if(this.localGlyphs[g.fontWeight][u])return this.localGlyphs[g.fontWeight][u];const _=String.fromCharCode(u),{data:T,width:D,height:I,glyphWidth:z,glyphHeight:B,glyphLeft:N,glyphTop:W,glyphAdvance:K}=g.draw(_);return this.localGlyphs[g.fontWeight][u]={id:u,bitmap:new Za({width:D,height:I},T),metrics:{width:z/2,height:B/2,left:N/2,top:W/2-27,advance:K/2,localGlyph:!0}}}}function Lw(a,n,s,u){const p=[],g=a.image,_=g.pixelRatio,T=g.paddedRect.w-2,D=g.paddedRect.h-2,I=a.right-a.left,z=a.bottom-a.top,B=g.stretchX||[[0,T]],N=g.stretchY||[[0,D]],W=(st,mt)=>st+mt[1]-mt[0],K=B.reduce(W,0),oe=N.reduce(W,0),ue=T-K,xe=D-oe;let Be=0,$e=K,Ze=0,Ye=oe,Ke=0,ut=ue,dt=0,xt=xe;if(g.content&&u){const st=g.content;Be=Wg(B,0,st[0]),Ze=Wg(N,0,st[1]),$e=Wg(B,st[0],st[2]),Ye=Wg(N,st[1],st[3]),Ke=st[0]-Be,dt=st[1]-Ze,ut=st[2]-st[0]-$e,xt=st[3]-st[1]-Ye}const Et=(st,mt,Pt,Bt)=>{const Rt=jg(st.stretch-Be,$e,I,a.left),Ft=Hg(st.fixed-Ke,ut,st.stretch,K),En=jg(mt.stretch-Ze,Ye,z,a.top),Un=Hg(mt.fixed-dt,xt,mt.stretch,oe),An=jg(Pt.stretch-Be,$e,I,a.left),Fn=Hg(Pt.fixed-Ke,ut,Pt.stretch,K),Qt=jg(Bt.stretch-Ze,Ye,z,a.top),Ht=Hg(Bt.fixed-dt,xt,Bt.stretch,oe),Vn=new b(Rt,En),Kn=new b(An,En),Bi=new b(An,Qt),ui=new b(Rt,Qt),Oi=new b(Ft/_,Un/_),Jn=new b(Fn/_,Ht/_),Wn=n*Math.PI/180;if(Wn){const Ci=Math.sin(Wn),Ni=Math.cos(Wn),Zi=[Ni,-Ci,Ci,Ni];Vn._matMult(Zi),Kn._matMult(Zi),ui._matMult(Zi),Bi._matMult(Zi)}const ni=st.stretch+st.fixed,wi=mt.stretch+mt.fixed;return{tl:Vn,tr:Kn,bl:ui,br:Bi,tex:{x:g.paddedRect.x+1+ni,y:g.paddedRect.y+1+wi,w:Pt.stretch+Pt.fixed-ni,h:Bt.stretch+Bt.fixed-wi},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Oi,pixelOffsetBR:Jn,minFontScaleX:ut/_/I,minFontScaleY:xt/_/z,isSDF:s}};if(u&&(g.stretchX||g.stretchY)){const st=Iw(B,ue,K),mt=Iw(N,xe,oe);for(let Pt=0;Pt<st.length-1;Pt++){const Bt=st[Pt],Rt=st[Pt+1];for(let Ft=0;Ft<mt.length-1;Ft++)p.push(Et(Bt,mt[Ft],Rt,mt[Ft+1]))}}else p.push(Et({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:T+1},{fixed:0,stretch:D+1}));return p}function Wg(a,n,s){let u=0;for(const p of a)u+=Math.max(n,Math.min(s,p[1]))-Math.max(n,Math.min(s,p[0]));return u}function Iw(a,n,s){const u=[{fixed:-1,stretch:0}];for(const[p,g]of a){const _=u[u.length-1];u.push({fixed:p-_.stretch,stretch:_.stretch}),u.push({fixed:p-_.stretch,stretch:_.stretch+(g-p)})}return u.push({fixed:n+1,stretch:s}),u}function jg(a,n,s,u){return a/n*s+u}function Hg(a,n,s,u){return a-n*s/u}function iF(a,n,s,u){const p=n+a.positionedLines[u].lineOffset;return u===0?s+p/2:s+(p+(n+a.positionedLines[u-1].lineOffset))/2}nh.loadGlyphRange=function(a,n,s,u,p){const g=256*n,_=g+255,T=u.transformRequest(u.normalizeGlyphsURL(s).replace("{fontstack}",a).replace("{range}",`${g}-${_}`),we.Glyphs);Re(T,(D,I)=>{if(D)p(D);else if(I){const z={},B=function(N){return new Pp(N).readFields(Zz,{})}(I);for(const N of B.glyphs)z[N.id]=N;p(null,{glyphs:z,ascender:B.ascender,descender:B.descender})}})},nh.TinySDF=class{constructor({fontSize:a=24,buffer:n=3,radius:s=8,cutoff:u=.25,fontFamily:p="sans-serif",fontWeight:g="normal",fontStyle:_="normal"}){this.buffer=n,this.cutoff=u,this.radius=s;const T=this.size=a+4*n,D=this._createCanvas(T),I=this.ctx=D.getContext("2d",{willReadFrequently:!0});I.font=`${_} ${g} ${a}px ${p}`,I.textBaseline="alphabetic",I.textAlign="left",I.fillStyle="black",this.gridOuter=new Float64Array(T*T),this.gridInner=new Float64Array(T*T),this.f=new Float64Array(T),this.z=new Float64Array(T+1),this.v=new Uint16Array(T)}_createCanvas(a){const n=document.createElement("canvas");return n.width=n.height=a,n}draw(a){const{width:n,actualBoundingBoxAscent:s,actualBoundingBoxDescent:u,actualBoundingBoxLeft:p,actualBoundingBoxRight:g}=this.ctx.measureText(a),_=Math.floor(s),T=Math.min(this.size-this.buffer,Math.ceil(g-p)),D=Math.min(this.size-this.buffer,Math.ceil(s)+Math.ceil(u)),I=T+2*this.buffer,z=D+2*this.buffer,B=I*z,N=new Uint8ClampedArray(B),W={data:N,width:I,height:z,glyphWidth:T,glyphHeight:D,glyphTop:_,glyphLeft:0,glyphAdvance:n};if(T===0||D===0)return W;const{ctx:K,buffer:oe,gridInner:ue,gridOuter:xe}=this;K.clearRect(oe,oe,T,D),K.fillText(a,oe,oe+_+1);const Be=K.getImageData(oe,oe,T,D);xe.fill(Lp,0,B),ue.fill(0,0,B);for(let $e=0;$e<D;$e++)for(let Ze=0;Ze<T;Ze++){const Ye=Be.data[4*($e*T+Ze)+3]/255;if(Ye===0)continue;const Ke=($e+oe)*I+Ze+oe;if(Ye===1)xe[Ke]=0,ue[Ke]=Lp;else{const ut=.5-Ye;xe[Ke]=ut>0?ut*ut:0,ue[Ke]=ut<0?ut*ut:0}}Pw(xe,0,0,I,z,I,this.f,this.v,this.z),Pw(ue,oe,oe,T,D,I,this.f,this.v,this.z);for(let $e=0;$e<B;$e++){const Ze=Math.sqrt(xe[$e])-Math.sqrt(ue[$e]);N[$e]=Math.round(255-255*(Ze/this.radius+this.cutoff))}return W}};class rF{constructor(n=[],s=oF){if(this.data=n,this.length=this.data.length,this.compare=s,this.length>0)for(let u=(this.length>>1)-1;u>=0;u--)this._down(u)}push(n){this.data.push(n),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const n=this.data[0],s=this.data.pop();return this.length--,this.length>0&&(this.data[0]=s,this._down(0)),n}peek(){return this.data[0]}_up(n){const{data:s,compare:u}=this,p=s[n];for(;n>0;){const g=n-1>>1,_=s[g];if(u(p,_)>=0)break;s[n]=_,n=g}s[n]=p}_down(n){const{data:s,compare:u}=this,p=this.length>>1,g=s[n];for(;n<p;){let _=1+(n<<1),T=s[_];const D=_+1;if(D<this.length&&u(s[D],T)<0&&(_=D,T=s[D]),u(T,g)>=0)break;s[n]=T,n=_}s[n]=g}}function oF(a,n){return a<n?-1:a>n?1:0}function aF(a,n=1,s=!1){let u=1/0,p=1/0,g=-1/0,_=-1/0;const T=a[0];for(let W=0;W<T.length;W++){const K=T[W];(!W||K.x<u)&&(u=K.x),(!W||K.y<p)&&(p=K.y),(!W||K.x>g)&&(g=K.x),(!W||K.y>_)&&(_=K.y)}const D=Math.min(g-u,_-p);let I=D/2;const z=new rF([],sF);if(D===0)return new b(u,p);for(let W=u;W<g;W+=D)for(let K=p;K<_;K+=D)z.push(new ih(W+I,K+I,I,a));let B=function(W){let K=0,oe=0,ue=0;const xe=W[0];for(let Be=0,$e=xe.length,Ze=$e-1;Be<$e;Ze=Be++){const Ye=xe[Be],Ke=xe[Ze],ut=Ye.x*Ke.y-Ke.x*Ye.y;oe+=(Ye.x+Ke.x)*ut,ue+=(Ye.y+Ke.y)*ut,K+=3*ut}return new ih(oe/K,ue/K,0,W)}(a),N=z.length;for(;z.length;){const W=z.pop();(W.d>B.d||!B.d)&&(B=W,s&&console.log("found best %d after %d probes",Math.round(1e4*W.d)/1e4,N)),W.max-B.d<=n||(I=W.h/2,z.push(new ih(W.p.x-I,W.p.y-I,I,a)),z.push(new ih(W.p.x+I,W.p.y-I,I,a)),z.push(new ih(W.p.x-I,W.p.y+I,I,a)),z.push(new ih(W.p.x+I,W.p.y+I,I,a)),N+=4)}return s&&(console.log(`num probes: ${N}`),console.log(`best distance: ${B.d}`)),B.p}function sF(a,n){return n.max-a.max}function ih(a,n,s,u){this.p=new b(a,n),this.h=s,this.d=function(p,g){let _=!1,T=1/0;for(let D=0;D<g.length;D++){const I=g[D];for(let z=0,B=I.length,N=B-1;z<B;N=z++){const W=I[z],K=I[N];W.y>p.y!=K.y>p.y&&p.x<(K.x-W.x)*(p.y-W.y)/(K.y-W.y)+W.x&&(_=!_),T=Math.min(T,Db(p,W,K))}}return(_?1:-1)*Math.sqrt(T)}(this.p,u),this.max=this.d+this.h*Math.SQRT2}const jv=Number.POSITIVE_INFINITY,lF=Math.sqrt(2);function Rw(a,n){return n[1]!==jv?function(s,u,p){let g=0,_=0;switch(u=Math.abs(u),p=Math.abs(p),s){case"top-right":case"top-left":case"top":_=p-7;break;case"bottom-right":case"bottom-left":case"bottom":_=7-p}switch(s){case"top-right":case"bottom-right":case"right":g=-u;break;case"top-left":case"bottom-left":case"left":g=u}return[g,_]}(a,n[0],n[1]):function(s,u){let p=0,g=0;u<0&&(u=0);const _=u/lF;switch(s){case"top-right":case"top-left":g=_-7;break;case"bottom-right":case"bottom-left":g=7-_;break;case"bottom":g=7-u;break;case"top":g=u-7}switch(s){case"top-right":case"bottom-right":p=-_;break;case"top-left":case"bottom-left":p=_;break;case"left":p=u;break;case"right":p=-u}return[p,g]}(a,n[0])}function cF(a,n,s,u,p,g,_,T,D,I){a.createArrays(),a.tilePixelRatio=In/(512*a.overscaling),a.compareText={},a.iconsNeedLinear=!1;const z=a.layers[0].layout,B=a.layers[0]._unevaluatedLayout._values,N={};if(a.textSizeData.kind==="composite"){const{minZoom:oe,maxZoom:ue}=a.textSizeData;N.compositeTextSizes=[B["text-size"].possiblyEvaluate(new ci(oe),T),B["text-size"].possiblyEvaluate(new ci(ue),T)]}if(a.iconSizeData.kind==="composite"){const{minZoom:oe,maxZoom:ue}=a.iconSizeData;N.compositeIconSizes=[B["icon-size"].possiblyEvaluate(new ci(oe),T),B["icon-size"].possiblyEvaluate(new ci(ue),T)]}N.layoutTextSize=B["text-size"].possiblyEvaluate(new ci(D+1),T),N.layoutIconSize=B["icon-size"].possiblyEvaluate(new ci(D+1),T),N.textMaxSize=B["text-size"].possiblyEvaluate(new ci(18),T);const W=z.get("text-rotation-alignment")==="map"&&z.get("symbol-placement")!=="point",K=z.get("text-size");for(const oe of a.features){const ue=z.get("text-font").evaluate(oe,{},T).join(","),xe=K.evaluate(oe,{},T),Be=N.layoutTextSize.evaluate(oe,{},T),$e=(N.layoutIconSize.evaluate(oe,{},T),{horizontal:{},vertical:void 0}),Ze=oe.text;let Ye,Ke=[0,0];if(Ze){const xt=Ze.toString(),Et=z.get("text-letter-spacing").evaluate(oe,{},T)*or,st=z.get("text-line-height").evaluate(oe,{},T)*or,mt=bg(xt)?Et:0,Pt=z.get("text-anchor").evaluate(oe,{},T),Bt=z.get("text-variable-anchor");if(!Bt){const Fn=z.get("text-radial-offset").evaluate(oe,{},T);Ke=Fn?Rw(Pt,[Fn*or,jv]):z.get("text-offset").evaluate(oe,{},T).map(Qt=>Qt*or)}let Rt=W?"center":z.get("text-justify").evaluate(oe,{},T);const Ft=z.get("symbol-placement"),En=Ft==="point",Un=Ft==="point"?z.get("text-max-width").evaluate(oe,{},T)*or:0,An=Fn=>{a.allowVerticalPlacement&&Ou(xt)&&($e.vertical=Uv(Ze,n,s,p,ue,Un,st,Pt,Fn,mt,Ke,yo.vertical,!0,Ft,Be,xe))};if(!W&&Bt){const Fn=Rt==="auto"?Bt.map(Ht=>Hv(Ht)):[Rt];let Qt=!1;for(let Ht=0;Ht<Fn.length;Ht++){const Vn=Fn[Ht];if(!$e.horizontal[Vn])if(Qt)$e.horizontal[Vn]=$e.horizontal[0];else{const Kn=Uv(Ze,n,s,p,ue,Un,st,"center",Vn,mt,Ke,yo.horizontal,!1,Ft,Be,xe);Kn&&($e.horizontal[Vn]=Kn,Qt=Kn.positionedLines.length===1)}}An("left")}else{if(Rt==="auto"&&(Rt=Hv(Pt)),En||z.get("text-writing-mode").indexOf("horizontal")>=0||!Ou(xt)){const Fn=Uv(Ze,n,s,p,ue,Un,st,Pt,Rt,mt,Ke,yo.horizontal,!1,Ft,Be,xe);Fn&&($e.horizontal[Rt]=Fn)}An(Ft==="point"?"left":Rt)}}let ut=!1;if(oe.icon&&oe.icon.name){const xt=u[oe.icon.name];xt&&(Ye=eF(p[oe.icon.name],z.get("icon-offset").evaluate(oe,{},T),z.get("icon-anchor").evaluate(oe,{},T)),ut=xt.sdf,a.sdfIcons===void 0?a.sdfIcons=xt.sdf:a.sdfIcons!==xt.sdf&&be("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(xt.pixelRatio!==a.pixelRatio||z.get("icon-rotate").constantOr(1)!==0)&&(a.iconsNeedLinear=!0))}const dt=zw($e.horizontal)||$e.vertical;a.iconsInText||(a.iconsInText=!!dt&&dt.iconsInText),(dt||Ye)&&uF(a,oe,$e,Ye,u,N,Be,0,Ke,ut,_,T,I)}g&&a.generateCollisionDebugBuffers(D,a.collisionBoxArray)}function Hv(a){switch(a){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function uF(a,n,s,u,p,g,_,T,D,I,z,B,N){let W=g.textMaxSize.evaluate(n,{},B);W===void 0&&(W=_);const K=a.layers[0].layout,oe=K.get("icon-offset").evaluate(n,{},B),ue=zw(s.horizontal)||s.vertical,xe=_/24,Be=a.tilePixelRatio*W/24,$e=(st=a.overscaling,a.zoom>18&&st>2&&(st>>=1),Math.max(In/(512*st),1)*K.get("symbol-spacing")),Ze=K.get("text-padding")*a.tilePixelRatio,Ye=K.get("icon-padding")*a.tilePixelRatio,Ke=F(K.get("text-max-angle")),ut=K.get("text-rotation-alignment")==="map"&&K.get("symbol-placement")!=="point",dt=K.get("icon-rotation-alignment")==="map"&&K.get("symbol-placement")!=="point",xt=K.get("symbol-placement"),Et=$e/2;var st;const mt=K.get("icon-text-fit");let Pt;u&&mt!=="none"&&(a.allowVerticalPlacement&&s.vertical&&(Pt=ww(u,s.vertical,mt,K.get("icon-text-fit-padding"),oe,xe)),ue&&(u=ww(u,ue,mt,K.get("icon-text-fit-padding"),oe,xe)));const Bt=(Rt,Ft,En)=>{if(Ft.x<0||Ft.x>=In||Ft.y<0||Ft.y>=In)return;const{x:Un,y:An,z:Fn}=N.projectTilePoint(Ft.x,Ft.y,En),Qt=new Ka(Un,An,Fn,0,void 0);(function(Ht,Vn,Kn,Bi,ui,Oi,Jn,Wn,ni,wi,Ci,Ni,Zi,Qr,Br,ii,xr,eo,er,Yi,fi,hi,Or,br,Ii){const wr=Ht.addToLineVertexArray(Vn,Bi);let dr,Ki,Co,qs,Up,Vp,yM,_M=0,vM=0,xM=0,bM=0,lx=-1,cx=-1;const ba={};let wM=fa(""),ux=0,hx=0;if(ni._unevaluatedLayout.getValue("text-radial-offset")===void 0?[ux,hx]=ni.layout.get("text-offset").evaluate(fi,{},Ii).map(to=>to*or):(ux=ni.layout.get("text-radial-offset").evaluate(fi,{},Ii)*or,hx=jv),Ht.allowVerticalPlacement&&ui.vertical){const to=ui.vertical;if(Br)Vp=$v(to),Wn&&(yM=$v(Wn));else{const no=ni.layout.get("text-rotate").evaluate(fi,{},Ii)+90;Co=$g(wi,Kn,Vn,Ci,Ni,Zi,to,Qr,no,ii),Wn&&(qs=$g(wi,Kn,Vn,Ci,Ni,Zi,Wn,eo,no))}}if(Oi){const to=ni.layout.get("icon-rotate").evaluate(fi,{},Ii),no=ni.layout.get("icon-text-fit")!=="none",Gp=Lw(Oi,to,Or,no),px=Wn?Lw(Wn,to,Or,no):void 0;Ki=$g(wi,Kn,Vn,Ci,Ni,Zi,Oi,eo,to),_M=4*Gp.length;const MM=Ht.iconSizeData;let ec=null;MM.kind==="source"?(ec=[ya*ni.layout.get("icon-size").evaluate(fi,{},Ii)],ec[0]>Vs&&be(`${Ht.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):MM.kind==="composite"&&(ec=[ya*hi.compositeIconSizes[0].evaluate(fi,{},Ii),ya*hi.compositeIconSizes[1].evaluate(fi,{},Ii)],(ec[0]>Vs||ec[1]>Vs)&&be(`${Ht.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),Ht.addSymbols(Ht.icon,Gp,ec,Yi,er,fi,!1,Kn,Vn,wr.lineStartIndex,wr.lineLength,-1,br,Ii),lx=Ht.icon.placedSymbolArray.length-1,px&&(vM=4*px.length,Ht.addSymbols(Ht.icon,px,ec,Yi,er,fi,yo.vertical,Kn,Vn,wr.lineStartIndex,wr.lineLength,-1,br,Ii),cx=Ht.icon.placedSymbolArray.length-1)}for(const to in ui.horizontal){const no=ui.horizontal[to];dr||(wM=fa(no.text),Br?Up=$v(no):dr=$g(wi,Kn,Vn,Ci,Ni,Zi,no,Qr,ni.layout.get("text-rotate").evaluate(fi,{},Ii),ii));const Gp=no.positionedLines.length===1;if(xM+=kw(Ht,Kn,Vn,no,Jn,ni,Br,fi,ii,wr,ui.vertical?yo.horizontal:yo.horizontalOnly,Gp?Object.keys(ui.horizontal):[to],ba,lx,hi,br,Ii),Gp)break}ui.vertical&&(bM+=kw(Ht,Kn,Vn,ui.vertical,Jn,ni,Br,fi,ii,wr,yo.vertical,["vertical"],ba,cx,hi,br,Ii));let Xs=-1;const dx=(to,no)=>to?Math.max(to,no):no;Xs=dx(Up,Xs),Xs=dx(Vp,Xs),Xs=dx(yM,Xs);const jF=Xs>-1?1:0;Ht.glyphOffsetArray.length>=Gs.MAX_GLYPHS&&be("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),fi.sortKey!==void 0&&Ht.addToSortKeyRanges(Ht.symbolInstances.length,fi.sortKey),Ht.symbolInstances.emplaceBack(Kn.x,Kn.y,Kn.z,Vn.x,Vn.y,ba.right>=0?ba.right:-1,ba.center>=0?ba.center:-1,ba.left>=0?ba.left:-1,ba.vertical>=0?ba.vertical:-1,lx,cx,wM,dr!==void 0?dr:Ht.collisionBoxArray.length,dr!==void 0?dr+1:Ht.collisionBoxArray.length,Co!==void 0?Co:Ht.collisionBoxArray.length,Co!==void 0?Co+1:Ht.collisionBoxArray.length,Ki!==void 0?Ki:Ht.collisionBoxArray.length,Ki!==void 0?Ki+1:Ht.collisionBoxArray.length,qs||Ht.collisionBoxArray.length,qs?qs+1:Ht.collisionBoxArray.length,Ci,xM,bM,_M,vM,jF,0,ux,hx,Xs)})(a,Ft,Qt,Rt,s,u,p,Pt,a.layers[0],a.collisionBoxArray,n.index,n.sourceLayerIndex,a.index,Ze,ut,D,0,Ye,dt,oe,n,g,I,z,B)};if(xt==="line")for(const Rt of Dw(n.geometry,0,0,In,In)){const Ft=nF(Rt,$e,Ke,s.vertical||ue,u,24,Be,a.overscaling,In);for(const En of Ft){const Un=ue;Un&&hF(a,Un.text,Et,En)||Bt(Rt,En,B)}}else if(xt==="line-center"){for(const Rt of n.geometry)if(Rt.length>1){const Ft=tF(Rt,Ke,s.vertical||ue,u,24,Be);Ft&&Bt(Rt,Ft,B)}}else if(n.type==="Polygon")for(const Rt of Rv(n.geometry,0)){const Ft=aF(Rt,16);Bt(Rt[0],new Ka(Ft.x,Ft.y,0,0,void 0),B)}else if(n.type==="LineString")for(const Rt of n.geometry)Bt(Rt,new Ka(Rt[0].x,Rt[0].y,0,0,void 0),B);else if(n.type==="Point")for(const Rt of n.geometry)for(const Ft of Rt)Bt([Ft],new Ka(Ft.x,Ft.y,0,0,void 0),B)}const Vs=32640;function kw(a,n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue){const xe=function(Ze,Ye,Ke,ut,dt,xt,Et,st){const mt=[];if(Ye.positionedLines.length===0)return mt;const Pt=ut.layout.get("text-rotate").evaluate(xt,{})*Math.PI/180,Bt=function(An){const Fn=An[0],Qt=An[1],Ht=Fn*Qt;return Ht>0?[Fn,-Qt]:Ht<0?[-Fn,Qt]:Fn===0?[Qt,Fn]:[Qt,-Fn]}(Ke);let Rt=Math.abs(Ye.top-Ye.bottom);for(const An of Ye.positionedLines)Rt-=An.lineOffset;const Ft=Ye.positionedLines.length,En=Rt/Ft;let Un=Ye.top-Ke[1];for(let An=0;An<Ft;++An){const Fn=Ye.positionedLines[An];Un=iF(Ye,En,Un,An);for(const Qt of Fn.positionedGlyphs){if(!Qt.rect)continue;const Ht=Qt.rect||{};let Vn=4,Kn=!0,Bi=1,ui=0;if(Qt.imageName){const hi=Et[Qt.imageName];if(!hi)continue;if(hi.sdf){be("SDF images are not supported in formatted text and will be ignored.");continue}Kn=!1,Bi=hi.pixelRatio,Vn=1/Bi}const Oi=(dt||st)&&Qt.vertical,Jn=Qt.metrics.advance*Qt.scale/2,Wn=Qt.metrics,ni=Qt.rect;if(ni===null)continue;st&&Ye.verticalizable&&(ui=Qt.imageName?Jn-Qt.metrics.width*Qt.scale/2:0);const wi=dt?[Qt.x+Jn,Qt.y]:[0,0];let Ci=[0,0],Ni=[0,0],Zi=!1;dt||(Oi?(Ni=[Qt.x+Jn+Bt[0],Qt.y+Bt[1]-ui],Zi=!0):Ci=[Qt.x+Jn+Ke[0],Qt.y+Ke[1]-ui]);const Qr=ni.w*Qt.scale/(Bi*(Qt.localGlyph?2:1)),Br=ni.h*Qt.scale/(Bi*(Qt.localGlyph?2:1));let ii,xr,eo,er;if(Oi){const hi=Qt.y-Un,Or=new b(-Jn,Jn-hi),br=-Math.PI/2,Ii=new b(...Ni);ii=new b(-Jn+Ci[0],Ci[1]),ii._rotateAround(br,Or)._add(Ii),ii.x+=-hi+Jn,ii.y-=(Wn.left-Vn)*Qt.scale;const wr=Qt.imageName?Wn.advance*Qt.scale:or*Qt.scale,dr=String.fromCharCode(Qt.glyph);Oz(dr)?ii.x+=(1-Vn)*Qt.scale:Nz(dr)?ii.x+=wr-Wn.height*Qt.scale+(-Vn-1)*Qt.scale:ii.x+=Qt.imageName||Wn.width+2*Vn===ni.w&&Wn.height+2*Vn===ni.h?(wr-Br)/2:(wr-(Wn.height+2*Vn)*Qt.scale)/2,xr=new b(ii.x,ii.y-Qr),eo=new b(ii.x+Br,ii.y),er=new b(ii.x+Br,ii.y-Qr)}else{const hi=(Wn.left-Vn)*Qt.scale-Jn+Ci[0],Or=(-Wn.top-Vn)*Qt.scale+Ci[1],br=hi+Qr,Ii=Or+Br;ii=new b(hi,Or),xr=new b(br,Or),eo=new b(hi,Ii),er=new b(br,Ii)}if(Pt){let hi;hi=dt?new b(0,0):Zi?new b(Bt[0],Bt[1]):new b(Ke[0],Ke[1]),ii._rotateAround(Pt,hi),xr._rotateAround(Pt,hi),eo._rotateAround(Pt,hi),er._rotateAround(Pt,hi)}const Yi=new b(0,0),fi=new b(0,0);mt.push({tl:ii,tr:xr,bl:eo,br:er,tex:Ht,writingMode:Ye.writingMode,glyphOffset:wi,sectionIndex:Qt.sectionIndex,isSDF:Kn,pixelOffsetTL:Yi,pixelOffsetBR:fi,minFontScaleX:0,minFontScaleY:0})}}return mt}(0,u,D,g,_,T,p,a.allowVerticalPlacement),Be=a.textSizeData;let $e=null;Be.kind==="source"?($e=[ya*g.layout.get("text-size").evaluate(T,{},ue)],$e[0]>Vs&&be(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):Be.kind==="composite"&&($e=[ya*K.compositeTextSizes[0].evaluate(T,{},ue),ya*K.compositeTextSizes[1].evaluate(T,{},ue)],($e[0]>Vs||$e[1]>Vs)&&be(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),a.addSymbols(a.text,xe,$e,D,_,T,z,n,s,I.lineStartIndex,I.lineLength,W,oe,ue);for(const Ze of B)N[Ze]=a.text.placedSymbolArray.length-1;return 4*xe.length}function zw(a){for(const n in a)return a[n];return null}function $g(a,n,s,u,p,g,_,T,D,I){let z=_.top,B=_.bottom,N=_.left,W=_.right;const K=_.collisionPadding;if(K&&(N-=K[0],z-=K[1],W+=K[2],B+=K[3]),D){const oe=new b(N,z),ue=new b(W,z),xe=new b(N,B),Be=new b(W,B),$e=F(D);let Ze=new b(0,0);I&&(Ze=new b(I[0],I[1])),oe._rotateAround($e,Ze),ue._rotateAround($e,Ze),xe._rotateAround($e,Ze),Be._rotateAround($e,Ze),N=Math.min(oe.x,ue.x,xe.x,Be.x),W=Math.max(oe.x,ue.x,xe.x,Be.x),z=Math.min(oe.y,ue.y,xe.y,Be.y),B=Math.max(oe.y,ue.y,xe.y,Be.y)}return a.emplaceBack(n.x,n.y,n.z,s.x,s.y,N,z,W,B,T,u,p,g),a.length-1}function $v(a){a.collisionPadding&&(a.top-=a.collisionPadding[1],a.bottom+=a.collisionPadding[3]);const n=a.bottom-a.top;return n>0?Math.max(10,n):null}function hF(a,n,s,u){const p=a.compareText;if(n in p){const g=p[n];for(let _=g.length-1;_>=0;_--)if(u.dist(g[_])<s)return!0}else p[n]=[];return p[n].push(u),!1}const dF=Kl.VectorTileFeature.types,pF=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function qg(a,n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe){const ue=z?Math.min(Vs,Math.round(z[0])):0,xe=z?Math.min(Vs,Math.round(z[1])):0;a.emplaceBack(n,s,Math.round(32*_),Math.round(32*T),D,I,(ue<<1)+(B?1:0),xe,16*N,16*W,256*K,256*oe,u,p,g,0)}function qv(a,n,s){a.emplaceBack(n.x,n.y,s),a.emplaceBack(n.x,n.y,s),a.emplaceBack(n.x,n.y,s),a.emplaceBack(n.x,n.y,s)}function fF(a){for(const n of a.sections)if(lv(n.text))return!0;return!1}class Xv{constructor(n){this.layoutVertexArray=new ht,this.indexArray=new qt,this.programConfigurations=n,this.segments=new Ei,this.dynamicLayoutVertexArray=new kt,this.opacityVertexArray=new it,this.placedSymbolArray=new Vo}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(n,s,u,p){this.isEmpty()||(u&&(this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,Lz.members),this.indexBuffer=n.createIndexBuffer(this.indexArray,s),this.dynamicLayoutVertexBuffer=n.createVertexBuffer(this.dynamicLayoutVertexArray,Iz.members,!0),this.opacityVertexBuffer=n.createVertexBuffer(this.opacityVertexArray,pF,!0),this.opacityVertexBuffer.itemSize=1),(u||p)&&this.programConfigurations.upload(n))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}$t(Xv,"SymbolBuffers");class Zv{constructor(n,s,u){this.layoutVertexArray=new n,this.layoutAttributes=s,this.indexArray=new u,this.segments=new Ei,this.collisionVertexArray=new ft,this.collisionVertexArrayExt=new kt}upload(n){this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=n.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=n.createVertexBuffer(this.collisionVertexArray,Rz.members,!0),this.collisionVertexBufferExt=n.createVertexBuffer(this.collisionVertexArrayExt,kz.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}$t(Zv,"CollisionBuffers");class Gs{constructor(n){this.collisionBoxArray=n.collisionBoxArray,this.zoom=n.zoom,this.overscaling=n.overscaling,this.layers=n.layers,this.layerIds=this.layers.map(_=>_.id),this.index=n.index,this.pixelRatio=n.pixelRatio,this.sourceLayerIndex=n.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=ga([]),this.placementViewportMatrix=ga([]);const s=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fv(this.zoom,s["text-size"]),this.iconSizeData=Fv(this.zoom,s["icon-size"]);const u=this.layers[0].layout,p=u.get("symbol-sort-key"),g=u.get("symbol-z-order");this.canOverlap=u.get("text-allow-overlap")||u.get("icon-allow-overlap")||u.get("text-ignore-placement")||u.get("icon-ignore-placement"),this.sortFeaturesByKey=g!=="viewport-y"&&p.constantOr(1)!==void 0,this.sortFeaturesByY=(g==="viewport-y"||g==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=u.get("text-writing-mode").map(_=>yo[_]),this.stateDependentLayerIds=this.layers.filter(_=>_.isStateDependent()).map(_=>_.id),this.sourceID=n.sourceID,this.projection=n.projection}createArrays(){this.text=new Xv(new ql(this.layers,this.zoom,n=>/^text/.test(n))),this.icon=new Xv(new ql(this.layers,this.zoom,n=>/^icon/.test(n))),this.glyphOffsetArray=new Yn,this.lineVertexArray=new Si,this.symbolInstances=new Ti}calculateGlyphDependencies(n,s,u,p,g){for(let _=0;_<n.length;_++)if(s[n.charCodeAt(_)]=!0,p&&g){const T=Dp[n.charAt(_)];T&&(s[T.charCodeAt(0)]=!0)}}populate(n,s,u,p){const g=this.layers[0],_=g.layout,T=_.get("text-font"),D=_.get("text-field"),I=_.get("icon-image"),z=(D.value.kind!=="constant"||D.value.value instanceof Fi&&!D.value.value.isEmpty()||D.value.value.toString().length>0)&&(T.value.kind!=="constant"||T.value.value.length>0),B=I.value.kind!=="constant"||!!I.value.value||Object.keys(I.parameters).length>0,N=_.get("symbol-sort-key");if(this.features=[],!z&&!B)return;const W=s.iconDependencies,K=s.glyphDependencies,oe=s.availableImages,ue=new ci(this.zoom);for(const{feature:xe,id:Be,index:$e,sourceLayerIndex:Ze}of n){const Ye=g._featureFilter.needGeometry,Ke=Xl(xe,Ye);if(!g._featureFilter.filter(ue,Ke,u))continue;let ut,dt;if(Ye||(Ke.geometry=Xa(xe,u,p)),z){const Et=g.getValueAndResolveTokens("text-field",Ke,u,oe),st=Fi.factory(Et);fF(st)&&(this.hasRTLText=!0),(!this.hasRTLText||Gu()==="unavailable"||this.hasRTLText&&qr.isParsed())&&(ut=Bz(st,g,Ke))}if(B){const Et=g.getValueAndResolveTokens("icon-image",Ke,u,oe);dt=Et instanceof Pr?Et:Pr.fromString(Et)}if(!ut&&!dt)continue;const xt=this.sortFeaturesByKey?N.evaluate(Ke,{},u):void 0;if(this.features.push({id:Be,text:ut,icon:dt,index:$e,sourceLayerIndex:Ze,geometry:Ke.geometry,properties:xe.properties,type:dF[xe.type],sortKey:xt}),dt&&(W[dt.name]=!0),ut){const Et=T.evaluate(Ke,{},u).join(","),st=_.get("text-rotation-alignment")==="map"&&_.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(yo.vertical)>=0;for(const mt of ut.sections)if(mt.image)W[mt.image.name]=!0;else{const Pt=Ou(ut.toString()),Bt=mt.fontStack||Et,Rt=K[Bt]=K[Bt]||{};this.calculateGlyphDependencies(mt.text,Rt,st,this.allowVerticalPlacement,Pt)}}}_.get("symbol-placement")==="line"&&(this.features=function(xe){const Be={},$e={},Ze=[];let Ye=0;function Ke(Et){Ze.push(xe[Et]),Ye++}function ut(Et,st,mt){const Pt=$e[Et];return delete $e[Et],$e[st]=Pt,Ze[Pt].geometry[0].pop(),Ze[Pt].geometry[0]=Ze[Pt].geometry[0].concat(mt[0]),Pt}function dt(Et,st,mt){const Pt=Be[st];return delete Be[st],Be[Et]=Pt,Ze[Pt].geometry[0].shift(),Ze[Pt].geometry[0]=mt[0].concat(Ze[Pt].geometry[0]),Pt}function xt(Et,st,mt){const Pt=mt?st[0][st[0].length-1]:st[0][0];return`${Et}:${Pt.x}:${Pt.y}`}for(let Et=0;Et<xe.length;Et++){const st=xe[Et],mt=st.geometry,Pt=st.text?st.text.toString():null;if(!Pt){Ke(Et);continue}const Bt=xt(Pt,mt),Rt=xt(Pt,mt,!0);if(Bt in $e&&Rt in Be&&$e[Bt]!==Be[Rt]){const Ft=dt(Bt,Rt,mt),En=ut(Bt,Rt,Ze[Ft].geometry);delete Be[Bt],delete $e[Rt],$e[xt(Pt,Ze[En].geometry,!0)]=En,Ze[Ft].geometry=null}else Bt in $e?ut(Bt,Rt,mt):Rt in Be?dt(Bt,Rt,mt):(Ke(Et),Be[Bt]=Ye-1,$e[Rt]=Ye-1)}return Ze.filter(Et=>Et.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((xe,Be)=>xe.sortKey-Be.sortKey)}update(n,s,u,p){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(n,s,this.layers,u,p),this.icon.programConfigurations.updatePaintArrays(n,s,this.layers,u,p))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(n){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(n),this.iconCollisionBox.upload(n)),this.text.upload(n,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(n,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(n,s){const u=this.lineVertexArray.length,p=n.segment;if(p!==void 0){let g=n.dist(s[p+1]),_=n.dist(s[p]);const T={};for(let D=p+1;D<s.length;D++)T[D]={x:s[D].x,y:s[D].y,tileUnitDistanceFromAnchor:g},D<s.length-1&&(g+=s[D+1].dist(s[D]));for(let D=p||0;D>=0;D--)T[D]={x:s[D].x,y:s[D].y,tileUnitDistanceFromAnchor:_},D>0&&(_+=s[D-1].dist(s[D]));for(let D=0;D<s.length;D++){const I=T[D];this.lineVertexArray.emplaceBack(I.x,I.y,I.tileUnitDistanceFromAnchor)}}return{lineStartIndex:u,lineLength:this.lineVertexArray.length-u}}addSymbols(n,s,u,p,g,_,T,D,I,z,B,N,W,K){const oe=n.indexArray,ue=n.layoutVertexArray,xe=n.segments.prepareSegment(4*s.length,ue,oe,this.canOverlap?_.sortKey:void 0),Be=this.glyphOffsetArray.length,$e=xe.vertexLength,Ze=this.allowVerticalPlacement&&T===yo.vertical?Math.PI/2:0,Ye=_.text&&_.text.sections;for(let Ke=0;Ke<s.length;Ke++){const{tl:ut,tr:dt,bl:xt,br:Et,tex:st,pixelOffsetTL:mt,pixelOffsetBR:Pt,minFontScaleX:Bt,minFontScaleY:Rt,glyphOffset:Ft,isSDF:En,sectionIndex:Un}=s[Ke],An=xe.vertexLength,Fn=Ft[1];qg(ue,D.x,D.y,D.z,I.x,I.y,ut.x,Fn+ut.y,st.x,st.y,u,En,mt.x,mt.y,Bt,Rt),qg(ue,D.x,D.y,D.z,I.x,I.y,dt.x,Fn+dt.y,st.x+st.w,st.y,u,En,Pt.x,mt.y,Bt,Rt),qg(ue,D.x,D.y,D.z,I.x,I.y,xt.x,Fn+xt.y,st.x,st.y+st.h,u,En,mt.x,Pt.y,Bt,Rt),qg(ue,D.x,D.y,D.z,I.x,I.y,Et.x,Fn+Et.y,st.x+st.w,st.y+st.h,u,En,Pt.x,Pt.y,Bt,Rt),qv(n.dynamicLayoutVertexArray,D,Ze),oe.emplaceBack(An,An+1,An+2),oe.emplaceBack(An+1,An+2,An+3),xe.vertexLength+=4,xe.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(Ft[0]),Ke!==s.length-1&&Un===s[Ke+1].sectionIndex||n.programConfigurations.populatePaintArrays(ue.length,_,_.index,{},W,K,Ye&&Ye[Un])}n.placedSymbolArray.emplaceBack(D.x,D.y,D.z,I.x,I.y,Be,this.glyphOffsetArray.length-Be,$e,z,B,I.segment,u?u[0]:0,u?u[1]:0,p[0],p[1],T,0,!1,0,N,0)}_commitLayoutVertex(n,s,u,p,g,_,T){n.emplaceBack(s,u,p,g,_,Math.round(T.x),Math.round(T.y))}_addCollisionDebugVertices(n,s,u,p,g,_,T){const D=u.segments.prepareSegment(4,u.layoutVertexArray,u.indexArray),I=D.vertexLength,z=T.tileAnchorX,B=T.tileAnchorY;for(let W=0;W<4;W++)u.collisionVertexArray.emplaceBack(0,0,0,0);u.collisionVertexArrayExt.emplaceBack(s,-n.padding,-n.padding),u.collisionVertexArrayExt.emplaceBack(s,n.padding,-n.padding),u.collisionVertexArrayExt.emplaceBack(s,n.padding,n.padding),u.collisionVertexArrayExt.emplaceBack(s,-n.padding,n.padding),this._commitLayoutVertex(u.layoutVertexArray,p,g,_,z,B,new b(n.x1,n.y1)),this._commitLayoutVertex(u.layoutVertexArray,p,g,_,z,B,new b(n.x2,n.y1)),this._commitLayoutVertex(u.layoutVertexArray,p,g,_,z,B,new b(n.x2,n.y2)),this._commitLayoutVertex(u.layoutVertexArray,p,g,_,z,B,new b(n.x1,n.y2)),D.vertexLength+=4;const N=u.indexArray;N.emplaceBack(I,I+1),N.emplaceBack(I+1,I+2),N.emplaceBack(I+2,I+3),N.emplaceBack(I+3,I),D.primitiveLength+=4}_addTextDebugCollisionBoxes(n,s,u,p,g,_){for(let T=p;T<g;T++){const D=u.get(T),I=this.getSymbolInstanceTextSize(n,_,s,T);this._addCollisionDebugVertices(D,I,this.textCollisionBox,D.projectedAnchorX,D.projectedAnchorY,D.projectedAnchorZ,_)}}_addIconDebugCollisionBoxes(n,s,u,p,g,_){for(let T=p;T<g;T++){const D=u.get(T),I=this.getSymbolInstanceIconSize(n,s,T);this._addCollisionDebugVertices(D,I,this.iconCollisionBox,D.projectedAnchorX,D.projectedAnchorY,D.projectedAnchorZ,_)}}generateCollisionDebugBuffers(n,s){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Zv(St,cw.members,Mn),this.iconCollisionBox=new Zv(St,cw.members,Mn);const u=Ju(this.iconSizeData,n),p=Ju(this.textSizeData,n);for(let g=0;g<this.symbolInstances.length;g++){const _=this.symbolInstances.get(g);this._addTextDebugCollisionBoxes(p,n,s,_.textBoxStartIndex,_.textBoxEndIndex,_),this._addTextDebugCollisionBoxes(p,n,s,_.verticalTextBoxStartIndex,_.verticalTextBoxEndIndex,_),this._addIconDebugCollisionBoxes(u,n,s,_.iconBoxStartIndex,_.iconBoxEndIndex,_),this._addIconDebugCollisionBoxes(u,n,s,_.verticalIconBoxStartIndex,_.verticalIconBoxEndIndex,_)}}getSymbolInstanceTextSize(n,s,u,p){const g=this.text.placedSymbolArray.get(s.rightJustifiedTextSymbolIndex>=0?s.rightJustifiedTextSymbolIndex:s.centerJustifiedTextSymbolIndex>=0?s.centerJustifiedTextSymbolIndex:s.leftJustifiedTextSymbolIndex>=0?s.leftJustifiedTextSymbolIndex:s.verticalPlacedTextSymbolIndex>=0?s.verticalPlacedTextSymbolIndex:p),_=Ug(this.textSizeData,n,g)/or;return this.tilePixelRatio*_}getSymbolInstanceIconSize(n,s,u){const p=this.icon.placedSymbolArray.get(u),g=Ug(this.iconSizeData,n,p);return this.tilePixelRatio*g}_commitDebugCollisionVertexUpdate(n,s,u){n.emplaceBack(s,-u,-u),n.emplaceBack(s,u,-u),n.emplaceBack(s,u,u),n.emplaceBack(s,-u,u)}_updateTextDebugCollisionBoxes(n,s,u,p,g,_){for(let T=p;T<g;T++){const D=u.get(T),I=this.getSymbolInstanceTextSize(n,_,s,T);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,I,D.padding)}}_updateIconDebugCollisionBoxes(n,s,u,p,g){for(let _=p;_<g;_++){const T=u.get(_),D=this.getSymbolInstanceIconSize(n,s,_);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,D,T.padding)}}updateCollisionDebugBuffers(n,s){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const u=Ju(this.iconSizeData,n),p=Ju(this.textSizeData,n);for(let g=0;g<this.symbolInstances.length;g++){const _=this.symbolInstances.get(g);this._updateTextDebugCollisionBoxes(p,n,s,_.textBoxStartIndex,_.textBoxEndIndex,_),this._updateTextDebugCollisionBoxes(p,n,s,_.verticalTextBoxStartIndex,_.verticalTextBoxEndIndex,_),this._updateIconDebugCollisionBoxes(u,n,s,_.iconBoxStartIndex,_.iconBoxEndIndex),this._updateIconDebugCollisionBoxes(u,n,s,_.verticalIconBoxStartIndex,_.verticalIconBoxEndIndex)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(n,s,u,p,g,_,T,D,I){const z={};for(let B=s;B<u;B++){const N=n.get(B);z.textBox={x1:N.x1,y1:N.y1,x2:N.x2,y2:N.y2,padding:N.padding,projectedAnchorX:N.projectedAnchorX,projectedAnchorY:N.projectedAnchorY,projectedAnchorZ:N.projectedAnchorZ,tileAnchorX:N.tileAnchorX,tileAnchorY:N.tileAnchorY},z.textFeatureIndex=N.featureIndex;break}for(let B=p;B<g;B++){const N=n.get(B);z.verticalTextBox={x1:N.x1,y1:N.y1,x2:N.x2,y2:N.y2,padding:N.padding,projectedAnchorX:N.projectedAnchorX,projectedAnchorY:N.projectedAnchorY,projectedAnchorZ:N.projectedAnchorZ,tileAnchorX:N.tileAnchorX,tileAnchorY:N.tileAnchorY},z.verticalTextFeatureIndex=N.featureIndex;break}for(let B=_;B<T;B++){const N=n.get(B);z.iconBox={x1:N.x1,y1:N.y1,x2:N.x2,y2:N.y2,padding:N.padding,projectedAnchorX:N.projectedAnchorX,projectedAnchorY:N.projectedAnchorY,projectedAnchorZ:N.projectedAnchorZ,tileAnchorX:N.tileAnchorX,tileAnchorY:N.tileAnchorY},z.iconFeatureIndex=N.featureIndex;break}for(let B=D;B<I;B++){const N=n.get(B);z.verticalIconBox={x1:N.x1,y1:N.y1,x2:N.x2,y2:N.y2,padding:N.padding,projectedAnchorX:N.projectedAnchorX,projectedAnchorY:N.projectedAnchorY,projectedAnchorZ:N.projectedAnchorZ,tileAnchorX:N.tileAnchorX,tileAnchorY:N.tileAnchorY},z.verticalIconFeatureIndex=N.featureIndex;break}return z}deserializeCollisionBoxes(n){this.collisionArrays=[];for(let s=0;s<this.symbolInstances.length;s++){const u=this.symbolInstances.get(s);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(n,u.textBoxStartIndex,u.textBoxEndIndex,u.verticalTextBoxStartIndex,u.verticalTextBoxEndIndex,u.iconBoxStartIndex,u.iconBoxEndIndex,u.verticalIconBoxStartIndex,u.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(n,s){const u=n.placedSymbolArray.get(s),p=u.vertexStartIndex+4*u.numGlyphs;for(let g=u.vertexStartIndex;g<p;g+=4)n.indexArray.emplaceBack(g,g+1,g+2),n.indexArray.emplaceBack(g+1,g+2,g+3)}getSortedSymbolIndexes(n){if(this.sortedAngle===n&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const s=Math.sin(n),u=Math.cos(n),p=[],g=[],_=[];for(let T=0;T<this.symbolInstances.length;++T){_.push(T);const D=this.symbolInstances.get(T);p.push(0|Math.round(s*D.tileAnchorX+u*D.tileAnchorY)),g.push(D.featureIndex)}return _.sort((T,D)=>p[T]-p[D]||g[D]-g[T]),_}addToSortKeyRanges(n,s){const u=this.sortKeyRanges[this.sortKeyRanges.length-1];u&&u.sortKey===s?u.symbolInstanceEnd=n+1:this.sortKeyRanges.push({sortKey:s,symbolInstanceStart:n,symbolInstanceEnd:n+1})}sortFeatures(n){if(this.sortFeaturesByY&&this.sortedAngle!==n&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(n),this.sortedAngle=n,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const s of this.symbolInstanceIndexes){const u=this.symbolInstances.get(s);this.featureSortOrder.push(u.featureIndex),[u.rightJustifiedTextSymbolIndex,u.centerJustifiedTextSymbolIndex,u.leftJustifiedTextSymbolIndex].forEach((p,g,_)=>{p>=0&&_.indexOf(p)===g&&this.addIndicesForPlacedSymbol(this.text,p)}),u.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,u.verticalPlacedTextSymbolIndex),u.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,u.placedIconSymbolIndex),u.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,u.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}$t(Gs,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Gs.MAX_GLYPHS=65535,Gs.addDynamicAttributes=qv;const mF=new Z({"symbol-placement":new S(Te.layout_symbol["symbol-placement"]),"symbol-spacing":new S(Te.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new S(Te.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new k(Te.layout_symbol["symbol-sort-key"]),"symbol-z-order":new S(Te.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new S(Te.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new S(Te.layout_symbol["icon-ignore-placement"]),"icon-optional":new S(Te.layout_symbol["icon-optional"]),"icon-rotation-alignment":new S(Te.layout_symbol["icon-rotation-alignment"]),"icon-size":new k(Te.layout_symbol["icon-size"]),"icon-text-fit":new S(Te.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new S(Te.layout_symbol["icon-text-fit-padding"]),"icon-image":new k(Te.layout_symbol["icon-image"]),"icon-rotate":new k(Te.layout_symbol["icon-rotate"]),"icon-padding":new S(Te.layout_symbol["icon-padding"]),"icon-keep-upright":new S(Te.layout_symbol["icon-keep-upright"]),"icon-offset":new k(Te.layout_symbol["icon-offset"]),"icon-anchor":new k(Te.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new S(Te.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new S(Te.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new S(Te.layout_symbol["text-rotation-alignment"]),"text-field":new k(Te.layout_symbol["text-field"]),"text-font":new k(Te.layout_symbol["text-font"]),"text-size":new k(Te.layout_symbol["text-size"]),"text-max-width":new k(Te.layout_symbol["text-max-width"]),"text-line-height":new k(Te.layout_symbol["text-line-height"]),"text-letter-spacing":new k(Te.layout_symbol["text-letter-spacing"]),"text-justify":new k(Te.layout_symbol["text-justify"]),"text-radial-offset":new k(Te.layout_symbol["text-radial-offset"]),"text-variable-anchor":new S(Te.layout_symbol["text-variable-anchor"]),"text-anchor":new k(Te.layout_symbol["text-anchor"]),"text-max-angle":new S(Te.layout_symbol["text-max-angle"]),"text-writing-mode":new S(Te.layout_symbol["text-writing-mode"]),"text-rotate":new k(Te.layout_symbol["text-rotate"]),"text-padding":new S(Te.layout_symbol["text-padding"]),"text-keep-upright":new S(Te.layout_symbol["text-keep-upright"]),"text-transform":new k(Te.layout_symbol["text-transform"]),"text-offset":new k(Te.layout_symbol["text-offset"]),"text-allow-overlap":new S(Te.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new S(Te.layout_symbol["text-ignore-placement"]),"text-optional":new S(Te.layout_symbol["text-optional"])});var Yv={paint:new Z({"icon-opacity":new k(Te.paint_symbol["icon-opacity"]),"icon-color":new k(Te.paint_symbol["icon-color"]),"icon-halo-color":new k(Te.paint_symbol["icon-halo-color"]),"icon-halo-width":new k(Te.paint_symbol["icon-halo-width"]),"icon-halo-blur":new k(Te.paint_symbol["icon-halo-blur"]),"icon-translate":new S(Te.paint_symbol["icon-translate"]),"icon-translate-anchor":new S(Te.paint_symbol["icon-translate-anchor"]),"text-opacity":new k(Te.paint_symbol["text-opacity"]),"text-color":new k(Te.paint_symbol["text-color"],{runtimeType:mn,getOverride:a=>a.textColor,hasOverride:a=>!!a.textColor}),"text-halo-color":new k(Te.paint_symbol["text-halo-color"]),"text-halo-width":new k(Te.paint_symbol["text-halo-width"]),"text-halo-blur":new k(Te.paint_symbol["text-halo-blur"]),"text-translate":new S(Te.paint_symbol["text-translate"]),"text-translate-anchor":new S(Te.paint_symbol["text-translate-anchor"])}),layout:mF};class Fw{constructor(n){this.type=n.property.overrides?n.property.overrides.runtimeType:Ln,this.defaultValue=n}evaluate(n){if(n.formattedSection){const s=this.defaultValue.property.overrides;if(s&&s.hasOverride(n.formattedSection))return s.getOverride(n.formattedSection)}return n.feature&&n.featureState?this.defaultValue.evaluate(n.feature,n.featureState):this.defaultValue.property.specification.default}eachChild(n){this.defaultValue.isConstant()||n(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}$t(Fw,"FormatSectionOverride",{omit:["defaultValue"]});class Xg extends Wo{constructor(n){super(n,Yv)}recalculate(n,s){super.recalculate(n,s),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const u=this.layout.get("text-writing-mode");if(u){const p=[];for(const g of u)p.indexOf(g)<0&&p.push(g);this.layout._values["text-writing-mode"]=p}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(n,s,u,p){const g=this.layout.get(n).evaluate(s,{},u,p),_=this._unevaluatedLayout._values[n];return _.isDataDriven()||Ds(_.value)||!g?g:function(T,D){return D.replace(/{([^{}]+)}/g,(I,z)=>z in T?String(T[z]):"")}(s.properties,g)}createBucket(n){return new Gs(n)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const n of Yv.paint.overridableProperties){if(!Xg.hasPaintOverride(this.layout,n))continue;const s=this.paint.get(n),u=new Fw(s),p=new Du(u,s.property.specification);let g=null;g=s.value.kind==="constant"||s.value.kind==="source"?new Hd("source",p):new $d("composite",p,s.value.zoomStops,s.value._interpolationType),this.paint._values[n]=new E(s.property,g,s.parameters)}}_handleOverridablePaintPropertyUpdate(n,s,u){return!(!this.layout||s.isDataDriven()||u.isDataDriven())&&Xg.hasPaintOverride(this.layout,n)}static hasPaintOverride(n,s){const u=n.get("text-field"),p=Yv.paint.properties[s];let g=!1;const _=T=>{for(const D of T)if(p.overrides&&p.overrides.hasOverride(D))return void(g=!0)};if(u.value.kind==="constant"&&u.value.value instanceof Fi)_(u.value.value.sections);else if(u.value.kind==="source"){const T=I=>{g||(I instanceof Fo&&Pi(I.value)===Dr?_(I.value.sections):I instanceof Ms?_(I.sections):I.eachChild(T))},D=u.value;D._styleExpression&&T(D._styleExpression.expression)}return g}getProgramConfiguration(n){return new Bs(this,n)}}var gF={paint:new Z({"background-color":new S(Te.paint_background["background-color"]),"background-pattern":new U(Te.paint_background["background-pattern"]),"background-opacity":new S(Te.paint_background["background-opacity"])})},yF={paint:new Z({"raster-opacity":new S(Te.paint_raster["raster-opacity"]),"raster-hue-rotate":new S(Te.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new S(Te.paint_raster["raster-brightness-min"]),"raster-brightness-max":new S(Te.paint_raster["raster-brightness-max"]),"raster-saturation":new S(Te.paint_raster["raster-saturation"]),"raster-contrast":new S(Te.paint_raster["raster-contrast"]),"raster-resampling":new S(Te.paint_raster["raster-resampling"]),"raster-fade-duration":new S(Te.paint_raster["raster-fade-duration"])})};class _F extends Wo{constructor(n){super(n,{}),this.implementation=n}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(n){this.implementation.onAdd&&this.implementation.onAdd(n,n.painter.context.gl)}onRemove(n){this.implementation.onRemove&&this.implementation.onRemove(n,n.painter.context.gl)}}var vF={paint:new Z({"sky-type":new S(Te.paint_sky["sky-type"]),"sky-atmosphere-sun":new S(Te.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new S(Te.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new S(Te.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new S(Te.paint_sky["sky-gradient-radius"]),"sky-gradient":new G(Te.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new S(Te.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new S(Te.paint_sky["sky-atmosphere-color"]),"sky-opacity":new S(Te.paint_sky["sky-opacity"])})};function Kv(a,n,s){const u=[0,0,1],p=Gb([]);return function(g,_,T){T*=.5;var D=_[0],I=_[1],z=_[2],B=_[3],N=Math.sin(T),W=Math.cos(T);g[0]=D*W-z*N,g[1]=I*W+B*N,g[2]=z*W+D*N,g[3]=B*W-I*N}(p,p,s?-F(a)+Math.PI:F(a)),Wb(p,p,-F(n)),Ub(u,u,p),yp(u,u)}const xF={circle:class extends Wo{constructor(a){super(a,Nk)}createBucket(a){return new gv(a)}queryRadius(a){const n=a;return qu("circle-radius",this,n)+qu("circle-stroke-width",this,n)+Lg(this.paint.get("circle-translate"))}queryIntersectsFeature(a,n,s,u,p,g,_,T){const D=Ib(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),g.angle,a.pixelToTileUnitsFactor),I=this.paint.get("circle-radius").evaluate(n,s)+this.paint.get("circle-stroke-width").evaluate(n,s);return jb(a,u,g,_,T,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",D,I)}getProgramIds(){return["circle"]}getProgramConfiguration(a){return new Bs(this,a)}},heatmap:class extends Wo{createBucket(a){return new $b(a)}constructor(a){super(a,$k),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(a){a==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Pv({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(a){return qu("heatmap-radius",this,a)}queryIntersectsFeature(a,n,s,u,p,g,_,T){const D=this.paint.get("heatmap-radius").evaluate(n,s);return jb(a,u,g,_,T,!0,!0,new b(0,0),D)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(a){return new Bs(this,a)}},hillshade:class extends Wo{constructor(a){super(a,qk)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends Wo{constructor(a){super(a,uz)}getProgramIds(){const a=this.paint.get("fill-pattern"),n=a&&a.constantOr(1),s=[n?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&s.push(n&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),s}getProgramConfiguration(a){return new Bs(this,a)}recalculate(a,n){super.recalculate(a,n);const s=this.paint._values["fill-outline-color"];s.value.kind==="constant"&&s.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(a){return new Bg(a)}queryRadius(){return Lg(this.paint.get("fill-translate"))}queryIntersectsFeature(a,n,s,u,p,g){return!a.queryGeometry.isAboveHorizon&&Ab(Lb(a.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),g.angle,a.pixelToTileUnitsFactor),u)}isTileClipped(){return!0}},"fill-extrusion":class extends Wo{constructor(a){super(a,wz)}createBucket(a){return new Cp(a)}queryRadius(){return Lg(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(a){return new Bs(this,a)}queryIntersectsFeature(a,n,s,u,p,g,_,T,D){const I=Ib(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),g.angle,a.pixelToTileUnitsFactor),z=this.paint.get("fill-extrusion-height").evaluate(n,s),B=this.paint.get("fill-extrusion-base").evaluate(n,s),N=[0,0],W=T&&g.elevation,K=g.elevation?g.elevation.exaggeration():1,oe=a.tile.getBucket(this);if(W&&oe instanceof Cp){const Be=oe.centroidVertexArray,$e=D+1;if($e<Be.length){const Ze=Be.get($e);N[0]=Ze.a_centroid_pos0,N[1]=Ze.a_centroid_pos1}}if(N[0]===0&&N[1]===1)return!1;const ue=function(Be,$e,Ze,Ye,Ke,ut,dt,xt,Et){return ut?function(st,mt,Pt,Bt,Rt,Ft,En,Un,An){const Fn=[],Qt=[],Ht=[0,0,0,1];for(const Vn of st){const Kn=[],Bi=[];for(const ui of Vn){const Oi=ui.x+Bt.x,Jn=ui.y+Bt.y,Wn=Mz(Oi,Jn,mt,Pt,Ft,En,Un,An);Ht[0]=Oi,Ht[1]=Jn,Ht[2]=Wn.base,Ht[3]=1,Zu(Ht,Ht,Rt),Ht[3]=Math.max(Ht[3],1e-5);const ni=ow([Ht[0]/Ht[3],Ht[1]/Ht[3],Ht[2]/Ht[3]]);Ht[0]=Oi,Ht[1]=Jn,Ht[2]=Wn.top,Ht[3]=1,Zu(Ht,Ht,Rt),Ht[3]=Math.max(Ht[3],1e-5);const wi=ow([Ht[0]/Ht[3],Ht[1]/Ht[3],Ht[2]/Ht[3]]);Kn.push(ni),Bi.push(wi)}Fn.push(Kn),Qt.push(Bi)}return[Fn,Qt]}(Be,$e,Ze,Ye,Ke,ut,dt,xt,Et):function(st,mt,Pt,Bt,Rt){const Ft=[],En=[],Un=Rt[8]*mt,An=Rt[9]*mt,Fn=Rt[10]*mt,Qt=Rt[11]*mt,Ht=Rt[8]*Pt,Vn=Rt[9]*Pt,Kn=Rt[10]*Pt,Bi=Rt[11]*Pt;for(const ui of st){const Oi=[],Jn=[];for(const Wn of ui){const ni=Wn.x+Bt.x,wi=Wn.y+Bt.y,Ci=Rt[0]*ni+Rt[4]*wi+Rt[12],Ni=Rt[1]*ni+Rt[5]*wi+Rt[13],Zi=Rt[2]*ni+Rt[6]*wi+Rt[14],Qr=Rt[3]*ni+Rt[7]*wi+Rt[15],Br=Ci+Un,ii=Ni+An,xr=Zi+Fn,eo=Math.max(Qr+Qt,1e-5),er=Ci+Ht,Yi=Ni+Vn,fi=Zi+Kn,hi=Math.max(Qr+Bi,1e-5),Or=new b(Br/eo,ii/eo);Or.z=xr/eo,Oi.push(Or);const br=new b(er/hi,Yi/hi);br.z=fi/hi,Jn.push(br)}Ft.push(Oi),En.push(Jn)}return[Ft,En]}(Be,$e,Ze,Ye,Ke)}(u,B,z,I,_,W?T:null,N,K,g.center.lat),xe=a.queryGeometry;return function(Be,$e,Ze){let Ye=1/0;Ab(Ze,$e)&&(Ye=rw(Ze,$e[0]));for(let Ke=0;Ke<$e.length;Ke++){const ut=$e[Ke],dt=Be[Ke];for(let xt=0;xt<ut.length-1;xt++){const Et=ut[xt],st=[Et,ut[xt+1],dt[xt+1],dt[xt],Et];Cb(Ze,st)&&(Ye=Math.min(Ye,rw(Ze,st)))}}return Ye!==1/0&&Ye}(ue[0],ue[1],xe.isPointQuery()?xe.screenBounds:xe.screenGeometry)}},line:class extends Wo{constructor(a){super(a,aw),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(a){if(a==="line-gradient"){const n=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=n._styleExpression&&n._styleExpression.expression instanceof El,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(a,n){super.recalculate(a,n),this.paint._values["line-floorwidth"]=sw.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,a)}createBucket(a){return new Ng(a)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getProgramConfiguration(a){return new Bs(this,a)}queryRadius(a){const n=a,s=lw(qu("line-width",this,n),qu("line-gap-width",this,n)),u=qu("line-offset",this,n);return s/2+Math.abs(u)+Lg(this.paint.get("line-translate"))}queryIntersectsFeature(a,n,s,u,p,g){if(a.queryGeometry.isAboveHorizon)return!1;const _=Lb(a.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),g.angle,a.pixelToTileUnitsFactor),T=a.pixelToTileUnitsFactor/2*lw(this.paint.get("line-width").evaluate(n,s),this.paint.get("line-gap-width").evaluate(n,s)),D=this.paint.get("line-offset").evaluate(n,s);return D&&(u=function(I,z){const B=[],N=new b(0,0);for(let W=0;W<I.length;W++){const K=I[W],oe=[];for(let ue=0;ue<K.length;ue++){const xe=K[ue-1],Be=K[ue],$e=K[ue+1],Ze=ue===0?N:Be.sub(xe)._unit()._perp(),Ye=ue===K.length-1?N:$e.sub(Be)._unit()._perp(),Ke=Ze._add(Ye)._unit();Ke._mult(1/(Ke.x*Ye.x+Ke.y*Ye.y)),oe.push(Ke._mult(z)._add(Be))}B.push(oe)}return B}(u,D*a.pixelToTileUnitsFactor)),function(I,z,B){for(let N=0;N<z.length;N++){const W=z[N];if(I.length>=3){for(let K=0;K<W.length;K++)if($u(I,W[K]))return!0}if(zk(I,W,B))return!0}return!1}(_,u,T)}isTileClipped(){return!0}},symbol:Xg,background:class extends Wo{constructor(a){super(a,gF)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends Wo{constructor(a){super(a,yF)}getProgramIds(){return["raster"]}},sky:class extends Wo{constructor(a){super(a,vF),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(a){a==="sky-gradient"?this._updateColorRamp():a!=="sky-atmosphere-sun"&&a!=="sky-atmosphere-halo-color"&&a!=="sky-atmosphere-color"&&a!=="sky-atmosphere-sun-intensity"||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=Pv({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(a){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const n=a.style.light.properties.get("position");return this._lightPosition.azimuthal!==n.azimuthal||this._lightPosition.polar!==n.polar}return!1}getCenter(a,n){if(this.paint.get("sky-type")==="atmosphere"){const u=this.paint.get("sky-atmosphere-sun"),p=!u,g=a.style.light,_=g.properties.get("position");return p&&g.properties.get("anchor")==="viewport"&&be("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),p?Kv(_.azimuthal,90-_.polar,n):Kv(u[0],90-u[1],n)}const s=this.paint.get("sky-gradient-center");return Kv(s[0],90-s[1],n)}is3D(){return!1}isSky(){return!0}markSkyboxValid(a){this._skyboxInvalidated=!1,this._lightPosition=a.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const a=this.paint.get("sky-type");return a==="atmosphere"?["skyboxCapture","skybox"]:a==="gradient"?["skyboxGradient"]:null}}};class Ip{constructor(n,s,u,p){this.context=n,this.format=u,this.texture=n.gl.createTexture(),this.update(s,p)}update(n,s,u){const{width:p,height:g}=n,{context:_}=this,{gl:T}=_,{HTMLImageElement:D,HTMLCanvasElement:I,HTMLVideoElement:z,ImageData:B,ImageBitmap:N}=L;if(T.bindTexture(T.TEXTURE_2D,this.texture),_.pixelStoreUnpackFlipY.set(!1),_.pixelStoreUnpack.set(1),_.pixelStoreUnpackPremultiplyAlpha.set(this.format===T.RGBA&&(!s||s.premultiply!==!1)),u||this.size&&this.size[0]===p&&this.size[1]===g){const{x:W,y:K}=u||{x:0,y:0};n instanceof D||n instanceof I||n instanceof z||n instanceof B||N&&n instanceof N?T.texSubImage2D(T.TEXTURE_2D,0,W,K,T.RGBA,T.UNSIGNED_BYTE,n):T.texSubImage2D(T.TEXTURE_2D,0,W,K,p,g,T.RGBA,T.UNSIGNED_BYTE,n.data)}else this.size=[p,g],n instanceof D||n instanceof I||n instanceof z||n instanceof B||N&&n instanceof N?T.texImage2D(T.TEXTURE_2D,0,this.format,this.format,T.UNSIGNED_BYTE,n):T.texImage2D(T.TEXTURE_2D,0,this.format,p,g,0,this.format,T.UNSIGNED_BYTE,n.data);this.useMipmap=!!(s&&s.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&T.generateMipmap(T.TEXTURE_2D)}bind(n,s){const{context:u}=this,{gl:p}=u;p.bindTexture(p.TEXTURE_2D,this.texture),n!==this.filter&&(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,n),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,this.useMipmap?n===p.NEAREST?p.NEAREST_MIPMAP_NEAREST:p.LINEAR_MIPMAP_NEAREST:n),this.filter=n),s!==this.wrap&&(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,s),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,s),this.wrap=s)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:n}=this.context;n.deleteTexture(this.texture),this.texture=null}}class Jv{constructor(n,s){this.width=n,this.height=s,this.nextRow=0,this.image=new Za({width:n,height:s}),this.positions={},this.uploaded=!1}getDash(n,s){const u=this.getKey(n,s);return this.positions[u]}trim(){const n=this.width,s=this.height=He(this.nextRow);this.image.resize({width:n,height:s})}getKey(n,s){return n.join(",")+s}getDashRanges(n,s,u){const p=[];let g=n.length%2==1?-n[n.length-1]*u:0,_=n[0]*u,T=!0;p.push({left:g,right:_,isDash:T,zeroLength:n[0]===0});let D=n[0];for(let I=1;I<n.length;I++){T=!T;const z=n[I];g=D*u,D+=z,_=D*u,p.push({left:g,right:_,isDash:T,zeroLength:z===0})}return p}addRoundDash(n,s,u){const p=s/2;for(let g=-u;g<=u;g++){const _=this.width*(this.nextRow+u+g);let T=0,D=n[T];for(let I=0;I<this.width;I++){I/D.right>1&&(D=n[++T]);const z=Math.abs(I-D.left),B=Math.abs(I-D.right),N=Math.min(z,B);let W;const K=g/u*(p+1);if(D.isDash){const oe=p-Math.abs(K);W=Math.sqrt(N*N+oe*oe)}else W=p-Math.sqrt(N*N+K*K);this.image.data[_+I]=Math.max(0,Math.min(255,W+128))}}}addRegularDash(n,s){for(let D=n.length-1;D>=0;--D){const I=n[D],z=n[D+1];I.zeroLength?n.splice(D,1):z&&z.isDash===I.isDash&&(z.left=I.left,n.splice(D,1))}const u=n[0],p=n[n.length-1];u.isDash===p.isDash&&(u.left=p.left-this.width,p.right=u.right+this.width);const g=this.width*this.nextRow;let _=0,T=n[_];for(let D=0;D<this.width;D++){D/T.right>1&&(T=n[++_]);const I=Math.abs(D-T.left),z=Math.abs(D-T.right),B=Math.min(I,z);this.image.data[g+D]=Math.max(0,Math.min(255,(T.isDash?B:-B)+s+128))}}addDash(n,s){const u=this.getKey(n,s);if(this.positions[u])return this.positions[u];const p=s==="round",g=p?7:0,_=2*g+1;if(this.nextRow+_>this.height)return be("LineAtlas out of space"),null;n.length===0&&n.push(1);let T=0;for(let z=0;z<n.length;z++)n[z]<0&&(be("Negative value is found in line dasharray, replacing values with 0"),n[z]=0),T+=n[z];if(T!==0){const z=this.width/T,B=this.getDashRanges(n,this.width,z);p?this.addRoundDash(B,z,g):this.addRegularDash(B,s==="square"?.5*z:0)}const D=this.nextRow+g;this.nextRow+=_;const I={tl:[D,g],br:[T,0]};return this.positions[u]=I,I}}$t(Jv,"LineAtlas");class bF{constructor(n){this._callback=n,this._triggered=!1,typeof MessageChannel!="undefined"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}const wF=L.performance;function Bw(a){const n=a?a.url.toString():void 0;return wF.getEntriesByName(n)}class MF{constructor(){this.tasks={},this.taskQueue=[],At(["process"],this),this.invoker=new bF(this.process),this.nextId=0}add(n,s){const u=this.nextId++,p=function({type:g,isSymbolTile:_,zoom:T}){return T=T||0,g==="message"?0:g!=="maybePrepare"||_?g!=="parseTile"||_?g==="parseTile"&&_?300-T:g==="maybePrepare"&&_?400-T:500:200-T:100-T}(s);if(p===0){ke();try{n()}finally{}return{cancel:()=>{}}}return this.tasks[u]={fn:n,metadata:s,priority:p,id:u},this.taskQueue.push(u),this.invoker.trigger(),{cancel:()=>{delete this.tasks[u]}}}process(){ke();try{if(this.taskQueue=this.taskQueue.filter(u=>!!this.tasks[u]),!this.taskQueue.length)return;const n=this.pick();if(n===null)return;const s=this.tasks[n];if(delete this.tasks[n],this.taskQueue.length&&this.invoker.trigger(),!s)return;s.fn()}finally{}}pick(){let n=null,s=1/0;for(let p=0;p<this.taskQueue.length;p++){const g=this.tasks[this.taskQueue[p]];g.priority<s&&(s=g.priority,n=p)}if(n===null)return null;const u=this.taskQueue[n];return this.taskQueue.splice(n,1),u}remove(){this.invoker.remove()}}const TF=Le([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_merc_pos",components:2},{type:"Float32",name:"a_uv",components:2}]),EF=Le([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Ow}=TF,Nw=Le([{name:"a_pos_3",components:3,type:"Int16"}]);var Rp=Le([{name:"a_pos",type:"Int16",components:2}]);const rh=In/Math.PI/2,Kr=-rh,Jr=rh,CF=[new go([Kr,Kr,Kr],[Jr,Jr,Jr]),new go([Kr,Kr,Kr],[0,0,Jr]),new go([0,Kr,Kr],[Jr,0,Jr]),new go([Kr,0,Kr],[0,Jr,Jr]),new go([0,0,Kr],[Jr,Jr,Jr])];class AF{constructor(n,s,u){this.a=Xu([],n,u),this.b=Xu([],s,u),this.center=u;const p=yp([],this.a),g=yp([],this.b);this.angle=Math.acos(_p(p,g))}}function Qv(a,n){if(a.angle===0)return null;let s;return s=a.a[n]===0?1/a.angle*.5*Math.PI:1/a.angle*Math.atan(a.b[n]/a.a[n]/Math.sin(a.angle)-1/Math.tan(a.angle)),s<0||s>1?null:function(u,p,g,_){const T=Math.sin(g);return u*(Math.sin((1-_)*g)/T)+p*(Math.sin(_*g)/T)}(a.a[n],a.b[n],a.angle,Q(s,0,1))+a.center[n]}function kp(a){if(a.z<=1)return CF[a.z+2*a.y+a.x];const[n,s]=ex(a),u=[Ja(n[0],n[1]),Ja(n[0],s[1]),Ja(s[0],n[1]),Ja(s[0],s[1])],p=[Jr,Jr,Jr],g=[Kr,Kr,Kr];for(const _ of u)p[0]=Math.min(p[0],_[0]),p[1]=Math.min(p[1],_[1]),p[2]=Math.min(p[2],_[2]),g[0]=Math.max(g[0],_[0]),g[1]=Math.max(g[1],_[1]),g[2]=Math.max(g[2],_[2]);return new go(p,g)}function DF(a,n,s){const u=n/a.worldSize,p=(mt,Pt)=>{gp(mt,mt,u),gp(Pt,Pt,u)},g=Number.MAX_VALUE,_=[-g,-g,-g],T=[g,g,g],D=jw(a);if(s.z<=1){const mt=kp(s).getCorners();for(let Pt=0;Pt<mt.length;Pt++)Yl(mt[Pt],mt[Pt],D),Tv(T,T,mt[Pt]),Ev(_,_,mt[Pt]);return p(T,_),new go(T,_)}const[I,z]=ex(s),B=new Os;B.setSouthWest([I[1],z[0]]),B.setNorthEast([z[1],I[0]]);const N=[Ja(B.getSouth(),B.getWest()),Ja(B.getSouth(),B.getEast()),Ja(B.getNorth(),B.getEast()),Ja(B.getNorth(),B.getWest())];for(let mt=0;mt<N.length;mt++)Yl(N[mt],N[mt],D),Tv(T,T,N[mt]),Ev(_,_,N[mt]);if(B.contains(a.center))return _[2]=0,p(T,_),new go(T,_);const W=[D[12],D[13],D[14]],K=a.center.lng,oe=Q(a.center.lat,-85.051129,ma),ue=[fp(K),ju(oe)],xe=B.getCenter().lng,Be=Q(B.getCenter().lat,-85.051129,ma),$e=[fp(xe),ju(Be)];let Ze=new Array(3),Ye=0;const Ke=ue[0]-$e[0],ut=ue[1]-$e[1];if(Math.abs(Ke)>Math.abs(ut))Ye=Ke>=0?1:3,Ze=W;else{Ye=ut>=0?0:2;const mt=[D[4],D[5],D[6]];let Pt;Pt=ut>=0?-Math.sin(F(B.getSouth()))*rh:-Math.sin(F(B.getNorth()))*rh,Ze=Cv(Ze,W,mt,Pt)}const dt=N[Ye],xt=N[(Ye+1)%4],Et=new AF(dt,xt,Ze),st=[Qv(Et,0)||dt[0],Qv(Et,1)||dt[1],Qv(Et,2)||dt[2]];return T[2]=Math.min(dt[2],xt[2]),Tv(T,T,st),Ev(_,_,st),p(T,_),new go(T,_)}function ex(a){const n=1<<a.z,s=a.x/n,u=(a.x+1)/n,p=(a.y+1)/n;return[[rr(a.y/n),To(s)],[rr(p),To(u)]]}function Uw(a,n,s,u=rh){return s=F(s),[a*Math.sin(s)*u,-n*u,a*Math.cos(s)*u]}function Ja(a,n,s){return Uw(Math.cos(F(a)),Math.sin(F(a)),n,s)}function Vw(a,n,s){const u=Math.pow(2,s.z),p=(a/In+s.x)/u;return Ja(rr((n/In+s.y)/u),To(p))}function tx(a){return 16383/Math.max(...Xu([],a.max,a.min))}function Gw(a){const n=ga(new Float64Array(16)),s=tx(a);var u,p;return Ns(n,n,[s,s,s]),Zl(n,n,((u=[])[0]=-(p=a.min)[0],u[1]=-p[1],u[2]=-p[2],u)),n}function Ww(a,n,s,u,p){const g=function(D){const I=In/(2*Math.PI);return D/(2*Math.PI)/I}(s),_=[a,n,-s/(2*Math.PI)],T=ga(new Float64Array(16));return Zl(T,T,_),Ns(T,T,[g,g,g]),bv(T,T,F(-p)),wv(T,T,F(-u)),T}function jw(a){const{x:n,y:s}=a.point,{lng:u,lat:p}=a._center;return Ww(n,s,a.worldSize,u,p)}const Hw=F(85),PF=Math.cos(Hw),SF=Math.sin(Hw);function $w(a,n,s){var u=2*Math.PI*6378137/256/Math.pow(2,s);return[a*u-2*Math.PI*6378137/2,n*u-2*Math.PI*6378137/2]}class Zg{constructor(n,s,u){this.z=n,this.x=s,this.y=u,this.key=zp(0,n,n,s,u)}equals(n){return this.z===n.z&&this.x===n.x&&this.y===n.y}url(n,s){const u=function(g,_,T){var D=$w(256*g,256*(_=Math.pow(2,T)-_-1),T),I=$w(256*(g+1),256*(_+1),T);return D[0]+","+D[1]+","+I[0]+","+I[1]}(this.x,this.y,this.z),p=function(g,_,T){let D,I="";for(let z=g;z>0;z--)D=1<<z-1,I+=(_&D?1:0)+(T&D?2:0);return I}(this.z,this.x,this.y);return n[(this.x+this.y)%n.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace("{z}",String(this.z)).replace("{x}",String(this.x)).replace("{y}",String(s==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",p).replace("{bbox-epsg-3857}",u)}toString(){return`${this.z}/${this.x}/${this.y}`}}class qw{constructor(n,s){this.wrap=n,this.canonical=s,this.key=zp(n,s.z,s.z,s.x,s.y)}}class vr{constructor(n,s,u,p,g){this.overscaledZ=n,this.wrap=s,this.canonical=new Zg(u,+p,+g),this.key=s===0&&n===u?this.canonical.key:zp(s,n,u,p,g)}equals(n){return this.overscaledZ===n.overscaledZ&&this.wrap===n.wrap&&this.canonical.equals(n.canonical)}scaledTo(n){const s=this.canonical.z-n;return n>this.canonical.z?new vr(n,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new vr(n,this.wrap,n,this.canonical.x>>s,this.canonical.y>>s)}calculateScaledKey(n,s=!0){if(this.overscaledZ===n&&s)return this.key;if(n>this.canonical.z)return zp(this.wrap*+s,n,this.canonical.z,this.canonical.x,this.canonical.y);{const u=this.canonical.z-n;return zp(this.wrap*+s,n,n,this.canonical.x>>u,this.canonical.y>>u)}}isChildOf(n){if(n.wrap!==this.wrap)return!1;const s=this.canonical.z-n.canonical.z;return n.overscaledZ===0||n.overscaledZ<this.overscaledZ&&n.canonical.x===this.canonical.x>>s&&n.canonical.y===this.canonical.y>>s}children(n){if(this.overscaledZ>=n)return[new vr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const s=this.canonical.z+1,u=2*this.canonical.x,p=2*this.canonical.y;return[new vr(s,this.wrap,s,u,p),new vr(s,this.wrap,s,u+1,p),new vr(s,this.wrap,s,u,p+1),new vr(s,this.wrap,s,u+1,p+1)]}isLessThan(n){return this.wrap<n.wrap||!(this.wrap>n.wrap)&&(this.overscaledZ<n.overscaledZ||!(this.overscaledZ>n.overscaledZ)&&(this.canonical.x<n.canonical.x||!(this.canonical.x>n.canonical.x)&&this.canonical.y<n.canonical.y))}wrapped(){return new vr(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(n){return new vr(this.overscaledZ,n,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new qw(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function zp(a,n,s,u,p){const g=1<<Math.min(s,22);let _=g*(p%g)+u%g;return a&&s<22&&(_+=g*g*((a<0?-2*a-1:2*a)%(1<<2*(22-s)))),16*(32*_+s)+(n-s)}function Jl(a,n){if(!n.isReprojectedInTileSpace)return{scale:1<<a.z,x:a.x,y:a.y,x2:a.x+1,y2:a.y+1,projection:n};const s=Math.pow(2,-a.z),u=a.x*s,p=(a.x+1)*s,g=a.y*s,_=(a.y+1)*s,T=To(u),D=To(p),I=rr(g),z=rr(_),B=n.project(T,I),N=n.project(D,I),W=n.project(D,z),K=n.project(T,z);let oe=Math.min(B.x,N.x,W.x,K.x),ue=Math.min(B.y,N.y,W.y,K.y),xe=Math.max(B.x,N.x,W.x,K.x),Be=Math.max(B.y,N.y,W.y,K.y);const $e=s/16;function Ze(Ke,ut,dt,xt,Et,st){const mt=(dt+Et)/2,Pt=(xt+st)/2,Bt=n.project(To(mt),rr(Pt)),Rt=Math.max(0,oe-Bt.x,ue-Bt.y,Bt.x-xe,Bt.y-Be);oe=Math.min(oe,Bt.x),xe=Math.max(xe,Bt.x),ue=Math.min(ue,Bt.y),Be=Math.max(Be,Bt.y),Rt>$e&&(Ze(Ke,Bt,dt,xt,mt,Pt),Ze(Bt,ut,mt,Pt,Et,st))}Ze(B,N,u,g,p,g),Ze(N,W,p,g,p,_),Ze(W,K,p,_,u,_),Ze(K,B,u,_,u,g),oe-=$e,ue-=$e,xe+=$e,Be+=$e;const Ye=1/Math.max(xe-oe,Be-ue);return{scale:Ye,x:oe*Ye,y:ue*Ye,x2:xe*Ye,y2:Be*Ye,projection:n}}$t(Zg,"CanonicalTileID"),$t(vr,"OverscaledTileID",{omit:["projMatrix"]});class Xw{constructor(n){this._stringToNumber={},this._numberToString=[];for(let s=0;s<n.length;s++){const u=n[s];this._stringToNumber[u]=s,this._numberToString[s]=u}}encode(n){return this._stringToNumber[n]}decode(n){return this._numberToString[n]}}const LF=["tile","layer","source","sourceLayer","state"];class Zw{constructor(n,s,u,p,g){this.type="Feature",this._vectorTileFeature=n,this._z=s,this._x=u,this._y=p,this.properties=n.properties,this.id=g}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(n){this._geometry=n}toJSON(){const n={type:"Feature",geometry:this.geometry,properties:this.properties};this.id!==void 0&&(n.id=this.id);for(const s of LF)this[s]!==void 0&&(n[s]=this[s]);return n}}const Eo=32,_a=33,Ws=new Uint16Array(8184);for(let a=0;a<2046;a++){let n=a+2,s=0,u=0,p=0,g=0,_=0,T=0;for(1&n?p=g=_=Eo:s=u=T=Eo;(n>>=1)>1;){const I=s+p>>1,z=u+g>>1;1&n?(p=s,g=u,s=_,u=T):(s=p,u=g,p=_,g=T),_=I,T=z}const D=4*a;Ws[D+0]=s,Ws[D+1]=u,Ws[D+2]=p,Ws[D+3]=g}const va=new Uint16Array(2178),js=new Uint8Array(1089),Yg=new Uint16Array(1089);function Yw(a){return a===0?-.03125:a===32?.03125:0}var Kw=Le([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Jw={type:2,extent:In,loadGeometry:()=>[[new b(0,0),new b(8193,0),new b(8193,8193),new b(0,8193),new b(0,0)]]};class nx{constructor(n,s,u,p,g){this.tileID=n,this.uid=Oe(),this.uses=0,this.tileSize=s,this.tileZoom=u,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=g,this.expiredRequestCount=0,this.state="loading",p&&p.transform&&(this.projection=p.transform.projection)}registerFadeDuration(n){const s=n+this.timeAdded;s<wt.now()||this.fadeEndTime&&s<this.fadeEndTime||(this.fadeEndTime=s)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}get tileTransform(){return this._tileTransform||(this._tileTransform=Jl(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(n,s,u){if(this.unloadVectorData(),this.state="loaded",n){n.featureIndex&&(this.latestFeatureIndex=n.featureIndex,n.rawTileData?(this.latestRawTileData=n.rawTileData,this.latestFeatureIndex.rawTileData=n.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=n.collisionBoxArray,this.buckets=function(p,g){const _={};if(!g)return _;for(const T of p){const D=T.layerIds.map(I=>g.getLayer(I)).filter(Boolean);if(D.length!==0){T.layers=D,T.stateDependentLayerIds&&(T.stateDependentLayers=T.stateDependentLayerIds.map(I=>D.filter(z=>z.id===I)[0]));for(const I of D)_[I.id]=T}}return _}(n.buckets,s.style),this.hasSymbolBuckets=!1;for(const p in this.buckets){const g=this.buckets[p];if(g instanceof Gs){if(this.hasSymbolBuckets=!0,!u)break;g.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const p in this.buckets){const g=this.buckets[p];if(g instanceof Gs&&g.hasRTLText){this.hasRTLText=!0,qr.isLoading()||qr.isLoaded()||Gu()!=="deferred"||Rs();break}}this.queryPadding=0;for(const p in this.buckets){const g=this.buckets[p];this.queryPadding=Math.max(this.queryPadding,s.style.getLayer(p).queryRadius(g))}n.imageAtlas&&(this.imageAtlas=n.imageAtlas),n.glyphAtlasImage&&(this.glyphAtlasImage=n.glyphAtlasImage),n.lineAtlas&&(this.lineAtlas=n.lineAtlas)}else this.collisionBoxArray=new Uo}unloadVectorData(){if(this.hasData()){for(const n in this.buckets)this.buckets[n].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(n){return this.buckets[n.id]}upload(n){for(const u in this.buckets){const p=this.buckets[u];p.uploadPending()&&p.upload(n)}const s=n.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Ip(n,this.imageAtlas.image,s.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Ip(n,this.glyphAtlasImage,s.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Ip(n,this.lineAtlas.image,s.ALPHA),this.lineAtlas.uploaded=!0)}prepare(n){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(n,this.imageAtlasTexture)}queryRenderedFeatures(n,s,u,p,g,_,T,D){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:p,pixelPosMatrix:T,transform:_,params:g,tileTransform:this.tileTransform},n,s,u):{}}querySourceFeatures(n,s){const u=this.latestFeatureIndex;if(!u||!u.rawTileData)return;const p=u.loadVTLayers(),g=s?s.sourceLayer:"",_=p._geojsonTileLayer||p[g];if(!_)return;const T=ca(s&&s.filter),{z:D,x:I,y:z}=this.tileID.canonical,B={z:D,x:I,y:z};for(let N=0;N<_.length;N++){const W=_.feature(N);if(T.needGeometry){const ue=Xl(W,!0);if(!T.filter(new ci(this.tileID.overscaledZ),ue,this.tileID.canonical))continue}else if(!T.filter(new ci(this.tileID.overscaledZ),W))continue;const K=u.getId(W,g),oe=new Zw(W,D,I,z,K);oe.tile=B,n.push(oe)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(n){const s=this.expirationTime;if(n.cacheControl){const u=ot(n.cacheControl);u["max-age"]&&(this.expirationTime=Date.now()+1e3*u["max-age"])}else n.expires&&(this.expirationTime=new Date(n.expires).getTime());if(this.expirationTime){const u=Date.now();let p=!1;if(this.expirationTime>u)p=!1;else if(s)if(this.expirationTime<s)p=!0;else{const g=this.expirationTime-s;g?this.expirationTime=u+Math.max(g,3e4):p=!0}else p=!0;p?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(n,s){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(n).length===0||!s)return;const u=this.latestFeatureIndex.loadVTLayers(),p=s.style.listImages();for(const g in this.buckets){if(!s.style.hasLayer(g))continue;const _=this.buckets[g],T=_.layers[0].sourceLayer||"_geojsonTileLayer",D=u[T],I=n[T];if(!D||!I||Object.keys(I).length===0)continue;if(_.update(I,D,p,this.imageAtlas&&this.imageAtlas.patternPositions||{}),_ instanceof Ng||_ instanceof Bg){const B=s.style._getSourceCache(_.layers[0].source);s._terrain&&s._terrain.enabled&&B&&_.programConfigurations.needsUpload&&s._terrain._clearRenderCacheForTile(B.id,this.tileID)}const z=s&&s.style&&s.style.getLayer(g);z&&(this.queryPadding=Math.max(this.queryPadding,z.queryRadius(_)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<wt.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(n){this.symbolFadeHoldUntil=wt.now()+n}setTexture(n,s){const u=s.context,p=u.gl;this.texture=s.getTileTexture(n.width),this.texture?this.texture.update(n,{useMipmap:!0}):(this.texture=new Ip(u,n,p.RGBA,{useMipmap:!0}),this.texture.bind(p.LINEAR,p.CLAMP_TO_EDGE),u.extTextureFilterAnisotropic&&p.texParameterf(p.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax))}setDependencies(n,s){const u={};for(const p of s)u[p]=!0;this.dependencies[n]=u}hasDependency(n,s){for(const u of n){const p=this.dependencies[u];if(p){for(const g of s)if(p[g])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(n,s){if(!s||s.name==="mercator"||this._tileDebugBuffer)return;const u=Xa(Jw,this.tileID.canonical,this.tileTransform)[0],p=new De,g=new $n;for(let _=0;_<u.length;_++){const{x:T,y:D}=u[_];p.emplaceBack(T,D),g.emplaceBack(_)}g.emplaceBack(0),this._tileDebugIndexBuffer=n.createIndexBuffer(g),this._tileDebugBuffer=n.createVertexBuffer(p,Rp.members),this._tileDebugSegments=Ei.simpleSegment(0,0,p.length,g.length)}_makeTileBoundsBuffers(n,s){if(this._tileBoundsBuffer||!s||s.name==="mercator")return;const u=Xa(Jw,this.tileID.canonical,this.tileTransform)[0];let p,g;if(this.isRaster){const _=function(T,D){const I=Jl(T,D),z=Math.pow(2,T.z);for(let ue=0;ue<_a;ue++)for(let xe=0;xe<_a;xe++){const Be=To((T.x+(xe+Yw(xe))/Eo)/z),$e=rr((T.y+(ue+Yw(ue))/Eo)/z),Ze=D.project(Be,$e),Ye=ue*_a+xe;va[2*Ye+0]=Math.round((Ze.x*I.scale-I.x)*In),va[2*Ye+1]=Math.round((Ze.y*I.scale-I.y)*In)}js.fill(0),Yg.fill(0);for(let ue=2045;ue>=0;ue--){const xe=4*ue,Be=Ws[xe+0],$e=Ws[xe+1],Ze=Ws[xe+2],Ye=Ws[xe+3],Ke=Be+Ze>>1,ut=$e+Ye>>1,dt=Ke+ut-$e,xt=ut+Be-Ke,Et=$e*_a+Be,st=Ye*_a+Ze,mt=ut*_a+Ke,Pt=Math.hypot((va[2*Et+0]+va[2*st+0])/2-va[2*mt+0],(va[2*Et+1]+va[2*st+1])/2-va[2*mt+1])>=16;if(js[mt]=js[mt]||(Pt?1:0),ue<1022){const Bt=($e+xt>>1)*_a+(Be+dt>>1),Rt=(Ye+xt>>1)*_a+(Ze+dt>>1);js[mt]=js[mt]||js[Bt]||js[Rt]}}const B=new ze,N=new qt;let W=0;function K(ue,xe){const Be=xe*_a+ue;return Yg[Be]===0&&(B.emplaceBack(va[2*Be+0],va[2*Be+1],ue*In/Eo,xe*In/Eo),Yg[Be]=++W),Yg[Be]-1}function oe(ue,xe,Be,$e,Ze,Ye){const Ke=ue+Be>>1,ut=xe+$e>>1;if(Math.abs(ue-Ze)+Math.abs(xe-Ye)>1&&js[ut*_a+Ke])oe(Ze,Ye,ue,xe,Ke,ut),oe(Be,$e,Ze,Ye,Ke,ut);else{const dt=K(ue,xe),xt=K(Be,$e),Et=K(Ze,Ye);N.emplaceBack(dt,xt,Et)}}return oe(0,0,Eo,Eo,Eo,0),oe(Eo,Eo,0,0,0,Eo),{vertices:B,indices:N}}(this.tileID.canonical,s);p=_.vertices,g=_.indices}else{p=new ze,g=new qt;for(const{x:T,y:D}of u)p.emplaceBack(T,D,0,0);const _=Ig(p.int16,void 0,4);for(let T=0;T<_.length;T+=3)g.emplaceBack(_[T],_[T+1],_[T+2])}this._tileBoundsBuffer=n.createVertexBuffer(p,Kw.members),this._tileBoundsIndexBuffer=n.createIndexBuffer(g),this._tileBoundsSegments=Ei.simpleSegment(0,0,p.length,g.length)}_makeGlobeTileDebugBuffers(n,s){if(this._globeTileDebugBorderBuffer||this._globeTileDebugTextBuffer||!s||s.name!=="globe")return;const u=this.tileID.canonical,p=Gw(kp(u));this._makeGlobeTileDebugBorderBuffer(n,u,p),this._makeGlobeTileDebugTextBuffer(n,u,p)}_makeGlobeTileDebugBorderBuffer(n,s,u){const p=new De,g=new $n,_=new Se,T=(I,z,B,N,W)=>{const K=(B-I)/(W-1),oe=(N-z)/(W-1),ue=p.length;for(let xe=0;xe<W;xe++){const Be=I+xe*K,$e=z+xe*oe;p.emplaceBack(Be,$e);const Ze=Vw(Be,$e,s),Ye=Yl(Ze,Ze,u);_.emplaceBack(Ye[0],Ye[1],Ye[2]),g.emplaceBack(ue+xe)}},D=In;T(0,0,D,0,16),T(D,0,D,D,16),T(D,D,0,D,16),T(0,D,0,0,16),this._tileDebugIndexBuffer=n.createIndexBuffer(g),this._tileDebugBuffer=n.createVertexBuffer(p,Rp.members),this._globeTileDebugBorderBuffer=n.createVertexBuffer(_,Nw.members),this._tileDebugSegments=Ei.simpleSegment(0,0,p.length,g.length)}_makeGlobeTileDebugTextBuffer(n,s,u){const p=new De,g=new qt,_=new Se,T=25;g.reserve(32),p.reserve(T),_.reserve(T);const D=(I,z)=>T*I+z;for(let I=0;I<T;I++){const z=2048*I;for(let B=0;B<T;B++){const N=2048*B;p.emplaceBack(N,z);const W=Vw(N,z,s),K=Yl(W,W,u);_.emplaceBack(K[0],K[1],K[2])}}for(let I=0;I<4;I++)for(let z=0;z<4;z++){const B=D(I,z),N=D(I,z+1),W=D(I+1,z),K=D(I+1,z+1);g.emplaceBack(B,N,W),g.emplaceBack(W,N,K)}this._tileDebugTextIndexBuffer=n.createIndexBuffer(g),this._tileDebugTextBuffer=n.createVertexBuffer(p,Rp.members),this._globeTileDebugTextBuffer=n.createVertexBuffer(_,Nw.members),this._tileDebugTextSegments=Ei.simpleSegment(0,0,T,32)}}class IF{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(n,s,u){const p=String(s);if(this.stateChanges[n]=this.stateChanges[n]||{},this.stateChanges[n][p]=this.stateChanges[n][p]||{},me(this.stateChanges[n][p],u),this.deletedStates[n]===null){this.deletedStates[n]={};for(const g in this.state[n])g!==p&&(this.deletedStates[n][g]=null)}else if(this.deletedStates[n]&&this.deletedStates[n][p]===null){this.deletedStates[n][p]={};for(const g in this.state[n][p])u[g]||(this.deletedStates[n][p][g]=null)}else for(const g in u)this.deletedStates[n]&&this.deletedStates[n][p]&&this.deletedStates[n][p][g]===null&&delete this.deletedStates[n][p][g]}removeFeatureState(n,s,u){if(this.deletedStates[n]===null)return;const p=String(s);if(this.deletedStates[n]=this.deletedStates[n]||{},u&&s!==void 0)this.deletedStates[n][p]!==null&&(this.deletedStates[n][p]=this.deletedStates[n][p]||{},this.deletedStates[n][p][u]=null);else if(s!==void 0)if(this.stateChanges[n]&&this.stateChanges[n][p])for(u in this.deletedStates[n][p]={},this.stateChanges[n][p])this.deletedStates[n][p][u]=null;else this.deletedStates[n][p]=null;else this.deletedStates[n]=null}getState(n,s){const u=String(s),p=me({},(this.state[n]||{})[u],(this.stateChanges[n]||{})[u]);if(this.deletedStates[n]===null)return{};if(this.deletedStates[n]){const g=this.deletedStates[n][s];if(g===null)return{};for(const _ in g)delete p[_]}return p}initializeTileState(n,s){n.setFeatureState(this.state,s)}coalesceChanges(n,s){const u={};for(const p in this.stateChanges){this.state[p]=this.state[p]||{};const g={};for(const _ in this.stateChanges[p])this.state[p][_]||(this.state[p][_]={}),me(this.state[p][_],this.stateChanges[p][_]),g[_]=this.state[p][_];u[p]=g}for(const p in this.deletedStates){this.state[p]=this.state[p]||{};const g={};if(this.deletedStates[p]===null)for(const _ in this.state[p])g[_]={},this.state[p][_]={};else for(const _ in this.deletedStates[p]){if(this.deletedStates[p][_]===null)this.state[p][_]={};else for(const T of Object.keys(this.deletedStates[p][_]))delete this.state[p][_][T];g[_]=this.state[p][_]}u[p]=u[p]||{},me(u[p],g)}if(this.stateChanges={},this.deletedStates={},Object.keys(u).length!==0)for(const p in n)n[p].setFeatureState(u,s)}}class Qw{constructor(n){this.size=n,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(n,s){const u=this.toIdx(n,s);return{min:this.minimums[u],max:this.maximums[u]}}isLeaf(n,s){return this.leaves[this.toIdx(n,s)]}toIdx(n,s){return s*this.size+n}}function eM(a,n,s,u){let p=0,g=Number.MAX_VALUE;for(let _=0;_<3;_++)if(Math.abs(u[_])<1e-15){if(s[_]<a[_]||s[_]>n[_])return null}else{const T=1/u[_];let D=(a[_]-s[_])*T,I=(n[_]-s[_])*T;if(D>I){const z=D;D=I,I=z}if(D>p&&(p=D),I<g&&(g=I),p>g)return null}return p}function tM(a,n,s,u,p,g,_,T,D,I,z){const B=u-a,N=p-n,W=g-s,K=_-a,oe=T-n,ue=D-s,xe=z[1]*ue-z[2]*oe,Be=z[2]*K-z[0]*ue,$e=z[0]*oe-z[1]*K,Ze=B*xe+N*Be+W*$e;if(Math.abs(Ze)<1e-15)return null;const Ye=1/Ze,Ke=I[0]-a,ut=I[1]-n,dt=I[2]-s,xt=(Ke*xe+ut*Be+dt*$e)*Ye;if(xt<0||xt>1)return null;const Et=ut*W-dt*N,st=dt*B-Ke*W,mt=Ke*N-ut*B,Pt=(z[0]*Et+z[1]*st+z[2]*mt)*Ye;return Pt<0||xt+Pt>1?null:(K*Et+oe*st+ue*mt)*Ye}function nM(a,n,s){return(a-n)/(s-n)}function iM(a,n,s,u,p,g,_,T,D){const I=1<<s,z=g-u,B=_-p,N=(a+1)/I*z+u,W=(n+0)/I*B+p,K=(n+1)/I*B+p;T[0]=(a+0)/I*z+u,T[1]=W,D[0]=N,D[1]=K}class rM{constructor(n){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=n,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const s=function(g){const _=Math.ceil(Math.log2(g.dim/8)),T=[];let D=Math.ceil(Math.pow(2,_));const I=1/D,z=(W,K,oe,ue,xe)=>{const Be=ue?1:0,$e=(W+1)*oe-Be,Ze=K*oe,Ye=(K+1)*oe-Be;xe[0]=W*oe,xe[1]=Ze,xe[2]=$e,xe[3]=Ye};let B=new Qw(D);const N=[];for(let W=0;W<D*D;W++){z(W%D,Math.floor(W/D),I,!1,N);const K=Hs(N[0],N[1],g),oe=Hs(N[2],N[1],g),ue=Hs(N[2],N[3],g),xe=Hs(N[0],N[3],g);B.minimums.push(Math.min(K,oe,ue,xe)),B.maximums.push(Math.max(K,oe,ue,xe)),B.leaves.push(1)}for(T.push(B),D/=2;D>=1;D/=2){const W=T[T.length-1];B=new Qw(D);for(let K=0;K<D*D;K++){z(K%D,Math.floor(K/D),2,!0,N);const oe=W.getElevation(N[0],N[1]),ue=W.getElevation(N[2],N[1]),xe=W.getElevation(N[2],N[3]),Be=W.getElevation(N[0],N[3]),$e=W.isLeaf(N[0],N[1]),Ze=W.isLeaf(N[2],N[1]),Ye=W.isLeaf(N[2],N[3]),Ke=W.isLeaf(N[0],N[3]),ut=Math.min(oe.min,ue.min,xe.min,Be.min),dt=Math.max(oe.max,ue.max,xe.max,Be.max),xt=$e&&Ze&&Ye&&Ke;B.maximums.push(dt),B.minimums.push(ut),B.leaves.push(dt-ut<=5&&xt?1:0)}T.push(B)}return T}(this.dem),u=s.length-1,p=s[u];this._addNode(p.minimums[0],p.maximums[0],p.leaves[0]),this._construct(s,0,0,u,0)}raycastRoot(n,s,u,p,g,_,T=1){return eM([n,s,-100],[u,p,this.maximums[0]*T],g,_)}raycast(n,s,u,p,g,_,T=1){if(!this.nodeCount)return null;const D=this.raycastRoot(n,s,u,p,g,_,T);if(D==null)return null;const I=[],z=[],B=[],N=[],W=[{idx:0,t:D,nodex:0,nodey:0,depth:0}];for(;W.length>0;){const{idx:K,t:oe,nodex:ue,nodey:xe,depth:Be}=W.pop();if(this.leaves[K]){iM(ue,xe,Be,n,s,u,p,B,N);const Ze=1<<Be,Ye=(ue+0)/Ze,Ke=(ue+1)/Ze,ut=(xe+0)/Ze,dt=(xe+1)/Ze,xt=Hs(Ye,ut,this.dem)*T,Et=Hs(Ke,ut,this.dem)*T,st=Hs(Ke,dt,this.dem)*T,mt=Hs(Ye,dt,this.dem)*T,Pt=tM(B[0],B[1],xt,N[0],B[1],Et,N[0],N[1],st,g,_),Bt=tM(N[0],N[1],st,B[0],N[1],mt,B[0],B[1],xt,g,_),Rt=Math.min(Pt!==null?Pt:Number.MAX_VALUE,Bt!==null?Bt:Number.MAX_VALUE);if(Rt!==Number.MAX_VALUE)return Rt;{const Ft=Cv([],g,_,oe);if(oM(xt,Et,mt,st,nM(Ft[0],B[0],N[0]),nM(Ft[1],B[1],N[1]))>=Ft[2])return oe}continue}let $e=0;for(let Ze=0;Ze<this._siblingOffset.length;Ze++){iM((ue<<1)+this._siblingOffset[Ze][0],(xe<<1)+this._siblingOffset[Ze][1],Be+1,n,s,u,p,B,N),B[2]=-100,N[2]=this.maximums[this.childOffsets[K]+Ze]*T;const Ye=eM(B,N,g,_);if(Ye!=null){const Ke=Ye;I[Ze]=Ke;let ut=!1;for(let dt=0;dt<$e&&!ut;dt++)Ke>=I[z[dt]]&&(z.splice(dt,0,Ze),ut=!0);ut||(z[$e]=Ze),$e++}}for(let Ze=0;Ze<$e;Ze++){const Ye=z[Ze];W.push({idx:this.childOffsets[K]+Ye,t:I[Ye],nodex:(ue<<1)+this._siblingOffset[Ye][0],nodey:(xe<<1)+this._siblingOffset[Ye][1],depth:Be+1})}}return null}_addNode(n,s,u){return this.minimums.push(n),this.maximums.push(s),this.leaves.push(u),this.childOffsets.push(0),this.nodeCount++}_construct(n,s,u,p,g){if(n[p].isLeaf(s,u)===1)return;this.childOffsets[g]||(this.childOffsets[g]=this.nodeCount);const _=p-1,T=n[_];let D=0,I=0;for(let z=0;z<this._siblingOffset.length;z++){const B=2*s+this._siblingOffset[z][0],N=2*u+this._siblingOffset[z][1],W=T.getElevation(B,N),K=T.isLeaf(B,N),oe=this._addNode(W.min,W.max,K);K&&(D|=1<<z),I||(I=oe)}for(let z=0;z<this._siblingOffset.length;z++)D&1<<z||this._construct(n,2*s+this._siblingOffset[z][0],2*u+this._siblingOffset[z][1],_,I+z)}}function oM(a,n,s,u,p,g){return yn(yn(a,s,g),yn(n,u,g),p)}function Hs(a,n,s){const u=s.dim,p=Q(a*u-.5,0,u-1),g=Q(n*u-.5,0,u-1),_=Math.floor(p),T=Math.floor(g),D=Math.min(_+1,u-1),I=Math.min(T+1,u-1);return oM(s.get(_,T),s.get(D,T),s.get(_,I),s.get(D,I),p-_,g-T)}const aM={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};class Kg{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(n,s,u,p=!1,g=!1){if(this.uid=n,s.height!==s.width)throw new RangeError("DEM tiles must be square");if(u&&u!=="mapbox"&&u!=="terrarium")return be(`"${u}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=s.height;const _=this.dim=s.height-2,T=new Uint32Array(s.data.buffer);if(this.pixels=new Uint8Array(s.data.buffer),this.encoding=u||"mapbox",this.borderReady=p,!p){for(let D=0;D<_;D++)T[this._idx(-1,D)]=T[this._idx(0,D)],T[this._idx(_,D)]=T[this._idx(_-1,D)],T[this._idx(D,-1)]=T[this._idx(D,0)],T[this._idx(D,_)]=T[this._idx(D,_-1)];T[this._idx(-1,-1)]=T[this._idx(0,0)],T[this._idx(_,-1)]=T[this._idx(_-1,0)],T[this._idx(-1,_)]=T[this._idx(0,_-1)],T[this._idx(_,_)]=T[this._idx(_-1,_-1)],g&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new rM(this)}get(n,s,u=!1){u&&(n=Q(n,-1,this.dim),s=Q(s,-1,this.dim));const p=4*this._idx(n,s);return(this.encoding==="terrarium"?this._unpackTerrarium:this._unpackMapbox)(this.pixels[p],this.pixels[p+1],this.pixels[p+2])}static getUnpackVector(n){return aM[n]}get unpackVector(){return aM[this.encoding]}_idx(n,s){if(n<-1||n>=this.dim+1||s<-1||s>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(s+1)*this.stride+(n+1)}_unpackMapbox(n,s,u){return(256*n*256+256*s+u)/10-1e4}_unpackTerrarium(n,s,u){return 256*n+s+u/256-32768}static pack(n,s){const u=[0,0,0,0],p=Kg.getUnpackVector(s);let g=Math.floor((n+p[3])/p[2]);return u[2]=g%256,g=Math.floor(g/256),u[1]=g%256,g=Math.floor(g/256),u[0]=g,u}getPixels(){return new Yr({width:this.stride,height:this.stride},this.pixels)}backfillBorder(n,s,u){if(this.dim!==n.dim)throw new Error("dem dimension mismatch");let p=s*this.dim,g=s*this.dim+this.dim,_=u*this.dim,T=u*this.dim+this.dim;switch(s){case-1:p=g-1;break;case 1:g=p+1}switch(u){case-1:_=T-1;break;case 1:T=_+1}const D=-s*this.dim,I=-u*this.dim;for(let z=_;z<T;z++)for(let B=p;B<g;B++){const N=4*this._idx(B,z),W=4*this._idx(B+D,z+I);this.pixels[N+0]=n.pixels[W+0],this.pixels[N+1]=n.pixels[W+1],this.pixels[N+2]=n.pixels[W+2],this.pixels[N+3]=n.pixels[W+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}$t(Kg,"DEMData"),$t(rM,"DemMinMaxQuadTree",{omit:["dem"]});class RF{constructor(n,s){this.max=n,this.onRemove=s,this.reset()}reset(){for(const n in this.data)for(const s of this.data[n])s.timeout&&clearTimeout(s.timeout),this.onRemove(s.value);return this.data={},this.order=[],this}add(n,s,u){const p=n.wrapped().key;this.data[p]===void 0&&(this.data[p]=[]);const g={value:s,timeout:void 0};if(u!==void 0&&(g.timeout=setTimeout(()=>{this.remove(n,g)},u)),this.data[p].push(g),this.order.push(p),this.order.length>this.max){const _=this._getAndRemoveByKey(this.order[0]);_&&this.onRemove(_)}return this}has(n){return n.wrapped().key in this.data}getAndRemove(n){return this.has(n)?this._getAndRemoveByKey(n.wrapped().key):null}_getAndRemoveByKey(n){const s=this.data[n].shift();return s.timeout&&clearTimeout(s.timeout),this.data[n].length===0&&delete this.data[n],this.order.splice(this.order.indexOf(n),1),s.value}getByKey(n){const s=this.data[n];return s?s[0].value:null}get(n){return this.has(n)?this.data[n.wrapped().key][0].value:null}remove(n,s){if(!this.has(n))return this;const u=n.wrapped().key,p=s===void 0?0:this.data[u].indexOf(s),g=this.data[u][p];return this.data[u].splice(p,1),g.timeout&&clearTimeout(g.timeout),this.data[u].length===0&&delete this.data[u],this.onRemove(g.value),this.order.splice(this.order.indexOf(u),1),this}setMaxSize(n){for(this.max=n;this.order.length>this.max;){const s=this._getAndRemoveByKey(this.order[0]);s&&this.onRemove(s)}return this}filter(n){const s=[];for(const u in this.data)for(const p of this.data[u])n(p.value)||s.push(p);for(const u of s)this.remove(u.value.tileID,u)}}class oh{constructor(n,s,u){this.func=n,this.mask=s,this.range=u}}oh.ReadOnly=!1,oh.ReadWrite=!0,oh.disabled=new oh(519,oh.ReadOnly,[0,1]);const ix=7680;class rx{constructor(n,s,u,p,g,_){this.test=n,this.ref=s,this.mask=u,this.fail=p,this.depthFail=g,this.pass=_}}rx.disabled=new rx({func:519,mask:0},0,0,ix,ix,ix);class xa{constructor(n,s,u){this.blendFunction=n,this.blendColor=s,this.mask=u}}xa.Replace=[1,0],xa.disabled=new xa(xa.Replace,Xn.transparent,[!1,!1,!1,!1]),xa.unblended=new xa(xa.Replace,Xn.transparent,[!0,!0,!0,!0]),xa.alphaBlended=new xa([1,771],Xn.transparent,[!0,!0,!0,!0]);const ox=1029,ax=2305;class jo{constructor(n,s,u){this.enable=n,this.mode=s,this.frontFace=u}}jo.disabled=new jo(!1,ox,ax),jo.backCCW=new jo(!0,ox,ax),jo.backCW=new jo(!0,ox,2304),jo.frontCW=new jo(!0,1028,2304),jo.frontCCW=new jo(!0,1028,ax);class Ql extends Fe{constructor(n,s,u){super(),this.id=n,this._onlySymbols=u,s.on("data",p=>{p.dataType==="source"&&p.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&p.dataType==="source"&&p.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),s.on("error",()=>{this._sourceErrored=!0}),this._source=s,this._tiles={},this._cache=new RF(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=s.minTileCacheSize,this._maxTileCacheSize=s.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new IF,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="custom"&&this._source._dataType==="raster"}onAdd(n){this.map=n,this._minTileCacheSize=this._minTileCacheSize===void 0&&n?n._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&n?n._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const n in this._tiles){const s=this._tiles[n];if(s.state!=="loaded"&&s.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const n=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,n&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(n,s){return n.isSymbolTile=this._onlySymbols,this._source.loadTile(n,s)}_unloadTile(n){if(this._source.unloadTile)return this._source.unloadTile(n,()=>{})}_abortTile(n){if(this._source.abortTile)return this._source.abortTile(n,()=>{})}serialize(){return this._source.serialize()}prepare(n){if(this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._source.prepareTile)for(const s in this._tiles){const u=this._tiles[s];this._source.prepareTile(u)&&this.map.painter.terrain&&this.map.painter.terrain._clearRenderCacheForTile(this.id,u.tileID),u.upload(n),u.prepare(this.map.style.imageManager)}else for(const s in this._tiles){const u=this._tiles[s];u.upload(n),u.prepare(this.map.style.imageManager)}}getIds(){return fe(this._tiles).map(n=>n.tileID).sort(sM).map(n=>n.key)}getRenderableIds(n){const s=[];for(const u in this._tiles)this._isIdRenderable(+u,n)&&s.push(this._tiles[u]);return n?s.sort((u,p)=>{const g=u.tileID,_=p.tileID,T=new b(g.canonical.x,g.canonical.y)._rotate(this.transform.angle),D=new b(_.canonical.x,_.canonical.y)._rotate(this.transform.angle);return g.overscaledZ-_.overscaledZ||D.y-T.y||D.x-T.x}).map(u=>u.tileID.key):s.map(u=>u.tileID).sort(sM).map(u=>u.key)}hasRenderableParent(n){const s=this.findLoadedParent(n,0);return!!s&&this._isIdRenderable(s.tileID.key)}_isIdRenderable(n,s){return this._tiles[n]&&this._tiles[n].hasData()&&!this._coveredTiles[n]&&(s||!this._tiles[n].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const n in this._tiles)this._tiles[n].state!=="errored"&&this._reloadTile(+n,"reloading")}}_reloadTile(n,s){const u=this._tiles[n];u&&(u.state!=="loading"&&(u.state=s),this._loadTile(u,this._tileLoaded.bind(this,u,n,s)))}_tileLoaded(n,s,u,p){if(p)if(n.state="errored",p.status!==404)this._source.fire(new re(p,{tile:n}));else if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const g=this.map.painter.terrain;this.update(this.transform,g.getScaledDemTileSize(),!0),g.resetTileLookupCache(this.id)}else this.update(this.transform);else n.timeAdded=wt.now(),u==="expired"&&(n.refreshedUponExpiration=!0),this._setTileReloadTimer(s,n),this._source.type==="raster-dem"&&n.dem&&this._backfillDEM(n),this._state.initializeTileState(n,this.map?this.map.painter:null),this._source.fire(new Y("data",{dataType:"source",tile:n,coord:n.tileID,sourceCacheId:this.id}))}_backfillDEM(n){const s=this.getRenderableIds();for(let p=0;p<s.length;p++){const g=s[p];if(n.neighboringTiles&&n.neighboringTiles[g]){const _=this.getTileByID(g);u(n,_),u(_,n)}}function u(p,g){if(!p.dem||p.dem.borderReady)return;p.needsHillshadePrepare=!0,p.needsDEMTextureUpload=!0;let _=g.tileID.canonical.x-p.tileID.canonical.x;const T=g.tileID.canonical.y-p.tileID.canonical.y,D=Math.pow(2,p.tileID.canonical.z),I=g.tileID.key;_===0&&T===0||Math.abs(T)>1||(Math.abs(_)>1&&(Math.abs(_+D)===1?_+=D:Math.abs(_-D)===1&&(_-=D)),g.dem&&p.dem&&(p.dem.backfillBorder(g.dem,_,T),p.neighboringTiles&&p.neighboringTiles[I]&&(p.neighboringTiles[I].backfilled=!0)))}}getTile(n){return this.getTileByID(n.key)}getTileByID(n){return this._tiles[n]}_retainLoadedChildren(n,s,u,p){for(const g in this._tiles){let _=this._tiles[g];if(p[g]||!_.hasData()||_.tileID.overscaledZ<=s||_.tileID.overscaledZ>u)continue;let T=_.tileID;for(;_&&_.tileID.overscaledZ>s+1;){const I=_.tileID.scaledTo(_.tileID.overscaledZ-1);_=this._tiles[I.key],_&&_.hasData()&&(T=I)}let D=T;for(;D.overscaledZ>s;)if(D=D.scaledTo(D.overscaledZ-1),n[D.key]){p[T.key]=T;break}}}findLoadedParent(n,s){if(n.key in this._loadedParentTiles){const u=this._loadedParentTiles[n.key];return u&&u.tileID.overscaledZ>=s?u:null}for(let u=n.overscaledZ-1;u>=s;u--){const p=n.scaledTo(u),g=this._getLoadedTile(p);if(g)return g}}_getLoadedTile(n){const s=this._tiles[n.key];return s&&s.hasData()?s:this._cache.getByKey(this._source.reparseOverscaled?n.wrapped().key:n.canonical.key)}updateCacheSize(n,s){s=s||this._source.tileSize;const u=Math.ceil(n.width/s)+1,p=Math.ceil(n.height/s)+1,g=Math.floor(u*p*5),_=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,g):g,T=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,_):_;this._cache.setMaxSize(T)}handleWrapJump(n){const s=Math.round((n-(this._prevLng===void 0?n:this._prevLng))/360);if(this._prevLng=n,s){const u={};for(const p in this._tiles){const g=this._tiles[p];g.tileID=g.tileID.unwrapTo(g.tileID.wrap+s),u[g.tileID.key]=g}this._tiles=u;for(const p in this._timers)clearTimeout(this._timers[p]),delete this._timers[p];for(const p in this._tiles)this._setTileReloadTimer(+p,this._tiles[p])}}update(n,s,u){if(this.transform=n,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!u)return;let p;this.updateCacheSize(n,s),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?p=n.getVisibleUnwrappedCoordinates(this._source.tileID).map(T=>new vr(T.canonical.z,T.wrap,T.canonical.z,T.canonical.x,T.canonical.y)):(p=n.coveringTiles({tileSize:s||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!u,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(p=p.filter(T=>this._source.hasTile(T)))):p=[];const g=this._updateRetainedTiles(p);if(lM(this._source.type)&&p.length!==0){const T={},D={},I=Object.keys(g);for(const B of I){const N=g[B],W=this._tiles[B];if(!W||W.fadeEndTime&&W.fadeEndTime<=wt.now())continue;const K=this.findLoadedParent(N,Math.max(N.overscaledZ-Ql.maxOverzooming,this._source.minzoom));K&&(this._addTile(K.tileID),T[K.tileID.key]=K.tileID),D[B]=N}const z=p[p.length-1].overscaledZ;for(const B in this._tiles){const N=this._tiles[B];if(g[B]||!N.hasData())continue;let W=N.tileID;for(;W.overscaledZ>z;){W=W.scaledTo(W.overscaledZ-1);const K=this._tiles[W.key];if(K&&K.hasData()&&D[W.key]){g[B]=N.tileID;break}}}for(const B in T)g[B]||(this._coveredTiles[B]=!0,g[B]=T[B])}for(const T in g)this._tiles[T].clearFadeHold();const _=function(T,D){const I=[];for(const z in T)z in D||I.push(z);return I}(this._tiles,g);for(const T of _){const D=this._tiles[T];D.hasSymbolBuckets&&!D.holdingForFade()?D.setHoldDuration(this.map._fadeDuration):D.hasSymbolBuckets&&!D.symbolFadeFinished()||this._removeTile(+T)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const n in this._tiles)this._tiles[n].holdingForFade()&&this._removeTile(+n)}_updateRetainedTiles(n){const s={};if(n.length===0)return s;const u={},p=n.reduce((I,z)=>Math.min(I,z.overscaledZ),1/0),g=n[0].overscaledZ,_=Math.max(g-Ql.maxOverzooming,this._source.minzoom),T=Math.max(g+Ql.maxUnderzooming,this._source.minzoom),D={};for(const I of n){const z=this._addTile(I);s[I.key]=I,z.hasData()||p<this._source.maxzoom&&(D[I.key]=I)}this._retainLoadedChildren(D,p,T,s);for(const I of n){let z=this._tiles[I.key];if(z.hasData())continue;if(I.canonical.z>=this._source.maxzoom){const N=I.children(this._source.maxzoom)[0],W=this.getTile(N);if(W&&W.hasData()){s[N.key]=N;continue}}else{const N=I.children(this._source.maxzoom);if(s[N[0].key]&&s[N[1].key]&&s[N[2].key]&&s[N[3].key])continue}let B=z.wasRequested();for(let N=I.overscaledZ-1;N>=_;--N){const W=I.scaledTo(N);if(u[W.key]||(u[W.key]=!0,z=this.getTile(W),!z&&B&&(z=this._addTile(W)),z&&(s[W.key]=W,B=z.wasRequested(),z.hasData())))break}}return s}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const n in this._tiles){const s=[];let u,p=this._tiles[n].tileID;for(;p.overscaledZ>0;){if(p.key in this._loadedParentTiles){u=this._loadedParentTiles[p.key];break}s.push(p.key);const g=p.scaledTo(p.overscaledZ-1);if(u=this._getLoadedTile(g),u)break;p=g}for(const g of s)this._loadedParentTiles[g]=u}}_addTile(n){let s=this._tiles[n.key];if(s)return this._source.prepareTile&&this._source.prepareTile(s),s;s=this._cache.getAndRemove(n),s&&(this._setTileReloadTimer(n.key,s),s.tileID=n,this._state.initializeTileState(s,this.map?this.map.painter:null),this._cacheTimers[n.key]&&(clearTimeout(this._cacheTimers[n.key]),delete this._cacheTimers[n.key],this._setTileReloadTimer(n.key,s)));const u=!!s;if(!u){const p=this.map?this.map.painter:null;s=new nx(n,this._source.tileSize*n.overscaleFactor(),this.transform.tileZoom,p,this._isRaster),this._source.prepareTile&&this._source.prepareTile(s)||this._loadTile(s,this._tileLoaded.bind(this,s,n.key,s.state))}return s?(s.uses++,this._tiles[n.key]=s,u||this._source.fire(new Y("dataloading",{tile:s,coord:s.tileID,dataType:"source"})),s):null}_setTileReloadTimer(n,s){n in this._timers&&(clearTimeout(this._timers[n]),delete this._timers[n]);const u=s.getExpiryTimeout();u&&(this._timers[n]=setTimeout(()=>{this._reloadTile(n,"expired"),delete this._timers[n]},u))}_removeTile(n){const s=this._tiles[n];s&&(s.uses--,delete this._tiles[n],this._timers[n]&&(clearTimeout(this._timers[n]),delete this._timers[n]),s.uses>0||(s.hasData()&&s.state!=="reloading"?this._cache.add(s.tileID,s,s.getExpiryTimeout()):(s.aborted=!0,this._abortTile(s),this._unloadTile(s))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const n in this._tiles)this._removeTile(+n);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(n,s,u){const p=[],g=this.transform;if(!g)return p;for(const _ in this._tiles){const T=this._tiles[_];if(u&&T.clearQueryDebugViz(),T.holdingForFade())continue;const D=n.containsTile(T,g,s);D&&p.push(D)}return p}getVisibleCoordinates(n){const s=this.getRenderableIds(n).map(u=>this._tiles[u].tileID);for(const u of s)u.projMatrix=this.transform.calculateProjMatrix(u.toUnwrapped());return s}hasTransition(){if(this._source.hasTransition())return!0;if(lM(this._source.type))for(const n in this._tiles){const s=this._tiles[n];if(s.fadeEndTime!==void 0&&s.fadeEndTime>=wt.now())return!0}return!1}setFeatureState(n,s,u){this._state.updateState(n=n||"_geojsonTileLayer",s,u)}removeFeatureState(n,s,u){this._state.removeFeatureState(n=n||"_geojsonTileLayer",s,u)}getFeatureState(n,s){return this._state.getState(n=n||"_geojsonTileLayer",s)}setDependencies(n,s,u){const p=this._tiles[n];p&&p.setDependencies(s,u)}reloadTilesForDependencies(n,s){for(const u in this._tiles)this._tiles[u].hasDependency(n,s)&&this._reloadTile(+u,"reloading");this._cache.filter(u=>!u.hasDependency(n,s))}_preloadTiles(n,s){const u=new Map,p=Array.isArray(n)?n:[n],g=this.map.painter.terrain,_=this.usedForTerrain&&g?g.getScaledDemTileSize():this._source.tileSize;for(const T of p){const D=T.coveringTiles({tileSize:_,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const I of D)u.set(I.key,I);this.usedForTerrain&&T.updateElevation(!1)}le(Array.from(u.values()),(T,D)=>{const I=new nx(T,this._source.tileSize*T.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(I,z=>{this._source.type==="raster-dem"&&I.dem&&this._backfillDEM(I),D(z,I)})},s)}}function sM(a,n){const s=Math.abs(2*a.wrap)-+(a.wrap<0),u=Math.abs(2*n.wrap)-+(n.wrap<0);return a.overscaledZ-n.overscaledZ||u-s||n.canonical.y-a.canonical.y||n.canonical.x-a.canonical.x}function lM(a){return a==="raster"||a==="image"||a==="video"}Ql.maxOverzooming=10,Ql.maxUnderzooming=3;class Jg{constructor(n,s,u){this._demTile=n,this._dem=this._demTile.dem,this._scale=s,this._offset=u}static create(n,s,u){const p=u||n.findDEMTileFor(s);if(!p||!p.dem)return;const g=p.dem,_=p.tileID,T=1<<s.canonical.z-_.canonical.z;return new Jg(p,p.tileSize/In/T,[(s.canonical.x/T-_.canonical.x)*g.dim,(s.canonical.y/T-_.canonical.y)*g.dim])}tileCoordToPixel(n,s){const u=s*this._scale+this._offset[1],p=Math.floor(n*this._scale+this._offset[0]),g=Math.floor(u);return new b(p,g)}getElevationAt(n,s,u,p){const g=n*this._scale+this._offset[0],_=s*this._scale+this._offset[1],T=Math.floor(g),D=Math.floor(_),I=this._dem;return p=!!p,u?yn(yn(I.get(T,D,p),I.get(T,D+1,p),_-D),yn(I.get(T+1,D,p),I.get(T+1,D+1,p),_-D),g-T):I.get(T,D,p)}getElevationAtPixel(n,s,u){return this._dem.get(n,s,!!u)}getMeterToDEM(n){return(1<<this._demTile.tileID.canonical.z)*Hu(1,n)*this._dem.stride}}class cM{constructor(n,s){this.tileID=n,this.x=n.canonical.x,this.y=n.canonical.y,this.z=n.canonical.z,this.grid=new da(In,16,0),this.featureIndexArray=new xi,this.promoteId=s}insert(n,s,u,p,g,_=0){const T=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(u,p,g,_);const D=this.grid;for(let I=0;I<s.length;I++){const z=s[I],B=[1/0,1/0,-1/0,-1/0];for(let N=0;N<z.length;N++){const W=z[N];B[0]=Math.min(B[0],W.x),B[1]=Math.min(B[1],W.y),B[2]=Math.max(B[2],W.x),B[3]=Math.max(B[3],W.y)}B[0]<In&&B[1]<In&&B[2]>=0&&B[3]>=0&&D.insert(T,B[0],B[1],B[2],B[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Kl.VectorTile(new Pp(this.rawTileData)).layers,this.sourceLayerCoder=new Xw(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const n in this.vtLayers)this.vtFeatures[n]=[]}return this.vtLayers}query(n,s,u,p){this.loadVTLayers();const g=n.params||{},_=ca(g.filter),T=n.tileResult,D=n.transform,I=T.bufferedTilespaceBounds,z=this.grid.query(I.min.x,I.min.y,I.max.x,I.max.y,(K,oe,ue,xe)=>Sb(T.bufferedTilespaceGeometry,K,oe,ue,xe));z.sort(kF);let B=null;D.elevation&&z.length>0&&(B=Jg.create(D.elevation,this.tileID));const N={};let W;for(let K=0;K<z.length;K++){const oe=z[K];if(oe===W)continue;W=oe;const ue=this.featureIndexArray.get(oe);let xe=null;this.loadMatchingFeature(N,ue,_,g.layers,g.availableImages,s,u,p,(Be,$e,Ze,Ye=0)=>(xe||(xe=Xa(Be,this.tileID.canonical,n.tileTransform)),$e.queryIntersectsFeature(T,Be,Ze,xe,this.z,n.transform,n.pixelPosMatrix,B,Ye)))}return N}loadMatchingFeature(n,s,u,p,g,_,T,D,I){const{featureIndex:z,bucketIndex:B,sourceLayerIndex:N,layoutVertexArrayOffset:W}=s,K=this.bucketLayerIDs[B];if(p&&!function(Be,$e){for(let Ze=0;Ze<Be.length;Ze++)if($e.indexOf(Be[Ze])>=0)return!0;return!1}(p,K))return;const oe=this.sourceLayerCoder.decode(N),ue=this.vtLayers[oe].feature(z);if(u.needGeometry){const Be=Xl(ue,!0);if(!u.filter(new ci(this.tileID.overscaledZ),Be,this.tileID.canonical))return}else if(!u.filter(new ci(this.tileID.overscaledZ),ue))return;const xe=this.getId(ue,oe);for(let Be=0;Be<K.length;Be++){const $e=K[Be];if(p&&p.indexOf($e)<0)continue;const Ze=_[$e];if(!Ze)continue;let Ye={};xe!==void 0&&D&&(Ye=D.getState(Ze.sourceLayer||"_geojsonTileLayer",xe));const Ke=me({},T[$e]);Ke.paint=uM(Ke.paint,Ze.paint,ue,Ye,g),Ke.layout=uM(Ke.layout,Ze.layout,ue,Ye,g);const ut=!I||I(ue,Ze,Ye,W);if(!ut)continue;const dt=new Zw(ue,this.z,this.x,this.y,xe);dt.layer=Ke;let xt=n[$e];xt===void 0&&(xt=n[$e]=[]),xt.push({featureIndex:z,feature:dt,intersectionZ:ut})}}lookupSymbolFeatures(n,s,u,p,g,_,T,D){const I={};this.loadVTLayers();const z=ca(g);for(const B of n)this.loadMatchingFeature(I,{bucketIndex:u,sourceLayerIndex:p,featureIndex:B,layoutVertexArrayOffset:0},z,_,T,D,s);return I}loadFeature(n){const{featureIndex:s,sourceLayerIndex:u}=n;this.loadVTLayers();const p=this.sourceLayerCoder.decode(u),g=this.vtFeatures[p];if(g[s])return g[s];const _=this.vtLayers[p].feature(s);return g[s]=_,_}hasLayer(n){for(const s of this.bucketLayerIDs)for(const u of s)if(n===u)return!0;return!1}getId(n,s){let u=n.id;return this.promoteId&&(u=n.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[s]],typeof u=="boolean"&&(u=Number(u))),u}}function uM(a,n,s,u,p){return Dt(a,(g,_)=>{const T=n instanceof C?n.get(_):null;return T&&T.evaluate?T.evaluate(s,u,p):T})}function kF(a,n){return n-a}$t(cM,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class hM{constructor(n){const s={},u=[];for(const T in n){const D=n[T],I=s[T]={};for(const z in D.glyphs){const B=D.glyphs[+z];if(!B||B.bitmap.width===0||B.bitmap.height===0)continue;const N=B.metrics.localGlyph?2:1,W={x:0,y:0,w:B.bitmap.width+2*N,h:B.bitmap.height+2*N};u.push(W),I[z]=W}}const{w:p,h:g}=Ov(u),_=new Za({width:p||1,height:g||1});for(const T in n){const D=n[T];for(const I in D.glyphs){const z=D.glyphs[+I];if(!z||z.bitmap.width===0||z.bitmap.height===0)continue;const B=s[T][I],N=z.metrics.localGlyph?2:1;Za.copy(z.bitmap,_,{x:0,y:0},{x:B.x+N,y:B.y+N},z.bitmap)}}this.image=_,this.positions=s}}$t(hM,"GlyphAtlas");class zF{constructor(n){this.tileID=new vr(n.tileID.overscaledZ,n.tileID.wrap,n.tileID.canonical.z,n.tileID.canonical.x,n.tileID.canonical.y),this.tileZoom=n.tileZoom,this.uid=n.uid,this.zoom=n.zoom,this.canonical=n.tileID.canonical,this.pixelRatio=n.pixelRatio,this.tileSize=n.tileSize,this.source=n.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=n.showCollisionBoxes,this.collectResourceTiming=!!n.collectResourceTiming,this.returnDependencies=!!n.returnDependencies,this.promoteId=n.promoteId,this.enableTerrain=!!n.enableTerrain,this.isSymbolTile=n.isSymbolTile,this.tileTransform=Jl(n.tileID.canonical,n.projection),this.projection=n.projection}parse(n,s,u,p,g){this.status="parsing",this.data=n,this.collisionBoxArray=new Uo;const _=new Xw(Object.keys(n.layers).sort()),T=new cM(this.tileID,this.promoteId);T.bucketLayerIDs=[];const D={},I=new Jv(256,256),z={featureIndex:T,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:I,availableImages:u},B=s.familiesBySource[this.source];for(const Ye in B){const Ke=n.layers[Ye];if(!Ke)continue;let ut=!1,dt=!1;for(const st of B[Ye])st[0].type==="symbol"?ut=!0:dt=!0;if(this.isSymbolTile===!0&&!ut||this.isSymbolTile===!1&&!dt)continue;Ke.version===1&&be(`Vector tile source "${this.source}" layer "${Ye}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const xt=_.encode(Ye),Et=[];for(let st=0;st<Ke.length;st++){const mt=Ke.feature(st),Pt=T.getId(mt,Ye);Et.push({feature:mt,id:Pt,index:st,sourceLayerIndex:xt})}for(const st of B[Ye]){const mt=st[0];this.isSymbolTile!==void 0&&mt.type==="symbol"!==this.isSymbolTile||mt.minzoom&&this.zoom<Math.floor(mt.minzoom)||mt.maxzoom&&this.zoom>=mt.maxzoom||mt.visibility!=="none"&&(sx(st,this.zoom,u),(D[mt.id]=mt.createBucket({index:T.bucketLayerIDs.length,layers:st,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:xt,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.name,availableImages:u})).populate(Et,z,this.tileID.canonical,this.tileTransform),T.bucketLayerIDs.push(st.map(Pt=>Pt.id)))}}let N,W,K,oe;I.trim();const ue={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},xe=Dt(z.glyphDependencies,Ye=>Object.keys(Ye).map(Number));Object.keys(xe).length?p.send("getGlyphs",{uid:this.uid,stacks:xe},(Ye,Ke)=>{N||(N=Ye,W=Ke,Ze.call(this))},void 0,!1,ue):W={};const Be=Object.keys(z.iconDependencies);Be.length?p.send("getImages",{icons:Be,source:this.source,tileID:this.tileID,type:"icons"},(Ye,Ke)=>{N||(N=Ye,K=Ke,Ze.call(this))},void 0,!1,ue):K={};const $e=Object.keys(z.patternDependencies);function Ze(){if(N)return g(N);if(W&&K&&oe){const Ye=new hM(W),Ke=new gw(K,oe);for(const ut in D){const dt=D[ut];dt instanceof Gs?(sx(dt.layers,this.zoom,u),cF(dt,W,Ye.positions,K,Ke.iconPositions,this.showCollisionBoxes,u,this.tileID.canonical,this.tileZoom,this.projection)):dt.hasPattern&&(dt instanceof Ng||dt instanceof Bg||dt instanceof Cp)&&(sx(dt.layers,this.zoom,u),dt.addFeatures(z,this.tileID.canonical,Ke.patternPositions,u,this.tileTransform))}this.status="done",g(null,{buckets:fe(D).filter(ut=>!ut.isEmpty()),featureIndex:T,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Ye.image,lineAtlas:I,imageAtlas:Ke,glyphMap:this.returnDependencies?W:null,iconMap:this.returnDependencies?K:null,glyphPositions:this.returnDependencies?Ye.positions:null})}}$e.length?p.send("getImages",{icons:$e,source:this.source,tileID:this.tileID,type:"patterns"},(Ye,Ke)=>{N||(N=Ye,oe=Ke,Ze.call(this))},void 0,!1,ue):oe={},Ze.call(this)}}function sx(a,n,s){const u=new ci(n);for(const p of a)p.recalculate(u,s)}class dM{constructor(n){this.entries={},this.scheduler=n}request(n,s,u,p){const g=this.entries[n]=this.entries[n]||{callbacks:[]};if(g.result){const[_,T]=g.result;return this.scheduler?this.scheduler.add(()=>{p(_,T)},s):p(_,T),()=>{}}return g.callbacks.push(p),g.cancel||(g.cancel=u((_,T)=>{g.result=[_,T];for(const D of g.callbacks)this.scheduler?this.scheduler.add(()=>{D(_,T)},s):D(_,T);setTimeout(()=>delete this.entries[n],3e3)})),()=>{g.result||(g.callbacks=g.callbacks.filter(_=>_!==p),g.callbacks.length||(g.cancel(),delete this.entries[n]))}}}function pM(a,n,s){const u=JSON.stringify(a.request);return a.data&&(this.deduped.entries[u]={result:[null,a.data]}),this.deduped.request(u,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom},p=>{const g=Re(a.request,(_,T,D,I)=>{_?p(_):T&&p(null,{vectorTile:s?void 0:new Kl.VectorTile(new Pp(T)),rawData:T,cacheControl:D,expires:I})});return()=>{g.cancel(),p()}},n)}const FF=ga(new Float32Array(16));class $s{constructor(n){this.name=n.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(n,s){return{x:0,y:0,z:0}}unproject(n,s){return new ti(0,0)}projectTilePoint(n,s,u){return{x:n,y:s,z:0}}locationPoint(n,s){return n._coordinatePoint(n.locationCoordinate(s),!1)}pixelsPerMeter(n,s){return Hu(1,n)*s}farthestPixelDistance(n){return function(s,u){const p=s.fovAboveCenter,g=s.elevation?s.elevation.getMinElevationBelowMSL()*u:0,_=(s._camera.position[2]*s.worldSize-g)/Math.cos(s._pitch),T=Math.sin(p)*_/Math.sin(Math.max(Math.PI/2-s._pitch-p,.01)),D=Math.sin(s._pitch)*T+_;return Math.min(1.01*D,_*(1/s._horizonShift))}(n,n.pixelsPerMeter)}pointCoordinate(n,s,u,p){const g=n.horizonLineFromTop(!1),_=new b(s,Math.max(g,u));return n.rayIntersectionCoordinate(n.pointRayIntersection(_,p))}createInversionMatrix(n,s){return FF}createTileMatrix(n,s,u){let p,g,_;const T=u.canonical,D=ga(new Float64Array(16));if(this.isReprojectedInTileSpace){const I=Jl(T,this);p=1,g=I.x+u.wrap*I.scale,_=I.y,Ns(D,D,[p/I.scale,p/I.scale,n.pixelsPerMeter/s])}else p=s/n.zoomScale(T.z),g=(T.x+Math.pow(2,T.z)*u.wrap)*p,_=T.y*p;return Zl(D,D,[g,_,0]),Ns(D,D,[p/In,p/In,1]),D}upVector(n,s,u){return[0,0,1]}upVectorScale(n,s,u){return{metersToTile:1,metersToLabelSpace:1}}}class BF extends $s{constructor(n){super(n),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(n,s){return{x:fp(n),y:ju(s),z:0}}unproject(n,s){const u=To(n),p=rr(s);return new ti(u,p)}}class OF extends $s{constructor(n){super(n),this.range=[4,7],this.center=n.center||[-96,37.5];const[s,u]=this.parallels=n.parallels||[29.5,45.5],p=Math.sin(F(s));this.n=(p+Math.sin(F(u)))/2,this.c=1+p*(2*this.n-p),this.r0=Math.sqrt(this.c)/this.n}project(n,s){const{n:u,c:p,r0:g}=this,_=F(n-this.center[0]),T=F(s),D=Math.sqrt(p-2*u*Math.sin(T))/u;return{x:D*Math.sin(_*u),y:D*Math.cos(_*u)-g,z:0}}unproject(n,s){const{n:u,c:p,r0:g}=this,_=g+s;let T=Math.atan2(n,Math.abs(_))*Math.sign(_);_*u<0&&(T-=Math.PI*Math.sign(n)*Math.sign(_));const D=F(this.center[0])*u;T=ie(T,-Math.PI-D,Math.PI-D);const I=V(T/u)+this.center[0],z=Math.asin(Q((p-(n*n+_*_)*u*u)/(2*u),-1,1)),B=Q(V(z),-85.051129,ma);return new ti(I,B)}}const Fp=1.340264,Bp=-.081106,Op=893e-6,Np=.003796,Qg=Math.sqrt(3)/2;class NF extends $s{project(n,s){s=s/180*Math.PI,n=n/180*Math.PI;const u=Math.asin(Qg*Math.sin(s)),p=u*u,g=p*p*p;return{x:.5*(n*Math.cos(u)/(Qg*(Fp+3*Bp*p+g*(7*Op+9*Np*p)))/Math.PI+.5),y:1-.5*(u*(Fp+Bp*p+g*(Op+Np*p))/Math.PI+1),z:0}}unproject(n,s){n=(2*n-.5)*Math.PI;let u=s=(2*(1-s)-1)*Math.PI,p=u*u,g=p*p*p;for(let z,B,N,W=0;W<12&&(B=u*(Fp+Bp*p+g*(Op+Np*p))-s,N=Fp+3*Bp*p+g*(7*Op+9*Np*p),z=B/N,u=Q(u-z,-Math.PI/3,Math.PI/3),p=u*u,g=p*p*p,!(Math.abs(z)<1e-12));++W);const _=Qg*n*(Fp+3*Bp*p+g*(7*Op+9*Np*p))/Math.cos(u),T=Math.asin(Math.sin(u)/Qg),D=Q(180*_/Math.PI,-180,180),I=Q(180*T/Math.PI,-85.051129,ma);return new ti(D,I)}}class UF extends $s{constructor(n){super(n),this.wrap=!0,this.supportsWorldCopies=!0}project(n,s){return{x:.5+n/360,y:.5-s/360,z:0}}unproject(n,s){const u=360*(n-.5),p=Q(360*(.5-s),-85.051129,ma);return new ti(u,p)}}const ah=Math.PI/2;function ey(a){return Math.tan((ah+a)/2)}class VF extends $s{constructor(n){super(n),this.center=n.center||[0,30];const[s,u]=this.parallels=n.parallels||[30,30],p=F(s),g=F(u),_=Math.cos(p);this.n=p===g?Math.sin(p):Math.log(_/Math.cos(g))/Math.log(ey(g)/ey(p)),this.f=_*Math.pow(ey(p),this.n)/this.n}project(n,s){s=F(s),n=F(n-this.center[0]);const u=1e-6,{n:p,f:g}=this;g>0?s<-ah+u&&(s=-ah+u):s>ah-u&&(s=ah-u);const _=g/Math.pow(ey(s),p),T=_*Math.sin(p*n),D=g-_*Math.cos(p*n);return{x:.5*(T/Math.PI+.5),y:1-.5*(D/Math.PI+.5),z:0}}unproject(n,s){n=(2*n-.5)*Math.PI,s=(2*(1-s)-.5)*Math.PI;const{n:u,f:p}=this,g=p-s,_=Math.sign(g),T=Math.sign(u)*Math.sqrt(n*n+g*g);let D=Math.atan2(n,Math.abs(g))*_;g*u<0&&(D-=Math.PI*Math.sign(n)*_);const I=Q(V(D/u)+this.center[0],-180,180),z=Q(V(2*Math.atan(Math.pow(p/T,1/u))-ah),-85.051129,ma);return new ti(I,z)}}const fM=F(ma);class GF extends $s{project(n,s){const u=(s=F(s))*s,p=u*u;return{x:.5*((n=F(n))*(.8707-.131979*u+p*(p*(.003971*u-.001529*p)-.013791))/Math.PI+.5),y:1-.5*(s*(1.007226+u*(.015085+p*(.028874*u-.044475-.005916*p)))/Math.PI+1),z:0}}unproject(n,s){n=(2*n-.5)*Math.PI;let u=s=(2*(1-s)-1)*Math.PI,p=25,g=0,_=u*u;do{_=u*u;const I=_*_;g=(u*(1.007226+_*(.015085+I*(.028874*_-.044475-.005916*I)))-s)/(1.007226+_*(.045255+I*(.259866*_-.311325-.06507600000000001*I))),u=Q(u-g,-fM,fM)}while(Math.abs(g)>1e-6&&--p>0);_=u*u;const T=Q(V(n/(.8707+_*(_*(_*_*_*(.003971-.001529*_)-.013791)-.131979))),-180,180),D=V(u);return new ti(T,D)}}const mM=F(ma);class WF extends $s{project(n,s){s=F(s),n=F(n);const u=Math.cos(s),p=2/Math.PI,g=Math.acos(u*Math.cos(n/2)),_=Math.sin(g)/g,T=.5*(n*p+2*u*Math.sin(n/2)/_)||0,D=.5*(s+Math.sin(s)/_)||0;return{x:.5*(T/Math.PI+.5),y:1-.5*(D/Math.PI+1),z:0}}unproject(n,s){let u=n=(2*n-.5)*Math.PI,p=s=(2*(1-s)-1)*Math.PI,g=25;const _=1e-6;let T=0,D=0;do{const I=Math.cos(p),z=Math.sin(p),B=2*z*I,N=z*z,W=I*I,K=Math.cos(u/2),oe=Math.sin(u/2),ue=2*K*oe,xe=oe*oe,Be=1-W*K*K,$e=Be?1/Be:0,Ze=Be?Math.acos(I*K)*Math.sqrt(1/Be):0,Ye=.5*(2*Ze*I*oe+2*u/Math.PI)-n,Ke=.5*(Ze*z+p)-s,ut=.5*$e*(W*xe+Ze*I*K*N)+1/Math.PI,dt=$e*(ue*B/4-Ze*z*oe),xt=.125*$e*(B*oe-Ze*z*W*ue),Et=.5*$e*(N*K+Ze*xe*I)+.5,st=dt*xt-Et*ut;T=(Ke*dt-Ye*Et)/st,D=(Ye*xt-Ke*ut)/st,u=Q(u-T,-Math.PI,Math.PI),p=Q(p-D,-mM,mM)}while((Math.abs(T)>_||Math.abs(D)>_)&&--g>0);return new ti(V(u),V(p))}}class gM extends $s{constructor(n){super(n),this.center=n.center||[0,0],this.parallels=n.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(F(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(n,s){const{scale:u,cosPhi:p}=this;return{x:F(n)*p*u+.5,y:-Math.sin(F(s))/p*u+.5,z:0}}unproject(n,s){const{scale:u,cosPhi:p}=this,g=-(s-.5)/u,_=Q(V((n-.5)/u)/p,-180,180),T=Math.asin(Q(g*p,-1,1)),D=Q(V(T),-85.051129,ma);return new ti(_,D)}}r.ARRAY_TYPE=Zr,r.AUTH_ERR_MSG=wn,r.Aabb=go,r.Actor=class{constructor(a,n,s){this.target=a,this.parent=n,this.mapId=s,this.callbacks={},this.cancelCallbacks={},At(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ke()?a:L,this.scheduler=new MF}send(a,n,s,u,p=!1,g){const _=Math.round(1e18*Math.random()).toString(36).substring(0,10);s&&(s.metadata=g,this.callbacks[_]=s);const T=Je(this.globalScope)?void 0:[];return this.target.postMessage({id:_,type:a,hasCallback:!!s,targetMapId:u,mustQueue:p,sourceMapId:this.mapId,data:Nl(n,T)},T),{cancel:()=>{s&&delete this.callbacks[_],this.target.postMessage({id:_,type:"<cancel>",targetMapId:u,sourceMapId:this.mapId})}}}receive(a){const n=a.data,s=n.id;if(s&&(!n.targetMapId||this.mapId===n.targetMapId))if(n.type==="<cancel>"){const u=this.cancelCallbacks[s];delete this.cancelCallbacks[s],u&&u.cancel()}else if(n.mustQueue||ke()){const u=this.callbacks[s];this.cancelCallbacks[s]=this.scheduler.add(()=>this.processTask(s,n),u&&u.metadata||{type:"message"})}else this.processTask(s,n)}processTask(a,n){if(n.type==="<response>"){const s=this.callbacks[a];delete this.callbacks[a],s&&(n.error?s(Ls(n.error)):s(null,Ls(n.data)))}else{const s=Je(this.globalScope)?void 0:[],u=n.hasCallback?(g,_)=>{delete this.cancelCallbacks[a],this.target.postMessage({id:a,type:"<response>",sourceMapId:this.mapId,error:g?Nl(g):null,data:Nl(_,s)},s)}:g=>{},p=Ls(n.data);if(this.parent[n.type])this.parent[n.type](n.sourceMapId,p,u);else if(this.parent.getWorkerSource){const g=n.type.split(".");this.parent.getWorkerSource(n.sourceMapId,g[0],p.source)[g[1]](p,u)}else u(new Error(`Could not find function ${n.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},r.CanonicalTileID=Zg,r.Color=Xn,r.ColorMode=xa,r.CullFaceMode=jo,r.DEMData=Kg,r.DataConstantProperty=S,r.DedupedRequest=dM,r.DepthMode=oh,r.EXTENT=In,r.Elevation=class{isDataAvailableAtPoint(a){const n=this._source();if(!n||a.y<0||a.y>1)return!1;const s=n.getSource().maxzoom,u=1<<s,p=Math.floor(a.x),g=Math.floor((a.x-p)*u),_=Math.floor(a.y*u),T=this.findDEMTileFor(new vr(s,p,s,g,_));return!(!T||!T.dem)}getAtPointOrZero(a,n=0){return this.getAtPoint(a,n)||0}getAtPoint(a,n,s=!0){n==null&&(n=null);const u=this._source();if(!u||a.y<0||a.y>1)return n;const p=u.getSource().maxzoom,g=1<<p,_=Math.floor(a.x),T=a.x-_,D=new vr(p,_,p,Math.floor(T*g),Math.floor(a.y*g)),I=this.findDEMTileFor(D);if(!I||!I.dem)return n;const z=I.dem,B=1<<I.tileID.canonical.z,N=(T*B-I.tileID.canonical.x)*z.dim,W=(a.y*B-I.tileID.canonical.y)*z.dim,K=Math.floor(N),oe=Math.floor(W);return(s?this.exaggeration():1)*yn(yn(z.get(K,oe),z.get(K,oe+1),W-oe),yn(z.get(K+1,oe),z.get(K+1,oe+1),W-oe),N-K)}getAtTileOffset(a,n,s){const u=1<<a.canonical.z;return this.getAtPointOrZero(new Dg(a.wrap+(a.canonical.x+n/In)/u,(a.canonical.y+s/In)/u))}getAtTileOffsetFunc(a,n,s,u){return p=>{const g=this.getAtTileOffset(a,p.x,p.y),_=u.upVector(a.canonical,p.x,p.y);return gp(_,_,g*u.upVectorScale(a.canonical,n,s).metersToTile),_}}getForTilePoints(a,n,s,u){const p=Jg.create(this,a,u);return!!p&&(n.forEach(g=>{g[2]=this.exaggeration()*p.getElevationAt(g[0],g[1],s)}),!0)}getMinMaxForTile(a){const n=this.findDEMTileFor(a);if(!n||!n.dem)return null;const s=n.dem.tree,u=n.tileID,p=1<<a.canonical.z-u.canonical.z;let g=a.canonical.x/p-u.canonical.x,_=a.canonical.y/p-u.canonical.y,T=0;for(let D=0;D<a.canonical.z-u.canonical.z&&!s.leaves[T];D++){g*=2,_*=2;const I=2*Math.floor(_)+Math.floor(g);T=s.childOffsets[T]+I,g%=1,_%=1}return{min:this.exaggeration()*s.minimums[T],max:this.exaggeration()*s.maximums[T]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(a,n,s){throw new Error("Pure virtual method called.")}pointCoordinate(a){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(a){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}},r.ErrorEvent=re,r.EvaluationParameters=ci,r.Event=Y,r.Evented=Fe,r.FillExtrusionBucket=Cp,r.Frustum=Av,r.GLOBE_RADIUS=rh,r.GlobeSharedBuffers=class{constructor(a){this._createGrid(a),this._createPoles(a),this._createAtmosphere(a)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const a of this._poleSegments)a.destroy();this._gridSegments.destroy(),this.atmosphereVertexBuffer.destroy(),this.atmosphereIndexBuffer.destroy(),this.atmosphereSegments.destroy(),this._wireframeIndexBuffer&&(this._wireframeIndexBuffer.destroy(),this._wireframeSegments.destroy())}_createGrid(a){const n=new De,s=new qt,u=65;for(let p=0;p<u;p++)for(let g=0;g<u;g++)n.emplaceBack(g,p);for(let p=0;p<64;p++)for(let g=0;g<64;g++){const _=p*u+g;s.emplaceBack(_+1,_,_+u),s.emplaceBack(_+u,_+u+1,_+1)}this._gridBuffer=a.createVertexBuffer(n,Rp.members),this._gridIndexBuffer=a.createIndexBuffer(s,!0),this._gridSegments=Ei.simpleSegment(0,0,4225,8192)}_createPoles(a){const n=new qt;for(let p=0;p<=64;p++)n.emplaceBack(0,p+1,p+2);this._poleIndexBuffer=a.createIndexBuffer(n,!0);const s=new xn,u=new xn;this._poleSegments=[];for(let p=0,g=0;p<5;p++){const _=1<<p,T=512*_/Math.PI/2,D=360/_;s.emplaceBack(0,-T,0,0,0,.5,0),u.emplaceBack(0,-T,0,0,0,.5,1);for(let I=0;I<=64;I++){const z=I/64,B=yn(0,D,z),[N,W,K]=Uw(PF,SF,B,T);s.emplaceBack(N,W,K,0,0,z,0),u.emplaceBack(N,W,K,0,0,z,1)}this._poleSegments.push(Ei.simpleSegment(g,0,66,64)),g+=66}this._poleNorthVertexBuffer=a.createVertexBuffer(s,Ow,!1),this._poleSouthVertexBuffer=a.createVertexBuffer(u,Ow,!1)}_createAtmosphere(a){const n=new zn;n.emplaceBack(-1,1,1,0,0),n.emplaceBack(1,1,1,1,0),n.emplaceBack(1,-1,1,1,1),n.emplaceBack(-1,-1,1,0,1);const s=new qt;s.emplaceBack(0,1,2),s.emplaceBack(2,3,0),this.atmosphereVertexBuffer=a.createVertexBuffer(n,EF.members),this.atmosphereIndexBuffer=a.createIndexBuffer(s),this.atmosphereSegments=Ei.simpleSegment(0,0,4,2)}getGridBuffers(){return[this._gridBuffer,this._gridIndexBuffer,this._gridSegments]}getPoleBuffers(a){return[this._poleNorthVertexBuffer,this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[a]]}getWirefameBuffers(a){if(!this._wireframeSegments){const n=new Mn,s=64,u=s+1;for(let p=0;p<s;p++)for(let g=0;g<s;g++){const _=p*u+g;n.emplaceBack(_,_+1),n.emplaceBack(_,_+u),n.emplaceBack(_,_+u+1)}this._wireframeIndexBuffer=a.createIndexBuffer(n),this._wireframeSegments=Ei.simpleSegment(0,0,s*s,n.length)}return[this._gridBuffer,this._wireframeIndexBuffer,this._wireframeSegments]}},r.GlyphManager=nh,r.ImagePosition=Nv,r.LineAtlas=Jv,r.LngLat=ti,r.LngLatBounds=Os,r.LocalGlyphMode=Wv,r.MAX_MERCATOR_LATITUDE=ma,r.MercatorCoordinate=Dg,r.ONE_EM=or,r.OverscaledTileID=vr,r.Properties=Z,r.RGBAImage=Yr,r.Ray=class{constructor(a,n){this.pos=a,this.dir=n}intersectsPlane(a,n,s){const u=_p(n,this.dir);if(Math.abs(u)<1e-6)return!1;const p=((a[0]-this.pos[0])*n[0]+(a[1]-this.pos[1])*n[1]+(a[2]-this.pos[2])*n[2])/u;return s[0]=this.pos[0]+this.dir[0]*p,s[1]=this.pos[1]+this.dir[1]*p,s[2]=this.pos[2]+this.dir[2]*p,!0}closestPointOnSphere(a,n,s){if(function(N,W){var K=N[0],oe=N[1],ue=N[2],xe=W[0],Be=W[1],$e=W[2];return Math.abs(K-xe)<=vv*Math.max(1,Math.abs(K),Math.abs(xe))&&Math.abs(oe-Be)<=vv*Math.max(1,Math.abs(oe),Math.abs(Be))&&Math.abs(ue-$e)<=vv*Math.max(1,Math.abs(ue),Math.abs($e))}(this.pos,a)||n===0)return s[0]=s[1]=s[2]=0,!1;const[u,p,g]=this.dir,_=this.pos[0]-a[0],T=this.pos[1]-a[1],D=this.pos[2]-a[2],I=u*u+p*p+g*g,z=2*(_*u+T*p+D*g),B=z*z-4*I*(_*_+T*T+D*D-n*n);if(B<0){const N=Math.max(-z/2,0),W=_+u*N,K=T+p*N,oe=D+g*N,ue=Math.hypot(W,K,oe);return s[0]=W*n/ue,s[1]=K*n/ue,s[2]=oe*n/ue,!1}{const N=(-z-Math.sqrt(B))/(2*I);if(N<0){const W=Math.hypot(_,T,D);return s[0]=_*n/W,s[1]=T*n/W,s[2]=D*n/W,!1}return s[0]=_+u*N,s[1]=T+p*N,s[2]=D+g*N,!0}}},r.RequestManager=class{constructor(a,n,s){this._transformRequestFn=a,this._customAccessToken=n,this._silenceAuthErrors=!!s,this._createSkuToken()}_createSkuToken(){const a=function(){let n="";for(let s=0;s<10;s++)n+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",pn,n].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=a.token,this._skuTokenExpiresAt=a.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(a,n){return this._transformRequestFn&&this._transformRequestFn(a,n)||{url:a}}normalizeStyleURL(a,n){if(!cn(a))return a;const s=Xt(a);return s.path=`/styles/v1${s.path}`,this._makeAPIURL(s,this._customAccessToken||n)}normalizeGlyphsURL(a,n){if(!cn(a))return a;const s=Xt(a);return s.path=`/fonts/v1${s.path}`,this._makeAPIURL(s,this._customAccessToken||n)}normalizeSourceURL(a,n){if(!cn(a))return a;const s=Xt(a);return s.path=`/v4/${s.authority}.json`,s.params.push("secure"),this._makeAPIURL(s,this._customAccessToken||n)}normalizeSpriteURL(a,n,s,u){const p=Xt(a);return cn(a)?(p.path=`/styles/v1${p.path}/sprite${n}${s}`,this._makeAPIURL(p,this._customAccessToken||u)):(p.path+=`${n}${s}`,Xe(p))}normalizeTileURL(a,n,s){if(this._isSkuTokenExpired()&&this._createSkuToken(),a&&!cn(a))return a;const u=Xt(a);u.path=u.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${n||s&&u.authority!=="raster"&&s===512?"@2x":""}${Me.supported?".webp":"$1"}`),u.authority==="raster"?u.path=`/${pe.RASTER_URL_PREFIX}${u.path}`:(u.path=u.path.replace(/^.+\/v4\//,"/"),u.path=`/${pe.TILE_URL_VERSION}${u.path}`);const p=this._customAccessToken||function(g){for(const _ of g){const T=_.match(/^access_token=(.*)$/);if(T)return T[1]}return null}(u.params)||pe.ACCESS_TOKEN;return pe.REQUIRE_ACCESS_TOKEN&&p&&this._skuToken&&u.params.push(`sku=${this._skuToken}`),this._makeAPIURL(u,p)}canonicalizeTileURL(a,n){const s=Xt(a);if(!s.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!s.path.match(/\.[\w]+$/))return a;let u="mapbox://";s.path.match(/^\/raster\/v1\//)?u+=`raster/${s.path.replace(`/${pe.RASTER_URL_PREFIX}/`,"")}`:u+=`tiles/${s.path.replace(`/${pe.TILE_URL_VERSION}/`,"")}`;let p=s.params;return n&&(p=p.filter(g=>!g.match(/^access_token=/))),p.length&&(u+=`?${p.join("&")}`),u}canonicalizeTileset(a,n){const s=!!n&&cn(n),u=[];for(const p of a.tiles||[])Wt(p)?u.push(this.canonicalizeTileURL(p,s)):u.push(p);return u}_makeAPIURL(a,n){const s="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",u=Xt(pe.API_URL);if(a.protocol=u.protocol,a.authority=u.authority,a.protocol==="http"){const p=a.params.indexOf("secure");p>=0&&a.params.splice(p,1)}if(u.path!=="/"&&(a.path=`${u.path}${a.path}`),!pe.REQUIRE_ACCESS_TOKEN)return Xe(a);if(n=n||pe.ACCESS_TOKEN,!this._silenceAuthErrors){if(!n)throw new Error(`An API access token is required to use Mapbox GL. ${s}`);if(n[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${s}`)}return a.params=a.params.filter(p=>p.indexOf("access_token")===-1),a.params.push(`access_token=${n||""}`),Xe(a)}},r.ResourceType=we,r.SegmentVector=Ei,r.SourceCache=Ql,r.StencilMode=rx,r.StructArrayLayout1ui2=$n,r.StructArrayLayout2f1f2i16=Jt,r.StructArrayLayout2i4=De,r.StructArrayLayout2ui4=Mn,r.StructArrayLayout3f12=kt,r.StructArrayLayout3ui6=qt,r.StructArrayLayout4i8=ze,r.Texture=Ip,r.Tile=nx,r.Transitionable=m,r.Uniform1f=Cg,r.Uniform1i=class extends $a{constructor(a,n){super(a,n),this.current=0}set(a){this.current!==a&&(this.current=a,this.gl.uniform1i(this.location,a))}},r.Uniform2f=class extends $a{constructor(a,n){super(a,n),this.current=[0,0]}set(a){a[0]===this.current[0]&&a[1]===this.current[1]||(this.current=a,this.gl.uniform2f(this.location,a[0],a[1]))}},r.Uniform3f=class extends $a{constructor(a,n){super(a,n),this.current=[0,0,0]}set(a){a[0]===this.current[0]&&a[1]===this.current[1]&&a[2]===this.current[2]||(this.current=a,this.gl.uniform3f(this.location,a[0],a[1],a[2]))}},r.Uniform4f=xb,r.UniformColor=bb,r.UniformMatrix2f=class extends $a{constructor(a,n){super(a,n),this.current=Ek}set(a){for(let n=0;n<4;n++)if(a[n]!==this.current[n]){this.current=a,this.gl.uniformMatrix2fv(this.location,!1,a);break}}},r.UniformMatrix3f=class extends $a{constructor(a,n){super(a,n),this.current=Tk}set(a){for(let n=0;n<9;n++)if(a[n]!==this.current[n]){this.current=a,this.gl.uniformMatrix3fv(this.location,!1,a);break}}},r.UniformMatrix4f=class extends $a{constructor(a,n){super(a,n),this.current=Mk}set(a){if(a[12]!==this.current[12]||a[0]!==this.current[0])return this.current=a,void this.gl.uniformMatrix4fv(this.location,!1,a);for(let n=1;n<16;n++)if(a[n]!==this.current[n]){this.current=a,this.gl.uniformMatrix4fv(this.location,!1,a);break}}},r.UnwrappedTileID=qw,r.ValidationError=jt,r.VectorTileWorkerSource=class extends Fe{constructor(a,n,s,u,p){super(),this.actor=a,this.layerIndex=n,this.availableImages=s,this.loadVectorData=p||pM,this.loading={},this.loaded={},this.deduped=new dM(a.scheduler),this.isSpriteLoaded=u,this.scheduler=a.scheduler}loadTile(a,n){const s=a.uid,u=a&&a.request,p=u&&u.collectResourceTiming,g=this.loading[s]=new zF(a);g.abort=this.loadVectorData(a,(_,T)=>{const D=!this.loading[s];if(delete this.loading[s],D||_||!T)return g.status="done",D||(this.loaded[s]=g),n(_);const I=T.rawData,z={};T.expires&&(z.expires=T.expires),T.cacheControl&&(z.cacheControl=T.cacheControl),g.vectorTile=T.vectorTile||new Kl.VectorTile(new Pp(I));const B=()=>{g.parse(g.vectorTile,this.layerIndex,this.availableImages,this.actor,(N,W)=>{if(N||!W)return n(N);const K={};if(p){const oe=Bw(u);oe.length>0&&(K.resourceTiming=JSON.parse(JSON.stringify(oe)))}n(null,me({rawTileData:I.slice(0)},W,z,K))})};this.isSpriteLoaded?B():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(B,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom}):B()}),this.loaded=this.loaded||{},this.loaded[s]=g})}reloadTile(a,n){const s=this.loaded,u=a.uid,p=this;if(s&&s[u]){const g=s[u];g.showCollisionBoxes=a.showCollisionBoxes,g.enableTerrain=!!a.enableTerrain,g.projection=a.projection,g.tileTransform=Jl(a.tileID.canonical,a.projection);const _=(T,D)=>{const I=g.reloadCallback;I&&(delete g.reloadCallback,g.parse(g.vectorTile,p.layerIndex,this.availableImages,p.actor,I)),n(T,D)};g.status==="parsing"?g.reloadCallback=_:g.status==="done"&&(g.vectorTile?g.parse(g.vectorTile,this.layerIndex,this.availableImages,this.actor,_):_())}}abortTile(a,n){const s=a.uid,u=this.loading[s];u&&(u.abort&&u.abort(),delete this.loading[s]),n()}removeTile(a,n){const s=this.loaded,u=a.uid;s&&s[u]&&delete s[u],n()}},r.WritingMode=yo,r.ZoomHistory=ep,r.add=Fb,r.addDynamicAttributes=qv,r.adjoint=function(a,n){var s=n[0],u=n[1],p=n[2],g=n[3],_=n[4],T=n[5],D=n[6],I=n[7],z=n[8];return a[0]=_*z-T*I,a[1]=p*I-u*z,a[2]=u*T-p*_,a[3]=T*D-g*z,a[4]=s*z-p*D,a[5]=p*g-s*T,a[6]=g*I-_*D,a[7]=u*D-s*I,a[8]=s*_-u*g,a},r.asyncAll=le,r.bezier=ne,r.bindAll=At,r.boundsAttributes=Kw,r.bufferConvexPolygon=function(a,n){const s=[];for(let u=0;u<a.length;u++){const p=ie(u-1,-1,a.length-1),g=ie(u+1,-1,a.length-1),_=a[u],T=a[g],D=a[p].sub(_).unit(),I=T.sub(_).unit(),z=I.angleWithSep(D.x,D.y),B=D.add(I).unit().mult(-1*n/Math.sin(z/2));s.push(_.add(B))}return s},r.cacheEntryPossiblyAdded=function(a){Ar++,Ar>jr&&(a.getActor().send("enforceCacheSizeLimit",_i),Ar=0)},r.calculateGlobeLabelMatrix=function(a,n){const{lng:s,lat:u}=a._center,p=Ww(0,0,a.worldSize/a._projectionScaler,s,u);return xv(p,p,function(g){const _=ga(new Float64Array(16)),T=1/tx(g);return Zl(_,_,g.min),Ns(_,_,[T,T,T]),_}(kp(n)))},r.calculateGlobeMatrix=jw,r.calculateGlobeMercatorMatrix=function(a){const n=a.worldSize,s=a.point,u=Hu(1,a.center.lat)*n,p=a.pixelsPerMeter,g=n/(u/a.pixelsPerMeter),_=ga(new Float64Array(16));return Zl(_,_,[s.x,s.y,0]),Ns(_,_,[g,g,p]),Float32Array.from(_)},r.circumferenceAtLatitude=pv,r.clamp=Q,r.clearTileCache=function(a){const n=L.caches.delete(Di);a&&n.catch(a).then(()=>a())},r.clipLine=Dw,r.clone=function(a){var n=new Zr(16);return n[0]=a[0],n[1]=a[1],n[2]=a[2],n[3]=a[3],n[4]=a[4],n[5]=a[5],n[6]=a[6],n[7]=a[7],n[8]=a[8],n[9]=a[9],n[10]=a[10],n[11]=a[11],n[12]=a[12],n[13]=a[13],n[14]=a[14],n[15]=a[15],n},r.clone$1=Nt,r.collisionCircleLayout=zz,r.config=pe,r.conjugate=function(a,n){return a[0]=-n[0],a[1]=-n[1],a[2]=-n[2],a[3]=n[3],a},r.create=function(){var a=new Zr(16);return Zr!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=0,a[12]=0,a[13]=0,a[14]=0),a[0]=1,a[5]=1,a[10]=1,a[15]=1,a},r.create$1=Rb,r.createExpression=Ll,r.createLayout=Le,r.createStyleLayer=function(a){return a.type==="custom"?new _F(a):new xF[a.type](a)},r.cross=Nb,r.degToRad=F,r.div=function(a,n,s){return a[0]=n[0]/s[0],a[1]=n[1]/s[1],a[2]=n[2]/s[2],a},r.dot=_p,r.earthRadius=dv,r.ease=H,r.easeCubicInOut=J,r.emitValidationErrors=ag,r.endsWith=yt,r.enforceCacheSizeLimit=function(a){zi(),ei&&ei.then(n=>{n.keys().then(s=>{for(let u=0;u<s.length-a;u++)n.delete(s[u])})})},r.evaluateSizeForFeature=Ug,r.evaluateSizeForZoom=Ju,r.evaluateVariableOffset=Rw,r.evented=up,r.exactEquals=function(a,n){return a[0]===n[0]&&a[1]===n[1]&&a[2]===n[2]&&a[3]===n[3]},r.exactEquals$1=function(a,n){return a[0]===n[0]&&a[1]===n[1]&&a[2]===n[2]},r.exported=wt,r.exported$1=Me,r.extend=me,r.extend$1=Tt,r.filterObject=It,r.fromMat4=function(a,n){return a[0]=n[0],a[1]=n[1],a[2]=n[2],a[3]=n[4],a[4]=n[5],a[5]=n[6],a[6]=n[8],a[7]=n[9],a[8]=n[10],a},r.fromQuat=function(a,n){var s=n[0],u=n[1],p=n[2],g=n[3],_=s+s,T=u+u,D=p+p,I=s*_,z=u*_,B=u*T,N=p*_,W=p*T,K=p*D,oe=g*_,ue=g*T,xe=g*D;return a[0]=1-B-K,a[1]=z+xe,a[2]=N-ue,a[3]=0,a[4]=z-xe,a[5]=1-I-K,a[6]=W+oe,a[7]=0,a[8]=N+ue,a[9]=W-oe,a[10]=1-I-B,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},r.fromRotation=function(a,n){var s=Math.sin(n),u=Math.cos(n);return a[0]=u,a[1]=s,a[2]=0,a[3]=-s,a[4]=u,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},r.fromScaling=function(a,n){return a[0]=n[0],a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=n[1],a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=n[2],a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},r.furthestTileCorner=function(a){const n=Math.round((a+45+360)%360/90)%4;return j[n]},r.getAABBPointSquareDist=function(a,n,s){let u=0;for(let p=0;p<2;++p){const g=s?s[p]:0;a[p]>g&&(u+=(a[p]-g)*(a[p]-g)),n[p]<g&&(u+=(g-n[p])*(g-n[p]))}return u},r.getAnchorAlignment=Gv,r.getAnchorJustification=Hv,r.getBounds=function(a){let n=1/0,s=1/0,u=-1/0,p=-1/0;for(const g of a)n=Math.min(n,g.x),s=Math.min(s,g.y),u=Math.max(u,g.x),p=Math.max(p,g.y);return{min:new b(n,s),max:new b(u,p)}},r.getColumn=function(a,n){return[a[4*n],a[4*n+1],a[4*n+2],a[4*n+3]]},r.getGridMatrix=function(a,n){const[s,u]=n,p=.015625;return[0,(u[1]-s[1])*p,1<<a.z,(u[0]-s[0])*p,0,a.y,s[0],s[1],p]},r.getImage=Vt,r.getJSON=function(a,n){return ye(me(a,{type:"json"}),n)},r.getMapSessionAPI=ji,r.getPerformanceMeasurement=Bw,r.getProjection=function(a){const n=a.parallels,s=!!n&&Math.abs(n[0]+n[1])<.01;switch(a.name){case"mercator":return new BF(a);case"equirectangular":return new UF(a);case"naturalEarth":return new GF(a);case"equalEarth":return new NF(a);case"winkelTripel":return new WF(a);case"albers":return s?new gM(a):new OF(a);case"lambertConformalConic":return s?new gM(a):new VF(a)}throw new Error(`Invalid projection name: ${a.name}`)},r.getRTLTextPluginStatus=Gu,r.getReferrer=ee,r.getTilePoint=function(a,{x:n,y:s},u=0){return new b(((n-u)*a.scale-a.x)*In,(s*a.scale-a.y)*In)},r.getTileVec3=function(a,n,s=0){return mp(((n.x-s)*a.scale-a.x)*In,(n.y*a.scale-a.y)*In,Tb(n.z,n.y))},r.getVideo=function(a,n){const s=L.document.createElement("video");s.muted=!0,s.onloadstart=function(){n(null,s)};for(let u=0;u<a.length;u++){const p=L.document.createElement("source");tt(a[u])||(s.crossOrigin="Anonymous"),p.src=a[u],s.appendChild(p)}return{cancel:()=>{}}},r.globeECEFOrigin=function(a,n){const s=[0,0,0];return Yl(s,s,Gw(kp(n.canonical))),Yl(s,s,a),s},r.globePixelsToTileUnits=function(a,n){return In/(512*Math.pow(2,a))*tx(kp(n))},r.globePoleMatrixForTile=function(a,n,s){const u=ga(new Float64Array(16)),p=1<<a,g=360*(n/p-.5),_=s.point,T=s.worldSize/(s.tileSize*p);return Zl(u,u,[_.x,_.y,-s.worldSize/Math.PI/2]),Ns(u,u,[T,T,T]),bv(u,u,F(-s._center.lat)),wv(u,u,F(-s._center.lng+g)),Float32Array.from(u)},r.globeTileLatLngCorners=ex,r.globeToMercatorTransition=function(a){return ae(5,6,a)},r.identity=ga,r.identity$1=Gb,r.invert=function(a,n){var s=n[0],u=n[1],p=n[2],g=n[3],_=n[4],T=n[5],D=n[6],I=n[7],z=n[8],B=n[9],N=n[10],W=n[11],K=n[12],oe=n[13],ue=n[14],xe=n[15],Be=s*T-u*_,$e=s*D-p*_,Ze=s*I-g*_,Ye=u*D-p*T,Ke=u*I-g*T,ut=p*I-g*D,dt=z*oe-B*K,xt=z*ue-N*K,Et=z*xe-W*K,st=B*ue-N*oe,mt=B*xe-W*oe,Pt=N*xe-W*ue,Bt=Be*Pt-$e*mt+Ze*st+Ye*Et-Ke*xt+ut*dt;return Bt?(a[0]=(T*Pt-D*mt+I*st)*(Bt=1/Bt),a[1]=(p*mt-u*Pt-g*st)*Bt,a[2]=(oe*ut-ue*Ke+xe*Ye)*Bt,a[3]=(N*Ke-B*ut-W*Ye)*Bt,a[4]=(D*Et-_*Pt-I*xt)*Bt,a[5]=(s*Pt-p*Et+g*xt)*Bt,a[6]=(ue*Ze-K*ut-xe*$e)*Bt,a[7]=(z*ut-N*Ze+W*$e)*Bt,a[8]=(_*mt-T*Et+I*dt)*Bt,a[9]=(u*Et-s*mt-g*dt)*Bt,a[10]=(K*Ke-oe*Ze+xe*Be)*Bt,a[11]=(B*Ze-z*Ke-W*Be)*Bt,a[12]=(T*xt-_*st-D*dt)*Bt,a[13]=(s*st-u*xt+p*dt)*Bt,a[14]=(oe*$e-K*Ye-ue*Be)*Bt,a[15]=(z*Ye-B*$e+N*Be)*Bt,a):null},r.isMapAuthenticated=function(a){return Nn.has(a)},r.isMapboxURL=cn,r.isSafariWithAntialiasingBug=function(a){const n=a.navigator?a.navigator.userAgent:null;return!!Je(a)&&n&&(n.match("Version/15.4")||n.match("Version/15.5")||n.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},r.latFromMercatorY=rr,r.len=Gk,r.length=zb,r.length$1=function(a){return Math.hypot(a[0],a[1],a[2],a[3])},r.loadVectorTile=pM,r.makeRequest=ye,r.mercatorXfromLng=fp,r.mercatorYfromLat=ju,r.mercatorZfromAltitude=Hu,r.mul=Uk,r.mul$1=Vk,r.multiply=function(a,n,s){var u=n[0],p=n[1],g=n[2],_=n[3],T=n[4],D=n[5],I=n[6],z=n[7],B=n[8],N=s[0],W=s[1],K=s[2],oe=s[3],ue=s[4],xe=s[5],Be=s[6],$e=s[7],Ze=s[8];return a[0]=N*u+W*_+K*I,a[1]=N*p+W*T+K*z,a[2]=N*g+W*D+K*B,a[3]=oe*u+ue*_+xe*I,a[4]=oe*p+ue*T+xe*z,a[5]=oe*g+ue*D+xe*B,a[6]=Be*u+$e*_+Ze*I,a[7]=Be*p+$e*T+Ze*z,a[8]=Be*g+$e*D+Ze*B,a},r.multiply$1=xv,r.multiply$2=Ob,r.nextPowerOfTwo=He,r.normalize=yp,r.normalize$1=function(a,n){var s=n[0],u=n[1],p=n[2],g=n[3],_=s*s+u*u+p*p+g*g;return _>0&&(_=1/Math.sqrt(_)),a[0]=s*_,a[1]=u*_,a[2]=p*_,a[3]=g*_,a},r.number=yn,r.ortho=function(a,n,s,u,p,g,_){var T=1/(n-s),D=1/(u-p),I=1/(g-_);return a[0]=-2*T,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=-2*D,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=2*I,a[11]=0,a[12]=(n+s)*T,a[13]=(p+u)*D,a[14]=(_+g)*I,a[15]=1,a},r.pbf=Pp,r.perspective=function(a,n,s,u,p){var g,_=1/Math.tan(n/2);return a[0]=_/s,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=_,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,p!=null&&p!==1/0?(a[10]=(p+u)*(g=1/(u-p)),a[14]=2*p*u*g):(a[10]=-1,a[14]=-2*u),a},r.pick=function(a,n){const s={};for(let u=0;u<n.length;u++){const p=n[u];p in a&&(s[p]=a[p])}return s},r.plugin=qr,r.pointGeometry=b,r.polygonIntersectsBox=Sb,r.polygonIntersectsPolygon=Cb,r.polygonizeBounds=function(a,n,s=0,u=!0){const p=new b(s,s),g=a.sub(p),_=n.add(p),T=[g,new b(_.x,g.y),_,new b(g.x,_.y)];return u&&T.push(g),T},r.posAttributes=Rp,r.postMapLoadEvent=Gn,r.postTurnstileEvent=fn,r.potpack=Ov,r.prevPowerOfTwo=function(a){return a<=1?1:Math.pow(2,Math.floor(Math.log(a)/Math.LN2))},r.radToDeg=V,r.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],r.registerForPluginStateChange=function(a){return a({pluginStatus:_r,pluginURL:Rr}),up.on("pluginStateChange",a),a},r.removeAuthState=function(a){Nn.delete(a)},r.renderColorRamp=Pv,r.rotateX=bv,r.rotateX$1=Wb,r.rotateY=wv,r.rotateZ=function(a,n,s){var u=Math.sin(s),p=Math.cos(s),g=n[0],_=n[1],T=n[2],D=n[3],I=n[4],z=n[5],B=n[6],N=n[7];return n!==a&&(a[8]=n[8],a[9]=n[9],a[10]=n[10],a[11]=n[11],a[12]=n[12],a[13]=n[13],a[14]=n[14],a[15]=n[15]),a[0]=g*p+I*u,a[1]=_*p+z*u,a[2]=T*p+B*u,a[3]=D*p+N*u,a[4]=I*p-g*u,a[5]=z*p-_*u,a[6]=B*p-T*u,a[7]=N*p-D*u,a},r.rotateZ$1=function(a,n,s){s*=.5;var u=n[0],p=n[1],g=n[2],_=n[3],T=Math.sin(s),D=Math.cos(s);return a[0]=u*D+p*T,a[1]=p*D-u*T,a[2]=g*D+_*T,a[3]=_*D-g*T,a},r.scale=Ns,r.scale$1=function(a,n,s){return a[0]=n[0]*s,a[1]=n[1]*s,a[2]=n[2]*s,a[3]=n[3]*s,a},r.scale$2=gp,r.scaleAndAdd=Cv,r.setCacheLimits=function(a,n){_i=a,jr=n},r.setColumn=function(a,n,s){a[4*n+0]=s[0],a[4*n+1]=s[1],a[4*n+2]=s[2],a[4*n+3]=s[3]},r.setRTLTextPlugin=function(a,n,s=!1){if(_r===sp||_r===Wl||_r===lp)throw new Error("setRTLTextPlugin cannot be called multiple times.");Rr=wt.resolveURL(a),_r=sp,cp=n,ja(),s||Rs()},r.smoothstep=ae,r.spec=Te,r.storeAuthState=function(a,n){n?Nn.add(a):Nn.delete(a)},r.sub=Xu,r.subtract=Bb,r.symbolSize=Fz,r.tileAABB=function(a,n,s,u,p,g,_,T,D){if(D.name==="globe")return DF(a,n,new Zg(s,u,p));const I=Jl({z:s,x:u,y:p},D);return new go([(g+I.x/I.scale)*n,n*(I.y/I.scale),_],[(g+I.x2/I.scale)*n,n*(I.y2/I.scale),T])},r.tileTransform=Jl,r.transformMat3=function(a,n,s){var u=n[0],p=n[1],g=n[2];return a[0]=u*s[0]+p*s[3]+g*s[6],a[1]=u*s[1]+p*s[4]+g*s[7],a[2]=u*s[2]+p*s[5]+g*s[8],a},r.transformMat4=Yl,r.transformMat4$1=Zu,r.transformQuat=Ub,r.translate=Zl,r.transpose=function(a,n){if(a===n){var s=n[1],u=n[2],p=n[5];a[1]=n[3],a[2]=n[6],a[3]=s,a[5]=n[7],a[6]=u,a[7]=p}else a[0]=n[0],a[1]=n[3],a[2]=n[6],a[3]=n[1],a[4]=n[4],a[5]=n[7],a[6]=n[2],a[7]=n[5],a[8]=n[8];return a},r.triggerPluginCompletionEvent=jl,r.uniqueId=Oe,r.validateCustomStyleLayer=function(a){const n=[],s=a.id;return s===void 0&&n.push({message:`layers.${s}: missing required property "id"`}),a.render===void 0&&n.push({message:`layers.${s}: missing required method "render"`}),a.renderingMode&&a.renderingMode!=="2d"&&a.renderingMode!=="3d"&&n.push({message:`layers.${s}: property "renderingMode" must be either "2d" or "3d"`}),n},r.validateFilter=a=>No(ha(a)),r.validateFog=a=>No(og(a)),r.validateLayer=a=>No(eg(a)),r.validateLight=a=>No(ig(a)),r.validateSource=a=>No(ng(a)),r.validateStyle=Ol,r.validateTerrain=a=>No(rg(a)),r.values=fe,r.vectorTile=Kl,r.version=v,r.warnOnce=be,r.window=L,r.wrap=ie}),h(["./shared"],function(r){function v(we){if(typeof we=="number"||typeof we=="boolean"||typeof we=="string"||we==null)return JSON.stringify(we);if(Array.isArray(we)){let ee="[";for(const ye of we)ee+=`${v(ye)},`;return`${ee}]`}let $="{";for(const ee of Object.keys(we).sort())$+=`${ee}:${v(we[ee])},`;return`${$}}`}function x(we){let $="";for(const ee of r.refProperties)$+=`/${v(we[ee])}`;return $}class w{constructor($){this.keyCache={},$&&this.replace($)}replace($){this._layerConfigs={},this._layers={},this.update($,[])}update($,ee){for(const Re of $)this._layerConfigs[Re.id]=Re,(this._layers[Re.id]=r.createStyleLayer(Re)).compileFilter(),this.keyCache[Re.id]&&delete this.keyCache[Re.id];for(const Re of ee)delete this.keyCache[Re],delete this._layerConfigs[Re],delete this._layers[Re];this.familiesBySource={};const ye=function(Re,je){const et={};for(let qe=0;qe<Re.length;qe++){const rt=je&&je[Re[qe].id]||x(Re[qe]);je&&(je[Re[qe].id]=rt);let vt=et[rt];vt||(vt=et[rt]=[]),vt.push(Re[qe])}const tt=[];for(const qe in et)tt.push(et[qe]);return tt}(r.values(this._layerConfigs),this.keyCache);for(const Re of ye){const je=Re.map(Vt=>this._layers[Vt.id]),et=je[0];if(et.visibility==="none")continue;const tt=et.source||"";let qe=this.familiesBySource[tt];qe||(qe=this.familiesBySource[tt]={});const rt=et.sourceLayer||"_geojsonTileLayer";let vt=qe[rt];vt||(vt=qe[rt]=[]),vt.push(je)}}}class b{loadTile($,ee){const{uid:ye,encoding:Re,rawImageData:je,padding:et,buildQuadTree:tt}=$,qe=r.window.ImageBitmap&&je instanceof r.window.ImageBitmap?this.getImageData(je,et):je;ee(null,new r.DEMData(ye,qe,Re,et<1,tt))}getImageData($,ee){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas($.width,$.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=$.width,this.offscreenCanvas.height=$.height,this.offscreenCanvasContext.drawImage($,0,0,$.width,$.height);const ye=this.offscreenCanvasContext.getImageData(-ee,-ee,$.width+2*ee,$.height+2*ee);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),ye}}var A=function we($,ee){var ye,Re=$&&$.type;if(Re==="FeatureCollection")for(ye=0;ye<$.features.length;ye++)we($.features[ye],ee);else if(Re==="GeometryCollection")for(ye=0;ye<$.geometries.length;ye++)we($.geometries[ye],ee);else if(Re==="Feature")we($.geometry,ee);else if(Re==="Polygon")L($.coordinates,ee);else if(Re==="MultiPolygon")for(ye=0;ye<$.coordinates.length;ye++)L($.coordinates[ye],ee);return $};function L(we,$){if(we.length!==0){P(we[0],$);for(var ee=1;ee<we.length;ee++)P(we[ee],!$)}}function P(we,$){for(var ee=0,ye=0,Re=0,je=we.length,et=je-1;Re<je;et=Re++){var tt=(we[Re][0]-we[et][0])*(we[et][1]+we[Re][1]),qe=ee+tt;ye+=Math.abs(ee)>=Math.abs(tt)?ee-qe+tt:tt-qe+ee,ee=qe}ee+ye>=0!=!!$&&we.reverse()}const R=r.vectorTile.VectorTileFeature.prototype.toGeoJSON;class F{constructor($){this._feature=$,this.extent=r.EXTENT,this.type=$.type,this.properties=$.tags,"id"in $&&!isNaN($.id)&&(this.id=parseInt($.id,10))}loadGeometry(){if(this._feature.type===1){const $=[];for(const ee of this._feature.geometry)$.push([new r.pointGeometry(ee[0],ee[1])]);return $}{const $=[];for(const ee of this._feature.geometry){const ye=[];for(const Re of ee)ye.push(new r.pointGeometry(Re[0],Re[1]));$.push(ye)}return $}}toGeoJSON($,ee,ye){return R.call(this,$,ee,ye)}}class V{constructor($){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=r.EXTENT,this.length=$.length,this._features=$}feature($){return new F(this._features[$])}}var j=r.vectorTile.VectorTileFeature,J=ne;function ne(we,$){this.options=$||{},this.features=we,this.length=we.length}function H(we,$){this.id=typeof we.id=="number"?we.id:void 0,this.type=we.type,this.rawGeometry=we.type===1?[we.geometry]:we.geometry,this.properties=we.tags,this.extent=$||4096}ne.prototype.feature=function(we){return new H(this.features[we],this.options.extent)},H.prototype.loadGeometry=function(){var we=this.rawGeometry;this.geometry=[];for(var $=0;$<we.length;$++){for(var ee=we[$],ye=[],Re=0;Re<ee.length;Re++)ye.push(new r.pointGeometry(ee[Re][0],ee[Re][1]));this.geometry.push(ye)}return this.geometry},H.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var we=this.geometry,$=1/0,ee=-1/0,ye=1/0,Re=-1/0,je=0;je<we.length;je++)for(var et=we[je],tt=0;tt<et.length;tt++){var qe=et[tt];$=Math.min($,qe.x),ee=Math.max(ee,qe.x),ye=Math.min(ye,qe.y),Re=Math.max(Re,qe.y)}return[$,ye,ee,Re]},H.prototype.toGeoJSON=j.prototype.toGeoJSON;var Q=ie,ae=J;function ie(we){var $=new r.pbf;return function(ee,ye){for(var Re in ee.layers)ye.writeMessage(3,le,ee.layers[Re])}(we,$),$.finish()}function le(we,$){var ee;$.writeVarintField(15,we.version||1),$.writeStringField(1,we.name||""),$.writeVarintField(5,we.extent||4096);var ye={keys:[],values:[],keycache:{},valuecache:{}};for(ee=0;ee<we.length;ee++)ye.feature=we.feature(ee),$.writeMessage(2,fe,ye);var Re=ye.keys;for(ee=0;ee<Re.length;ee++)$.writeStringField(3,Re[ee]);var je=ye.values;for(ee=0;ee<je.length;ee++)$.writeMessage(4,He,je[ee])}function fe(we,$){var ee=we.feature;ee.id!==void 0&&$.writeVarintField(1,ee.id),$.writeMessage(2,me,we),$.writeVarintField(3,ee.type),$.writeMessage(4,Ve,ee)}function me(we,$){var ee=we.feature,ye=we.keys,Re=we.values,je=we.keycache,et=we.valuecache;for(var tt in ee.properties){var qe=ee.properties[tt],rt=je[tt];if(qe!==null){rt===void 0&&(ye.push(tt),je[tt]=rt=ye.length-1),$.writeVarint(rt);var vt=typeof qe;vt!=="string"&&vt!=="boolean"&&vt!=="number"&&(qe=JSON.stringify(qe));var Vt=vt+":"+qe,Ct=et[Vt];Ct===void 0&&(Re.push(qe),et[Vt]=Ct=Re.length-1),$.writeVarint(Ct)}}}function he(we,$){return($<<3)+(7&we)}function Oe(we){return we<<1^we>>31}function Ve(we,$){for(var ee=we.loadGeometry(),ye=we.type,Re=0,je=0,et=ee.length,tt=0;tt<et;tt++){var qe=ee[tt],rt=1;ye===1&&(rt=qe.length),$.writeVarint(he(1,rt));for(var vt=ye===3?qe.length-1:qe.length,Vt=0;Vt<vt;Vt++){Vt===1&&ye!==1&&$.writeVarint(he(2,vt-1));var Ct=qe[Vt].x-Re,_n=qe[Vt].y-je;$.writeVarint(Oe(Ct)),$.writeVarint(Oe(_n)),Re+=Ct,je+=_n}ye===3&&$.writeVarint(he(7,1))}}function He(we,$){var ee=typeof we;ee==="string"?$.writeStringField(1,we):ee==="boolean"?$.writeBooleanField(7,we):ee==="number"&&(we%1!=0?$.writeDoubleField(3,we):we<0?$.writeSVarintField(6,we):$.writeVarintField(5,we))}function at(we,$,ee,ye,Re,je){if(Re-ye<=ee)return;const et=ye+Re>>1;At(we,$,et,ye,Re,je%2),at(we,$,ee,ye,et-1,je+1),at(we,$,ee,et+1,Re,je+1)}function At(we,$,ee,ye,Re,je){for(;Re>ye;){if(Re-ye>600){const rt=Re-ye+1,vt=ee-ye+1,Vt=Math.log(rt),Ct=.5*Math.exp(2*Vt/3),_n=.5*Math.sqrt(Vt*Ct*(rt-Ct)/rt)*(vt-rt/2<0?-1:1);At(we,$,ee,Math.max(ye,Math.floor(ee-vt*Ct/rt+_n)),Math.min(Re,Math.floor(ee+(rt-vt)*Ct/rt+_n)),je)}const et=$[2*ee+je];let tt=ye,qe=Re;for(yt(we,$,ye,ee),$[2*Re+je]>et&&yt(we,$,ye,Re);tt<qe;){for(yt(we,$,tt,qe),tt++,qe--;$[2*tt+je]<et;)tt++;for(;$[2*qe+je]>et;)qe--}$[2*ye+je]===et?yt(we,$,ye,qe):(qe++,yt(we,$,qe,Re)),qe<=ee&&(ye=qe+1),ee<=qe&&(Re=qe-1)}}function yt(we,$,ee,ye){Dt(we,ee,ye),Dt($,2*ee,2*ye),Dt($,2*ee+1,2*ye+1)}function Dt(we,$,ee){const ye=we[$];we[$]=we[ee],we[ee]=ye}function It(we,$,ee,ye){const Re=we-ee,je=$-ye;return Re*Re+je*je}Q.fromVectorTileJs=ie,Q.fromGeojsonVt=function(we,$){$=$||{};var ee={};for(var ye in we)ee[ye]=new J(we[ye].features,$),ee[ye].name=ye,ee[ye].version=$.version,ee[ye].extent=$.extent;return ie({layers:ee})},Q.GeoJSONWrapper=ae;const Nt=we=>we[0],Ie=we=>we[1];class be{constructor($,ee=Nt,ye=Ie,Re=64,je=Float64Array){this.nodeSize=Re,this.points=$;const et=$.length<65536?Uint16Array:Uint32Array,tt=this.ids=new et($.length),qe=this.coords=new je(2*$.length);for(let rt=0;rt<$.length;rt++)tt[rt]=rt,qe[2*rt]=ee($[rt]),qe[2*rt+1]=ye($[rt]);at(tt,qe,Re,0,tt.length-1,0)}range($,ee,ye,Re){return function(je,et,tt,qe,rt,vt,Vt){const Ct=[0,je.length-1,0],_n=[];let Y,re;for(;Ct.length;){const Fe=Ct.pop(),Te=Ct.pop(),Tt=Ct.pop();if(Te-Tt<=Vt){for(let rn=Tt;rn<=Te;rn++)Y=et[2*rn],re=et[2*rn+1],Y>=tt&&Y<=rt&&re>=qe&&re<=vt&&_n.push(je[rn]);continue}const _t=Math.floor((Tt+Te)/2);Y=et[2*_t],re=et[2*_t+1],Y>=tt&&Y<=rt&&re>=qe&&re<=vt&&_n.push(je[_t]);const Ot=(Fe+1)%2;(Fe===0?tt<=Y:qe<=re)&&(Ct.push(Tt),Ct.push(_t-1),Ct.push(Ot)),(Fe===0?rt>=Y:vt>=re)&&(Ct.push(_t+1),Ct.push(Te),Ct.push(Ot))}return _n}(this.ids,this.coords,$,ee,ye,Re,this.nodeSize)}within($,ee,ye){return function(Re,je,et,tt,qe,rt){const vt=[0,Re.length-1,0],Vt=[],Ct=qe*qe;for(;vt.length;){const _n=vt.pop(),Y=vt.pop(),re=vt.pop();if(Y-re<=rt){for(let Ot=re;Ot<=Y;Ot++)It(je[2*Ot],je[2*Ot+1],et,tt)<=Ct&&Vt.push(Re[Ot]);continue}const Fe=Math.floor((re+Y)/2),Te=je[2*Fe],Tt=je[2*Fe+1];It(Te,Tt,et,tt)<=Ct&&Vt.push(Re[Fe]);const _t=(_n+1)%2;(_n===0?et-qe<=Te:tt-qe<=Tt)&&(vt.push(re),vt.push(Fe-1),vt.push(_t)),(_n===0?et+qe>=Te:tt+qe>=Tt)&&(vt.push(Fe+1),vt.push(Y),vt.push(_t))}return Vt}(this.ids,this.coords,$,ee,ye,this.nodeSize)}}const We={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:we=>we},Ge=Math.fround||(ke=new Float32Array(1),we=>(ke[0]=+we,ke[0]));var ke;class ot{constructor($){this.options=wt(Object.create(We),$),this.trees=new Array(this.options.maxZoom+1)}load($){const{log:ee,minZoom:ye,maxZoom:Re,nodeSize:je}=this.options;ee&&console.time("total time");const et=`prepare ${$.length} points`;ee&&console.time(et),this.points=$;let tt=[];for(let qe=0;qe<$.length;qe++)$[qe].geometry&&tt.push(Ce($[qe],qe));this.trees[Re+1]=new be(tt,Gt,pe,je,Float32Array),ee&&console.timeEnd(et);for(let qe=Re;qe>=ye;qe--){const rt=+Date.now();tt=this._cluster(tt,qe),this.trees[qe]=new be(tt,Gt,pe,je,Float32Array),ee&&console.log("z%d: %d clusters in %dms",qe,tt.length,+Date.now()-rt)}return ee&&console.timeEnd("total time"),this}getClusters($,ee){let ye=(($[0]+180)%360+360)%360-180;const Re=Math.max(-90,Math.min(90,$[1]));let je=$[2]===180?180:(($[2]+180)%360+360)%360-180;const et=Math.max(-90,Math.min(90,$[3]));if($[2]-$[0]>=360)ye=-180,je=180;else if(ye>je){const vt=this.getClusters([ye,Re,180,et],ee),Vt=this.getClusters([-180,Re,je,et],ee);return vt.concat(Vt)}const tt=this.trees[this._limitZoom(ee)],qe=tt.range(Ne(ye),Je(et),Ne(je),Je(Re)),rt=[];for(const vt of qe){const Vt=tt.points[vt];rt.push(Vt.numPoints?Ae(Vt):this.points[Vt.index])}return rt}getChildren($){const ee=this._getOriginId($),ye=this._getOriginZoom($),Re="No cluster with the specified id.",je=this.trees[ye];if(!je)throw new Error(Re);const et=je.points[ee];if(!et)throw new Error(Re);const tt=this.options.radius/(this.options.extent*Math.pow(2,ye-1)),qe=je.within(et.x,et.y,tt),rt=[];for(const vt of qe){const Vt=je.points[vt];Vt.parentId===$&&rt.push(Vt.numPoints?Ae(Vt):this.points[Vt.index])}if(rt.length===0)throw new Error(Re);return rt}getLeaves($,ee,ye){const Re=[];return this._appendLeaves(Re,$,ee=ee||10,ye=ye||0,0),Re}getTile($,ee,ye){const Re=this.trees[this._limitZoom($)],je=Math.pow(2,$),{extent:et,radius:tt}=this.options,qe=tt/et,rt=(ye-qe)/je,vt=(ye+1+qe)/je,Vt={features:[]};return this._addTileFeatures(Re.range((ee-qe)/je,rt,(ee+1+qe)/je,vt),Re.points,ee,ye,je,Vt),ee===0&&this._addTileFeatures(Re.range(1-qe/je,rt,1,vt),Re.points,je,ye,je,Vt),ee===je-1&&this._addTileFeatures(Re.range(0,rt,qe/je,vt),Re.points,-1,ye,je,Vt),Vt.features.length?Vt:null}getClusterExpansionZoom($){let ee=this._getOriginZoom($)-1;for(;ee<=this.options.maxZoom;){const ye=this.getChildren($);if(ee++,ye.length!==1)break;$=ye[0].properties.cluster_id}return ee}_appendLeaves($,ee,ye,Re,je){const et=this.getChildren(ee);for(const tt of et){const qe=tt.properties;if(qe&&qe.cluster?je+qe.point_count<=Re?je+=qe.point_count:je=this._appendLeaves($,qe.cluster_id,ye,Re,je):je<Re?je++:$.push(tt),$.length===ye)break}return je}_addTileFeatures($,ee,ye,Re,je,et){for(const tt of $){const qe=ee[tt],rt=qe.numPoints;let vt,Vt,Ct;if(rt)vt=_e(qe),Vt=qe.x,Ct=qe.y;else{const re=this.points[qe.index];vt=re.properties,Vt=Ne(re.geometry.coordinates[0]),Ct=Je(re.geometry.coordinates[1])}const _n={type:1,geometry:[[Math.round(this.options.extent*(Vt*je-ye)),Math.round(this.options.extent*(Ct*je-Re))]],tags:vt};let Y;rt?Y=qe.id:this.options.generateId?Y=qe.index:this.points[qe.index].id&&(Y=this.points[qe.index].id),Y!==void 0&&(_n.id=Y),et.features.push(_n)}}_limitZoom($){return Math.max(this.options.minZoom,Math.min(+$,this.options.maxZoom+1))}_cluster($,ee){const ye=[],{radius:Re,extent:je,reduce:et,minPoints:tt}=this.options,qe=Re/(je*Math.pow(2,ee));for(let rt=0;rt<$.length;rt++){const vt=$[rt];if(vt.zoom<=ee)continue;vt.zoom=ee;const Vt=this.trees[ee+1],Ct=Vt.within(vt.x,vt.y,qe),_n=vt.numPoints||1;let Y=_n;for(const re of Ct){const Fe=Vt.points[re];Fe.zoom>ee&&(Y+=Fe.numPoints||1)}if(Y>_n&&Y>=tt){let re=vt.x*_n,Fe=vt.y*_n,Te=et&&_n>1?this._map(vt,!0):null;const Tt=(rt<<5)+(ee+1)+this.points.length;for(const _t of Ct){const Ot=Vt.points[_t];if(Ot.zoom<=ee)continue;Ot.zoom=ee;const rn=Ot.numPoints||1;re+=Ot.x*rn,Fe+=Ot.y*rn,Ot.parentId=Tt,et&&(Te||(Te=this._map(vt,!0)),et(Te,this._map(Ot)))}vt.parentId=Tt,ye.push(ge(re/Y,Fe/Y,Tt,Y,Te))}else if(ye.push(vt),Y>1)for(const re of Ct){const Fe=Vt.points[re];Fe.zoom<=ee||(Fe.zoom=ee,ye.push(Fe))}}return ye}_getOriginId($){return $-this.points.length>>5}_getOriginZoom($){return($-this.points.length)%32}_map($,ee){if($.numPoints)return ee?wt({},$.properties):$.properties;const ye=this.points[$.index].properties,Re=this.options.map(ye);return ee&&Re===ye?wt({},Re):Re}}function ge(we,$,ee,ye,Re){return{x:Ge(we),y:Ge($),zoom:1/0,id:ee,parentId:-1,numPoints:ye,properties:Re}}function Ce(we,$){const[ee,ye]=we.geometry.coordinates;return{x:Ge(Ne(ee)),y:Ge(Je(ye)),zoom:1/0,index:$,parentId:-1}}function Ae(we){return{type:"Feature",id:we.id,properties:_e(we),geometry:{type:"Point",coordinates:[($=we.x,360*($-.5)),ct(we.y)]}};var $}function _e(we){const $=we.numPoints,ee=$>=1e4?`${Math.round($/1e3)}k`:$>=1e3?Math.round($/100)/10+"k":$;return wt(wt({},we.properties),{cluster:!0,cluster_id:we.id,point_count:$,point_count_abbreviated:ee})}function Ne(we){return we/360+.5}function Je(we){const $=Math.sin(we*Math.PI/180),ee=.5-.25*Math.log((1+$)/(1-$))/Math.PI;return ee<0?0:ee>1?1:ee}function ct(we){const $=(180-360*we)*Math.PI/180;return 360*Math.atan(Math.exp($))/Math.PI-90}function wt(we,$){for(const ee in $)we[ee]=$[ee];return we}function Gt(we){return we.x}function pe(we){return we.y}function Me(we,$,ee,ye){for(var Re,je=ye,et=ee-$>>1,tt=ee-$,qe=we[$],rt=we[$+1],vt=we[ee],Vt=we[ee+1],Ct=$+3;Ct<ee;Ct+=3){var _n=bt(we[Ct],we[Ct+1],qe,rt,vt,Vt);if(_n>je)Re=Ct,je=_n;else if(_n===je){var Y=Math.abs(Ct-et);Y<tt&&(Re=Ct,tt=Y)}}je>ye&&(Re-$>3&&Me(we,$,Re,ye),we[Re+2]=je,ee-Re>3&&Me(we,Re,ee,ye))}function bt(we,$,ee,ye,Re,je){var et=Re-ee,tt=je-ye;if(et!==0||tt!==0){var qe=((we-ee)*et+($-ye)*tt)/(et*et+tt*tt);qe>1?(ee=Re,ye=je):qe>0&&(ee+=et*qe,ye+=tt*qe)}return(et=we-ee)*et+(tt=$-ye)*tt}function gt(we,$,ee,ye){var Re={id:we===void 0?null:we,type:$,geometry:ee,tags:ye,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(je){var et=je.geometry,tt=je.type;if(tt==="Point"||tt==="MultiPoint"||tt==="LineString")bn(je,et);else if(tt==="Polygon"||tt==="MultiLineString")for(var qe=0;qe<et.length;qe++)bn(je,et[qe]);else if(tt==="MultiPolygon")for(qe=0;qe<et.length;qe++)for(var rt=0;rt<et[qe].length;rt++)bn(je,et[qe][rt])}(Re),Re}function bn(we,$){for(var ee=0;ee<$.length;ee+=3)we.minX=Math.min(we.minX,$[ee]),we.minY=Math.min(we.minY,$[ee+1]),we.maxX=Math.max(we.maxX,$[ee]),we.maxY=Math.max(we.maxY,$[ee+1])}function hn(we,$,ee,ye){if($.geometry){var Re=$.geometry.coordinates,je=$.geometry.type,et=Math.pow(ee.tolerance/((1<<ee.maxZoom)*ee.extent),2),tt=[],qe=$.id;if(ee.promoteId?qe=$.properties[ee.promoteId]:ee.generateId&&(qe=ye||0),je==="Point")nn(Re,tt);else if(je==="MultiPoint")for(var rt=0;rt<Re.length;rt++)nn(Re[rt],tt);else if(je==="LineString")pn(Re,tt,et,!1);else if(je==="MultiLineString"){if(ee.lineMetrics){for(rt=0;rt<Re.length;rt++)pn(Re[rt],tt=[],et,!1),we.push(gt(qe,"LineString",tt,$.properties));return}wn(Re,tt,et,!1)}else if(je==="Polygon")wn(Re,tt,et,!0);else{if(je!=="MultiPolygon"){if(je==="GeometryCollection"){for(rt=0;rt<$.geometry.geometries.length;rt++)hn(we,{id:qe,geometry:$.geometry.geometries[rt],properties:$.properties},ee,ye);return}throw new Error("Input data is not a valid GeoJSON object.")}for(rt=0;rt<Re.length;rt++){var vt=[];wn(Re[rt],vt,et,!0),tt.push(vt)}}we.push(gt(qe,je,tt,$.properties))}}function nn(we,$){$.push(cn(we[0])),$.push(Wt(we[1])),$.push(0)}function pn(we,$,ee,ye){for(var Re,je,et=0,tt=0;tt<we.length;tt++){var qe=cn(we[tt][0]),rt=Wt(we[tt][1]);$.push(qe),$.push(rt),$.push(0),tt>0&&(et+=ye?(Re*rt-qe*je)/2:Math.sqrt(Math.pow(qe-Re,2)+Math.pow(rt-je,2))),Re=qe,je=rt}var vt=$.length-3;$[2]=1,Me($,0,vt,ee),$[vt+2]=1,$.size=Math.abs(et),$.start=0,$.end=$.size}function wn(we,$,ee,ye){for(var Re=0;Re<we.length;Re++){var je=[];pn(we[Re],je,ee,ye),$.push(je)}}function cn(we){return we/360+.5}function Wt(we){var $=Math.sin(we*Math.PI/180),ee=.5-.25*Math.log((1+$)/(1-$))/Math.PI;return ee<0?0:ee>1?1:ee}function sn(we,$,ee,ye,Re,je,et,tt){if(ye/=$,je>=(ee/=$)&&et<ye)return we;if(et<ee||je>=ye)return null;for(var qe=[],rt=0;rt<we.length;rt++){var vt=we[rt],Vt=vt.geometry,Ct=vt.type,_n=Re===0?vt.minX:vt.minY,Y=Re===0?vt.maxX:vt.maxY;if(_n>=ee&&Y<ye)qe.push(vt);else if(!(Y<ee||_n>=ye)){var re=[];if(Ct==="Point"||Ct==="MultiPoint")Xt(Vt,re,ee,ye,Re);else if(Ct==="LineString")Xe(Vt,re,ee,ye,Re,!1,tt.lineMetrics);else if(Ct==="MultiLineString")en(Vt,re,ee,ye,Re,!1);else if(Ct==="Polygon")en(Vt,re,ee,ye,Re,!0);else if(Ct==="MultiPolygon")for(var Fe=0;Fe<Vt.length;Fe++){var Te=[];en(Vt[Fe],Te,ee,ye,Re,!0),Te.length&&re.push(Te)}if(re.length){if(tt.lineMetrics&&Ct==="LineString"){for(Fe=0;Fe<re.length;Fe++)qe.push(gt(vt.id,Ct,re[Fe],vt.tags));continue}Ct!=="LineString"&&Ct!=="MultiLineString"||(re.length===1?(Ct="LineString",re=re[0]):Ct="MultiLineString"),Ct!=="Point"&&Ct!=="MultiPoint"||(Ct=re.length===3?"Point":"MultiPoint"),qe.push(gt(vt.id,Ct,re,vt.tags))}}}return qe.length?qe:null}function Xt(we,$,ee,ye,Re){for(var je=0;je<we.length;je+=3){var et=we[je+Re];et>=ee&&et<=ye&&($.push(we[je]),$.push(we[je+1]),$.push(we[je+2]))}}function Xe(we,$,ee,ye,Re,je,et){for(var tt,qe,rt=Ut(we),vt=Re===0?fn:On,Vt=we.start,Ct=0;Ct<we.length-3;Ct+=3){var _n=we[Ct],Y=we[Ct+1],re=we[Ct+2],Fe=we[Ct+3],Te=we[Ct+4],Tt=Re===0?_n:Y,_t=Re===0?Fe:Te,Ot=!1;et&&(tt=Math.sqrt(Math.pow(_n-Fe,2)+Math.pow(Y-Te,2))),Tt<ee?_t>ee&&(qe=vt(rt,_n,Y,Fe,Te,ee),et&&(rt.start=Vt+tt*qe)):Tt>ye?_t<ye&&(qe=vt(rt,_n,Y,Fe,Te,ye),et&&(rt.start=Vt+tt*qe)):Pn(rt,_n,Y,re),_t<ee&&Tt>=ee&&(qe=vt(rt,_n,Y,Fe,Te,ee),Ot=!0),_t>ye&&Tt<=ye&&(qe=vt(rt,_n,Y,Fe,Te,ye),Ot=!0),!je&&Ot&&(et&&(rt.end=Vt+tt*qe),$.push(rt),rt=Ut(we)),et&&(Vt+=tt)}var rn=we.length-3;_n=we[rn],Y=we[rn+1],re=we[rn+2],(Tt=Re===0?_n:Y)>=ee&&Tt<=ye&&Pn(rt,_n,Y,re),rn=rt.length-3,je&&rn>=3&&(rt[rn]!==rt[0]||rt[rn+1]!==rt[1])&&Pn(rt,rt[0],rt[1],rt[2]),rt.length&&$.push(rt)}function Ut(we){var $=[];return $.size=we.size,$.start=we.start,$.end=we.end,$}function en(we,$,ee,ye,Re,je){for(var et=0;et<we.length;et++)Xe(we[et],$,ee,ye,Re,je,!1)}function Pn(we,$,ee,ye){we.push($),we.push(ee),we.push(ye)}function fn(we,$,ee,ye,Re,je){var et=(je-$)/(ye-$);return we.push(je),we.push(ee+(Re-ee)*et),we.push(1),et}function On(we,$,ee,ye,Re,je){var et=(je-ee)/(Re-ee);return we.push($+(ye-$)*et),we.push(je),we.push(1),et}function Gn(we,$){for(var ee=[],ye=0;ye<we.length;ye++){var Re,je=we[ye],et=je.type;if(et==="Point"||et==="MultiPoint"||et==="LineString")Re=qn(je.geometry,$);else if(et==="MultiLineString"||et==="Polygon"){Re=[];for(var tt=0;tt<je.geometry.length;tt++)Re.push(qn(je.geometry[tt],$))}else if(et==="MultiPolygon")for(Re=[],tt=0;tt<je.geometry.length;tt++){for(var qe=[],rt=0;rt<je.geometry[tt].length;rt++)qe.push(qn(je.geometry[tt][rt],$));Re.push(qe)}ee.push(gt(je.id,et,Re,je.tags))}return ee}function qn(we,$){var ee=[];ee.size=we.size,we.start!==void 0&&(ee.start=we.start,ee.end=we.end);for(var ye=0;ye<we.length;ye+=3)ee.push(we[ye]+$,we[ye+1],we[ye+2]);return ee}function ji(we,$){if(we.transformed)return we;var ee,ye,Re,je=1<<we.z,et=we.x,tt=we.y;for(ee=0;ee<we.features.length;ee++){var qe=we.features[ee],rt=qe.geometry,vt=qe.type;if(qe.geometry=[],vt===1)for(ye=0;ye<rt.length;ye+=2)qe.geometry.push(Nn(rt[ye],rt[ye+1],$,je,et,tt));else for(ye=0;ye<rt.length;ye++){var Vt=[];for(Re=0;Re<rt[ye].length;Re+=2)Vt.push(Nn(rt[ye][Re],rt[ye][Re+1],$,je,et,tt));qe.geometry.push(Vt)}}return we.transformed=!0,we}function Nn(we,$,ee,ye,Re,je){return[Math.round(ee*(we*ye-Re)),Math.round(ee*($*ye-je))]}function Di(we,$,ee,ye,Re){for(var je=$===Re.maxZoom?0:Re.tolerance/((1<<$)*Re.extent),et={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:ee,y:ye,z:$,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},tt=0;tt<we.length;tt++){et.numFeatures++,ei(et,we[tt],je,Re);var qe=we[tt].minX,rt=we[tt].minY,vt=we[tt].maxX,Vt=we[tt].maxY;qe<et.minX&&(et.minX=qe),rt<et.minY&&(et.minY=rt),vt>et.maxX&&(et.maxX=vt),Vt>et.maxY&&(et.maxY=Vt)}return et}function ei(we,$,ee,ye){var Re=$.geometry,je=$.type,et=[];if(je==="Point"||je==="MultiPoint")for(var tt=0;tt<Re.length;tt+=3)et.push(Re[tt]),et.push(Re[tt+1]),we.numPoints++,we.numSimplified++;else if(je==="LineString")Ji(et,Re,we,ee,!1,!1);else if(je==="MultiLineString"||je==="Polygon")for(tt=0;tt<Re.length;tt++)Ji(et,Re[tt],we,ee,je==="Polygon",tt===0);else if(je==="MultiPolygon")for(var qe=0;qe<Re.length;qe++){var rt=Re[qe];for(tt=0;tt<rt.length;tt++)Ji(et,rt[tt],we,ee,!0,tt===0)}if(et.length){var vt=$.tags||null;if(je==="LineString"&&ye.lineMetrics){for(var Vt in vt={},$.tags)vt[Vt]=$.tags[Vt];vt.mapbox_clip_start=Re.start/Re.size,vt.mapbox_clip_end=Re.end/Re.size}var Ct={geometry:et,type:je==="Polygon"||je==="MultiPolygon"?3:je==="LineString"||je==="MultiLineString"?2:1,tags:vt};$.id!==null&&(Ct.id=$.id),we.features.push(Ct)}}function Ji(we,$,ee,ye,Re,je){var et=ye*ye;if(ye>0&&$.size<(Re?et:ye))ee.numPoints+=$.length/3;else{for(var tt=[],qe=0;qe<$.length;qe+=3)(ye===0||$[qe+2]>et)&&(ee.numSimplified++,tt.push($[qe]),tt.push($[qe+1])),ee.numPoints++;Re&&function(rt,vt){for(var Vt=0,Ct=0,_n=rt.length,Y=_n-2;Ct<_n;Y=Ct,Ct+=2)Vt+=(rt[Ct]-rt[Y])*(rt[Ct+1]+rt[Y+1]);if(Vt>0===vt)for(Ct=0,_n=rt.length;Ct<_n/2;Ct+=2){var re=rt[Ct],Fe=rt[Ct+1];rt[Ct]=rt[_n-2-Ct],rt[Ct+1]=rt[_n-1-Ct],rt[_n-2-Ct]=re,rt[_n-1-Ct]=Fe}}(tt,je),we.push(tt)}}function _i(we,$){var ee=($=this.options=function(Re,je){for(var et in je)Re[et]=je[et];return Re}(Object.create(this.options),$)).debug;if(ee&&console.time("preprocess data"),$.maxZoom<0||$.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if($.promoteId&&$.generateId)throw new Error("promoteId and generateId cannot be used together.");var ye=function(Re,je){var et=[];if(Re.type==="FeatureCollection")for(var tt=0;tt<Re.features.length;tt++)hn(et,Re.features[tt],je,tt);else hn(et,Re.type==="Feature"?Re:{geometry:Re},je);return et}(we,$);this.tiles={},this.tileCoords=[],ee&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",$.indexMaxZoom,$.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),(ye=function(Re,je){var et=je.buffer/je.extent,tt=Re,qe=sn(Re,1,-1-et,et,0,-1,2,je),rt=sn(Re,1,1-et,2+et,0,-1,2,je);return(qe||rt)&&(tt=sn(Re,1,-et,1+et,0,-1,2,je)||[],qe&&(tt=Gn(qe,1).concat(tt)),rt&&(tt=tt.concat(Gn(rt,-1)))),tt}(ye,$)).length&&this.splitTile(ye,0,0,0),ee&&(ye.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function jr(we,$,ee){return 32*((1<<we)*ee+$)+we}function zi(we,$){const ee=we.tileID.canonical;if(!this._geoJSONIndex)return $(null,null);const ye=this._geoJSONIndex.getTile(ee.z,ee.x,ee.y);if(!ye)return $(null,null);const Re=new V(ye.features);let je=Q(Re);je.byteOffset===0&&je.byteLength===je.buffer.byteLength||(je=new Uint8Array(je)),$(null,{vectorTile:Re,rawData:je.buffer})}_i.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},_i.prototype.splitTile=function(we,$,ee,ye,Re,je,et){for(var tt=[we,$,ee,ye],qe=this.options,rt=qe.debug;tt.length;){ye=tt.pop(),ee=tt.pop(),$=tt.pop(),we=tt.pop();var vt=1<<$,Vt=jr($,ee,ye),Ct=this.tiles[Vt];if(!Ct&&(rt>1&&console.time("creation"),Ct=this.tiles[Vt]=Di(we,$,ee,ye,qe),this.tileCoords.push({z:$,x:ee,y:ye}),rt)){rt>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",$,ee,ye,Ct.numFeatures,Ct.numPoints,Ct.numSimplified),console.timeEnd("creation"));var _n="z"+$;this.stats[_n]=(this.stats[_n]||0)+1,this.total++}if(Ct.source=we,Re){if($===qe.maxZoom||$===Re)continue;var Y=1<<Re-$;if(ee!==Math.floor(je/Y)||ye!==Math.floor(et/Y))continue}else if($===qe.indexMaxZoom||Ct.numPoints<=qe.indexMaxPoints)continue;if(Ct.source=null,we.length!==0){rt>1&&console.time("clipping");var re,Fe,Te,Tt,_t,Ot,rn=.5*qe.buffer/qe.extent,Sn=.5-rn,Ln=.5+rn,Mt=1+rn;re=Fe=Te=Tt=null,_t=sn(we,vt,ee-rn,ee+Ln,0,Ct.minX,Ct.maxX,qe),Ot=sn(we,vt,ee+Sn,ee+Mt,0,Ct.minX,Ct.maxX,qe),we=null,_t&&(re=sn(_t,vt,ye-rn,ye+Ln,1,Ct.minY,Ct.maxY,qe),Fe=sn(_t,vt,ye+Sn,ye+Mt,1,Ct.minY,Ct.maxY,qe),_t=null),Ot&&(Te=sn(Ot,vt,ye-rn,ye+Ln,1,Ct.minY,Ct.maxY,qe),Tt=sn(Ot,vt,ye+Sn,ye+Mt,1,Ct.minY,Ct.maxY,qe),Ot=null),rt>1&&console.timeEnd("clipping"),tt.push(re||[],$+1,2*ee,2*ye),tt.push(Fe||[],$+1,2*ee,2*ye+1),tt.push(Te||[],$+1,2*ee+1,2*ye),tt.push(Tt||[],$+1,2*ee+1,2*ye+1)}}},_i.prototype.getTile=function(we,$,ee){var ye=this.options,Re=ye.extent,je=ye.debug;if(we<0||we>24)return null;var et=1<<we,tt=jr(we,$=($%et+et)%et,ee);if(this.tiles[tt])return ji(this.tiles[tt],Re);je>1&&console.log("drilling down to z%d-%d-%d",we,$,ee);for(var qe,rt=we,vt=$,Vt=ee;!qe&&rt>0;)rt--,vt=Math.floor(vt/2),Vt=Math.floor(Vt/2),qe=this.tiles[jr(rt,vt,Vt)];return qe&&qe.source?(je>1&&console.log("found parent tile z%d-%d-%d",rt,vt,Vt),je>1&&console.time("drilling down"),this.splitTile(qe.source,rt,vt,Vt,we,$,ee),je>1&&console.timeEnd("drilling down"),this.tiles[tt]?ji(this.tiles[tt],Re):null):null};class Hr extends r.VectorTileWorkerSource{constructor($,ee,ye,Re,je){super($,ee,ye,Re,zi),je&&(this.loadGeoJSON=je)}loadData($,ee){const ye=$&&$.request,Re=ye&&ye.collectResourceTiming;this.loadGeoJSON($,(je,et)=>{if(je||!et)return ee(je);if(typeof et!="object")return ee(new Error(`Input data given to '${$.source}' is not a valid GeoJSON object.`));{A(et,!0);try{if($.filter){const qe=r.createExpression($.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(qe.result==="error")throw new Error(qe.value.map(vt=>`${vt.key}: ${vt.message}`).join(", "));et={type:"FeatureCollection",features:et.features.filter(vt=>qe.value.evaluate({zoom:0},vt))}}this._geoJSONIndex=$.cluster?new ot(function({superclusterOptions:qe,clusterProperties:rt}){if(!rt||!qe)return qe;const vt={},Vt={},Ct={accumulated:null,zoom:0},_n={properties:null},Y=Object.keys(rt);for(const re of Y){const[Fe,Te]=rt[re],Tt=r.createExpression(Te),_t=r.createExpression(typeof Fe=="string"?[Fe,["accumulated"],["get",re]]:Fe);vt[re]=Tt.value,Vt[re]=_t.value}return qe.map=re=>{_n.properties=re;const Fe={};for(const Te of Y)Fe[Te]=vt[Te].evaluate(Ct,_n);return Fe},qe.reduce=(re,Fe)=>{_n.properties=Fe;for(const Te of Y)Ct.accumulated=re[Te],re[Te]=Vt[Te].evaluate(Ct,_n)},qe}($)).load(et.features):function(qe,rt){return new _i(qe,rt)}(et,$.geojsonVtOptions)}catch(qe){return ee(qe)}this.loaded={};const tt={};if(Re){const qe=r.getPerformanceMeasurement(ye);qe&&(tt.resourceTiming={},tt.resourceTiming[$.source]=JSON.parse(JSON.stringify(qe)))}ee(null,tt)}})}reloadTile($,ee){const ye=this.loaded;return ye&&ye[$.uid]?super.reloadTile($,ee):this.loadTile($,ee)}loadGeoJSON($,ee){if($.request)r.getJSON($.request,ee);else{if(typeof $.data!="string")return ee(new Error(`Input data given to '${$.source}' is not a valid GeoJSON object.`));try{return ee(null,JSON.parse($.data))}catch(ye){return ee(new Error(`Input data given to '${$.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom($,ee){try{ee(null,this._geoJSONIndex.getClusterExpansionZoom($.clusterId))}catch(ye){ee(ye)}}getClusterChildren($,ee){try{ee(null,this._geoJSONIndex.getChildren($.clusterId))}catch(ye){ee(ye)}}getClusterLeaves($,ee){try{ee(null,this._geoJSONIndex.getLeaves($.clusterId,$.limit,$.offset))}catch(ye){ee(ye)}}}class Ar{constructor($){this.self=$,this.actor=new r.Actor($,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=r.getProjection({name:"mercator"}),this.workerSourceTypes={vector:r.VectorTileWorkerSource,geojson:Hr},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(ee,ye)=>{if(this.workerSourceTypes[ee])throw new Error(`Worker source with name "${ee}" already registered.`);this.workerSourceTypes[ee]=ye},this.self.registerRTLTextPlugin=ee=>{if(r.plugin.isParsed())throw new Error("RTL text plugin already registered.");r.plugin.applyArabicShaping=ee.applyArabicShaping,r.plugin.processBidirectionalText=ee.processBidirectionalText,r.plugin.processStyledBidirectionalText=ee.processStyledBidirectionalText}}clearCaches($,ee,ye){delete this.layerIndexes[$],delete this.availableImages[$],delete this.workerSources[$],delete this.demWorkerSources[$],ye()}checkIfReady($,ee,ye){ye()}setReferrer($,ee){this.referrer=ee}spriteLoaded($,ee){this.isSpriteLoaded[$]=ee;for(const ye in this.workerSources[$]){const Re=this.workerSources[$][ye];for(const je in Re)Re[je]instanceof r.VectorTileWorkerSource&&(Re[je].isSpriteLoaded=ee,Re[je].fire(new r.Event("isSpriteLoaded")))}}setImages($,ee,ye){this.availableImages[$]=ee;for(const Re in this.workerSources[$]){const je=this.workerSources[$][Re];for(const et in je)je[et].availableImages=ee}ye()}enableTerrain($,ee,ye){this.terrain=ee,ye()}setProjection($,ee){this.projections[$]=r.getProjection(ee)}setLayers($,ee,ye){this.getLayerIndex($).replace(ee),ye()}updateLayers($,ee,ye){this.getLayerIndex($).update(ee.layers,ee.removedIds),ye()}loadTile($,ee,ye){const Re=this.enableTerrain?r.extend({enableTerrain:this.terrain},ee):ee;Re.projection=this.projections[$]||this.defaultProjection,this.getWorkerSource($,ee.type,ee.source).loadTile(Re,ye)}loadDEMTile($,ee,ye){const Re=this.enableTerrain?r.extend({buildQuadTree:this.terrain},ee):ee;this.getDEMWorkerSource($,ee.source).loadTile(Re,ye)}reloadTile($,ee,ye){const Re=this.enableTerrain?r.extend({enableTerrain:this.terrain},ee):ee;Re.projection=this.projections[$]||this.defaultProjection,this.getWorkerSource($,ee.type,ee.source).reloadTile(Re,ye)}abortTile($,ee,ye){this.getWorkerSource($,ee.type,ee.source).abortTile(ee,ye)}removeTile($,ee,ye){this.getWorkerSource($,ee.type,ee.source).removeTile(ee,ye)}removeSource($,ee,ye){if(!this.workerSources[$]||!this.workerSources[$][ee.type]||!this.workerSources[$][ee.type][ee.source])return;const Re=this.workerSources[$][ee.type][ee.source];delete this.workerSources[$][ee.type][ee.source],Re.removeSource!==void 0?Re.removeSource(ee,ye):ye()}loadWorkerSource($,ee,ye){try{this.self.importScripts(ee.url),ye()}catch(Re){ye(Re.toString())}}syncRTLPluginState($,ee,ye){try{r.plugin.setState(ee);const Re=r.plugin.getPluginURL();if(r.plugin.isLoaded()&&!r.plugin.isParsed()&&Re!=null){this.self.importScripts(Re);const je=r.plugin.isParsed();ye(je?void 0:new Error(`RTL Text Plugin failed to import scripts from ${Re}`),je)}}catch(Re){ye(Re.toString())}}getAvailableImages($){let ee=this.availableImages[$];return ee||(ee=[]),ee}getLayerIndex($){let ee=this.layerIndexes[$];return ee||(ee=this.layerIndexes[$]=new w),ee}getWorkerSource($,ee,ye){return this.workerSources[$]||(this.workerSources[$]={}),this.workerSources[$][ee]||(this.workerSources[$][ee]={}),this.workerSources[$][ee][ye]||(this.workerSources[$][ee][ye]=new this.workerSourceTypes[ee]({send:(Re,je,et,tt,qe,rt)=>{this.actor.send(Re,je,et,$,qe,rt)},scheduler:this.actor.scheduler},this.getLayerIndex($),this.getAvailableImages($),this.isSpriteLoaded[$])),this.workerSources[$][ee][ye]}getDEMWorkerSource($,ee){return this.demWorkerSources[$]||(this.demWorkerSources[$]={}),this.demWorkerSources[$][ee]||(this.demWorkerSources[$][ee]=new b),this.demWorkerSources[$][ee]}enforceCacheSizeLimit($,ee){r.enforceCacheSizeLimit(ee)}getWorkerPerformanceMetrics($,ee,ye){ye(void 0,void 0)}}return typeof WorkerGlobalScope!="undefined"&&typeof self!="undefined"&&self instanceof WorkerGlobalScope&&(self.worker=new Ar(self)),Ar}),h(["./shared"],function(r){var v=x;function x(m){return!function(o){return typeof window=="undefined"||typeof document=="undefined"?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var y,E,C=new Blob([""],{type:"text/javascript"}),S=URL.createObjectURL(C);try{E=new Worker(S),y=!0}catch(k){y=!1}return E&&E.terminate(),URL.revokeObjectURL(S),y}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var y=document.createElement("canvas");y.width=y.height=1;var E=y.getContext("2d");if(!E)return!1;var C=E.getImageData(0,0,1,1);return C&&C.width===y.width}()?(w[d=o&&o.failIfMajorPerformanceCaveat]===void 0&&(w[d]=function(y){var E,C=function(S){var k=document.createElement("canvas"),O=Object.create(x.webGLContextAttributes);return O.failIfMajorPerformanceCaveat=S,k.getContext("webgl",O)||k.getContext("experimental-webgl",O)}(y);if(!C)return!1;try{E=C.createShader(C.VERTEX_SHADER)}catch(S){return!1}return!(!E||C.isContextLost())&&(C.shaderSource(E,"void main() {}"),C.compileShader(E),C.getShaderParameter(E,C.COMPILE_STATUS)===!0)}(d)),w[d]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var d}(m)}var w={};function b(m,o){if(Array.isArray(m)){if(!Array.isArray(o)||m.length!==o.length)return!1;for(let d=0;d<m.length;d++)if(!b(m[d],o[d]))return!1;return!0}if(typeof m=="object"&&m!==null&&o!==null){if(typeof o!="object"||Object.keys(m).length!==Object.keys(o).length)return!1;for(const d in m)if(!b(m[d],o[d]))return!1;return!0}return m===o}function A(m,o,d){const y=r.window.document.createElement(m);return o!==void 0&&(y.className=o),d&&d.appendChild(y),y}function L(m,o,d){const y=r.window.document.createElementNS("http://www.w3.org/2000/svg",m);for(const E of Object.keys(o))y.setAttributeNS(null,E,o[E]);return d&&d.appendChild(y),y}x.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const P=r.window.document&&r.window.document.documentElement.style,R=P&&P.userSelect!==void 0?"userSelect":"WebkitUserSelect";let F;function V(){P&&R&&(F=P[R],P[R]="none")}function j(){P&&R&&(P[R]=F)}function J(m){m.preventDefault(),m.stopPropagation(),r.window.removeEventListener("click",J,!0)}function ne(){r.window.addEventListener("click",J,!0),r.window.setTimeout(()=>{r.window.removeEventListener("click",J,!0)},0)}function H(m,o){const d=m.getBoundingClientRect();return ie(m,d,o)}function Q(m,o){const d=m.getBoundingClientRect(),y=[];for(let E=0;E<o.length;E++)y.push(ie(m,d,o[E]));return y}function ae(m){return r.window.InstallTrigger!==void 0&&m.button===2&&m.ctrlKey&&r.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:m.button}function ie(m,o,d){const y=m.offsetWidth===o.width?1:m.offsetWidth/o.width;return new r.pointGeometry((d.clientX-o.left)*y,(d.clientY-o.top)*y)}function le(m,o){var d=o[0],y=o[1],E=o[2],C=o[3],S=d*C-E*y;return S?(m[0]=C*(S=1/S),m[1]=-y*S,m[2]=-E*S,m[3]=d*S,m):null}function fe(m){const{userImage:o}=m;return!!(o&&o.render&&o.render())&&(m.data.replace(new Uint8Array(o.data.buffer)),!0)}class me extends r.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new r.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(o){if(this.loaded!==o&&(this.loaded=o,o)){for(const{ids:d,callback:y}of this.requestors)this._notify(d,y);this.requestors=[]}}hasImage(o){return!!this.getImage(o)}getImage(o){return this.images[o]}addImage(o,d){this._validate(o,d)&&(this.images[o]=d)}_validate(o,d){let y=!0;return this._validateStretch(d.stretchX,d.data&&d.data.width)||(this.fire(new r.ErrorEvent(new Error(`Image "${o}" has invalid "stretchX" value`))),y=!1),this._validateStretch(d.stretchY,d.data&&d.data.height)||(this.fire(new r.ErrorEvent(new Error(`Image "${o}" has invalid "stretchY" value`))),y=!1),this._validateContent(d.content,d)||(this.fire(new r.ErrorEvent(new Error(`Image "${o}" has invalid "content" value`))),y=!1),y}_validateStretch(o,d){if(!o)return!0;let y=0;for(const E of o){if(E[0]<y||E[1]<E[0]||d<E[1])return!1;y=E[1]}return!0}_validateContent(o,d){return!(o&&(o.length!==4||o[0]<0||d.data.width<o[0]||o[1]<0||d.data.height<o[1]||o[2]<0||d.data.width<o[2]||o[3]<0||d.data.height<o[3]||o[2]<o[0]||o[3]<o[1]))}updateImage(o,d){d.version=this.images[o].version+1,this.images[o]=d,this.updatedImages[o]=!0}removeImage(o){const d=this.images[o];delete this.images[o],delete this.patterns[o],d.userImage&&d.userImage.onRemove&&d.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(o,d){let y=!0;if(!this.isLoaded())for(const E of o)this.images[E]||(y=!1);this.isLoaded()||y?this._notify(o,d):this.requestors.push({ids:o,callback:d})}_notify(o,d){const y={};for(const E of o){this.images[E]||this.fire(new r.Event("styleimagemissing",{id:E}));const C=this.images[E];C?y[E]={data:C.data.clone(),pixelRatio:C.pixelRatio,sdf:C.sdf,version:C.version,stretchX:C.stretchX,stretchY:C.stretchY,content:C.content,hasRenderCallback:!!(C.userImage&&C.userImage.render)}:r.warnOnce(`Image "${E}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}d(null,y)}getPixelSize(){const{width:o,height:d}=this.atlasImage;return{width:o,height:d}}getPattern(o){const d=this.patterns[o],y=this.getImage(o);if(!y)return null;if(d&&d.position.version===y.version)return d.position;if(d)d.position.version=y.version;else{const E={w:y.data.width+2,h:y.data.height+2,x:0,y:0},C=new r.ImagePosition(E,y);this.patterns[o]={bin:E,position:C}}return this._updatePatternAtlas(),this.patterns[o].position}bind(o){const d=o.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new r.Texture(o,this.atlasImage,d.RGBA),this.atlasTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE)}_updatePatternAtlas(){const o=[];for(const C in this.patterns)o.push(this.patterns[C].bin);const{w:d,h:y}=r.potpack(o),E=this.atlasImage;E.resize({width:d||1,height:y||1});for(const C in this.patterns){const{bin:S}=this.patterns[C],k=S.x+1,O=S.y+1,U=this.images[C].data,G=U.width,Z=U.height;r.RGBAImage.copy(U,E,{x:0,y:0},{x:k,y:O},{width:G,height:Z}),r.RGBAImage.copy(U,E,{x:0,y:Z-1},{x:k,y:O-1},{width:G,height:1}),r.RGBAImage.copy(U,E,{x:0,y:0},{x:k,y:O+Z},{width:G,height:1}),r.RGBAImage.copy(U,E,{x:G-1,y:0},{x:k-1,y:O},{width:1,height:Z}),r.RGBAImage.copy(U,E,{x:0,y:0},{x:k+G,y:O},{width:1,height:Z})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(o){for(const d of o){if(this.callbackDispatchedThisFrame[d])continue;this.callbackDispatchedThisFrame[d]=!0;const y=this.images[d];fe(y)&&this.updateImage(d,y)}}}const he=new r.Properties({anchor:new r.DataConstantProperty(r.spec.light.anchor),position:new class{constructor(){this.specification=r.spec.light.position}possiblyEvaluate(m,o){return function([d,y,E]){const C=r.degToRad(y+90),S=r.degToRad(E);return{x:d*Math.cos(C)*Math.sin(S),y:d*Math.sin(C)*Math.sin(S),z:d*Math.cos(S),azimuthal:y,polar:E}}(m.expression.evaluate(o))}interpolate(m,o,d){return{x:r.number(m.x,o.x,d),y:r.number(m.y,o.y,d),z:r.number(m.z,o.z,d),azimuthal:r.number(m.azimuthal,o.azimuthal,d),polar:r.number(m.polar,o.polar,d)}}},color:new r.DataConstantProperty(r.spec.light.color),intensity:new r.DataConstantProperty(r.spec.light.intensity)}),Oe="-transition";class Ve extends r.Evented{constructor(o){super(),this._transitionable=new r.Transitionable(he),this.setLight(o),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(o,d={}){if(!this._validate(r.validateLight,o,d))for(const y in o){const E=o[y];r.endsWith(y,Oe)?this._transitionable.setTransition(y.slice(0,-Oe.length),E):this._transitionable.setValue(y,E)}}updateTransitions(o){this._transitioning=this._transitionable.transitioned(o,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(o){this.properties=this._transitioning.possiblyEvaluate(o)}_validate(o,d,y){return(!y||y.validate!==!1)&&r.emitValidationErrors(this,o.call(r.validateStyle,r.extend({value:d,style:{glyphs:!0,sprite:!0},styleSpec:r.spec})))}}const He=new r.Properties({source:new r.DataConstantProperty(r.spec.terrain.source),exaggeration:new r.DataConstantProperty(r.spec.terrain.exaggeration)}),at="-transition";class At extends r.Evented{constructor(o,d){super(),this._transitionable=new r.Transitionable(He),this.set(o),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=d}get(){return this._transitionable.serialize()}set(o){for(const d in o){const y=o[d];r.endsWith(d,at)?this._transitionable.setTransition(d.slice(0,-at.length),y):this._transitionable.setValue(d,y)}}updateTransitions(o){this._transitioning=this._transitionable.transitioned(o,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(o){this.properties=this._transitioning.possiblyEvaluate(o)}}function yt(m,o,d,y){const E=r.smoothstep(45,65,d),[C,S]=Dt(m,y),k=r.length(o);let O=1-Math.min(1,Math.exp((k-C)/(S-C)*-6));return O*=O*O,O=Math.min(1,1.00747*O),O*E*m.alpha}function Dt(m,o){const d=.5/Math.tan(.5*o);return[m.range[0]+d,m.range[1]+d]}const It=new r.Properties({range:new r.DataConstantProperty(r.spec.fog.range),color:new r.DataConstantProperty(r.spec.fog.color),"horizon-blend":new r.DataConstantProperty(r.spec.fog["horizon-blend"])}),Nt="-transition";class Ie extends r.Evented{constructor(o,d){super(),this._transitionable=new r.Transitionable(It),this.set(o),this._transitioning=this._transitionable.untransitioned(),this._transform=d}get state(){return{range:this.properties.get("range"),horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(o,d={}){if(!this._validate(r.validateFog,o,d))for(const y in o){const E=o[y];r.endsWith(y,Nt)?this._transitionable.setTransition(y.slice(0,-Nt.length),E):this._transitionable.setValue(y,E)}}getOpacity(o){if(!this._transform.projection.supportsFog)return 0;const d=this.properties&&this.properties.get("color")||1;return r.smoothstep(45,65,o)*d.a}getOpacityAtLatLng(o,d){return this._transform.projection.supportsFog?function(y,E,C){const S=r.MercatorCoordinate.fromLngLat(E),k=C.elevation?C.elevation.getAtPointOrZero(S):0,O=[S.x,S.y,k];return r.transformMat4(O,O,C.mercatorFogMatrix),yt(y,O,C.pitch,C._fov)}(this.state,o,d):0}getFovAdjustedRange(o){return this._transform.projection.supportsFog?Dt(this.state,o):[0,1]}updateTransitions(o){this._transitioning=this._transitionable.transitioned(o,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(o){this.properties=this._transitioning.possiblyEvaluate(o)}_validate(o,d,y){return(!y||y.validate!==!1)&&r.emitValidationErrors(this,o.call(r.validateStyle,r.extend({value:d,style:{glyphs:!0,sprite:!0},styleSpec:r.spec})))}}class be{constructor(o,d){this.workerPool=o,this.actors=[],this.currentActor=0,this.id=r.uniqueId();const y=this.workerPool.acquire(this.id);for(let E=0;E<y.length;E++){const C=new be.Actor(y[E],d,this.id);C.name=`Worker ${E}`,this.actors.push(C)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(o,d,y){r.asyncAll(this.actors,(E,C)=>{E.send(o,d,C)},y=y||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(o=>{o.remove()}),this.actors=[],this.workerPool.release(this.id)}}function We(m,o,d){return o*(r.EXTENT/(m.tileSize*Math.pow(2,d-m.tileID.overscaledZ)))}be.Actor=r.Actor;class Ge{constructor(o,d,y,E){this.screenBounds=o,this.cameraPoint=d,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=y,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this.screenGeometry.map(C=>E.pointCoordinate3D(C)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(o,d){let y,E;if(o instanceof r.pointGeometry||typeof o[0]=="number"){const C=r.pointGeometry.convert(o);y=[r.pointGeometry.convert(o)],E=d.isPointAboveHorizon(C)}else{const C=r.pointGeometry.convert(o[0]),S=r.pointGeometry.convert(o[1]);y=[C,S],E=r.polygonizeBounds(C,S).every(k=>d.isPointAboveHorizon(k))}return new Ge(y,d.getCameraPoint(),E,d)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(o){return r.polygonizeBounds(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],o)}bufferedCameraGeometry(o){const d=this.screenBounds[0],y=this.screenBounds.length===1?this.screenBounds[0].add(new r.pointGeometry(1,1)):this.screenBounds[1],E=r.polygonizeBounds(d,y,0,!1);return this.cameraPoint.y>y.y&&(this.cameraPoint.x>d.x&&this.cameraPoint.x<y.x?E.splice(3,0,this.cameraPoint):this.cameraPoint.x>=y.x?E[2]=this.cameraPoint:this.cameraPoint.x<=d.x&&(E[3]=this.cameraPoint)),r.bufferConvexPolygon(E,o)}containsTile(o,d,y){const E=o.queryPadding+1,C=o.tileID.wrap,S=y?this._bufferedCameraMercator(E,d).map(ce=>r.getTilePoint(o.tileTransform,ce,C)):this._bufferedScreenMercator(E,d).map(ce=>r.getTilePoint(o.tileTransform,ce,C)),k=this.screenGeometryMercator.map(ce=>r.getTileVec3(o.tileTransform,ce,C)),O=k.map(ce=>new r.pointGeometry(ce[0],ce[1])),U=d.getFreeCameraOptions().position||new r.MercatorCoordinate(0,0,0),G=r.getTileVec3(o.tileTransform,U,C),Z=k.map(ce=>{const te=r.sub(ce,ce,G);return r.normalize(te,te),new r.Ray(G,te)}),se=We(o,1,d.zoom);if(r.polygonIntersectsBox(S,0,0,r.EXTENT,r.EXTENT))return{queryGeometry:this,tilespaceGeometry:O,tilespaceRays:Z,bufferedTilespaceGeometry:S,bufferedTilespaceBounds:(de=r.getBounds(S),de.min.x=r.clamp(de.min.x,0,r.EXTENT),de.min.y=r.clamp(de.min.y,0,r.EXTENT),de.max.x=r.clamp(de.max.x,0,r.EXTENT),de.max.y=r.clamp(de.max.y,0,r.EXTENT),de),tile:o,tileID:o.tileID,pixelToTileUnitsFactor:se};var de}_bufferedScreenMercator(o,d){const y=ke(o);if(this._screenRaycastCache[y])return this._screenRaycastCache[y];{const E=this.bufferedScreenGeometry(o).map(C=>d.pointCoordinate3D(C));return this._screenRaycastCache[y]=E,E}}_bufferedCameraMercator(o,d){const y=ke(o);if(this._cameraRaycastCache[y])return this._cameraRaycastCache[y];{const E=this.bufferedCameraGeometry(o).map(C=>d.pointCoordinate3D(C));return this._cameraRaycastCache[y]=E,E}}}function ke(m){return 100*m|0}function ot(m,o,d){const y=function(E,C){if(E)return d(E);if(C){const S=r.pick(r.extend(C,m),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);C.vector_layers&&(S.vectorLayers=C.vector_layers,S.vectorLayerIds=S.vectorLayers.map(k=>k.id)),S.tiles=o.canonicalizeTileset(S,m.url),d(null,S)}};return m.url?r.getJSON(o.transformRequest(o.normalizeSourceURL(m.url),r.ResourceType.Source),y):r.exported.frame(()=>y(null,m))}class ge{constructor(o,d,y){this.bounds=r.LngLatBounds.convert(this.validateBounds(o)),this.minzoom=d||0,this.maxzoom=y||24}validateBounds(o){return Array.isArray(o)&&o.length===4?[Math.max(-180,o[0]),Math.max(-90,o[1]),Math.min(180,o[2]),Math.min(90,o[3])]:[-180,-90,180,90]}contains(o){const d=Math.pow(2,o.z),y=Math.floor(r.mercatorXfromLng(this.bounds.getWest())*d),E=Math.floor(r.mercatorYfromLat(this.bounds.getNorth())*d),C=Math.ceil(r.mercatorXfromLng(this.bounds.getEast())*d),S=Math.ceil(r.mercatorYfromLat(this.bounds.getSouth())*d);return o.x>=y&&o.x<C&&o.y>=E&&o.y<S}}class Ce{constructor(o,d,y){this.context=o;const E=o.gl;this.buffer=E.createBuffer(),this.dynamicDraw=!!y,this.context.unbindVAO(),o.bindElementBuffer.set(this.buffer),E.bufferData(E.ELEMENT_ARRAY_BUFFER,d.arrayBuffer,this.dynamicDraw?E.DYNAMIC_DRAW:E.STATIC_DRAW),this.dynamicDraw||d.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(o){const d=this.context.gl;this.context.unbindVAO(),this.bind(),d.bufferSubData(d.ELEMENT_ARRAY_BUFFER,0,o.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Ae={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class _e{constructor(o,d,y,E){this.length=d.length,this.attributes=y,this.itemSize=d.bytesPerElement,this.dynamicDraw=E,this.context=o;const C=o.gl;this.buffer=C.createBuffer(),o.bindVertexBuffer.set(this.buffer),C.bufferData(C.ARRAY_BUFFER,d.arrayBuffer,this.dynamicDraw?C.DYNAMIC_DRAW:C.STATIC_DRAW),this.dynamicDraw||d.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(o){const d=this.context.gl;this.bind(),d.bufferSubData(d.ARRAY_BUFFER,0,o.arrayBuffer)}enableAttributes(o,d){for(let y=0;y<this.attributes.length;y++){const E=d.attributes[this.attributes[y].name];E!==void 0&&o.enableVertexAttribArray(E)}}setVertexAttribPointers(o,d,y){for(let E=0;E<this.attributes.length;E++){const C=this.attributes[E],S=d.attributes[C.name];S!==void 0&&o.vertexAttribPointer(S,C.components,o[Ae[C.type]],!1,this.itemSize,C.offset+this.itemSize*(y||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Ne{constructor(o){this.gl=o.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(o){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Je extends Ne{getDefault(){return r.Color.transparent}set(o){const d=this.current;(o.r!==d.r||o.g!==d.g||o.b!==d.b||o.a!==d.a||this.dirty)&&(this.gl.clearColor(o.r,o.g,o.b,o.a),this.current=o,this.dirty=!1)}}class ct extends Ne{getDefault(){return 1}set(o){(o!==this.current||this.dirty)&&(this.gl.clearDepth(o),this.current=o,this.dirty=!1)}}class wt extends Ne{getDefault(){return 0}set(o){(o!==this.current||this.dirty)&&(this.gl.clearStencil(o),this.current=o,this.dirty=!1)}}class Gt extends Ne{getDefault(){return[!0,!0,!0,!0]}set(o){const d=this.current;(o[0]!==d[0]||o[1]!==d[1]||o[2]!==d[2]||o[3]!==d[3]||this.dirty)&&(this.gl.colorMask(o[0],o[1],o[2],o[3]),this.current=o,this.dirty=!1)}}class pe extends Ne{getDefault(){return!0}set(o){(o!==this.current||this.dirty)&&(this.gl.depthMask(o),this.current=o,this.dirty=!1)}}class Me extends Ne{getDefault(){return 255}set(o){(o!==this.current||this.dirty)&&(this.gl.stencilMask(o),this.current=o,this.dirty=!1)}}class bt extends Ne{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(o){const d=this.current;(o.func!==d.func||o.ref!==d.ref||o.mask!==d.mask||this.dirty)&&(this.gl.stencilFunc(o.func,o.ref,o.mask),this.current=o,this.dirty=!1)}}class gt extends Ne{getDefault(){const o=this.gl;return[o.KEEP,o.KEEP,o.KEEP]}set(o){const d=this.current;(o[0]!==d[0]||o[1]!==d[1]||o[2]!==d[2]||this.dirty)&&(this.gl.stencilOp(o[0],o[1],o[2]),this.current=o,this.dirty=!1)}}class bn extends Ne{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;o?d.enable(d.STENCIL_TEST):d.disable(d.STENCIL_TEST),this.current=o,this.dirty=!1}}class hn extends Ne{getDefault(){return[0,1]}set(o){const d=this.current;(o[0]!==d[0]||o[1]!==d[1]||this.dirty)&&(this.gl.depthRange(o[0],o[1]),this.current=o,this.dirty=!1)}}class nn extends Ne{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;o?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST),this.current=o,this.dirty=!1}}class pn extends Ne{getDefault(){return this.gl.LESS}set(o){(o!==this.current||this.dirty)&&(this.gl.depthFunc(o),this.current=o,this.dirty=!1)}}class wn extends Ne{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;o?d.enable(d.BLEND):d.disable(d.BLEND),this.current=o,this.dirty=!1}}class cn extends Ne{getDefault(){const o=this.gl;return[o.ONE,o.ZERO]}set(o){const d=this.current;(o[0]!==d[0]||o[1]!==d[1]||this.dirty)&&(this.gl.blendFunc(o[0],o[1]),this.current=o,this.dirty=!1)}}class Wt extends Ne{getDefault(){return r.Color.transparent}set(o){const d=this.current;(o.r!==d.r||o.g!==d.g||o.b!==d.b||o.a!==d.a||this.dirty)&&(this.gl.blendColor(o.r,o.g,o.b,o.a),this.current=o,this.dirty=!1)}}class sn extends Ne{getDefault(){return this.gl.FUNC_ADD}set(o){(o!==this.current||this.dirty)&&(this.gl.blendEquation(o),this.current=o,this.dirty=!1)}}class Xt extends Ne{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;o?d.enable(d.CULL_FACE):d.disable(d.CULL_FACE),this.current=o,this.dirty=!1}}class Xe extends Ne{getDefault(){return this.gl.BACK}set(o){(o!==this.current||this.dirty)&&(this.gl.cullFace(o),this.current=o,this.dirty=!1)}}class Ut extends Ne{getDefault(){return this.gl.CCW}set(o){(o!==this.current||this.dirty)&&(this.gl.frontFace(o),this.current=o,this.dirty=!1)}}class en extends Ne{getDefault(){return null}set(o){(o!==this.current||this.dirty)&&(this.gl.useProgram(o),this.current=o,this.dirty=!1)}}class Pn extends Ne{getDefault(){return this.gl.TEXTURE0}set(o){(o!==this.current||this.dirty)&&(this.gl.activeTexture(o),this.current=o,this.dirty=!1)}}class fn extends Ne{getDefault(){const o=this.gl;return[0,0,o.drawingBufferWidth,o.drawingBufferHeight]}set(o){const d=this.current;(o[0]!==d[0]||o[1]!==d[1]||o[2]!==d[2]||o[3]!==d[3]||this.dirty)&&(this.gl.viewport(o[0],o[1],o[2],o[3]),this.current=o,this.dirty=!1)}}class On extends Ne{getDefault(){return null}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;d.bindFramebuffer(d.FRAMEBUFFER,o),this.current=o,this.dirty=!1}}class Gn extends Ne{getDefault(){return null}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;d.bindRenderbuffer(d.RENDERBUFFER,o),this.current=o,this.dirty=!1}}class qn extends Ne{getDefault(){return null}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;d.bindTexture(d.TEXTURE_2D,o),this.current=o,this.dirty=!1}}class ji extends Ne{getDefault(){return null}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;d.bindBuffer(d.ARRAY_BUFFER,o),this.current=o,this.dirty=!1}}class Nn extends Ne{getDefault(){return null}set(o){const d=this.gl;d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,o),this.current=o,this.dirty=!1}}class Di extends Ne{constructor(o){super(o),this.vao=o.extVertexArrayObject}getDefault(){return null}set(o){this.vao&&(o!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(o),this.current=o,this.dirty=!1)}}class ei extends Ne{getDefault(){return 4}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;d.pixelStorei(d.UNPACK_ALIGNMENT,o),this.current=o,this.dirty=!1}}class Ji extends Ne{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;d.pixelStorei(d.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o),this.current=o,this.dirty=!1}}class _i extends Ne{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;d.pixelStorei(d.UNPACK_FLIP_Y_WEBGL,o),this.current=o,this.dirty=!1}}class jr extends Ne{constructor(o,d){super(o),this.context=o,this.parent=d}getDefault(){return null}}class zi extends jr{setDirty(){this.dirty=!0}set(o){if(o===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const d=this.gl;d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,o,0),this.current=o,this.dirty=!1}}class Hr extends jr{attachment(){return this.gl.DEPTH_ATTACHMENT}set(o){if(o===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const d=this.gl;d.framebufferRenderbuffer(d.FRAMEBUFFER,this.attachment(),d.RENDERBUFFER,o),this.current=o,this.dirty=!1}}class Ar extends Hr{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class we{constructor(o,d,y,E){this.context=o,this.width=d,this.height=y;const C=this.framebuffer=o.gl.createFramebuffer();this.colorAttachment=new zi(o,C),E&&(this.depthAttachment=new Hr(o,C))}destroy(){const o=this.context.gl,d=this.colorAttachment.get();if(d&&o.deleteTexture(d),this.depthAttachment){const y=this.depthAttachment.get();y&&o.deleteRenderbuffer(y)}o.deleteFramebuffer(this.framebuffer)}}class ${constructor(o){this.gl=o,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new Je(this),this.clearDepth=new ct(this),this.clearStencil=new wt(this),this.colorMask=new Gt(this),this.depthMask=new pe(this),this.stencilMask=new Me(this),this.stencilFunc=new bt(this),this.stencilOp=new gt(this),this.stencilTest=new bn(this),this.depthRange=new hn(this),this.depthTest=new nn(this),this.depthFunc=new pn(this),this.blend=new wn(this),this.blendFunc=new cn(this),this.blendColor=new Wt(this),this.blendEquation=new sn(this),this.cullFace=new Xt(this),this.cullFaceSide=new Xe(this),this.frontFace=new Ut(this),this.program=new en(this),this.activeTexture=new Pn(this),this.viewport=new fn(this),this.bindFramebuffer=new On(this),this.bindRenderbuffer=new Gn(this),this.bindTexture=new qn(this),this.bindVertexBuffer=new ji(this),this.bindElementBuffer=new Nn(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new Di(this),this.pixelStoreUnpack=new ei(this),this.pixelStoreUnpackPremultiplyAlpha=new Ji(this),this.pixelStoreUnpackFlipY=new _i(this),this.extTextureFilterAnisotropic=o.getExtension("EXT_texture_filter_anisotropic")||o.getExtension("MOZ_EXT_texture_filter_anisotropic")||o.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=o.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extTextureHalfFloat=o.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(o.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=o.getExtension("EXT_color_buffer_half_float")),this.extTimerQuery=o.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=o.getParameter(o.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(o,d){return new Ce(this,o,d)}createVertexBuffer(o,d,y){return new _e(this,o,d,y)}createRenderbuffer(o,d,y){const E=this.gl,C=E.createRenderbuffer();return this.bindRenderbuffer.set(C),E.renderbufferStorage(E.RENDERBUFFER,o,d,y),this.bindRenderbuffer.set(null),C}createFramebuffer(o,d,y){return new we(this,o,d,y)}clear({color:o,depth:d,stencil:y}){const E=this.gl;let C=0;o&&(C|=E.COLOR_BUFFER_BIT,this.clearColor.set(o),this.colorMask.set([!0,!0,!0,!0])),d!==void 0&&(C|=E.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(d),this.depthMask.set(!0)),y!==void 0&&(C|=E.STENCIL_BUFFER_BIT,this.clearStencil.set(y),this.stencilMask.set(255)),E.clear(C)}setCullFace(o){o.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(o.mode),this.frontFace.set(o.frontFace))}setDepthMode(o){o.func!==this.gl.ALWAYS||o.mask?(this.depthTest.set(!0),this.depthFunc.set(o.func),this.depthMask.set(o.mask),this.depthRange.set(o.range)):this.depthTest.set(!1)}setStencilMode(o){o.test.func!==this.gl.ALWAYS||o.mask?(this.stencilTest.set(!0),this.stencilMask.set(o.mask),this.stencilOp.set([o.fail,o.depthFail,o.pass]),this.stencilFunc.set({func:o.test.func,ref:o.ref,mask:o.test.mask})):this.stencilTest.set(!1)}setColorMode(o){b(o.blendFunction,r.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(o.blendFunction),this.blendColor.set(o.blendColor)),this.colorMask.set(o.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class ee extends r.Evented{constructor(o,d,y,E){super(),this.id=o,this.dispatcher=y,this.setEventedParent(E),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=r.extend({type:"raster"},d),r.extend(this,r.pick(d,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new r.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ot(this._options,this.map._requestManager,(o,d)=>{this._tileJSONRequest=null,this._loaded=!0,o?this.fire(new r.ErrorEvent(o)):d&&(r.extend(this,d),d.bounds&&(this.tileBounds=new ge(d.bounds,this.minzoom,this.maxzoom)),r.postTurnstileEvent(d.tiles),this.fire(new r.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new r.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(o){this.map=o,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return r.extend({},this._options)}hasTile(o){return!this.tileBounds||this.tileBounds.contains(o.canonical)}loadTile(o,d){const y=r.exported.devicePixelRatio>=2,E=this.map._requestManager.normalizeTileURL(o.tileID.canonical.url(this.tiles,this.scheme),y,this.tileSize);o.request=r.getImage(this.map._requestManager.transformRequest(E,r.ResourceType.Tile),(C,S,k,O)=>(delete o.request,o.aborted?(o.state="unloaded",d(null)):C?(o.state="errored",d(C)):S?(this.map._refreshExpiredTiles&&o.setExpiryData({cacheControl:k,expires:O}),o.setTexture(S,this.map.painter),o.state="loaded",r.cacheEntryPossiblyAdded(this.dispatcher),void d(null)):d(null)))}static loadTileData(o,d,y){o.setTexture(d,y)}static unloadTileData(o,d){o.texture&&d.saveTileTexture(o.texture)}abortTile(o,d){o.request&&(o.request.cancel(),delete o.request),d()}unloadTile(o,d){o.texture&&this.map.painter.saveTileTexture(o.texture),d()}hasTransition(){return!1}}let ye;function Re(m,o,d,y,E,C,S,k){const O=[m,d,E,o,y,C,1,1,1],U=[S,k,1],G=r.adjoint([],O),[Z,se,de]=r.transformMat3(U,U,r.transpose(G,G));return r.multiply(O,[Z,0,0,0,se,0,0,0,de],O)}class je extends r.Evented{constructor(o,d,y,E){super(),this.id=o,this.dispatcher=y,this.coordinates=d.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(E),this.options=d}load(o){this._loaded=!1,this.fire(new r.Event("dataloading",{dataType:"source"})),this.url=this.options.url,r.getImage(this.map._requestManager.transformRequest(this.url,r.ResourceType.Image),(d,y)=>{if(this._loaded=!0,d)this.fire(new r.ErrorEvent(d));else if(y){const{HTMLImageElement:E}=r.window;this.image=y instanceof E?r.exported.getImageData(y):y,this.width=this.image.width,this.height=this.image.height,o&&(this.coordinates=o),this._finishLoading()}})}loaded(){return this._loaded}updateImage(o){return this.image&&o.url?(this.options.url=o.url,this.load(o.coordinates),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new r.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(o){this.map=o,this.load()}onRemove(){this.texture&&this.texture.destroy()}setCoordinates(o){this.coordinates=o,this._boundsArray=void 0;const d=o.map(r.MercatorCoordinate.fromLngLat);return this.tileID=function(y){let E=1/0,C=1/0,S=-1/0,k=-1/0;for(const Z of y)E=Math.min(E,Z.x),C=Math.min(C,Z.y),S=Math.max(S,Z.x),k=Math.max(k,Z.y);const O=Math.max(S-E,k-C),U=Math.max(0,Math.floor(-Math.log(O)/Math.LN2)),G=Math.pow(2,U);return new r.CanonicalTileID(U,Math.floor((E+S)/2*G),Math.floor((C+k)/2*G))}(d),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new r.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(o){for(const O in this.tiles){const U=this.tiles[O];U.state!=="loaded"&&(U.state="loaded",U.texture=this.texture)}if(this._boundsArray)return;const d=r.tileTransform(this.tileID,this.map.transform.projection),[y,E,C,S]=this.coordinates.map(O=>{const U=d.projection.project(O[0],O[1]);return r.getTilePoint(d,U)._round()});this.perspectiveTransform=function(O,U,G,Z,se,de,ce,te,Le,ve){const De=Re(0,0,O,0,0,U,O,U),Se=Re(G,Z,se,de,ce,te,Le,ve);return r.multiply(Se,r.adjoint(De,De),Se),[Se[6]/Se[8]*O/r.EXTENT,Se[7]/Se[8]*U/r.EXTENT]}(this.width,this.height,y.x,y.y,E.x,E.y,S.x,S.y,C.x,C.y);const k=this._boundsArray=new r.StructArrayLayout4i8;k.emplaceBack(y.x,y.y,0,0),k.emplaceBack(E.x,E.y,r.EXTENT,0),k.emplaceBack(S.x,S.y,0,r.EXTENT),k.emplaceBack(C.x,C.y,r.EXTENT,r.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=o.createVertexBuffer(k,r.boundsAttributes.members),this.boundsSegments=r.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const o=this.map.painter.context,d=o.gl;this.texture?this.texture.update(this.image):(this.texture=new r.Texture(o,this.image,d.RGBA),this.texture.bind(d.LINEAR,d.CLAMP_TO_EDGE)),this._prepareData(o)}loadTile(o,d){this.tileID&&this.tileID.equals(o.tileID.canonical)?(this.tiles[String(o.tileID.wrap)]=o,o.buckets={},d(null)):(o.state="errored",d(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const et={vector:class extends r.Evented{constructor(m,o,d,y){if(super(),this.id=m,this.dispatcher=d,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,r.extend(this,r.pick(o,["url","scheme","tileSize","promoteId"])),this._options=r.extend({type:"vector"},o),this._collectResourceTiming=o.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(y),this._tileWorkers={},this._deduped=new r.DedupedRequest}load(){this._loaded=!1,this.fire(new r.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ot(this._options,this.map._requestManager,(m,o)=>{this._tileJSONRequest=null,this._loaded=!0,m?this.fire(new r.ErrorEvent(m)):o&&(r.extend(this,o),o.bounds&&(this.tileBounds=new ge(o.bounds,this.minzoom,this.maxzoom)),r.postTurnstileEvent(o.tiles,this.map._requestManager._customAccessToken),this.fire(new r.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new r.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(m){return!this.tileBounds||this.tileBounds.contains(m.canonical)}onAdd(m){this.map=m,this.load()}setSourceProperty(m){this._tileJSONRequest&&this._tileJSONRequest.cancel(),m();const o=this.map.style._getSourceCaches(this.id);for(const d of o)d.clearTiles();this.load()}setTiles(m){return this.setSourceProperty(()=>{this._options.tiles=m}),this}setUrl(m){return this.setSourceProperty(()=>{this.url=m,this._options.url=m}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return r.extend({},this._options)}loadTile(m,o){const d=this.map._requestManager.normalizeTileURL(m.tileID.canonical.url(this.tiles,this.scheme)),y={request:this.map._requestManager.transformRequest(d,r.ResourceType.Tile),data:void 0,uid:m.uid,tileID:m.tileID,tileZoom:m.tileZoom,zoom:m.tileID.overscaledZ,tileSize:this.tileSize*m.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:r.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:m.isSymbolTile};if(y.request.collectResourceTiming=this._collectResourceTiming,m.actor&&m.state!=="expired")m.state==="loading"?m.reloadCallback=o:m.request=m.actor.send("reloadTile",y,E.bind(this));else if(m.actor=this._tileWorkers[d]=this._tileWorkers[d]||this.dispatcher.getActor(),this.dispatcher.ready)m.request=m.actor.send("loadTile",y,E.bind(this),void 0,!0);else{const C=r.loadVectorTile.call({deduped:this._deduped},y,(S,k)=>{S||!k?E.call(this,S):(y.data={cacheControl:k.cacheControl,expires:k.expires,rawData:k.rawData.slice(0)},m.actor&&m.actor.send("loadTile",y,E.bind(this),void 0,!0))},!0);m.request={cancel:C}}function E(C,S){return delete m.request,m.aborted?o(null):C&&C.status!==404?o(C):(S&&S.resourceTiming&&(m.resourceTiming=S.resourceTiming),this.map._refreshExpiredTiles&&S&&m.setExpiryData(S),m.loadVectorData(S,this.map.painter),r.cacheEntryPossiblyAdded(this.dispatcher),o(null),void(m.reloadCallback&&(this.loadTile(m,m.reloadCallback),m.reloadCallback=null)))}}abortTile(m){m.request&&(m.request.cancel(),delete m.request),m.actor&&m.actor.send("abortTile",{uid:m.uid,type:this.type,source:this.id})}unloadTile(m){m.unloadVectorData(),m.actor&&m.actor.send("removeTile",{uid:m.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:ee,"raster-dem":class extends ee{constructor(m,o,d,y){super(m,o,d,y),this.type="raster-dem",this.maxzoom=22,this._options=r.extend({type:"raster-dem"},o),this.encoding=o.encoding||"mapbox"}loadTile(m,o){const d=this.map._requestManager.normalizeTileURL(m.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function y(E,C){E&&(m.state="errored",o(E)),C&&(m.dem=C,m.dem.onDeserialize(),m.needsHillshadePrepare=!0,m.needsDEMTextureUpload=!0,m.state="loaded",o(null))}m.request=r.getImage(this.map._requestManager.transformRequest(d,r.ResourceType.Tile),function(E,C,S,k){if(delete m.request,m.aborted)m.state="unloaded",o(null);else if(E)m.state="errored",o(E);else if(C){this.map._refreshExpiredTiles&&m.setExpiryData({cacheControl:S,expires:k});const O=r.window.ImageBitmap&&C instanceof r.window.ImageBitmap&&(ye==null&&(ye=r.window.OffscreenCanvas&&new r.window.OffscreenCanvas(1,1).getContext("2d")&&typeof r.window.createImageBitmap=="function"),ye),U=1-(C.width-r.prevPowerOfTwo(C.width))/2;U<1||m.neighboringTiles||(m.neighboringTiles=this._getNeighboringTiles(m.tileID));const G=O?C:r.exported.getImageData(C,U),Z={uid:m.uid,coord:m.tileID,source:this.id,rawImageData:G,encoding:this.encoding,padding:U};m.actor&&m.state!=="expired"||(m.actor=this.dispatcher.getActor(),m.actor.send("loadDEMTile",Z,y.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(m){const o=m.canonical,d=Math.pow(2,o.z),y=(o.x-1+d)%d,E=o.x===0?m.wrap-1:m.wrap,C=(o.x+1+d)%d,S=o.x+1===d?m.wrap+1:m.wrap,k={};return k[new r.OverscaledTileID(m.overscaledZ,E,o.z,y,o.y).key]={backfilled:!1},k[new r.OverscaledTileID(m.overscaledZ,S,o.z,C,o.y).key]={backfilled:!1},o.y>0&&(k[new r.OverscaledTileID(m.overscaledZ,E,o.z,y,o.y-1).key]={backfilled:!1},k[new r.OverscaledTileID(m.overscaledZ,m.wrap,o.z,o.x,o.y-1).key]={backfilled:!1},k[new r.OverscaledTileID(m.overscaledZ,S,o.z,C,o.y-1).key]={backfilled:!1}),o.y+1<d&&(k[new r.OverscaledTileID(m.overscaledZ,E,o.z,y,o.y+1).key]={backfilled:!1},k[new r.OverscaledTileID(m.overscaledZ,m.wrap,o.z,o.x,o.y+1).key]={backfilled:!1},k[new r.OverscaledTileID(m.overscaledZ,S,o.z,C,o.y+1).key]={backfilled:!1}),k}unloadTile(m){m.demTexture&&this.map.painter.saveTileTexture(m.demTexture),m.fbo&&(m.fbo.destroy(),delete m.fbo),m.dem&&delete m.dem,delete m.neighboringTiles,m.state="unloaded"}},geojson:class extends r.Evented{constructor(m,o,d,y){super(),this.id=m,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=d.getActor(),this.setEventedParent(y),this._data=o.data,this._options=r.extend({},o),this._collectResourceTiming=o.collectResourceTiming,o.maxzoom!==void 0&&(this.maxzoom=o.maxzoom),o.type&&(this.type=o.type),o.attribution&&(this.attribution=o.attribution),this.promoteId=o.promoteId;const E=r.EXTENT/this.tileSize;this.workerOptions=r.extend({source:this.id,cluster:o.cluster||!1,geojsonVtOptions:{buffer:(o.buffer!==void 0?o.buffer:128)*E,tolerance:(o.tolerance!==void 0?o.tolerance:.375)*E,extent:r.EXTENT,maxZoom:this.maxzoom,lineMetrics:o.lineMetrics||!1,generateId:o.generateId||!1},superclusterOptions:{maxZoom:o.clusterMaxZoom!==void 0?o.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,o.clusterMinPoints||2),extent:r.EXTENT,radius:(o.clusterRadius!==void 0?o.clusterRadius:50)*E,log:!1,generateId:o.generateId||!1},clusterProperties:o.clusterProperties,filter:o.filter},o.workerOptions)}onAdd(m){this.map=m,this.setData(this._data)}setData(m){return this._data=m,this._updateWorkerData(),this}getClusterExpansionZoom(m,o){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:m,source:this.id},o),this}getClusterChildren(m,o){return this.actor.send("geojson.getClusterChildren",{clusterId:m,source:this.id},o),this}getClusterLeaves(m,o,d,y){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:m,limit:o,offset:d},y),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new r.Event("dataloading",{dataType:"source"})),this._loaded=!1;const m=r.extend({},this.workerOptions),o=this._data;typeof o=="string"?(m.request=this.map._requestManager.transformRequest(r.exported.resolveURL(o),r.ResourceType.Source),m.request.collectResourceTiming=this._collectResourceTiming):m.data=JSON.stringify(o),this._pendingLoad=this.actor.send(`${this.type}.loadData`,m,(d,y)=>{if(this._loaded=!0,this._pendingLoad=null,d)this.fire(new r.ErrorEvent(d));else{const E={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&y&&y.resourceTiming&&y.resourceTiming[this.id]&&(E.resourceTiming=y.resourceTiming[this.id]),this.fire(new r.Event("data",E)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(m,o){const d=m.actor?"reloadTile":"loadTile";m.actor=this.actor,m.request=this.actor.send(d,{type:this.type,uid:m.uid,tileID:m.tileID,tileZoom:m.tileZoom,zoom:m.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:r.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(y,E)=>(delete m.request,m.unloadVectorData(),m.aborted?o(null):y?o(y):(m.loadVectorData(E,this.map.painter,d==="reloadTile"),o(null))),void 0,d==="loadTile")}abortTile(m){m.request&&(m.request.cancel(),delete m.request),m.aborted=!0}unloadTile(m){m.unloadVectorData(),this.actor.send("removeTile",{uid:m.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return r.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends je{constructor(m,o,d,y){super(m,o,d,y),this.roundZoom=!0,this.type="video",this.options=o}load(){this._loaded=!1;const m=this.options;this.urls=[];for(const o of m.urls)this.urls.push(this.map._requestManager.transformRequest(o,r.ResourceType.Source).url);r.getVideo(this.urls,(o,d)=>{this._loaded=!0,o?this.fire(new r.ErrorEvent(o)):d&&(this.video=d,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(m){if(this.video){const o=this.video.seekable;m<o.start(0)||m>o.end(0)?this.fire(new r.ErrorEvent(new r.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${o.start(0)} and ${o.end(0)}-second mark.`))):this.video.currentTime=m}}getVideo(){return this.video}onAdd(m){this.map||(this.map=m,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const m=this.map.painter.context,o=m.gl;this.texture?this.video.paused||(this.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE),o.texSubImage2D(o.TEXTURE_2D,0,0,0,o.RGBA,o.UNSIGNED_BYTE,this.video)):(this.texture=new r.Texture(m,this.video,o.RGBA),this.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(m)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:je,canvas:class extends je{constructor(m,o,d,y){super(m,o,d,y),o.coordinates?Array.isArray(o.coordinates)&&o.coordinates.length===4&&!o.coordinates.some(E=>!Array.isArray(E)||E.length!==2||E.some(C=>typeof C!="number"))||this.fire(new r.ErrorEvent(new r.ValidationError(`sources.${m}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new r.ErrorEvent(new r.ValidationError(`sources.${m}`,null,'missing required property "coordinates"'))),o.animate&&typeof o.animate!="boolean"&&this.fire(new r.ErrorEvent(new r.ValidationError(`sources.${m}`,null,'optional "animate" property must be a boolean value'))),o.canvas?typeof o.canvas=="string"||o.canvas instanceof r.window.HTMLCanvasElement||this.fire(new r.ErrorEvent(new r.ValidationError(`sources.${m}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new r.ErrorEvent(new r.ValidationError(`sources.${m}`,null,'missing required property "canvas"'))),this.options=o,this.animate=o.animate===void 0||o.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof r.window.HTMLCanvasElement?this.options.canvas:r.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new r.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(m){this.map=m,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let m=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,m=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,m=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const o=this.map.painter.context;this.texture?(m||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new r.Texture(o,this.canvas,o.gl.RGBA,{premultiply:!0}),this._prepareData(o)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const m of[this.canvas.width,this.canvas.height])if(isNaN(m)||m<=0)return!0;return!1}},custom:class extends r.Evented{constructor(m,o,d,y){super(),this.id=m,this.type="custom",this._dataType="raster",this._dispatcher=d,this._implementation=o,this.setEventedParent(y),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new r.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new r.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new ge(this._implementation.bounds,this.minzoom,this.maxzoom)),o.update=this._update.bind(this),o.coveringTiles=this._coveringTiles.bind(this),r.extend(this,r.pick(o,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return r.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new r.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new r.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(m){this._map=m,this._loaded=!1,this.fire(new r.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(m),this.load()}onRemove(m){this._implementation.onRemove&&this._implementation.onRemove(m)}hasTile(m){if(this._implementation.hasTile){const{x:o,y:d,z:y}=m.canonical;return this._implementation.hasTile({x:o,y:d,z:y})}return!this.tileBounds||this.tileBounds.contains(m.canonical)}loadTile(m,o){const{x:d,y,z:E}=m.tileID.canonical,C=new r.window.AbortController,S=this._implementation.loadTile({x:d,y,z:E},{signal:C.signal});if(!S)return this.loadTileData(m,{width:this.tileSize,height:this.tileSize,data:null}),m.state="loaded",o(null);S.cancel=()=>C.abort(),m.request=S.then(function(k){return delete m.request,m.aborted?(m.state="unloaded",o(null)):k?function(O){return O instanceof r.window.ImageData||O instanceof r.window.ImageBitmap||O instanceof r.window.HTMLCanvasElement}(k)?(this.loadTileData(m,k),m.state="loaded",void o(null)):(m.state="errored",o(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`))):(this.loadTileData(m,{width:this.tileSize,height:this.tileSize,data:null}),m.state="loaded",o(null))}.bind(this)).catch(k=>{k.code!==20&&(m.state="errored",o(k))})}loadTileData(m,o){ee.loadTileData(m,o,this._map.painter)}unloadTileData(m){ee.unloadTileData(m,this._map.painter)}prepareTile(m){if(!this._implementation.prepareTile)return null;const{x:o,y:d,z:y}=m.tileID.canonical,E=this._implementation.prepareTile({x:o,y:d,z:y});return E?(this.loadTileData(m,E),m.state="loaded",E):null}unloadTile(m,o){if(this.unloadTileData(m),this._implementation.unloadTile){const{x:d,y,z:E}=m.tileID.canonical;this._implementation.unloadTile({x:d,y,z:E})}o()}abortTile(m,o){m.request&&m.request.cancel&&(m.request.cancel(),delete m.request),o()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(m=>({x:m.canonical.x,y:m.canonical.y,z:m.canonical.z}))}_update(){this.fire(new r.Event("data",{dataType:"source",sourceDataType:"content"}))}}},tt=function(m,o,d,y){const E=new et[o.type](m,o,d,y);if(E.id!==m)throw new Error(`Expected Source id to be ${m} instead of ${E.id}`);return r.bindAll(["load","abort","unload","serialize","prepare"],E),E};function qe(m,o){const d=r.identity([]);return r.scale(d,d,[.5*m.width,.5*-m.height,1]),r.translate(d,d,[1,-1,0]),r.multiply$1(d,d,m.calculateProjMatrix(o.toUnwrapped())),Float32Array.from(d)}function rt(m,o,d,y,E,C,S,k=!1){const O=m.tilesIn(y,S,k);O.sort(Vt);const U=[];for(const Z of O)U.push({wrappedTileID:Z.tile.tileID.wrapped().key,queryResults:Z.tile.queryRenderedFeatures(o,d,m._state,Z,E,C,qe(m.transform,Z.tile.tileID),k)});const G=function(Z){const se={},de={};for(const ce of Z){const te=ce.queryResults,Le=ce.wrappedTileID,ve=de[Le]=de[Le]||{};for(const De in te){const Se=te[De],ze=ve[De]=ve[De]||{},Ee=se[De]=se[De]||[];for(const Ue of Se)ze[Ue.featureIndex]||(ze[Ue.featureIndex]=!0,Ee.push(Ue))}}return se}(U);for(const Z in G)G[Z].forEach(se=>{const de=se.feature,ce=de.layer;ce&&ce.type!=="background"&&ce.type!=="sky"&&(de.source=ce.source,ce["source-layer"]&&(de.sourceLayer=ce["source-layer"]),de.state=de.id!==void 0?m.getFeatureState(ce["source-layer"],de.id):{})});return G}function vt(m,o){const d=m.getRenderableIds().map(C=>m.getTileByID(C)),y=[],E={};for(let C=0;C<d.length;C++){const S=d[C],k=S.tileID.canonical.key;E[k]||(E[k]=!0,S.querySourceFeatures(y,o))}return y}function Vt(m,o){const d=m.tileID,y=o.tileID;return d.overscaledZ-y.overscaledZ||d.canonical.y-y.canonical.y||d.wrap-y.wrap||d.canonical.x-y.canonical.x}function Ct(){return ks.workerClass!=null?new ks.workerClass:new r.window.Worker(ks.workerUrl)}const _n="mapboxgl_preloaded_worker_pool";class Y{constructor(){this.active={}}acquire(o){if(!this.workers)for(this.workers=[];this.workers.length<Y.workerCount;)this.workers.push(new Ct);return this.active[o]=!0,this.workers.slice()}release(o){delete this.active[o],this.numActive()===0&&(this.workers.forEach(d=>{d.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[_n]}numActive(){return Object.keys(this.active).length}}let re;function Fe(){return re||(re=new Y),re}function Te(m,o){const d={};for(const y in m)y!=="ref"&&(d[y]=m[y]);return r.refProperties.forEach(y=>{y in o&&(d[y]=o[y])}),d}function Tt(m){m=m.slice();const o=Object.create(null);for(let d=0;d<m.length;d++)o[m[d].id]=m[d];for(let d=0;d<m.length;d++)"ref"in m[d]&&(m[d]=Te(m[d],o[m[d].ref]));return m}Y.workerCount=2;const _t={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function Ot(m,o,d){d.push({command:_t.addSource,args:[m,o[m]]})}function rn(m,o,d){o.push({command:_t.removeSource,args:[m]}),d[m]=!0}function Sn(m,o,d,y){rn(m,d,y),Ot(m,o,d)}function Ln(m,o,d){let y;for(y in m[d])if(m[d].hasOwnProperty(y)&&y!=="data"&&!b(m[d][y],o[d][y]))return!1;for(y in o[d])if(o[d].hasOwnProperty(y)&&y!=="data"&&!b(m[d][y],o[d][y]))return!1;return!0}function Mt(m,o,d,y,E,C){let S;for(S in o=o||{},m=m||{})m.hasOwnProperty(S)&&(b(m[S],o[S])||d.push({command:C,args:[y,S,o[S],E]}));for(S in o)o.hasOwnProperty(S)&&!m.hasOwnProperty(S)&&(b(m[S],o[S])||d.push({command:C,args:[y,S,o[S],E]}))}function un(m){return m.id}function Kt(m,o){return m[o.id]=o,m}class mn{constructor(o,d){this.reset(o,d)}reset(o,d){this.points=o||[],this._distances=[0];for(let y=1;y<this.points.length;y++)this._distances[y]=this._distances[y-1]+this.points[y].dist(this.points[y-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(d||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(o){if(this.points.length===1)return this.points[0];o=r.clamp(o,0,1);let d=1,y=this._distances[d];const E=o*this.paddedLength+this.padding;for(;y<E&&d<this._distances.length;)y=this._distances[++d];const C=d-1,S=this._distances[C],k=y-S,O=k>0?(E-S)/k:0;return this.points[C].mult(1-O).add(this.points[d].mult(O))}}class Tn{constructor(o,d,y){const E=this.boxCells=[],C=this.circleCells=[];this.xCellCount=Math.ceil(o/y),this.yCellCount=Math.ceil(d/y);for(let S=0;S<this.xCellCount*this.yCellCount;S++)E.push([]),C.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=o,this.height=d,this.xScale=this.xCellCount/o,this.yScale=this.yCellCount/d,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(o,d,y,E,C){this._forEachCell(d,y,E,C,this._insertBoxCell,this.boxUid++),this.boxKeys.push(o),this.bboxes.push(d),this.bboxes.push(y),this.bboxes.push(E),this.bboxes.push(C)}insertCircle(o,d,y,E){this._forEachCell(d-E,y-E,d+E,y+E,this._insertCircleCell,this.circleUid++),this.circleKeys.push(o),this.circles.push(d),this.circles.push(y),this.circles.push(E)}_insertBoxCell(o,d,y,E,C,S){this.boxCells[C].push(S)}_insertCircleCell(o,d,y,E,C,S){this.circleCells[C].push(S)}_query(o,d,y,E,C,S){if(y<0||o>this.width||E<0||d>this.height)return!C&&[];const k=[];if(o<=0&&d<=0&&this.width<=y&&this.height<=E){if(C)return!0;for(let O=0;O<this.boxKeys.length;O++)k.push({key:this.boxKeys[O],x1:this.bboxes[4*O],y1:this.bboxes[4*O+1],x2:this.bboxes[4*O+2],y2:this.bboxes[4*O+3]});for(let O=0;O<this.circleKeys.length;O++){const U=this.circles[3*O],G=this.circles[3*O+1],Z=this.circles[3*O+2];k.push({key:this.circleKeys[O],x1:U-Z,y1:G-Z,x2:U+Z,y2:G+Z})}return S?k.filter(S):k}return this._forEachCell(o,d,y,E,this._queryCell,k,{hitTest:C,seenUids:{box:{},circle:{}}},S),C?k.length>0:k}_queryCircle(o,d,y,E,C){const S=o-y,k=o+y,O=d-y,U=d+y;if(k<0||S>this.width||U<0||O>this.height)return!E&&[];const G=[];return this._forEachCell(S,O,k,U,this._queryCellCircle,G,{hitTest:E,circle:{x:o,y:d,radius:y},seenUids:{box:{},circle:{}}},C),E?G.length>0:G}query(o,d,y,E,C){return this._query(o,d,y,E,!1,C)}hitTest(o,d,y,E,C){return this._query(o,d,y,E,!0,C)}hitTestCircle(o,d,y,E){return this._queryCircle(o,d,y,!0,E)}_queryCell(o,d,y,E,C,S,k,O){const U=k.seenUids,G=this.boxCells[C];if(G!==null){const se=this.bboxes;for(const de of G)if(!U.box[de]){U.box[de]=!0;const ce=4*de;if(o<=se[ce+2]&&d<=se[ce+3]&&y>=se[ce+0]&&E>=se[ce+1]&&(!O||O(this.boxKeys[de]))){if(k.hitTest)return S.push(!0),!0;S.push({key:this.boxKeys[de],x1:se[ce],y1:se[ce+1],x2:se[ce+2],y2:se[ce+3]})}}}const Z=this.circleCells[C];if(Z!==null){const se=this.circles;for(const de of Z)if(!U.circle[de]){U.circle[de]=!0;const ce=3*de;if(this._circleAndRectCollide(se[ce],se[ce+1],se[ce+2],o,d,y,E)&&(!O||O(this.circleKeys[de]))){if(k.hitTest)return S.push(!0),!0;{const te=se[ce],Le=se[ce+1],ve=se[ce+2];S.push({key:this.circleKeys[de],x1:te-ve,y1:Le-ve,x2:te+ve,y2:Le+ve})}}}}}_queryCellCircle(o,d,y,E,C,S,k,O){const U=k.circle,G=k.seenUids,Z=this.boxCells[C];if(Z!==null){const de=this.bboxes;for(const ce of Z)if(!G.box[ce]){G.box[ce]=!0;const te=4*ce;if(this._circleAndRectCollide(U.x,U.y,U.radius,de[te+0],de[te+1],de[te+2],de[te+3])&&(!O||O(this.boxKeys[ce])))return S.push(!0),!0}}const se=this.circleCells[C];if(se!==null){const de=this.circles;for(const ce of se)if(!G.circle[ce]){G.circle[ce]=!0;const te=3*ce;if(this._circlesCollide(de[te],de[te+1],de[te+2],U.x,U.y,U.radius)&&(!O||O(this.circleKeys[ce])))return S.push(!0),!0}}}_forEachCell(o,d,y,E,C,S,k,O){const U=this._convertToXCellCoord(o),G=this._convertToYCellCoord(d),Z=this._convertToXCellCoord(y),se=this._convertToYCellCoord(E);for(let de=U;de<=Z;de++)for(let ce=G;ce<=se;ce++)if(C.call(this,o,d,y,E,this.xCellCount*ce+de,S,k,O))return}_convertToXCellCoord(o){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(o*this.xScale)))}_convertToYCellCoord(o){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(o*this.yScale)))}_circlesCollide(o,d,y,E,C,S){const k=E-o,O=C-d,U=y+S;return U*U>k*k+O*O}_circleAndRectCollide(o,d,y,E,C,S,k){const O=(S-E)/2,U=Math.abs(o-(E+O));if(U>O+y)return!1;const G=(k-C)/2,Z=Math.abs(d-(C+G));if(Z>G+y)return!1;if(U<=O||Z<=G)return!0;const se=U-O,de=Z-G;return se*se+de*de<=y*y}}const Cn=Math.tan(85*Math.PI/180);function di(m,o,d,y,E,C){const S=r.create();if(d){if(E.projection.name==="globe")r.multiply$1(S,S,r.calculateGlobeLabelMatrix(E,o));else{const k=le([],C);S[0]=k[0],S[1]=k[1],S[4]=k[2],S[5]=k[3]}y||r.rotateZ(S,S,E.angle)}else r.multiply$1(S,E.labelPlaneMatrix,m);return S}function Dr(m,o,d,y,E,C){if(d){if(E.projection.name==="globe"){const S=di(m,o,d,y,E,C);return r.invert(S,S),r.multiply$1(S,m,S),S}{const S=r.clone(m),k=r.identity([]);return k[0]=C[0],k[1]=C[1],k[4]=C[2],k[5]=C[3],r.multiply$1(S,S,k),y||r.rotateZ(S,S,-E.angle),S}}return E.glCoordMatrix}function oi(m,o,d=0){const y=[m.x,m.y,d,1];d?r.transformMat4$1(y,y,o):Pr(y,y,o);const E=y[3];return{point:new r.pointGeometry(y[0]/E,y[1]/E),signedDistanceFromCamera:E}}function li(m,o){const d=[m[0],m[1],m[2],1];r.transformMat4$1(d,d,o);const y=d[3];return{point:new r.pointGeometry(d[0]/y,d[1]/y),signedDistanceFromCamera:y}}function ai(m,o){return Math.min(.5+m/o*.5,1.5)}function xs(m,o){const d=m[0]/m[3],y=m[1]/m[3];return d>=-o[0]&&d<=o[0]&&y>=-o[1]&&y<=o[1]}function ko(m,o,d,y,E,C,S,k,O,U){const G=d.transform,Z=y?m.textSizeData:m.iconSizeData,se=r.evaluateSizeForZoom(Z,d.transform.zoom),de=[256/d.width*2+1,256/d.height*2+1],ce=y?m.text.dynamicLayoutVertexArray:m.icon.dynamicLayoutVertexArray;ce.clear();const te=m.lineVertexArray,Le=y?m.text.placedSymbolArray:m.icon.placedSymbolArray,ve=d.transform.width/d.transform.height;let De=!1;for(let Se=0;Se<Le.length;Se++){const ze=Le.get(Se);if(ze.writingMode!==r.WritingMode.vertical||De||Se!==0&&Le.get(Se-1).writingMode===r.WritingMode.horizontal||(De=!0),(ze.hidden||ze.writingMode===r.WritingMode.vertical)&&!De){Fi(ze.numGlyphs,ce);continue}De=!1;const Ee=new r.pointGeometry(ze.tileAnchorX,ze.tileAnchorY),Ue=O?O(Ee):[0,0,0],nt=G.projection.projectTilePoint(Ee.x,Ee.y,U.canonical),lt=[nt.x+Ue[0],nt.y+Ue[1],nt.z+Ue[2]],pt=[...lt,1];if(r.transformMat4$1(pt,pt,o),!xs(pt,de)){Fi(ze.numGlyphs,ce);continue}const ht=ai(d.transform.cameraToCenterDistance,pt[3]),kt=r.evaluateSizeForFeature(Z,se,ze),it=S?kt/ht:kt*ht,zt=oi(new r.pointGeometry(lt[0],lt[1]),E,lt[2]);if(zt.signedDistanceFromCamera<=0){Fi(ze.numGlyphs,ce);continue}let St={};const Jt=S?null:O,ft=hu(ze,it,!1,k,o,E,C,m.glyphOffsetArray,te,ce,zt.point,Ee,St,ve,Jt,G.projection,U);De=ft.useVertical,Jt&&ft.needsFlipping&&(St={}),(ft.notEnoughRoom||De||ft.needsFlipping&&hu(ze,it,!0,k,o,E,C,m.glyphOffsetArray,te,ce,zt.point,Ee,St,ve,Jt,G.projection,U).notEnoughRoom)&&Fi(ze.numGlyphs,ce)}y?m.text.dynamicLayoutVertexBuffer.updateData(ce):m.icon.dynamicLayoutVertexBuffer.updateData(ce)}function uu(m,o,d,y,E,C,S,k,O,U,G,Z,se,de,ce){const te=k.glyphStartIndex+k.numGlyphs,Le=k.lineStartIndex,ve=k.lineStartIndex+k.lineLength,De=o.getoffsetX(k.glyphStartIndex),Se=o.getoffsetX(te-1),ze=ws(m*De,d,y,E,C,S,k.segment,Le,ve,O,U,G,Z,se,!0,de,ce);if(!ze)return null;const Ee=ws(m*Se,d,y,E,C,S,k.segment,Le,ve,O,U,G,Z,se,!0,de,ce);return Ee?{first:ze,last:Ee}:null}function bs(m,o,d,y){return m.writingMode===r.WritingMode.horizontal&&Math.abs(d.y-o.y)>Math.abs(d.x-o.x)*y?{useVertical:!0}:m.writingMode===r.WritingMode.vertical?o.y<d.y?{needsFlipping:!0}:null:m.flipState!==0&&function(E,C,S){const k=(C.x-E.x)*S;return k===0||Math.abs((C.y-E.y)/k)>Cn}(o,d,y)?m.flipState===1?{needsFlipping:!0}:null:o.x>d.x?{needsFlipping:!0}:null}function hu(m,o,d,y,E,C,S,k,O,U,G,Z,se,de,ce,te,Le){const ve=o/24,De=m.lineOffsetX*ve,Se=m.lineOffsetY*ve;let ze;if(m.numGlyphs>1){const Ee=m.glyphStartIndex+m.numGlyphs,Ue=m.lineStartIndex,nt=m.lineStartIndex+m.lineLength,lt=uu(ve,k,De,Se,d,G,Z,m,O,C,se,ce,!1,te,Le);if(!lt)return{notEnoughRoom:!0};const pt=oi(lt.first.point,S).point,ht=oi(lt.last.point,S).point;if(y&&!d){const kt=bs(m,pt,ht,de);if(m.flipState=kt&&kt.needsFlipping?1:2,kt)return kt}ze=[lt.first];for(let kt=m.glyphStartIndex+1;kt<Ee-1;kt++)ze.push(ws(ve*k.getoffsetX(kt),De,Se,d,G,Z,m.segment,Ue,nt,O,C,se,ce,!1,!1,te,Le));ze.push(lt.last)}else{if(y&&!d){const Ue=oi(Z,E).point,nt=m.lineStartIndex+m.segment+1,lt=new r.pointGeometry(O.getx(nt),O.gety(nt)),pt=oi(lt,E),ht=bs(m,Ue,pt.signedDistanceFromCamera>0?pt.point:Xn(Z,lt,Ue,1,E,void 0,te,Le.canonical),de);if(m.flipState=ht&&ht.needsFlipping?1:2,ht)return ht}const Ee=ws(ve*k.getoffsetX(m.glyphStartIndex),De,Se,d,G,Z,m.segment,m.lineStartIndex,m.lineStartIndex+m.lineLength,O,C,se,ce,!1,!1,te,Le);if(!Ee)return{notEnoughRoom:!0};ze=[Ee]}for(const Ee of ze)r.addDynamicAttributes(U,Ee.point,Ee.angle);return{}}function Cd(m,o,d,y,E){const C=y.projectTilePoint(m.x,m.y,o);if(!E)return oi(C,d,C.z);const S=E(m);return oi(new r.pointGeometry(C.x+S[0],C.y+S[1]),d,C.z+S[2])}function Xn(m,o,d,y,E,C,S,k){const O=Cd(m.add(m.sub(o)._unit()),k,E,S,C).point,U=d.sub(O);return d.add(U._mult(y/U.mag()))}function ws(m,o,d,y,E,C,S,k,O,U,G,Z,se,de,ce,te,Le){const ve=y?m-o:m+o;let De=ve>0?1:-1,Se=0;y&&(De*=-1,Se=Math.PI),De<0&&(Se+=Math.PI);let ze=De>0?k+S:k+S+1,Ee=E,Ue=E,nt=0,lt=0;const pt=Math.abs(ve),ht=[],kt=[];let it=C;const zt=()=>{const Zt=ze-De;return nt===0?C:new r.pointGeometry(U.getx(Zt),U.gety(Zt))},St=()=>Xn(zt(),it,Ue,pt-nt+1,G,se,te,Le.canonical);for(;nt+lt<=pt;){if(ze+=De,ze<k||ze>=O)return null;if(Ue=Ee,ht.push(Ee),de&&kt.push(it||zt()),Ee=Z[ze],Ee===void 0){it=new r.pointGeometry(U.getx(ze),U.gety(ze));const Zt=Cd(it,Le.canonical,G,te,se);Ee=Zt.signedDistanceFromCamera>0?Z[ze]=Zt.point:St()}else it=null;nt+=lt,lt=Ue.dist(Ee)}ce&&se&&(it=it||new r.pointGeometry(U.getx(ze),U.gety(ze)),Z[ze]=Ee=Z[ze]===void 0?Ee:St(),lt=Ue.dist(Ee));const Jt=(pt-nt)/lt,ft=Ee.sub(Ue),qt=ft.mult(Jt)._add(Ue);d&&qt._add(ft._unit()._perp()._mult(d*De));const gn=Se+Math.atan2(Ee.y-Ue.y,Ee.x-Ue.x);return ht.push(qt),de&&(it=it||new r.pointGeometry(U.getx(ze),U.gety(ze)),kt.push(function(Zt,Yt,xn){const zn=1-xn;return new r.pointGeometry(Zt.x*zn+Yt.x*xn,Zt.y*zn+Yt.y*xn)}(kt.length>0?kt[kt.length-1]:it,it,Jt))),{point:qt,angle:gn,path:ht,tilePath:kt}}const Ad=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Fi(m,o){for(let d=0;d<m;d++){const y=o.length;o.resize(y+4),o.float32.set(Ad,3*y)}}function Pr(m,o,d){const y=o[0],E=o[1];return m[0]=d[0]*y+d[4]*E+d[12],m[1]=d[1]*y+d[5]*E+d[13],m[3]=d[3]*y+d[7]*E+d[15],m}const ho=100;class du{constructor(o,d,y=new Tn(o.width+200,o.height+200,25),E=new Tn(o.width+200,o.height+200,25)){this.transform=o,this.grid=y,this.ignoredGrid=E,this.pitchfactor=Math.cos(o._pitch)*o.cameraToCenterDistance,this.screenRightBoundary=o.width+ho,this.screenBottomBoundary=o.height+ho,this.gridRightBoundary=o.width+200,this.gridBottomBoundary=o.height+200,this.fogState=d}placeCollisionBox(o,d,y,E,C,S,k){let O=d.projectedAnchorX,U=d.projectedAnchorY,G=d.projectedAnchorZ;const Z=d.elevation,se=d.tileID;if(Z&&se){const ze=this.transform.projection.upVector(se.canonical,d.tileAnchorX,d.tileAnchorY),Ee=this.transform.projection.upVectorScale(se.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;O+=ze[0]*Z*Ee,U+=ze[1]*Z*Ee,G+=ze[2]*Z*Ee}const de=this.projectAndGetPerspectiveRatio(S,[O,U,G],d.tileID,this.transform.projection.name==="globe"||!!Z||this.transform.pitch>0),ce=C*de.perspectiveRatio,te=(d.x1*o+y.x-d.padding)*ce+de.point.x,Le=(d.y1*o+y.y-d.padding)*ce+de.point.y,ve=(d.x2*o+y.x+d.padding)*ce+de.point.x,De=(d.y2*o+y.y+d.padding)*ce+de.point.y,Se=de.perspectiveRatio<=.55||de.occluded;return!this.isInsideGrid(te,Le,ve,De)||!E&&this.grid.hitTest(te,Le,ve,De,k)||Se?{box:[],offscreen:!1,occluded:de.occluded}:{box:[te,Le,ve,De],offscreen:this.isOffscreen(te,Le,ve,De),occluded:!1}}placeCollisionCircles(o,d,y,E,C,S,k,O,U,G,Z,se,de,ce){const te=[],Le=this.transform.elevation,ve=Le?Le.getAtTileOffsetFunc(ce,this.transform.center.lat,this.transform.worldSize,this.transform.projection):St=>[0,0,0],De=new r.pointGeometry(d.tileAnchorX,d.tileAnchorY),Se=this.transform.projection.projectTilePoint(d.tileAnchorX,d.tileAnchorY,ce.canonical),ze=ve(De),Ee=[Se.x+ze[0],Se.y+ze[1],Se.z+ze[2]],Ue=this.projectAndGetPerspectiveRatio(S,[Ee[0],Ee[1],Ee[2]],ce,this.transform.projection.name==="globe"||!!Le||this.transform.pitch>0),{perspectiveRatio:nt}=Ue,lt=(G?C/nt:C*nt)/r.ONE_EM,pt=oi(new r.pointGeometry(Ee[0],Ee[1]),k,Ee[2]).point,ht=Ue.signedDistanceFromCamera>0?uu(lt,E,d.lineOffsetX*lt,d.lineOffsetY*lt,!1,pt,De,d,y,k,{},Le&&!G?ve:null,G&&!!Le,this.transform.projection,ce):null;let kt=!1,it=!1,zt=!0;if(ht&&!Ue.occluded){const St=.5*se*nt+de,Jt=new r.pointGeometry(-100,-100),ft=new r.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),qt=new mn,gn=ht.first,Zt=ht.last;let Yt=[];for(let dn=gn.path.length-1;dn>=1;dn--)Yt.push(gn.path[dn]);for(let dn=1;dn<Zt.path.length;dn++)Yt.push(Zt.path[dn]);const xn=2.5*St;if(O){const dn=Yt.map(Le?(Mn,$n)=>{const vi=ve($n<gn.path.length-1?gn.tilePath[gn.path.length-1-$n]:Zt.tilePath[$n-gn.path.length+2]);return oi(Mn,O,vi[2])}:Mn=>oi(Mn,O));Yt=dn.some(Mn=>Mn.signedDistanceFromCamera<=0)?[]:dn.map(Mn=>Mn.point)}let zn=[];if(Yt.length>0){const dn=Yt[0].clone(),Mn=Yt[0].clone();for(let $n=1;$n<Yt.length;$n++)dn.x=Math.min(dn.x,Yt[$n].x),dn.y=Math.min(dn.y,Yt[$n].y),Mn.x=Math.max(Mn.x,Yt[$n].x),Mn.y=Math.max(Mn.y,Yt[$n].y);zn=dn.x>=Jt.x&&Mn.x<=ft.x&&dn.y>=Jt.y&&Mn.y<=ft.y?[Yt]:Mn.x<Jt.x||dn.x>ft.x||Mn.y<Jt.y||dn.y>ft.y?[]:r.clipLine([Yt],Jt.x,Jt.y,ft.x,ft.y)}for(const dn of zn){qt.reset(dn,.25*St);let Mn=0;Mn=qt.length<=.5*St?1:Math.ceil(qt.paddedLength/xn)+1;for(let $n=0;$n<Mn;$n++){const vi=$n/Math.max(Mn-1,1),nr=qt.lerp(vi),ir=nr.x+ho,kr=nr.y+ho;te.push(ir,kr,St,0);const mo=ir-St,Uo=kr-St,pa=ir+St,Vo=kr+St;if(zt=zt&&this.isOffscreen(mo,Uo,pa,Vo),it=it||this.isInsideGrid(mo,Uo,pa,Vo),!o&&this.grid.hitTestCircle(ir,kr,St,Z)&&(kt=!0,!U))return{circles:[],offscreen:!1,collisionDetected:kt,occluded:!1}}}}return{circles:!U&&kt||!it?[]:te,offscreen:zt,collisionDetected:kt,occluded:Ue.occluded}}queryRenderedSymbols(o){if(o.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const d=[];let y=1/0,E=1/0,C=-1/0,S=-1/0;for(const G of o){const Z=new r.pointGeometry(G.x+ho,G.y+ho);y=Math.min(y,Z.x),E=Math.min(E,Z.y),C=Math.max(C,Z.x),S=Math.max(S,Z.y),d.push(Z)}const k=this.grid.query(y,E,C,S).concat(this.ignoredGrid.query(y,E,C,S)),O={},U={};for(const G of k){const Z=G.key;if(O[Z.bucketInstanceId]===void 0&&(O[Z.bucketInstanceId]={}),O[Z.bucketInstanceId][Z.featureIndex])continue;const se=[new r.pointGeometry(G.x1,G.y1),new r.pointGeometry(G.x2,G.y1),new r.pointGeometry(G.x2,G.y2),new r.pointGeometry(G.x1,G.y2)];r.polygonIntersectsPolygon(d,se)&&(O[Z.bucketInstanceId][Z.featureIndex]=!0,U[Z.bucketInstanceId]===void 0&&(U[Z.bucketInstanceId]=[]),U[Z.bucketInstanceId].push(Z.featureIndex))}return U}insertCollisionBox(o,d,y,E,C){(d?this.ignoredGrid:this.grid).insert({bucketInstanceId:y,featureIndex:E,collisionGroupID:C},o[0],o[1],o[2],o[3])}insertCollisionCircles(o,d,y,E,C){const S=d?this.ignoredGrid:this.grid,k={bucketInstanceId:y,featureIndex:E,collisionGroupID:C};for(let O=0;O<o.length;O+=4)S.insertCircle(k,o[O],o[O+1],o[O+2])}projectAndGetPerspectiveRatio(o,d,y,E){const C=[d[0],d[1],d[2],1];let S=!1;return d[2]||this.transform.pitch>0?(r.transformMat4$1(C,C,o),this.fogState&&y&&(S=function(k,O,U,G,Z,se){const de=se.calculateFogTileMatrix(Z),ce=[O,U,G];return r.transformMat4(ce,ce,de),yt(k,ce,se.pitch,se._fov)}(this.fogState,d[0],d[1],d[2],y.toUnwrapped(),this.transform)>.9)):Pr(C,C,o),{point:new r.pointGeometry((C[0]/C[3]+1)/2*this.transform.width+ho,(-C[1]/C[3]+1)/2*this.transform.height+ho),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/C[3]*.5,1.5),signedDistanceFromCamera:C[3],occluded:E&&C[2]>C[3]||S}}isOffscreen(o,d,y,E){return y<ho||o>=this.screenRightBoundary||E<ho||d>this.screenBottomBoundary}isInsideGrid(o,d,y,E){return y>=0&&o<this.gridRightBoundary&&E>=0&&d<this.gridBottomBoundary}getViewportMatrix(){const o=r.identity([]);return r.translate(o,o,[-100,-100,0]),o}}class Pi{constructor(o,d,y,E){this.opacity=o?Math.max(0,Math.min(1,o.opacity+(o.placed?d:-d))):E&&y?1:0,this.placed=y}isHidden(){return this.opacity===0&&!this.placed}}class zo{constructor(o,d,y,E,C,S=!1){this.text=new Pi(o?o.text:null,d,y,C),this.icon=new Pi(o?o.icon:null,d,E,C),this.clipped=S}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Fo{constructor(o,d,y,E=!1){this.text=o,this.icon=d,this.skipFade=y,this.clipped=E}}class Qi{constructor(){this.invProjMatrix=r.create(),this.viewportMatrix=r.create(),this.circles=[]}}class Dd{constructor(o,d,y,E,C){this.bucketInstanceId=o,this.featureIndex=d,this.sourceLayerIndex=y,this.bucketIndex=E,this.tileID=C}}class po{constructor(o){this.crossSourceCollisions=o,this.maxGroupID=0,this.collisionGroups={}}get(o){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[o]){const d=++this.maxGroupID;this.collisionGroups[o]={ID:d,predicate:y=>y.collisionGroupID===d}}return this.collisionGroups[o]}}function Ms(m,o,d,y,E){const{horizontalAlign:C,verticalAlign:S}=r.getAnchorAlignment(m),k=-(C-.5)*o,O=-(S-.5)*d,U=r.evaluateVariableOffset(m,y);return new r.pointGeometry(k+U[0]*E,O+U[1]*E)}function Ts(m,o,d,y,E){const C=new r.pointGeometry(m,o);return d&&C._rotate(y?E:-E),C}class $_{constructor(o,d,y,E,C){this.transform=o.clone(),this.collisionIndex=new du(this.transform,C),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=d,this.retainedQueryData={},this.collisionGroups=new po(y),this.collisionCircleArrays={},this.prevPlacement=E,E&&(E.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(o,d,y,E){const C=y.getBucket(d),S=y.latestFeatureIndex;if(!C||!S||d.id!==C.layerIds[0])return;const k=C.layers[0].layout,O=y.collisionBoxArray,U=Math.pow(2,this.transform.zoom-y.tileID.overscaledZ),G=y.tileSize/r.EXTENT,Z=y.tileID.toUnwrapped(),se=this.transform.calculateProjMatrix(Z),de=k.get("text-pitch-alignment")==="map",ce=k.get("text-rotation-alignment")==="map";d.compileFilter();const te=d.dynamicFilter(),Le=d.dynamicFilterNeedsFeature(),ve=this.transform.calculatePixelsToTileUnitsMatrix(y),De=di(se,y.tileID.canonical,de,ce,this.transform,ve);let Se=null;if(de){const Ue=Dr(se,y.tileID.canonical,de,ce,this.transform,ve);Se=r.multiply$1([],this.transform.labelPlaneMatrix,Ue)}let ze=null;te&&y.latestFeatureIndex&&(ze={unwrappedTileID:Z,dynamicFilter:te,dynamicFilterNeedsFeature:Le,featureIndex:y.latestFeatureIndex}),this.retainedQueryData[C.bucketInstanceId]=new Dd(C.bucketInstanceId,S,C.sourceLayerIndex,C.index,y.tileID);const Ee={bucket:C,layout:k,posMatrix:se,textLabelPlaneMatrix:De,labelToScreenMatrix:Se,clippingData:ze,scale:U,textPixelRatio:G,holdingForFade:y.holdingForFade(),collisionBoxArray:O,partiallyEvaluatedTextSize:r.evaluateSizeForZoom(C.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:r.evaluateSizeForZoom(C.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(C.sourceID)};if(E)for(const Ue of C.sortKeyRanges){const{sortKey:nt,symbolInstanceStart:lt,symbolInstanceEnd:pt}=Ue;o.push({sortKey:nt,symbolInstanceStart:lt,symbolInstanceEnd:pt,parameters:Ee})}else o.push({symbolInstanceStart:0,symbolInstanceEnd:C.symbolInstances.length,parameters:Ee})}attemptAnchorPlacement(o,d,y,E,C,S,k,O,U,G,Z,se,de,ce,te,Le,ve,De){const Se=[se.textOffset0,se.textOffset1],ze=Ms(o,y,E,Se,C),Ee=this.collisionIndex.placeCollisionBox(C,d,Ts(ze.x,ze.y,S,k,this.transform.angle),Z,O,U,G.predicate);if((!Le||this.collisionIndex.placeCollisionBox(ce.getSymbolInstanceIconSize(De,this.transform.zoom,de),Le,Ts(ze.x,ze.y,S,k,this.transform.angle),Z,O,U,G.predicate).box.length!==0)&&Ee.box.length>0){let Ue;return this.prevPlacement&&this.prevPlacement.variableOffsets[se.crossTileID]&&this.prevPlacement.placements[se.crossTileID]&&this.prevPlacement.placements[se.crossTileID].text&&(Ue=this.prevPlacement.variableOffsets[se.crossTileID].anchor),this.variableOffsets[se.crossTileID]={textOffset:Se,width:y,height:E,anchor:o,textScale:C,prevAnchor:Ue},this.markUsedJustification(ce,o,se,te),ce.allowVerticalPlacement&&(this.markUsedOrientation(ce,te,se),this.placedOrientations[se.crossTileID]=te),{shift:ze,placedGlyphBoxes:Ee}}}placeLayerBucketPart(o,d,y,E){const{bucket:C,layout:S,posMatrix:k,textLabelPlaneMatrix:O,labelToScreenMatrix:U,clippingData:G,textPixelRatio:Z,holdingForFade:se,collisionBoxArray:de,partiallyEvaluatedTextSize:ce,partiallyEvaluatedIconSize:te,collisionGroup:Le}=o.parameters,ve=S.get("text-optional"),De=S.get("icon-optional"),Se=S.get("text-allow-overlap"),ze=S.get("icon-allow-overlap"),Ee=S.get("text-rotation-alignment")==="map",Ue=S.get("text-pitch-alignment")==="map",nt=S.get("icon-text-fit")!=="none",lt=S.get("symbol-z-order")==="viewport-y";let pt=Se&&(ze||!C.hasIconData()||De),ht=ze&&(Se||!C.hasTextData()||ve);!C.collisionArrays&&de&&C.deserializeCollisionBoxes(de),y&&E&&C.updateCollisionDebugBuffers(this.transform.zoom,de);const kt=(it,zt,St)=>{if(G){const bi={zoom:this.transform.zoom,pitch:this.transform.pitch};let Ti=null;if(G.dynamicFilterNeedsFeature){const Yn=this.retainedQueryData[C.bucketInstanceId];Ti=G.featureIndex.loadFeature({featureIndex:it.featureIndex,bucketIndex:Yn.bucketIndex,sourceLayerIndex:Yn.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,G.dynamicFilter)(bi,Ti,this.retainedQueryData[C.bucketInstanceId].tileID.canonical,new r.pointGeometry(it.tileAnchorX,it.tileAnchorY),this.transform.calculateDistanceTileData(G.unwrappedTileID)))return this.placements[it.crossTileID]=new Fo(!1,!1,!1,!0),void(d[it.crossTileID]=!0)}if(d[it.crossTileID])return;if(se)return void(this.placements[it.crossTileID]=new Fo(!1,!1,!1));let Jt=!1,ft=!1,qt=!0,gn=!1,Zt=!1,Yt=null,xn={box:null,offscreen:null,occluded:null},zn={box:null,offscreen:null,occluded:null},dn=null,Mn=null,$n=null,vi=0,nr=0,ir=0;St.textFeatureIndex?vi=St.textFeatureIndex:it.useRuntimeCollisionCircles&&(vi=it.featureIndex),St.verticalTextFeatureIndex&&(nr=St.verticalTextFeatureIndex);const kr=bi=>{bi.tileID=this.retainedQueryData[C.bucketInstanceId].tileID,(this.transform.elevation||bi.elevation)&&(bi.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[C.bucketInstanceId].tileID,bi.tileAnchorX,bi.tileAnchorY):0)},mo=St.textBox;if(mo){kr(mo);const bi=Yn=>{let Si=r.WritingMode.horizontal;if(C.allowVerticalPlacement&&!Yn&&this.prevPlacement){const zr=this.prevPlacement.placedOrientations[it.crossTileID];zr&&(this.placedOrientations[it.crossTileID]=zr,Si=zr,this.markUsedOrientation(C,Si,it))}return Si},Ti=(Yn,Si)=>{if(C.allowVerticalPlacement&&it.numVerticalGlyphVertices>0&&St.verticalTextBox){for(const zr of C.writingModes)if(zr===r.WritingMode.vertical?(xn=Si(),zn=xn):xn=Yn(),xn&&xn.box&&xn.box.length)break}else xn=Yn()};if(S.get("text-variable-anchor")){let Yn=S.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[it.crossTileID]){const xi=this.prevPlacement.variableOffsets[it.crossTileID];Yn.indexOf(xi.anchor)>0&&(Yn=Yn.filter(Xr=>Xr!==xi.anchor),Yn.unshift(xi.anchor))}const Si=(xi,Xr,$l)=>{const Fr=C.getSymbolInstanceTextSize(ce,it,this.transform.zoom,zt),Ha=(xi.x2-xi.x1)*Fr+2*xi.padding,Mg=(xi.y2-xi.y1)*Fr+2*xi.padding,hp=nt&&!ze?Xr:null;hp&&kr(hp);let zs={box:[],offscreen:!1,occluded:!1};const cv=Se?2*Yn.length:Yn.length;for(let fa=0;fa<cv;++fa){const dp=this.attemptAnchorPlacement(Yn[fa%Yn.length],xi,Ha,Mg,Fr,Ee,Ue,Z,k,Le,fa>=Yn.length,it,zt,C,$l,hp,ce,te);if(dp&&(zs=dp.placedGlyphBoxes,zs&&zs.box&&zs.box.length)){Jt=!0,Yt=dp.shift;break}}return zs};Ti(()=>Si(mo,St.iconBox,r.WritingMode.horizontal),()=>{const xi=St.verticalTextBox;return xi&&kr(xi),C.allowVerticalPlacement&&!(xn&&xn.box&&xn.box.length)&&it.numVerticalGlyphVertices>0&&xi?Si(xi,St.verticalIconBox,r.WritingMode.vertical):{box:null,offscreen:null,occluded:null}}),xn&&(Jt=xn.box,qt=xn.offscreen,gn=xn.occluded);const zr=bi(xn&&xn.box);if(!Jt&&this.prevPlacement){const xi=this.prevPlacement.variableOffsets[it.crossTileID];xi&&(this.variableOffsets[it.crossTileID]=xi,this.markUsedJustification(C,xi.anchor,it,zr))}}else{const Yn=(Si,zr)=>{const xi=C.getSymbolInstanceTextSize(ce,it,this.transform.zoom,zt),Xr=this.collisionIndex.placeCollisionBox(xi,Si,new r.pointGeometry(0,0),Se,Z,k,Le.predicate);return Xr&&Xr.box&&Xr.box.length&&(this.markUsedOrientation(C,zr,it),this.placedOrientations[it.crossTileID]=zr),Xr};Ti(()=>Yn(mo,r.WritingMode.horizontal),()=>{const Si=St.verticalTextBox;return C.allowVerticalPlacement&&it.numVerticalGlyphVertices>0&&Si?(kr(Si),Yn(Si,r.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}}),bi(xn&&xn.box&&xn.box.length)}}if(dn=xn,Jt=dn&&dn.box&&dn.box.length>0,qt=dn&&dn.offscreen,gn=dn&&dn.occluded,it.useRuntimeCollisionCircles){const bi=C.text.placedSymbolArray.get(it.centerJustifiedTextSymbolIndex>=0?it.centerJustifiedTextSymbolIndex:it.verticalPlacedTextSymbolIndex),Ti=r.evaluateSizeForFeature(C.textSizeData,ce,bi),Yn=S.get("text-padding");Mn=this.collisionIndex.placeCollisionCircles(Se,bi,C.lineVertexArray,C.glyphOffsetArray,Ti,k,O,U,y,Ue,Le.predicate,it.collisionCircleDiameter*Ti/r.ONE_EM,Yn,this.retainedQueryData[C.bucketInstanceId].tileID),Jt=Se||Mn.circles.length>0&&!Mn.collisionDetected,qt=qt&&Mn.offscreen,gn=Mn.occluded}if(St.iconFeatureIndex&&(ir=St.iconFeatureIndex),St.iconBox){const bi=Ti=>{kr(Ti);const Yn=nt&&Yt?Ts(Yt.x,Yt.y,Ee,Ue,this.transform.angle):new r.pointGeometry(0,0),Si=C.getSymbolInstanceIconSize(te,this.transform.zoom,zt);return this.collisionIndex.placeCollisionBox(Si,Ti,Yn,ze,Z,k,Le.predicate)};zn&&zn.box&&zn.box.length&&St.verticalIconBox?($n=bi(St.verticalIconBox),ft=$n.box.length>0):($n=bi(St.iconBox),ft=$n.box.length>0),qt=qt&&$n.offscreen,Zt=$n.occluded}const Uo=ve||it.numHorizontalGlyphVertices===0&&it.numVerticalGlyphVertices===0,pa=De||it.numIconVertices===0;if(Uo||pa?pa?Uo||(ft=ft&&Jt):Jt=ft&&Jt:ft=Jt=ft&&Jt,Jt&&dn&&dn.box&&this.collisionIndex.insertCollisionBox(dn.box,S.get("text-ignore-placement"),C.bucketInstanceId,zn&&zn.box&&nr?nr:vi,Le.ID),ft&&$n&&this.collisionIndex.insertCollisionBox($n.box,S.get("icon-ignore-placement"),C.bucketInstanceId,ir,Le.ID),Mn&&(Jt&&this.collisionIndex.insertCollisionCircles(Mn.circles,S.get("text-ignore-placement"),C.bucketInstanceId,vi,Le.ID),y)){const bi=C.bucketInstanceId;let Ti=this.collisionCircleArrays[bi];Ti===void 0&&(Ti=this.collisionCircleArrays[bi]=new Qi);for(let Yn=0;Yn<Mn.circles.length;Yn+=4)Ti.circles.push(Mn.circles[Yn+0]),Ti.circles.push(Mn.circles[Yn+1]),Ti.circles.push(Mn.circles[Yn+2]),Ti.circles.push(Mn.collisionDetected?1:0)}const Vo=this.transform.projection.name!=="globe";pt=pt&&(Vo||!gn),ht=ht&&(Vo||!Zt),this.placements[it.crossTileID]=new Fo(Jt||pt,ft||ht,qt||C.justReloaded),d[it.crossTileID]=!0};if(lt){const it=C.getSortedSymbolIndexes(this.transform.angle);for(let zt=it.length-1;zt>=0;--zt){const St=it[zt];kt(C.symbolInstances.get(St),St,C.collisionArrays[St])}}else for(let it=o.symbolInstanceStart;it<o.symbolInstanceEnd;it++)kt(C.symbolInstances.get(it),it,C.collisionArrays[it]);if(y&&C.bucketInstanceId in this.collisionCircleArrays){const it=this.collisionCircleArrays[C.bucketInstanceId];r.invert(it.invProjMatrix,k),it.viewportMatrix=this.collisionIndex.getViewportMatrix()}C.justReloaded=!1}markUsedJustification(o,d,y,E){let C;C=E===r.WritingMode.vertical?y.verticalPlacedTextSymbolIndex:{left:y.leftJustifiedTextSymbolIndex,center:y.centerJustifiedTextSymbolIndex,right:y.rightJustifiedTextSymbolIndex}[r.getAnchorJustification(d)];const S=[y.leftJustifiedTextSymbolIndex,y.centerJustifiedTextSymbolIndex,y.rightJustifiedTextSymbolIndex,y.verticalPlacedTextSymbolIndex];for(const k of S)k>=0&&(o.text.placedSymbolArray.get(k).crossTileID=C>=0&&k!==C?0:y.crossTileID)}markUsedOrientation(o,d,y){const E=d===r.WritingMode.horizontal||d===r.WritingMode.horizontalOnly?d:0,C=d===r.WritingMode.vertical?d:0,S=[y.leftJustifiedTextSymbolIndex,y.centerJustifiedTextSymbolIndex,y.rightJustifiedTextSymbolIndex];for(const k of S)o.text.placedSymbolArray.get(k).placedOrientation=E;y.verticalPlacedTextSymbolIndex&&(o.text.placedSymbolArray.get(y.verticalPlacedTextSymbolIndex).placedOrientation=C)}commit(o){this.commitTime=o,this.zoomAtLastRecencyCheck=this.transform.zoom;const d=this.prevPlacement;let y=!1;this.prevZoomAdjustment=d?d.zoomAdjustment(this.transform.zoom):0;const E=d?d.symbolFadeChange(o):1,C=d?d.opacities:{},S=d?d.variableOffsets:{},k=d?d.placedOrientations:{};for(const O in this.placements){const U=this.placements[O],G=C[O];G?(this.opacities[O]=new zo(G,E,U.text,U.icon,null,U.clipped),y=y||U.text!==G.text.placed||U.icon!==G.icon.placed):(this.opacities[O]=new zo(null,E,U.text,U.icon,U.skipFade,U.clipped),y=y||U.text||U.icon)}for(const O in C){const U=C[O];if(!this.opacities[O]){const G=new zo(U,E,!1,!1);G.isHidden()||(this.opacities[O]=G,y=y||U.text.placed||U.icon.placed)}}for(const O in S)this.variableOffsets[O]||!this.opacities[O]||this.opacities[O].isHidden()||(this.variableOffsets[O]=S[O]);for(const O in k)this.placedOrientations[O]||!this.opacities[O]||this.opacities[O].isHidden()||(this.placedOrientations[O]=k[O]);y?this.lastPlacementChangeTime=o:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=d?d.lastPlacementChangeTime:o)}updateLayerOpacities(o,d){const y={};for(const E of d){const C=E.getBucket(o);C&&E.latestFeatureIndex&&o.id===C.layerIds[0]&&this.updateBucketOpacities(C,y,E.collisionBoxArray)}}updateBucketOpacities(o,d,y){o.hasTextData()&&o.text.opacityVertexArray.clear(),o.hasIconData()&&o.icon.opacityVertexArray.clear(),o.hasIconCollisionBoxData()&&o.iconCollisionBox.collisionVertexArray.clear(),o.hasTextCollisionBoxData()&&o.textCollisionBox.collisionVertexArray.clear();const E=o.layers[0].layout,C=!!o.layers[0].dynamicFilter(),S=new zo(null,0,!1,!1,!0),k=E.get("text-allow-overlap"),O=E.get("icon-allow-overlap"),U=E.get("text-variable-anchor"),G=E.get("text-rotation-alignment")==="map",Z=E.get("text-pitch-alignment")==="map",se=E.get("icon-text-fit")!=="none",de=new zo(null,0,k&&(O||!o.hasIconData()||E.get("icon-optional")),O&&(k||!o.hasTextData()||E.get("text-optional")),!0);!o.collisionArrays&&y&&(o.hasIconCollisionBoxData()||o.hasTextCollisionBoxData())&&o.deserializeCollisionBoxes(y);const ce=(Le,ve,De)=>{for(let Se=0;Se<ve/4;Se++)Le.opacityVertexArray.emplaceBack(De)};let te=0;for(let Le=0;Le<o.symbolInstances.length;Le++){const ve=o.symbolInstances.get(Le),{numHorizontalGlyphVertices:De,numVerticalGlyphVertices:Se,crossTileID:ze}=ve;let Ee=this.opacities[ze];d[ze]?Ee=S:Ee||(Ee=de,this.opacities[ze]=Ee),d[ze]=!0;const Ue=De>0||Se>0,nt=ve.numIconVertices>0,lt=this.placedOrientations[ve.crossTileID],pt=lt===r.WritingMode.vertical,ht=lt===r.WritingMode.horizontal||lt===r.WritingMode.horizontalOnly;if(!Ue&&!nt||Ee.isHidden()||te++,Ue){const kt=Im(Ee.text);ce(o.text,De,pt?mu:kt),ce(o.text,Se,ht?mu:kt);const it=Ee.text.isHidden();[ve.rightJustifiedTextSymbolIndex,ve.centerJustifiedTextSymbolIndex,ve.leftJustifiedTextSymbolIndex].forEach(Jt=>{Jt>=0&&(o.text.placedSymbolArray.get(Jt).hidden=it||pt?1:0)}),ve.verticalPlacedTextSymbolIndex>=0&&(o.text.placedSymbolArray.get(ve.verticalPlacedTextSymbolIndex).hidden=it||ht?1:0);const zt=this.variableOffsets[ve.crossTileID];zt&&this.markUsedJustification(o,zt.anchor,ve,lt);const St=this.placedOrientations[ve.crossTileID];St&&(this.markUsedJustification(o,"left",ve,St),this.markUsedOrientation(o,St,ve))}if(nt){const kt=Im(Ee.icon);ve.placedIconSymbolIndex>=0&&(ce(o.icon,ve.numIconVertices,pt?mu:kt),o.icon.placedSymbolArray.get(ve.placedIconSymbolIndex).hidden=Ee.icon.isHidden()),ve.verticalPlacedIconSymbolIndex>=0&&(ce(o.icon,ve.numVerticalIconVertices,ht?mu:kt),o.icon.placedSymbolArray.get(ve.verticalPlacedIconSymbolIndex).hidden=Ee.icon.isHidden())}if(o.hasIconCollisionBoxData()||o.hasTextCollisionBoxData()){const kt=o.collisionArrays[Le];if(kt){let it=new r.pointGeometry(0,0),zt=!0;if(kt.textBox||kt.verticalTextBox){if(U){const Jt=this.variableOffsets[ze];Jt?(it=Ms(Jt.anchor,Jt.width,Jt.height,Jt.textOffset,Jt.textScale),G&&it._rotate(Z?this.transform.angle:-this.transform.angle)):zt=!1}C&&(zt=!Ee.clipped),kt.textBox&&fo(o.textCollisionBox.collisionVertexArray,Ee.text.placed,!zt||pt,it.x,it.y),kt.verticalTextBox&&fo(o.textCollisionBox.collisionVertexArray,Ee.text.placed,!zt||ht,it.x,it.y)}const St=zt&&!!(!ht&&kt.verticalIconBox);kt.iconBox&&fo(o.iconCollisionBox.collisionVertexArray,Ee.icon.placed,St,se?it.x:0,se?it.y:0),kt.verticalIconBox&&fo(o.iconCollisionBox.collisionVertexArray,Ee.icon.placed,!St,se?it.x:0,se?it.y:0)}}}if(o.fullyClipped=te===0,o.sortFeatures(this.transform.angle),this.retainedQueryData[o.bucketInstanceId]&&(this.retainedQueryData[o.bucketInstanceId].featureSortOrder=o.featureSortOrder),o.hasTextData()&&o.text.opacityVertexBuffer&&o.text.opacityVertexBuffer.updateData(o.text.opacityVertexArray),o.hasIconData()&&o.icon.opacityVertexBuffer&&o.icon.opacityVertexBuffer.updateData(o.icon.opacityVertexArray),o.hasIconCollisionBoxData()&&o.iconCollisionBox.collisionVertexBuffer&&o.iconCollisionBox.collisionVertexBuffer.updateData(o.iconCollisionBox.collisionVertexArray),o.hasTextCollisionBoxData()&&o.textCollisionBox.collisionVertexBuffer&&o.textCollisionBox.collisionVertexBuffer.updateData(o.textCollisionBox.collisionVertexArray),o.bucketInstanceId in this.collisionCircleArrays){const Le=this.collisionCircleArrays[o.bucketInstanceId];o.placementInvProjMatrix=Le.invProjMatrix,o.placementViewportMatrix=Le.viewportMatrix,o.collisionCircleArray=Le.circles,delete this.collisionCircleArrays[o.bucketInstanceId]}}symbolFadeChange(o){return this.fadeDuration===0?1:(o-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(o){return Math.max(0,(this.transform.zoom-o)/1.5)}hasTransitions(o){return this.stale||o-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(o,d){const y=this.zoomAtLastRecencyCheck===d?1-this.zoomAdjustment(d):1;return this.zoomAtLastRecencyCheck=d,this.commitTime+this.fadeDuration*y>o}setStale(){this.stale=!0}}function fo(m,o,d,y,E){m.emplaceBack(o?1:0,d?1:0,y||0,E||0),m.emplaceBack(o?1:0,d?1:0,y||0,E||0),m.emplaceBack(o?1:0,d?1:0,y||0,E||0),m.emplaceBack(o?1:0,d?1:0,y||0,E||0)}const q_=Math.pow(2,25),Lm=Math.pow(2,24),Sr=Math.pow(2,17),pu=Math.pow(2,16),ra=Math.pow(2,9),Pd=Math.pow(2,8),fu=Math.pow(2,1);function Im(m){if(m.opacity===0&&!m.placed)return 0;if(m.opacity===1&&m.placed)return 4294967295;const o=m.placed?1:0,d=Math.floor(127*m.opacity);return d*q_+o*Lm+d*Sr+o*pu+d*ra+o*Pd+d*fu+o}const mu=0;class Sd{constructor(o){this._sortAcrossTiles=o.layout.get("symbol-z-order")!=="viewport-y"&&o.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(o,d,y,E,C){const S=this._bucketParts;for(;this._currentTileIndex<o.length;)if(d.getBucketParts(S,E,o[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,C())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,S.sort((k,O)=>k.sortKey-O.sortKey));this._currentPartIndex<S.length;){const k=S[this._currentPartIndex];if(d.placeLayerBucketPart(k,this._seenCrossTileIDs,y,k.symbolInstanceStart===0),this._currentPartIndex++,C())return!0}return!1}}class X_{constructor(o,d,y,E,C,S,k,O){this.placement=new $_(o,C,S,k,O),this._currentPlacementIndex=d.length-1,this._forceFullPlacement=y,this._showCollisionBoxes=E,this._done=!1}isDone(){return this._done}continuePlacement(o,d,y){const E=r.exported.now(),C=()=>{const S=r.exported.now()-E;return!this._forceFullPlacement&&S>2};for(;this._currentPlacementIndex>=0;){const S=d[o[this._currentPlacementIndex]],k=this.placement.collisionIndex.transform.zoom;if(S.type==="symbol"&&(!S.minzoom||S.minzoom<=k)&&(!S.maxzoom||S.maxzoom>k)){if(this._inProgressLayer||(this._inProgressLayer=new Sd(S)),this._inProgressLayer.continuePlacement(y[S.source],this.placement,this._showCollisionBoxes,S,C))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(o){return this.placement.commit(o),this.placement}}const Rm=512/r.EXTENT/2;class Z_{constructor(o,d,y){this.tileID=o,this.indexedSymbolInstances={},this.bucketInstanceId=y;for(let E=0;E<d.length;E++){const C=d.get(E),S=C.key;this.indexedSymbolInstances[S]||(this.indexedSymbolInstances[S]=[]),this.indexedSymbolInstances[S].push({crossTileID:C.crossTileID,coord:this.getScaledCoordinates(C,o)})}}getScaledCoordinates(o,d){const y=Rm/Math.pow(2,d.canonical.z-this.tileID.canonical.z);return{x:Math.floor((d.canonical.x*r.EXTENT+o.tileAnchorX)*y),y:Math.floor((d.canonical.y*r.EXTENT+o.tileAnchorY)*y)}}findMatches(o,d,y){const E=this.tileID.canonical.z<d.canonical.z?1:Math.pow(2,this.tileID.canonical.z-d.canonical.z);for(let C=0;C<o.length;C++){const S=o.get(C);if(S.crossTileID)continue;const k=this.indexedSymbolInstances[S.key];if(!k)continue;const O=this.getScaledCoordinates(S,d);for(const U of k)if(Math.abs(U.coord.x-O.x)<=E&&Math.abs(U.coord.y-O.y)<=E&&!y[U.crossTileID]){y[U.crossTileID]=!0,S.crossTileID=U.crossTileID;break}}}}class km{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Y_{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(o){const d=Math.round((o-this.lng)/360);if(d!==0)for(const y in this.indexes){const E=this.indexes[y],C={};for(const S in E){const k=E[S];k.tileID=k.tileID.unwrapTo(k.tileID.wrap+d),C[k.tileID.key]=k}this.indexes[y]=C}this.lng=o}addBucket(o,d,y){if(this.indexes[o.overscaledZ]&&this.indexes[o.overscaledZ][o.key]){if(this.indexes[o.overscaledZ][o.key].bucketInstanceId===d.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(o.overscaledZ,this.indexes[o.overscaledZ][o.key])}for(let C=0;C<d.symbolInstances.length;C++)d.symbolInstances.get(C).crossTileID=0;this.usedCrossTileIDs[o.overscaledZ]||(this.usedCrossTileIDs[o.overscaledZ]={});const E=this.usedCrossTileIDs[o.overscaledZ];for(const C in this.indexes){const S=this.indexes[C];if(Number(C)>o.overscaledZ)for(const k in S){const O=S[k];O.tileID.isChildOf(o)&&O.findMatches(d.symbolInstances,o,E)}else{const k=S[o.scaledTo(Number(C)).key];k&&k.findMatches(d.symbolInstances,o,E)}}for(let C=0;C<d.symbolInstances.length;C++){const S=d.symbolInstances.get(C);S.crossTileID||(S.crossTileID=y.generate(),E[S.crossTileID]=!0)}return this.indexes[o.overscaledZ]===void 0&&(this.indexes[o.overscaledZ]={}),this.indexes[o.overscaledZ][o.key]=new Z_(o,d.symbolInstances,d.bucketInstanceId),!0}removeBucketCrossTileIDs(o,d){for(const y in d.indexedSymbolInstances)for(const E of d.indexedSymbolInstances[y])delete this.usedCrossTileIDs[o][E.crossTileID]}removeStaleBuckets(o){let d=!1;for(const y in this.indexes){const E=this.indexes[y];for(const C in E)o[E[C].bucketInstanceId]||(this.removeBucketCrossTileIDs(y,E[C]),delete E[C],d=!0)}return d}}class gu{constructor(){this.layerIndexes={},this.crossTileIDs=new km,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(o,d,y,E){let C=this.layerIndexes[o.id];C===void 0&&(C=this.layerIndexes[o.id]=new Y_);let S=!1;const k={};E.name!=="globe"&&C.handleWrapJump(y);for(const O of d){const U=O.getBucket(o);U&&o.id===U.layerIds[0]&&(U.bucketInstanceId||(U.bucketInstanceId=++this.maxBucketInstanceId),C.addBucket(O.tileID,U,this.crossTileIDs)&&(S=!0),k[U.bucketInstanceId]=!0)}return C.removeStaleBuckets(k)&&(S=!0),S}pruneUnusedLayers(o){const d={};o.forEach(y=>{d[y]=!0});for(const y in this.layerIndexes)d[y]||delete this.layerIndexes[y]}}const bl=(m,o)=>r.emitValidationErrors(m,o&&o.filter(d=>d.identifier!=="source.canvas")),zm=r.pick(_t,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Fm=r.pick(_t,["setCenter","setZoom","setBearing","setPitch"]),Bm={version:8,layers:[],sources:{}},Na={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class yr extends r.Evented{constructor(o,d={}){super(),this.map=o,this.dispatcher=new be(Fe(),this),this.imageManager=new me,this.imageManager.setEventedParent(this),this.glyphManager=new r.GlyphManager(o._requestManager,d.localFontFamily?r.LocalGlyphMode.all:d.localIdeographFontFamily?r.LocalGlyphMode.ideographs:r.LocalGlyphMode.none,d.localFontFamily||d.localIdeographFontFamily),this.lineAtlas=new r.LineAtlas(256,512),this.crossTileSymbolIndex=new gu,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new r.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",r.getReferrer());const y=this;this._rtlTextPluginCallback=yr.registerForPluginStateChange(E=>{y.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:E.pluginStatus,pluginURL:E.pluginURL},(C,S)=>{if(r.triggerPluginCompletionEvent(C),S&&S.every(k=>k))for(const k in y._sourceCaches){const O=y._sourceCaches[k],U=O.getSource().type;U!=="vector"&&U!=="geojson"||O.reload()}})}),this.on("data",E=>{if(E.dataType!=="source"||E.sourceDataType!=="metadata")return;const C=this.getSource(E.sourceId);if(C&&C.vectorLayerIds)for(const S in this._layers){const k=this._layers[S];k.source===C.id&&this._validateLayer(k)}})}loadURL(o,d={}){this.fire(new r.Event("dataloading",{dataType:"style"}));const y=typeof d.validate=="boolean"?d.validate:!r.isMapboxURL(o);o=this.map._requestManager.normalizeStyleURL(o,d.accessToken);const E=this.map._requestManager.transformRequest(o,r.ResourceType.Style);this._request=r.getJSON(E,(C,S)=>{this._request=null,C?this.fire(new r.ErrorEvent(C)):S&&this._load(S,y)})}loadJSON(o,d={}){this.fire(new r.Event("dataloading",{dataType:"style"})),this._request=r.exported.frame(()=>{this._request=null,this._load(o,d.validate!==!1)})}loadEmpty(){this.fire(new r.Event("dataloading",{dataType:"style"})),this._load(Bm,!1)}_updateLayerCount(o,d){const y=d?1:-1;o.is3D()&&(this._num3DLayers+=y),o.type==="circle"&&(this._numCircleLayers+=y),o.type==="symbol"&&(this._numSymbolLayers+=y)}_load(o,d){if(d&&bl(this,r.validateStyle(o)))return;this._loaded=!0,this.stylesheet=o,this._updateMapProjection();for(const E in o.sources)this.addSource(E,o.sources[E],{validate:!1});this._changed=!1,o.sprite?this._loadSprite(o.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(o.glyphs);const y=Tt(this.stylesheet.layers);this._order=y.map(E=>E.id),this._layers={},this._serializedLayers={};for(let E of y)E=r.createStyleLayer(E),E.setEventedParent(this,{layer:{id:E.id}}),this._layers[E.id]=E,this._serializedLayers[E.id]=E.serialize(),this._updateLayerCount(E,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new Ve(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new r.Event("data",{dataType:"style"})),this.fire(new r.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}setProjection(o){o?this.stylesheet.projection=o:delete this.stylesheet.projection,this.map._explicitProjection||this.map._updateProjection()}_updateMapProjection(){this.map._explicitProjection?this.applyProjectionUpdate():this.map._updateProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_loadSprite(o){this._spriteRequest=function(d,y,E){let C,S,k;const O=r.exported.devicePixelRatio>1?"@2x":"";let U=r.getJSON(y.transformRequest(y.normalizeSpriteURL(d,O,".json"),r.ResourceType.SpriteJSON),(se,de)=>{U=null,k||(k=se,C=de,Z())}),G=r.getImage(y.transformRequest(y.normalizeSpriteURL(d,O,".png"),r.ResourceType.SpriteImage),(se,de)=>{G=null,k||(k=se,S=de,Z())});function Z(){if(k)E(k);else if(C&&S){const se=r.exported.getImageData(S),de={};for(const ce in C){const{width:te,height:Le,x:ve,y:De,sdf:Se,pixelRatio:ze,stretchX:Ee,stretchY:Ue,content:nt}=C[ce],lt=new r.RGBAImage({width:te,height:Le});r.RGBAImage.copy(se,lt,{x:ve,y:De},{x:0,y:0},{width:te,height:Le}),de[ce]={data:lt,pixelRatio:ze,sdf:Se,stretchX:Ee,stretchY:Ue,content:nt}}E(null,de)}}return{cancel(){U&&(U.cancel(),U=null),G&&(G.cancel(),G=null)}}}(o,this.map._requestManager,(d,y)=>{if(this._spriteRequest=null,d)this.fire(new r.ErrorEvent(d));else if(y)for(const E in y)this.imageManager.addImage(E,y[E]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new r.Event("data",{dataType:"style"}))})}_validateLayer(o){const d=this.getSource(o.source);if(!d)return;const y=o.sourceLayer;y&&(d.type==="geojson"||d.vectorLayerIds&&d.vectorLayerIds.indexOf(y)===-1)&&this.fire(new r.ErrorEvent(new Error(`Source layer "${y}" does not exist on source "${d.id}" as specified by style layer "${o.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const o in this._sourceCaches)if(!this._sourceCaches[o].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(o){const d=[];for(const y of o){const E=this._layers[y];E.type!=="custom"&&d.push(E.serialize())}return d}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const o in this._sourceCaches)if(this._sourceCaches[o].hasTransition())return!0;for(const o in this._layers)if(this._layers[o].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(o){return!!this.terrain&&Na[o.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(o){if(!this._loaded)return;const d=this._changed;if(this._changed){const E=Object.keys(this._updatedLayers),C=Object.keys(this._removedLayers);(E.length||C.length)&&this._updateWorkerLayers(E,C);for(const S in this._updatedSources){const k=this._updatedSources[S];k==="reload"?this._reloadSource(S):k==="clear"&&this._clearSource(S)}this._updateTilesForChangedImages();for(const S in this._updatedPaintProps)this._layers[S].updateTransitions(o);this.light.updateTransitions(o),this.fog&&this.fog.updateTransitions(o),this._resetUpdates()}const y={};for(const E in this._sourceCaches){const C=this._sourceCaches[E];y[E]=C.used,C.used=!1}for(const E of this._order){const C=this._layers[E];if(C.recalculate(o,this._availableImages),!C.isHidden(o.zoom)){const k=this._getLayerSourceCache(C);k&&(k.used=!0)}const S=this.map.painter;if(S){const k=C.getProgramIds();if(!k)continue;const O=C.getProgramConfiguration(o.zoom);for(const U of k)S.useProgram(U,O)}}for(const E in y){const C=this._sourceCaches[E];y[E]!==C.used&&C.getSource().fire(new r.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:C.getSource().id}))}this.light.recalculate(o),this.terrain&&this.terrain.recalculate(o),this.fog&&this.fog.recalculate(o),this.z=o.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),d&&this.fire(new r.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const o=Object.keys(this._changedImages);if(o.length){for(const d in this._sourceCaches)this._sourceCaches[d].reloadTilesForDependencies(["icons","patterns"],o);this._changedImages={}}}_updateWorkerLayers(o,d){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(o),removedIds:d})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(o){if(this._checkLoaded(),bl(this,r.validateStyle(o)))return!1;(o=r.clone$1(o)).layers=Tt(o.layers);const d=function(E,C){if(!E)return[{command:_t.setStyle,args:[C]}];let S=[];try{if(!b(E.version,C.version))return[{command:_t.setStyle,args:[C]}];b(E.center,C.center)||S.push({command:_t.setCenter,args:[C.center]}),b(E.zoom,C.zoom)||S.push({command:_t.setZoom,args:[C.zoom]}),b(E.bearing,C.bearing)||S.push({command:_t.setBearing,args:[C.bearing]}),b(E.pitch,C.pitch)||S.push({command:_t.setPitch,args:[C.pitch]}),b(E.sprite,C.sprite)||S.push({command:_t.setSprite,args:[C.sprite]}),b(E.glyphs,C.glyphs)||S.push({command:_t.setGlyphs,args:[C.glyphs]}),b(E.transition,C.transition)||S.push({command:_t.setTransition,args:[C.transition]}),b(E.light,C.light)||S.push({command:_t.setLight,args:[C.light]}),b(E.fog,C.fog)||S.push({command:_t.setFog,args:[C.fog]}),b(E.projection,C.projection)||S.push({command:_t.setProjection,args:[C.projection]});const k={},O=[];(function(Z,se,de,ce){let te;for(te in se=se||{},Z=Z||{})Z.hasOwnProperty(te)&&(se.hasOwnProperty(te)||rn(te,de,ce));for(te in se)se.hasOwnProperty(te)&&(Z.hasOwnProperty(te)?b(Z[te],se[te])||(Z[te].type==="geojson"&&se[te].type==="geojson"&&Ln(Z,se,te)?de.push({command:_t.setGeoJSONSourceData,args:[te,se[te].data]}):Sn(te,se,de,ce)):Ot(te,se,de))})(E.sources,C.sources,O,k);const U=[];E.layers&&E.layers.forEach(Z=>{Z.source&&k[Z.source]?S.push({command:_t.removeLayer,args:[Z.id]}):U.push(Z)});let G=E.terrain;G&&k[G.source]&&(S.push({command:_t.setTerrain,args:[void 0]}),G=void 0),S=S.concat(O),b(G,C.terrain)||S.push({command:_t.setTerrain,args:[C.terrain]}),function(Z,se,de){se=se||[];const ce=(Z=Z||[]).map(un),te=se.map(un),Le=Z.reduce(Kt,{}),ve=se.reduce(Kt,{}),De=ce.slice(),Se=Object.create(null);let ze,Ee,Ue,nt,lt,pt,ht;for(ze=0,Ee=0;ze<ce.length;ze++)Ue=ce[ze],ve.hasOwnProperty(Ue)?Ee++:(de.push({command:_t.removeLayer,args:[Ue]}),De.splice(De.indexOf(Ue,Ee),1));for(ze=0,Ee=0;ze<te.length;ze++)Ue=te[te.length-1-ze],De[De.length-1-ze]!==Ue&&(Le.hasOwnProperty(Ue)?(de.push({command:_t.removeLayer,args:[Ue]}),De.splice(De.lastIndexOf(Ue,De.length-Ee),1)):Ee++,pt=De[De.length-ze],de.push({command:_t.addLayer,args:[ve[Ue],pt]}),De.splice(De.length-ze,0,Ue),Se[Ue]=!0);for(ze=0;ze<te.length;ze++)if(Ue=te[ze],nt=Le[Ue],lt=ve[Ue],!Se[Ue]&&!b(nt,lt))if(b(nt.source,lt.source)&&b(nt["source-layer"],lt["source-layer"])&&b(nt.type,lt.type)){for(ht in Mt(nt.layout,lt.layout,de,Ue,null,_t.setLayoutProperty),Mt(nt.paint,lt.paint,de,Ue,null,_t.setPaintProperty),b(nt.filter,lt.filter)||de.push({command:_t.setFilter,args:[Ue,lt.filter]}),b(nt.minzoom,lt.minzoom)&&b(nt.maxzoom,lt.maxzoom)||de.push({command:_t.setLayerZoomRange,args:[Ue,lt.minzoom,lt.maxzoom]}),nt)nt.hasOwnProperty(ht)&&ht!=="layout"&&ht!=="paint"&&ht!=="filter"&&ht!=="metadata"&&ht!=="minzoom"&&ht!=="maxzoom"&&(ht.indexOf("paint.")===0?Mt(nt[ht],lt[ht],de,Ue,ht.slice(6),_t.setPaintProperty):b(nt[ht],lt[ht])||de.push({command:_t.setLayerProperty,args:[Ue,ht,lt[ht]]}));for(ht in lt)lt.hasOwnProperty(ht)&&!nt.hasOwnProperty(ht)&&ht!=="layout"&&ht!=="paint"&&ht!=="filter"&&ht!=="metadata"&&ht!=="minzoom"&&ht!=="maxzoom"&&(ht.indexOf("paint.")===0?Mt(nt[ht],lt[ht],de,Ue,ht.slice(6),_t.setPaintProperty):b(nt[ht],lt[ht])||de.push({command:_t.setLayerProperty,args:[Ue,ht,lt[ht]]}))}else de.push({command:_t.removeLayer,args:[Ue]}),pt=De[De.lastIndexOf(Ue)+1],de.push({command:_t.addLayer,args:[lt,pt]})}(U,C.layers,S)}catch(k){console.warn("Unable to compute style diff:",k),S=[{command:_t.setStyle,args:[C]}]}return S}(this.serialize(),o).filter(E=>!(E.command in Fm));if(d.length===0)return!1;const y=d.filter(E=>!(E.command in zm));if(y.length>0)throw new Error(`Unimplemented: ${y.map(E=>E.command).join(", ")}.`);return d.forEach(E=>{E.command!=="setTransition"&&this[E.command].apply(this,E.args)}),this.stylesheet=o,this._updateMapProjection(),!0}addImage(o,d){return this.getImage(o)?this.fire(new r.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(o,d),this._afterImageUpdated(o),this)}updateImage(o,d){this.imageManager.updateImage(o,d)}getImage(o){return this.imageManager.getImage(o)}removeImage(o){return this.getImage(o)?(this.imageManager.removeImage(o),this._afterImageUpdated(o),this):this.fire(new r.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(o){this._availableImages=this.imageManager.listImages(),this._changedImages[o]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new r.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(o,d,y={}){if(this._checkLoaded(),this.getSource(o)!==void 0)throw new Error("There is already a source with this ID");if(!d.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(d).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(d.type)>=0&&this._validate(r.validateSource,`sources.${o}`,d,null,y))return;this.map&&this.map._collectResourceTiming&&(d.collectResourceTiming=!0);const E=tt(o,d,this.dispatcher,this);E.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(o),source:E.serialize(),sourceId:o}));const C=S=>{const k=(S?"symbol:":"other:")+o,O=this._sourceCaches[k]=new r.SourceCache(k,E,S);(S?this._symbolSourceCaches:this._otherSourceCaches)[o]=O,O.style=this,O.onAdd(this.map)};C(!1),d.type!=="vector"&&d.type!=="geojson"||C(!0),E.onAdd&&E.onAdd(this.map),this._changed=!0}removeSource(o){this._checkLoaded();const d=this.getSource(o);if(!d)throw new Error("There is no source with this ID");for(const E in this._layers)if(this._layers[E].source===o)return this.fire(new r.ErrorEvent(new Error(`Source "${o}" cannot be removed while layer "${E}" is using it.`)));if(this.terrain&&this.terrain.get().source===o)return this.fire(new r.ErrorEvent(new Error(`Source "${o}" cannot be removed while terrain is using it.`)));const y=this._getSourceCaches(o);for(const E of y)delete this._sourceCaches[E.id],delete this._updatedSources[E.id],E.fire(new r.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:E.getSource().id})),E.setEventedParent(null),E.clearTiles();return delete this._otherSourceCaches[o],delete this._symbolSourceCaches[o],d.setEventedParent(null),d.onRemove&&d.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(o,d){this._checkLoaded(),this.getSource(o).setData(d),this._changed=!0}getSource(o){const d=this._getSourceCache(o);return d&&d.getSource()}addLayer(o,d,y={}){this._checkLoaded();const E=o.id;if(this.getLayer(E))return void this.fire(new r.ErrorEvent(new Error(`Layer with id "${E}" already exists on this map`)));let C;if(o.type==="custom"){if(bl(this,r.validateCustomStyleLayer(o)))return;C=r.createStyleLayer(o)}else{if(typeof o.source=="object"&&(this.addSource(E,o.source),o=r.clone$1(o),o=r.extend(o,{source:E})),this._validate(r.validateLayer,`layers.${E}`,o,{arrayIndex:-1},y))return;C=r.createStyleLayer(o),this._validateLayer(C),C.setEventedParent(this,{layer:{id:E}}),this._serializedLayers[C.id]=C.serialize(),this._updateLayerCount(C,!0)}const S=d?this._order.indexOf(d):this._order.length;if(d&&S===-1)return void this.fire(new r.ErrorEvent(new Error(`Layer with id "${d}" does not exist on this map.`)));this._order.splice(S,0,E),this._layerOrderChanged=!0,this._layers[E]=C;const k=this._getLayerSourceCache(C);if(this._removedLayers[E]&&C.source&&k&&C.type!=="custom"){const O=this._removedLayers[E];delete this._removedLayers[E],O.type!==C.type?this._updatedSources[C.source]="clear":(this._updatedSources[C.source]="reload",k.pause())}this._updateLayer(C),C.onAdd&&C.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(o,d){if(this._checkLoaded(),this._changed=!0,!this._layers[o])return void this.fire(new r.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be moved.`)));if(o===d)return;const y=this._order.indexOf(o);this._order.splice(y,1);const E=d?this._order.indexOf(d):this._order.length;d&&E===-1?this.fire(new r.ErrorEvent(new Error(`Layer with id "${d}" does not exist on this map.`))):(this._order.splice(E,0,o),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(o){this._checkLoaded();const d=this._layers[o];if(!d)return void this.fire(new r.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be removed.`)));d.setEventedParent(null),this._updateLayerCount(d,!1);const y=this._order.indexOf(o);this._order.splice(y,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[o]=d,delete this._layers[o],delete this._serializedLayers[o],delete this._updatedLayers[o],delete this._updatedPaintProps[o],d.onRemove&&d.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(o){return this._layers[o]}hasLayer(o){return o in this._layers}hasLayerType(o){for(const d in this._layers)if(this._layers[d].type===o)return!0;return!1}setLayerZoomRange(o,d,y){this._checkLoaded();const E=this.getLayer(o);E?E.minzoom===d&&E.maxzoom===y||(d!=null&&(E.minzoom=d),y!=null&&(E.maxzoom=y),this._updateLayer(E)):this.fire(new r.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(o,d,y={}){this._checkLoaded();const E=this.getLayer(o);if(E){if(!b(E.filter,d))return d==null?(E.filter=void 0,void this._updateLayer(E)):void(this._validate(r.validateFilter,`layers.${E.id}.filter`,d,{layerType:E.type},y)||(E.filter=r.clone$1(d),this._updateLayer(E)))}else this.fire(new r.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be filtered.`)))}getFilter(o){const d=this.getLayer(o);return d&&r.clone$1(d.filter)}setLayoutProperty(o,d,y,E={}){this._checkLoaded();const C=this.getLayer(o);C?b(C.getLayoutProperty(d),y)||(C.setLayoutProperty(d,y,E),this._updateLayer(C)):this.fire(new r.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(o,d){const y=this.getLayer(o);if(y)return y.getLayoutProperty(d);this.fire(new r.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style.`)))}setPaintProperty(o,d,y,E={}){this._checkLoaded();const C=this.getLayer(o);C?b(C.getPaintProperty(d),y)||(C.setPaintProperty(d,y,E)&&this._updateLayer(C),this._changed=!0,this._updatedPaintProps[o]=!0):this.fire(new r.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(o,d){const y=this.getLayer(o);return y&&y.getPaintProperty(d)}setFeatureState(o,d){this._checkLoaded();const y=o.source,E=o.sourceLayer,C=this.getSource(y);if(!C)return void this.fire(new r.ErrorEvent(new Error(`The source '${y}' does not exist in the map's style.`)));const S=C.type;if(S==="geojson"&&E)return void this.fire(new r.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(S==="vector"&&!E)return void this.fire(new r.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));o.id===void 0&&this.fire(new r.ErrorEvent(new Error("The feature id parameter must be provided.")));const k=this._getSourceCaches(y);for(const O of k)O.setFeatureState(E,o.id,d)}removeFeatureState(o,d){this._checkLoaded();const y=o.source,E=this.getSource(y);if(!E)return void this.fire(new r.ErrorEvent(new Error(`The source '${y}' does not exist in the map's style.`)));const C=E.type,S=C==="vector"?o.sourceLayer:void 0;if(C==="vector"&&!S)return void this.fire(new r.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(d&&typeof o.id!="string"&&typeof o.id!="number")return void this.fire(new r.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const k=this._getSourceCaches(y);for(const O of k)O.removeFeatureState(S,o.id,d)}getFeatureState(o){this._checkLoaded();const d=o.source,y=o.sourceLayer,E=this.getSource(d);if(E){if(E.type!=="vector"||y)return o.id===void 0&&this.fire(new r.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(d)[0].getFeatureState(y,o.id);this.fire(new r.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new r.ErrorEvent(new Error(`The source '${d}' does not exist in the map's style.`)))}getTransition(){return r.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const o={};for(const d in this._sourceCaches){const y=this._sourceCaches[d].getSource();o[y.id]||(o[y.id]=y.serialize())}return r.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:o,layers:this._serializeLayers(this._order)},d=>d!==void 0)}_updateLayer(o){this._updatedLayers[o.id]=!0;const d=this._getLayerSourceCache(o);o.source&&!this._updatedSources[o.source]&&d&&d.getSource().type!=="raster"&&(this._updatedSources[o.source]="reload",d.pause()),this._changed=!0,o.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(o){const d=S=>this._layers[S].type==="fill-extrusion",y={},E=[];for(let S=this._order.length-1;S>=0;S--){const k=this._order[S];if(d(k)){y[k]=S;for(const O of o){const U=O[k];if(U)for(const G of U)E.push(G)}}}E.sort((S,k)=>k.intersectionZ-S.intersectionZ);const C=[];for(let S=this._order.length-1;S>=0;S--){const k=this._order[S];if(d(k))for(let O=E.length-1;O>=0;O--){const U=E[O].feature;if(y[U.layer.id]<S)break;C.push(U),E.pop()}else for(const O of o){const U=O[k];if(U)for(const G of U)C.push(G.feature)}}return C}queryRenderedFeatures(o,d,y){d&&d.filter&&this._validate(r.validateFilter,"queryRenderedFeatures.filter",d.filter,null,d);const E={};if(d&&d.layers){if(!Array.isArray(d.layers))return this.fire(new r.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const O of d.layers){const U=this._layers[O];if(!U)return this.fire(new r.ErrorEvent(new Error(`The layer '${O}' does not exist in the map's style and cannot be queried for features.`))),[];E[U.source]=!0}}const C=[];d.availableImages=this._availableImages;const S=d&&d.layers?d.layers.some(O=>{const U=this.getLayer(O);return U&&U.is3D()}):this.has3DLayers(),k=Ge.createFromScreenPoints(o,y);for(const O in this._sourceCaches){const U=this._sourceCaches[O].getSource().id;d.layers&&!E[U]||C.push(rt(this._sourceCaches[O],this._layers,this._serializedLayers,k,d,y,S,!!this.map._showQueryGeometry))}return this.placement&&C.push(function(O,U,G,Z,se,de,ce){const te={},Le=de.queryRenderedSymbols(Z),ve=[];for(const De of Object.keys(Le).map(Number))ve.push(ce[De]);ve.sort(Vt);for(const De of ve){const Se=De.featureIndex.lookupSymbolFeatures(Le[De.bucketInstanceId],U,De.bucketIndex,De.sourceLayerIndex,se.filter,se.layers,se.availableImages,O);for(const ze in Se){const Ee=te[ze]=te[ze]||[],Ue=Se[ze];Ue.sort((nt,lt)=>{const pt=De.featureSortOrder;if(pt){const ht=pt.indexOf(nt.featureIndex);return pt.indexOf(lt.featureIndex)-ht}return lt.featureIndex-nt.featureIndex});for(const nt of Ue)Ee.push(nt)}}for(const De in te)te[De].forEach(Se=>{const ze=Se.feature,Ee=G(O[De]).getFeatureState(ze.layer["source-layer"],ze.id);ze.source=ze.layer.source,ze.layer["source-layer"]&&(ze.sourceLayer=ze.layer["source-layer"]),ze.state=Ee});return te}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),k.screenGeometry,d,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(C)}querySourceFeatures(o,d){d&&d.filter&&this._validate(r.validateFilter,"querySourceFeatures.filter",d.filter,null,d);const y=this._getSourceCaches(o);let E=[];for(const C of y)E=E.concat(vt(C,d));return E}addSourceType(o,d,y){return yr.getSourceType(o)?y(new Error(`A source type called "${o}" already exists.`)):(yr.setSourceType(o,d),d.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:o,url:d.workerSourceURL},y):y(null,null))}getLight(){return this.light.getLight()}setLight(o,d={}){this._checkLoaded();const y=this.light.getLight();let E=!1;for(const S in o)if(!b(o[S],y[S])){E=!0;break}if(!E)return;const C={now:r.exported.now(),transition:r.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(o,d),this.light.updateTransitions(C)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(o,d=1){if(this._checkLoaded(),!o)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(d===1){if(typeof o.source=="object"){const y="terrain-dem-src";this.addSource(y,o.source),o=r.clone$1(o),o=r.extend(o,{source:y})}if(this._validate(r.validateTerrain,"terrain",o))return}if(!this.terrain||this.terrain&&d!==this.terrain.drapeRenderMode)this._createTerrain(o,d);else{const y=this.terrain,E=y.get();for(const C in o)if(!b(o[C],E[C])){y.set(o),this.stylesheet.terrain=o;const S={now:r.exported.now(),transition:r.extend({duration:0},this.stylesheet.transition)};y.updateTransitions(S);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(o){const d=this.fog=new Ie(o,this.map.transform);this.stylesheet.fog=o;const y={now:r.exported.now(),transition:r.extend({duration:0},this.stylesheet.transition)};d.updateTransitions(y)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const o of this.map._markers)o._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(o){if(this._checkLoaded(),!o)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const d=this.fog,y=d.get();for(const E in o)if(!b(o[E],y[E])){d.set(o),this.stylesheet.fog=o;const C={now:r.exported.now(),transition:r.extend({duration:0},this.stylesheet.transition)};d.updateTransitions(C);break}}else this._createFog(o);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const o=this._order.filter(y=>this.isLayerDraped(this._layers[y])),d=this._order.filter(y=>!this.isLayerDraped(this._layers[y]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...o),this._drapedFirstOrder.push(...d)}_createTerrain(o,d){const y=this.terrain=new At(o,d);this.stylesheet.terrain=o,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const E={now:r.exported.now(),transition:r.extend({duration:0},this.stylesheet.transition)};y.updateTransitions(E)}_force3DLayerUpdate(){for(const o in this._layers){const d=this._layers[o];d.type==="fill-extrusion"&&this._updateLayer(d)}}_forceSymbolLayerUpdate(){for(const o in this._layers){const d=this._layers[o];d.type==="symbol"&&this._updateLayer(d)}}_validate(o,d,y,E,C={}){return(!C||C.validate!==!1)&&bl(this,o.call(r.validateStyle,r.extend({key:d,style:this.serialize(),value:y,styleSpec:r.spec},E)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),r.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const o in this._layers)this._layers[o].setEventedParent(null);for(const o in this._sourceCaches)this._sourceCaches[o].clearTiles(),this._sourceCaches[o].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(o){const d=this._getSourceCaches(o);for(const y of d)y.clearTiles()}_reloadSource(o){const d=this._getSourceCaches(o);for(const y of d)y.resume(),y.reload()}_updateSources(o){for(const d in this._sourceCaches)this._sourceCaches[d].update(o)}_generateCollisionBoxes(){for(const o in this._sourceCaches){const d=this._sourceCaches[o];d.resume(),d.reload()}}_updatePlacement(o,d,y,E,C=!1){let S=!1,k=!1;const O={};for(const U of this._order){const G=this._layers[U];if(G.type!=="symbol")continue;if(!O[G.source]){const se=this._getLayerSourceCache(G);if(!se)continue;O[G.source]=se.getRenderableIds(!0).map(de=>se.getTileByID(de)).sort((de,ce)=>ce.tileID.overscaledZ-de.tileID.overscaledZ||(de.tileID.isLessThan(ce.tileID)?-1:1))}const Z=this.crossTileSymbolIndex.addLayer(G,O[G.source],o.center.lng,o.projection);S=S||Z}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),C=C||this._layerOrderChanged||y===0,this._layerOrderChanged&&this.fire(new r.Event("neworder")),(C||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(r.exported.now(),o.zoom))&&(this.pauseablePlacement=new X_(o,this._order,C,d,y,E,this.placement,this.fog&&o.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,O),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(r.exported.now()),k=!0),S&&this.pauseablePlacement.placement.setStale()),k||S)for(const U of this._order){const G=this._layers[U];G.type==="symbol"&&this.placement.updateLayerOpacities(G,O[G.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(r.exported.now())}_releaseSymbolFadeTiles(){for(const o in this._sourceCaches)this._sourceCaches[o].releaseSymbolFadeTiles()}getImages(o,d,y){this.imageManager.getImages(d.icons,y),this._updateTilesForChangedImages();const E=C=>{C&&C.setDependencies(d.tileID.key,d.type,d.icons)};E(this._otherSourceCaches[d.source]),E(this._symbolSourceCaches[d.source])}getGlyphs(o,d,y){this.glyphManager.getGlyphs(d.stacks,y)}getResource(o,d,y){return r.makeRequest(d,y)}_getSourceCache(o){return this._otherSourceCaches[o]}_getLayerSourceCache(o){return o.type==="symbol"?this._symbolSourceCaches[o.source]:this._otherSourceCaches[o.source]}_getSourceCaches(o){const d=[];return this._otherSourceCaches[o]&&d.push(this._otherSourceCaches[o]),this._symbolSourceCaches[o]&&d.push(this._symbolSourceCaches[o]),d}_isSourceCacheLoaded(o){const d=this._getSourceCaches(o);return d.length===0?(this.fire(new r.ErrorEvent(new Error(`There is no source with ID '${o}'`))),!1):d.every(y=>y.loaded())}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}yr.getSourceType=function(m){return et[m]},yr.setSourceType=function(m,o){et[m]=o},yr.registerForPluginStateChange=r.registerForPluginStateChange;var wl=`
- #define EPSILON 0.0000001
- #define PI 3.141592653589793
- #define EXTENT 8192.0
- #define HALF_PI PI/2.0
- #define QUARTER_PI PI/4.0
- #define RAD_TO_DEG 180.0/PI
- #define DEG_TO_RAD PI/180.0
- #define GLOBE_RADIUS EXTENT/PI/2.0
- #ifdef FOG
- uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}
- #endif`,Ml="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}";let Ua={},oa={};Ua=yn("",`
- #define ELEVATION_SCALE 7.0
- #define ELEVATION_OFFSET 450.0
- #ifdef PROJECTION_GLOBE_VIEW
- uniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(
- mix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}
- #else
- vec3 elevationVector(vec2 pos) { return vec3(0,0,1); }
- #endif
- #ifdef TERRAIN
- #ifdef TERRAIN_DEM_FLOAT_FORMAT
- uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;
- #else
- uniform sampler2D u_dem;uniform sampler2D u_dem_prev;
- #endif
- uniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {
- #ifdef TERRAIN_DEM_FLOAT_FORMAT
- vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;
- #else
- float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));
- #ifdef TERRAIN_DEM_NEAREST_FILTER
- return u_exaggeration*tl;
- #endif
- float tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
- #endif
- }float prevElevation(vec2 apos) {
- #ifdef TERRAIN_DEM_FLOAT_FORMAT
- vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;
- #else
- float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
- #endif
- }
- #ifdef TERRAIN_VERTEX_MORPHING
- float elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}
- #else
- float elevation(vec2 apos) {return currentElevation(apos);}
- #endif
- float unpack_depth(vec4 rgba_depth)
- {const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(
- unpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))
- );return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {
- #ifdef TERRAIN_DEM_FLOAT_FORMAT
- float tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;
- #else
- vec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);
- #endif
- return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}
- #else
- float elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }
- #endif`,!0),oa=yn(`#ifdef FOG
- uniform float u_fog_temporal_offset;float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}
- #endif`,`#ifdef FOG
- uniform mat4 u_fog_matrix;vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}
- #endif`,!0);const yu=yn(`
- highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}
- #ifdef TERRAIN
- highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}
- #endif`,`
- float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}
- #ifdef PROJECTION_GLOBE_VIEW
- vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {
- #ifndef PROJECTED_POS_ON_VIEWPORT
- float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;
- #else
- return vec3(0.0);
- #endif
- }vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}
- #endif
- vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(
- unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
- );}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered.`),Tl=wl;var El={background:yn(`uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;
- #ifdef FOG
- out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
- #endif
- gl_FragColor=out_color*u_opacity;
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);
- #ifdef FOG
- v_fog_pos=fog_position(a_pos);
- #endif
- }`),backgroundPattern:yn(`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);
- #ifdef FOG
- out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
- #endif
- gl_FragColor=out_color*u_opacity;
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);
- #ifdef FOG
- v_fog_pos=fog_position(a_pos);
- #endif
- }`),circle:yn(`varying vec3 v_data;varying float v_visibility;
- #pragma mapbox: define highp vec4 color
- #pragma mapbox: define mediump float radius
- #pragma mapbox: define lowp float blur
- #pragma mapbox: define lowp float opacity
- #pragma mapbox: define highp vec4 stroke_color
- #pragma mapbox: define mediump float stroke_width
- #pragma mapbox: define lowp float stroke_opacity
- void main() {
- #pragma mapbox: initialize highp vec4 color
- #pragma mapbox: initialize mediump float radius
- #pragma mapbox: initialize lowp float blur
- #pragma mapbox: initialize lowp float opacity
- #pragma mapbox: initialize highp vec4 stroke_color
- #pragma mapbox: initialize mediump float stroke_width
- #pragma mapbox: initialize lowp float stroke_opacity
- vec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(
- antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)
- );vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);
- #ifdef FOG
- out_color=fog_apply_premultiplied(out_color,v_fog_pos);
- #endif
- gl_FragColor=out_color*(v_visibility*opacity_t);
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`#define NUM_VISIBILITY_RINGS 2
- #define INV_SQRT2 0.70710678
- #define ELEVATION_BIAS 0.0001
- #define NUM_SAMPLES_PER_RING 16
- uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;
- #ifdef PROJECTION_GLOBE_VIEW
- attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
- #endif
- varying vec3 v_data;varying float v_visibility;
- #pragma mapbox: define highp vec4 color
- #pragma mapbox: define mediump float radius
- #pragma mapbox: define lowp float blur
- #pragma mapbox: define lowp float opacity
- #pragma mapbox: define highp vec4 stroke_color
- #pragma mapbox: define mediump float stroke_width
- #pragma mapbox: define lowp float stroke_opacity
- vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {
- #if defined(TERRAIN)
- return elevation(pos)+ELEVATION_BIAS;
- #else
- return 0.0;
- #endif
- }vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);
- #ifdef PITCH_WITH_MAP
- #ifdef PROJECTION_GLOBE_VIEW
- return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );
- #else
- return u_matrix*( world_center+vec4(sample_offset,0,0) );
- #endif
- #else
- return projected_center+vec4(sample_offset,0,0);
- #endif
- }float get_sample_step() {
- #ifdef PITCH_WITH_MAP
- return 2.0*PI/float(NUM_SAMPLES_PER_RING);
- #else
- return PI/float(NUM_SAMPLES_PER_RING);
- #endif
- }void main(void) {
- #pragma mapbox: initialize highp vec4 color
- #pragma mapbox: initialize mediump float radius
- #pragma mapbox: initialize lowp float blur
- #pragma mapbox: initialize lowp float opacity
- #pragma mapbox: initialize highp vec4 stroke_color
- #pragma mapbox: initialize mediump float stroke_width
- #pragma mapbox: initialize lowp float stroke_opacity
- vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);
- #ifdef PROJECTION_GLOBE_VIEW
- vec2 scaled_extrude=extrude*a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=scaled_extrude.x*surface_vectors[0]+scaled_extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);vec4 world_center=vec4(pos,1);
- #else
- mat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);
- #endif
- vec4 projected_center=u_matrix*world_center;float view_scale=0.0;
- #ifdef PITCH_WITH_MAP
- #ifdef SCALE_WITH_MAP
- view_scale=1.0;
- #else
- view_scale=projected_center.w/u_camera_to_center_distance;
- #endif
- #else
- #ifdef SCALE_WITH_MAP
- view_scale=u_camera_to_center_distance;
- #else
- view_scale=projected_center.w;
- #endif
- #endif
- #if defined(SCALE_WITH_MAP) && defined(PROJECTION_GLOBE_VIEW)
- view_scale*=a_scale;
- #endif
- gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;
- #ifdef TERRAIN
- float step=get_sample_step();
- #ifdef PITCH_WITH_MAP
- float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;
- #else
- vec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;
- #endif
- for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);
- #else
- visibility=1.0;
- #endif
- #ifdef PROJECTION_GLOBE_VIEW
- visibility=1.0;
- #endif
- v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);
- #ifdef FOG
- v_fog_pos=fog_position(world_center.xyz);
- #endif
- }`),clippingMask:yn("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:yn(`uniform highp float u_intensity;varying vec2 v_extrude;
- #pragma mapbox: define highp float weight
- #define GAUSS_COEF 0.3989422804014327
- void main() {
- #pragma mapbox: initialize highp float weight
- float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);
- #ifdef FOG
- gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);
- #endif
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;
- #ifdef PROJECTION_GLOBE_VIEW
- attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
- #endif
- varying vec2 v_extrude;
- #pragma mapbox: define highp float weight
- #pragma mapbox: define mediump float radius
- const highp float ZERO=1.0/255.0/16.0;
- #define GAUSS_COEF 0.3989422804014327
- void main(void) {
- #pragma mapbox: initialize highp float weight
- #pragma mapbox: initialize mediump float radius
- vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);
- #ifdef PROJECTION_GLOBE_VIEW
- extrude*=a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
- #else
- vec3 pos=vec3(tilePos+extrude,elevation(tilePos));
- #endif
- gl_Position=u_matrix*vec4(pos,1);
- #ifdef FOG
- v_fog_pos=fog_position(pos);
- #endif
- }`),heatmapTexture:yn(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(0.0);
- #endif
- }`,"attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:yn("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",`attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(
- 0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:yn("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}",`attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(
- mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(
- 0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:yn("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}",`attribute vec2 a_pos;
- #ifdef PROJECTION_GLOBE_VIEW
- attribute vec3 a_pos_3;
- #endif
- varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;
- #ifdef PROJECTION_GLOBE_VIEW
- gl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);
- #else
- gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);
- #endif
- }`),fill:yn(`#pragma mapbox: define highp vec4 color
- #pragma mapbox: define lowp float opacity
- void main() {
- #pragma mapbox: initialize highp vec4 color
- #pragma mapbox: initialize lowp float opacity
- vec4 out_color=color;
- #ifdef FOG
- out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
- #endif
- gl_FragColor=out_color*opacity;
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`attribute vec2 a_pos;uniform mat4 u_matrix;
- #pragma mapbox: define highp vec4 color
- #pragma mapbox: define lowp float opacity
- void main() {
- #pragma mapbox: initialize highp vec4 color
- #pragma mapbox: initialize lowp float opacity
- gl_Position=u_matrix*vec4(a_pos,0,1);
- #ifdef FOG
- v_fog_pos=fog_position(a_pos);
- #endif
- }`),fillOutline:yn(`varying vec2 v_pos;
- #pragma mapbox: define highp vec4 outline_color
- #pragma mapbox: define lowp float opacity
- void main() {
- #pragma mapbox: initialize highp vec4 outline_color
- #pragma mapbox: initialize lowp float opacity
- float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;
- #ifdef FOG
- out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
- #endif
- gl_FragColor=out_color*(alpha*opacity);
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;
- #pragma mapbox: define highp vec4 outline_color
- #pragma mapbox: define lowp float opacity
- void main() {
- #pragma mapbox: initialize highp vec4 outline_color
- #pragma mapbox: initialize lowp float opacity
- gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
- #ifdef FOG
- v_fog_pos=fog_position(a_pos);
- #endif
- }`),fillOutlinePattern:yn(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;
- #pragma mapbox: define lowp float opacity
- #pragma mapbox: define lowp vec4 pattern_from
- #pragma mapbox: define lowp vec4 pattern_to
- void main() {
- #pragma mapbox: initialize lowp float opacity
- #pragma mapbox: initialize mediump vec4 pattern_from
- #pragma mapbox: initialize mediump vec4 pattern_to
- vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);
- #ifdef FOG
- out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
- #endif
- gl_FragColor=out_color*(alpha*opacity);
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;
- #pragma mapbox: define lowp float opacity
- #pragma mapbox: define lowp vec4 pattern_from
- #pragma mapbox: define lowp vec4 pattern_to
- #pragma mapbox: define lowp float pixel_ratio_from
- #pragma mapbox: define lowp float pixel_ratio_to
- void main() {
- #pragma mapbox: initialize lowp float opacity
- #pragma mapbox: initialize mediump vec4 pattern_from
- #pragma mapbox: initialize mediump vec4 pattern_to
- #pragma mapbox: initialize lowp float pixel_ratio_from
- #pragma mapbox: initialize lowp float pixel_ratio_to
- vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
- #ifdef FOG
- v_fog_pos=fog_position(a_pos);
- #endif
- }`),fillPattern:yn(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;
- #pragma mapbox: define lowp float opacity
- #pragma mapbox: define lowp vec4 pattern_from
- #pragma mapbox: define lowp vec4 pattern_to
- void main() {
- #pragma mapbox: initialize lowp float opacity
- #pragma mapbox: initialize mediump vec4 pattern_from
- #pragma mapbox: initialize mediump vec4 pattern_to
- vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);
- #ifdef FOG
- out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
- #endif
- gl_FragColor=out_color*opacity;
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;
- #pragma mapbox: define lowp float opacity
- #pragma mapbox: define lowp vec4 pattern_from
- #pragma mapbox: define lowp vec4 pattern_to
- #pragma mapbox: define lowp float pixel_ratio_from
- #pragma mapbox: define lowp float pixel_ratio_to
- void main() {
- #pragma mapbox: initialize lowp float opacity
- #pragma mapbox: initialize mediump vec4 pattern_from
- #pragma mapbox: initialize mediump vec4 pattern_to
- #pragma mapbox: initialize lowp float pixel_ratio_from
- #pragma mapbox: initialize lowp float pixel_ratio_to
- vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);
- #ifdef FOG
- v_fog_pos=fog_position(a_pos);
- #endif
- }`),fillExtrusion:yn(`varying vec4 v_color;void main() {vec4 color=v_color;
- #ifdef FOG
- color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
- #endif
- gl_FragColor=color;
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;
- #ifdef PROJECTION_GLOBE_VIEW
- attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
- #endif
- varying vec4 v_color;
- #pragma mapbox: define highp float base
- #pragma mapbox: define highp float height
- #pragma mapbox: define highp vec4 color
- void main() {
- #pragma mapbox: initialize highp float base
- #pragma mapbox: initialize highp float height
- #pragma mapbox: initialize highp vec4 color
- vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);
- #if defined(HAS_CENTROID) || defined(TERRAIN)
- centroid_pos=a_centroid_pos;
- #endif
- #ifdef TERRAIN
- bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);
- #else
- vec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);
- #endif
- #ifdef PROJECTION_GLOBE_VIEW
- float lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(pos.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
- #endif
- float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(
- (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;
- #ifdef FOG
- v_fog_pos=fog_position(pos);
- #endif
- }`),fillExtrusionPattern:yn(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;
- #pragma mapbox: define lowp float base
- #pragma mapbox: define lowp float height
- #pragma mapbox: define lowp vec4 pattern_from
- #pragma mapbox: define lowp vec4 pattern_to
- #pragma mapbox: define lowp float pixel_ratio_from
- #pragma mapbox: define lowp float pixel_ratio_to
- void main() {
- #pragma mapbox: initialize lowp float base
- #pragma mapbox: initialize lowp float height
- #pragma mapbox: initialize mediump vec4 pattern_from
- #pragma mapbox: initialize mediump vec4 pattern_to
- #pragma mapbox: initialize lowp float pixel_ratio_from
- #pragma mapbox: initialize lowp float pixel_ratio_to
- vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;
- #ifdef FOG
- out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
- #endif
- gl_FragColor=out_color;
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;
- #ifdef PROJECTION_GLOBE_VIEW
- attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
- #endif
- varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;
- #pragma mapbox: define lowp float base
- #pragma mapbox: define lowp float height
- #pragma mapbox: define lowp vec4 pattern_from
- #pragma mapbox: define lowp vec4 pattern_to
- #pragma mapbox: define lowp float pixel_ratio_from
- #pragma mapbox: define lowp float pixel_ratio_to
- void main() {
- #pragma mapbox: initialize lowp float base
- #pragma mapbox: initialize lowp float height
- #pragma mapbox: initialize mediump vec4 pattern_from
- #pragma mapbox: initialize mediump vec4 pattern_to
- #pragma mapbox: initialize lowp float pixel_ratio_from
- #pragma mapbox: initialize lowp float pixel_ratio_to
- vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);
- #if defined(HAS_CENTROID) || defined(TERRAIN)
- centroid_pos=a_centroid_pos;
- #endif
- #ifdef TERRAIN
- bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);
- #else
- vec3 p=vec3(pos_nx.xy,z);
- #endif
- #ifdef PROJECTION_GLOBE_VIEW
- float lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
- #endif
- float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0
- ? pos_nx.xy
- : vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(
- (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;
- #ifdef FOG
- v_fog_pos=fog_position(p);
- #endif
- }`),hillshadePrepare:yn(`#ifdef GL_ES
- precision highp float;
- #endif
- uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {
- #ifdef TERRAIN_DEM_FLOAT_FORMAT
- return texture2D(u_image,coord).a/4.0;
- #else
- vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;
- #endif
- }void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(
- (c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)
- )/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(
- deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,"uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:yn(`uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;
- #ifdef FOG
- gl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));
- #endif
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;
- #ifdef FOG
- v_fog_pos=fog_position(a_pos);
- #endif
- }`),line:yn(`uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;
- #ifdef RENDER_LINE_DASH
- uniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;
- #endif
- #ifdef RENDER_LINE_GRADIENT
- uniform sampler2D u_gradient_image;varying highp vec2 v_uv;
- #endif
- #pragma mapbox: define highp vec4 color
- #pragma mapbox: define lowp float floorwidth
- #pragma mapbox: define lowp vec4 dash_from
- #pragma mapbox: define lowp vec4 dash_to
- #pragma mapbox: define lowp float blur
- #pragma mapbox: define lowp float opacity
- void main() {
- #pragma mapbox: initialize highp vec4 color
- #pragma mapbox: initialize lowp float floorwidth
- #pragma mapbox: initialize lowp vec4 dash_from
- #pragma mapbox: initialize lowp vec4 dash_to
- #pragma mapbox: initialize lowp float blur
- #pragma mapbox: initialize lowp float opacity
- float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);
- #ifdef RENDER_LINE_DASH
- float sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);
- #endif
- #ifdef RENDER_LINE_GRADIENT
- vec4 out_color=texture2D(u_gradient_image,v_uv);
- #else
- vec4 out_color=color;
- #endif
- #ifdef FOG
- out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
- #endif
- #ifdef RENDER_LINE_ALPHA_DISCARD
- if (alpha < u_alpha_discard_threshold) {discard;}
- #endif
- gl_FragColor=out_color*(alpha*opacity);
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`
- #define EXTRUDE_SCALE 0.015873016
- attribute vec2 a_pos_normal;attribute vec4 a_data;
- #ifdef RENDER_LINE_GRADIENT
- attribute vec3 a_packed;
- #else
- attribute float a_linesofar;
- #endif
- uniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;
- #ifdef RENDER_LINE_DASH
- uniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;
- #endif
- #ifdef RENDER_LINE_GRADIENT
- uniform float u_image_height;varying highp vec2 v_uv;
- #endif
- #pragma mapbox: define highp vec4 color
- #pragma mapbox: define lowp float floorwidth
- #pragma mapbox: define lowp vec4 dash_from
- #pragma mapbox: define lowp vec4 dash_to
- #pragma mapbox: define lowp float blur
- #pragma mapbox: define lowp float opacity
- #pragma mapbox: define mediump float gapwidth
- #pragma mapbox: define lowp float offset
- #pragma mapbox: define mediump float width
- void main() {
- #pragma mapbox: initialize highp vec4 color
- #pragma mapbox: initialize lowp float floorwidth
- #pragma mapbox: initialize lowp vec4 dash_from
- #pragma mapbox: initialize lowp vec4 dash_to
- #pragma mapbox: initialize lowp float blur
- #pragma mapbox: initialize lowp float opacity
- #pragma mapbox: initialize mediump float gapwidth
- #pragma mapbox: initialize lowp float offset
- #pragma mapbox: initialize mediump float width
- float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;
- #ifndef RENDER_TO_TEXTURE
- float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
- #else
- v_gamma_scale=1.0;
- #endif
- #ifdef RENDER_LINE_GRADIENT
- float a_uv_x=a_packed[0];float a_split_index=a_packed[1];float a_linesofar=a_packed[2];highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);
- #endif
- #ifdef RENDER_LINE_DASH
- float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);
- #endif
- v_width2=vec2(outset,inset);
- #ifdef FOG
- v_fog_pos=fog_position(pos);
- #endif
- }`),linePattern:yn(`uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
- #pragma mapbox: define lowp vec4 pattern_from
- #pragma mapbox: define lowp vec4 pattern_to
- #pragma mapbox: define lowp float pixel_ratio_from
- #pragma mapbox: define lowp float pixel_ratio_to
- #pragma mapbox: define lowp float blur
- #pragma mapbox: define lowp float opacity
- void main() {
- #pragma mapbox: initialize mediump vec4 pattern_from
- #pragma mapbox: initialize mediump vec4 pattern_to
- #pragma mapbox: initialize lowp float pixel_ratio_from
- #pragma mapbox: initialize lowp float pixel_ratio_to
- #pragma mapbox: initialize lowp float blur
- #pragma mapbox: initialize lowp float opacity
- vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);
- #ifdef FOG
- color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
- #endif
- gl_FragColor=color*(alpha*opacity);
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`
- #define scale 0.015873016
- attribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
- #pragma mapbox: define lowp float blur
- #pragma mapbox: define lowp float opacity
- #pragma mapbox: define lowp float offset
- #pragma mapbox: define mediump float gapwidth
- #pragma mapbox: define mediump float width
- #pragma mapbox: define lowp float floorwidth
- #pragma mapbox: define lowp vec4 pattern_from
- #pragma mapbox: define lowp vec4 pattern_to
- #pragma mapbox: define lowp float pixel_ratio_from
- #pragma mapbox: define lowp float pixel_ratio_to
- void main() {
- #pragma mapbox: initialize lowp float blur
- #pragma mapbox: initialize lowp float opacity
- #pragma mapbox: initialize lowp float offset
- #pragma mapbox: initialize mediump float gapwidth
- #pragma mapbox: initialize mediump float width
- #pragma mapbox: initialize lowp float floorwidth
- #pragma mapbox: initialize mediump vec4 pattern_from
- #pragma mapbox: initialize mediump vec4 pattern_to
- #pragma mapbox: initialize lowp float pixel_ratio_from
- #pragma mapbox: initialize lowp float pixel_ratio_to
- float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;
- #ifndef RENDER_TO_TEXTURE
- float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
- #else
- v_gamma_scale=1.0;
- #endif
- v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;
- #ifdef FOG
- v_fog_pos=fog_position(pos);
- #endif
- }`),raster:yn(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(
- dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);
- #ifdef FOG
- out_color=fog_dither(fog_apply(out_color,v_fog_pos));
- #endif
- gl_FragColor=vec4(out_color*color.a,color.a);
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;
- #ifdef FOG
- v_fog_pos=fog_position(a_pos);
- #endif
- }`),symbolIcon:yn(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;
- #pragma mapbox: define lowp float opacity
- void main() {
- #pragma mapbox: initialize lowp float opacity
- lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;
- #ifdef PROJECTION_GLOBE_VIEW
- uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
- #endif
- varying vec2 v_tex;varying float v_fade_opacity;
- #pragma mapbox: define lowp float opacity
- void main() {
- #pragma mapbox: initialize lowp float opacity
- vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);
- #ifdef PROJECTION_GLOBE_VIEW
- vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchor_z)+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
- #else
- vec3 world_pos=vec3(a_pos,anchor_z)+h;float globe_occlusion_fade=1.0;
- #endif
- vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
- camera_to_anchor_distance/u_camera_to_center_distance :
- u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
- 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point=u_matrix*vec4(a_pos+vec2(1,0),anchor_z,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}
- #ifdef PROJECTION_GLOBE_VIEW
- vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);
- #else
- vec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);
- #endif
- #ifdef PROJECTED_POS_ON_VIEWPORT
- vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);
- #else
- vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);
- #endif
- highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);
- #ifdef PITCH_WITH_MAP_TERRAIN
- vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
- #endif
- float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));float projection_transition_fade=1.0;
- #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
- projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
- #endif
- v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}`),symbolSDF:yn(`#define SDF_PX 8.0
- uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;
- #pragma mapbox: define highp vec4 fill_color
- #pragma mapbox: define highp vec4 halo_color
- #pragma mapbox: define lowp float opacity
- #pragma mapbox: define lowp float halo_width
- #pragma mapbox: define lowp float halo_blur
- void main() {
- #pragma mapbox: initialize highp vec4 fill_color
- #pragma mapbox: initialize highp vec4 halo_color
- #pragma mapbox: initialize lowp float opacity
- #pragma mapbox: initialize lowp float halo_width
- #pragma mapbox: initialize lowp float halo_blur
- float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;
- #ifdef PROJECTION_GLOBE_VIEW
- uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
- #endif
- varying vec2 v_data0;varying vec3 v_data1;
- #pragma mapbox: define highp vec4 fill_color
- #pragma mapbox: define highp vec4 halo_color
- #pragma mapbox: define lowp float opacity
- #pragma mapbox: define lowp float halo_width
- #pragma mapbox: define lowp float halo_blur
- void main() {
- #pragma mapbox: initialize highp vec4 fill_color
- #pragma mapbox: initialize highp vec4 halo_color
- #pragma mapbox: initialize lowp float opacity
- #pragma mapbox: initialize lowp float halo_width
- #pragma mapbox: initialize lowp float halo_blur
- vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);
- #ifdef PROJECTION_GLOBE_VIEW
- vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchor_z)+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
- #else
- vec3 world_pos=vec3(a_pos,anchor_z)+h;float globe_occlusion_fade=1.0;
- #endif
- vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
- camera_to_anchor_distance/u_camera_to_center_distance :
- u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
- 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point=u_matrix*vec4(a_pos+vec2(1,0),anchor_z,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}
- #ifdef PROJECTION_GLOBE_VIEW
- vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);
- #else
- vec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);
- #endif
- #ifdef PROJECTED_POS_ON_VIEWPORT
- vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);
- #else
- vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);
- #endif
- highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);
- #ifdef PITCH_WITH_MAP_TERRAIN
- vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
- #endif
- float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;float projection_transition_fade=1.0;
- #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
- projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
- #endif
- vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}`),symbolTextAndIcon:yn(`#define SDF_PX 8.0
- #define SDF 1.0
- #define ICON 0.0
- uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;
- #pragma mapbox: define highp vec4 fill_color
- #pragma mapbox: define highp vec4 halo_color
- #pragma mapbox: define lowp float opacity
- #pragma mapbox: define lowp float halo_width
- #pragma mapbox: define lowp float halo_blur
- void main() {
- #pragma mapbox: initialize highp vec4 fill_color
- #pragma mapbox: initialize highp vec4 halo_color
- #pragma mapbox: initialize lowp float opacity
- #pragma mapbox: initialize lowp float halo_width
- #pragma mapbox: initialize lowp float halo_blur
- float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;
- #ifdef PROJECTION_GLOBE_VIEW
- uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
- #endif
- varying vec4 v_data0;varying vec4 v_data1;
- #pragma mapbox: define highp vec4 fill_color
- #pragma mapbox: define highp vec4 halo_color
- #pragma mapbox: define lowp float opacity
- #pragma mapbox: define lowp float halo_width
- #pragma mapbox: define lowp float halo_blur
- void main() {
- #pragma mapbox: initialize highp vec4 fill_color
- #pragma mapbox: initialize highp vec4 halo_color
- #pragma mapbox: initialize lowp float opacity
- #pragma mapbox: initialize lowp float halo_width
- #pragma mapbox: initialize lowp float halo_blur
- vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);
- #ifdef PROJECTION_GLOBE_VIEW
- vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchor_z)+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
- #else
- vec3 world_pos=vec3(a_pos,anchor_z)+h;float globe_occlusion_fade=1.0;
- #endif
- vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
- camera_to_anchor_distance/u_camera_to_center_distance :
- u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
- 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),anchor_z,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}
- #ifdef PROJECTION_GLOBE_VIEW
- vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);
- #else
- vec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);
- #endif
- #ifdef PROJECTED_POS_ON_VIEWPORT
- vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);
- #else
- vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);
- #endif
- highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);
- #ifdef PITCH_WITH_MAP_TERRAIN
- vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
- #endif
- float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;
- #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
- projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
- #endif
- v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}`),terrainRaster:yn(`uniform sampler2D u_image0;varying vec2 v_pos0;
- #ifdef FOG
- varying float v_fog_opacity;
- #endif
- void main() {vec4 color=texture2D(u_image0,v_pos0);
- #ifdef FOG
- color=fog_dither(fog_apply_from_vert(color,v_fog_opacity));
- #endif
- gl_FragColor=color;
- #ifdef TERRAIN_WIREFRAME
- gl_FragColor=vec4(1.0,0.0,0.0,0.8);
- #endif
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;
- #ifdef FOG
- varying float v_fog_opacity;
- #endif
- const float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;
- #ifdef TERRAIN_WIREFRAME
- elevation+=u_skirt_height*u_skirt_height*wireframeOffset;
- #endif
- vec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);
- #ifdef FOG
- v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));
- #endif
- }`),terrainDepth:yn(`#ifdef GL_ES
- precision highp float;
- #endif
- varying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}`,"uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:yn(`
- varying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(
- cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;
- #ifdef FOG
- sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);
- #endif
- sky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,Ml),skyboxGradient:yn(`varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));
- #ifdef FOG
- color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;
- #endif
- color*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,Ml),skyboxCapture:yn(`
- varying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;
- #ifdef GL_ES
- precision highp float;
- #endif
- #define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)
- #define BETA_M vec3(21e-6,21e-6,21e-6)
- #define MIE_G 0.76
- #define DENSITY_HEIGHT_SCALE_R 8000.0
- #define DENSITY_HEIGHT_SCALE_M 1200.0
- #define PLANET_RADIUS 6360e3
- #define ATMOSPHERE_RADIUS 6420e3
- #define SAMPLE_STEPS 10
- #define DENSITY_STEPS 4
- float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}`,"attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:yn(`uniform sampler2D u_image0;varying vec2 v_pos0;void main() {gl_FragColor=texture2D(u_image0,v_pos0);
- #ifdef TERRAIN_WIREFRAME
- gl_FragColor=vec4(1.0,0.0,0.0,0.8);
- #endif
- #ifdef OVERDRAW_INSPECTOR
- gl_FragColor=vec4(1.0);
- #endif
- }`,`uniform mat4 u_proj_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;
- #ifdef GLOBE_POLES
- attribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;
- #else
- attribute vec2 a_pos;
- #endif
- varying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {
- #ifdef GLOBE_POLES
- vec3 globe_pos=a_globe_pos;vec2 merc_pos=a_merc_pos;vec2 uv=a_uv;
- #else
- float tiles=u_grid_matrix[0][2];float idy=u_grid_matrix[1][2];float S=u_grid_matrix[2][2];vec3 latLng=u_grid_matrix*vec3(a_pos,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=a_pos[0]*S;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);
- #endif
- v_pos0=uv;uv=uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);
- #ifdef TERRAIN_WIREFRAME
- height+=wireframeOffset;
- #endif
- vec4 globe=u_globe_matrix*vec4(globe_pos+up_vector.xyz*height,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);}`),globeAtmosphere:yn(`uniform float u_opacity;uniform highp float u_fadeout_range;uniform vec3 u_start_color;uniform vec3 u_end_color;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;varying highp vec3 v_ray_dir;void main() {highp vec3 dir=normalize(v_ray_dir);highp vec3 closest_point=abs(dot(u_globe_pos,dir))*dir;float norm_dist_from_center=length(closest_point-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 1.0)
- discard;float t=clamp(1.0-sqrt(norm_dist_from_center-1.0)/u_fadeout_range,0.0,1.0);vec3 color=mix(u_start_color,u_end_color,1.0-t);gl_FragColor=vec4(color*t*u_opacity,u_opacity);}`,"attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;varying highp vec3 v_ray_dir;void main() {v_ray_dir=mix(mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);gl_Position=vec4(a_pos,1.0);}")};function yn(m,o,d){const y=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,E=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,C=o.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),S=m.match(E),k=o.match(E),O=wl.match(E);let U=k?k.concat(S):S;d||(Ua.staticUniforms&&(U=Ua.staticUniforms.concat(U)),oa.staticUniforms&&(U=oa.staticUniforms.concat(U))),U&&(U=U.concat(O));const G={};return{fragmentSource:m=m.replace(y,(Z,se,de,ce,te)=>(G[te]=!0,se==="define"?`
- #ifndef HAS_UNIFORM_u_${te}
- varying ${de} ${ce} ${te};
- #else
- uniform ${de} ${ce} u_${te};
- #endif
- `:`
- #ifdef HAS_UNIFORM_u_${te}
- ${de} ${ce} ${te} = u_${te};
- #endif
- `)),vertexSource:o=o.replace(y,(Z,se,de,ce,te)=>{const Le=ce==="float"?"vec2":"vec4",ve=te.match(/color/)?"color":Le;return G[te]?se==="define"?`
- #ifndef HAS_UNIFORM_u_${te}
- uniform lowp float u_${te}_t;
- attribute ${de} ${Le} a_${te};
- varying ${de} ${ce} ${te};
- #else
- uniform ${de} ${ce} u_${te};
- #endif
- `:ve==="vec4"?`
- #ifndef HAS_UNIFORM_u_${te}
- ${te} = a_${te};
- #else
- ${de} ${ce} ${te} = u_${te};
- #endif
- `:`
- #ifndef HAS_UNIFORM_u_${te}
- ${te} = unpack_mix_${ve}(a_${te}, u_${te}_t);
- #else
- ${de} ${ce} ${te} = u_${te};
- #endif
- `:se==="define"?`
- #ifndef HAS_UNIFORM_u_${te}
- uniform lowp float u_${te}_t;
- attribute ${de} ${Le} a_${te};
- #else
- uniform ${de} ${ce} u_${te};
- #endif
- `:ve==="vec4"?`
- #ifndef HAS_UNIFORM_u_${te}
- ${de} ${ce} ${te} = a_${te};
- #else
- ${de} ${ce} ${te} = u_${te};
- #endif
- `:`
- #ifndef HAS_UNIFORM_u_${te}
- ${de} ${ce} ${te} = unpack_mix_${ve}(a_${te}, u_${te}_t);
- #else
- ${de} ${ce} ${te} = u_${te};
- #endif
- `}),staticAttributes:C,staticUniforms:U}}class _u{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(o,d,y,E,C,S,k,O){this.context=o;let U=this.boundPaintVertexBuffers.length!==E.length;for(let G=0;!U&&G<E.length;G++)this.boundPaintVertexBuffers[G]!==E[G]&&(U=!0);o.extVertexArrayObject&&this.vao&&this.boundProgram===d&&this.boundLayoutVertexBuffer===y&&!U&&this.boundIndexBuffer===C&&this.boundVertexOffset===S&&this.boundDynamicVertexBuffer===k&&this.boundDynamicVertexBuffer2===O?(o.bindVertexArrayOES.set(this.vao),k&&k.bind(),C&&C.dynamicDraw&&C.bind(),O&&O.bind()):this.freshBind(d,y,E,C,S,k,O)}freshBind(o,d,y,E,C,S,k){let O;const U=o.numAttributes,G=this.context,Z=G.gl;if(G.extVertexArrayObject)this.vao&&this.destroy(),this.vao=G.extVertexArrayObject.createVertexArrayOES(),G.bindVertexArrayOES.set(this.vao),O=0,this.boundProgram=o,this.boundLayoutVertexBuffer=d,this.boundPaintVertexBuffers=y,this.boundIndexBuffer=E,this.boundVertexOffset=C,this.boundDynamicVertexBuffer=S,this.boundDynamicVertexBuffer2=k;else{O=G.currentNumAttributes||0;for(let se=U;se<O;se++)Z.disableVertexAttribArray(se)}d.enableAttributes(Z,o);for(const se of y)se.enableAttributes(Z,o);S&&S.enableAttributes(Z,o),k&&k.enableAttributes(Z,o),d.bind(),d.setVertexAttribPointers(Z,o,C);for(const se of y)se.bind(),se.setVertexAttribPointers(Z,o,C);S&&(S.bind(),S.setVertexAttribPointers(Z,o,C)),E&&E.bind(),k&&(k.bind(),k.setVertexAttribPointers(Z,o,C)),G.currentNumAttributes=U}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function Om(m,o){const d=Math.pow(2,o.canonical.z),y=o.canonical.y;return[new r.MercatorCoordinate(0,y/d).toLngLat().lat,new r.MercatorCoordinate(0,(y+1)/d).toLngLat().lat]}function Nm(m,o,d,y,E,C,S){const k=m.context,O=k.gl,U=d.fbo;if(!U)return;m.prepareDrawTile();const G=m.useProgram("hillshade");k.activeTexture.set(O.TEXTURE0),O.bindTexture(O.TEXTURE_2D,U.colorAttachment.get());const Z=((te,Le,ve,De)=>{const Se=ve.paint.get("hillshade-shadow-color"),ze=ve.paint.get("hillshade-highlight-color"),Ee=ve.paint.get("hillshade-accent-color");let Ue=ve.paint.get("hillshade-illumination-direction")*(Math.PI/180);ve.paint.get("hillshade-illumination-anchor")==="viewport"&&(Ue-=te.transform.angle);const nt=!te.options.moving;return{u_matrix:De||te.transform.calculateProjMatrix(Le.tileID.toUnwrapped(),nt),u_image:0,u_latrange:Om(0,Le.tileID),u_light:[ve.paint.get("hillshade-exaggeration"),Ue],u_shadow:Se,u_highlight:ze,u_accent:Ee}})(m,d,y,m.terrain?o.projMatrix:null);m.prepareDrawProgram(k,G,o.toUnwrapped());const{tileBoundsBuffer:se,tileBoundsIndexBuffer:de,tileBoundsSegments:ce}=m.getTileBoundsBuffers(d);G.draw(k,O.TRIANGLES,E,C,S,r.CullFaceMode.disabled,Z,y.id,se,de,ce)}function Ld(m,o,d){if(!o.needsDEMTextureUpload)return;const y=m.context,E=y.gl;y.pixelStoreUnpackPremultiplyAlpha.set(!1),o.demTexture=o.demTexture||m.getTileTexture(d.stride);const C=d.getPixels();o.demTexture?o.demTexture.update(C,{premultiply:!1}):o.demTexture=new r.Texture(y,C,E.RGBA,{premultiply:!1}),o.needsDEMTextureUpload=!1}function Id(m,o,d,y,E,C){const S=m.context,k=S.gl;if(!o.dem)return;const O=o.dem;if(S.activeTexture.set(k.TEXTURE1),Ld(m,o,O),!o.demTexture)return;o.demTexture.bind(k.NEAREST,k.CLAMP_TO_EDGE);const U=O.dim;S.activeTexture.set(k.TEXTURE0);let G=o.fbo;if(!G){const ce=new r.Texture(S,{width:U,height:U,data:null},k.RGBA);ce.bind(k.LINEAR,k.CLAMP_TO_EDGE),G=o.fbo=S.createFramebuffer(U,U,!0),G.colorAttachment.set(ce.texture)}S.bindFramebuffer.set(G.framebuffer),S.viewport.set([0,0,U,U]);const{tileBoundsBuffer:Z,tileBoundsIndexBuffer:se,tileBoundsSegments:de}=m.getMercatorTileBoundsBuffers();m.useProgram("hillshadePrepare").draw(S,k.TRIANGLES,y,E,C,r.CullFaceMode.disabled,((ce,te)=>{const Le=te.stride,ve=r.create();return r.ortho(ve,0,r.EXTENT,-r.EXTENT,0,0,1),r.translate(ve,ve,[0,-r.EXTENT,0]),{u_matrix:ve,u_image:1,u_dimension:[Le,Le],u_zoom:ce.overscaledZ,u_unpack:te.unpackVector}})(o.tileID,O),d.id,Z,se,de),o.needsHillshadePrepare=!1}const Rd=(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_image0:new r.Uniform1i(m,o.u_image0),u_skirt_height:new r.Uniform1f(m,o.u_skirt_height)}),Um=(m,o)=>({u_matrix:m,u_image0:0,u_skirt_height:o}),Vm=(m,o,d,y,E,C)=>({u_proj_matrix:Float32Array.from(m),u_globe_matrix:o,u_merc_matrix:d,u_zoom_transition:y,u_merc_center:E,u_image0:0,u_grid_matrix:C?Float32Array.from(C):new Float32Array(9)});function vu(m,o){return m!=null&&o!=null&&!(!m.hasData()||!o.hasData())&&m.demTexture!=null&&o.demTexture!=null&&m.tileID.key!==o.tileID.key}const aa=new class{constructor(){this.operations={}}newMorphing(m,o,d,y,E){if(m in this.operations){const C=this.operations[m];C.to.tileID.key!==d.tileID.key&&(C.queued=d)}else this.operations[m]={startTime:y,phase:0,duration:E,from:o,to:d,queued:null}}getMorphValuesForProxy(m){if(!(m in this.operations))return null;const o=this.operations[m];return{from:o.from,to:o.to,phase:o.phase}}update(m){for(const o in this.operations){const d=this.operations[o];for(d.phase=(m-d.startTime)/d.duration;d.phase>=1||!this._validOp(d);)if(!this._nextOp(d,m)){delete this.operations[o];break}}}_nextOp(m,o){return!!m.queued&&(m.from=m.to,m.to=m.queued,m.queued=null,m.phase=0,m.startTime=o,!0)}_validOp(m){return m.from.hasData()&&m.to.hasData()}},Es={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function kd(m,o){const d=1<<m.z;return!o&&(m.x===0||m.x===d-1)||m.y===0||m.y===d-1}const xu=m=>({u_matrix:m});function zd(m,o,d,y,E){if(E>0){const C=r.exported.now(),S=(C-m.timeAdded)/E,k=o?(C-o.timeAdded)/E:-1,O=d.getSource(),U=y.coveringZoomLevel({tileSize:O.tileSize,roundZoom:O.roundZoom}),G=!o||Math.abs(o.tileID.overscaledZ-U)>Math.abs(m.tileID.overscaledZ-U),Z=G&&m.refreshedUponExpiration?1:r.clamp(G?S:1-k,0,1);return m.refreshedUponExpiration&&S>=1&&(m.refreshedUponExpiration=!1),o?{opacity:1,mix:1-Z}:{opacity:Z,mix:0}}return{opacity:1,mix:0}}const K_=2*r.mercatorZfromAltitude(1,0)*r.GLOBE_RADIUS*Math.PI;class Cl extends r.SourceCache{constructor(o){const d={type:"raster-dem",maxzoom:o.transform.maxZoom},y=new be(Fe(),null),E=tt("mock-dem",d,y,o.style);super("mock-dem",E,!1),E.setEventedParent(this),this._sourceLoaded=!0}_loadTile(o,d){o.state="loaded",d(null)}}class Al extends r.SourceCache{constructor(o){const d=tt("proxy",{type:"geojson",maxzoom:o.transform.maxZoom},new be(Fe(),null),o.style);super("proxy",d,!1),d.setEventedParent(this),this.map=this.getSource().map=o,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(o,d,y){if(o.freezeTileCoverage)return;this.transform=o;const E=o.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((C,S)=>{if(C[S.key]="",!this._tiles[S.key]){const k=new r.Tile(S,this._source.tileSize*S.overscaleFactor(),o.tileZoom);k.state="loaded",this._tiles[S.key]=k}return C},{});for(const C in this._tiles)C in E||(this.freeFBO(C),this._tiles[C].unloadVectorData(),delete this._tiles[C])}freeFBO(o){const d=this.proxyCachedFBO[o];if(d!==void 0){const y=Object.values(d);this.renderCachePool.push(...y),delete this.proxyCachedFBO[o]}}deallocRenderCache(){this.renderCache.forEach(o=>o.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Fd extends r.OverscaledTileID{constructor(o,d,y){super(o.overscaledZ,o.wrap,o.canonical.z,o.canonical.x,o.canonical.y),this.proxyTileKey=d,this.projMatrix=y}}class Lr extends r.Elevation{constructor(o,d){super(),this.painter=o,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[y,E,C]=function(O){const U=new r.StructArrayLayout4i8,G=new r.StructArrayLayout3ui6,Z=131;U.reserve(17161),G.reserve(33800);const se=r.EXTENT/128,de=r.EXTENT+se/2,ce=de+se;for(let Le=-se;Le<ce;Le+=se)for(let ve=-se;ve<ce;ve+=se){const De=ve<0||ve>de||Le<0||Le>de?24575:0,Se=r.clamp(Math.round(ve),0,r.EXTENT),ze=r.clamp(Math.round(Le),0,r.EXTENT);U.emplaceBack(Se+De,ze,Se,ze)}const te=(Le,ve)=>{const De=ve*Z+Le;G.emplaceBack(De+1,De,De+Z),G.emplaceBack(De+Z,De+Z+1,De+1)};for(let Le=1;Le<129;Le++)for(let ve=1;ve<129;ve++)te(ve,Le);return[0,129].forEach(Le=>{for(let ve=0;ve<130;ve++)te(ve,Le),te(Le,ve)}),[U,G,32768]}(),S=o.context;this.gridBuffer=S.createVertexBuffer(y,r.boundsAttributes.members),this.gridIndexBuffer=S.createIndexBuffer(E),this.gridSegments=r.SegmentVector.simpleSegment(0,0,y.length,E.length),this.gridNoSkirtSegments=r.SegmentVector.simpleSegment(0,0,y.length,C),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Al(d.map),this.orthoMatrix=r.create(),r.ortho(this.orthoMatrix,0,r.EXTENT,0,r.EXTENT,0,1);const k=S.gl;this._overlapStencilMode=new r.StencilMode({func:k.GEQUAL,mask:255},0,255,k.KEEP,k.KEEP,k.REPLACE),this._previousZoom=o.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=d,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Cl(d.map)}set style(o){o.on("data",this._onStyleDataEvent.bind(this)),o.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=o,this._checkRenderCacheEfficiency()}update(o,d,y){if(o&&o.terrain){this._style!==o&&(this.style=o),this.enabled=!0;const E=o.terrain.properties;this.sourceCache=o.terrain.drapeRenderMode===0?this._mockSourceCache:o._getSourceCache(E.get("source")),this._exaggeration=E.get("exaggeration");const C=()=>{this.sourceCache.used&&r.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.
- This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const S=this.getScaledDemTileSize();this.sourceCache.update(d,S,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,C(),this._initializing=!0),C(),d.updateElevation(!y),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(d),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(o){this._findCoveringTileCache[o]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const o=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||o.efficiency!==100&&r.warnOnce(`Terrain render cache efficiency is not optimal (${o.efficiency}%) and performance
- may be affected negatively, consider placing all background, fill and line layers before layer
- with id '${o.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(o){o.coord&&o.dataType==="source"?this._clearRenderCacheForTile(o.sourceCacheId,o.coord):o.dataType==="style"&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const o in this._style._sourceCaches)this._style._sourceCaches[o].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(o=>o.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const o=2*this.proxySourceCache.getSource().tileSize;return[o,o]}set useVertexMorphing(o){this._useVertexMorphing=o}updateTileBinding(o){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const d=this.proxySourceCache,y=this.painter.transform;this._initializing&&(this._initializing=y._centerAltitude===0&&this.getAtPointOrZero(r.MercatorCoordinate.fromLngLat(y.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const E=this.proxyCoords=d.getIds().map(O=>{const U=d.getTileByID(O).tileID;return U.projMatrix=y.calculateProjMatrix(U.toUnwrapped()),U});(function(O,U){const G=U.transform.pointCoordinate(U.transform.getCameraPoint()),Z=new r.pointGeometry(G.x,G.y);O.sort((se,de)=>{if(de.overscaledZ-se.overscaledZ)return de.overscaledZ-se.overscaledZ;const ce=new r.pointGeometry(se.canonical.x+(1<<se.canonical.z)*se.wrap,se.canonical.y),te=new r.pointGeometry(de.canonical.x+(1<<de.canonical.z)*de.wrap,de.canonical.y),Le=Z.mult(1<<se.canonical.z);return Le.x-=.5,Le.y-=.5,Le.distSqr(ce)-Le.distSqr(te)})})(E,this.painter),this._previousZoom=y.zoom;const C=this.proxyToSource||{};this.proxyToSource={},E.forEach(O=>{this.proxyToSource[O.key]={}}),this.terrainTileForTile={};const S=this._style._sourceCaches;for(const O in S){const U=S[O];if(!U.used||(U!==this.sourceCache&&this.resetTileLookupCache(U.id),this._setupProxiedCoordsForOrtho(U,o[O],C),U.usedForTerrain))continue;const G=o[O];U.getSource().reparseOverscaled&&this._assignTerrainTiles(G)}this.proxiedCoords[d.id]=E.map(O=>new Fd(O,O.key,this.orthoMatrix)),this._assignTerrainTiles(E),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(C),this.renderingToTexture=!1,this._updateTimestamp=r.exported.now();const k={};this._visibleDemTiles=[];for(const O of this.proxyCoords){const U=this.terrainTileForTile[O.key];if(!U)continue;const G=U.tileID.key;G in k||(this._visibleDemTiles.push(U),k[G]=G)}}_assignTerrainTiles(o){this._initializing||o.forEach(d=>{if(this.terrainTileForTile[d.key])return;const y=this._findTileCoveringTileID(d,this.sourceCache);y&&(this.terrainTileForTile[d.key]=y)})}_prepareDEMTextures(){const o=this.painter.context,d=o.gl;for(const y in this.terrainTileForTile){const E=this.terrainTileForTile[y],C=E.dem;!C||E.demTexture&&!E.needsDEMTextureUpload||(o.activeTexture.set(d.TEXTURE1),Ld(this.painter,E,C))}}_prepareDemTileUniforms(o,d,y,E){if(!d||d.demTexture==null)return!1;const C=o.tileID.canonical,S=Math.pow(2,d.tileID.canonical.z-C.z),k=E||"";return y[`u_dem_tl${k}`]=[C.x*S%1,C.y*S%1],y[`u_dem_scale${k}`]=S,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const o=this.painter.context,d=o.gl;if(!this._emptyDepthBufferTexture){const y=new r.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new r.Texture(o,y,d.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let o=0;const d=this._visibleDemTiles.reduce((y,E)=>{if(!E.dem)return y;const C=E.dem.tree.minimums[0];return C>0&&o++,y+C},0);return o?d/o:0}_updateEmptyDEMTexture(){const o=this.painter.context,d=o.gl;o.activeTexture.set(d.TEXTURE2);const y=this._getLoadedAreaMinimum(),E=new r.RGBAImage({width:1,height:1},new Uint8Array(r.DEMData.pack(y,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let C=this._emptyDEMTexture;return C?C.update(E,{premultiply:!1}):C=this._emptyDEMTexture=new r.Texture(o,E,d.RGBA,{premultiply:!1}),C}setupElevationDraw(o,d,y){const E=this.painter.context,C=E.gl,S=(k=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:r.DEMData.getUnpackVector(k),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0,u_tile_tl_up:[0,0,1],u_tile_tr_up:[0,0,1],u_tile_br_up:[0,0,1],u_tile_bl_up:[0,0,1],u_tile_up_scale:1});var k;S.u_dem_size=this.sourceCache.getSource().tileSize,S.u_exaggeration=this.exaggeration();const O=this.painter.transform,U=O.projection,G=o.tileID.canonical;S.u_tile_tl_up=U.upVector(G,0,0),S.u_tile_tr_up=U.upVector(G,r.EXTENT,0),S.u_tile_br_up=U.upVector(G,r.EXTENT,r.EXTENT),S.u_tile_bl_up=U.upVector(G,0,r.EXTENT),S.u_tile_up_scale=y&&y.useDenormalizedUpVectorScale?K_:U.upVectorScale(G,O.center.lat,O.worldSize).metersToTile;let Z=null,se=null,de=1;if(y&&y.morphing&&this._useVertexMorphing){const ce=y.morphing.srcDemTile,te=y.morphing.dstDemTile;de=y.morphing.phase,ce&&te&&(this._prepareDemTileUniforms(o,ce,S,"_prev")&&(se=ce),this._prepareDemTileUniforms(o,te,S)&&(Z=te))}if(se&&Z?(E.activeTexture.set(C.TEXTURE2),Z.demTexture.bind(C.NEAREST,C.CLAMP_TO_EDGE,C.NEAREST),E.activeTexture.set(C.TEXTURE4),se.demTexture.bind(C.NEAREST,C.CLAMP_TO_EDGE,C.NEAREST),S.u_dem_lerp=de):(Z=this.terrainTileForTile[o.tileID.key],E.activeTexture.set(C.TEXTURE2),(this._prepareDemTileUniforms(o,Z,S)?Z.demTexture:this.emptyDEMTexture).bind(C.NEAREST,C.CLAMP_TO_EDGE)),E.activeTexture.set(C.TEXTURE3),y&&y.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(C.NEAREST,C.CLAMP_TO_EDGE),this._depthFBO&&(S.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(C.NEAREST,C.CLAMP_TO_EDGE),S.u_depth_size_inv=[1,1]),y&&y.useMeterToDem&&Z){const ce=(1<<Z.tileID.canonical.z)*r.mercatorZfromAltitude(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;S.u_meter_to_dem=ce}y&&y.labelPlaneMatrixInv&&(S.u_label_plane_matrix_inv=y.labelPlaneMatrixInv),d.setTerrainUniformValues(E,S)}renderToBackBuffer(o){const d=this.painter,y=this.painter.context;o.length!==0&&(y.bindFramebuffer.set(null),y.viewport.set([0,0,d.width,d.height]),this.renderingToTexture=!1,function(E,C,S,k,O){if(E.transform.projection.name==="globe")(function(U,G,Z,se,de){const ce=U.context,te=ce.gl;let Le,ve;const De=U.options.showTerrainWireframe?2:0,Se=(ht,kt)=>{if(ve===ht)return;const it=[Es[ht],"PROJECTION_GLOBE_VIEW"];kt&&it.push(Es[De]),Le=U.useProgram("globeRaster",null,it),ve=ht},ze=U.colorModeForRenderPass(),Ee=new r.DepthMode(te.LEQUAL,r.DepthMode.ReadWrite,U.depthRangeFor3D);aa.update(de);const Ue=U.transform,nt=r.calculateGlobeMercatorMatrix(Ue),lt=[r.mercatorXfromLng(Ue.center.lng),r.mercatorYfromLat(Ue.center.lat)],pt=U.globeSharedBuffers;if((De?[!1,!0]:[!1]).forEach(ht=>{ve=-1;const kt=ht?te.LINES:te.TRIANGLES;for(const it of se){const zt=Z.getTile(it),St=r.StencilMode.disabled,Jt=G.prevTerrainTileForTile[it.key],ft=G.terrainTileForTile[it.key];vu(Jt,ft)&&aa.newMorphing(it.key,Jt,ft,de,250),ce.activeTexture.set(te.TEXTURE0),zt.texture.bind(te.LINEAR,te.CLAMP_TO_EDGE);const qt=aa.getMorphValuesForProxy(it.key),gn=qt?1:0,Zt={useDenormalizedUpVectorScale:!0};qt&&r.extend$1(Zt,{morphing:{srcDemTile:qt.from,dstDemTile:qt.to,phase:r.easeCubicInOut(qt.phase)}});const Yt=Float32Array.from(Ue.globeMatrix),xn=r.globeTileLatLngCorners(it.canonical),zn=r.getGridMatrix(it.canonical,xn),dn=Vm(Ue.projMatrix,Yt,nt,r.globeToMercatorTransition(Ue.zoom),lt,zn);if(Se(gn,ht),G.setupElevationDraw(zt,Le,Zt),U.prepareDrawProgram(ce,Le,it.toUnwrapped()),pt){const[Mn,$n,vi]=ht?pt.getWirefameBuffers(U.context):pt.getGridBuffers();Le.draw(ce,kt,Ee,St,ze,r.CullFaceMode.backCCW,dn,"globe_raster",Mn,$n,vi)}}}),pt){Le=U.useProgram("globeRaster",null,["GLOBE_POLES","PROJECTION_GLOBE_VIEW"]);for(const ht of se){const{x:kt,y:it,z:zt}=ht.canonical,St=it===0,Jt=it===(1<<zt)-1,[ft,qt,gn,Zt]=pt.getPoleBuffers(zt);if(Zt&&(St||Jt)){const Yt=Z.getTile(ht);ce.activeTexture.set(te.TEXTURE0),Yt.texture.bind(te.LINEAR,te.CLAMP_TO_EDGE);let xn=r.globePoleMatrixForTile(zt,kt,Ue);const zn=(dn,Mn)=>dn.draw(ce,te.TRIANGLES,Ee,r.StencilMode.disabled,ze,r.CullFaceMode.disabled,Vm(Ue.projMatrix,xn,xn,0,lt),"globe_pole_raster",Mn,gn,Zt);G.setupElevationDraw(Yt,Le,{}),U.prepareDrawProgram(ce,Le,ht.toUnwrapped()),St&&zn(Le,ft),Jt&&(xn=r.scale(r.create(),xn,[1,-1,1]),zn(Le,qt))}}}})(E,C,S,k,O);else{const U=E.context,G=U.gl;let Z,se;const de=E.options.showTerrainWireframe?2:0,ce=(Se,ze)=>{if(se===Se)return;const Ee=[Es[Se]];ze&&Ee.push(Es[de]),Z=E.useProgram("terrainRaster",null,Ee),se=Se},te=E.colorModeForRenderPass(),Le=new r.DepthMode(G.LEQUAL,r.DepthMode.ReadWrite,E.depthRangeFor3D);aa.update(O);const ve=E.transform,De=6*Math.pow(1.5,22-ve.zoom)*C.exaggeration();(de?[!1,!0]:[!1]).forEach(Se=>{se=-1;const ze=Se?G.LINES:G.TRIANGLES,[Ee,Ue]=Se?C.getWirefameBuffer():[C.gridIndexBuffer,C.gridSegments];for(const nt of k){const lt=S.getTile(nt),pt=r.StencilMode.disabled,ht=C.prevTerrainTileForTile[nt.key],kt=C.terrainTileForTile[nt.key];vu(ht,kt)&&aa.newMorphing(nt.key,ht,kt,O,250),U.activeTexture.set(G.TEXTURE0),lt.texture.bind(G.LINEAR,G.CLAMP_TO_EDGE,G.LINEAR_MIPMAP_NEAREST);const it=aa.getMorphValuesForProxy(nt.key),zt=it?1:0;let St;it&&(St={morphing:{srcDemTile:it.from,dstDemTile:it.to,phase:r.easeCubicInOut(it.phase)}});const Jt=Um(nt.projMatrix,kd(nt.canonical,ve.renderWorldCopies)?De/10:De);ce(zt,Se),C.setupElevationDraw(lt,Z,St),E.prepareDrawProgram(U,Z,nt.toUnwrapped()),Z.draw(U,ze,Le,pt,te,r.CullFaceMode.backCCW,Jt,"terrain_raster",C.gridBuffer,Ee,Ue)}})}}(d,this,this.proxySourceCache,o,this._updateTimestamp),this.renderingToTexture=!0,o.splice(0,o.length))}renderBatch(o){if(this._drapedRenderBatches.length===0)return o+1;this.renderingToTexture=!0;const d=this.painter,y=this.painter.context,E=this.proxySourceCache,C=this.proxiedCoords[E.id],S=this._drapedRenderBatches.shift(),k=[],O=d.style.order;let U=0;for(const G of C){const Z=E.getTileByID(G.proxyTileKey),se=E.proxyCachedFBO[G.key]?E.proxyCachedFBO[G.key][o]:void 0,de=se!==void 0?E.renderCache[se]:this.pool[U++],ce=se!==void 0;if(Z.texture=de.tex,ce&&!de.dirty){k.push(Z.tileID);continue}let te;y.bindFramebuffer.set(de.fb.framebuffer),this.renderedToTile=!1,de.dirty&&(y.clear({color:r.Color.transparent,stencil:0}),de.dirty=!1);for(let Le=S.start;Le<=S.end;++Le){const ve=d.style._layers[O[Le]];if(ve.isHidden(d.transform.zoom))continue;const De=d.style._getLayerSourceCache(ve),Se=De?this.proxyToSource[G.key][De.id]:[G];if(!Se)continue;const ze=Se;y.viewport.set([0,0,de.fb.width,de.fb.height]),te!==(De?De.id:null)&&(this._setupStencil(de,Se,ve,De),te=De?De.id:null),d.renderLayer(d,De,ve,ze)}this.renderedToTile?(de.dirty=!0,k.push(Z.tileID)):ce||--U,U===5&&(U=0,this.renderToBackBuffer(k))}return this.renderToBackBuffer(k),this.renderingToTexture=!1,y.bindFramebuffer.set(null),y.viewport.set([0,0,d.width,d.height]),S.end+1}postRender(){}renderCacheEfficiency(o){const d=o.order.length;if(d===0)return{efficiency:100};let y,E=0,C=0,S=!1;for(let k=0;k<d;++k){const O=o._layers[o.order[k]];this._style.isLayerDraped(O)?(S&&++E,++C):S||(S=!0,y=O.id)}return C===0?{efficiency:100}:{efficiency:100*(1-E/C),firstUndrapedLayer:y}}getMinElevationBelowMSL(){let o=0;return this._visibleDemTiles.filter(d=>d.dem).forEach(d=>{o=Math.min(o,d.dem.tree.minimums[0])}),o===0?o:(o-30)*this._exaggeration}raycast(o,d,y){if(!this._visibleDemTiles)return null;const E=this._visibleDemTiles.filter(C=>C.dem).map(C=>{const S=C.tileID,k=Math.pow(2,S.overscaledZ),{x:O,y:U}=S.canonical,G=O/k,Z=(O+1)/k,se=U/k,de=(U+1)/k;return{minx:G,miny:se,maxx:Z,maxy:de,t:C.dem.tree.raycastRoot(G,se,Z,de,o,d,y),tile:C}});E.sort((C,S)=>(C.t!==null?C.t:Number.MAX_VALUE)-(S.t!==null?S.t:Number.MAX_VALUE));for(const C of E){if(C.t==null)return null;const S=C.tile.dem.tree.raycast(C.minx,C.miny,C.maxx,C.maxy,o,d,y);if(S!=null)return S}return null}_createFBO(){const o=this.painter.context,d=o.gl,y=this.drapeBufferSize;o.activeTexture.set(d.TEXTURE0);const E=new r.Texture(o,{width:y[0],height:y[1],data:null},d.RGBA);E.bind(d.LINEAR,d.CLAMP_TO_EDGE);const C=o.createFramebuffer(y[0],y[1],!1);return C.colorAttachment.set(E.texture),C.depthAttachment=new Ar(o,C.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=o.createRenderbuffer(o.gl.DEPTH_STENCIL,y[0],y[1]),this._stencilRef=0,C.depthAttachment.set(this._sharedDepthStencil),o.clear({stencil:0})):C.depthAttachment.set(this._sharedDepthStencil),o.extTextureFilterAnisotropic&&!o.extTextureFilterAnisotropicForceOff&&d.texParameterf(d.TEXTURE_2D,o.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,o.extTextureFilterAnisotropicMax),{fb:C,tex:E,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.light&&this._style.light.hasTransition())return!0;for(const o in this._style._sourceCaches)if(this._style._sourceCaches[o].hasTransition())return!0;return this._style.order.some(o=>{const d=this._style._layers[o],y=d.isHidden(this.painter.transform.zoom),E=d.getCrossfadeParameters(),C=!!E&&E.t!==1,S=d.hasTransition();return d.type!=="custom"&&!y&&(C||S)})}_clearRasterFadeFromRenderCache(){let o=!1;for(const d in this._style._sourceCaches)if(this._style._sourceCaches[d]._source instanceof ee){o=!0;break}if(o)for(let d=0;d<this._style.order.length;++d){const y=this._style._layers[this._style.order[d]],E=y.isHidden(this.painter.transform.zoom),C=this._style._getLayerSourceCache(y);if(y.type!=="raster"||E||!C)continue;const S=y.paint.get("raster-fade-duration");for(const k of this.proxyCoords){const O=this.proxyToSource[k.key][C.id];if(O)for(const U of O){const G=zd(C.getTile(U),C.findLoadedParent(U,0),C,this.painter.transform,S);(G.opacity!==1||G.mix!==0)&&this._clearRenderCacheForTile(C.id,U)}}}}_setupDrapedRenderBatches(){const o=this._style.order,d=o.length;if(d===0)return;const y=[];let E,C=0,S=this._style._layers[o[C]];for(;!this._style.isLayerDraped(S)&&S.isHidden(this.painter.transform.zoom)&&++C<d;)S=this._style._layers[o[C]];for(;C<d;++C){const k=this._style._layers[o[C]];k.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(k)?E===void 0&&(E=C):E!==void 0&&(y.push({start:E,end:C-1}),E=void 0))}E!==void 0&&y.push({start:E,end:C-1}),this._drapedRenderBatches=y}_setupRenderCache(o){const d=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,d.renderCache.length>d.renderCachePool.length){const S=Object.values(d.proxyCachedFBO);d.proxyCachedFBO={};for(let k=0;k<S.length;++k){const O=Object.values(S[k]);d.renderCachePool.push(...O)}}return}this._clearRasterFadeFromRenderCache();const y=this.proxyCoords,E=this._tilesDirty;for(let S=y.length-1;S>=0;S--){const k=y[S];if(d.getTileByID(k.key),d.proxyCachedFBO[k.key]!==void 0){const O=o[k.key],U=this.proxyToSource[k.key];let G=0;for(const Z in U){const se=U[Z],de=O[Z];if(!de||de.length!==se.length||se.some((ce,te)=>ce!==de[te]||E[Z]&&E[Z].hasOwnProperty(ce.key))){G=-1;break}++G}for(const Z in d.proxyCachedFBO[k.key])d.renderCache[d.proxyCachedFBO[k.key][Z]].dirty=G<0||G!==Object.values(O).length}}const C=[...this._drapedRenderBatches];C.sort((S,k)=>k.end-k.start-(S.end-S.start));for(const S of C)for(const k of y){if(d.proxyCachedFBO[k.key])continue;let O=d.renderCachePool.pop();O===void 0&&d.renderCache.length<50&&(O=d.renderCache.length,d.renderCache.push(this._createFBO())),O!==void 0&&(d.proxyCachedFBO[k.key]={},d.proxyCachedFBO[k.key][S.start]=O,d.renderCache[O].dirty=!0)}this._tilesDirty={}}_setupStencil(o,d,y,E){if(!E||!this._sourceTilesOverlap[E.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const C=this.painter.context,S=C.gl;if(d.length<=1)return void(this._overlapStencilType=!1);let k;if(y.isTileClipped())k=d.length,this._overlapStencilMode.test={func:S.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(d[0].overscaledZ>d[d.length-1].overscaledZ))return void(this._overlapStencilType=!1);k=1,this._overlapStencilMode.test={func:S.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+k>255&&(C.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=k,this._overlapStencilMode.ref=this._stencilRef,y.isTileClipped()&&this._renderTileClippingMasks(d,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(o){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs.get(o.key)||0),this._overlapStencilMode):r.StencilMode.disabled}_renderTileClippingMasks(o,d){const y=this.painter,E=this.painter.context,C=E.gl;y._tileClippingMaskIDs.clear(),E.setColorMode(r.ColorMode.disabled),E.setDepthMode(r.DepthMode.disabled);const S=y.useProgram("clippingMask");for(const k of o){const O=--d;y._tileClippingMaskIDs.set(k.key,O),S.draw(E,C.TRIANGLES,r.DepthMode.disabled,new r.StencilMode({func:C.ALWAYS,mask:0},O,255,C.KEEP,C.KEEP,C.REPLACE),r.ColorMode.disabled,r.CullFaceMode.disabled,xu(k.projMatrix),"$clipping",y.tileExtentBuffer,y.quadTriangleIndexBuffer,y.tileExtentSegments)}}pointCoordinate(o){const d=this.painter.transform;if(o.x<0||o.x>d.width||o.y<0||o.y>d.height)return null;const y=[o.x,o.y,1,1];r.transformMat4$1(y,y,d.pixelMatrixInverse),r.scale$1(y,y,1/y[3]),y[0]/=d.worldSize,y[1]/=d.worldSize;const E=d._camera.position,C=r.mercatorZfromAltitude(1,d.center.lat),S=[E[0],E[1],E[2]/C,0],k=r.subtract([],y.slice(0,3),S);r.normalize(k,k);const O=this.raycast(S,k,this._exaggeration);return O!==null&&O?(r.scaleAndAdd(S,S,k,O),S[3]=S[2],S[2]*=C,S):null}drawDepth(){const o=this.painter,d=o.context,y=this.proxySourceCache,E=Math.ceil(o.width),C=Math.ceil(o.height);if(!this._depthFBO||this._depthFBO.width===E&&this._depthFBO.height===C||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const S=d.gl,k=d.createFramebuffer(E,C,!0);d.activeTexture.set(S.TEXTURE0);const O=new r.Texture(d,{width:E,height:C,data:null},S.RGBA);O.bind(S.NEAREST,S.CLAMP_TO_EDGE),k.colorAttachment.set(O.texture);const U=d.createRenderbuffer(d.gl.DEPTH_COMPONENT16,E,C);k.depthAttachment.set(U),this._depthFBO=k,this._depthTexture=O}d.bindFramebuffer.set(this._depthFBO.framebuffer),d.viewport.set([0,0,E,C]),function(S,k,O,U){if(S.transform.projection.name==="globe")return;const G=S.context,Z=G.gl;G.clear({depth:1});const se=S.useProgram("terrainDepth"),de=new r.DepthMode(Z.LESS,r.DepthMode.ReadWrite,S.depthRangeFor3D);for(const ce of U){const te=O.getTile(ce),Le=Um(ce.projMatrix,0);k.setupElevationDraw(te,se),se.draw(G,Z.TRIANGLES,de,r.StencilMode.disabled,r.ColorMode.unblended,r.CullFaceMode.backCCW,Le,"terrain_depth",k.gridBuffer,k.gridIndexBuffer,k.gridNoSkirtSegments)}}(o,this,y,this.proxyCoords)}_setupProxiedCoordsForOrtho(o,d,y){if(o.getSource()instanceof je)return this._setupProxiedCoordsForImageSource(o,d,y);this._findCoveringTileCache[o.id]=this._findCoveringTileCache[o.id]||{};const E=this.proxiedCoords[o.id]=[],C=this.proxyCoords;for(let k=0;k<C.length;k++){const O=C[k],U=this._findTileCoveringTileID(O,o);if(U){const G=this._createProxiedId(O,U,y[O.key]&&y[O.key][o.id]);E.push(G),this.proxyToSource[O.key][o.id]=[G]}}let S=!1;for(let k=0;k<d.length;k++){const O=o.getTile(d[k]);if(!O||!O.hasData())continue;const U=this._findTileCoveringTileID(O.tileID,this.proxySourceCache);if(U&&U.tileID.canonical.z!==O.tileID.canonical.z){const G=this.proxyToSource[U.tileID.key][o.id],Z=this._createProxiedId(U.tileID,O,y[U.tileID.key]&&y[U.tileID.key][o.id]);G?G.splice(G.length-1,0,Z):this.proxyToSource[U.tileID.key][o.id]=[Z],E.push(Z),S=!0}}this._sourceTilesOverlap[o.id]=S}_setupProxiedCoordsForImageSource(o,d,y){if(!o.getSource().loaded())return;const E=this.proxiedCoords[o.id]=[],C=this.proxyCoords,S=o.getSource(),k=new r.pointGeometry(S.tileID.x,S.tileID.y)._div(1<<S.tileID.z),O=S.coordinates.map(r.MercatorCoordinate.fromLngLat).reduce((G,Z)=>(G.min.x=Math.min(G.min.x,Z.x-k.x),G.min.y=Math.min(G.min.y,Z.y-k.y),G.max.x=Math.max(G.max.x,Z.x-k.x),G.max.y=Math.max(G.max.y,Z.y-k.y),G),{min:new r.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new r.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),U=(G,Z)=>{const se=G.wrap+G.canonical.x/(1<<G.canonical.z),de=G.canonical.y/(1<<G.canonical.z),ce=r.EXTENT/(1<<G.canonical.z),te=Z.wrap+Z.canonical.x/(1<<Z.canonical.z),Le=Z.canonical.y/(1<<Z.canonical.z);return se+ce<te+O.min.x||se>te+O.max.x||de+ce<Le+O.min.y||de>Le+O.max.y};for(let G=0;G<C.length;G++){const Z=C[G];for(let se=0;se<d.length;se++){const de=o.getTile(d[se]);if(!de||!de.hasData()||U(Z,de.tileID))continue;const ce=this._createProxiedId(Z,de,y[Z.key]&&y[Z.key][o.id]),te=this.proxyToSource[Z.key][o.id];te?te.push(ce):this.proxyToSource[Z.key][o.id]=[ce],E.push(ce)}}}_createProxiedId(o,d,y){let E=this.orthoMatrix;if(y){const C=y.find(S=>S.key===d.tileID.key);if(C)return C}if(d.tileID.key!==o.key){const C=o.canonical.z-d.tileID.canonical.z;let S,k,O;E=r.create();const U=d.tileID.wrap-o.wrap<<o.overscaledZ;C>0?(S=r.EXTENT>>C,k=S*((d.tileID.canonical.x<<C)-o.canonical.x+U),O=S*((d.tileID.canonical.y<<C)-o.canonical.y)):(S=r.EXTENT<<-C,k=r.EXTENT*(d.tileID.canonical.x-(o.canonical.x+U<<-C)),O=r.EXTENT*(d.tileID.canonical.y-(o.canonical.y<<-C))),r.ortho(E,0,S,0,S,0,1),r.translate(E,E,[k,O,0])}return new Fd(d.tileID,o.key,E)}_findTileCoveringTileID(o,d){let y=d.getTile(o);if(y&&y.hasData())return y;const E=this._findCoveringTileCache[d.id],C=E[o.key];if(y=C?d.getTileByID(C):null,y&&y.hasData()||C===null)return y;let S=y?y.tileID:o,k=S.overscaledZ;const O=d.getSource().minzoom,U=[];if(!C){const Z=d.getSource().maxzoom;if(o.canonical.z>=Z){const se=o.canonical.z-Z;d.getSource().reparseOverscaled?(k=Math.max(o.canonical.z+2,d.transform.tileZoom),S=new r.OverscaledTileID(k,o.wrap,Z,o.canonical.x>>se,o.canonical.y>>se)):se!==0&&(k=Z,S=new r.OverscaledTileID(k,o.wrap,Z,o.canonical.x>>se,o.canonical.y>>se))}S.key!==o.key&&(U.push(S.key),y=d.getTile(S))}const G=Z=>{U.forEach(se=>{E[se]=Z}),U.length=0};for(k-=1;k>=O&&(!y||!y.hasData());k--){y&&G(y.tileID.key);const Z=S.calculateScaledKey(k);if(y=d.getTileByID(Z),y&&y.hasData())break;const se=E[Z];if(se===null)break;se===void 0?U.push(Z):y=d.getTileByID(se)}return G(y?y.tileID.key:null),y&&y.hasData()?y:null}findDEMTileFor(o){return this.enabled?this._findTileCoveringTileID(o,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(o,d){let y=this._tilesDirty[o];y||(y=this._tilesDirty[o]={}),y[d.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const o=function(d){let y=0;const E=new r.StructArrayLayout2ui4,C=131;for(let S=1;S<129;S++){for(let k=1;k<129;k++)y=S*C+k,E.emplaceBack(y,y+1),E.emplaceBack(y,y+C),E.emplaceBack(y+1,y+C),S===128&&E.emplaceBack(y+C,y+C+1);E.emplaceBack(y+1,y+1+C)}return E}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(o),this.wireframeSegments=r.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,o.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function bu(m){const o=[];for(let d=0;d<m.length;d++){if(m[d]===null)continue;const y=m[d].split(" ");o.push(y.pop())}return o}class Dl{static cacheKey(o,d,y){let E=`${o}${y?y.cacheKey:""}`;for(const C of d)E+=`/${C}`;return E}constructor(o,d,y,E,C,S){const k=o.gl;this.program=k.createProgram();const O=bu(y.staticAttributes),U=E?E.getBinderAttributes():[],G=O.concat(U),Z=y.staticUniforms?bu(y.staticUniforms):[],se=E?E.getBinderUniforms():[],de=Z.concat(se),ce=[];for(const Ee of de)ce.indexOf(Ee)<0&&ce.push(Ee);let te=E?E.defines():[];te=te.concat(S.map(Ee=>`#define ${Ee}`));const Le=te.concat(`
- #ifdef GL_ES
- precision mediump float;
- #else
- #if !defined(lowp)
- #define lowp
- #endif
- #if !defined(mediump)
- #define mediump
- #endif
- #if !defined(highp)
- #define highp
- #endif
- #endif`,Tl,yu.fragmentSource,oa.fragmentSource,y.fragmentSource).join(`
- `),ve=te.concat(`
- #ifdef GL_ES
- precision highp float;
- #else
- #if !defined(lowp)
- #define lowp
- #endif
- #if !defined(mediump)
- #define mediump
- #endif
- #if !defined(highp)
- #define highp
- #endif
- #endif`,Tl,yu.vertexSource,oa.vertexSource,Ua.vertexSource,y.vertexSource).join(`
- `),De=k.createShader(k.FRAGMENT_SHADER);if(k.isContextLost())return void(this.failedToCreate=!0);k.shaderSource(De,Le),k.compileShader(De),k.attachShader(this.program,De);const Se=k.createShader(k.VERTEX_SHADER);if(k.isContextLost())return void(this.failedToCreate=!0);k.shaderSource(Se,ve),k.compileShader(Se),k.attachShader(this.program,Se),this.attributes={};const ze={};this.numAttributes=G.length;for(let Ee=0;Ee<this.numAttributes;Ee++)G[Ee]&&(k.bindAttribLocation(this.program,Ee,G[Ee]),this.attributes[G[Ee]]=Ee);k.linkProgram(this.program),k.deleteShader(Se),k.deleteShader(De);for(let Ee=0;Ee<ce.length;Ee++){const Ue=ce[Ee];if(Ue&&!ze[Ue]){const nt=k.getUniformLocation(this.program,Ue);nt&&(ze[Ue]=nt)}}this.fixedUniforms=C(o,ze),this.binderUniforms=E?E.getUniforms(o,ze):[],S.indexOf("TERRAIN")!==-1&&(this.terrainUniforms=((Ee,Ue)=>({u_dem:new r.Uniform1i(Ee,Ue.u_dem),u_dem_prev:new r.Uniform1i(Ee,Ue.u_dem_prev),u_dem_unpack:new r.Uniform4f(Ee,Ue.u_dem_unpack),u_dem_tl:new r.Uniform2f(Ee,Ue.u_dem_tl),u_dem_scale:new r.Uniform1f(Ee,Ue.u_dem_scale),u_dem_tl_prev:new r.Uniform2f(Ee,Ue.u_dem_tl_prev),u_dem_scale_prev:new r.Uniform1f(Ee,Ue.u_dem_scale_prev),u_dem_size:new r.Uniform1f(Ee,Ue.u_dem_size),u_dem_lerp:new r.Uniform1f(Ee,Ue.u_dem_lerp),u_exaggeration:new r.Uniform1f(Ee,Ue.u_exaggeration),u_depth:new r.Uniform1i(Ee,Ue.u_depth),u_depth_size_inv:new r.Uniform2f(Ee,Ue.u_depth_size_inv),u_meter_to_dem:new r.Uniform1f(Ee,Ue.u_meter_to_dem),u_label_plane_matrix_inv:new r.UniformMatrix4f(Ee,Ue.u_label_plane_matrix_inv),u_tile_tl_up:new r.Uniform3f(Ee,Ue.u_tile_tl_up),u_tile_tr_up:new r.Uniform3f(Ee,Ue.u_tile_tr_up),u_tile_br_up:new r.Uniform3f(Ee,Ue.u_tile_br_up),u_tile_bl_up:new r.Uniform3f(Ee,Ue.u_tile_bl_up),u_tile_up_scale:new r.Uniform1f(Ee,Ue.u_tile_up_scale)}))(o,ze)),S.indexOf("FOG")!==-1&&(this.fogUniforms=((Ee,Ue)=>({u_fog_matrix:new r.UniformMatrix4f(Ee,Ue.u_fog_matrix),u_fog_range:new r.Uniform2f(Ee,Ue.u_fog_range),u_fog_color:new r.Uniform4f(Ee,Ue.u_fog_color),u_fog_horizon_blend:new r.Uniform1f(Ee,Ue.u_fog_horizon_blend),u_fog_temporal_offset:new r.Uniform1f(Ee,Ue.u_fog_temporal_offset)}))(o,ze))}setTerrainUniformValues(o,d){if(!this.terrainUniforms)return;const y=this.terrainUniforms;if(!this.failedToCreate){o.program.set(this.program);for(const E in d)y[E].set(d[E])}}setFogUniformValues(o,d){if(!this.fogUniforms)return;const y=this.fogUniforms;if(!this.failedToCreate){o.program.set(this.program);for(const E in d)y[E].location&&y[E].set(d[E])}}draw(o,d,y,E,C,S,k,O,U,G,Z,se,de,ce,te,Le){const ve=o.gl;if(this.failedToCreate)return;o.program.set(this.program),o.setDepthMode(y),o.setStencilMode(E),o.setColorMode(C),o.setCullFace(S);for(const Se of Object.keys(this.fixedUniforms))this.fixedUniforms[Se].set(k[Se]);ce&&ce.setUniforms(o,this.binderUniforms,se,{zoom:de});const De={[ve.LINES]:2,[ve.TRIANGLES]:3,[ve.LINE_STRIP]:1}[d];for(const Se of Z.get()){const ze=Se.vaos||(Se.vaos={});(ze[O]||(ze[O]=new _u)).bind(o,this,U,ce?ce.getPaintVertexBuffers():[],G,Se.vertexOffset,te,Le),ve.drawElements(d,Se.primitiveLength*De,ve.UNSIGNED_SHORT,Se.primitiveOffset*De*2)}}}function Pl(m,o,d){const y=1/We(d,1,o.transform.tileZoom),E=Math.pow(2,d.tileID.overscaledZ),C=d.tileSize*Math.pow(2,o.transform.tileZoom)/E,S=C*(d.tileID.canonical.x+d.tileID.wrap*E),k=C*d.tileID.canonical.y;return{u_image:0,u_texsize:d.imageAtlasTexture.size,u_scale:[y,m.fromScale,m.toScale],u_fade:m.t,u_pixel_coord_upper:[S>>16,k>>16],u_pixel_coord_lower:[65535&S,65535&k]}}const Bd=r.create(),wu=(m,o,d,y,E,C,S,k,O)=>{const U=o.style.light,G=U.properties.get("position"),Z=[G.x,G.y,G.z],se=r.create$1();U.properties.get("anchor")==="viewport"&&(r.fromRotation(se,-o.transform.angle),r.transformMat3(Z,Z,se));const de=U.properties.get("color"),ce=o.transform,te={u_matrix:m,u_lightpos:Z,u_lightintensity:U.properties.get("intensity"),u_lightcolor:[de.r,de.g,de.b],u_vertical_gradient:+d,u_opacity:y,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Bd,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0};return ce.projection.name==="globe"&&(te.u_tile_id=[E.canonical.x,E.canonical.y,1<<E.canonical.z],te.u_zoom_transition=S,te.u_inv_rot_matrix=O,te.u_merc_center=k,te.u_up_dir=ce.projection.upVector(new r.CanonicalTileID(0,0,0),k[0]*r.EXTENT,k[1]*r.EXTENT),te.u_height_lift=C),te},Mu=(m,o,d,y,E,C,S,k,O,U,G)=>{const Z=wu(m,o,d,y,E,k,O,U,G),se={u_height_factor:-Math.pow(2,E.overscaledZ)/S.tileSize/8};return r.extend(Z,Pl(C,o,S),se)},Tu=m=>({u_matrix:m}),Eu=(m,o,d,y)=>r.extend(Tu(m),Pl(d,o,y)),Cu=(m,o)=>({u_matrix:m,u_world:o}),Gm=(m,o,d,y,E)=>r.extend(Eu(m,o,d,y),{u_world:E}),Wm=r.create(),Cs=(m,o,d,y,E,C)=>{const S=m.transform,k=S.projection.name==="globe";let O;if(C.paint.get("circle-pitch-alignment")==="map")if(k){const G=r.globePixelsToTileUnits(S.zoom,o.canonical);O=Float32Array.from([G,0,0,G])}else O=S.calculatePixelsToTileUnitsMatrix(d);else O=new Float32Array([S.pixelsToGLUnits[0],0,0,S.pixelsToGLUnits[1]]);const U={u_camera_to_center_distance:S.cameraToCenterDistance,u_matrix:m.translatePosMatrix(o.projMatrix,d,C.paint.get("circle-translate"),C.paint.get("circle-translate-anchor")),u_device_pixel_ratio:r.exported.devicePixelRatio,u_extrude_scale:O,u_inv_rot_matrix:Wm,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};return k&&(U.u_inv_rot_matrix=y,U.u_merc_center=E,U.u_tile_id=[o.canonical.x,o.canonical.y,1<<o.canonical.z],U.u_zoom_transition=r.globeToMercatorTransition(S.zoom),U.u_up_dir=S.projection.upVector(o.canonical,E[0],E[1])),U},J_=m=>{const o=[];return m.paint.get("circle-pitch-alignment")==="map"&&o.push("PITCH_WITH_MAP"),m.paint.get("circle-pitch-scale")==="map"&&o.push("SCALE_WITH_MAP"),o},Q_=(m,o,d)=>{const y=r.EXTENT/d.tileSize;return{u_matrix:m,u_camera_to_center_distance:o.cameraToCenterDistance,u_extrude_scale:[o.pixelsToGLUnits[0]/y,o.pixelsToGLUnits[1]/y]}},jm=(m,o,d=1)=>({u_matrix:m,u_color:o,u_overlay:0,u_overlay_scale:d}),ev=r.create(),tv=(m,o,d,y,E,C,S)=>{const k=m.transform,O=k.projection.name==="globe",U=O?r.globePixelsToTileUnits(k.zoom,o.canonical):We(d,1,C),G={u_matrix:o.projMatrix,u_extrude_scale:U,u_intensity:S,u_inv_rot_matrix:ev,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};return O&&(G.u_inv_rot_matrix=y,G.u_merc_center=E,G.u_tile_id=[o.canonical.x,o.canonical.y,1<<o.canonical.z],G.u_zoom_transition=r.globeToMercatorTransition(k.zoom),G.u_up_dir=k.projection.upVector(o.canonical,E[0],E[1])),G},nv=(m,o,d,y,E,C,S)=>{const k=m.transform,O=k.calculatePixelsToTileUnitsMatrix(o),U={u_matrix:Va(m,o,d,E),u_pixels_to_tile_units:O,u_device_pixel_ratio:S,u_units_to_pixels:[1/k.pixelsToGLUnits[0],1/k.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:C,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0};if(Nd(d)){const G=Au(o,m.transform);U.u_texsize=o.lineAtlasTexture.size,U.u_scale=[G,y.fromScale,y.toScale],U.u_mix=y.t}return U},Od=(m,o,d,y,E,C)=>{const S=m.transform,k=Au(o,S);return{u_matrix:Va(m,o,d,E),u_texsize:o.imageAtlasTexture.size,u_pixels_to_tile_units:S.calculatePixelsToTileUnitsMatrix(o),u_device_pixel_ratio:C,u_image:0,u_scale:[k,y.fromScale,y.toScale],u_fade:y.t,u_units_to_pixels:[1/S.pixelsToGLUnits[0],1/S.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Au(m,o){return 1/We(m,1,o.tileZoom)}function Va(m,o,d,y){return m.translatePosMatrix(y||o.tileID.projMatrix,o,d.paint.get("line-translate"),d.paint.get("line-translate-anchor"))}function Nd(m){const o=m.paint.get("line-dasharray").value;return o.value||o.kind!=="constant"}const Hm=(m,o,d,y,E,C)=>{return{u_matrix:m,u_tl_parent:o,u_scale_parent:d,u_fade_t:y.mix,u_opacity:y.opacity*E.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:E.paint.get("raster-brightness-min"),u_brightness_high:E.paint.get("raster-brightness-max"),u_saturation_factor:(k=E.paint.get("raster-saturation"),k>0?1-1/(1.001-k):-k),u_contrast_factor:(S=E.paint.get("raster-contrast"),S>0?1/(1-S):1+S),u_spin_weights:Ud(E.paint.get("raster-hue-rotate")),u_perspective_transform:C};var S,k};function Ud(m){m*=Math.PI/180;const o=Math.sin(m),d=Math.cos(m);return[(2*d+1)/3,(-Math.sqrt(3)*o-d+1)/3,(Math.sqrt(3)*o-d+1)/3]}const sa=r.create(),Vd=(m,o,d,y,E,C,S,k,O,U,G,Z,se,de)=>{const ce=E.transform,te={u_is_size_zoom_constant:+(m==="constant"||m==="source"),u_is_size_feature_constant:+(m==="constant"||m==="camera"),u_size_t:o?o.uSizeT:0,u_size:o?o.uSize:0,u_camera_to_center_distance:ce.cameraToCenterDistance,u_rotate_symbol:+d,u_aspect_ratio:ce.width/ce.height,u_fade_change:E.options.fadeDuration?E.symbolFadeChange:1,u_matrix:C,u_label_plane_matrix:S,u_coord_matrix:k,u_is_text:+O,u_pitch_with_map:+y,u_texsize:U,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:sa,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:sa};return ce.projection.name==="globe"&&(te.u_tile_id=[G.canonical.x,G.canonical.y,1<<G.canonical.z],te.u_zoom_transition=Z,te.u_inv_rot_matrix=de,te.u_merc_center=se,te.u_camera_forward=ce._camera.forward(),te.u_ecef_origin=r.globeECEFOrigin(ce.globeMatrix,G.toUnwrapped()),te.u_tile_matrix=Float32Array.from(ce.globeMatrix)),te},Ga=(m,o,d,y,E,C,S,k,O,U,G,Z,se,de,ce)=>{const{cameraToCenterDistance:te,_pitch:Le}=E.transform;return r.extend(Vd(m,o,d,y,E,C,S,k,O,U,Z,se,de,ce),{u_gamma_scale:y?te*Math.cos(E.terrain?0:Le):1,u_device_pixel_ratio:r.exported.devicePixelRatio,u_is_halo:+G})},As=(m,o,d,y,E,C,S,k,O,U,G,Z,se,de)=>r.extend(Ga(m,o,d,y,E,C,S,k,!0,O,!0,G,Z,se,de),{u_texsize_icon:U,u_texture_icon:1}),$m=(m,o,d)=>({u_matrix:m,u_opacity:o,u_color:d}),Gd=(m,o,d,y,E,C)=>r.extend(function(S,k,O,U){const G=O.imageManager.getPattern(S.from.toString()),Z=O.imageManager.getPattern(S.to.toString()),{width:se,height:de}=O.imageManager.getPixelSize(),ce=Math.pow(2,U.tileID.overscaledZ),te=U.tileSize*Math.pow(2,O.transform.tileZoom)/ce,Le=te*(U.tileID.canonical.x+U.tileID.wrap*ce),ve=te*U.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:G.tl,u_pattern_br_a:G.br,u_pattern_tl_b:Z.tl,u_pattern_br_b:Z.br,u_texsize:[se,de],u_mix:k.t,u_pattern_size_a:G.displaySize,u_pattern_size_b:Z.displaySize,u_scale_a:k.fromScale,u_scale_b:k.toScale,u_tile_units_to_pixels:1/We(U,1,O.transform.tileZoom),u_pixel_coord_upper:[Le>>16,ve>>16],u_pixel_coord_lower:[65535&Le,65535&ve]}}(y,C,d,E),{u_matrix:m,u_opacity:o}),Qn={fillExtrusion:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_lightpos:new r.Uniform3f(m,o.u_lightpos),u_lightintensity:new r.Uniform1f(m,o.u_lightintensity),u_lightcolor:new r.Uniform3f(m,o.u_lightcolor),u_vertical_gradient:new r.Uniform1f(m,o.u_vertical_gradient),u_opacity:new r.Uniform1f(m,o.u_opacity),u_tile_id:new r.Uniform3f(m,o.u_tile_id),u_zoom_transition:new r.Uniform1f(m,o.u_zoom_transition),u_inv_rot_matrix:new r.UniformMatrix4f(m,o.u_inv_rot_matrix),u_merc_center:new r.Uniform2f(m,o.u_merc_center),u_up_dir:new r.Uniform3f(m,o.u_up_dir),u_height_lift:new r.Uniform1f(m,o.u_height_lift)}),fillExtrusionPattern:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_lightpos:new r.Uniform3f(m,o.u_lightpos),u_lightintensity:new r.Uniform1f(m,o.u_lightintensity),u_lightcolor:new r.Uniform3f(m,o.u_lightcolor),u_vertical_gradient:new r.Uniform1f(m,o.u_vertical_gradient),u_height_factor:new r.Uniform1f(m,o.u_height_factor),u_tile_id:new r.Uniform3f(m,o.u_tile_id),u_zoom_transition:new r.Uniform1f(m,o.u_zoom_transition),u_inv_rot_matrix:new r.UniformMatrix4f(m,o.u_inv_rot_matrix),u_merc_center:new r.Uniform2f(m,o.u_merc_center),u_up_dir:new r.Uniform3f(m,o.u_up_dir),u_height_lift:new r.Uniform1f(m,o.u_height_lift),u_image:new r.Uniform1i(m,o.u_image),u_texsize:new r.Uniform2f(m,o.u_texsize),u_pixel_coord_upper:new r.Uniform2f(m,o.u_pixel_coord_upper),u_pixel_coord_lower:new r.Uniform2f(m,o.u_pixel_coord_lower),u_scale:new r.Uniform3f(m,o.u_scale),u_fade:new r.Uniform1f(m,o.u_fade),u_opacity:new r.Uniform1f(m,o.u_opacity)}),fill:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix)}),fillPattern:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_image:new r.Uniform1i(m,o.u_image),u_texsize:new r.Uniform2f(m,o.u_texsize),u_pixel_coord_upper:new r.Uniform2f(m,o.u_pixel_coord_upper),u_pixel_coord_lower:new r.Uniform2f(m,o.u_pixel_coord_lower),u_scale:new r.Uniform3f(m,o.u_scale),u_fade:new r.Uniform1f(m,o.u_fade)}),fillOutline:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_world:new r.Uniform2f(m,o.u_world)}),fillOutlinePattern:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_world:new r.Uniform2f(m,o.u_world),u_image:new r.Uniform1i(m,o.u_image),u_texsize:new r.Uniform2f(m,o.u_texsize),u_pixel_coord_upper:new r.Uniform2f(m,o.u_pixel_coord_upper),u_pixel_coord_lower:new r.Uniform2f(m,o.u_pixel_coord_lower),u_scale:new r.Uniform3f(m,o.u_scale),u_fade:new r.Uniform1f(m,o.u_fade)}),circle:(m,o)=>({u_camera_to_center_distance:new r.Uniform1f(m,o.u_camera_to_center_distance),u_extrude_scale:new r.UniformMatrix2f(m,o.u_extrude_scale),u_device_pixel_ratio:new r.Uniform1f(m,o.u_device_pixel_ratio),u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_inv_rot_matrix:new r.UniformMatrix4f(m,o.u_inv_rot_matrix),u_merc_center:new r.Uniform2f(m,o.u_merc_center),u_tile_id:new r.Uniform3f(m,o.u_tile_id),u_zoom_transition:new r.Uniform1f(m,o.u_zoom_transition),u_up_dir:new r.Uniform3f(m,o.u_up_dir)}),collisionBox:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_camera_to_center_distance:new r.Uniform1f(m,o.u_camera_to_center_distance),u_extrude_scale:new r.Uniform2f(m,o.u_extrude_scale)}),collisionCircle:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_inv_matrix:new r.UniformMatrix4f(m,o.u_inv_matrix),u_camera_to_center_distance:new r.Uniform1f(m,o.u_camera_to_center_distance),u_viewport_size:new r.Uniform2f(m,o.u_viewport_size)}),debug:(m,o)=>({u_color:new r.UniformColor(m,o.u_color),u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_overlay:new r.Uniform1i(m,o.u_overlay),u_overlay_scale:new r.Uniform1f(m,o.u_overlay_scale)}),clippingMask:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix)}),heatmap:(m,o)=>({u_extrude_scale:new r.Uniform1f(m,o.u_extrude_scale),u_intensity:new r.Uniform1f(m,o.u_intensity),u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_inv_rot_matrix:new r.UniformMatrix4f(m,o.u_inv_rot_matrix),u_merc_center:new r.Uniform2f(m,o.u_merc_center),u_tile_id:new r.Uniform3f(m,o.u_tile_id),u_zoom_transition:new r.Uniform1f(m,o.u_zoom_transition),u_up_dir:new r.Uniform3f(m,o.u_up_dir)}),heatmapTexture:(m,o)=>({u_image:new r.Uniform1i(m,o.u_image),u_color_ramp:new r.Uniform1i(m,o.u_color_ramp),u_opacity:new r.Uniform1f(m,o.u_opacity)}),hillshade:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_image:new r.Uniform1i(m,o.u_image),u_latrange:new r.Uniform2f(m,o.u_latrange),u_light:new r.Uniform2f(m,o.u_light),u_shadow:new r.UniformColor(m,o.u_shadow),u_highlight:new r.UniformColor(m,o.u_highlight),u_accent:new r.UniformColor(m,o.u_accent)}),hillshadePrepare:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_image:new r.Uniform1i(m,o.u_image),u_dimension:new r.Uniform2f(m,o.u_dimension),u_zoom:new r.Uniform1f(m,o.u_zoom),u_unpack:new r.Uniform4f(m,o.u_unpack)}),line:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_pixels_to_tile_units:new r.UniformMatrix2f(m,o.u_pixels_to_tile_units),u_device_pixel_ratio:new r.Uniform1f(m,o.u_device_pixel_ratio),u_units_to_pixels:new r.Uniform2f(m,o.u_units_to_pixels),u_dash_image:new r.Uniform1i(m,o.u_dash_image),u_gradient_image:new r.Uniform1i(m,o.u_gradient_image),u_image_height:new r.Uniform1f(m,o.u_image_height),u_texsize:new r.Uniform2f(m,o.u_texsize),u_scale:new r.Uniform3f(m,o.u_scale),u_mix:new r.Uniform1f(m,o.u_mix),u_alpha_discard_threshold:new r.Uniform1f(m,o.u_alpha_discard_threshold)}),linePattern:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_texsize:new r.Uniform2f(m,o.u_texsize),u_pixels_to_tile_units:new r.UniformMatrix2f(m,o.u_pixels_to_tile_units),u_device_pixel_ratio:new r.Uniform1f(m,o.u_device_pixel_ratio),u_image:new r.Uniform1i(m,o.u_image),u_units_to_pixels:new r.Uniform2f(m,o.u_units_to_pixels),u_scale:new r.Uniform3f(m,o.u_scale),u_fade:new r.Uniform1f(m,o.u_fade),u_alpha_discard_threshold:new r.Uniform1f(m,o.u_alpha_discard_threshold)}),raster:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_tl_parent:new r.Uniform2f(m,o.u_tl_parent),u_scale_parent:new r.Uniform1f(m,o.u_scale_parent),u_fade_t:new r.Uniform1f(m,o.u_fade_t),u_opacity:new r.Uniform1f(m,o.u_opacity),u_image0:new r.Uniform1i(m,o.u_image0),u_image1:new r.Uniform1i(m,o.u_image1),u_brightness_low:new r.Uniform1f(m,o.u_brightness_low),u_brightness_high:new r.Uniform1f(m,o.u_brightness_high),u_saturation_factor:new r.Uniform1f(m,o.u_saturation_factor),u_contrast_factor:new r.Uniform1f(m,o.u_contrast_factor),u_spin_weights:new r.Uniform3f(m,o.u_spin_weights),u_perspective_transform:new r.Uniform2f(m,o.u_perspective_transform)}),symbolIcon:(m,o)=>({u_is_size_zoom_constant:new r.Uniform1i(m,o.u_is_size_zoom_constant),u_is_size_feature_constant:new r.Uniform1i(m,o.u_is_size_feature_constant),u_size_t:new r.Uniform1f(m,o.u_size_t),u_size:new r.Uniform1f(m,o.u_size),u_camera_to_center_distance:new r.Uniform1f(m,o.u_camera_to_center_distance),u_rotate_symbol:new r.Uniform1i(m,o.u_rotate_symbol),u_aspect_ratio:new r.Uniform1f(m,o.u_aspect_ratio),u_fade_change:new r.Uniform1f(m,o.u_fade_change),u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_label_plane_matrix:new r.UniformMatrix4f(m,o.u_label_plane_matrix),u_coord_matrix:new r.UniformMatrix4f(m,o.u_coord_matrix),u_is_text:new r.Uniform1i(m,o.u_is_text),u_pitch_with_map:new r.Uniform1i(m,o.u_pitch_with_map),u_texsize:new r.Uniform2f(m,o.u_texsize),u_tile_id:new r.Uniform3f(m,o.u_tile_id),u_zoom_transition:new r.Uniform1f(m,o.u_zoom_transition),u_inv_rot_matrix:new r.UniformMatrix4f(m,o.u_inv_rot_matrix),u_merc_center:new r.Uniform2f(m,o.u_merc_center),u_camera_forward:new r.Uniform3f(m,o.u_camera_forward),u_tile_matrix:new r.UniformMatrix4f(m,o.u_tile_matrix),u_ecef_origin:new r.Uniform3f(m,o.u_ecef_origin),u_texture:new r.Uniform1i(m,o.u_texture)}),symbolSDF:(m,o)=>({u_is_size_zoom_constant:new r.Uniform1i(m,o.u_is_size_zoom_constant),u_is_size_feature_constant:new r.Uniform1i(m,o.u_is_size_feature_constant),u_size_t:new r.Uniform1f(m,o.u_size_t),u_size:new r.Uniform1f(m,o.u_size),u_camera_to_center_distance:new r.Uniform1f(m,o.u_camera_to_center_distance),u_rotate_symbol:new r.Uniform1i(m,o.u_rotate_symbol),u_aspect_ratio:new r.Uniform1f(m,o.u_aspect_ratio),u_fade_change:new r.Uniform1f(m,o.u_fade_change),u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_label_plane_matrix:new r.UniformMatrix4f(m,o.u_label_plane_matrix),u_coord_matrix:new r.UniformMatrix4f(m,o.u_coord_matrix),u_is_text:new r.Uniform1i(m,o.u_is_text),u_pitch_with_map:new r.Uniform1i(m,o.u_pitch_with_map),u_texsize:new r.Uniform2f(m,o.u_texsize),u_texture:new r.Uniform1i(m,o.u_texture),u_gamma_scale:new r.Uniform1f(m,o.u_gamma_scale),u_device_pixel_ratio:new r.Uniform1f(m,o.u_device_pixel_ratio),u_tile_id:new r.Uniform3f(m,o.u_tile_id),u_zoom_transition:new r.Uniform1f(m,o.u_zoom_transition),u_inv_rot_matrix:new r.UniformMatrix4f(m,o.u_inv_rot_matrix),u_merc_center:new r.Uniform2f(m,o.u_merc_center),u_camera_forward:new r.Uniform3f(m,o.u_camera_forward),u_tile_matrix:new r.UniformMatrix4f(m,o.u_tile_matrix),u_ecef_origin:new r.Uniform3f(m,o.u_ecef_origin),u_is_halo:new r.Uniform1i(m,o.u_is_halo)}),symbolTextAndIcon:(m,o)=>({u_is_size_zoom_constant:new r.Uniform1i(m,o.u_is_size_zoom_constant),u_is_size_feature_constant:new r.Uniform1i(m,o.u_is_size_feature_constant),u_size_t:new r.Uniform1f(m,o.u_size_t),u_size:new r.Uniform1f(m,o.u_size),u_camera_to_center_distance:new r.Uniform1f(m,o.u_camera_to_center_distance),u_rotate_symbol:new r.Uniform1i(m,o.u_rotate_symbol),u_aspect_ratio:new r.Uniform1f(m,o.u_aspect_ratio),u_fade_change:new r.Uniform1f(m,o.u_fade_change),u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_label_plane_matrix:new r.UniformMatrix4f(m,o.u_label_plane_matrix),u_coord_matrix:new r.UniformMatrix4f(m,o.u_coord_matrix),u_is_text:new r.Uniform1i(m,o.u_is_text),u_pitch_with_map:new r.Uniform1i(m,o.u_pitch_with_map),u_texsize:new r.Uniform2f(m,o.u_texsize),u_texsize_icon:new r.Uniform2f(m,o.u_texsize_icon),u_texture:new r.Uniform1i(m,o.u_texture),u_texture_icon:new r.Uniform1i(m,o.u_texture_icon),u_gamma_scale:new r.Uniform1f(m,o.u_gamma_scale),u_device_pixel_ratio:new r.Uniform1f(m,o.u_device_pixel_ratio),u_is_halo:new r.Uniform1i(m,o.u_is_halo)}),background:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_opacity:new r.Uniform1f(m,o.u_opacity),u_color:new r.UniformColor(m,o.u_color)}),backgroundPattern:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_opacity:new r.Uniform1f(m,o.u_opacity),u_image:new r.Uniform1i(m,o.u_image),u_pattern_tl_a:new r.Uniform2f(m,o.u_pattern_tl_a),u_pattern_br_a:new r.Uniform2f(m,o.u_pattern_br_a),u_pattern_tl_b:new r.Uniform2f(m,o.u_pattern_tl_b),u_pattern_br_b:new r.Uniform2f(m,o.u_pattern_br_b),u_texsize:new r.Uniform2f(m,o.u_texsize),u_mix:new r.Uniform1f(m,o.u_mix),u_pattern_size_a:new r.Uniform2f(m,o.u_pattern_size_a),u_pattern_size_b:new r.Uniform2f(m,o.u_pattern_size_b),u_scale_a:new r.Uniform1f(m,o.u_scale_a),u_scale_b:new r.Uniform1f(m,o.u_scale_b),u_pixel_coord_upper:new r.Uniform2f(m,o.u_pixel_coord_upper),u_pixel_coord_lower:new r.Uniform2f(m,o.u_pixel_coord_lower),u_tile_units_to_pixels:new r.Uniform1f(m,o.u_tile_units_to_pixels)}),terrainRaster:Rd,terrainDepth:Rd,skybox:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_sun_direction:new r.Uniform3f(m,o.u_sun_direction),u_cubemap:new r.Uniform1i(m,o.u_cubemap),u_opacity:new r.Uniform1f(m,o.u_opacity),u_temporal_offset:new r.Uniform1f(m,o.u_temporal_offset)}),skyboxGradient:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_color_ramp:new r.Uniform1i(m,o.u_color_ramp),u_center_direction:new r.Uniform3f(m,o.u_center_direction),u_radius:new r.Uniform1f(m,o.u_radius),u_opacity:new r.Uniform1f(m,o.u_opacity),u_temporal_offset:new r.Uniform1f(m,o.u_temporal_offset)}),skyboxCapture:(m,o)=>({u_matrix_3f:new r.UniformMatrix3f(m,o.u_matrix_3f),u_sun_direction:new r.Uniform3f(m,o.u_sun_direction),u_sun_intensity:new r.Uniform1f(m,o.u_sun_intensity),u_color_tint_r:new r.Uniform4f(m,o.u_color_tint_r),u_color_tint_m:new r.Uniform4f(m,o.u_color_tint_m),u_luminance:new r.Uniform1f(m,o.u_luminance)}),globeRaster:(m,o)=>({u_proj_matrix:new r.UniformMatrix4f(m,o.u_proj_matrix),u_globe_matrix:new r.UniformMatrix4f(m,o.u_globe_matrix),u_merc_matrix:new r.UniformMatrix4f(m,o.u_merc_matrix),u_zoom_transition:new r.Uniform1f(m,o.u_zoom_transition),u_merc_center:new r.Uniform2f(m,o.u_merc_center),u_image0:new r.Uniform1i(m,o.u_image0),u_grid_matrix:new r.UniformMatrix3f(m,o.u_grid_matrix)}),globeAtmosphere:(m,o)=>({u_frustum_tl:new r.Uniform3f(m,o.u_frustum_tl),u_frustum_tr:new r.Uniform3f(m,o.u_frustum_tr),u_frustum_br:new r.Uniform3f(m,o.u_frustum_br),u_frustum_bl:new r.Uniform3f(m,o.u_frustum_bl),u_globe_pos:new r.Uniform3f(m,o.u_globe_pos),u_globe_radius:new r.Uniform1f(m,o.u_globe_radius),u_opacity:new r.Uniform1f(m,o.u_opacity),u_fadeout_range:new r.Uniform1f(m,o.u_fadeout_range),u_start_color:new r.Uniform3f(m,o.u_start_color),u_end_color:new r.Uniform3f(m,o.u_end_color)})};let Wa;function qm(m,o,d,y,E,C,S){const k=m.context,O=k.gl,U=m.useProgram("collisionBox"),G=[];let Z=0,se=0;for(let Se=0;Se<y.length;Se++){const ze=y[Se],Ee=o.getTile(ze),Ue=Ee.getBucket(d);if(!Ue)continue;let nt=ze.projMatrix;E[0]===0&&E[1]===0||(nt=m.translatePosMatrix(ze.projMatrix,Ee,E,C));const lt=S?Ue.textCollisionBox:Ue.iconCollisionBox,pt=Ue.collisionCircleArray;if(pt.length>0){const ht=r.create(),kt=nt;r.mul(ht,Ue.placementInvProjMatrix,m.transform.glCoordMatrix),r.mul(ht,ht,Ue.placementViewportMatrix),G.push({circleArray:pt,circleOffset:se,transform:kt,invTransform:ht}),Z+=pt.length/4,se=Z}lt&&(m.terrain&&m.terrain.setupElevationDraw(Ee,U),U.draw(k,O.LINES,r.DepthMode.disabled,r.StencilMode.disabled,m.colorModeForRenderPass(),r.CullFaceMode.disabled,Q_(nt,m.transform,Ee),d.id,lt.layoutVertexBuffer,lt.indexBuffer,lt.segments,null,m.transform.zoom,null,lt.collisionVertexBuffer,lt.collisionVertexBufferExt))}if(!S||!G.length)return;const de=m.useProgram("collisionCircle"),ce=new r.StructArrayLayout2f1f2i16;ce.resize(4*Z),ce._trim();let te=0;for(const Se of G)for(let ze=0;ze<Se.circleArray.length/4;ze++){const Ee=4*ze,Ue=Se.circleArray[Ee+0],nt=Se.circleArray[Ee+1],lt=Se.circleArray[Ee+2],pt=Se.circleArray[Ee+3];ce.emplace(te++,Ue,nt,lt,pt,0),ce.emplace(te++,Ue,nt,lt,pt,1),ce.emplace(te++,Ue,nt,lt,pt,2),ce.emplace(te++,Ue,nt,lt,pt,3)}(!Wa||Wa.length<2*Z)&&(Wa=function(Se){const ze=2*Se,Ee=new r.StructArrayLayout3ui6;Ee.resize(ze),Ee._trim();for(let Ue=0;Ue<ze;Ue++){const nt=6*Ue;Ee.uint16[nt+0]=4*Ue+0,Ee.uint16[nt+1]=4*Ue+1,Ee.uint16[nt+2]=4*Ue+2,Ee.uint16[nt+3]=4*Ue+2,Ee.uint16[nt+4]=4*Ue+3,Ee.uint16[nt+5]=4*Ue+0}return Ee}(Z));const Le=k.createIndexBuffer(Wa,!0),ve=k.createVertexBuffer(ce,r.collisionCircleLayout.members,!0);for(const Se of G){const ze={u_matrix:Se.transform,u_inv_matrix:Se.invTransform,u_camera_to_center_distance:(De=m.transform).cameraToCenterDistance,u_viewport_size:[De.width,De.height]};de.draw(k,O.TRIANGLES,r.DepthMode.disabled,r.StencilMode.disabled,m.colorModeForRenderPass(),r.CullFaceMode.disabled,ze,d.id,ve,Le,r.SegmentVector.simpleSegment(0,2*Se.circleOffset,Se.circleArray.length,Se.circleArray.length/2),null,m.transform.zoom,null,null,null)}var De;ve.destroy(),Le.destroy()}const Wd=r.create();function Sl(m,o,d,y,E,C){const{horizontalAlign:S,verticalAlign:k}=r.getAnchorAlignment(m),O=-(S-.5)*o,U=-(k-.5)*d,G=r.evaluateVariableOffset(m,y);return new r.pointGeometry((O/E+G[0])*C,(U/E+G[1])*C)}function iv(m,o,d,y,E,C,S,k,O,U,G,Z){const se=m.text.placedSymbolArray,de=m.text.dynamicLayoutVertexArray,ce=m.icon.dynamicLayoutVertexArray,te={},Le=k.projMatrix,ve=C.elevation,De=Z.upVectorScale(k.canonical,C.center.lat,C.worldSize);de.clear();for(let Se=0;Se<se.length;Se++){const ze=se.get(Se),Ee=m.allowVerticalPlacement&&!ze.placedOrientation,Ue=ze.hidden||!ze.crossTileID||Ee?null:y[ze.crossTileID];if(Ue){const nt=new r.pointGeometry(ze.tileAnchorX,ze.tileAnchorY),lt=Z.upVector(k.canonical,nt.x,nt.y),pt=ve?ve.getAtTileOffset(k,nt.x,nt.y):0,ht=li([ze.projectedAnchorX+pt*lt[0]*De.metersToTile,ze.projectedAnchorY+pt*lt[1]*De.metersToTile,ze.projectedAnchorZ+pt*lt[2]*De.metersToTile],d?Le:S),kt=ai(C.cameraToCenterDistance,ht.signedDistanceFromCamera);let it=E.evaluateSizeForFeature(m.textSizeData,U,ze)*kt/r.ONE_EM;d&&(it*=m.tilePixelRatio/O);const{width:zt,height:St,anchor:Jt,textOffset:ft,textScale:qt}=Ue,gn=Sl(Jt,zt,St,ft,qt,it),Zt=d?oi(nt.add(gn),S,pt*De.metersToLabelSpace).point:ht.point.add(o?gn.rotate(-C.angle):gn),Yt=m.allowVerticalPlacement&&ze.placedOrientation===r.WritingMode.vertical?Math.PI/2:0;for(let xn=0;xn<ze.numGlyphs;xn++)r.addDynamicAttributes(de,Zt,Yt);G&&ze.associatedIconIndex>=0&&(te[ze.associatedIconIndex]={shiftedAnchor:Zt,angle:Yt})}else Fi(ze.numGlyphs,de)}if(G){ce.clear();const Se=m.icon.placedSymbolArray;for(let ze=0;ze<Se.length;ze++){const Ee=Se.get(ze);if(Ee.hidden)Fi(Ee.numGlyphs,ce);else{const Ue=te[ze];if(Ue)for(let nt=0;nt<Ee.numGlyphs;nt++)r.addDynamicAttributes(ce,Ue.shiftedAnchor,Ue.angle);else Fi(Ee.numGlyphs,ce)}}m.icon.dynamicLayoutVertexBuffer.updateData(ce)}m.text.dynamicLayoutVertexBuffer.updateData(de)}function rv(m,o,d){return d.iconsInText&&o?"symbolTextAndIcon":m?"symbolSDF":"symbolIcon"}function jd(m,o,d,y,E,C,S,k,O,U,G,Z){const se=m.context,de=se.gl,ce=m.transform,te=k==="map",Le=O==="map",ve=te&&d.layout.get("symbol-placement")!=="point",De=te&&!Le&&!ve,Se=d.layout.get("symbol-sort-key").constantOr(1)!==void 0;let ze=!1;const Ee=m.depthModeForSublayer(0,r.DepthMode.ReadOnly),Ue=[r.mercatorXfromLng(ce.center.lng),r.mercatorYfromLat(ce.center.lat)],nt=d.layout.get("text-variable-anchor"),lt=ce.projection.name==="globe",pt=lt?r.globeToMercatorTransition(ce.zoom):0,ht=[],kt=[];m.terrain&&Le&&kt.push("PITCH_WITH_MAP_TERRAIN"),lt&&kt.push("PROJECTION_GLOBE_VIEW");for(const it of y){const zt=o.getTile(it),St=zt.getBucket(d);if(!St||St.projection!==ce.projection.name)continue;const Jt=E?St.text:St.icon;if(!Jt||St.fullyClipped||!Jt.segments.get().length)continue;const ft=Jt.programConfigurations.get(d.id),qt=E||St.sdfIcons,gn=E?St.textSizeData:St.iconSizeData,Zt=Le||ce.pitch!==0,Yt=r.evaluateSizeForZoom(gn,ce.zoom);let xn,zn,dn,Mn,$n=[0,0],vi=null;if(E){if(zn=zt.glyphAtlasTexture,dn=de.LINEAR,xn=zt.glyphAtlasTexture.size,St.iconsInText){$n=zt.imageAtlasTexture.size,vi=zt.imageAtlasTexture;const Fr=gn.kind==="composite"||gn.kind==="camera";Mn=Zt||m.options.rotating||m.options.zooming||Fr?de.LINEAR:de.NEAREST}}else{const Fr=d.layout.get("icon-size").constantOr(0)!==1||St.iconsNeedLinear;zn=zt.imageAtlasTexture,dn=qt||m.options.rotating||m.options.zooming||Fr||Zt?de.LINEAR:de.NEAREST,xn=zt.imageAtlasTexture.size}const nr=m.transform.calculatePixelsToTileUnitsMatrix(zt),ir=di(it.projMatrix,zt.tileID.canonical,Le,te,m.transform,nr),kr=m.terrain&&Le&&ve?r.invert(r.create(),ir):Wd,mo=Dr(it.projMatrix,zt.tileID.canonical,Le,te,m.transform,nr),Uo=nt&&St.hasTextData(),pa=d.layout.get("icon-text-fit")!=="none"&&Uo&&St.hasIconData();if(ve){const Fr=ce.elevation,Ha=Fr?Fr.getAtTileOffsetFunc(it,ce.center.lat,ce.worldSize,ce.projection):Mg=>[0,0,0];ko(St,it.projMatrix,m,E,ir,mo,Le,U,Ha,it)}const Vo=ve||E&&nt||pa,bi=m.translatePosMatrix(it.projMatrix,zt,C,S),Ti=Vo?Wd:ir,Yn=m.translatePosMatrix(mo,zt,C,S,!0),Si=ce.projection.createInversionMatrix(ce,it.canonical),zr=Vo?kt.concat(["PROJECTED_POS_ON_VIEWPORT"]):kt,xi=qt&&d.paint.get(E?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Xr;Xr=qt?St.iconsInText?As(gn.kind,Yt,De,Le,m,bi,Ti,Yn,xn,$n,it,pt,Ue,Si):Ga(gn.kind,Yt,De,Le,m,bi,Ti,Yn,E,xn,!0,it,pt,Ue,Si):Vd(gn.kind,Yt,De,Le,m,bi,Ti,Yn,E,xn,it,pt,Ue,Si);const $l={program:m.useProgram(rv(qt,E,St),ft,zr),buffers:Jt,uniformValues:Xr,atlasTexture:zn,atlasTextureIcon:vi,atlasInterpolation:dn,atlasInterpolationIcon:Mn,isSDF:qt,hasHalo:xi,tile:zt,labelPlaneMatrixInv:kr};if(Se&&St.canOverlap){ze=!0;const Fr=Jt.segments.get();for(const Ha of Fr)ht.push({segments:new r.SegmentVector([Ha]),sortKey:Ha.sortKey,state:$l})}else ht.push({segments:Jt.segments,sortKey:0,state:$l})}ze&&ht.sort((it,zt)=>it.sortKey-zt.sortKey);for(const it of ht){const zt=it.state;if(m.terrain&&m.terrain.setupElevationDraw(zt.tile,zt.program,{useDepthForOcclusion:!lt,labelPlaneMatrixInv:zt.labelPlaneMatrixInv}),se.activeTexture.set(de.TEXTURE0),zt.atlasTexture.bind(zt.atlasInterpolation,de.CLAMP_TO_EDGE),zt.atlasTextureIcon&&(se.activeTexture.set(de.TEXTURE1),zt.atlasTextureIcon&&zt.atlasTextureIcon.bind(zt.atlasInterpolationIcon,de.CLAMP_TO_EDGE)),zt.isSDF){const St=zt.uniformValues;zt.hasHalo&&(St.u_is_halo=1,Xm(zt.buffers,it.segments,d,m,zt.program,Ee,G,Z,St)),St.u_is_halo=0}Xm(zt.buffers,it.segments,d,m,zt.program,Ee,G,Z,zt.uniformValues)}}function Xm(m,o,d,y,E,C,S,k,O){const U=y.context;E.draw(U,U.gl.TRIANGLES,C,S,k,r.CullFaceMode.disabled,O,d.id,m.layoutVertexBuffer,m.indexBuffer,o,d.paint,y.transform.zoom,m.programConfigurations.get(d.id),m.dynamicLayoutVertexBuffer,m.opacityVertexBuffer)}function Du(m,o,d,y,E,C,S){const k=m.context.gl,O=d.paint.get("fill-pattern"),U=O&&O.constantOr(1),G=d.getCrossfadeParameters();let Z,se,de,ce,te;S?(se=U&&!d.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",Z=k.LINES):(se=U?"fillPattern":"fill",Z=k.TRIANGLES);for(const Le of y){const ve=o.getTile(Le);if(U&&!ve.patternsLoaded())continue;const De=ve.getBucket(d);if(!De)continue;m.prepareDrawTile();const Se=De.programConfigurations.get(d.id),ze=m.useProgram(se,Se);U&&(m.context.activeTexture.set(k.TEXTURE0),ve.imageAtlasTexture.bind(k.LINEAR,k.CLAMP_TO_EDGE),Se.updatePaintBuffers(G));const Ee=O.constantOr(null);if(Ee&&ve.imageAtlas){const nt=ve.imageAtlas,lt=nt.patternPositions[Ee.to.toString()],pt=nt.patternPositions[Ee.from.toString()];lt&&pt&&Se.setConstantPatternPositions(lt,pt)}const Ue=m.translatePosMatrix(Le.projMatrix,ve,d.paint.get("fill-translate"),d.paint.get("fill-translate-anchor"));if(S){ce=De.indexBuffer2,te=De.segments2;const nt=m.terrain&&m.terrain.renderingToTexture?m.terrain.drapeBufferSize:[k.drawingBufferWidth,k.drawingBufferHeight];de=se==="fillOutlinePattern"&&U?Gm(Ue,m,G,ve,nt):Cu(Ue,nt)}else ce=De.indexBuffer,te=De.segments,de=U?Eu(Ue,m,G,ve):Tu(Ue);m.prepareDrawProgram(m.context,ze,Le.toUnwrapped()),ze.draw(m.context,Z,E,m.stencilModeForClipping(Le),C,r.CullFaceMode.disabled,de,d.id,De.layoutVertexBuffer,ce,te,d.paint,m.transform.zoom,Se)}}function Ds(m,o,d,y,E,C,S){const k=m.context,O=k.gl,U=m.transform,G=d.paint.get("fill-extrusion-pattern"),Z=G.constantOr(1),se=d.getCrossfadeParameters(),de=d.paint.get("fill-extrusion-opacity"),ce=function(Se){if(Se.projection.name!=="globe")return 0;const ze=Math.PI/32,Ee=Math.tan(ze),Ue=r.earthRadius;return Ue*Math.sqrt(1+2*Ee*Ee)-Ue}(U),te=U.projection.name==="globe",Le=te?r.globeToMercatorTransition(U.zoom):0,ve=[r.mercatorXfromLng(U.center.lng),r.mercatorYfromLat(U.center.lat)],De=[];te&&De.push("PROJECTION_GLOBE_VIEW");for(const Se of y){const ze=o.getTile(Se),Ee=ze.getBucket(d);if(!Ee||Ee.projection!==U.projection.name)continue;const Ue=Ee.programConfigurations.get(d.id),nt=m.useProgram(Z?"fillExtrusionPattern":"fillExtrusion",Ue,De);if(m.terrain){const zt=m.terrain;if(m.style.terrainSetForDrapingOnly())zt.setupElevationDraw(ze,nt,{useMeterToDem:!0});else{if(!Ee.enableTerrain)continue;if(zt.setupElevationDraw(ze,nt,{useMeterToDem:!0}),Ll(k,o,Se,Ee,d,zt),!Ee.centroidVertexBuffer){const St=nt.attributes.a_centroid_pos;St!==void 0&&O.vertexAttrib2f(St,0,0)}}}Z&&(m.context.activeTexture.set(O.TEXTURE0),ze.imageAtlasTexture.bind(O.LINEAR,O.CLAMP_TO_EDGE),Ue.updatePaintBuffers(se));const lt=G.constantOr(null);if(lt&&ze.imageAtlas){const zt=ze.imageAtlas,St=zt.patternPositions[lt.to.toString()],Jt=zt.patternPositions[lt.from.toString()];St&&Jt&&Ue.setConstantPatternPositions(St,Jt)}const pt=m.translatePosMatrix(Se.projMatrix,ze,d.paint.get("fill-extrusion-translate"),d.paint.get("fill-extrusion-translate-anchor")),ht=U.projection.createInversionMatrix(U,Se.canonical),kt=d.paint.get("fill-extrusion-vertical-gradient"),it=Z?Mu(pt,m,kt,de,Se,se,ze,ce,Le,ve,ht):wu(pt,m,kt,de,Se,ce,Le,ve,ht);m.prepareDrawProgram(k,nt,Se.toUnwrapped()),nt.draw(k,k.gl.TRIANGLES,E,C,S,r.CullFaceMode.backCCW,it,d.id,Ee.layoutVertexBuffer,Ee.indexBuffer,Ee.segments,d.paint,m.transform.zoom,Ue,m.terrain?Ee.centroidVertexBuffer:null,te?Ee.layoutVertexExtBuffer:null)}}function Ll(m,o,d,y,E,C){const S=[ve=>{let De=ve.canonical.x-1,Se=ve.wrap;return De<0&&(De=(1<<ve.canonical.z)-1,Se--),new r.OverscaledTileID(ve.overscaledZ,Se,ve.canonical.z,De,ve.canonical.y)},ve=>{let De=ve.canonical.x+1,Se=ve.wrap;return De===1<<ve.canonical.z&&(De=0,Se++),new r.OverscaledTileID(ve.overscaledZ,Se,ve.canonical.z,De,ve.canonical.y)},ve=>new r.OverscaledTileID(ve.overscaledZ,ve.wrap,ve.canonical.z,ve.canonical.x,(ve.canonical.y===0?1<<ve.canonical.z:ve.canonical.y)-1),ve=>new r.OverscaledTileID(ve.overscaledZ,ve.wrap,ve.canonical.z,ve.canonical.x,ve.canonical.y===(1<<ve.canonical.z)-1?0:ve.canonical.y+1)],k=ve=>{const De=o.getSource().minzoom,Se=Ee=>{const Ue=o.getTileByID(Ee);if(Ue&&Ue.hasData())return Ue.getBucket(E)},ze=[0,-1,1];for(const Ee of ze){if(ve.overscaledZ+Ee<De)continue;const Ue=Se(ve.calculateScaledKey(ve.overscaledZ+Ee));if(Ue)return Ue}},O=[0,0,0],U=(ve,De)=>(O[0]=Math.min(ve.min.y,De.min.y),O[1]=Math.max(ve.max.y,De.max.y),O[2]=r.EXTENT-De.min.x>ve.max.x?De.min.x-r.EXTENT:ve.max.x,O),G=(ve,De)=>(O[0]=Math.min(ve.min.x,De.min.x),O[1]=Math.max(ve.max.x,De.max.x),O[2]=r.EXTENT-De.min.y>ve.max.y?De.min.y-r.EXTENT:ve.max.y,O),Z=[(ve,De)=>U(ve,De),(ve,De)=>U(De,ve),(ve,De)=>G(ve,De),(ve,De)=>G(De,ve)],se=new r.pointGeometry(0,0);let de,ce,te;const Le=(ve,De,Se,ze,Ee)=>{const Ue=[[ze?Se:ve,ze?ve:Se,0],[ze?Se:De,ze?De:Se,0]],nt=Ee<0?r.EXTENT+Ee:Ee,lt=[ze?nt:(ve+De)/2,ze?(ve+De)/2:nt,0];return Se===0&&Ee<0||Se!==0&&Ee>0?C.getForTilePoints(te,[lt],!0,ce):Ue.push(lt),C.getForTilePoints(d,Ue,!0,de),Math.max(Ue[0][2],Ue[1][2],lt[2])/C.exaggeration()};for(let ve=0;ve<4;ve++){const De=(ve<2?1:5)-ve,Se=y.borders[ve];if(Se.length===0)continue;const ze=te=S[ve](d),Ee=k(ze);if(!(Ee&&Ee instanceof r.FillExtrusionBucket&&Ee.enableTerrain)||y.borderDoneWithNeighborZ[ve]===Ee.canonical.z&&Ee.borderDoneWithNeighborZ[De]===y.canonical.z||(ce=C.findDEMTileFor(ze),!ce||!ce.dem))continue;if(!de){const pt=C.findDEMTileFor(d);if(!pt||!pt.dem)return;de=pt}const Ue=Ee.borders[De];let nt=0;const lt=Ee.borderDoneWithNeighborZ[De]!==y.canonical.z;if(y.canonical.z===Ee.canonical.z){for(let pt=0;pt<Se.length;pt++){const ht=y.featuresOnBorder[Se[pt]],kt=ht.borders[ve];let it;for(;nt<Ue.length&&(it=Ee.featuresOnBorder[Ue[nt]],!(it.borders[De][1]>kt[0]+3));)lt&&Ee.encodeCentroid(void 0,it,!1),nt++;if(it&&nt<Ue.length){const zt=nt;let St=0;for(;!(it.borders[De][0]>kt[1]-3)&&(St++,++nt!==Ue.length);)it=Ee.featuresOnBorder[Ue[nt]];if(it=Ee.featuresOnBorder[Ue[zt]],ht.intersectsCount()>1||it.intersectsCount()>1||St!==1){St!==1&&(nt=zt),y.encodeCentroid(void 0,ht,!1),lt&&Ee.encodeCentroid(void 0,it,!1);continue}const Jt=Z[ve](ht,it),ft=ve%2?r.EXTENT-1:0;se.x=Le(Jt[0],Math.min(r.EXTENT-1,Jt[1]),ft,ve<2,Jt[2]),se.y=0,y.encodeCentroid(se,ht,!1),lt&&Ee.encodeCentroid(se,it,!1)}else y.encodeCentroid(void 0,ht,!1)}y.borderDoneWithNeighborZ[ve]=Ee.canonical.z,y.needsCentroidUpdate=!0,lt&&(Ee.borderDoneWithNeighborZ[De]=y.canonical.z,Ee.needsCentroidUpdate=!0)}else{for(const pt of Se)y.encodeCentroid(void 0,y.featuresOnBorder[pt],!1);if(lt){for(const pt of Ue)Ee.encodeCentroid(void 0,Ee.featuresOnBorder[pt],!1);Ee.borderDoneWithNeighborZ[De]=y.canonical.z,Ee.needsCentroidUpdate=!0}y.borderDoneWithNeighborZ[ve]=Ee.canonical.z,y.needsCentroidUpdate=!0}}(y.needsCentroidUpdate||!y.centroidVertexBuffer&&y.centroidVertexArray.length!==0)&&y.uploadCentroid(m)}const Hd=new r.Color(1,0,0,1),$d=new r.Color(0,1,0,1),Zm=new r.Color(0,0,1,1),Pu=new r.Color(1,0,1,1),Su=new r.Color(0,1,1,1);function jt(m,o,d,y){Il(m,0,o+d/2,m.transform.width,d,y)}function $r(m,o,d,y){Il(m,o-d/2,0,d,m.transform.height,y)}function Il(m,o,d,y,E,C){const S=m.context,k=S.gl;k.enable(k.SCISSOR_TEST),k.scissor(o*r.exported.devicePixelRatio,d*r.exported.devicePixelRatio,y*r.exported.devicePixelRatio,E*r.exported.devicePixelRatio),S.clear({color:C}),k.disable(k.SCISSOR_TEST)}function Ym(m,o,d){const y=m.context,E=y.gl,C=m.transform.projection.name==="globe",S=d.projMatrix,k=m.useProgram("debug",null,C?["PROJECTION_GLOBE_VIEW"]:null),O=o.getTileByID(d.key);m.terrain&&m.terrain.setupElevationDraw(O,k);const U=r.DepthMode.disabled,G=r.StencilMode.disabled,Z=m.colorModeForRenderPass(),se="$debug";y.activeTexture.set(E.TEXTURE0),m.emptyTexture.bind(E.LINEAR,E.CLAMP_TO_EDGE),C?O._makeGlobeTileDebugBuffers(m.context,m.transform.projection):O._makeDebugTileBoundsBuffers(m.context,m.transform.projection);const de=O._tileDebugBuffer||m.debugBuffer,ce=O._tileDebugIndexBuffer||m.debugIndexBuffer,te=O._tileDebugSegments||m.debugSegments;k.draw(y,E.LINE_STRIP,U,G,Z,r.CullFaceMode.disabled,jm(S,r.Color.red),se,de,ce,te,null,null,null,O._globeTileDebugBorderBuffer);const Le=O.latestRawTileData,ve=Math.floor((Le&&Le.byteLength||0)/1024),De=o.getTile(d).tileSize,Se=512/Math.min(De,512)*(d.overscaledZ/m.transform.zoom)*.5;let ze=d.canonical.toString();d.overscaledZ!==d.canonical.z&&(ze+=` => ${d.overscaledZ}`),function(lt,pt){lt.initDebugOverlayCanvas();const ht=lt.debugOverlayCanvas,kt=lt.context.gl,it=lt.debugOverlayCanvas.getContext("2d");it.clearRect(0,0,ht.width,ht.height),it.shadowColor="white",it.shadowBlur=2,it.lineWidth=1.5,it.strokeStyle="white",it.textBaseline="top",it.font="bold 36px Open Sans, sans-serif",it.fillText(pt,5,5),it.strokeText(pt,5,5),lt.debugOverlayTexture.update(ht),lt.debugOverlayTexture.bind(kt.LINEAR,kt.CLAMP_TO_EDGE)}(m,`${ze} ${ve}kb`);const Ee=O._tileDebugTextBuffer||m.debugBuffer,Ue=O._tileDebugTextIndexBuffer||m.quadTriangleIndexBuffer,nt=O._tileDebugTextSegments||m.debugSegments;k.draw(y,E.TRIANGLES,U,G,r.ColorMode.alphaBlended,r.CullFaceMode.disabled,jm(S,r.Color.transparent,Se),se,Ee,Ue,nt,null,null,null,O._globeTileDebugTextBuffer)}const Km=r.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Ps}=Km;function Bo(m,o,d,y){m.emplaceBack(o,d,y)}class Rl{constructor(o){this.vertexArray=new r.StructArrayLayout3f12,this.indices=new r.StructArrayLayout3ui6,Bo(this.vertexArray,-1,-1,1),Bo(this.vertexArray,1,-1,1),Bo(this.vertexArray,-1,1,1),Bo(this.vertexArray,1,1,1),Bo(this.vertexArray,-1,-1,-1),Bo(this.vertexArray,1,-1,-1),Bo(this.vertexArray,-1,1,-1),Bo(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=o.createVertexBuffer(this.vertexArray,Ps),this.indexBuffer=o.createIndexBuffer(this.indices),this.segment=r.SegmentVector.simpleSegment(0,0,36,12)}}function la(m,o,d,y,E,C){const S=m.gl,k=o.paint.get("sky-atmosphere-color"),O=o.paint.get("sky-atmosphere-halo-color"),U=o.paint.get("sky-atmosphere-sun-intensity"),G=((Z,se,de,ce,te)=>({u_matrix_3f:Z,u_sun_direction:se,u_sun_intensity:de,u_color_tint_r:[ce.r,ce.g,ce.b,ce.a],u_color_tint_m:[te.r,te.g,te.b,te.a],u_luminance:5e-5}))(r.fromMat4(r.create$1(),y),E,U,k,O);S.framebufferTexture2D(S.FRAMEBUFFER,S.COLOR_ATTACHMENT0,S.TEXTURE_CUBE_MAP_POSITIVE_X+C,o.skyboxTexture,0),d.draw(m,S.TRIANGLES,r.DepthMode.disabled,r.StencilMode.disabled,r.ColorMode.unblended,r.CullFaceMode.frontCW,G,"skyboxCapture",o.skyboxGeometry.vertexBuffer,o.skyboxGeometry.indexBuffer,o.skyboxGeometry.segment)}function ca(m,o){return r.transformMat4(m,m,o)}const qd={symbol:function(m,o,d,y,E){if(m.renderPass!=="translucent")return;const C=r.StencilMode.disabled,S=m.colorModeForRenderPass();d.layout.get("text-variable-anchor")&&function(k,O,U,G,Z,se,de){const ce=O.transform,te=Z==="map",Le=se==="map";for(const ve of k){const De=G.getTile(ve),Se=De.getBucket(U);if(!Se||Se.projection!==ce.projection.name||!Se.text||!Se.text.segments.get().length)continue;const ze=r.evaluateSizeForZoom(Se.textSizeData,ce.zoom),Ee=O.transform.calculatePixelsToTileUnitsMatrix(De),Ue=di(ve.projMatrix,De.tileID.canonical,Le,te,O.transform,Ee),nt=U.layout.get("icon-text-fit")!=="none"&&Se.hasIconData();if(ze){const lt=Math.pow(2,ce.zoom-De.tileID.overscaledZ);iv(Se,te,Le,de,r.symbolSize,ce,Ue,ve,lt,ze,nt,ce.projection)}}}(y,m,d,o,d.layout.get("text-rotation-alignment"),d.layout.get("text-pitch-alignment"),E),d.paint.get("icon-opacity").constantOr(1)!==0&&jd(m,o,d,y,!1,d.paint.get("icon-translate"),d.paint.get("icon-translate-anchor"),d.layout.get("icon-rotation-alignment"),d.layout.get("icon-pitch-alignment"),d.layout.get("icon-keep-upright"),C,S),d.paint.get("text-opacity").constantOr(1)!==0&&jd(m,o,d,y,!0,d.paint.get("text-translate"),d.paint.get("text-translate-anchor"),d.layout.get("text-rotation-alignment"),d.layout.get("text-pitch-alignment"),d.layout.get("text-keep-upright"),C,S),o.map.showCollisionBoxes&&(qm(m,o,d,y,d.paint.get("text-translate"),d.paint.get("text-translate-anchor"),!0),qm(m,o,d,y,d.paint.get("icon-translate"),d.paint.get("icon-translate-anchor"),!1))},circle:function(m,o,d,y){if(m.renderPass!=="translucent")return;const E=d.paint.get("circle-opacity"),C=d.paint.get("circle-stroke-width"),S=d.paint.get("circle-stroke-opacity"),k=d.layout.get("circle-sort-key").constantOr(1)!==void 0;if(E.constantOr(1)===0&&(C.constantOr(1)===0||S.constantOr(1)===0))return;const O=m.context,U=O.gl,G=m.transform,Z=m.depthModeForSublayer(0,r.DepthMode.ReadOnly),se=r.StencilMode.disabled,de=m.colorModeForRenderPass(),ce=G.projection.name==="globe",te=[r.mercatorXfromLng(G.center.lng),r.mercatorYfromLat(G.center.lat)],Le=[];for(let De=0;De<y.length;De++){const Se=y[De],ze=o.getTile(Se),Ee=ze.getBucket(d);if(!Ee)continue;const Ue=Ee.programConfigurations.get(d.id),nt=J_(d);ce&&nt.push("PROJECTION_GLOBE_VIEW");const lt=m.useProgram("circle",Ue,nt),pt=Ee.layoutVertexBuffer,ht=Ee.globeExtVertexBuffer,kt=Ee.indexBuffer,it=G.projection.createInversionMatrix(G,Se.canonical),zt={programConfiguration:Ue,program:lt,layoutVertexBuffer:pt,globeExtVertexBuffer:ht,indexBuffer:kt,uniformValues:Cs(m,Se,ze,it,te,d),tile:ze};if(k){const St=Ee.segments.get();for(const Jt of St)Le.push({segments:new r.SegmentVector([Jt]),sortKey:Jt.sortKey,state:zt})}else Le.push({segments:Ee.segments,sortKey:0,state:zt})}k&&Le.sort((De,Se)=>De.sortKey-Se.sortKey);const ve={useDepthForOcclusion:!ce};for(const De of Le){const{programConfiguration:Se,program:ze,layoutVertexBuffer:Ee,globeExtVertexBuffer:Ue,indexBuffer:nt,uniformValues:lt,tile:pt}=De.state,ht=De.segments;m.terrain&&m.terrain.setupElevationDraw(pt,ze,ve),m.prepareDrawProgram(O,ze,pt.tileID.toUnwrapped()),ze.draw(O,U.TRIANGLES,Z,se,de,r.CullFaceMode.disabled,lt,d.id,Ee,nt,ht,d.paint,G.zoom,Se,ce?Ue:null)}},heatmap:function(m,o,d,y){if(d.paint.get("heatmap-opacity")!==0)if(m.renderPass==="offscreen"){const E=m.context,C=E.gl,S=r.StencilMode.disabled,k=new r.ColorMode([C.ONE,C.ONE],r.Color.transparent,[!0,!0,!0,!0]);(function(se,de,ce){const te=se.gl;se.activeTexture.set(te.TEXTURE1),se.viewport.set([0,0,de.width/4,de.height/4]);let Le=ce.heatmapFbo;if(Le)te.bindTexture(te.TEXTURE_2D,Le.colorAttachment.get()),se.bindFramebuffer.set(Le.framebuffer);else{const ve=te.createTexture();te.bindTexture(te.TEXTURE_2D,ve),te.texParameteri(te.TEXTURE_2D,te.TEXTURE_WRAP_S,te.CLAMP_TO_EDGE),te.texParameteri(te.TEXTURE_2D,te.TEXTURE_WRAP_T,te.CLAMP_TO_EDGE),te.texParameteri(te.TEXTURE_2D,te.TEXTURE_MIN_FILTER,te.LINEAR),te.texParameteri(te.TEXTURE_2D,te.TEXTURE_MAG_FILTER,te.LINEAR),Le=ce.heatmapFbo=se.createFramebuffer(de.width/4,de.height/4,!1),function(De,Se,ze,Ee){const Ue=De.gl;Ue.texImage2D(Ue.TEXTURE_2D,0,Ue.RGBA,Se.width/4,Se.height/4,0,Ue.RGBA,De.extRenderToTextureHalfFloat?De.extTextureHalfFloat.HALF_FLOAT_OES:Ue.UNSIGNED_BYTE,null),Ee.colorAttachment.set(ze)}(se,de,ve,Le)}})(E,m,d),E.clear({color:r.Color.transparent});const O=m.transform,U=O.projection.name==="globe",G=U?["PROJECTION_GLOBE_VIEW"]:null,Z=[r.mercatorXfromLng(O.center.lng),r.mercatorYfromLat(O.center.lat)];for(let se=0;se<y.length;se++){const de=y[se];if(o.hasRenderableParent(de))continue;const ce=o.getTile(de),te=ce.getBucket(d);if(!te)continue;const Le=te.programConfigurations.get(d.id),ve=m.useProgram("heatmap",Le,G),{zoom:De}=m.transform;m.terrain&&m.terrain.setupElevationDraw(ce,ve),m.prepareDrawProgram(E,ve,de.toUnwrapped());const Se=O.projection.createInversionMatrix(O,de.canonical);ve.draw(E,C.TRIANGLES,r.DepthMode.disabled,S,k,r.CullFaceMode.disabled,tv(m,de,ce,Se,Z,De,d.paint.get("heatmap-intensity")),d.id,te.layoutVertexBuffer,te.indexBuffer,te.segments,d.paint,m.transform.zoom,Le,U?te.globeExtVertexBuffer:null)}E.viewport.set([0,0,m.width,m.height])}else m.renderPass==="translucent"&&(m.context.setColorMode(m.colorModeForRenderPass()),function(E,C){const S=E.context,k=S.gl,O=C.heatmapFbo;if(!O)return;S.activeTexture.set(k.TEXTURE0),k.bindTexture(k.TEXTURE_2D,O.colorAttachment.get()),S.activeTexture.set(k.TEXTURE1);let U=C.colorRampTexture;U||(U=C.colorRampTexture=new r.Texture(S,C.colorRamp,k.RGBA)),U.bind(k.LINEAR,k.CLAMP_TO_EDGE),E.useProgram("heatmapTexture").draw(S,k.TRIANGLES,r.DepthMode.disabled,r.StencilMode.disabled,E.colorModeForRenderPass(),r.CullFaceMode.disabled,((G,Z,se,de)=>({u_image:0,u_color_ramp:1,u_opacity:Z.paint.get("heatmap-opacity")}))(0,C),C.id,E.viewportBuffer,E.quadTriangleIndexBuffer,E.viewportSegments,C.paint,E.transform.zoom)}(m,d))},line:function(m,o,d,y){if(m.renderPass!=="translucent")return;const E=d.paint.get("line-opacity"),C=d.paint.get("line-width");if(E.constantOr(1)===0||C.constantOr(1)===0)return;const S=m.depthModeForSublayer(0,r.DepthMode.ReadOnly),k=m.colorModeForRenderPass(),O=m.terrain&&m.terrain.renderingToTexture?1:r.exported.devicePixelRatio,U=d.paint.get("line-dasharray"),G=U.constantOr(1),Z=d.layout.get("line-cap"),se=d.paint.get("line-pattern"),de=se.constantOr(1),ce=d.paint.get("line-gradient"),te=d.getCrossfadeParameters(),Le=de?"linePattern":"line",ve=m.context,De=ve.gl,Se=(Ee=>{const Ue=[];Nd(Ee)&&Ue.push("RENDER_LINE_DASH"),Ee.paint.get("line-gradient")&&Ue.push("RENDER_LINE_GRADIENT");const nt=Ee.paint.get("line-pattern").constantOr(1),lt=Ee.paint.get("line-opacity").constantOr(1)!==1;return!nt&<&&Ue.push("RENDER_LINE_ALPHA_DISCARD"),Ue})(d);let ze=Se.includes("RENDER_LINE_ALPHA_DISCARD");m.terrain&&m.terrain.clipOrMaskOverlapStencilType()&&(ze=!1);for(const Ee of y){const Ue=o.getTile(Ee);if(de&&!Ue.patternsLoaded())continue;const nt=Ue.getBucket(d);if(!nt)continue;m.prepareDrawTile();const lt=nt.programConfigurations.get(d.id),pt=m.useProgram(Le,lt,Se),ht=se.constantOr(null);if(ht&&Ue.imageAtlas){const ft=Ue.imageAtlas,qt=ft.patternPositions[ht.to.toString()],gn=ft.patternPositions[ht.from.toString()];qt&&gn&<.setConstantPatternPositions(qt,gn)}const kt=U.constantOr(null),it=Z.constantOr(null);if(!de&&kt&&it&&Ue.lineAtlas){const ft=Ue.lineAtlas,qt=ft.getDash(kt.to,it),gn=ft.getDash(kt.from,it);qt&&gn&<.setConstantPatternPositions(qt,gn)}const zt=m.terrain?Ee.projMatrix:null,St=de?Od(m,Ue,d,te,zt,O):nv(m,Ue,d,te,zt,nt.lineClipsArray.length,O);if(ce){const ft=nt.gradients[d.id];let qt=ft.texture;if(d.gradientVersion!==ft.version){let gn=256;if(d.stepInterpolant){const Zt=o.getSource().maxzoom,Yt=Ee.canonical.z===Zt?Math.ceil(1<<m.transform.maxZoom-Ee.canonical.z):1;gn=r.clamp(r.nextPowerOfTwo(nt.maxLineLength/r.EXTENT*1024*Yt),256,ve.maxTextureSize)}ft.gradient=r.renderColorRamp({expression:d.gradientExpression(),evaluationKey:"lineProgress",resolution:gn,image:ft.gradient||void 0,clips:nt.lineClipsArray}),ft.texture?ft.texture.update(ft.gradient):ft.texture=new r.Texture(ve,ft.gradient,De.RGBA),ft.version=d.gradientVersion,qt=ft.texture}ve.activeTexture.set(De.TEXTURE1),qt.bind(d.stepInterpolant?De.NEAREST:De.LINEAR,De.CLAMP_TO_EDGE)}G&&(ve.activeTexture.set(De.TEXTURE0),Ue.lineAtlasTexture.bind(De.LINEAR,De.REPEAT),lt.updatePaintBuffers(te)),de&&(ve.activeTexture.set(De.TEXTURE0),Ue.imageAtlasTexture.bind(De.LINEAR,De.CLAMP_TO_EDGE),lt.updatePaintBuffers(te)),m.prepareDrawProgram(ve,pt,Ee.toUnwrapped());const Jt=ft=>{pt.draw(ve,De.TRIANGLES,S,ft,k,r.CullFaceMode.disabled,St,d.id,nt.layoutVertexBuffer,nt.indexBuffer,nt.segments,d.paint,m.transform.zoom,lt,nt.layoutVertexBuffer2)};if(ze){const ft=m.stencilModeForClipping(Ee).ref;ft===0&&m.terrain&&ve.clear({stencil:0});const qt={func:De.EQUAL,mask:255};St.u_alpha_discard_threshold=.8,Jt(new r.StencilMode(qt,ft,255,De.KEEP,De.KEEP,De.INVERT)),St.u_alpha_discard_threshold=0,Jt(new r.StencilMode(qt,ft,255,De.KEEP,De.KEEP,De.KEEP))}else Jt(m.stencilModeForClipping(Ee))}ze&&(m.resetStencilClippingMasks(),m.terrain&&ve.clear({stencil:0}))},fill:function(m,o,d,y){const E=d.paint.get("fill-color"),C=d.paint.get("fill-opacity");if(C.constantOr(1)===0)return;const S=m.colorModeForRenderPass(),k=d.paint.get("fill-pattern"),O=m.opaquePassEnabledForLayer()&&!k.constantOr(1)&&E.constantOr(r.Color.transparent).a===1&&C.constantOr(0)===1?"opaque":"translucent";if(m.renderPass===O){const U=m.depthModeForSublayer(1,m.renderPass==="opaque"?r.DepthMode.ReadWrite:r.DepthMode.ReadOnly);Du(m,o,d,y,U,S,!1)}if(m.renderPass==="translucent"&&d.paint.get("fill-antialias")){const U=m.depthModeForSublayer(d.getPaintProperty("fill-outline-color")?2:0,r.DepthMode.ReadOnly);Du(m,o,d,y,U,S,!0)}},"fill-extrusion":function(m,o,d,y){const E=d.paint.get("fill-extrusion-opacity");if(E!==0&&m.renderPass==="translucent"){const C=new r.DepthMode(m.context.gl.LEQUAL,r.DepthMode.ReadWrite,m.depthRangeFor3D);if(E!==1||d.paint.get("fill-extrusion-pattern").constantOr(1))Ds(m,o,d,y,C,r.StencilMode.disabled,r.ColorMode.disabled),Ds(m,o,d,y,C,m.stencilModeFor3D(),m.colorModeForRenderPass()),m.resetStencilClippingMasks();else{const S=m.colorModeForRenderPass();Ds(m,o,d,y,C,r.StencilMode.disabled,S)}}},hillshade:function(m,o,d,y){if(m.renderPass!=="offscreen"&&m.renderPass!=="translucent")return;const E=m.context,C=m.depthModeForSublayer(0,r.DepthMode.ReadOnly),S=m.colorModeForRenderPass(),k=m.terrain&&m.terrain.renderingToTexture,[O,U]=m.renderPass!=="translucent"||k?[{},y]:m.stencilConfigForOverlap(y);for(const G of U){const Z=o.getTile(G);if(Z.needsHillshadePrepare&&m.renderPass==="offscreen")Id(m,Z,d,C,r.StencilMode.disabled,S);else if(m.renderPass==="translucent"){const se=k&&m.terrain?m.terrain.stencilModeForRTTOverlap(G):O[G.overscaledZ];Nm(m,G,Z,d,C,se,S)}}E.viewport.set([0,0,m.width,m.height]),m.resetStencilClippingMasks()},raster:function(m,o,d,y,E,C){if(m.renderPass!=="translucent"||d.paint.get("raster-opacity")===0||!y.length)return;const S=m.context,k=S.gl,O=o.getSource(),U=m.useProgram("raster"),G=m.colorModeForRenderPass(),Z=m.terrain&&m.terrain.renderingToTexture,[se,de]=O instanceof je||Z?[{},y]:m.stencilConfigForOverlap(y),ce=de[de.length-1].overscaledZ,te=!m.options.moving;for(const Le of de){const ve=Z?r.DepthMode.disabled:m.depthModeForSublayer(Le.overscaledZ-ce,d.paint.get("raster-opacity")===1?r.DepthMode.ReadWrite:r.DepthMode.ReadOnly,k.LESS),De=Le.toUnwrapped(),Se=o.getTile(Le);if(Z&&(!Se||!Se.hasData()))continue;const ze=Z?Le.projMatrix:m.transform.calculateProjMatrix(De,te),Ee=m.terrain&&Z?m.terrain.stencilModeForRTTOverlap(Le):se[Le.overscaledZ],Ue=C?0:d.paint.get("raster-fade-duration");Se.registerFadeDuration(Ue);const nt=o.findLoadedParent(Le,0),lt=zd(Se,nt,o,m.transform,Ue);let pt,ht;m.terrain&&m.terrain.prepareDrawTile();const kt=d.paint.get("raster-resampling")==="nearest"?k.NEAREST:k.LINEAR;S.activeTexture.set(k.TEXTURE0),Se.texture.bind(kt,k.CLAMP_TO_EDGE),S.activeTexture.set(k.TEXTURE1),nt?(nt.texture.bind(kt,k.CLAMP_TO_EDGE),pt=Math.pow(2,nt.tileID.overscaledZ-Se.tileID.overscaledZ),ht=[Se.tileID.canonical.x*pt%1,Se.tileID.canonical.y*pt%1]):Se.texture.bind(kt,k.CLAMP_TO_EDGE);const it=Hm(ze,ht||[0,0],pt||1,lt,d,O instanceof je?O.perspectiveTransform:[0,0]);if(m.prepareDrawProgram(S,U,De),O instanceof je)O.boundsBuffer&&O.boundsSegments&&U.draw(S,k.TRIANGLES,ve,r.StencilMode.disabled,G,r.CullFaceMode.disabled,it,d.id,O.boundsBuffer,m.quadTriangleIndexBuffer,O.boundsSegments);else{const{tileBoundsBuffer:zt,tileBoundsIndexBuffer:St,tileBoundsSegments:Jt}=m.getTileBoundsBuffers(Se);U.draw(S,k.TRIANGLES,ve,Ee,G,r.CullFaceMode.disabled,it,d.id,zt,St,Jt)}}m.resetStencilClippingMasks()},background:function(m,o,d,y){const E=d.paint.get("background-color"),C=d.paint.get("background-opacity");if(C===0)return;const S=m.context,k=S.gl,O=m.transform,U=O.tileSize,G=d.paint.get("background-pattern");if(m.isPatternMissing(G))return;const Z=!G&&E.a===1&&C===1&&m.opaquePassEnabledForLayer()?"opaque":"translucent";if(m.renderPass!==Z)return;const se=r.StencilMode.disabled,de=m.depthModeForSublayer(0,Z==="opaque"?r.DepthMode.ReadWrite:r.DepthMode.ReadOnly),ce=m.colorModeForRenderPass(),te=m.useProgram(G?"backgroundPattern":"background");let Le,ve=y;ve||(Le=m.getBackgroundTiles(),ve=Object.values(Le).map(Se=>Se.tileID)),G&&(S.activeTexture.set(k.TEXTURE0),m.imageManager.bind(m.context));const De=d.getCrossfadeParameters();for(const Se of ve){const ze=Se.toUnwrapped(),Ee=y?Se.projMatrix:m.transform.calculateProjMatrix(ze);m.prepareDrawTile();const Ue=o?o.getTile(Se):Le?Le[Se.key]:new r.Tile(Se,U,O.zoom,m),nt=G?Gd(Ee,C,m,G,{tileID:Se,tileSize:U},De):$m(Ee,C,E);m.prepareDrawProgram(S,te,ze);const{tileBoundsBuffer:lt,tileBoundsIndexBuffer:pt,tileBoundsSegments:ht}=m.getTileBoundsBuffers(Ue);te.draw(S,k.TRIANGLES,de,se,ce,r.CullFaceMode.disabled,nt,d.id,lt,pt,ht)}},sky:function(m,o,d){const y=m.transform,E=y.projection.name==="mercator"||y.projection.name==="globe"?1:r.smoothstep(7,8,y.zoom),C=d.paint.get("sky-opacity")*E;if(C===0)return;const S=m.context,k=d.paint.get("sky-type"),O=new r.DepthMode(S.gl.LEQUAL,r.DepthMode.ReadOnly,[0,1]),U=m.frameCounter/1e3%1;k==="atmosphere"?m.renderPass==="offscreen"?d.needsSkyboxCapture(m)&&(function(G,Z,se,de){const ce=G.context,te=ce.gl;let Le=Z.skyboxFbo;if(!Le){Le=Z.skyboxFbo=ce.createFramebuffer(32,32,!1),Z.skyboxGeometry=new Rl(ce),Z.skyboxTexture=ce.gl.createTexture(),te.bindTexture(te.TEXTURE_CUBE_MAP,Z.skyboxTexture),te.texParameteri(te.TEXTURE_CUBE_MAP,te.TEXTURE_WRAP_S,te.CLAMP_TO_EDGE),te.texParameteri(te.TEXTURE_CUBE_MAP,te.TEXTURE_WRAP_T,te.CLAMP_TO_EDGE),te.texParameteri(te.TEXTURE_CUBE_MAP,te.TEXTURE_MIN_FILTER,te.LINEAR),te.texParameteri(te.TEXTURE_CUBE_MAP,te.TEXTURE_MAG_FILTER,te.LINEAR);for(let ze=0;ze<6;++ze)te.texImage2D(te.TEXTURE_CUBE_MAP_POSITIVE_X+ze,0,te.RGBA,32,32,0,te.RGBA,te.UNSIGNED_BYTE,null)}ce.bindFramebuffer.set(Le.framebuffer),ce.viewport.set([0,0,32,32]);const ve=Z.getCenter(G,!0),De=G.useProgram("skyboxCapture"),Se=new Float64Array(16);r.identity(Se),r.rotateY(Se,Se,.5*-Math.PI),la(ce,Z,De,Se,ve,0),r.identity(Se),r.rotateY(Se,Se,.5*Math.PI),la(ce,Z,De,Se,ve,1),r.identity(Se),r.rotateX(Se,Se,.5*-Math.PI),la(ce,Z,De,Se,ve,2),r.identity(Se),r.rotateX(Se,Se,.5*Math.PI),la(ce,Z,De,Se,ve,3),r.identity(Se),la(ce,Z,De,Se,ve,4),r.identity(Se),r.rotateY(Se,Se,Math.PI),la(ce,Z,De,Se,ve,5),ce.viewport.set([0,0,G.width,G.height])}(m,d),d.markSkyboxValid(m)):m.renderPass==="sky"&&function(G,Z,se,de,ce){const te=G.context,Le=te.gl,ve=G.transform,De=G.useProgram("skybox");te.activeTexture.set(Le.TEXTURE0),Le.bindTexture(Le.TEXTURE_CUBE_MAP,Z.skyboxTexture);const Se=((ze,Ee,Ue,nt,lt)=>({u_matrix:ze,u_sun_direction:Ee,u_cubemap:0,u_opacity:nt,u_temporal_offset:lt}))(ve.skyboxMatrix,Z.getCenter(G,!1),0,de,ce);G.prepareDrawProgram(te,De),De.draw(te,Le.TRIANGLES,se,r.StencilMode.disabled,G.colorModeForRenderPass(),r.CullFaceMode.backCW,Se,"skybox",Z.skyboxGeometry.vertexBuffer,Z.skyboxGeometry.indexBuffer,Z.skyboxGeometry.segment)}(m,d,O,C,U):k==="gradient"&&m.renderPass==="sky"&&function(G,Z,se,de,ce){const te=G.context,Le=te.gl,ve=G.transform,De=G.useProgram("skyboxGradient");Z.skyboxGeometry||(Z.skyboxGeometry=new Rl(te)),te.activeTexture.set(Le.TEXTURE0);let Se=Z.colorRampTexture;Se||(Se=Z.colorRampTexture=new r.Texture(te,Z.colorRamp,Le.RGBA)),Se.bind(Le.LINEAR,Le.CLAMP_TO_EDGE);const ze=((Ee,Ue,nt,lt,pt)=>({u_matrix:Ee,u_color_ramp:0,u_center_direction:Ue,u_radius:r.degToRad(nt),u_opacity:lt,u_temporal_offset:pt}))(ve.skyboxMatrix,Z.getCenter(G,!1),Z.paint.get("sky-gradient-radius"),de,ce);G.prepareDrawProgram(te,De),De.draw(te,Le.TRIANGLES,se,r.StencilMode.disabled,G.colorModeForRenderPass(),r.CullFaceMode.backCW,ze,"skyboxGradient",Z.skyboxGeometry.vertexBuffer,Z.skyboxGeometry.indexBuffer,Z.skyboxGeometry.segment)}(m,d,O,C,U)},debug:function(m,o,d){for(let y=0;y<d.length;y++)Ym(m,o,d[y])},custom:function(m,o,d){const y=m.context,E=d.implementation;if(m.transform.projection.unsupportedLayers&&m.transform.projection.unsupportedLayers.includes("custom"))r.warnOnce("Custom layers are not yet supported with non-mercator projections. Use mercator to enable custom layers.");else if(m.renderPass==="offscreen"){const C=E.prerender;C&&(m.setCustomLayerDefaults(),y.setColorMode(m.colorModeForRenderPass()),C.call(E,y.gl,m.transform.customLayerMatrix()),y.setDirty(),m.setBaseState())}else if(m.renderPass==="translucent"){m.setCustomLayerDefaults(),y.setColorMode(m.colorModeForRenderPass()),y.setStencilMode(r.StencilMode.disabled);const C=E.renderingMode==="3d"?new r.DepthMode(m.context.gl.LEQUAL,r.DepthMode.ReadWrite,m.depthRangeFor3D):m.depthModeForSublayer(0,r.DepthMode.ReadOnly);y.setDepthMode(C),E.render(y.gl,m.transform.customLayerMatrix()),y.setDirty(),m.setBaseState(),y.bindFramebuffer.set(null)}}};class Jm{constructor(o,d){this.context=new $(o),this.transform=d,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=r.SourceCache.maxUnderzooming+r.SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new gu,this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this._tileClippingMaskIDs=new Map,this._skippedStencilTileIDs=new Set}updateTerrain(o,d){const y=!!o&&!!o.terrain&&this.transform.projection.supportsTerrain;if(!(y||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new Lr(this,o));const E=this._terrain;this.transform.elevation=y?E:null,E.update(o,this.transform,d)}_updateFog(o){const d=o.fog;if(!d||d.getOpacity(this.transform.pitch)<1||d.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[y,E]=d.getFovAdjustedRange(this.transform._fov);if(y>E)return void(this.transform.fogCullDistSq=null);const C=y+.78*(E-y);this.transform.fogCullDistSq=C*C}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(o,d){if(this.width=o*r.exported.devicePixelRatio,this.height=d*r.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const y of this.style.order)this.style._layers[y].resize()}setup(){const o=this.context,d=new r.StructArrayLayout2i4;d.emplaceBack(0,0),d.emplaceBack(r.EXTENT,0),d.emplaceBack(0,r.EXTENT),d.emplaceBack(r.EXTENT,r.EXTENT),this.tileExtentBuffer=o.createVertexBuffer(d,r.posAttributes.members),this.tileExtentSegments=r.SegmentVector.simpleSegment(0,0,4,2);const y=new r.StructArrayLayout2i4;y.emplaceBack(0,0),y.emplaceBack(r.EXTENT,0),y.emplaceBack(0,r.EXTENT),y.emplaceBack(r.EXTENT,r.EXTENT),this.debugBuffer=o.createVertexBuffer(y,r.posAttributes.members),this.debugSegments=r.SegmentVector.simpleSegment(0,0,4,5);const E=new r.StructArrayLayout2i4;E.emplaceBack(-1,-1),E.emplaceBack(1,-1),E.emplaceBack(-1,1),E.emplaceBack(1,1),this.viewportBuffer=o.createVertexBuffer(E,r.posAttributes.members),this.viewportSegments=r.SegmentVector.simpleSegment(0,0,4,2);const C=new r.StructArrayLayout4i8;C.emplaceBack(0,0,0,0),C.emplaceBack(r.EXTENT,0,r.EXTENT,0),C.emplaceBack(0,r.EXTENT,0,r.EXTENT),C.emplaceBack(r.EXTENT,r.EXTENT,r.EXTENT,r.EXTENT),this.mercatorBoundsBuffer=o.createVertexBuffer(C,r.boundsAttributes.members),this.mercatorBoundsSegments=r.SegmentVector.simpleSegment(0,0,4,2);const S=new r.StructArrayLayout3ui6;S.emplaceBack(0,1,2),S.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=o.createIndexBuffer(S);const k=new r.StructArrayLayout1ui2;for(const U of[0,1,3,2,0])k.emplaceBack(U);this.debugIndexBuffer=o.createIndexBuffer(k),this.emptyTexture=new r.Texture(o,new r.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),o.gl.RGBA),this.identityMat=r.create();const O=this.context.gl;this.stencilClearMode=new r.StencilMode({func:O.ALWAYS,mask:0},0,255,O.ZERO,O.ZERO,O.ZERO),this.loadTimeStamps.push(r.window.performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(o){return o._makeTileBoundsBuffers(this.context,this.transform.projection),o._tileBoundsBuffer?{tileBoundsBuffer:o._tileBoundsBuffer,tileBoundsIndexBuffer:o._tileBoundsIndexBuffer,tileBoundsSegments:o._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const o=this.context,d=o.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear(),this.useProgram("clippingMask").draw(o,d.TRIANGLES,r.DepthMode.disabled,this.stencilClearMode,r.ColorMode.disabled,r.CullFaceMode.disabled,xu(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear())}_renderTileClippingMasks(o,d,y){if(!d||this.currentStencilSource===d.id||!o.isTileClipped()||!y||y.length===0)return;const E=[];let C=!1;if(this._tileClippingMaskIDs&&!this.terrain){for(const G of y)if(this._tileClippingMaskIDs.has(G.key)||(C=!0),this._skippedStencilTileIDs.has(G.key)){if(!d.getTile(G).getBucket(o))continue;this._skippedStencilTileIDs.delete(G.key),E.push(G)}if(!C&&E.length===0)return}const S=this.context,k=S.gl;S.setColorMode(r.ColorMode.disabled),S.setDepthMode(r.DepthMode.disabled);const O=this.useProgram("clippingMask"),U=G=>{const Z=d.getTile(G),{tileBoundsBuffer:se,tileBoundsIndexBuffer:de,tileBoundsSegments:ce}=this.getTileBoundsBuffers(Z);O.draw(S,k.TRIANGLES,r.DepthMode.disabled,new r.StencilMode({func:k.GREATER,mask:255},this._tileClippingMaskIDs.get(G.key)||0,255,k.KEEP,k.KEEP,k.REPLACE),r.ColorMode.disabled,r.CullFaceMode.disabled,xu(G.projMatrix),"$clipping",se,de,ce)};if(!C&&E.length>0)for(const G of E)U(G);else{(this._tileClippingMaskIDs.size===0||this.nextStencilID+y.length>256)&&this.clearStencil(),this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear();for(const G of y)this._tileClippingMaskIDs.set(G.key,this.nextStencilID++),d.getTile(G).getBucket(o)?U(G):this._skippedStencilTileIDs.add(G.key)}this._skippedStencilTileIDs.size===0&&(this.currentStencilSource=d.id)}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const o=this.nextStencilID++,d=this.context.gl;return new r.StencilMode({func:d.NOTEQUAL,mask:255},o,255,d.KEEP,d.KEEP,d.REPLACE)}stencilModeForClipping(o){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(o);const d=this.context.gl;return new r.StencilMode({func:d.EQUAL,mask:255},this._tileClippingMaskIDs.get(o.key)||0,0,d.KEEP,d.KEEP,d.REPLACE)}stencilConfigForOverlap(o){const d=this.context.gl,y=o.sort((S,k)=>k.overscaledZ-S.overscaledZ),E=y[y.length-1].overscaledZ,C=y[0].overscaledZ-E+1;if(C>1){this.currentStencilSource=void 0,this.nextStencilID+C>256&&this.clearStencil();const S={};for(let k=0;k<C;k++)S[k+E]=new r.StencilMode({func:d.GEQUAL,mask:255},k+this.nextStencilID,255,d.KEEP,d.KEEP,d.REPLACE);return this.nextStencilID+=C,[S,y]}return[{[E]:r.StencilMode.disabled},y]}colorModeForRenderPass(){const o=this.context.gl;return this._showOverdrawInspector?new r.ColorMode([o.CONSTANT_COLOR,o.ONE],new r.Color(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?r.ColorMode.unblended:r.ColorMode.alphaBlended}depthModeForSublayer(o,d,y){if(!this.opaquePassEnabledForLayer())return r.DepthMode.disabled;const E=1-((1+this.currentLayer)*this.numSublayers+o)*this.depthEpsilon;return new r.DepthMode(y||this.context.gl.LEQUAL,d,[E,E])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(o,d){this.style=o,this.options=d,this.lineAtlas=o.lineAtlas,this.imageManager=o.imageManager,this.glyphManager=o.glyphManager,this.symbolFadeChange=o.placement.symbolFadeChange(r.exported.now()),this.imageManager.beginFrame();const y=this.style.order,E=this.style._sourceCaches;for(const U in E){const G=E[U];G.used&&G.prepare(this.context)}const C={},S={},k={};for(const U in E){const G=E[U];C[U]=G.getVisibleCoordinates(),S[U]=C[U].slice().reverse(),k[U]=G.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let U=0;U<y.length;U++)if(this.style._layers[y[U]].is3D()){this.opaquePassCutoff=U;break}if(this.terrain&&(this.terrain.updateTileBinding(k),this.opaquePassCutoff=0),this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new r.GlobeSharedBuffers(this.context)),!r.isMapAuthenticated(this.context.gl))return;this.renderPass="offscreen";for(const U of y){const G=this.style._layers[U],Z=o._getLayerSourceCache(G);if(!G.hasOffscreenPass()||G.isHidden(this.transform.zoom))continue;const se=Z?S[Z.id]:void 0;(G.type==="custom"||G.isSky()||se&&se.length)&&this.renderLayer(this,Z,G,se)}this.depthRangeFor3D=[0,1-(o.order.length+2)*this.numSublayers*this.depthEpsilon],this.terrain&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&this.terrain.drawDepth(),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);let O=r.Color.transparent;if(this.style.fog&&this.style.fog.getOpacity(this.transform.pitch)&&(O=this.style.fog.properties.get("color")),this.context.clear({color:d.showOverdrawInspector?r.Color.black:O,depth:1}),this.clearStencil(),this._showOverdrawInspector=d.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=y.length-1;this.currentLayer>=0;this.currentLayer--){const U=this.style._layers[y[this.currentLayer]],G=o._getLayerSourceCache(U);if(U.isSky())continue;const Z=G?S[G.id]:void 0;this._renderTileClippingMasks(U,G,Z),this.renderLayer(this,G,U,Z)}if(this.renderPass="sky",(r.globeToMercatorTransition(this.transform.zoom)>0||this.transform.projection.name!=="globe")&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<y.length;this.currentLayer++){const U=this.style._layers[y[this.currentLayer]],G=o._getLayerSourceCache(U);U.isSky()&&this.renderLayer(this,G,U,G?S[G.id]:void 0)}for(this.transform.projection.name==="globe"&&function(U){const G=U.context,Z=G.gl,se=U.transform,de=new r.DepthMode(Z.LEQUAL,r.DepthMode.ReadOnly,[0,1]),ce=U.useProgram("globeAtmosphere"),te=se.centerOffset,Le=se._camera.getCameraToClipPerspective(se._fov,se.width/se.height,se._nearZ,se._farZ);Le[8]=2*-te.x/se.width,Le[9]=2*te.y/se.height;const ve=r.invert([],Le),De=r.mul([],ve,se.projMatrix),Se={u_frustum_tl:ca([-1,1,1],ve),u_frustum_tr:ca([1,1,1],ve),u_frustum_br:ca([1,-1,1],ve),u_frustum_bl:ca([-1,-1,1],ve),u_globe_pos:ca([se.globeMatrix[12],se.globeMatrix[13],se.globeMatrix[14]],De),u_globe_radius:se.worldSize/2/Math.PI-1,u_opacity:1-r.globeToMercatorTransition(se.zoom),u_fadeout_range:2,u_start_color:[1,1,1],u_end_color:[.0118,.7451,.9882]};U.prepareDrawProgram(G,ce);const ze=U.globeSharedBuffers;ze&&ce.draw(G,Z.TRIANGLES,de,r.StencilMode.disabled,r.ColorMode.alphaBlended,r.CullFaceMode.backCW,Se,"skybox",ze.atmosphereVertexBuffer,ze.atmosphereIndexBuffer,ze.atmosphereSegments)}(this),this.renderPass="translucent",this.currentLayer=0;this.currentLayer<y.length;){const U=this.style._layers[y[this.currentLayer]],G=o._getLayerSourceCache(U);if(U.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(U)){if(U.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}const Z=G?(U.type==="symbol"?k:S)[G.id]:void 0;this._renderTileClippingMasks(U,G,G?C[G.id]:void 0),this.renderLayer(this,G,U,Z),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry){let U=null;r.values(this.style._layers).forEach(G=>{const Z=o._getLayerSourceCache(G);Z&&!G.isHidden(this.transform.zoom)&&(!U||U.getSource().maxzoom<Z.getSource().maxzoom)&&(U=Z)}),U&&this.options.showTileBoundaries&&qd.debug(this,U,U.getVisibleCoordinates())}this.options.showPadding&&function(U){const G=U.transform.padding;jt(U,U.transform.height-(G.top||0),3,Hd),jt(U,G.bottom||0,3,$d),$r(U,G.left||0,3,Zm),$r(U,U.transform.width-(G.right||0),3,Pu);const Z=U.transform.centerPoint;(function(se,de,ce,te){Il(se,de-1,ce-10,2,20,te),Il(se,de-10,ce-1,20,2,te)})(U,Z.x,U.transform.height-Z.y,Su)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(r.window.performance.now()),this.saveCanvasCopy())}renderLayer(o,d,y,E){y.isHidden(this.transform.zoom)||(y.type==="background"||y.type==="sky"||y.type==="custom"||E&&E.length)&&(this.id=y.id,this.gpuTimingStart(y),o.transform.projection.unsupportedLayers&&o.transform.projection.unsupportedLayers.includes(y.type)||qd[y.type](o,d,y,E,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(o){if(!this.options.gpuTiming)return;const d=this.context.extTimerQuery;let y=this.gpuTimers[o.id];y||(y=this.gpuTimers[o.id]={calls:0,cpuTime:0,query:d.createQueryEXT()}),y.calls++,d.beginQueryEXT(d.TIME_ELAPSED_EXT,y.query)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const o=this.context.extTimerQuery;o.endQueryEXT(o.TIME_ELAPSED_EXT)}collectGpuTimers(){const o=this.gpuTimers;return this.gpuTimers={},o}queryGpuTimers(o){const d={};for(const y in o){const E=o[y],C=this.context.extTimerQuery,S=C.getQueryObjectEXT(E.query,C.QUERY_RESULT_EXT)/1e6;C.deleteQueryEXT(E.query),d[y]=S}return d}translatePosMatrix(o,d,y,E,C){if(!y[0]&&!y[1])return o;const S=C?E==="map"?this.transform.angle:0:E==="viewport"?-this.transform.angle:0;if(S){const U=Math.sin(S),G=Math.cos(S);y=[y[0]*G-y[1]*U,y[0]*U+y[1]*G]}const k=[C?y[0]:We(d,y[0],this.transform.zoom),C?y[1]:We(d,y[1],this.transform.zoom),0],O=new Float32Array(16);return r.translate(O,o,k),O}saveTileTexture(o){const d=this._tileTextures[o.size[0]];d?d.push(o):this._tileTextures[o.size[0]]=[o]}getTileTexture(o){const d=this._tileTextures[o];return d&&d.length>0?d.pop():null}isPatternMissing(o){if(!o)return!1;if(!o.from||!o.to)return!0;const d=this.imageManager.getPattern(o.from.toString()),y=this.imageManager.getPattern(o.to.toString());return!d||!y}currentGlobalDefines(){const o=this.terrain&&this.terrain.renderingToTexture,d=this.style&&this.style.fog,y=[];return this.terrain&&!this.terrain.renderingToTexture&&y.push("TERRAIN"),d&&!o&&d.getOpacity(this.transform.pitch)!==0&&y.push("FOG"),o&&y.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&y.push("OVERDRAW_INSPECTOR"),y}useProgram(o,d,y){this.cache=this.cache||{};const E=y||[],C=this.currentGlobalDefines().concat(E),S=Dl.cacheKey(o,C,d);return this.cache[S]||(this.cache[S]=new Dl(this.context,o,El[o],d,Qn[o],C)),this.cache[S]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const o=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(o.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=r.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new r.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(o,d,y){if(this.terrain&&this.terrain.renderingToTexture)return;const E=this.style.fog;if(E){const C=E.getOpacity(this.transform.pitch);C!==0&&d.setFogUniformValues(o,((S,k,O,U)=>{const G=k.properties.get("color"),Z=S.frameCounter/1e3%1,se=[G.r/G.a,G.g/G.a,G.b/G.a,U];return{u_fog_matrix:O?S.transform.calculateFogTileMatrix(O):S.identityMat,u_fog_range:k.getFovAdjustedRange(S.transform._fov),u_fog_color:se,u_fog_horizon_blend:k.properties.get("horizon-blend"),u_fog_temporal_offset:Z}})(this,E,y,C))}}setTileLoadedFlag(o){this.tileLoaded=o}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const o=this.context.gl,d=o.createTexture();return o.bindTexture(o.TEXTURE_2D,d),o.copyTexImage2D(o.TEXTURE_2D,0,o.RGBA,0,0,o.drawingBufferWidth,o.drawingBufferHeight,0),d}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const o=this.style&&this.style.fog;return!!o&&o.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const o=this._backgroundTiles,d=this._backgroundTiles={},y=this.transform.coveringTiles({tileSize:512});for(const E of y)d[E.key]=o[E.key]||new r.Tile(E,512,this.transform.tileZoom,this);return d}clearBackgroundTiles(){this._backgroundTiles={}}}class ua{constructor(o=0,d=0,y=0,E=0){if(isNaN(o)||o<0||isNaN(d)||d<0||isNaN(y)||y<0||isNaN(E)||E<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=o,this.bottom=d,this.left=y,this.right=E}interpolate(o,d,y){return d.top!=null&&o.top!=null&&(this.top=r.number(o.top,d.top,y)),d.bottom!=null&&o.bottom!=null&&(this.bottom=r.number(o.bottom,d.bottom,y)),d.left!=null&&o.left!=null&&(this.left=r.number(o.left,d.left,y)),d.right!=null&&o.right!=null&&(this.right=r.number(o.right,d.right,y)),this}getCenter(o,d){const y=r.clamp((this.left+o-this.right)/2,0,o),E=r.clamp((this.top+d-this.bottom)/2,0,d);return new r.pointGeometry(y,E)}equals(o){return this.top===o.top&&this.bottom===o.bottom&&this.left===o.left&&this.right===o.right}clone(){return new ua(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Qm(m,o){const d=r.getColumn(m,3);r.fromQuat(m,o),r.setColumn(m,3,d)}function Xd(m,o){const d=r.identity$1([]);return r.rotateZ$1(d,d,-o),r.rotateX$1(d,d,-m),d}function Lu(m,o){const d=[m[0],m[1],0],y=[o[0],o[1],0];if(r.length(d)>=1e-15){const S=r.normalize([],d);r.scale$2(y,S,r.dot(y,S)),o[0]=y[0],o[1]=y[1]}const E=r.cross([],o,m);if(r.len(E)<1e-15)return null;const C=Math.atan2(-E[1],E[0]);return Xd(Math.atan2(Math.sqrt(m[0]*m[0]+m[1]*m[1]),-m[2]),C)}class kl{constructor(o,d){this.position=o,this.orientation=d}get position(){return this._position}set position(o){if(o){const d=o instanceof r.MercatorCoordinate?o:new r.MercatorCoordinate(o[0],o[1],o[2]);this._renderWorldCopies&&(d.x=r.wrap(d.x,0,1)),this._position=d}else this._position=null}lookAtPoint(o,d){if(this.orientation=null,!this.position)return;const y=this._elevation?this._elevation.getAtPointOrZero(r.MercatorCoordinate.fromLngLat(o)):0,E=this.position,C=r.MercatorCoordinate.fromLngLat(o,y),S=[C.x-E.x,C.y-E.y,C.z-E.z];d||(d=[0,0,1]),d[2]=Math.abs(d[2]),this.orientation=Lu(S,d)}setPitchBearing(o,d){this.orientation=Xd(r.degToRad(o),r.degToRad(-d))}}class zl{constructor(o,d){this._transform=r.identity([]),this.orientation=d,this.position=o}get mercatorPosition(){const o=this.position;return new r.MercatorCoordinate(o[0],o[1],o[2])}get position(){const o=r.getColumn(this._transform,3);return[o[0],o[1],o[2]]}set position(o){var d;o&&r.setColumn(this._transform,3,[(d=o)[0],d[1],d[2],1])}get orientation(){return this._orientation}set orientation(o){this._orientation=o||r.identity$1([]),o&&Qm(this._transform,this._orientation)}getPitchBearing(){const o=this.forward(),d=this.right();return{bearing:Math.atan2(-d[1],d[0]),pitch:Math.atan2(Math.sqrt(o[0]*o[0]+o[1]*o[1]),-o[2])}}setPitchBearing(o,d){this._orientation=Xd(o,d),Qm(this._transform,this._orientation)}forward(){const o=r.getColumn(this._transform,2);return[-o[0],-o[1],-o[2]]}up(){const o=r.getColumn(this._transform,1);return[-o[0],-o[1],-o[2]]}right(){const o=r.getColumn(this._transform,0);return[o[0],o[1],o[2]]}getCameraToWorld(o,d){const y=new Float64Array(16);return r.invert(y,this.getWorldToCamera(o,d)),y}getWorldToCameraPosition(o,d,y){const E=this.position;r.scale$2(E,E,-o);const C=new Float64Array(16);return r.fromScaling(C,[y,y,y]),r.translate(C,C,E),C[10]*=d,C}getWorldToCamera(o,d){const y=new Float64Array(16),E=new Float64Array(4),C=this.position;return r.conjugate(E,this._orientation),r.scale$2(C,C,-o),r.fromQuat(y,E),r.translate(y,y,C),y[1]*=-1,y[5]*=-1,y[9]*=-1,y[13]*=-1,y[8]*=d,y[9]*=d,y[10]*=d,y[11]*=d,y}getCameraToClipPerspective(o,d,y,E){const C=new Float64Array(16);return r.perspective(C,o,d,y,E),C}getDistanceToElevation(o){const d=o===0?0:r.mercatorZfromAltitude(o,this.position[1]),y=this.forward();return(d-this.position[2])/y[2]}clone(){return new zl([...this.position],[...this.orientation])}}function Zd(m,o){const d=Fl(m),y=function(C,S,k,O,U){const G=new r.LngLat(k.lng-180*ha,k.lat),Z=new r.LngLat(k.lng+180*ha,k.lat),se=C.project(G.lng,G.lat),de=C.project(Z.lng,Z.lat),ce=-Math.atan2(de.y-se.y,de.x-se.x),te=r.MercatorCoordinate.fromLngLat(k);te.y=r.clamp(te.y,-.999975,.999975);const Le=te.toLngLat(),ve=C.project(Le.lng,Le.lat),De=r.MercatorCoordinate.fromLngLat(Le);De.x+=ha;const Se=De.toLngLat(),ze=C.project(Se.lng,Se.lat),Ee=Jd(ze.x-ve.x,ze.y-ve.y,ce),Ue=r.MercatorCoordinate.fromLngLat(Le);Ue.y+=ha;const nt=Ue.toLngLat(),lt=C.project(nt.lng,nt.lat),pt=Jd(lt.x-ve.x,lt.y-ve.y,ce),ht=Math.abs(Ee.x)/Math.abs(pt.y),kt=r.identity([]);r.rotateZ(kt,kt,-ce*(1-(U?0:O)));const it=r.identity([]);return r.scale(it,it,[1,1-(1-ht)*O,1]),it[4]=-pt.x/pt.y*O,r.rotateZ(it,it,ce),r.multiply$1(it,kt,it),it}(m.projection,0,m.center,d,o),E=Yd(m);return r.scale(y,y,[E,E,1]),y}function Yd(m){const o=m.projection,d=Fl(m),y=Kd(o,m.center),E=Kd(o,r.LngLat.convert(o.center));return Math.pow(2,y*d+(1-d)*E)}function Fl(m){const o=m.projection.range;if(!o)return 0;const d=Math.max(m.width,m.height),y=Math.log(d/1024)/Math.LN2;return r.smoothstep(o[0]+y,o[1]+y,m.zoom)}const ha=1/4e4;function Kd(m,o){const d=r.clamp(o.lat,-r.MAX_MERCATOR_LATITUDE,r.MAX_MERCATOR_LATITUDE),y=new r.LngLat(o.lng-180*ha,d),E=new r.LngLat(o.lng+180*ha,d),C=m.project(y.lng,d),S=m.project(E.lng,d),k=r.MercatorCoordinate.fromLngLat(y),O=r.MercatorCoordinate.fromLngLat(E),U=S.x-C.x,G=S.y-C.y,Z=O.x-k.x,se=O.y-k.y,de=Math.sqrt((Z*Z+se*se)/(U*U+G*G));return Math.log(de)/Math.LN2}function Jd(m,o,d){const y=Math.cos(d),E=Math.sin(d);return{x:m*y-o*E,y:m*E+o*y}}class Iu{constructor(o,d,y,E,C,S,k){this.tileSize=512,this._renderWorldCopies=C===void 0||C,this._minZoom=o||0,this._maxZoom=d||22,this._minPitch=y==null?0:y,this._maxPitch=E==null?60:E,this.setProjection(S),this.setMaxBounds(k),this.width=0,this.height=0,this._center=new r.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new ua,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new zl,this._centerAltitude=0,this._centerAltitudeValidForExaggeration=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this._horizonShift=.1}clone(){const o=new Iu(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return o._elevation=this._elevation,o._centerAltitude=this._centerAltitude,o._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,o.tileSize=this.tileSize,o.width=this.width,o.height=this.height,o.cameraElevationReference=this.cameraElevationReference,o._center=this._center,o._setZoom(this.zoom),o._seaLevelZoom=this._seaLevelZoom,o.angle=this.angle,o._fov=this._fov,o._pitch=this._pitch,o._nearZ=this._nearZ,o._farZ=this._farZ,o._averageElevation=this._averageElevation,o._unmodified=this._unmodified,o._edgeInsets=this._edgeInsets.clone(),o._camera=this._camera.clone(),o._calcMatrices(),o.freezeTileCoverage=this.freezeTileCoverage,o}get elevation(){return this._elevation}set elevation(o){this._elevation!==o&&(this._elevation=o,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(o){const d=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||d)&&this._updateCameraOnTerrain(),(o||d)&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return r.pick(this.projection,["name","center","parallels"])}setProjection(o){o==null&&(o={name:"mercator"}),this.projectionOptions=o;const d=this.projection?this.getProjection():void 0;this.projection=r.getProjection(o);const y=this.getProjection();return b(d,y)?null:(this._calcMatrices(),y)}get minZoom(){return this._minZoom}set minZoom(o){this._minZoom!==o&&(this._minZoom=o,this.zoom=Math.max(this.zoom,o))}get maxZoom(){return this._maxZoom}set maxZoom(o){this._maxZoom!==o&&(this._maxZoom=o,this.zoom=Math.min(this.zoom,o))}get minPitch(){return this._minPitch}set minPitch(o){this._minPitch!==o&&(this._minPitch=o,this.pitch=Math.max(this.pitch,o))}get maxPitch(){return this._maxPitch}set maxPitch(o){this._maxPitch!==o&&(this._maxPitch=o,this.pitch=Math.min(this.pitch,o))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(o){o===void 0?o=!0:o===null&&(o=!1),this._renderWorldCopies=o}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const o=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(o))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new r.pointGeometry(this.width,this.height)}get bearing(){return r.wrap(this.rotation,-180,180)}set bearing(o){this.rotation=o}get rotation(){return-this.angle/Math.PI*180}set rotation(o){const d=-o*Math.PI/180;var y;this.angle!==d&&(this._unmodified=!1,this.angle=d,this._calcMatrices(),this.rotationMatrix=(y=new r.ARRAY_TYPE(4),r.ARRAY_TYPE!=Float32Array&&(y[1]=0,y[2]=0),y[0]=1,y[3]=1,y),function(E,C,S){var k=C[0],O=C[1],U=C[2],G=C[3],Z=Math.sin(S),se=Math.cos(S);E[0]=k*se+U*Z,E[1]=O*se+G*Z,E[2]=k*-Z+U*se,E[3]=O*-Z+G*se}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(o){const d=r.clamp(o,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==d&&(this._unmodified=!1,this._pitch=d,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(o){o=Math.max(.01,Math.min(60,o)),this._fov!==o&&(this._unmodified=!1,this._fov=o/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(o){this._averageElevation=o,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(o){const d=Math.min(Math.max(o,this.minZoom),this.maxZoom);this._zoom!==d&&(this._unmodified=!1,this._setZoom(d),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(o){this._zoom=o,this.scale=this.zoomScale(o),this.tileZoom=Math.floor(o),this.zoomFraction=o-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=0);const o=this._elevation;this._centerAltitude=o.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=o.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){this._centerAltitudeValidForExaggeration!==0&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const o=this._elevation,d=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],y=this.horizonLineFromTop();let E=0,C=0;for(let S=0;S<d.length;S++){const k=new r.pointGeometry(d[S][0]*this.width,y+d[S][1]*(this.height-y)),O=o.pointCoordinate(k);if(!O)continue;const U=1/Math.hypot(O[0]-this._camera.position[0],O[1]-this._camera.position[1]);E+=O[3]*U,C+=U}return C===0?NaN:E/C}get center(){return this._center}set center(o){o.lat===this._center.lat&&o.lng===this._center.lng||(this._unmodified=!1,this._center=o,this._terrainEnabled()&&(this.cameraElevationReference==="ground"?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(this._seaLevelZoom==null||!this._elevation)return;const o=this._seaLevelZoom,d=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),y=this.pixelsPerMeter/this.worldSize*d,E=this._mercatorZfromZoom(o),C=this._mercatorZfromZoom(this._maxZoom),S=Math.max(E-y,C);this._setZoom(this._zoomFromMercatorZ(S))}get padding(){return this._edgeInsets.toJSON()}set padding(o){this._edgeInsets.equals(o)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,o,1),this._calcMatrices())}computeZoomRelativeTo(o){const d=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,o.toAltitude()));let y;y=o.z<this._camera.position[2]?[d.x,d.y,d.z]:[o.x,o.y,o.z];const E=r.length(r.sub([],this._camera.position,y));return r.clamp(this._zoomFromMercatorZ(E),this._minZoom,this._maxZoom)}setFreeCameraOptions(o){if(!this.height||!o.position&&!o.orientation)return;this._updateCameraState();let d=!1;if(o.orientation&&!r.exactEquals(o.orientation,this._camera.orientation)&&(d=this._setCameraOrientation(o.orientation)),o.position){const y=[o.position.x,o.position.y,o.position.z];r.exactEquals$1(y,this._camera.position)||(this._setCameraPosition(y),d=!0)}d&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const o=this._camera.position,d=new kl;return d.position=new r.MercatorCoordinate(o[0],o[1],o[2]),d.orientation=this._camera.orientation,d._elevation=this.elevation,d._renderWorldCopies=this.renderWorldCopies,d}_setCameraOrientation(o){if(!r.length$1(o))return!1;r.normalize$1(o,o);const d=r.transformQuat([],[0,0,-1],o),y=r.transformQuat([],[0,-1,0],o);if(y[2]<0)return!1;const E=Lu(d,y);return!!E&&(this._camera.orientation=E,!0)}_setCameraPosition(o){const d=this.zoomScale(this.minZoom)*this.tileSize,y=this.zoomScale(this.maxZoom)*this.tileSize,E=this.cameraToCenterDistance;o[2]=r.clamp(o[2],E/y,E/d),this._camera.position=o}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(o){return this._edgeInsets.equals(o)}interpolatePadding(o,d,y){this._unmodified=!1,this._edgeInsets.interpolate(o,d,y),this._constrain(),this._calcMatrices()}coveringZoomLevel(o){const d=(o.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/o.tileSize));return Math.max(0,d)}getVisibleUnwrappedCoordinates(o){const d=[new r.UnwrappedTileID(0,o)];if(this.renderWorldCopies){const y=this.pointCoordinate(new r.pointGeometry(0,0)),E=this.pointCoordinate(new r.pointGeometry(this.width,0)),C=this.pointCoordinate(new r.pointGeometry(this.width,this.height)),S=this.pointCoordinate(new r.pointGeometry(0,this.height)),k=Math.floor(Math.min(y.x,E.x,C.x,S.x)),O=Math.floor(Math.max(y.x,E.x,C.x,S.x)),U=1;for(let G=k-U;G<=O+U;G++)G!==0&&d.push(new r.UnwrappedTileID(G,o))}return d}coveringTiles(o){let d=this.coveringZoomLevel(o);const y=d,E=this.elevation&&!o.isTerrainDEM,C=this.projection.name==="mercator";if(o.minzoom!==void 0&&d<o.minzoom)return[];o.maxzoom!==void 0&&d>o.maxzoom&&(d=o.maxzoom);const S=this.locationCoordinate(this.center),k=this.center.lat,O=1<<d,U=[O*S.x,O*S.y,0],G=this.projection.name==="globe",Z=!G,se=r.Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,d,Z),de=G?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),ce=O*r.mercatorZfromAltitude(1,this.center.lat),te=this._camera.position[2]/r.mercatorZfromAltitude(1,this.center.lat),Le=[O*de.x,O*de.y,te*(Z?1:ce)],ve=this.cameraToCenterDistance/o.tileSize*(o.roundZoom?1:.502),De=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?d:0,Se=o.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,ze=o.isTerrainDEM?-Se:this._elevation?this._elevation.getMinElevationBelowMSL():0,Ee=this.projection.isReprojectedInTileSpace?Yd(this):1,Ue=ft=>{const gn=new r.MercatorCoordinate(ft.x+25e-6,ft.y,ft.z),Zt=new r.MercatorCoordinate(ft.x,ft.y+25e-6,ft.z),Yt=ft.toLngLat(),xn=gn.toLngLat(),zn=Zt.toLngLat(),dn=this.locationCoordinate(Yt),Mn=this.locationCoordinate(xn),$n=this.locationCoordinate(zn),vi=Math.hypot(Mn.x-dn.x,Mn.y-dn.y),nr=Math.hypot($n.x-dn.x,$n.y-dn.y);return Math.sqrt(vi*nr)*Ee/25e-6},nt=ft=>{const qt=Se,gn=ze;return{aabb:r.tileAABB(this,O,0,0,0,ft,gn,qt,this.projection),zoom:0,x:0,y:0,minZ:gn,maxZ:qt,wrap:ft,fullyVisible:!1}},lt=[];let pt=[];const ht=d,kt=o.reparseOverscaled?y:d,it=ft=>ft*ft,zt=it((te-this._centerAltitude)*ce),St=ft=>{if(!this._elevation||!ft.tileID||!C)return;const qt=this._elevation.getMinMaxForTile(ft.tileID),gn=ft.aabb;qt?(gn.min[2]=qt.min,gn.max[2]=qt.max,gn.center[2]=(gn.min[2]+gn.max[2])/2):(ft.shouldSplit=Jt(ft),ft.shouldSplit||(gn.min[2]=gn.max[2]=gn.center[2]=this._centerAltitude))},Jt=ft=>{if(ft.zoom<De)return!0;if(ft.zoom===ht)return!1;if(ft.shouldSplit!=null)return ft.shouldSplit;const qt=ft.aabb.distanceX(Le),gn=ft.aabb.distanceY(Le);let Zt=zt,Yt=1;if(G){Zt=it(ft.aabb.distanceZ(Le));const zn=Math.pow(2,ft.zoom),dn=r.latFromMercatorY((ft.y+1)/zn),Mn=r.latFromMercatorY(ft.y/zn),$n=Math.min(Math.max(k,dn),Mn),vi=r.circumferenceAtLatitude($n)/r.circumferenceAtLatitude(k);Yt=Math.min(vi,1)}else if(E&&(Zt=it(ft.aabb.distanceZ(Le)*ce)),this.projection.isReprojectedInTileSpace&&y<=5){const zn=Math.pow(2,ft.zoom),dn=Ue(new r.MercatorCoordinate((ft.x+.5)/zn,(ft.y+.5)/zn));Yt=dn>.85?1:dn}const xn=qt*qt+gn*gn+Zt;return xn<it((1<<ht-ft.zoom)*ve*Yt*((zn,dn)=>{if(dn*it(.707)<zn)return 1;const Mn=Math.sqrt(dn/zn);return Mn/(1.4144271570014144+(Math.pow(1.1,Mn-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(Zt,zt),xn))};if(this.renderWorldCopies)for(let ft=1;ft<=3;ft++)lt.push(nt(-ft)),lt.push(nt(ft));for(lt.push(nt(0));lt.length>0;){const ft=lt.pop(),qt=ft.x,gn=ft.y;let Zt=ft.fullyVisible;if(!Zt){const Yt=ft.aabb.intersects(se);if(Yt===0)continue;Zt=Yt===2}if(ft.zoom!==ht&&Jt(ft))for(let Yt=0;Yt<4;Yt++){const xn=(qt<<1)+Yt%2,zn=(gn<<1)+(Yt>>1),dn={aabb:C?ft.aabb.quadrant(Yt):r.tileAABB(this,O,ft.zoom+1,xn,zn,ft.wrap,ft.minZ,ft.maxZ,this.projection),zoom:ft.zoom+1,x:xn,y:zn,wrap:ft.wrap,fullyVisible:Zt,tileID:void 0,shouldSplit:void 0,minZ:ft.minZ,maxZ:ft.maxZ};E&&!G&&(dn.tileID=new r.OverscaledTileID(ft.zoom+1===ht?kt:ft.zoom+1,ft.wrap,ft.zoom+1,xn,zn),St(dn)),lt.push(dn)}else{const Yt=ft.zoom===ht?kt:ft.zoom;if(o.minzoom&&o.minzoom>Yt)continue;const xn=U[0]-(.5+qt+(ft.wrap<<ft.zoom))*(1<<d-ft.zoom),zn=U[1]-.5-gn,dn=ft.tileID?ft.tileID:new r.OverscaledTileID(Yt,ft.wrap,ft.zoom,qt,gn);pt.push({tileID:dn,distanceSq:xn*xn+zn*zn})}}if(this.fogCullDistSq){const ft=this.fogCullDistSq,qt=this.horizonLineFromTop();pt=pt.filter(gn=>{const Zt=[0,0,0,1],Yt=[r.EXTENT,r.EXTENT,0,1],xn=this.calculateFogTileMatrix(gn.tileID.toUnwrapped());r.transformMat4$1(Zt,Zt,xn),r.transformMat4$1(Yt,Yt,xn);const zn=r.getAABBPointSquareDist(Zt,Yt);if(zn===0)return!0;let dn=!1;const Mn=this._elevation;if(Mn&&zn>ft&&qt!==0){const $n=this.calculateProjMatrix(gn.tileID.toUnwrapped());let vi;o.isTerrainDEM||(vi=Mn.getMinMaxForTile(gn.tileID)),vi||(vi={min:ze,max:Se});const nr=r.furthestTileCorner(this.rotation),ir=[nr[0]*r.EXTENT,nr[1]*r.EXTENT,vi.max];r.transformMat4(ir,ir,$n),dn=(1-ir[1])*this.height*.5<qt}return zn<ft||dn})}return pt.sort((ft,qt)=>ft.distanceSq-qt.distanceSq).map(ft=>ft.tileID)}resize(o,d){this.width=o,this.height=d,this.pixelsToGLUnits=[2/o,-2/d],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(o){return Math.pow(2,o)}scaleZoom(o){return Math.log(o)/Math.LN2}project(o){const d=r.clamp(o.lat,-r.MAX_MERCATOR_LATITUDE,r.MAX_MERCATOR_LATITUDE),y=this.projection.project(o.lng,d);return new r.pointGeometry(y.x*this.worldSize,y.y*this.worldSize)}unproject(o){return this.projection.unproject(o.x/this.worldSize,o.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(o,d){let y,E;const C=this.centerPoint;if(this.projection.name==="globe"){const k=this.worldSize;y=(d.x-C.x)/k,E=(d.y-C.y)/k}else{const k=this.pointCoordinate(d),O=this.pointCoordinate(C);y=k.x-O.x,E=k.y-O.y}const S=this.locationCoordinate(o);this.setLocation(new r.MercatorCoordinate(S.x-y,S.y-E))}setLocation(o){this.center=this.coordinateLocation(o),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(o){return this.projection.locationPoint(this,o)}locationPoint3D(o){return this._coordinatePoint(this.locationCoordinate(o),!0)}pointLocation(o){return this.coordinateLocation(this.pointCoordinate(o))}pointLocation3D(o){return this.coordinateLocation(this.pointCoordinate3D(o))}locationCoordinate(o,d){const y=d?r.mercatorZfromAltitude(d,o.lat):void 0,E=this.projection.project(o.lng,o.lat);return new r.MercatorCoordinate(E.x,E.y,y)}coordinateLocation(o){return this.projection.unproject(o.x,o.y)}pointRayIntersection(o,d){const y=d!=null?d:this._centerAltitude,E=[o.x,o.y,0,1],C=[o.x,o.y,1,1];r.transformMat4$1(E,E,this.pixelMatrixInverse),r.transformMat4$1(C,C,this.pixelMatrixInverse);const S=C[3];r.scale$1(E,E,1/E[3]),r.scale$1(C,C,1/S);const k=E[2],O=C[2];return{p0:E,p1:C,t:k===O?0:(y-k)/(O-k)}}screenPointToMercatorRay(o){const d=[o.x,o.y,0,1],y=[o.x,o.y,1,1];return r.transformMat4$1(d,d,this.pixelMatrixInverse),r.transformMat4$1(y,y,this.pixelMatrixInverse),r.scale$1(d,d,1/d[3]),r.scale$1(y,y,1/y[3]),d[2]=r.mercatorZfromAltitude(d[2],this._center.lat)*this.worldSize,y[2]=r.mercatorZfromAltitude(y[2],this._center.lat)*this.worldSize,r.scale$1(d,d,1/this.worldSize),r.scale$1(y,y,1/this.worldSize),new r.Ray([d[0],d[1],d[2]],r.normalize([],r.sub([],y,d)))}rayIntersectionCoordinate(o){const{p0:d,p1:y,t:E}=o,C=r.mercatorZfromAltitude(d[2],this._center.lat),S=r.mercatorZfromAltitude(y[2],this._center.lat);return new r.MercatorCoordinate(r.number(d[0],y[0],E)/this.worldSize,r.number(d[1],y[1],E)/this.worldSize,r.number(C,S,E))}pointCoordinate(o,d=this._centerAltitude){return this.projection.pointCoordinate(this,o.x,o.y,d)}pointCoordinate3D(o){if(!this.elevation)return this.pointCoordinate(o);const d=this.elevation;let y=this.elevation.pointCoordinate(o);if(y)return new r.MercatorCoordinate(y[0],y[1],y[2]);let E=0,C=this.horizonLineFromTop();if(o.y>C)return this.pointCoordinate(o);const S=.02*C,k=o.clone();for(let O=0;O<10&&C-E>S;O++){k.y=r.number(E,C,.66);const U=d.pointCoordinate(k);U?(C=k.y,y=U):E=k.y}return y?new r.MercatorCoordinate(y[0],y[1],y[2]):this.pointCoordinate(o)}isPointAboveHorizon(o){if(this.elevation)return!this.elevation.pointCoordinate(o);{const d=this.horizonLineFromTop();return o.y<d}}_coordinatePoint(o,d){const y=d&&this.elevation?this.elevation.getAtPointOrZero(o,this._centerAltitude):this._centerAltitude,E=[o.x*this.worldSize,o.y*this.worldSize,y+o.toAltitude(),1];return r.transformMat4$1(E,E,this.pixelMatrix),E[3]>0?new r.pointGeometry(E[0]/E[3],E[1]/E[3]):new r.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(o,d){const y=new r.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),E=new r.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),C=new r.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),S=new r.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let k=this.pointCoordinate(y,o),O=this.pointCoordinate(E,o);const U=this.pointCoordinate(C,d),G=this.pointCoordinate(S,d),Z=(se,de)=>(de.y-se.y)/(de.x-se.x);return k.y>1&&O.y>=0?k=new r.MercatorCoordinate((1-G.y)/Z(G,k)+G.x,1):k.y<0&&O.y<=1&&(k=new r.MercatorCoordinate(-G.y/Z(G,k)+G.x,0)),O.y>1&&k.y>=0?O=new r.MercatorCoordinate((1-U.y)/Z(U,O)+U.x,1):O.y<0&&k.y<=1&&(O=new r.MercatorCoordinate(-U.y/Z(U,O)+U.x,0)),new r.LngLatBounds().extend(this.coordinateLocation(k)).extend(this.coordinateLocation(O)).extend(this.coordinateLocation(G)).extend(this.coordinateLocation(U))}_getBounds3D(){const o=this.elevation;if(!o.visibleDemTiles.length)return this._getBounds(0,0);const d=o.visibleDemTiles.reduce((y,E)=>{if(E.dem){const C=E.dem.tree;y.min=Math.min(y.min,C.minimums[0]),y.max=Math.max(y.max,C.maximums[0])}return y},{min:Number.MAX_VALUE,max:0});return this._getBounds(d.min*o.exaggeration(),d.max*o.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(o=!0){const d=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,y=this.height/2-d*(1-this._horizonShift);return o?Math.max(0,y):y}getMaxBounds(){return this.maxBounds}setMaxBounds(o){this.maxBounds=o,this.minLat=-r.MAX_MERCATOR_LATITUDE,this.maxLat=r.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,o&&(this.minLat=o.getSouth(),this.maxLat=o.getNorth(),this.minLng=o.getWest(),this.maxLng=o.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=r.mercatorXfromLng(this.minLng)*this.tileSize,this.worldMaxX=r.mercatorXfromLng(this.maxLng)*this.tileSize,this.worldMinY=r.mercatorYfromLat(this.maxLat)*this.tileSize,this.worldMaxY=r.mercatorYfromLat(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(o,d){return this.projection.createTileMatrix(this,d,o)}calculateDistanceTileData(o){const d=o.key,y=this._distanceTileDataCache;if(y[d])return y[d];const E=o.canonical,C=1/this.height,S=this.cameraWorldSize/this.zoomScale(E.z),k=(E.x+Math.pow(2,E.z)*o.wrap)*S,O=E.y*S,U=this.point,G=this.angle,Z=Math.sin(-G),se=-Math.cos(-G);return y[d]={bearing:[Z,se],center:[(U.x-k)*C,(U.y-O)*C],scale:S/r.EXTENT*C},y[d]}calculateFogTileMatrix(o){const d=o.key,y=this._fogTileMatrixCache;if(y[d])return y[d];const E=this.calculatePosMatrix(o,this.cameraWorldSize);return r.multiply$1(E,this.worldToFogMatrix,E),y[d]=new Float32Array(E),y[d]}calculateProjMatrix(o,d=!1){const y=o.key,E=d?this._alignedProjMatrixCache:this._projMatrixCache;if(E[y])return E[y];const C=this.calculatePosMatrix(o,this.worldSize);return r.multiply$1(C,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:d?this.alignedProjMatrix:this.projMatrix,C),E[y]=new Float32Array(C),E[y]}calculatePixelsToTileUnitsMatrix(o){const d=o.tileID.key,y=this._pixelsToTileUnitsCache;if(y[d])return y[d];const E=function(C,S){const{scale:k}=C.tileTransform,O=k*r.EXTENT/(C.tileSize*Math.pow(2,S.zoom-C.tileID.overscaledZ+C.tileID.canonical.z));return U=new Float32Array(4),se=(G=S.inverseAdjustmentMatrix)[1],de=G[2],ce=G[3],Le=(Z=[O,O])[1],U[0]=G[0]*(te=Z[0]),U[1]=se*te,U[2]=de*Le,U[3]=ce*Le,U;var U,G,Z,se,de,ce,te,Le}(o,this);return y[d]=E,y[d]}customLayerMatrix(){return this.mercatorMatrix.slice()}recenterOnTerrain(){if(!this._elevation)return;const o=this._elevation;this._updateCameraState();const d=r.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,y=this._computeCameraPosition(d),E=this._camera.forward(),C=r.mercatorZfromAltitude(1,this._center.lat);y[2]/=C,E[2]/=C,r.normalize(E,E);const S=o.raycast(y,E,o.exaggeration());if(S){const k=r.scaleAndAdd([],y,E,S),O=new r.MercatorCoordinate(k[0],k[1],r.mercatorZfromAltitude(k[2],r.latFromMercatorY(k[1]))),U=(O.z+r.length([O.x-y[0],O.y-y[1],O.z-y[2]*C]))*this._projectionScaler;this._seaLevelZoom=this._zoomFromMercatorZ(U),this._centerAltitude=O.toAltitude(),this._center=this.coordinateLocation(O),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCameraAltitude(){if(!this._elevation)return;const o=this._elevation;this._updateCameraState();const d=r.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,y=this._computeCameraPosition(d),E=o.getAtPointOrZero(new r.MercatorCoordinate(...y)),C=this._minimumHeightOverTerrain()*Math.cos(r.degToRad(this._maxPitch)),S=this._camera.position[2]-this.pixelsPerMeter/this.worldSize*E;if(S<C){const k=this.locationCoordinate(this._center,this._centerAltitude),O=[k.x-y[0],k.y-y[1],k.z-y[2]],U=r.length(O);O[2]-=(C-S)/this._projectionScaler;const G=r.length(O);if(G===0)return;r.scale$2(O,O,U/G*this._projectionScaler),this._camera.position=[k.x-O[0],k.y-O[1],k.z*this._projectionScaler-O[2]],this._camera.orientation=Lu(O,this._camera.up()),this._updateStateFromCamera()}}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;if(this._constraining=!0,this.projection.isReprojectedInTileSpace){const Z=this.center;return Z.lat=r.clamp(Z.lat,this.minLat,this.maxLat),!this.maxBounds&&this.renderWorldCopies||(Z.lng=r.clamp(Z.lng,this.minLng,this.maxLng)),this.center=Z,void(this._constraining=!1)}const o=this._unmodified,{x:d,y}=this.point;let E=0,C=d,S=y;const k=this.width/2,O=this.height/2,U=this.worldMinY*this.scale,G=this.worldMaxY*this.scale;if(y-O<U&&(S=U+O),y+O>G&&(S=G-O),G-U<this.height&&(E=Math.max(E,this.height/(G-U)),S=(G+U)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const Z=this.worldMinX*this.scale,se=this.worldMaxX*this.scale,de=this.worldSize/2-(Z+se)/2;C=(d+de+this.worldSize)%this.worldSize-de,C-k<Z&&(C=Z+k),C+k>se&&(C=se-k),se-Z<this.width&&(E=Math.max(E,this.width/(se-Z)),C=(se+Z)/2)}C===d&&S===y||(this.center=this.unproject(new r.pointGeometry(C,S))),E&&(this.zoom+=this.scaleZoom(E)),this._constrainCameraAltitude(),this._unmodified=o,this._constraining=!1}_minZoomForBounds(){let o=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(o=Math.max(o,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),o}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const o=this._fov/2,d=this.centerOffset,y=this.pixelsPerMeter;this._projectionScaler=y/(r.mercatorZfromAltitude(1,this.center.lat)*this.worldSize),this.cameraToCenterDistance=.5/Math.tan(o)*this.height*this._projectionScaler,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const E=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?y:1),C=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);C[8]=2*-d.x/this.width,C[9]=2*d.y/this.height;let S=r.mul([],C,E);if(this.projection.isReprojectedInTileSpace){const ze=this.locationCoordinate(this.center),Ee=r.identity([]);r.translate(Ee,Ee,[ze.x*this.worldSize,ze.y*this.worldSize,0]),r.multiply$1(Ee,Ee,Zd(this)),r.translate(Ee,Ee,[-ze.x*this.worldSize,-ze.y*this.worldSize,0]),r.multiply$1(S,S,Ee),this.inverseAdjustmentMatrix=function(Ue){const nt=Zd(Ue,!0);return le([],[nt[0],nt[1],nt[4],nt[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=r.scale([],S,[this.worldSize,this.worldSize,this.worldSize/y,1]),this.projMatrix=S,this.invProjMatrix=r.invert(new Float64Array(16),this.projMatrix);const k=new Float32Array(16);r.identity(k),r.scale(k,k,[1,-1,1]),r.rotateX(k,k,this._pitch),r.rotateZ(k,k,this.angle);const O=r.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),U=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;O[8]=2*-d.x/this.width,O[9]=2*(d.y+U)/this.height,this.skyboxMatrix=r.multiply$1(k,O,k);const G=this.point,Z=G.x,se=G.y,de=this.width%2/2,ce=this.height%2/2,te=Math.cos(this.angle),Le=Math.sin(this.angle),ve=Z-Math.round(Z)+te*de+Le*ce,De=se-Math.round(se)+te*ce+Le*de,Se=new Float64Array(S);if(r.translate(Se,Se,[ve>.5?ve-1:ve,De>.5?De-1:De,0]),this.alignedProjMatrix=Se,S=r.create(),r.scale(S,S,[this.width/2,-this.height/2,1]),r.translate(S,S,[1,-1,0]),this.labelPlaneMatrix=S,S=r.create(),r.scale(S,S,[1,-1,1]),r.translate(S,S,[-1,-1,0]),r.scale(S,S,[2/this.width,2/this.height,1]),this.glCoordMatrix=S,this.pixelMatrix=r.multiply$1(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},S=r.invert(new Float64Array(16),this.pixelMatrix),!S)throw new Error("failed to invert matrix");this.pixelMatrixInverse=S,this.globeMatrix=this.projection.name==="globe"?r.calculateGlobeMatrix(this):S,this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const o=this.cameraWorldSize,d=this.cameraPixelsPerMeter,y=this._camera.position,E=1/this.height,C=[o,o,d];r.scale$2(C,C,E),r.scale$2(y,y,-1),r.multiply$2(y,y,C);const S=r.create();r.translate(S,S,y),r.scale(S,S,C),this.mercatorFogMatrix=S,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(o,d,E)}_computeCameraPosition(o){const d=(o=o||this.pixelsPerMeter)/this.pixelsPerMeter,y=this._camera.forward(),E=this.point,C=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*d-o/this.worldSize*this._centerAltitude;return[E.x/this.worldSize-y[0]*C,E.y/this.worldSize-y[1]*C,o/this.worldSize*this._centerAltitude-y[2]*C]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(o){const d=this._maxCameraBoundsDistance()*Math.cos(this._pitch),y=o[2];let E=1;y>0&&(E=Math.min((d-this._camera.position[2])/y,1)),this._camera.position=r.scaleAndAdd([],this._camera.position,o,E),this._updateStateFromCamera(),this.projection.wrap&&(this.center=this.center.wrap())}_updateStateFromCamera(){const o=this._camera.position,d=this._camera.forward(),{pitch:y,bearing:E}=this._camera.getPitchBearing(),C=r.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,S=this._mercatorZfromZoom(this._maxZoom)*Math.cos(r.degToRad(this._maxPitch)),k=Math.max((o[2]-C)/Math.cos(y),S),O=this._zoomFromMercatorZ(k);r.scaleAndAdd(o,o,d,k),this._pitch=r.clamp(y,r.degToRad(this.minPitch),r.degToRad(this.maxPitch)),this.angle=r.wrap(E,-Math.PI,Math.PI),this._setZoom(r.clamp(O,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new r.MercatorCoordinate(o[0],o[1],o[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(o){return Math.pow(2,o)*this.tileSize}_mercatorZfromZoom(o){return this.cameraToCenterDistance/this._worldSizeFromZoom(o)}_minimumHeightOverTerrain(){const o=Math.min((this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(o)}_zoomFromMercatorZ(o){return this.scaleZoom(this.cameraToCenterDistance/(o*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(r.warnOnce("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."),1))}anyCornerOffEdge(o,d){const y=Math.min(o.x,d.x),E=Math.max(o.x,d.x),C=Math.min(o.y,d.y),S=Math.max(o.y,d.y);if(C<this.horizonLineFromTop(!1))return!0;if(this.projection.name!=="mercator")return!1;const k=[new r.pointGeometry(y,C),new r.pointGeometry(E,S),new r.pointGeometry(y,S),new r.pointGeometry(E,C)],O=this.renderWorldCopies?-3:0,U=this.renderWorldCopies?4:1;for(const G of k){const Z=this.pointRayIntersection(G);if(Z.t<0)return!0;const se=this.rayIntersectionCoordinate(Z);if(se.x<O||se.y<0||se.x>U||se.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+r.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new r.pointGeometry(0,0),new r.pointGeometry(this.width,this.height))}zoomDeltaToMovement(o,d){const y=r.length(r.sub([],this._camera.position,o)),E=this._zoomFromMercatorZ(y)+d;return y-this._mercatorZfromZoom(E)}getCameraPoint(){const o=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new r.pointGeometry(0,o))}}function Qd(m,o){let d=!1,y=null;const E=()=>{y=null,d&&(m(),y=setTimeout(E,o),d=!1)};return()=>(d=!0,y||E(),y)}class eg{constructor(o){this._hashName=o&&encodeURIComponent(o),r.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Qd(this._updateHashUnthrottled.bind(this),300)}addTo(o){return this._map=o,r.window.addEventListener("hashchange",this._onHashChange,!1),o.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),r.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(o){const d=this._map;if(!d)return"";const y=d.getCenter(),E=Math.round(100*d.getZoom())/100,C=Math.ceil((E*Math.LN2+Math.log(512/360/.5))/Math.LN10),S=Math.pow(10,C),k=Math.round(y.lng*S)/S,O=Math.round(y.lat*S)/S,U=d.getBearing(),G=d.getPitch();let Z="";if(Z+=o?`/${k}/${O}/${E}`:`${E}/${O}/${k}`,(U||G)&&(Z+="/"+Math.round(10*U)/10),G&&(Z+=`/${Math.round(G)}`),this._hashName){const se=this._hashName;let de=!1;const ce=r.window.location.hash.slice(1).split("&").map(te=>{const Le=te.split("=")[0];return Le===se?(de=!0,`${Le}=${Z}`):te}).filter(te=>te);return de||ce.push(`${se}=${Z}`),`#${ce.join("&")}`}return`#${Z}`}_getCurrentHash(){const o=r.window.location.hash.replace("#","");if(this._hashName){let d;return o.split("&").map(y=>y.split("=")).forEach(y=>{y[0]===this._hashName&&(d=y)}),(d&&d[1]||"").split("/")}return o.split("/")}_onHashChange(){const o=this._map;if(!o)return!1;const d=this._getCurrentHash();if(d.length>=3&&!d.some(y=>isNaN(y))){const y=o.dragRotate.isEnabled()&&o.touchZoomRotate.isEnabled()?+(d[3]||0):o.getBearing();return o.jumpTo({center:[+d[2],+d[1]],zoom:+d[0],bearing:y,pitch:+(d[4]||0)}),!0}return!1}_updateHashUnthrottled(){const o=r.window.location.href.replace(/(#.+)?$/,this.getHashString());r.window.history.replaceState(r.window.history.state,null,o)}}const Oo={linearity:.3,easing:r.bezier(0,0,.3,1)},tg=r.extend({deceleration:2500,maxSpeed:1400},Oo),ng=r.extend({deceleration:20,maxSpeed:1400},Oo),ig=r.extend({deceleration:1e3,maxSpeed:360},Oo),rg=r.extend({deceleration:1e3,maxSpeed:90},Oo);class og{constructor(o){this._map=o,this.clear()}clear(){this._inertiaBuffer=[]}record(o){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:r.exported.now(),settings:o})}_drainInertiaBuffer(){const o=this._inertiaBuffer,d=r.exported.now();for(;o.length>0&&d-o[0].time>160;)o.shift()}_onMoveEnd(o){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const d={zoom:0,bearing:0,pitch:0,pan:new r.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:C}of this._inertiaBuffer)d.zoom+=C.zoomDelta||0,d.bearing+=C.bearingDelta||0,d.pitch+=C.pitchDelta||0,C.panDelta&&d.pan._add(C.panDelta),C.around&&(d.around=C.around),C.pinchAround&&(d.pinchAround=C.pinchAround);const y=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,E={};if(d.pan.mag()){const C=Hi(d.pan.mag(),y,r.extend({},tg,o||{}));E.offset=d.pan.mult(C.amount/d.pan.mag()),E.center=this._map.transform.center,Bl(E,C)}if(d.zoom){const C=Hi(d.zoom,y,ng);E.zoom=this._map.transform.zoom+C.amount,Bl(E,C)}if(d.bearing){const C=Hi(d.bearing,y,ig);E.bearing=this._map.transform.bearing+r.clamp(C.amount,-179,179),Bl(E,C)}if(d.pitch){const C=Hi(d.pitch,y,rg);E.pitch=this._map.transform.pitch+C.amount,Bl(E,C)}if(E.zoom||E.bearing){const C=d.pinchAround===void 0?d.around:d.pinchAround;E.around=C?this._map.unproject(C):this._map.getCenter()}return this.clear(),E.noMoveStart=!0,E}}function Bl(m,o){(!m.duration||m.duration<o.duration)&&(m.duration=o.duration,m.easing=o.easing)}function Hi(m,o,d){const{maxSpeed:y,linearity:E,deceleration:C}=d,S=r.clamp(m*E/(o/1e3),-y,y),k=Math.abs(S)/(C*E);return{easing:d.easing,duration:1e3*k,amount:S*(k/2)}}class Ir extends r.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(o,d,y,E={}){const C=H(d.getCanvasContainer(),y),S=d.unproject(C);super(o,r.extend({point:C,lngLat:S,originalEvent:y},E)),this._defaultPrevented=!1,this.target=d}}class Ol extends r.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(o,d,y){const E=o==="touchend"?y.changedTouches:y.touches,C=Q(d.getCanvasContainer(),E),S=C.map(O=>d.unproject(O)),k=C.reduce((O,U,G,Z)=>O.add(U.div(Z.length)),new r.pointGeometry(0,0));super(o,{points:C,point:k,lngLats:S,lngLat:d.unproject(k),originalEvent:y}),this._defaultPrevented=!1}}class ov extends r.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(o,d,y){super(o,{originalEvent:y}),this._defaultPrevented=!1}}class av{constructor(o,d){this._map=o,this._clickTolerance=d.clickTolerance}reset(){this._mousedownPos=void 0}wheel(o){return this._firePreventable(new ov(o.type,this._map,o))}mousedown(o,d){return this._mousedownPos=d,this._firePreventable(new Ir(o.type,this._map,o))}mouseup(o){this._map.fire(new Ir(o.type,this._map,o))}preclick(o){const d=r.extend({},o);d.type="preclick",this._map.fire(new Ir(d.type,this._map,d))}click(o,d){this._mousedownPos&&this._mousedownPos.dist(d)>=this._clickTolerance||(this.preclick(o),this._map.fire(new Ir(o.type,this._map,o)))}dblclick(o){return this._firePreventable(new Ir(o.type,this._map,o))}mouseover(o){this._map.fire(new Ir(o.type,this._map,o))}mouseout(o){this._map.fire(new Ir(o.type,this._map,o))}touchstart(o){return this._firePreventable(new Ol(o.type,this._map,o))}touchmove(o){this._map.fire(new Ol(o.type,this._map,o))}touchend(o){this._map.fire(new Ol(o.type,this._map,o))}touchcancel(o){this._map.fire(new Ol(o.type,this._map,o))}_firePreventable(o){if(this._map.fire(o),o.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class No{constructor(o){this._map=o}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(o){this._map.fire(new Ir(o.type,this._map,o))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Ir("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(o){this._delayContextMenu?this._contextMenuEvent=o:this._map.fire(new Ir(o.type,this._map,o)),this._map.listens("contextmenu")&&o.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ag{constructor(o,d){this._map=o,this._el=o.getCanvasContainer(),this._container=o.getContainer(),this._clickTolerance=d.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(o,d){this.isEnabled()&&o.shiftKey&&o.button===0&&(V(),this._startPos=this._lastPos=d,this._active=!0)}mousemoveWindow(o,d){if(!this._active)return;const y=d;if(this._lastPos.equals(y)||!this._box&&y.dist(this._startPos)<this._clickTolerance)return;const E=this._startPos;this._lastPos=y,this._box||(this._box=A("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",o));const C=Math.min(E.x,y.x),S=Math.max(E.x,y.x),k=Math.min(E.y,y.y),O=Math.max(E.y,y.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${C}px,${k}px)`,this._box.style.width=S-C+"px",this._box.style.height=O-k+"px")})}mouseupWindow(o,d){if(!this._active||o.button!==0)return;const y=this._startPos,E=d;if(this.reset(),ne(),y.x!==E.x||y.y!==E.y)return this._map.fire(new r.Event("boxzoomend",{originalEvent:o})),{cameraAnimation:C=>C.fitScreenCoordinates(y,E,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",o)}keydown(o){this._active&&o.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",o))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),j(),delete this._startPos,delete this._lastPos}_fireEvent(o,d){return this._map.fire(new r.Event(o,{originalEvent:d}))}}function da(m,o){const d={};for(let y=0;y<m.length;y++)d[m[y].identifier]=o[y];return d}class Mo{constructor(o){this.reset(),this.numTouches=o.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(o,d,y){(this.centroid||y.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=o.timeStamp),y.length===this.numTouches&&(this.centroid=function(E){const C=new r.pointGeometry(0,0);for(const S of E)C._add(S);return C.div(E.length)}(d),this.touches=da(y,d)))}touchmove(o,d,y){if(this.aborted||!this.centroid)return;const E=da(y,d);for(const C in this.touches){const S=this.touches[C],k=E[C];(!k||k.dist(S)>30)&&(this.aborted=!0)}}touchend(o,d,y){if((!this.centroid||o.timeStamp-this.startTime>500)&&(this.aborted=!0),y.length===0){const E=!this.aborted&&this.centroid;if(this.reset(),E)return E}}}class Ss{constructor(o){this.singleTap=new Mo(o),this.numTaps=o.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(o,d,y){this.singleTap.touchstart(o,d,y)}touchmove(o,d,y){this.singleTap.touchmove(o,d,y)}touchend(o,d,y){const E=this.singleTap.touchend(o,d,y);if(E){const C=o.timeStamp-this.lastTime<500,S=!this.lastTap||this.lastTap.dist(E)<30;if(C&&S||this.reset(),this.count++,this.lastTime=o.timeStamp,this.lastTap=E,this.count===this.numTaps)return this.reset(),E}}}class $t{constructor(){this._zoomIn=new Ss({numTouches:1,numTaps:2}),this._zoomOut=new Ss({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(o,d,y){this._zoomIn.touchstart(o,d,y),this._zoomOut.touchstart(o,d,y)}touchmove(o,d,y){this._zoomIn.touchmove(o,d,y),this._zoomOut.touchmove(o,d,y)}touchend(o,d,y){const E=this._zoomIn.touchend(o,d,y),C=this._zoomOut.touchend(o,d,y);return E?(this._active=!0,o.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:S=>S.easeTo({duration:300,zoom:S.getZoom()+1,around:S.unproject(E)},{originalEvent:o})}):C?(this._active=!0,o.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:S=>S.easeTo({duration:300,zoom:S.getZoom()-1,around:S.unproject(C)},{originalEvent:o})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const sg={0:1,2:2};class Ru{constructor(o){this.reset(),this._clickTolerance=o.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(o,d){return!1}_move(o,d){return{}}mousedown(o,d){if(this._lastPoint)return;const y=ae(o);this._correctButton(o,y)&&(this._lastPoint=d,this._eventButton=y)}mousemoveWindow(o,d){const y=this._lastPoint;if(y){if(o.preventDefault(),this._eventButton!=null&&function(E,C){const S=sg[C];return E.buttons===void 0||(E.buttons&S)!==S}(o,this._eventButton))this.reset();else if(this._moved||!(d.dist(y)<this._clickTolerance))return this._moved=!0,this._lastPoint=d,this._move(y,d)}}mouseupWindow(o){this._lastPoint&&ae(o)===this._eventButton&&(this._moved&&ne(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Nl extends Ru{mousedown(o,d){super.mousedown(o,d),this._lastPoint&&(this._active=!0)}_correctButton(o,d){return d===0&&!o.ctrlKey}_move(o,d){return{around:d,panDelta:d.sub(o)}}}class Ls extends Ru{_correctButton(o,d){return d===0&&o.ctrlKey||d===2}_move(o,d){const y=.8*(d.x-o.x);if(y)return this._active=!0,{bearingDelta:y}}contextmenu(o){o.preventDefault()}}class ep extends Ru{_correctButton(o,d){return d===0&&o.ctrlKey||d===2}_move(o,d){const y=-.5*(d.y-o.y);if(y)return this._active=!0,{pitchDelta:y}}contextmenu(o){o.preventDefault()}}class lg{constructor(o,d){this._map=o,this._el=o.getCanvasContainer(),this._minTouches=1,this._clickTolerance=d.clickTolerance||1,this.reset(),r.bindAll(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new r.pointGeometry(0,0)}touchstart(o,d,y){return this._calculateTransform(o,d,y)}touchmove(o,d,y){if(this._active&&!(y.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(y.length===1)return void this._showTouchPanBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return o.preventDefault(),this._calculateTransform(o,d,y)}}touchend(o,d,y){this._calculateTransform(o,d,y),this._active&&y.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(o,d,y){y.length>0&&(this._active=!0);const E=da(y,d),C=new r.pointGeometry(0,0),S=new r.pointGeometry(0,0);let k=0;for(const U in E){const G=E[U],Z=this._touches[U];Z&&(C._add(G),S._add(G.sub(Z)),k++,E[U]=G)}if(this._touches=E,k<this._minTouches||!S.mag())return;const O=S.div(k);return this._sum._add(O),this._sum.mag()<this._clickTolerance?void 0:{around:C.div(k),panDelta:O}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=A("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility==="hidden"&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")},500)}}class ku{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(o){}_move(o,d,y){return{}}touchstart(o,d,y){this._firstTwoTouches||y.length<2||(this._firstTwoTouches=[y[0].identifier,y[1].identifier],this._start([d[0],d[1]]))}touchmove(o,d,y){const E=this._firstTwoTouches;if(!E)return;o.preventDefault();const[C,S]=E,k=Ul(y,d,C),O=Ul(y,d,S);if(!k||!O)return;const U=this._aroundCenter?null:k.add(O).div(2);return this._move([k,O],U,o)}touchend(o,d,y){if(!this._firstTwoTouches)return;const[E,C]=this._firstTwoTouches,S=Ul(y,d,E),k=Ul(y,d,C);S&&k||(this._active&&ne(),this.reset())}touchcancel(){this.reset()}enable(o){this._enabled=!0,this._aroundCenter=!!o&&o.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Ul(m,o,d){for(let y=0;y<m.length;y++)if(m[y].identifier===d)return o[y]}function tp(m,o){return Math.log(m/o)/Math.LN2}class cg extends ku{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(o){this._startDistance=this._distance=o[0].dist(o[1])}_move(o,d){const y=this._distance;if(this._distance=o[0].dist(o[1]),this._active||!(Math.abs(tp(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:tp(this._distance,y),pinchAround:d}}}function np(m,o){return 180*m.angleWith(o)/Math.PI}class zu extends ku{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(o){this._startVector=this._vector=o[0].sub(o[1]),this._minDiameter=o[0].dist(o[1])}_move(o,d){const y=this._vector;if(this._vector=o[0].sub(o[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:np(this._vector,y),pinchAround:d}}_isBelowThreshold(o){this._minDiameter=Math.min(this._minDiameter,o.mag());const d=25/(Math.PI*this._minDiameter)*360,y=np(o,this._startVector);return Math.abs(y)<d}}function Vl(m){return Math.abs(m.y)>Math.abs(m.x)}class Fu extends ku{constructor(o){super(),this._map=o}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(o){this._lastPoints=o,Vl(o[0].sub(o[1]))&&(this._valid=!1)}_move(o,d,y){const E=this._lastPoints;if(!E)return;const C=o[0].sub(E[0]),S=o[1].sub(E[1]);return this._map._cooperativeGestures&&y.touches.length<3||(this._valid=this.gestureBeginsVertically(C,S,y.timeStamp),!this._valid)?void 0:(this._lastPoints=o,this._active=!0,{pitchDelta:(C.y+S.y)/2*-.5})}gestureBeginsVertically(o,d,y){if(this._valid!==void 0)return this._valid;const E=o.mag()>=2,C=d.mag()>=2;if(!E&&!C)return;if(!E||!C)return this._firstMove==null&&(this._firstMove=y),y-this._firstMove<100&&void 0;const S=o.y>0==d.y>0;return Vl(o)&&Vl(d)&&S}}const ug={panStep:100,bearingStep:15,pitchStep:10};class hg{constructor(){const o=ug;this._panStep=o.panStep,this._bearingStep=o.bearingStep,this._pitchStep=o.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(o){if(o.altKey||o.ctrlKey||o.metaKey)return;let d=0,y=0,E=0,C=0,S=0;switch(o.keyCode){case 61:case 107:case 171:case 187:d=1;break;case 189:case 109:case 173:d=-1;break;case 37:o.shiftKey?y=-1:(o.preventDefault(),C=-1);break;case 39:o.shiftKey?y=1:(o.preventDefault(),C=1);break;case 38:o.shiftKey?E=1:(o.preventDefault(),S=-1);break;case 40:o.shiftKey?E=-1:(o.preventDefault(),S=1);break;default:return}return this._rotationDisabled&&(y=0,E=0),{cameraAnimation:k=>{const O=k.getZoom();k.easeTo({duration:300,easeId:"keyboardHandler",easing:dg,zoom:d?Math.round(O)+d*(o.shiftKey?2:1):O,bearing:k.getBearing()+y*this._bearingStep,pitch:k.getPitch()+E*this._pitchStep,offset:[-C*this._panStep,-S*this._panStep],center:k.getCenter()},{originalEvent:o})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function dg(m){return m*(2-m)}const ip=4.000244140625;class pg{constructor(o,d){this._map=o,this._el=o.getCanvasContainer(),this._handler=d,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,r.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen"],this)}setZoomRate(o){this._defaultZoomRate=o}setWheelZoomRate(o){this._wheelZoomRate=o}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(o){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!o&&o.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(o){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(o.ctrlKey||o.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let d=o.deltaMode===r.window.WheelEvent.DOM_DELTA_LINE?40*o.deltaY:o.deltaY;const y=r.exported.now(),E=y-(this._lastWheelEventTime||0);this._lastWheelEventTime=y,d!==0&&d%ip==0?this._type="wheel":d!==0&&Math.abs(d)<4?this._type="trackpad":E>400?(this._type=null,this._lastValue=d,this._timeout=setTimeout(this._onTimeout,40,o)):this._type||(this._type=Math.abs(E*d)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,d+=this._lastValue)),o.shiftKey&&d&&(d/=4),this._type&&(this._lastWheelEvent=o,this._delta-=d,this._active||this._start(o)),o.preventDefault()}_onTimeout(o){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(o)}_start(o){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const d=H(this._el,o);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:d,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const o=this._map.transform,d=()=>o._terrainEnabled()&&this._aroundCoord?o.computeZoomRelativeTo(this._aroundCoord):o.zoom;if(this._delta!==0){const O=this._type==="wheel"&&Math.abs(this._delta)>ip?this._wheelZoomRate:this._defaultZoomRate;let U=2/(1+Math.exp(-Math.abs(this._delta*O)));this._delta<0&&U!==0&&(U=1/U);const G=d(),Z=Math.pow(2,G),se=typeof this._targetZoom=="number"?o.zoomScale(this._targetZoom):Z;this._targetZoom=Math.min(o.maxZoom,Math.max(o.minZoom,o.scaleZoom(se*U))),this._type==="wheel"&&(this._startZoom=d(),this._easing=this._smoothOutEasing(200)),this._delta=0}const y=typeof this._targetZoom=="number"?this._targetZoom:d(),E=this._startZoom,C=this._easing;let S,k=!1;if(this._type==="wheel"&&E&&C){const O=Math.min((r.exported.now()-this._lastWheelEventTime)/200,1),U=C(O);S=r.number(E,y,U),O<1?this._frameId||(this._frameId=!0):k=!0}else S=y,k=!0;return this._active=!0,k&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!k,zoomDelta:S-d(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(o){let d=r.ease;if(this._prevEase){const y=this._prevEase,E=(r.exported.now()-y.start)/y.duration,C=y.easing(E+.01)-y.easing(E),S=.27/Math.sqrt(C*C+1e-4)*.01,k=Math.sqrt(.0729-S*S);d=r.bezier(S,k,.25,1)}return this._prevEase={start:r.exported.now(),duration:o,easing:d},d}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=A("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(r.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_isFullscreen(){return!!r.window.document.fullscreenElement||!!r.window.document.webkitFullscreenElement}_showBlockerAlert(){this._alertContainer.style.visibility==="hidden"&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")},200)}}class fg{constructor(o,d){this._clickZoom=o,this._tapZoom=d}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class mg{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(o,d){return o.preventDefault(),{cameraAnimation:y=>{y.easeTo({duration:300,zoom:y.getZoom()+(o.shiftKey?-1:1),around:y.unproject(d)},{originalEvent:o})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class rp{constructor(){this._tap=new Ss({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(o,d,y){this._swipePoint||(this._tapTime&&o.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?y.length>0&&(this._swipePoint=d[0],this._swipeTouch=y[0].identifier):this._tap.touchstart(o,d,y))}touchmove(o,d,y){if(this._tapTime){if(this._swipePoint){if(y[0].identifier!==this._swipeTouch)return;const E=d[0],C=E.y-this._swipePoint.y;return this._swipePoint=E,o.preventDefault(),this._active=!0,{zoomDelta:C/128}}}else this._tap.touchmove(o,d,y)}touchend(o,d,y){this._tapTime?this._swipePoint&&y.length===0&&this.reset():this._tap.touchend(o,d,y)&&(this._tapTime=o.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class gg{constructor(o,d,y){this._el=o,this._mousePan=d,this._touchPan=y}enable(o){this._inertiaOptions=o||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class yg{constructor(o,d,y){this._pitchWithRotate=o.pitchWithRotate,this._mouseRotate=d,this._mousePitch=y}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class _g{constructor(o,d,y,E){this._el=o,this._touchZoom=d,this._touchRotate=y,this._tapDragZoom=E,this._rotationDisabled=!1,this._enabled=!0}enable(o){this._touchZoom.enable(o),this._rotationDisabled||this._touchRotate.enable(o),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Gl=m=>m.zoom||m.drag||m.pitch||m.rotate;class op extends r.Event{}class vg{constructor(){this.constants=[1,1,.01],this.radius=0}setup(o,d){const y=r.sub([],d,o);this.radius=r.length(y[2]<0?r.div([],y,this.constants):[y[0],y[1],0])}projectRay(o){r.div(o,o,this.constants),r.normalize(o,o),r.mul$1(o,o,this.constants);const d=r.scale$2([],o,this.radius);if(d[2]>0){const y=r.scale$2([],[0,0,1],r.dot(d,[0,0,1])),E=r.scale$2([],r.normalize([],[d[0],d[1],0]),this.radius),C=r.add([],d,r.scale$2([],r.sub([],r.add([],E,y),d),2));d[0]=C[0],d[1]=C[1]}return d}}function Is(m){return m.panDelta&&m.panDelta.mag()||m.zoomDelta||m.bearingDelta||m.pitchDelta}class xg{constructor(o,d){this._map=o,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new og(o),this._bearingSnap=d.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new vg,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(d),r.bindAll(["handleEvent","handleWindowEvent"],this);const y=this._el;this._listeners=[[y,"touchstart",{passive:!0}],[y,"touchmove",{passive:!1}],[y,"touchend",void 0],[y,"touchcancel",void 0],[y,"mousedown",void 0],[y,"mousemove",void 0],[y,"mouseup",void 0],[r.window.document,"mousemove",{capture:!0}],[r.window.document,"mouseup",void 0],[y,"mouseover",void 0],[y,"mouseout",void 0],[y,"dblclick",void 0],[y,"click",void 0],[y,"keydown",{capture:!1}],[y,"keyup",void 0],[y,"wheel",{passive:!1}],[y,"contextmenu",void 0],[r.window,"blur",void 0]];for(const[E,C,S]of this._listeners)E.addEventListener(C,E===r.window.document?this.handleWindowEvent:this.handleEvent,S)}destroy(){for(const[o,d,y]of this._listeners)o.removeEventListener(d,o===r.window.document?this.handleWindowEvent:this.handleEvent,y)}_addDefaultHandlers(o){const d=this._map,y=d.getCanvasContainer();this._add("mapEvent",new av(d,o));const E=d.boxZoom=new ag(d,o);this._add("boxZoom",E);const C=new $t,S=new mg;d.doubleClickZoom=new fg(S,C),this._add("tapZoom",C),this._add("clickZoom",S);const k=new rp;this._add("tapDragZoom",k);const O=d.touchPitch=new Fu(d);this._add("touchPitch",O);const U=new Ls(o),G=new ep(o);d.dragRotate=new yg(o,U,G),this._add("mouseRotate",U,["mousePitch"]),this._add("mousePitch",G,["mouseRotate"]);const Z=new Nl(o),se=new lg(d,o);d.dragPan=new gg(y,Z,se),this._add("mousePan",Z),this._add("touchPan",se,["touchZoom","touchRotate"]);const de=new zu,ce=new cg;d.touchZoomRotate=new _g(y,ce,de,k),this._add("touchRotate",de,["touchPan","touchZoom"]),this._add("touchZoom",ce,["touchPan","touchRotate"]),this._add("blockableMapEvent",new No(d));const te=d.scrollZoom=new pg(d,this);this._add("scrollZoom",te,["mousePan"]);const Le=d.keyboard=new hg;this._add("keyboard",Le);for(const ve of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])o.interactive&&o[ve]&&d[ve].enable(o[ve])}_add(o,d,y){this._handlers.push({handlerName:o,handler:d,allowed:y}),this._handlersById[o]=d}stop(o){if(!this._updatingCamera){for(const{handler:d}of this._handlers)d.reset();this._inertia.clear(),this._fireEvents({},{},o),this._changes=[]}}isActive(){for(const{handler:o}of this._handlers)if(o.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Gl(this._eventsInProgress)||this.isZooming()}_blockedByActive(o,d,y){for(const E in o)if(E!==y&&(!d||d.indexOf(E)<0))return!0;return!1}handleWindowEvent(o){this.handleEvent(o,`${o.type}Window`)}_getMapTouches(o){const d=[];for(const y of o)this._el.contains(y.target)&&d.push(y);return d}handleEvent(o,d){this._updatingCamera=!0;const y=o.type==="renderFrame",E=y?void 0:o,C={needsRenderFrame:!1},S={},k={},O=o.touches?this._getMapTouches(o.touches):void 0,U=O?Q(this._el,O):y?void 0:H(this._el,o);for(const{handlerName:se,handler:de,allowed:ce}of this._handlers){if(!de.isEnabled())continue;let te;this._blockedByActive(k,ce,se)?de.reset():de[d||o.type]&&(te=de[d||o.type](o,U,O),this.mergeHandlerResult(C,S,te,se,E),te&&te.needsRenderFrame&&this._triggerRenderFrame()),(te||de.isActive())&&(k[se]=de)}const G={};for(const se in this._previousActiveHandlers)k[se]||(G[se]=E);this._previousActiveHandlers=k,(Object.keys(G).length||Is(C))&&(this._changes.push([C,S,G]),this._triggerRenderFrame()),(Object.keys(k).length||Is(C))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:Z}=C;Z&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],Z(this._map))}mergeHandlerResult(o,d,y,E,C){if(!y)return;r.extend(o,y);const S={handlerName:E,originalEvent:y.originalEvent||C};y.zoomDelta!==void 0&&(d.zoom=S),y.panDelta!==void 0&&(d.drag=S),y.pitchDelta!==void 0&&(d.pitch=S),y.bearingDelta!==void 0&&(d.rotate=S)}_applyChanges(){const o={},d={},y={};for(const[E,C,S]of this._changes)E.panDelta&&(o.panDelta=(o.panDelta||new r.pointGeometry(0,0))._add(E.panDelta)),E.zoomDelta&&(o.zoomDelta=(o.zoomDelta||0)+E.zoomDelta),E.bearingDelta&&(o.bearingDelta=(o.bearingDelta||0)+E.bearingDelta),E.pitchDelta&&(o.pitchDelta=(o.pitchDelta||0)+E.pitchDelta),E.around!==void 0&&(o.around=E.around),E.aroundCoord!==void 0&&(o.aroundCoord=E.aroundCoord),E.pinchAround!==void 0&&(o.pinchAround=E.pinchAround),E.noInertia&&(o.noInertia=E.noInertia),r.extend(d,C),r.extend(y,S);this._updateMapTransform(o,d,y),this._changes=[]}_updateMapTransform(o,d,y){const E=this._map,C=E.transform,S=De=>[De.x,De.y,De.z];if((De=>{const Se=this._eventsInProgress.drag;return Se&&!this._handlersById[Se.handlerName].isActive()})()&&!Is(o)){const De=C.zoom;C.cameraElevationReference="sea",C.recenterOnTerrain(),C.cameraElevationReference="ground",De!==C.zoom&&this._map._update(!0)}if(!Is(o))return void this._fireEvents(d,y,!0);let{panDelta:k,zoomDelta:O,bearingDelta:U,pitchDelta:G,around:Z,aroundCoord:se,pinchAround:de}=o;de!==void 0&&(Z=de),(De=>d.drag&&!this._eventsInProgress.drag)()&&Z&&(this._dragOrigin=S(C.pointCoordinate3D(Z)),this._trackingEllipsoid.setup(C._camera.position,this._dragOrigin)),C.cameraElevationReference="sea",E._stop(!0),Z=Z||E.transform.centerPoint,U&&(C.bearing+=U),G&&(C.pitch+=G),C._updateCameraState();const ce=[0,0,0];if(k){const De=C.pointCoordinate(Z);if(C.projection.name==="globe"){const Se=r.latFromMercatorY(De.y),ze=C.center.lat,Ee=Math.min(r.mercatorZfromAltitude(1,Se)/r.mercatorZfromAltitude(1,ze),2);k=k.rotate(-C.angle),ce[0]=-k.x/C.worldSize*Ee,ce[1]=-k.y/C.worldSize*Ee}else{const Se=C.pointCoordinate(Z.sub(k));De&&Se&&(ce[0]=Se.x-De.x,ce[1]=Se.y-De.y)}}const te=C.zoom,Le=[0,0,0];if(O){const De=S(se||C.pointCoordinate3D(Z)),Se={dir:r.normalize([],r.sub([],De,C._camera.position))};if(Se.dir[2]<0){const ze=C.zoomDeltaToMovement(De,O);r.scale$2(Le,Se.dir,ze)}}const ve=r.add(ce,ce,Le);C._translateCameraConstrained(ve),O&&Math.abs(C.zoom-te)>1e-4&&C.recenterOnTerrain(),C.cameraElevationReference="ground",this._map._update(),o.noInertia||this._inertia.record(o),this._fireEvents(d,y,!0)}_fireEvents(o,d,y){const E=Gl(this._eventsInProgress),C=Gl(o),S={};for(const G in o){const{originalEvent:Z}=o[G];this._eventsInProgress[G]||(S[`${G}start`]=Z),this._eventsInProgress[G]=o[G]}!E&&C&&this._fireEvent("movestart",C.originalEvent);for(const G in S)this._fireEvent(G,S[G]);C&&this._fireEvent("move",C.originalEvent);for(const G in o){const{originalEvent:Z}=o[G];this._fireEvent(G,Z)}const k={};let O;for(const G in this._eventsInProgress){const{handlerName:Z,originalEvent:se}=this._eventsInProgress[G];this._handlersById[Z].isActive()||(delete this._eventsInProgress[G],O=d[Z]||se,k[`${G}end`]=O)}for(const G in k)this._fireEvent(G,k[G]);const U=Gl(this._eventsInProgress);if(y&&(E||C)&&!U){this._updatingCamera=!0;const G=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),Z=se=>se!==0&&-this._bearingSnap<se&&se<this._bearingSnap;G?(Z(G.bearing||this._map.getBearing())&&(G.bearing=0),this._map.easeTo(G,{originalEvent:O})):(this._map.fire(new r.Event("moveend",{originalEvent:O})),Z(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(o,d){this._map.fire(new r.Event(o,d?{originalEvent:d}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(o=>{this._frameId=void 0,this.handleEvent(new op("renderFrame",{timeStamp:o})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const Bu="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class ap extends r.Evented{constructor(o,d){super(),this._moving=!1,this._zooming=!1,this.transform=o,this._bearingSnap=d.bearingSnap,r.bindAll(["_renderFrameCallback"],this)}getCenter(){return new r.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(o,d){return this.jumpTo({center:o},d)}panBy(o,d,y){return o=r.pointGeometry.convert(o).mult(-1),this.panTo(this.transform.center,r.extend({offset:o},d),y)}panTo(o,d,y){return this.easeTo(r.extend({center:o},d),y)}getZoom(){return this.transform.zoom}setZoom(o,d){return this.jumpTo({zoom:o},d),this}zoomTo(o,d,y){return this.easeTo(r.extend({zoom:o},d),y)}zoomIn(o,d){return this.zoomTo(this.getZoom()+1,o,d),this}zoomOut(o,d){return this.zoomTo(this.getZoom()-1,o,d),this}getBearing(){return this.transform.bearing}setBearing(o,d){return this.jumpTo({bearing:o},d),this}getPadding(){return this.transform.padding}setPadding(o,d){return this.jumpTo({padding:o},d),this}rotateTo(o,d,y){return this.easeTo(r.extend({bearing:o},d),y)}resetNorth(o,d){return this.rotateTo(0,r.extend({duration:1e3},o),d),this}resetNorthPitch(o,d){return this.easeTo(r.extend({bearing:0,pitch:0,duration:1e3},o),d),this}snapToNorth(o,d){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(o,d):this}getPitch(){return this.transform.pitch}setPitch(o,d){return this.jumpTo({pitch:o},d),this}cameraForBounds(o,d){o=r.LngLatBounds.convert(o);const y=d&&d.bearing||0;return this._cameraForBoxAndBearing(o.getNorthWest(),o.getSouthEast(),y,d)}_extendCameraOptions(o){const d={top:0,bottom:0,right:0,left:0};if(typeof(o=r.extend({padding:d,offset:[0,0],maxZoom:this.transform.maxZoom},o)).padding=="number"){const y=o.padding;o.padding={top:y,bottom:y,right:y,left:y}}return o.padding=r.extend(d,o.padding),o}_cameraForBoxAndBearing(o,d,y,E){const C=this._extendCameraOptions(E),S=this.transform,k=S.padding,O=S.project(r.LngLat.convert(o)),U=S.project(r.LngLat.convert(d)),G=new r.pointGeometry(O.x,U.y),Z=new r.pointGeometry(U.x,O.y),se=-r.degToRad(y),de=O.rotate(se),ce=U.rotate(se),te=G.rotate(se),Le=Z.rotate(se),ve=new r.pointGeometry(Math.max(de.x,ce.x,te.x,Le.x),Math.max(de.y,ce.y,te.y,Le.y)),De=new r.pointGeometry(Math.min(de.x,ce.x,te.x,Le.x),Math.min(de.y,ce.y,te.y,Le.y)),Se=ve.sub(De),ze=(S.width-((k.left||0)+(k.right||0)+C.padding.left+C.padding.right))/Se.x,Ee=(S.height-((k.top||0)+(k.bottom||0)+C.padding.top+C.padding.bottom))/Se.y;if(Ee<0||ze<0)return void r.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const Ue=Math.min(S.scaleZoom(S.scale*Math.min(ze,Ee)),C.maxZoom),nt=typeof C.offset.x=="number"&&typeof C.offset.y=="number"?new r.pointGeometry(C.offset.x,C.offset.y):r.pointGeometry.convert(C.offset),lt=new r.pointGeometry((C.padding.left-C.padding.right)/2,(C.padding.top-C.padding.bottom)/2).rotate(y*Math.PI/180),pt=nt.add(lt).mult(S.scale/S.zoomScale(Ue));return{center:S.unproject(O.add(U).div(2).sub(pt)),zoom:Ue,bearing:y}}_cameraForBox(o,d,y,E,C){const S=this._extendCameraOptions(C);y=y||0,E=E||0,o=r.LngLat.convert(o),d=r.LngLat.convert(d);const k=this.transform.clone();k.padding=S.padding;const O=this.getFreeCameraOptions(),U=new r.LngLat(.5*(o.lng+d.lng),.5*(o.lat+d.lat)),G=.5*(y+E);if(k._camera.position[2]<r.mercatorZfromAltitude(G,U.lat))return void r.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");O.lookAtPoint(U),k.setFreeCameraOptions(O);const Z=r.MercatorCoordinate.fromLngLat(o),se=r.MercatorCoordinate.fromLngLat(d),de=k.pointRayIntersection(k.centerPoint,G),ce=[(te=k.rayIntersectionCoordinate(de)).x,te.y,te.z];var te;const Le=k.screenPointToMercatorRay(k.centerPoint),ve=k.projection.name!=="globe";let De,Se=0;do{const ze=Math.floor(k.zoom),Ee=1<<ze,Ue=Math.min(Ee*Z.x,Ee*se.x),nt=Math.min(Ee*Z.y,Ee*se.y),lt=Math.max(Ee*Z.x,Ee*se.x),pt=Math.max(Ee*Z.y,Ee*se.y),ht=new r.Aabb([Ue,nt,y],[lt,pt,E]),kt=r.Frustum.fromInvProjectionMatrix(k.invProjMatrix,k.worldSize,ze,ve);if(ht.intersects(kt)!==2){De&&(k._camera.position=r.scaleAndAdd([],k._camera.position,Le.dir,-De),k._updateStateFromCamera());break}const it=r.sub([],k._camera.position,ce);De=.5*r.length(it),k._camera.position=r.scaleAndAdd([],k._camera.position,Le.dir,De);try{k._updateStateFromCamera()}catch(zt){return void r.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}}while(++Se<10);return{center:k.center,zoom:k.zoom,bearing:k.bearing,pitch:k.pitch}}fitBounds(o,d,y){return this._fitInternal(this.cameraForBounds(o,d),d,y)}_raycastElevationBox(o,d){const y=this.transform.elevation;if(!y)return;const E=new r.pointGeometry(o.x,d.y),C=new r.pointGeometry(d.x,o.y),S=y.pointCoordinate(o);if(!S)return;const k=y.pointCoordinate(d);if(!k)return;const O=y.pointCoordinate(E);if(!O)return;const U=y.pointCoordinate(C);if(!U)return;const G=new r.MercatorCoordinate(S[0],S[1]).toLngLat(),Z=new r.MercatorCoordinate(k[0],k[1]).toLngLat(),se=new r.MercatorCoordinate(O[0],O[1]).toLngLat(),de=new r.MercatorCoordinate(U[0],U[1]).toLngLat(),ce=Math.min(G.lng,Math.min(Z.lng,Math.min(se.lng,de.lng))),te=Math.min(G.lat,Math.min(Z.lat,Math.min(se.lat,de.lat))),Le=Math.max(G.lng,Math.max(Z.lng,Math.max(se.lng,de.lng))),ve=Math.max(G.lat,Math.max(Z.lat,Math.max(se.lat,de.lat))),De=Math.min(S[3],Math.min(k[3],Math.min(O[3],U[3]))),Se=Math.max(S[3],Math.max(k[3],Math.max(O[3],U[3])));return{minLngLat:new r.LngLat(ce,te),maxLngLat:new r.LngLat(Le,ve),minAltitude:De,maxAltitude:Se}}fitScreenCoordinates(o,d,y,E,C){let S,k,O,U;const G=r.pointGeometry.convert(o),Z=r.pointGeometry.convert(d),se=this._raycastElevationBox(G,Z);if(se)S=se.minLngLat,k=se.maxLngLat,O=se.minAltitude,U=se.maxAltitude;else{if(this.transform.anyCornerOffEdge(G,Z))return this;S=this.transform.pointLocation(G),k=this.transform.pointLocation(Z)}return this._fitInternal(this.transform.pitch===0?this._cameraForBoxAndBearing(this.transform.pointLocation(r.pointGeometry.convert(o)),this.transform.pointLocation(r.pointGeometry.convert(d)),y,E):this._cameraForBox(S,k,O,U,E),E,C)}_fitInternal(o,d,y){return o?(delete(d=r.extend(o,d)).padding,d.linear?this.easeTo(d,y):this.flyTo(d,y)):this}jumpTo(o,d){this.stop();const y=o.preloadOnly?this.transform.clone():this.transform;let E=!1,C=!1,S=!1;return"zoom"in o&&y.zoom!==+o.zoom&&(E=!0,y.zoom=+o.zoom),o.center!==void 0&&(y.center=r.LngLat.convert(o.center)),"bearing"in o&&y.bearing!==+o.bearing&&(C=!0,y.bearing=+o.bearing),"pitch"in o&&y.pitch!==+o.pitch&&(S=!0,y.pitch=+o.pitch),o.padding==null||y.isPaddingEqual(o.padding)||(y.padding=o.padding),o.preloadOnly?(this._preloadTiles(y),this):(this.fire(new r.Event("movestart",d)).fire(new r.Event("move",d)),E&&this.fire(new r.Event("zoomstart",d)).fire(new r.Event("zoom",d)).fire(new r.Event("zoomend",d)),C&&this.fire(new r.Event("rotatestart",d)).fire(new r.Event("rotate",d)).fire(new r.Event("rotateend",d)),S&&this.fire(new r.Event("pitchstart",d)).fire(new r.Event("pitch",d)).fire(new r.Event("pitchend",d)),this.fire(new r.Event("moveend",d)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||r.warnOnce(Bu),this.transform.getFreeCameraOptions()}setFreeCameraOptions(o,d){const y=this.transform;if(!y.projection.supportsFreeCamera)return r.warnOnce(Bu),this;this.stop();const E=y.zoom,C=y.pitch,S=y.bearing;y.setFreeCameraOptions(o);const k=E!==y.zoom,O=C!==y.pitch,U=S!==y.bearing;return this.fire(new r.Event("movestart",d)).fire(new r.Event("move",d)),k&&this.fire(new r.Event("zoomstart",d)).fire(new r.Event("zoom",d)).fire(new r.Event("zoomend",d)),U&&this.fire(new r.Event("rotatestart",d)).fire(new r.Event("rotate",d)).fire(new r.Event("rotateend",d)),O&&this.fire(new r.Event("pitchstart",d)).fire(new r.Event("pitch",d)).fire(new r.Event("pitchend",d)),this.fire(new r.Event("moveend",d)),this}easeTo(o,d){this._stop(!1,o.easeId),((o=r.extend({offset:[0,0],duration:500,easing:r.ease},o)).animate===!1||!o.essential&&r.exported.prefersReducedMotion)&&(o.duration=0);const y=this.transform,E=this.getZoom(),C=this.getBearing(),S=this.getPitch(),k=this.getPadding(),O="zoom"in o?+o.zoom:E,U="bearing"in o?this._normalizeBearing(o.bearing,C):C,G="pitch"in o?+o.pitch:S,Z="padding"in o?o.padding:y.padding,se=r.pointGeometry.convert(o.offset);let de,ce,te;if(y.projection.name==="globe"){const pt=r.MercatorCoordinate.fromLngLat(y.center),ht=se.rotate(-y.angle);pt.x+=ht.x/y.worldSize,pt.y+=ht.y/y.worldSize;const kt=pt.toLngLat(),it=r.LngLat.convert(o.center||kt);this._normalizeCenter(it),de=y.centerPoint.add(ht),ce=new r.pointGeometry(pt.x,pt.y).mult(y.worldSize),te=new r.pointGeometry(r.mercatorXfromLng(it.lng),r.mercatorYfromLat(it.lat)).mult(y.worldSize).sub(ce)}else{de=y.centerPoint.add(se);const pt=y.pointLocation(de),ht=r.LngLat.convert(o.center||pt);this._normalizeCenter(ht),ce=y.project(pt),te=y.project(ht).sub(ce)}const Le=y.zoomScale(O-E);let ve,De;o.around&&(ve=r.LngLat.convert(o.around),De=y.locationPoint(ve));const Se=this._zooming||O!==E,ze=this._rotating||C!==U,Ee=this._pitching||G!==S,Ue=!y.isPaddingEqual(Z),nt=pt=>ht=>{if(Se&&(pt.zoom=r.number(E,O,ht)),ze&&(pt.bearing=r.number(C,U,ht)),Ee&&(pt.pitch=r.number(S,G,ht)),Ue&&(pt.interpolatePadding(k,Z,ht),de=pt.centerPoint.add(se)),ve)pt.setLocationAtPoint(ve,De);else{const kt=pt.zoomScale(pt.zoom-E),it=O>E?Math.min(2,Le):Math.max(.5,Le),zt=Math.pow(it,1-ht),St=pt.unproject(ce.add(te.mult(ht*zt)).mult(kt));pt.setLocationAtPoint(pt.renderWorldCopies?St.wrap():St,de)}return o.preloadOnly||this._fireMoveEvents(d),pt};if(o.preloadOnly){const pt=this._emulate(nt,o.duration,y);return this._preloadTiles(pt),this}const lt={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=Se,this._rotating=ze,this._pitching=Ee,this._padding=Ue,this._easeId=o.easeId,this._prepareEase(d,o.noMoveStart,lt),this._ease(nt(y),pt=>{y.recenterOnTerrain(),this._afterEase(d,pt)},o),this}_prepareEase(o,d,y={}){this._moving=!0,this.transform.cameraElevationReference="sea",d||y.moving||this.fire(new r.Event("movestart",o)),this._zooming&&!y.zooming&&this.fire(new r.Event("zoomstart",o)),this._rotating&&!y.rotating&&this.fire(new r.Event("rotatestart",o)),this._pitching&&!y.pitching&&this.fire(new r.Event("pitchstart",o))}_fireMoveEvents(o){this.fire(new r.Event("move",o)),this._zooming&&this.fire(new r.Event("zoom",o)),this._rotating&&this.fire(new r.Event("rotate",o)),this._pitching&&this.fire(new r.Event("pitch",o))}_afterEase(o,d){if(this._easeId&&d&&this._easeId===d)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const y=this._zooming,E=this._rotating,C=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,y&&this.fire(new r.Event("zoomend",o)),E&&this.fire(new r.Event("rotateend",o)),C&&this.fire(new r.Event("pitchend",o)),this.fire(new r.Event("moveend",o))}flyTo(o,d){if(!o.essential&&r.exported.prefersReducedMotion){const Zt=r.pick(o,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Zt,d)}this.stop(),o=r.extend({offset:[0,0],speed:1.2,curve:1.42,easing:r.ease},o);const y=this.transform,E=this.getZoom(),C=this.getBearing(),S=this.getPitch(),k=this.getPadding(),O="zoom"in o?r.clamp(+o.zoom,y.minZoom,y.maxZoom):E,U="bearing"in o?this._normalizeBearing(o.bearing,C):C,G="pitch"in o?+o.pitch:S,Z="padding"in o?o.padding:y.padding,se=y.zoomScale(O-E),de=r.pointGeometry.convert(o.offset);let ce=y.centerPoint.add(de);const te=y.pointLocation(ce),Le=r.LngLat.convert(o.center||te);this._normalizeCenter(Le);const ve=y.project(te),De=y.project(Le).sub(ve);let Se=o.curve;const ze=Math.max(y.width,y.height),Ee=ze/se,Ue=De.mag();if("minZoom"in o){const Zt=r.clamp(Math.min(o.minZoom,E,O),y.minZoom,y.maxZoom),Yt=ze/y.zoomScale(Zt-E);Se=Math.sqrt(Yt/Ue*2)}const nt=Se*Se;function lt(Zt){const Yt=(Ee*Ee-ze*ze+(Zt?-1:1)*nt*nt*Ue*Ue)/(2*(Zt?Ee:ze)*nt*Ue);return Math.log(Math.sqrt(Yt*Yt+1)-Yt)}function pt(Zt){return(Math.exp(Zt)-Math.exp(-Zt))/2}function ht(Zt){return(Math.exp(Zt)+Math.exp(-Zt))/2}const kt=lt(0);let it=function(Zt){return ht(kt)/ht(kt+Se*Zt)},zt=function(Zt){return ze*((ht(kt)*(pt(Yt=kt+Se*Zt)/ht(Yt))-pt(kt))/nt)/Ue;var Yt},St=(lt(1)-kt)/Se;if(Math.abs(Ue)<1e-6||!isFinite(St)){if(Math.abs(ze-Ee)<1e-6)return this.easeTo(o,d);const Zt=Ee<ze?-1:1;St=Math.abs(Math.log(Ee/ze))/Se,zt=function(){return 0},it=function(Yt){return Math.exp(Zt*Se*Yt)}}o.duration="duration"in o?+o.duration:1e3*St/("screenSpeed"in o?+o.screenSpeed/Se:+o.speed),o.maxDuration&&o.duration>o.maxDuration&&(o.duration=0);const Jt=C!==U,ft=G!==S,qt=!y.isPaddingEqual(Z),gn=Zt=>Yt=>{const xn=Yt*St,zn=1/it(xn);Zt.zoom=Yt===1?O:E+Zt.scaleZoom(zn),Jt&&(Zt.bearing=r.number(C,U,Yt)),ft&&(Zt.pitch=r.number(S,G,Yt)),qt&&(Zt.interpolatePadding(k,Z,Yt),ce=Zt.centerPoint.add(de));const dn=Yt===1?Le:Zt.unproject(ve.add(De.mult(zt(xn))).mult(zn));return Zt.setLocationAtPoint(Zt.renderWorldCopies?dn.wrap():dn,ce),Zt._updateCameraOnTerrain(),o.preloadOnly||this._fireMoveEvents(d),Zt};if(o.preloadOnly){const Zt=this._emulate(gn,o.duration,y);return this._preloadTiles(Zt),this}return this._zooming=!0,this._rotating=Jt,this._pitching=ft,this._padding=qt,this._prepareEase(d,!1),this._ease(gn(y),()=>this._afterEase(d),o),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(o,d){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const y=this._onEaseEnd;this._onEaseEnd=void 0,y.call(this,d)}if(!o){const y=this.handlers;y&&y.stop(!1)}return this}_ease(o,d,y){y.animate===!1||y.duration===0?(o(1),d()):(this._easeStart=r.exported.now(),this._easeOptions=y,this._onEaseFrame=o,this._onEaseEnd=d,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const o=Math.min((r.exported.now()-this._easeStart)/this._easeOptions.duration,1),d=this._onEaseFrame;d&&d(this._easeOptions.easing(o)),o<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(o,d){o=r.wrap(o,-180,180);const y=Math.abs(o-d);return Math.abs(o-360-d)<y&&(o-=360),Math.abs(o+360-d)<y&&(o+=360),o}_normalizeCenter(o){const d=this.transform;if(!d.renderWorldCopies||d.maxBounds)return;const y=o.lng-d.center.lng;o.lng+=y>180?-360:y<-180?360:0}_emulate(o,d,y){const E=Math.ceil(15*d/1e3),C=[],S=o(y.clone());for(let k=0;k<=E;k++){const O=S(k/E);C.push(O.clone())}return C}}class Ou{constructor(o={}){this.options=o,r.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(o){const d=this.options&&this.options.compact;return this._map=o,this._container=A("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=A("button","mapboxgl-ctrl-attrib-button",this._container),A("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=A("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),d&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),d===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(o,d){const y=this._map._getUIString(`AttributionControl.${d}`);o.setAttribute("aria-label",y),o.removeAttribute("title"),o.firstElementChild&&o.firstElementChild.setAttribute("title",y)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let o=this._editLink;o||(o=this._editLink=this._container.querySelector(".mapbox-improve-map"));const d=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||r.config.ACCESS_TOKEN}];if(o){const y=d.reduce((E,C,S)=>(C.value&&(E+=`${C.key}=${C.value}${S<d.length-1?"&":""}`),E),"?");o.href=`${r.config.FEEDBACK_URL}/${y}${this._map._hash?this._map._hash.getHashString(!0):""}`,o.rel="noopener nofollow",this._setElementTitle(o,"MapFeedback")}}_updateData(o){!o||o.sourceDataType!=="metadata"&&o.sourceDataType!=="visibility"&&o.dataType!=="style"||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let o=[];if(this._map.style.stylesheet){const E=this._map.style.stylesheet;this.styleOwner=E.owner,this.styleId=E.id}const d=this._map.style._sourceCaches;for(const E in d){const C=d[E];if(C.used){const S=C.getSource();S.attribution&&o.indexOf(S.attribution)<0&&o.push(S.attribution)}}o.sort((E,C)=>E.length-C.length),o=o.filter((E,C)=>{for(let S=C+1;S<o.length;S++)if(o[S].indexOf(E)>=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?o=[...this.options.customAttribution,...o]:o.unshift(this.options.customAttribution));const y=o.join(" | ");y!==this._attribHTML&&(this._attribHTML=y,o.length?(this._innerContainer.innerHTML=y,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class bg{constructor(){r.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(o){this._map=o,this._container=A("div","mapboxgl-ctrl");const d=A("a","mapboxgl-ctrl-logo");return d.target="_blank",d.rel="noopener nofollow",d.href="https://www.mapbox.com/",d.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),d.setAttribute("rel","noopener nofollow"),this._container.appendChild(d),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(o){o&&o.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const o=this._map.style._sourceCaches;if(Object.entries(o).length===0)return!0;for(const d in o){const y=o[d].getSource();if(y.hasOwnProperty("mapbox_logo")&&!y.mapbox_logo)return!1}return!0}_updateCompact(){const o=this._container.children;if(o.length){const d=o[0];this._map.getCanvasContainer().offsetWidth<250?d.classList.add("mapboxgl-compact"):d.classList.remove("mapboxgl-compact")}}}class wg{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(o){const d=++this._id;return this._queue.push({callback:o,id:d,cancelled:!1}),d}remove(o){const d=this._currentlyRunning,y=d?this._queue.concat(d):this._queue;for(const E of y)if(E.id===o)return void(E.cancelled=!0)}run(o=0){const d=this._currentlyRunning=this._queue;this._queue=[];for(const y of d)if(!y.cancelled&&(y.callback(o),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Nu(m,o,d){if(m=new r.LngLat(m.lng,m.lat),o){const y=new r.LngLat(m.lng-360,m.lat),E=new r.LngLat(m.lng+360,m.lat),C=360*Math.ceil(Math.abs(m.lng-d.center.lng)/360),S=d.locationPoint(m).distSqr(o),k=o.x<0||o.y<0||o.x>d.width||o.y>d.height;d.locationPoint(y).distSqr(o)<S&&(k||Math.abs(y.lng-d.center.lng)<C)?m=y:d.locationPoint(E).distSqr(o)<S&&(k||Math.abs(E.lng-d.center.lng)<C)&&(m=E)}for(;Math.abs(m.lng-d.center.lng)>180;){const y=d.locationPoint(m);if(y.x>=0&&y.y>=0&&y.x<=d.width&&y.y<=d.height)break;m.lng>d.center.lng?m.lng-=360:m.lng+=360}return m}const Uu={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class Vu extends r.Evented{constructor(o,d){if(super(),(o instanceof r.window.HTMLElement||d)&&(o=r.extend({element:o},d)),r.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=o&&o.anchor||"center",this._color=o&&o.color||"#3FB1CE",this._scale=o&&o.scale||1,this._draggable=o&&o.draggable||!1,this._clickTolerance=o&&o.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=o&&o.rotation||0,this._rotationAlignment=o&&o.rotationAlignment||"auto",this._pitchAlignment=o&&o.pitchAlignment&&o.pitchAlignment!=="auto"?o.pitchAlignment:this._rotationAlignment,this._updateMoving=()=>this._update(!0),o&&o.element)this._element=o.element,this._offset=r.pointGeometry.convert(o&&o.offset||[0,0]);else{this._defaultMarker=!0,this._element=A("div");const E=41,C=27,S=L("svg",{display:"block",height:E*this._scale+"px",width:C*this._scale+"px",viewBox:`0 0 ${C} ${E}`},this._element),k=L("radialGradient",{id:"shadowGradient"},L("defs",{},S));L("stop",{offset:"10%","stop-opacity":.4},k),L("stop",{offset:"100%","stop-opacity":.05},k),L("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},S),L("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},S),L("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},S),L("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},S),this._offset=r.pointGeometry.convert(o&&o.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",E=>{E.preventDefault()}),this._element.addEventListener("mousedown",E=>{E.preventDefault()});const y=this._element.classList;for(const E in Uu)y.remove(`mapboxgl-marker-anchor-${E}`);y.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(o){return o===this._map||(this.remove(),this._map=o,o.getCanvasContainer().appendChild(this._element),o.on("move",this._updateMoving),o.on("moveend",this._update),o.on("remove",this._clearFadeTimer),o._addMarker(this),this.setDraggable(this._draggable),this._update(),o.on("click",this._onMapClick)),this}remove(){const o=this._map;return o&&(o.off("click",this._onMapClick),o.off("move",this._updateMoving),o.off("moveend",this._update),o.off("mousedown",this._addDragHandler),o.off("touchstart",this._addDragHandler),o.off("mouseup",this._onUp),o.off("touchend",this._onUp),o.off("mousemove",this._onMove),o.off("touchmove",this._onMove),o.off("remove",this._clearFadeTimer),o._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(o){return this._lngLat=r.LngLat.convert(o),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(o){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),o){if(!("offset"in o.options)){const E=Math.sqrt(Math.pow(13.5,2)/2);o.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[E,-1*(24.6+E)],"bottom-right":[-E,-1*(24.6+E)],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=o,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(o){const d=o.code,y=o.charCode||o.keyCode;d!=="Space"&&d!=="Enter"&&y!==32&&y!==13||this.togglePopup()}_onMapClick(o){const d=o.originalEvent.target,y=this._element;this._popup&&(d===y||y.contains(d))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const o=this._popup;return o?(o.isOpen()?(o.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(o.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_evaluateOpacity(){const o=this._map;if(!o)return;const d=this._pos;if(!d||d.x<0||d.x>o.transform.width||d.y<0||d.y>o.transform.height)return void this._clearFadeTimer();const y=o.unproject(d);let E=!1;if(o.transform._terrainEnabled()&&o.getTerrain()){const S=o.getFreeCameraOptions();if(S.position){const k=S.position.toLngLat();E=k.distanceTo(y)<.9*k.distanceTo(this._lngLat)}}const C=(1-o._queryFogOpacity(y))*(E?.2:1);this._element.style.opacity=`${C}`,this._popup&&this._popup._setOpacity(`${C}`),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const o=this._pos;if(!o)return;const d=this._offset.mult(this._scale),y=this._calculatePitch(),E=this._calculateRotation();this._element.style.transform=`
- translate(${o.x}px, ${o.y}px) ${Uu[this._anchor]}
- rotateX(${y}deg) rotateZ(${E}deg)
- translate(${d.x}px, ${d.y}px)
- `}_calculatePitch(){return this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?0:this._map&&this._pitchAlignment==="map"?this._map.getPitch():0}_calculateRotation(){return this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?this._rotation:this._map&&this._rotationAlignment==="map"?this._rotation-this._map.getBearing():0}_update(o){r.window.cancelAnimationFrame(this._updateFrameId);const d=this._map;d&&(d.transform.renderWorldCopies&&(this._lngLat=Nu(this._lngLat,this._pos,d.transform)),this._pos=d.project(this._lngLat),o===!0?this._updateFrameId=r.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),d._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),!d.getTerrain()&&!d.getFog()||this._fadeTimer||(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(o){return this._offset=r.pointGeometry.convert(o),this._update(),this}_onMove(o){const d=this._map;if(d){if(!this._isDragging){const y=this._clickTolerance||d._clickTolerance;this._isDragging=o.point.dist(this._pointerdownPos)>=y}this._isDragging&&(this._pos=o.point.sub(this._positionDelta),this._lngLat=d.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new r.Event("dragstart"))),this.fire(new r.Event("drag")))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const o=this._map;o&&(o.off("mousemove",this._onMove),o.off("touchmove",this._onMove)),this._state==="active"&&this.fire(new r.Event("dragend")),this._state="inactive"}_addDragHandler(o){const d=this._map;d&&this._element.contains(o.originalEvent.target)&&(o.preventDefault(),this._positionDelta=o.point.sub(this._pos),this._pointerdownPos=o.point,this._state="pending",d.on("mousemove",this._onMove),d.on("touchmove",this._onMove),d.once("mouseup",this._onUp),d.once("touchend",this._onUp))}setDraggable(o){this._draggable=!!o;const d=this._map;return d&&(o?(d.on("mousedown",this._addDragHandler),d.on("touchstart",this._addDragHandler)):(d.off("mousedown",this._addDragHandler),d.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(o){return this._rotation=o||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(o){return this._rotationAlignment=o||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(o){return this._pitchAlignment=o&&o!=="auto"?o:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}class sv{constructor(o){this.jumpTo(o)}getValue(o){if(o<=this._startTime)return this._start;if(o>=this._endTime)return this._end;const d=r.easeCubicInOut((o-this._startTime)/(this._endTime-this._startTime));return this._start*(1-d)+this._end*d}isEasing(o){return o>=this._startTime&&o<=this._endTime}jumpTo(o){this._startTime=-1/0,this._endTime=-1/0,this._start=o,this._end=o}easeTo(o,d,y){this._start=this.getValue(d),this._end=o,this._startTime=d,this._endTime=d+y}}const lv={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},sp={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0};function Wl(m){m.parentNode&&m.parentNode.removeChild(m)}const lp={showCompass:!0,showZoom:!0,visualizePitch:!1};class cp{constructor(o,d,y=!1){this._clickTolerance=10,this.element=d,this.mouseRotate=new Ls({clickTolerance:o.dragRotate._mouseRotate._clickTolerance}),this.map=o,y&&(this.mousePitch=new ep({clickTolerance:o.dragRotate._mousePitch._clickTolerance})),r.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),d.addEventListener("mousedown",this.mousedown),d.addEventListener("touchstart",this.touchstart,{passive:!1}),d.addEventListener("touchmove",this.touchmove),d.addEventListener("touchend",this.touchend),d.addEventListener("touchcancel",this.reset)}down(o,d){this.mouseRotate.mousedown(o,d),this.mousePitch&&this.mousePitch.mousedown(o,d),V()}move(o,d){const y=this.map,E=this.mouseRotate.mousemoveWindow(o,d),C=E&&E.bearingDelta;if(C&&y.setBearing(y.getBearing()+C),this.mousePitch){const S=this.mousePitch.mousemoveWindow(o,d),k=S&&S.pitchDelta;k&&y.setPitch(y.getPitch()+k)}}off(){const o=this.element;o.removeEventListener("mousedown",this.mousedown),o.removeEventListener("touchstart",this.touchstart,{passive:!1}),o.removeEventListener("touchmove",this.touchmove),o.removeEventListener("touchend",this.touchend),o.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){j(),r.window.removeEventListener("mousemove",this.mousemove),r.window.removeEventListener("mouseup",this.mouseup)}mousedown(o){this.down(r.extend({},o,{ctrlKey:!0,preventDefault:()=>o.preventDefault()}),H(this.element,o)),r.window.addEventListener("mousemove",this.mousemove),r.window.addEventListener("mouseup",this.mouseup)}mousemove(o){this.move(o,H(this.element,o))}mouseup(o){this.mouseRotate.mouseupWindow(o),this.mousePitch&&this.mousePitch.mouseupWindow(o),this.offTemp()}touchstart(o){o.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=Q(this.element,o.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>o.preventDefault()},this._startPos))}touchmove(o){o.targetTouches.length!==1?this.reset():(this._lastPos=Q(this.element,o.targetTouches)[0],this.move({preventDefault:()=>o.preventDefault()},this._lastPos))}touchend(o){o.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}const _r={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1};let Rr,jl=0,ja=!1;const up={maxWidth:100,unit:"metric"};function Gu(m,o,d){const y=d&&d.maxWidth||100,E=m._containerHeight/2,C=m._containerWidth/2-y/2,S=m.unproject([C,E]),k=m.unproject([C+y,E]),O=S.distanceTo(k);if(d&&d.unit==="imperial"){const U=3.2808*O;U>5280?Rs(o,y,U/5280,m._getUIString("ScaleControl.Miles"),m):Rs(o,y,U,m._getUIString("ScaleControl.Feet"),m)}else d&&d.unit==="nautical"?Rs(o,y,O/1852,m._getUIString("ScaleControl.NauticalMiles"),m):O>=1e3?Rs(o,y,O/1e3,m._getUIString("ScaleControl.Kilometers"),m):Rs(o,y,O,m._getUIString("ScaleControl.Meters"),m)}function Rs(m,o,d,y,E){const C=function(k){const O=Math.pow(10,`${Math.floor(k)}`.length-1);let U=k/O;return U=U>=10?10:U>=5?5:U>=3?3:U>=2?2:U>=1?1:function(G){const Z=Math.pow(10,Math.ceil(-Math.log(G)/Math.LN10));return Math.round(G*Z)/Z}(U),O*U}(d),S=C/d;E._requestDomTask(()=>{m.style.width=o*S+"px",m.innerHTML=`${C} ${y}`})}const qr={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},ci=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Hl(m=new r.pointGeometry(0,0),o="bottom"){if(typeof m=="number"){const d=Math.round(Math.sqrt(.5*Math.pow(m,2)));switch(o){case"top":return new r.pointGeometry(0,m);case"top-left":return new r.pointGeometry(d,d);case"top-right":return new r.pointGeometry(-d,d);case"bottom":return new r.pointGeometry(0,-m);case"bottom-left":return new r.pointGeometry(d,-d);case"bottom-right":return new r.pointGeometry(-d,-d);case"left":return new r.pointGeometry(m,0);case"right":return new r.pointGeometry(-m,0)}return new r.pointGeometry(0,0)}return m instanceof r.pointGeometry||Array.isArray(m)?r.pointGeometry.convert(m):r.pointGeometry.convert(m[o]||[0,0])}const ks={version:r.version,supported:v,setRTLTextPlugin:r.setRTLTextPlugin,getRTLTextPluginStatus:r.getRTLTextPluginStatus,Map:class extends ap{constructor(m){if((m=r.extend({},sp,m)).minZoom!=null&&m.maxZoom!=null&&m.minZoom>m.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(m.minPitch!=null&&m.maxPitch!=null&&m.minPitch>m.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(m.minPitch!=null&&m.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(m.maxPitch!=null&&m.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(m.antialias&&r.isSafariWithAntialiasingBug(r.window)&&(m.antialias=!1,r.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Iu(m.minZoom,m.maxZoom,m.minPitch,m.maxPitch,m.renderWorldCopies),m),this._interactive=m.interactive,this._minTileCacheSize=m.minTileCacheSize,this._maxTileCacheSize=m.maxTileCacheSize,this._failIfMajorPerformanceCaveat=m.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=m.preserveDrawingBuffer,this._antialias=m.antialias,this._trackResize=m.trackResize,this._bearingSnap=m.bearingSnap,this._refreshExpiredTiles=m.refreshExpiredTiles,this._fadeDuration=m.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=m.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=m.collectResourceTiming,this._optimizeForTerrain=m.optimizeForTerrain,this._renderTaskQueue=new wg,this._domRenderTaskQueue=new wg,this._controls=[],this._markers=[],this._mapId=r.uniqueId(),this._locale=r.extend({},lv,m.locale),this._clickTolerance=m.clickTolerance,this._cooperativeGestures=m.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new sv(0),this._explicitProjection=null,this._requestManager=new r.RequestManager(m.transformRequest,m.accessToken,m.testMode),this._silenceAuthErrors=!!m.testMode,typeof m.container=="string"){if(this._container=r.window.document.getElementById(m.container),!this._container)throw new Error(`Container '${m.container}' not found.`)}else{if(!(m.container instanceof r.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=m.container}if(this._container.childNodes.length>0&&r.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),m.maxBounds&&this.setMaxBounds(m.maxBounds),r.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)throw new Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),r.window!==void 0&&(r.window.addEventListener("online",this._onWindowOnline,!1),r.window.addEventListener("resize",this._onWindowResize,!1),r.window.addEventListener("orientationchange",this._onWindowResize,!1),r.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new xg(this,m),this._localFontFamily=m.localFontFamily,this._localIdeographFontFamily=m.localIdeographFontFamily,m.style&&this.setStyle(m.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),m.projection&&this.setProjection(m.projection),this._hash=m.hash&&new eg(typeof m.hash=="string"&&m.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:m.center,zoom:m.zoom,bearing:m.bearing,pitch:m.pitch}),m.bounds&&(this.resize(),this.fitBounds(m.bounds,r.extend({},m.fitBoundsOptions,{duration:0})))),this.resize(),m.attributionControl&&this.addControl(new Ou({customAttribution:m.customAttribution})),this._logoControl=new bg,this.addControl(this._logoControl,m.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",o=>{this._update(o.dataType==="style"),this.fire(new r.Event(`${o.dataType}data`,o))}),this.on("dataloading",o=>{this.fire(new r.Event(`${o.dataType}dataloading`,o))})}_getMapId(){return this._mapId}addControl(m,o){if(o===void 0&&(o=m.getDefaultPosition?m.getDefaultPosition():"top-right"),!m||!m.onAdd)return this.fire(new r.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const d=m.onAdd(this);this._controls.push(m);const y=this._controlPositions[o];return o.indexOf("bottom")!==-1?y.insertBefore(d,y.firstChild):y.appendChild(d),this}removeControl(m){if(!m||!m.onRemove)return this.fire(new r.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const o=this._controls.indexOf(m);return o>-1&&this._controls.splice(o,1),m.onRemove(this),this}hasControl(m){return this._controls.indexOf(m)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(m){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const o=!this._moving;return o&&this.fire(new r.Event("movestart",m)).fire(new r.Event("move",m)),this.fire(new r.Event("resize",m)),o&&this.fire(new r.Event("moveend",m)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(m){return this.transform.setMaxBounds(r.LngLatBounds.convert(m)),this._update()}setMinZoom(m){if((m=m==null?-2:m)>=-2&&m<=this.transform.maxZoom)return this.transform.minZoom=m,this._update(),this.getZoom()<m?this.setZoom(m):this.fire(new r.Event("zoomstart")).fire(new r.Event("zoom")).fire(new r.Event("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(m){if((m=m==null?22:m)>=this.transform.minZoom)return this.transform.maxZoom=m,this._update(),this.getZoom()>m?this.setZoom(m):this.fire(new r.Event("zoomstart")).fire(new r.Event("zoom")).fire(new r.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(m){if((m=m==null?0:m)<0)throw new Error("minPitch must be greater than or equal to 0");if(m>=0&&m<=this.transform.maxPitch)return this.transform.minPitch=m,this._update(),this.getPitch()<m?this.setPitch(m):this.fire(new r.Event("pitchstart")).fire(new r.Event("pitch")).fire(new r.Event("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(m){if((m=m==null?85:m)>85)throw new Error("maxPitch must be less than or equal to 85");if(m>=this.transform.minPitch)return this.transform.maxPitch=m,this._update(),this.getPitch()>m?this.setPitch(m):this.fire(new r.Event("pitchstart")).fire(new r.Event("pitch")).fire(new r.Event("pitchend")),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(m){return this.transform.renderWorldCopies=m,this._update()}getProjection(){return this._explicitProjection?this._explicitProjection:this.style&&this.style.stylesheet&&this.style.stylesheet.projection?this.style.stylesheet.projection:{name:"mercator",center:[0,0]}}setProjection(m){return this._lazyInitEmptyStyle(),m?typeof m=="string"&&(m={name:m}):m=null,this._updateProjection(m)}_updateProjection(m){m===null&&(this._explicitProjection=null);const o=m||this.getProjection(),d=this.transform.setProjection(o);if(m&&(this._explicitProjection=this.transform.getProjection()),d){this.painter.clearBackgroundTiles();for(const y in this.style._sourceCaches)this.style._sourceCaches[y].clearTiles();this.style.applyProjectionUpdate(),this._update(!0)}return this}project(m){return this.transform.locationPoint3D(r.LngLat.convert(m))}unproject(m){return this.transform.pointLocation3D(r.pointGeometry.convert(m))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_createDelegatedListener(m,o,d){if(m==="mouseenter"||m==="mouseover"){let y=!1;const E=S=>{const k=o.filter(U=>this.getLayer(U)),O=k.length?this.queryRenderedFeatures(S.point,{layers:k}):[];O.length?y||(y=!0,d.call(this,new Ir(m,this,S.originalEvent,{features:O}))):y=!1},C=()=>{y=!1};return{layers:new Set(o),listener:d,delegates:{mousemove:E,mouseout:C}}}if(m==="mouseleave"||m==="mouseout"){let y=!1;const E=S=>{const k=o.filter(O=>this.getLayer(O));(k.length?this.queryRenderedFeatures(S.point,{layers:k}):[]).length?y=!0:y&&(y=!1,d.call(this,new Ir(m,this,S.originalEvent)))},C=S=>{y&&(y=!1,d.call(this,new Ir(m,this,S.originalEvent)))};return{layers:new Set(o),listener:d,delegates:{mousemove:E,mouseout:C}}}{const y=E=>{const C=o.filter(k=>this.getLayer(k)),S=C.length?this.queryRenderedFeatures(E.point,{layers:C}):[];S.length&&(E.features=S,d.call(this,E),delete E.features)};return{layers:new Set(o),listener:d,delegates:{[m]:y}}}}on(m,o,d){if(d===void 0)return super.on(m,o);Array.isArray(o)||(o=[o]);const y=this._createDelegatedListener(m,o,d);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[m]=this._delegatedListeners[m]||[],this._delegatedListeners[m].push(y);for(const E in y.delegates)this.on(E,y.delegates[E]);return this}once(m,o,d){if(d===void 0)return super.once(m,o);Array.isArray(o)||(o=[o]);const y=this._createDelegatedListener(m,o,d);for(const E in y.delegates)this.once(E,y.delegates[E]);return this}off(m,o,d){if(d===void 0)return super.off(m,o);o=new Set(Array.isArray(o)?o:[o]);const y=(C,S)=>{if(C.size!==S.size)return!1;for(const k of C)if(!S.has(k))return!1;return!0},E=this._delegatedListeners?this._delegatedListeners[m]:void 0;return E&&(C=>{for(let S=0;S<C.length;S++){const k=C[S];if(k.listener===d&&y(k.layers,o)){for(const O in k.delegates)this.off(O,k.delegates[O]);return C.splice(S,1),this}}})(E),this}queryRenderedFeatures(m,o){return this.style?(o!==void 0||m===void 0||m instanceof r.pointGeometry||Array.isArray(m)||(o=m,m=void 0),this.style.queryRenderedFeatures(m=m||[[0,0],[this.transform.width,this.transform.height]],o=o||{},this.transform)):[]}querySourceFeatures(m,o){return this.style.querySourceFeatures(m,o)}queryTerrainElevation(m,o){const d=this.transform.elevation;return d?(o=r.extend({},{exaggerated:!0},o),d.getAtPoint(r.MercatorCoordinate.fromLngLat(m),null,o.exaggerated)):null}setStyle(m,o){return(o=r.extend({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},o)).diff!==!1&&o.localIdeographFontFamily===this._localIdeographFontFamily&&o.localFontFamily===this._localFontFamily&&this.style&&m?(this._diffStyle(m,o),this):(this._localIdeographFontFamily=o.localIdeographFontFamily,this._localFontFamily=o.localFontFamily,this._updateStyle(m,o))}_getUIString(m){const o=this._locale[m];if(o==null)throw new Error(`Missing UI string '${m}'`);return o}_updateStyle(m,o){return this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),m&&(this.style=new yr(this,o||{}),this.style.setEventedParent(this,{style:this.style}),typeof m=="string"?this.style.loadURL(m):this.style.loadJSON(m)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new yr(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(m,o){if(typeof m=="string"){const d=this._requestManager.normalizeStyleURL(m),y=this._requestManager.transformRequest(d,r.ResourceType.Style);r.getJSON(y,(E,C)=>{E?this.fire(new r.ErrorEvent(E)):C&&this._updateDiff(C,o)})}else typeof m=="object"&&this._updateDiff(m,o)}_updateDiff(m,o){try{this.style.setState(m)&&this._update(!0)}catch(d){r.warnOnce(`Unable to perform style diff: ${d.message||d.error||d}. Rebuilding the style from scratch.`),this._updateStyle(m,o)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(r.warnOnce("There is no style added to the map."),!1)}addSource(m,o){return this._lazyInitEmptyStyle(),this.style.addSource(m,o),this._update(!0)}isSourceLoaded(m){return!!this.style&&this.style._isSourceCacheLoaded(m)}areTilesLoaded(){const m=this.style&&this.style._sourceCaches;for(const o in m){const d=m[o]._tiles;for(const y in d){const E=d[y];if(E.state!=="loaded"&&E.state!=="errored")return!1}}return!0}addSourceType(m,o,d){this._lazyInitEmptyStyle(),this.style.addSourceType(m,o,d)}removeSource(m){return this.style.removeSource(m),this._updateTerrain(),this._update(!0)}getSource(m){return this.style.getSource(m)}addImage(m,o,{pixelRatio:d=1,sdf:y=!1,stretchX:E,stretchY:C,content:S}={}){if(this._lazyInitEmptyStyle(),o instanceof r.window.HTMLImageElement||r.window.ImageBitmap&&o instanceof r.window.ImageBitmap){const{width:k,height:O,data:U}=r.exported.getImageData(o);this.style.addImage(m,{data:new r.RGBAImage({width:k,height:O},U),pixelRatio:d,stretchX:E,stretchY:C,content:S,sdf:y,version:0})}else if(o.width===void 0||o.height===void 0)this.fire(new r.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:k,height:O}=o,U=o;this.style.addImage(m,{data:new r.RGBAImage({width:k,height:O},new Uint8Array(U.data)),pixelRatio:d,stretchX:E,stretchY:C,content:S,sdf:y,version:0,userImage:U}),U.onAdd&&U.onAdd(this,m)}}updateImage(m,o){const d=this.style.getImage(m);if(!d)return void this.fire(new r.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const y=o instanceof r.window.HTMLImageElement||r.window.ImageBitmap&&o instanceof r.window.ImageBitmap?r.exported.getImageData(o):o,{width:E,height:C}=y;E!==void 0&&C!==void 0?E===d.data.width&&C===d.data.height?(d.data.replace(y.data,!(o instanceof r.window.HTMLImageElement||r.window.ImageBitmap&&o instanceof r.window.ImageBitmap)),this.style.updateImage(m,d)):this.fire(new r.ErrorEvent(new Error("The width and height of the updated image must be that same as the previous version of the image"))):this.fire(new r.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")))}hasImage(m){return m?!!this.style.getImage(m):(this.fire(new r.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(m){this.style.removeImage(m)}loadImage(m,o){r.getImage(this._requestManager.transformRequest(m,r.ResourceType.Image),(d,y)=>{o(d,y instanceof r.window.HTMLImageElement?r.exported.getImageData(y):y)})}listImages(){return this.style.listImages()}addLayer(m,o){return this._lazyInitEmptyStyle(),this.style.addLayer(m,o),this._update(!0)}moveLayer(m,o){return this.style.moveLayer(m,o),this._update(!0)}removeLayer(m){return this.style.removeLayer(m),this._update(!0)}getLayer(m){return this.style.getLayer(m)}setLayerZoomRange(m,o,d){return this.style.setLayerZoomRange(m,o,d),this._update(!0)}setFilter(m,o,d={}){return this.style.setFilter(m,o,d),this._update(!0)}getFilter(m){return this.style.getFilter(m)}setPaintProperty(m,o,d,y={}){return this.style.setPaintProperty(m,o,d,y),this._update(!0)}getPaintProperty(m,o){return this.style.getPaintProperty(m,o)}setLayoutProperty(m,o,d,y={}){return this.style.setLayoutProperty(m,o,d,y),this._update(!0)}getLayoutProperty(m,o){return this.style.getLayoutProperty(m,o)}setLight(m,o={}){return this._lazyInitEmptyStyle(),this.style.setLight(m,o),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(m){return this._lazyInitEmptyStyle(),!m&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(m),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(m){return this._lazyInitEmptyStyle(),this.style.setFog(m),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(m){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(r.LngLat.convert(m),this.transform):0}setFeatureState(m,o){return this.style.setFeatureState(m,o),this._update()}removeFeatureState(m,o){return this.style.removeFeatureState(m,o),this._update()}getFeatureState(m){return this.style.getFeatureState(m)}_updateContainerDimensions(){if(!this._container)return;const m=this._container.getBoundingClientRect().width||400,o=this._container.getBoundingClientRect().height||300;let d,y,E,C=this._container;for(;C&&(!y||!E);){const S=r.window.getComputedStyle(C).transform;S&&S!=="none"&&(d=S.match(/matrix.*\((.+)\)/)[1].split(", "),d[0]&&d[0]!=="0"&&d[0]!=="1"&&(y=d[0]),d[3]&&d[3]!=="0"&&d[3]!=="1"&&(E=d[3])),C=C.parentElement}this._containerWidth=y?Math.abs(m/y):m,this._containerHeight=E?Math.abs(o/E):o}_detectMissingCSS(){r.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&r.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const m=this._container;m.classList.add("mapboxgl-map"),(this._missingCSSCanary=A("div","mapboxgl-canary",m)).style.visibility="hidden",this._detectMissingCSS();const o=this._canvasContainer=A("div","mapboxgl-canvas-container",m);this._interactive&&o.classList.add("mapboxgl-interactive"),this._canvas=A("canvas","mapboxgl-canvas",o),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const d=this._controlContainer=A("div","mapboxgl-control-container",m),y=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(E=>{y[E]=A("div",`mapboxgl-ctrl-${E}`,d)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(m,o){const d=r.exported.devicePixelRatio||1;this._canvas.width=d*Math.ceil(m),this._canvas.height=d*Math.ceil(o),this._canvas.style.width=`${m}px`,this._canvas.style.height=`${o}px`}_addMarker(m){this._markers.push(m)}_removeMarker(m){const o=this._markers.indexOf(m);o!==-1&&this._markers.splice(o,1)}_setupPainter(){const m=r.extend({},v.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),o=this._canvas.getContext("webgl",m)||this._canvas.getContext("experimental-webgl",m);o?(r.storeAuthState(o,!0),this.painter=new Jm(o,this.transform),this.on("data",d=>{d.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),r.exported$1.testSupport(o)):this.fire(new r.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(m){m.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new r.Event("webglcontextlost",{originalEvent:m}))}_contextRestored(m){this._setupPainter(),this.resize(),this._update(),this.fire(new r.Event("webglcontextrestored",{originalEvent:m}))}_onMapScroll(m){if(m.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(m){return this.style?(this._styleDirty=this._styleDirty||m,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(m){return this._update(),this._renderTaskQueue.add(m)}_cancelRenderFrame(m){this._renderTaskQueue.remove(m)}_requestDomTask(m){!this.loaded()||this.loaded()&&!this.isMoving()?m():this._domRenderTaskQueue.add(m)}_render(m){let o;const d=this.painter.context.extTimerQuery,y=r.exported.now();if(this.listens("gpu-timing-frame")&&(o=d.createQueryEXT(),d.beginQueryEXT(d.TIME_ELAPSED_EXT,o)),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(m),this._domRenderTaskQueue.run(m),this._removed)return;let E=!1;const C=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const O=this.transform.zoom,U=this.transform.pitch,G=r.exported.now();this.style.zoomHistory.update(O,G);const Z=new r.EvaluationParameters(O,{now:G,fadeDuration:C,pitch:U,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),se=Z.crossFadingFactor();se===1&&se===this._crossFadingFactor||(E=!0,this._crossFadingFactor=se),this.style.update(Z)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let S=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),S=this._updateAverageElevation(y),this.style._updateSources(this.transform),this._forceMarkerUpdate()):S=this._updateAverageElevation(y),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,C,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:C,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),speedIndexTiming:this.speedIndexTiming}),this.fire(new r.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new r.Event("load"))),this.style&&(this.style.hasTransitions()||E)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const O=r.exported.now()-y;d.endQueryEXT(d.TIME_ELAPSED_EXT,o),setTimeout(()=>{const U=d.getQueryObjectEXT(o,d.QUERY_RESULT_EXT)/1e6;d.deleteQueryEXT(o),this.fire(new r.Event("gpu-timing-frame",{cpuTime:O,gpuTime:U}))},50)}if(this.listens("gpu-timing-layer")){const O=this.painter.collectGpuTimers();setTimeout(()=>{const U=this.painter.queryGpuTimers(O);this.fire(new r.Event("gpu-timing-layer",{layerTimes:U}))},50)}const k=this._sourcesDirty||this._styleDirty||this._placementDirty||S;if(k||this._repaint)this.triggerRepaint();else{const O=!this.isMoving()&&this.loaded();if(O&&(S=this._updateAverageElevation(y,!0)),S)this.triggerRepaint();else if(this._triggerFrame(!1),O&&(this.fire(new r.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const U=this._calculateSpeedIndex();this.fire(new r.Event("speedindexcompleted",{speedIndex:U})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||k||(this._fullyLoaded=!0,this._authenticate())}_forceMarkerUpdate(){for(const m of this._markers)m._update()}_updateAverageElevation(m,o=!1){const d=y=>(this.transform.averageElevation=y,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&d(0);if((o||m-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(m)){const y=this.transform.averageElevation;let E=this.transform.sampleAverageElevation(),C=!1;this.transform.elevation&&(C=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(E)?E=0:this._averageElevationLastSampledAt=m;const S=Math.abs(y-E);if(S>1){if(this._isInitialLoad||C)return this._averageElevation.jumpTo(E),d(E);this._averageElevation.easeTo(E,m,300)}else if(S>1e-4)return this._averageElevation.jumpTo(E),d(E)}return!!this._averageElevation.isEasing(m)&&d(this._averageElevation.getValue(m))}_authenticate(){r.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,m=>{if(m&&(m.message===r.AUTH_ERR_MSG||m.status===401)){const o=this.painter.context.gl;r.storeAuthState(o,!1),this._logoControl instanceof bg&&this._logoControl._updateLogo(),o&&o.clear(o.DEPTH_BUFFER_BIT|o.COLOR_BUFFER_BIT|o.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new r.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),r.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const m=this.painter.canvasCopy(),o=this.painter.getCanvasCopiesAndTimestamps();o.timeStamps.push(performance.now());const d=this.painter.context.gl,y=d.createFramebuffer();function E(C){d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,C,0);const S=new Uint8Array(d.drawingBufferWidth*d.drawingBufferHeight*4);return d.readPixels(0,0,d.drawingBufferWidth,d.drawingBufferHeight,d.RGBA,d.UNSIGNED_BYTE,S),S}return d.bindFramebuffer(d.FRAMEBUFFER,y),this._canvasPixelComparison(E(m),o.canvasCopies.map(E),o.timeStamps)}_canvasPixelComparison(m,o,d){let y=d[1]-d[0];const E=m.length/4;for(let C=0;C<o.length;C++){const S=o[C];let k=0;for(let O=0;O<S.length;O+=4)S[O]===m[O]&&S[O+1]===m[O+1]&&S[O+2]===m[O+2]&&S[O+3]===m[O+3]&&(k+=1);y+=(d[C+2]-d[C+1])*(1-k/E)}return y}remove(){this._hash&&this._hash.remove();for(const o of this._controls)o.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),r.window!==void 0&&(r.window.removeEventListener("resize",this._onWindowResize,!1),r.window.removeEventListener("orientationchange",this._onWindowResize,!1),r.window.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),r.window.removeEventListener("online",this._onWindowOnline,!1));const m=this.painter.context.gl.getExtension("WEBGL_lose_context");m&&m.loseContext(),Wl(this._canvasContainer),Wl(this._controlContainer),Wl(this._missingCSSCanary),this._container.classList.remove("mapboxgl-map"),r.removeAuthState(this.painter.context.gl),this._removed=!0,this.fire(new r.Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(m){this._renderNextFrame=this._renderNextFrame||m,this.style&&!this._frame&&(this._frame=r.exported.frame(o=>{const d=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,d&&this._render(o)}))}_preloadTiles(m){const o=this.style?Object.values(this.style._sourceCaches):[];return r.asyncAll(o,(d,y)=>d._preloadTiles(m,y),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(m){this._trackResize&&this.resize({originalEvent:m})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(m){this._showTileBoundaries!==m&&(this._showTileBoundaries=m,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(m){this._showTerrainWireframe!==m&&(this._showTerrainWireframe=m,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(m){this._speedIndexTiming!==m&&(this._speedIndexTiming=m,this._update())}get showPadding(){return!!this._showPadding}set showPadding(m){this._showPadding!==m&&(this._showPadding=m,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(m){this._showCollisionBoxes!==m&&(this._showCollisionBoxes=m,m?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(m){this._showOverdrawInspector!==m&&(this._showOverdrawInspector=m,this._update())}get repaint(){return!!this._repaint}set repaint(m){this._repaint!==m&&(this._repaint=m,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(m){this._vertices=m,this._update()}_setCacheLimits(m,o){r.setCacheLimits(m,o)}get version(){return r.version}},NavigationControl:class{constructor(m){this.options=r.extend({},lp,m),this._container=A("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",o=>o.preventDefault()),this.options.showZoom&&(r.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",o=>{this._map&&this._map.zoomIn({},{originalEvent:o})}),A("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",o=>{this._map&&this._map.zoomOut({},{originalEvent:o})}),A("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(r.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",o=>{const d=this._map;d&&(this.options.visualizePitch?d.resetNorthPitch({},{originalEvent:o}):d.resetNorth({},{originalEvent:o}))}),this._compassIcon=A("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const m=this._map;if(!m)return;const o=m.getZoom(),d=o===m.getMaxZoom(),y=o===m.getMinZoom();this._zoomInButton.disabled=d,this._zoomOutButton.disabled=y,this._zoomInButton.setAttribute("aria-disabled",d.toString()),this._zoomOutButton.setAttribute("aria-disabled",y.toString())}_rotateCompassArrow(){const m=this._map;if(!m)return;const o=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(m.transform.pitch*(Math.PI/180)),.5)}) rotateX(${m.transform.pitch}deg) rotateZ(${m.transform.angle*(180/Math.PI)}deg)`:`rotate(${m.transform.angle*(180/Math.PI)}deg)`;m._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=o)})}onAdd(m){return this._map=m,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),m.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&m.on("pitch",this._rotateCompassArrow),m.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new cp(m,this._compass,this.options.visualizePitch)),this._container}onRemove(){const m=this._map;m&&(this._container.remove(),this.options.showZoom&&m.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&m.off("pitch",this._rotateCompassArrow),m.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(m,o){const d=A("button",m,this._container);return d.type="button",d.addEventListener("click",o),d}_setButtonTitle(m,o){if(!this._map)return;const d=this._map._getUIString(`NavigationControl.${o}`);m.setAttribute("aria-label",d),m.firstElementChild&&m.firstElementChild.setAttribute("title",d)}},GeolocateControl:class extends r.Evented{constructor(m){super(),this.options=r.extend({},_r,m),r.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Qd(this._updateMarkerRotation,20)}onAdd(m){var o;return this._map=m,this._container=A("div","mapboxgl-ctrl mapboxgl-ctrl-group"),o=this._setupUI,Rr!==void 0?o(Rr):r.window.navigator.permissions!==void 0?r.window.navigator.permissions.query({name:"geolocation"}).then(d=>{Rr=d.state!=="denied",o(Rr)}):(Rr=!!r.window.navigator.geolocation,o(Rr)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(r.window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,jl=0,ja=!1}_isOutOfMapMaxBounds(m){const o=this._map.getMaxBounds(),d=m.coords;return!!o&&(d.longitude<o.getWest()||d.longitude>o.getEast()||d.latitude<o.getSouth()||d.latitude>o.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(m){if(this._map){if(this._isOutOfMapMaxBounds(m))return this._setErrorState(),this.fire(new r.Event("outofmaxbounds",m)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=m,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(m),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(m),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new r.Event("geolocate",m)),this._finish()}}_updateCamera(m){const o=new r.LngLat(m.coords.longitude,m.coords.latitude),d=m.coords.accuracy,y=this._map.getBearing(),E=r.extend({bearing:y},this.options.fitBoundsOptions);this._map.fitBounds(o.toBounds(d),E,{geolocateSource:!0})}_updateMarker(m){if(m){const o=new r.LngLat(m.coords.longitude,m.coords.latitude);this._accuracyCircleMarker.setLngLat(o).addTo(this._map),this._userLocationDotMarker.setLngLat(o).addTo(this._map),this._accuracy=m.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const m=this._map._containerHeight/2,o=this._map.unproject([0,m]),d=this._map.unproject([100,m]),y=o.distanceTo(d)/100,E=Math.ceil(2*this._accuracy/y);this._circleElement.style.width=`${E}px`,this._circleElement.style.height=`${E}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(m){if(this._map){if(this.options.trackUserLocation)if(m.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const o=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",o),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",o),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(m.code===3&&ja)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new r.Event("error",m)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(m){if(this._container.addEventListener("contextmenu",o=>o.preventDefault()),this._geolocateButton=A("button","mapboxgl-ctrl-geolocate",this._container),A("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",m===!1){r.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const o=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",o),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",o)}else{const o=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",o),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",o)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=A("div","mapboxgl-user-location"),this._dotElement.appendChild(A("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(A("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Vu({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=A("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Vu({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",o=>{o.geolocateSource||this._watchState!=="ACTIVE_LOCK"||o.originalEvent&&o.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new r.Event("trackuserlocationend")))})}_onDeviceOrientation(m){this._userLocationDotMarker&&(m.webkitCompassHeading?this._heading=m.webkitCompassHeading:m.absolute===!0&&(this._heading=-1*m.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return r.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new r.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":jl--,ja=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new r.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new r.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let m;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),jl++,jl>1?(m={maximumAge:6e5,timeout:0},ja=!0):(m=this.options.positionOptions,ja=!1),this._geolocationWatchID=r.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,m),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else r.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const m=()=>{r.window.addEventListener("ondeviceorientationabsolute"in r.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};r.window.DeviceMotionEvent!==void 0&&typeof r.window.DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(o=>{o==="granted"&&m()}).catch(console.error):m()}_clearWatch(){r.window.navigator.geolocation.clearWatch(this._geolocationWatchID),r.window.removeEventListener("deviceorientation",this._onDeviceOrientation),r.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Ou,ScaleControl:class{constructor(m){this.options=r.extend({},up,m),r.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){Gu(this._map,this._container,this.options)}onAdd(m){return this._map=m,this._container=A("div","mapboxgl-ctrl mapboxgl-ctrl-scale",m.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}setUnit(m){this.options.unit=m,Gu(this._map,this._container,this.options)}},FullscreenControl:class{constructor(m){this._fullscreen=!1,m&&m.container&&(m.container instanceof r.window.HTMLElement?this._container=m.container:r.warnOnce("Full screen control 'container' must be a DOM element.")),r.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in r.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in r.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(m){return this._map=m,this._container||(this._container=this._map.getContainer()),this._controlContainer=A("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",r.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,r.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!r.window.document.fullscreenEnabled&&!r.window.document.webkitFullscreenEnabled)}_setupUI(){const m=this._fullscreenButton=A("button","mapboxgl-ctrl-fullscreen",this._controlContainer);A("span","mapboxgl-ctrl-icon",m).setAttribute("aria-hidden","true"),m.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),r.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const m=this._getTitle();this._fullscreenButton.setAttribute("aria-label",m),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",m)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(r.window.document.fullscreenElement||r.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?r.window.document.exitFullscreen?r.window.document.exitFullscreen():r.window.document.webkitCancelFullScreen&&r.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends r.Evented{constructor(m){super(),this.options=r.extend(Object.create(qr),m),r.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(m&&m.className?m.className.trim().split(/\s+/):[])}addTo(m){return this._map&&this.remove(),this._map=m,this.options.closeOnClick&&m.on("preclick",this._onClose),this.options.closeOnMove&&m.on("move",this._onClose),m.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(m.on("mousemove",this._onMouseEvent),m.on("mouseup",this._onMouseEvent),m._canvasContainer.classList.add("mapboxgl-track-pointer")):m.on("move",this._update),this.fire(new r.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const m=this._map;return m&&(m.off("move",this._update),m.off("move",this._onClose),m.off("preclick",this._onClose),m.off("click",this._onClose),m.off("remove",this.remove),m.off("mousemove",this._onMouseEvent),m.off("mouseup",this._onMouseEvent),m.off("drag",this._onMouseEvent),this._map=void 0),this.fire(new r.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(m){this._lngLat=r.LngLat.convert(m),this._pos=null,this._trackPointer=!1,this._update();const o=this._map;return o&&(o.on("move",this._update),o.off("mousemove",this._onMouseEvent),o._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const m=this._map;return m&&(m.off("move",this._update),m.on("mousemove",this._onMouseEvent),m.on("drag",this._onMouseEvent),m._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(m){return this.setDOMContent(r.window.document.createTextNode(m))}setHTML(m){const o=r.window.document.createDocumentFragment(),d=r.window.document.createElement("body");let y;for(d.innerHTML=m;y=d.firstChild,y;)o.appendChild(y);return this.setDOMContent(o)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(m){return this.options.maxWidth=m,this._update(),this}setDOMContent(m){let o=this._content;if(o)for(;o.hasChildNodes();)o.firstChild&&o.removeChild(o.firstChild);else o=this._content=A("div","mapboxgl-popup-content",this._container||void 0);if(o.appendChild(m),this.options.closeButton){const d=this._closeButton=A("button","mapboxgl-popup-close-button",o);d.type="button",d.setAttribute("aria-label","Close popup"),d.setAttribute("aria-hidden","true"),d.innerHTML="×",d.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(m){return this._classList.add(m),this._updateClassList(),this}removeClassName(m){return this._classList.delete(m),this._updateClassList(),this}setOffset(m){return this.options.offset=m,this._update(),this}toggleClassName(m){let o;return this._classList.delete(m)?o=!1:(this._classList.add(m),o=!0),this._updateClassList(),o}_onMouseEvent(m){this._update(m.point)}_getAnchor(m){if(this.options.anchor)return this.options.anchor;const o=this._map,d=this._container,y=this._pos;if(!o||!d||!y)return"bottom";const E=d.offsetWidth,C=d.offsetHeight,S=y.x<E/2,k=y.x>o.transform.width-E/2;if(y.y+m<C)return S?"top-left":k?"top-right":"top";if(y.y>o.transform.height-C){if(S)return"bottom-left";if(k)return"bottom-right"}return S?"left":k?"right":"bottom"}_updateClassList(){const m=this._container;if(!m)return;const o=[...this._classList];o.push("mapboxgl-popup"),this._anchor&&o.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&o.push("mapboxgl-popup-track-pointer"),m.className=o.join(" ")}_update(m){const o=this._map,d=this._content;if(!o||!this._lngLat&&!this._trackPointer||!d)return;let y=this._container;if(y||(y=this._container=A("div","mapboxgl-popup",o.getContainer()),this._tip=A("div","mapboxgl-popup-tip",y),y.appendChild(d)),this.options.maxWidth&&y.style.maxWidth!==this.options.maxWidth&&(y.style.maxWidth=this.options.maxWidth),o.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Nu(this._lngLat,this._pos,o.transform)),!this._trackPointer||m){const E=this._pos=this._trackPointer&&m?m:o.project(this._lngLat),C=Hl(this.options.offset),S=this._anchor=this._getAnchor(C.y),k=Hl(this.options.offset,S),O=E.add(k).round();o._requestDomTask(()=>{this._container&&S&&(this._container.style.transform=`${Uu[S]} translate(${O.x}px,${O.y}px)`)})}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const m=this._container.querySelector(ci);m&&m.focus()}_onClose(){this.remove()}_setOpacity(m){this._content&&(this._content.style.opacity=m),this._tip&&(this._tip.style.opacity=m)}},Marker:Vu,Style:yr,LngLat:r.LngLat,LngLatBounds:r.LngLatBounds,Point:r.pointGeometry,MercatorCoordinate:r.MercatorCoordinate,FreeCameraOptions:kl,Evented:r.Evented,config:r.config,prewarm:function(){Fe().acquire(_n)},clearPrewarmedResources:function(){const m=re;m&&(m.isPreloaded()&&m.numActive()===1?(m.release(_n),re=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return r.config.ACCESS_TOKEN},set accessToken(m){r.config.ACCESS_TOKEN=m},get baseApiUrl(){return r.config.API_URL},set baseApiUrl(m){r.config.API_URL=m},get workerCount(){return Y.workerCount},set workerCount(m){Y.workerCount=m},get maxParallelImageRequests(){return r.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(m){r.config.MAX_PARALLEL_IMAGE_REQUESTS=m},clearStorage(m){r.clearTileCache(m)},workerUrl:"",workerClass:null,setNow:r.exported.setNow,restoreNow:r.exported.restoreNow};return ks});var f=c;return f})})(lb);var LR=lb.exports;const IR=Z1(LR),su={tdtsl(){return{layers:[["tdtsl","TianDiTu.Normal.Map"],["tdtslzj","TianDiTu.Normal.Annotion"]],key:"fb258b4c0bbf60ff7a0205b519ad9a96"}},tdtyx(){return{layers:[["tdtyx","TianDiTu.Satellite.Map"],["tdtyxzj","TianDiTu.Satellite.Annotion"]],key:"fb258b4c0bbf60ff7a0205b519ad9a96"}},tdtdx(){return{layers:[["tdtdx","TianDiTu.Terrain.Map"],["tdtdxzj","TianDiTu.Terrain.Annotion"]],key:"fb258b4c0bbf60ff7a0205b519ad9a96"}},gdsl(){return{layers:[["gdsl","GaoDe.Normal.Map"]]}},gdslwzj(){return{layers:[["gdslwzj","GaoDe.Normal_NoTag.Map"]]}},gdyx(){return{layers:[["gdyx","GaoDe.Satellite.Map"],["gdyxzj","GaoDe.Satellite.Annotion"]]}},bdsl(){return{layers:[["bdsl","Baidu.Normal.Map"]]}},bdyx(){return{layers:[["bdyx","Baidu.Satellite.Map"],["bdyxzj","Baidu.Satellite.Annotion"]]}},osm(){return{layers:[["osm","OSM.Normal.Map"]]}},geoq(){return{layers:[["geoq","Geoq.Normal.Map"]]}},geoqPurplishBlue(){return{layers:[["geoqPurplishBlue","Geoq.Normal.PurplishBlue"]]}},geoqGray(){return{layers:[["geoqGray","Geoq.Normal.Gray"]]}},geoqWarm(){return{layers:[["geoqWarm","Geoq.Normal.Warm"]]}},geoqCold(){return{layers:[["geoqCold","Geoq.Normal.Cold"]]}}};function RR(e){const t="./gis/radar.tiff";console.log(t);let i=(114.06825863001939-104.18084906665138)*.005,l=(32.396413467808586-22.54283198132819)*.005,c=114.07867152431874,h=22.563727343812303;e.addSource("radar",{type:"image",url:t,coordinates:[[c-i*.5,h+l*.5],[c+i*.5,h+l*.5],[c+i*.5,h-l*.5],[c-i*.5,h-l*.5]]}),e.addLayer({id:"radar-layer",type:"raster",source:"radar",paint:{"raster-fade-duration":0}})}function kR(e){var t="http://192.168.5.19:8080/geoserver/gwc/service/wmts?layer=mytest%3Amxcadtest2&style=&tilematrixset=EPSG:900913&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png&TileMatrix=EPSG:900913:{z}&TileCol={x}&TileRow={y}";e.addSource("wmts-source",{type:"raster",tiles:[t],tileSize:256}),e.addLayer({id:"wmts-layer",type:"raster",source:"wmts-source",paint:{"raster-opacity":.95}})}function zR(){return{TianDiTu:{Normal:{Map:"http://t{s}.tianditu.com/DataServer?T=vec_w&X={x}&Y={y}&L={z}&tk={key}",Annotion:"http://t{s}.tianditu.com/DataServer?T=cva_w&X={x}&Y={y}&L={z}&tk={key}",minzoom:0,maxzoom:18},Satellite:{Map:"http://t{s}.tianditu.com/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk={key}",Annotion:"http://t{s}.tianditu.com/DataServer?T=cia_w&X={x}&Y={y}&L={z}&tk={key}",minzoom:0,maxzoom:18},Terrain:{Map:"http://t{s}.tianditu.com/DataServer?T=ter_w&X={x}&Y={y}&L={z}&tk={key}",Annotion:"http://t{s}.tianditu.com/DataServer?T=cta_w&X={x}&Y={y}&L={z}&tk={key}",minzoom:0,maxzoom:14},Subdomains:["0","1","2","3","4","5","6","7"],key:""},GaoDe:{Normal:{Map:"http://webrd0{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}",minzoom:0,maxzoom:18},Normal_NoTag:{Map:"https://wprd0{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&scl=1<ype=11&x={x}&y={y}&z={z}",minzoom:3,maxzoom:18},Satellite:{Map:"http://webst0{s}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",Annotion:"http://webst0{s}.is.autonavi.com/appmaptile?style=8&x={x}&y={y}&z={z}",minzoom:3,maxzoom:18},Subdomains:["1","2","3","4"]},Baidu:{Normal:{Map:"http://online{s}.map.bdimg.com/onlinelabel/?qt=tile&x={x}&y={y}&z={z}&styles=pl&scaler=1&p=1"},Satellite:{Map:"http://shangetu{s}.map.bdimg.com/it/u=x={x};y={y};z={z};v=009;type=sate&fm=46",Annotion:"http://online{s}.map.bdimg.com/tile/?qt=tile&x={x}&y={y}&z={z}&styles=sl&v=020"},Subdomains:"0123456789",tileType:"bd09"},Geoq:{Normal:{Map:"http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer/tile/{z}/{y}/{x}",PurplishBlue:"http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/{z}/{y}/{x}",Gray:"http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetGray/MapServer/tile/{z}/{y}/{x}",Warm:"http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetWarm/MapServer/tile/{z}/{y}/{x}",minzoom:3,maxzoom:16},Subdomains:[]},OSM:{Normal:{Map:"http://{s}.tile.osm.org/{z}/{x}/{y}.png",minzoom:0,maxzoom:18},Subdomains:["a","b","c"]}}}function FR(){return["https://0pn.cn/maps/vt?lyrs=s&x={x}&y={y}&z={z}","https://0pn.cn/maps/vt?lyrs=s,m&gl=CN&x={x}&y={y}&z={z}"]}let Td,Ro;function BR(e){Td.on("click",function(t){return Qe(this,null,function*(){let{lng:i,lat:l}=t.lngLat;if(e){let f=M.mx_gcj02_To_gps84(i,l);i=f.lng,l=f.lat}console.log("经纬度坐标:",JSON.stringify([i,l]));let c=IR.MercatorCoordinate.fromLngLat([i,l],0);console.log("墨卡托坐标:",JSON.stringify(Ro.map_lnglat_to_meters(i,l)));let h=Ro.mercatorCoord2CAD(c.x,c.y);console.log("CAD坐标:",JSON.stringify(h))})})}let Ed=!1,Sm=!0;Sm=!1,Sm&&(Ed=!1);function OR(){let e=new M.MxCADPluginMapDefaultData;e.cadOrigin=[116275.977014,19273.279085],e.mapOrigin=[114.06825863001939,22.54283198132819],e.meterInCADUnits=1,e.openFile="./demo/road.dwg.mxweb";let t=X.MxFun.getQueryString("maptype");if(!Sm)if(t=="google"){let i=M.mx_gps84_To_gcj02(e.mapOrigin[0],e.mapOrigin[1]);e.mapOrigin=[i.lng,i.lat],Ed=!0,e.viewColor={red:0,green:0,blue:0}}else{let i=su.gdslwzj();t=="gdslwzj"?i=su.gdslwzj():t=="gdyx"?i=su.gdyx():t=="tdtsl"?i=su.tdtsl():t=="bdsl"?i=su.bdsl():t=="geoq"&&(i=su.geoq()),e.rasterTileLayerList=i.layers,i.key&&(e.rasterTileKey=i.key),e.providers=zR()}return e}function NR(e){Ro=e,Td=e.getMapbox(),Ed&&M.MxMapAddGoogleCnLayer(Td,["Image","Lable"],FR()),BR(Ed),Sm?kR(Td):RR(Td)}function UR(){return Qe(this,null,function*(){let e=new M.MxCADUiPrPoint;e.setMessage(`
- 指定下载范围第一点:`);let t=yield e.go();if(!t)return;e.setMessage(`
- 指定下载范围第二点:`),e.setUserDraw((x,w)=>{w.setColor(16711680);let b=new M.McDbPolyline;b.addVertexAt(t),b.addVertexAt(new M.McGePoint3d(t.x,x.y)),b.addVertexAt(x),b.addVertexAt(new M.McGePoint3d(x.x,t.y)),b.constantWidth=X.MxFun.screenCoordLong2Doc(2),b.isClosed=!0,w.drawMcDbEntity(b);let A=[];A.push(t.toVector3()),A.push(new THREE.Vector3(t.x,x.y)),A.push(x.toVector3()),A.push(new THREE.Vector3(x.x,t.y)),w.setColor(12868),w.drawSolid(A,.5)}),e.setDisableOsnap(!0),e.setDisableOrthoTrace(!0),e.setDynamicInputType(X.DynamicInputType.kXYCoordInput);let i=yield e.go();if(!i)return;let l=Ro.cadTolnglat(t.toVector3()),c=Ro.cadTolnglat(i.toVector3()),h=Ro.map_lnglat_to_meters(l[0],l[1]),f=Ro.map_lnglat_to_meters(c[0],c[1]);if(Ed&&!(Ro.outOfChina(l[0],l[1])&&Ro.outOfChina(c[0],c[1]))){let x=M.mx_gcj02_To_gps84(l[0],l[1]),w=M.mx_gcj02_To_gps84(c[0],c[1]);h=Ro.map_lnglat_to_meters(x.lng,x.lat),f=Ro.map_lnglat_to_meters(w.lng,w.lat)}let r={url:"https://0pn.cn/maps/vt?lyrs=s&x={x}&y={y}&z={z}",polygon:[h[0],h[1],f[0],f[1]],zoom:18,auto_close:!1,no_repeated_download:!0,download_dir:"",thread_count:32};X.MxFun.acutPrintf(`
- 使用教程:https://help.mxdraw.com/?pid=111`),X.MxFun.acutPrintf(`
- 复制下面的范围,到下载器下载地图,下载范围:`);let v=`
- `+JSON.stringify([h[0],h[1],f[0],f[1]]);X.MxFun.acutPrintf(v),X.MxFun.acutPrintf(`
- `),Wp({method:"post",url:"http://localhost:1337/users/mxgis/download",data:r}).then(x=>{console.log(x.data),alert(JSON.stringify(x.data))}).catch(x=>{console.log("网络错误")})})}window._iconfont_svg_string_4337873='<svg><symbol id="icon-zidian" viewBox="0 0 1024 1024"><path d="M893.080181 585.210149h-86.234525v-37.615932h79.557697a57.552376 57.552376 0 0 0 1.786757-115.104753l-20.500683-0.658279 2.445035-20.312603a153.473004 153.473004 0 0 0 1.034439-17.679488A148.300813 148.300813 0 0 0 723.056167 245.72636a151.310088 151.310088 0 0 0-39.966928 5.64239l-20.782803 5.64239-3.009274-21.347042A225.695594 225.695594 0 0 0 209.222531 266.415123v18.807966l-16.739089 1.880797a130.715365 130.715365 0 0 0 14.952333 260.490331v37.615932a168.331297 168.331297 0 0 1-35.547056-332.806961 263.311526 263.311526 0 0 1 521.074702-41.753685 181.120714 181.120714 0 0 1 29.998706-2.539075 185.916746 185.916746 0 0 1 185.822706 185.728666v3.573513a95.168309 95.168309 0 0 1-15.704652 187.515423z" fill="#282D33" ></path><path d="M399.371069 341.646988H329.875634a74.573586 74.573586 0 0 0-74.291466 73.257028v478.944858-18.807966 14.576174a74.573586 74.573586 0 0 1 74.573586-74.479546h431.454744V341.646988H399.371069z" fill="#FFFFFF" ></path><path d="M255.584168 908.519088h-18.807966V414.715936A94.039831 94.039831 0 0 1 329.875634 322.839021h69.495435v37.615933H329.875634a56.423898 56.423898 0 0 0-55.4835 54.825221v399.481201a93.381552 93.381552 0 0 1 55.76562-18.807966h412.646778V360.454954H506.012238v-37.615933h274.408226v511.106481H329.875634a55.85966 55.85966 0 0 0-55.4835 52.568265v7.523187h-0.940398a18.807966 18.807966 0 0 1-17.867568 14.482134z" fill="#282D33" ></path><path d="M369.654483 392.804655H710.736949v371.363292H369.654483z" fill="#F8C44F" ></path><path d="M761.612498 815.137536H329.875634a74.573586 74.573586 0 1 0 0 149.053132h431.736864z" fill="#FFFFFF" ></path><path d="M780.420464 982.998634H329.875634a93.381552 93.381552 0 1 1 0-186.669064h450.54483zM329.875634 833.945502a55.76562 55.76562 0 1 0 0 111.437199h412.928898V833.945502z" fill="#282D33" ></path><path d="M475.073133 1024l-54.072903-34.230498-54.072902 34.230498v-127.89417h108.145805v127.89417z" fill="#34CA9D" ></path><path d="M324.327284 893.942914z" fill="#FFFFFF" ></path><path d="M324.327284 875.134948h437.285214v37.615932h-437.285214z" fill="#282D33" ></path><path d="M324.327284 810.529584z" fill="#FFFFFF" ></path><path d="M305.519318 349.076134h37.615933v461.45345h-37.615933zM520.494371 257.857498L453.067813 190.524979l-67.332519 67.332519-26.613272-26.613272L453.067813 137.392475l94.039831 93.851751-26.613273 26.613272z" fill="#282D33" ></path><path d="M436.422763 189.302462h37.615932v248.829392h-37.615932zM559.803021 694.390393l-94.039831-93.851751 26.613272-26.613272 67.426559 67.332519 67.426558-67.332519 26.519233 26.613272-93.945791 93.851751z" fill="#282D33" ></path><path d="M538.832138 393.556974h37.615933v248.829393h-37.615933z" fill="#282D33" ></path></symbol></svg>',function(e){var i=(i=document.getElementsByTagName("script"))[i.length-1],t=i.getAttribute("data-injectcss"),i=i.getAttribute("data-disable-injectsvg");if(!i){var l,c,h,f,r,v=function(b,A){A.parentNode.insertBefore(b,A)};if(t&&!e.__iconfont__svg__cssinject__){e.__iconfont__svg__cssinject__=!0;try{document.write("<style>.svgfont {display: inline-block;width: 1em;height: 1em;fill: currentColor;vertical-align: -0.1em;font-size:16px;}</style>")}catch(b){console&&console.log(b)}}l=function(){var b,A=document.createElement("div");A.innerHTML=e._iconfont_svg_string_4337873,(A=A.getElementsByTagName("svg")[0])&&(A.setAttribute("aria-hidden","true"),A.style.position="absolute",A.style.width=0,A.style.height=0,A.style.overflow="hidden",A=A,(b=document.body).firstChild?v(A,b.firstChild):b.appendChild(A))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(l,0):(c=function(){document.removeEventListener("DOMContentLoaded",c,!1),l()},document.addEventListener("DOMContentLoaded",c,!1)):document.attachEvent&&(h=l,f=e.document,r=!1,w(),f.onreadystatechange=function(){f.readyState=="complete"&&(f.onreadystatechange=null,x())})}function x(){r||(r=!0,h())}function w(){try{f.documentElement.doScroll("left")}catch(b){return void setTimeout(w,50)}x()}}(window),window._iconfont_svg_string_4604696='<svg><symbol id="icon-guding1" viewBox="0 0 1024 1024"><path d="M251.15000029 471.5l214.425 150.1875 183.74999942 128.62500029a243.7875 243.7875 0 0 0 7.01250029-235.42500058l-10.31249971-20.1375 160.61249971-229.3875-153.60000029-107.55-160.61249971 229.3875-22.42500029-2.77499971a243.7875 243.7875 0 0 0-218.84999942 87.11250029z m192.9375 180.9l-204.37500058 291.825a18.74999971 18.74999971 0 1 1-30.67499971-21.4875L413.37500029 630.87499971l-261.1125-182.84999942a18.74999971 18.74999971 0 1 1 21.4875-30.7125l46.61249942 32.625a281.28750029 281.28750029 0 0 1 254.32500058-102.75000029l147.63749942-210.89999971-46.04999942-32.25000058a18.74999971 18.74999971 0 0 1 21.4875-30.74999942l307.19999971 215.1a18.74999971 18.74999971 0 1 1-21.52500029 30.74999942l-46.08749971-32.2875-147.63750029 210.86250029a281.28750029 281.28750029 0 0 1-9.59999942 274.12499971l46.575 32.625a18.74999971 18.74999971 0 1 1-21.4875 30.75000029l-261.1125-182.85000029z" fill="#89cbfa" ></path></symbol><symbol id="icon-guding" viewBox="0 0 1024 1024"><path d="M381.298 418.828h-157.703l-37.575 38.272 155.61 158.377-278.212 345.128 356.040-265.838 154.71 157.41 38.813-39.51 2.407-157.972 238.838-313.29 71.685 73.013 34.695-35.28-310.185-315.743-34.672 35.257 77.287 79.402-311.737 240.773z" ></path></symbol><symbol id="icon-dengpao1" viewBox="0 0 1024 1024"><path d="M344.73 841.5c0 8.28 6.77 15.31 15.31 15.31h32.75v1.26c0 40.65 51.69 73.52 115.43 73.52s115.18-32.87 115.18-73.52v-1.26h28.48c8.53 0 15.31-7.03 15.31-15.31v-59.95H344.96c-0.23 33.17-0.23 59.95-0.23 59.95zM512.1 98.23c-187.2 0-338.76 140.02-338.76 312.67 0 89.83 40.9 170.89 106.65 227.85 14.1 12.12 26.16 26.24 35.98 41.69h137.08l-31.49-352.21 4.6-0.02v-0.1h149.83v0.11l2.61 0.01-31.49 352.21h149.23c6.92-8.25 14.58-15.91 23.54-22.37 79.8-57.21 130.99-146.55 130.99-247.17C850.86 238.25 699.3 98.23 512.1 98.23zM343.93 759.53h323.25v-1.34c0-17.26 3.88-33.93 10.87-49.21H330.27c6.72 16.12 11.77 32.96 13.66 50.55z" fill="#F7B52C" ></path><path d="M546.38 357.44h-92.6l28.87 323h34.85z" fill="#F7B52C" ></path></symbol><symbol id="icon-duigou" viewBox="0 0 1024 1024"><path d="M387.072 611.328L236.6464 460.8 128 569.3952l259.072 259.1232 515.1232-515.072L793.6 204.8z" fill="#07A35A" ></path></symbol><symbol id="icon-jiantou_xiangyou" viewBox="0 0 1024 1024"><path d="M729.6 448H128v85.333333h601.6L597.333333 665.6l59.733334 59.733333 234.666666-234.666666L661.333333 256l-59.733333 59.733333 128 132.266667z" fill="#444444" ></path></symbol><symbol id="icon-jiantou_xiangzuo" viewBox="0 0 1024 1024"><path d="M290.133333 448H896v85.333333H290.133333l132.266667 132.266667L362.666667 725.333333 128 490.666667 362.666667 256l59.733333 59.733333-132.266667 132.266667z" fill="#444444" ></path></symbol><symbol id="icon-shezhi" viewBox="0 0 1024 1024"><path d="M519.9 647.4c-44.8 7.4-90.4-6.9-122.5-38.3-32.1-31.4-46.6-76.2-39-120 9.4-56.8 56.2-102.7 114.2-112.1 44.9-7.6 90.7 6.7 122.9 38.2 32.2 31.6 46.7 76.5 38.9 120.4-9.7 56.9-56.5 102.6-114.5 111.8M848.4 559l66-40.4c10.5-6.4 15.6-18.6 12.9-30.4L895 349.3c-2.7-11.8-12.8-20.6-25.1-21.9l-77.5-8.4c-7.7-0.8-14.7-4.6-19.5-10.5l-13-16c-4.8-5.9-7-13.5-6.1-21l8.9-75.7c1.4-12-5.1-23.6-16.2-28.9l-131-61.8c-11.1-5.2-24.4-3-33.2 5.5l-55 54c-5.4 5.3-12.8 8.4-20.6 8.4H486c-7.7 0-15.1-3-20.6-8.4l-55-54c-8.7-8.6-22-10.8-33.2-5.5l-130.9 61.8c-11.1 5.3-17.6 16.8-16.2 28.9l8.9 75.8c0.9 7.5-1.3 15-6.1 21L220 308.4c-4.8 5.9-11.8 9.7-19.5 10.5l-77.5 8.5c-12.3 1.3-22.3 10.1-25.1 21.9L65.5 488.1c-2.7 11.8 2.4 24 12.9 30.4l66 40.5c6.5 4 11.2 10.4 12.9 17.8l4.6 19.9c1.7 7.4 0.4 15.1-3.7 21.5l-41.6 64.5c-6.6 10.2-5.8 23.4 1.9 32.9l90.7 111.3c7.7 9.5 20.7 13.1 32.3 9.1l73.5-25.3c7.3-2.5 15.3-2.1 22.2 1.2l18.7 8.8c7 3.3 12.3 9.1 14.8 16.3l25.6 72c4.1 11.4 15.1 19.1 27.4 19.1H569c12.4 0 23.4-7.7 27.4-19.1l25.6-72c2.5-7.1 7.9-13 14.8-16.3l18.7-8.8c6.9-3.3 14.9-3.7 22.2-1.2l73.5 25.3c11.7 4 24.6 0.4 32.3-9.1l90.7-111.3c7.7-9.5 8.4-22.7 1.9-32.9l-41.6-64.5c-4.1-6.4-5.5-14.1-3.8-21.5l4.6-19.8c1.9-7.5 6.5-13.9 13.1-17.9" fill="" ></path></symbol><symbol id="icon-dengpao" viewBox="0 0 1024 1024"><path d="M661.333333 916.394667a21.333333 21.333333 0 0 1 21.333334 21.333333v42.666667a21.333333 21.333333 0 0 1-21.333334 21.333333h-298.666666a21.333333 21.333333 0 0 1-21.333334-21.333333v-42.666667a21.333333 21.333333 0 0 1 21.333334-21.333333h298.666666z m-149.333333-896a384 384 0 0 1 170.709333 728.064L682.666667 831.061333a42.666667 42.666667 0 0 1-42.666667 42.666667H384a42.666667 42.666667 0 0 1-42.666667-42.666667v-82.602666A384 384 0 0 1 512 20.394667z m0 85.333333a298.666667 298.666667 0 0 0-85.333333 584.96v97.706667h170.666666l0.042667-97.706667A298.666667 298.666667 0 0 0 512 105.728z" fill="#000000" opacity=".65" ></path></symbol></svg>',function(e){var i=(i=document.getElementsByTagName("script"))[i.length-1],t=i.getAttribute("data-injectcss"),i=i.getAttribute("data-disable-injectsvg");if(!i){var l,c,h,f,r,v=function(b,A){A.parentNode.insertBefore(b,A)};if(t&&!e.__iconfont__svg__cssinject__){e.__iconfont__svg__cssinject__=!0;try{document.write("<style>.svgfont {display: inline-block;width: 1em;height: 1em;fill: currentColor;vertical-align: -0.1em;font-size:16px;}</style>")}catch(b){console&&console.log(b)}}l=function(){var b,A=document.createElement("div");A.innerHTML=e._iconfont_svg_string_4604696,(A=A.getElementsByTagName("svg")[0])&&(A.setAttribute("aria-hidden","true"),A.style.position="absolute",A.style.width=0,A.style.height=0,A.style.overflow="hidden",A=A,(b=document.body).firstChild?v(A,b.firstChild):b.appendChild(A))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(l,0):(c=function(){document.removeEventListener("DOMContentLoaded",c,!1),l()},document.addEventListener("DOMContentLoaded",c,!1)):document.attachEvent&&(h=l,f=e.document,r=!1,w(),f.onreadystatechange=function(){f.readyState=="complete"&&(f.onreadystatechange=null,x())})}function x(){r||(r=!0,h())}function w(){try{f.documentElement.doScroll("left")}catch(b){return void setTimeout(w,50)}x()}}(window);var VR=function(){function e(Ie){ri.call(this,Ie),this.dracoLoader=null,this.ddsLoader=null}e.prototype=Object.assign(Object.create(ri.prototype),{constructor:e,load:function(Ie,be,We,Ge){var ke=this,ot;this.resourcePath!==""?ot=this.resourcePath:this.path!==""?ot=this.path:ot=dl.extractUrlBase(Ie),ke.manager.itemStart(Ie);var ge=function(Ae){Ge?Ge(Ae):console.error(Ae),ke.manager.itemError(Ie),ke.manager.itemEnd(Ie)},Ce=new xo(ke.manager);Ce.setPath(this.path),Ce.setResponseType("arraybuffer"),ke.crossOrigin==="use-credentials"&&Ce.setWithCredentials(!0),Ce.load(Ie,function(Ae){try{ke.parse(Ae,ot,function(_e){be(_e),ke.manager.itemEnd(Ie)},ge)}catch(_e){ge(_e)}},We,ge)},setDRACOLoader:function(Ie){return this.dracoLoader=Ie,this},setDDSLoader:function(Ie){return this.ddsLoader=Ie,this},parse:function(Ie,be,We,Ge){var ke,ot={};if(typeof Ie=="string")ke=Ie;else{var ge=dl.decodeText(new Uint8Array(Ie,0,4));if(ge===f){try{ot[i.KHR_BINARY_GLTF]=new x(Ie)}catch(ct){Ge&&Ge(ct);return}ke=ot[i.KHR_BINARY_GLTF].content}else ke=dl.decodeText(new Uint8Array(Ie))}var Ce=JSON.parse(ke);if(Ce.asset===void 0||Ce.asset.version[0]<2){Ge&&Ge(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}if(Ce.extensionsUsed)for(var Ae=0;Ae<Ce.extensionsUsed.length;++Ae){var _e=Ce.extensionsUsed[Ae],Ne=Ce.extensionsRequired||[];switch(_e){case i.KHR_LIGHTS_PUNCTUAL:ot[_e]=new c(Ce);break;case i.KHR_MATERIALS_UNLIT:ot[_e]=new h;break;case i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:ot[_e]=new L;break;case i.KHR_DRACO_MESH_COMPRESSION:ot[_e]=new w(Ce,this.dracoLoader);break;case i.MSFT_TEXTURE_DDS:ot[_e]=new l(this.ddsLoader);break;case i.KHR_TEXTURE_TRANSFORM:ot[_e]=new b;break;case i.KHR_MESH_QUANTIZATION:ot[_e]=new P;break;default:Ne.indexOf(_e)>=0&&console.warn('THREE.GLTFLoader: Unknown extension "'+_e+'".')}}var Je=new yt(Ce,ot,{path:be||this.resourcePath||"",crossOrigin:this.crossOrigin,manager:this.manager});Je.parse(We,Ge)}});function t(){var Ie={};return{get:function(be){return Ie[be]},add:function(be,We){Ie[be]=We},remove:function(be){delete Ie[be]},removeAll:function(){Ie={}}}}var i={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",MSFT_TEXTURE_DDS:"MSFT_texture_dds"};function l(Ie){if(!Ie)throw new Error("THREE.GLTFLoader: Attempting to load .dds texture without importing DDSLoader");this.name=i.MSFT_TEXTURE_DDS,this.ddsLoader=Ie}function c(Ie){this.name=i.KHR_LIGHTS_PUNCTUAL;var be=Ie.extensions&&Ie.extensions[i.KHR_LIGHTS_PUNCTUAL]||{};this.lightDefs=be.lights||[]}c.prototype.loadLight=function(Ie){var be=this.lightDefs[Ie],We,Ge=new tn(16777215);be.color!==void 0&&Ge.fromArray(be.color);var ke=be.range!==void 0?be.range:0;switch(be.type){case"directional":We=new am(Ge),We.target.position.set(0,0,-1),We.add(We.target);break;case"point":We=new om(Ge),We.distance=ke;break;case"spot":We=new rm(Ge),We.distance=ke,be.spot=be.spot||{},be.spot.innerConeAngle=be.spot.innerConeAngle!==void 0?be.spot.innerConeAngle:0,be.spot.outerConeAngle=be.spot.outerConeAngle!==void 0?be.spot.outerConeAngle:Math.PI/4,We.angle=be.spot.outerConeAngle,We.penumbra=1-be.spot.innerConeAngle/be.spot.outerConeAngle,We.target.position.set(0,0,-1),We.add(We.target);break;default:throw new Error('THREE.GLTFLoader: Unexpected light type, "'+be.type+'".')}return We.position.set(0,0,0),We.decay=2,be.intensity!==void 0&&(We.intensity=be.intensity),We.name=be.name||"light_"+Ie,Promise.resolve(We)};function h(){this.name=i.KHR_MATERIALS_UNLIT}h.prototype.getMaterialType=function(){return cr},h.prototype.extendParams=function(Ie,be,We){var Ge=[];Ie.color=new tn(1,1,1),Ie.opacity=1;var ke=be.pbrMetallicRoughness;if(ke){if(Array.isArray(ke.baseColorFactor)){var ot=ke.baseColorFactor;Ie.color.fromArray(ot),Ie.opacity=ot[3]}ke.baseColorTexture!==void 0&&Ge.push(We.assignTexture(Ie,"map",ke.baseColorTexture))}return Promise.all(Ge)};var f="glTF",r=12,v={JSON:1313821514,BIN:5130562};function x(Ie){this.name=i.KHR_BINARY_GLTF,this.content=null,this.body=null;var be=new DataView(Ie,0,r);if(this.header={magic:dl.decodeText(new Uint8Array(Ie.slice(0,4))),version:be.getUint32(4,!0),length:be.getUint32(8,!0)},this.header.magic!==f)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");for(var We=new DataView(Ie,r),Ge=0;Ge<We.byteLength;){var ke=We.getUint32(Ge,!0);Ge+=4;var ot=We.getUint32(Ge,!0);if(Ge+=4,ot===v.JSON){var ge=new Uint8Array(Ie,r+Ge,ke);this.content=dl.decodeText(ge)}else if(ot===v.BIN){var Ce=r+Ge;this.body=Ie.slice(Ce,Ce+ke)}Ge+=ke}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}function w(Ie,be){if(!be)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=i.KHR_DRACO_MESH_COMPRESSION,this.json=Ie,this.dracoLoader=be,this.dracoLoader.preload()}w.prototype.decodePrimitive=function(Ie,be){var We=this.json,Ge=this.dracoLoader,ke=Ie.extensions[this.name].bufferView,ot=Ie.extensions[this.name].attributes,ge={},Ce={},Ae={};for(var _e in ot){var Ne=H[_e]||_e.toLowerCase();ge[Ne]=ot[_e]}for(_e in Ie.attributes){var Ne=H[_e]||_e.toLowerCase();if(ot[_e]!==void 0){var Je=We.accessors[Ie.attributes[_e]],ct=V[Je.componentType];Ae[Ne]=ct,Ce[Ne]=Je.normalized===!0}}return be.getDependency("bufferView",ke).then(function(wt){return new Promise(function(Gt){Ge.decodeDracoFile(wt,function(pe){for(var Me in pe.attributes){var bt=pe.attributes[Me],gt=Ce[Me];gt!==void 0&&(bt.normalized=gt)}Gt(pe)},ge,Ae)})})};function b(){this.name=i.KHR_TEXTURE_TRANSFORM}b.prototype.extendTexture=function(Ie,be){return Ie=Ie.clone(),be.offset!==void 0&&Ie.offset.fromArray(be.offset),be.rotation!==void 0&&(Ie.rotation=be.rotation),be.scale!==void 0&&Ie.repeat.fromArray(be.scale),be.texCoord!==void 0&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),Ie.needsUpdate=!0,Ie};function A(Ie){Vr.call(this),this.isGLTFSpecularGlossinessMaterial=!0;var be=["#ifdef USE_SPECULARMAP"," uniform sampler2D specularMap;","#endif"].join(`
- `),We=["#ifdef USE_GLOSSINESSMAP"," uniform sampler2D glossinessMap;","#endif"].join(`
- `),Ge=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP"," vec4 texelSpecular = texture2D( specularMap, vUv );"," texelSpecular = sRGBToLinear( texelSpecular );"," // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture"," specularFactor *= texelSpecular.rgb;","#endif"].join(`
- `),ke=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP"," vec4 texelGlossiness = texture2D( glossinessMap, vUv );"," // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture"," glossinessFactor *= texelGlossiness.a;","#endif"].join(`
- `),ot=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb;","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.","material.specularRoughness += geometryRoughness;","material.specularRoughness = min( material.specularRoughness, 1.0 );","material.specularColor = specularFactor.rgb;"].join(`
- `),ge={specular:{value:new tn().setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=ge,this.onBeforeCompile=function(Ce){for(var Ae in ge)Ce.uniforms[Ae]=ge[Ae];Ce.fragmentShader=Ce.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;"),Ce.fragmentShader=Ce.fragmentShader.replace("uniform float metalness;","uniform float glossiness;"),Ce.fragmentShader=Ce.fragmentShader.replace("#include <roughnessmap_pars_fragment>",be),Ce.fragmentShader=Ce.fragmentShader.replace("#include <metalnessmap_pars_fragment>",We),Ce.fragmentShader=Ce.fragmentShader.replace("#include <roughnessmap_fragment>",Ge),Ce.fragmentShader=Ce.fragmentShader.replace("#include <metalnessmap_fragment>",ke),Ce.fragmentShader=Ce.fragmentShader.replace("#include <lights_physical_fragment>",ot)},Object.defineProperties(this,{specular:{get:function(){return ge.specular.value},set:function(Ce){ge.specular.value=Ce}},specularMap:{get:function(){return ge.specularMap.value},set:function(Ce){ge.specularMap.value=Ce}},glossiness:{get:function(){return ge.glossiness.value},set:function(Ce){ge.glossiness.value=Ce}},glossinessMap:{get:function(){return ge.glossinessMap.value},set:function(Ce){ge.glossinessMap.value=Ce,Ce?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_ROUGHNESSMAP=""):(delete this.defines.USE_ROUGHNESSMAP,delete this.defines.USE_GLOSSINESSMAP)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(Ie)}A.prototype=Object.create(Vr.prototype),A.prototype.constructor=A,A.prototype.copy=function(Ie){return Vr.prototype.copy.call(this,Ie),this.specularMap=Ie.specularMap,this.specular.copy(Ie.specular),this.glossinessMap=Ie.glossinessMap,this.glossiness=Ie.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this};function L(){return{name:i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,specularGlossinessParams:["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"],getMaterialType:function(){return A},extendParams:function(Ie,be,We){var Ge=be.extensions[this.name];Ie.color=new tn(1,1,1),Ie.opacity=1;var ke=[];if(Array.isArray(Ge.diffuseFactor)){var ot=Ge.diffuseFactor;Ie.color.fromArray(ot),Ie.opacity=ot[3]}if(Ge.diffuseTexture!==void 0&&ke.push(We.assignTexture(Ie,"map",Ge.diffuseTexture)),Ie.emissive=new tn(0,0,0),Ie.glossiness=Ge.glossinessFactor!==void 0?Ge.glossinessFactor:1,Ie.specular=new tn(1,1,1),Array.isArray(Ge.specularFactor)&&Ie.specular.fromArray(Ge.specularFactor),Ge.specularGlossinessTexture!==void 0){var ge=Ge.specularGlossinessTexture;ke.push(We.assignTexture(Ie,"glossinessMap",ge)),ke.push(We.assignTexture(Ie,"specularMap",ge))}return Promise.all(ke)},createMaterial:function(Ie){var be=new A(Ie);return be.fog=!0,be.color=Ie.color,be.map=Ie.map===void 0?null:Ie.map,be.lightMap=null,be.lightMapIntensity=1,be.aoMap=Ie.aoMap===void 0?null:Ie.aoMap,be.aoMapIntensity=1,be.emissive=Ie.emissive,be.emissiveIntensity=1,be.emissiveMap=Ie.emissiveMap===void 0?null:Ie.emissiveMap,be.bumpMap=Ie.bumpMap===void 0?null:Ie.bumpMap,be.bumpScale=1,be.normalMap=Ie.normalMap===void 0?null:Ie.normalMap,be.normalMapType=Ys,Ie.normalScale&&(be.normalScale=Ie.normalScale),be.displacementMap=null,be.displacementScale=1,be.displacementBias=0,be.specularMap=Ie.specularMap===void 0?null:Ie.specularMap,be.specular=Ie.specular,be.glossinessMap=Ie.glossinessMap===void 0?null:Ie.glossinessMap,be.glossiness=Ie.glossiness,be.alphaMap=null,be.envMap=Ie.envMap===void 0?null:Ie.envMap,be.envMapIntensity=1,be.refractionRatio=.98,be}}}function P(){this.name=i.KHR_MESH_QUANTIZATION}function R(Ie,be,We,Ge){Gr.call(this,Ie,be,We,Ge)}R.prototype=Object.create(Gr.prototype),R.prototype.constructor=R,R.prototype.copySampleValue_=function(Ie){for(var be=this.resultBuffer,We=this.sampleValues,Ge=this.valueSize,ke=Ie*Ge*3+Ge,ot=0;ot!==Ge;ot++)be[ot]=We[ke+ot];return be},R.prototype.beforeStart_=R.prototype.copySampleValue_,R.prototype.afterEnd_=R.prototype.copySampleValue_,R.prototype.interpolate_=function(Ie,be,We,Ge){for(var ke=this.resultBuffer,ot=this.sampleValues,ge=this.valueSize,Ce=ge*2,Ae=ge*3,_e=Ge-be,Ne=(We-be)/_e,Je=Ne*Ne,ct=Je*Ne,wt=Ie*Ae,Gt=wt-Ae,pe=-2*ct+3*Je,Me=ct-Je,bt=1-pe,gt=Me-Je+Ne,bn=0;bn!==ge;bn++){var hn=ot[Gt+bn+ge],nn=ot[Gt+bn+Ce]*_e,pn=ot[wt+bn+ge],wn=ot[wt+bn]*_e;ke[bn]=bt*hn+gt*nn+pe*pn+Me*wn}return ke};var F={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},V={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},j={9728:Ui,9729:$i,9984:Yp,9985:uy,9986:Kp,9987:oc},J={33071:Mr,33648:fh,10497:Zs},ne={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},H={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Q={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ae={CUBICSPLINE:void 0,LINEAR:sc,STEP:yh},ie={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"},le={"image/png":Ao,"image/jpeg":Ma};function fe(Ie,be){return typeof Ie!="string"||Ie===""?"":(/^https?:\/\//i.test(be)&&/^\//.test(Ie)&&(be=be.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(Ie)||/^data:.*,.*$/i.test(Ie)||/^blob:.*$/i.test(Ie)?Ie:be+Ie)}function me(Ie){return Ie.DefaultMaterial===void 0&&(Ie.DefaultMaterial=new Vr({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:nc})),Ie.DefaultMaterial}function he(Ie,be,We){for(var Ge in We.extensions)Ie[Ge]===void 0&&(be.userData.gltfExtensions=be.userData.gltfExtensions||{},be.userData.gltfExtensions[Ge]=We.extensions[Ge])}function Oe(Ie,be){be.extras!==void 0&&(typeof be.extras=="object"?Object.assign(Ie.userData,be.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+be.extras))}function Ve(Ie,be,We){for(var Ge=!1,ke=!1,ot=0,ge=be.length;ot<ge;ot++){var Ce=be[ot];if(Ce.POSITION!==void 0&&(Ge=!0),Ce.NORMAL!==void 0&&(ke=!0),Ge&&ke)break}if(!Ge&&!ke)return Promise.resolve(Ie);for(var Ae=[],_e=[],ot=0,ge=be.length;ot<ge;ot++){var Ce=be[ot];if(Ge){var Ne=Ce.POSITION!==void 0?We.getDependency("accessor",Ce.POSITION):Ie.attributes.position;Ae.push(Ne)}if(ke){var Ne=Ce.NORMAL!==void 0?We.getDependency("accessor",Ce.NORMAL):Ie.attributes.normal;_e.push(Ne)}}return Promise.all([Promise.all(Ae),Promise.all(_e)]).then(function(Je){var ct=Je[0],wt=Je[1];return Ge&&(Ie.morphAttributes.position=ct),ke&&(Ie.morphAttributes.normal=wt),Ie.morphTargetsRelative=!0,Ie})}function He(Ie,be){if(Ie.updateMorphTargets(),be.weights!==void 0)for(var We=0,Ge=be.weights.length;We<Ge;We++)Ie.morphTargetInfluences[We]=be.weights[We];if(be.extras&&Array.isArray(be.extras.targetNames)){var ke=be.extras.targetNames;if(Ie.morphTargetInfluences.length===ke.length){Ie.morphTargetDictionary={};for(var We=0,Ge=ke.length;We<Ge;We++)Ie.morphTargetDictionary[ke[We]]=We}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function at(Ie){var be=Ie.extensions&&Ie.extensions[i.KHR_DRACO_MESH_COMPRESSION],We;return be?We="draco:"+be.bufferView+":"+be.indices+":"+At(be.attributes):We=Ie.indices+":"+At(Ie.attributes)+":"+Ie.mode,We}function At(Ie){for(var be="",We=Object.keys(Ie).sort(),Ge=0,ke=We.length;Ge<ke;Ge++)be+=We[Ge]+":"+Ie[We[Ge]]+";";return be}function yt(Ie,be,We){this.json=Ie||{},this.extensions=be||{},this.options=We||{},this.cache=new t,this.primitiveCache={},this.textureLoader=new id(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.fileLoader=new xo(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}yt.prototype.parse=function(Ie,be){var We=this,Ge=this.json,ke=this.extensions;this.cache.removeAll(),this.markDefs(),Promise.all([this.getDependencies("scene"),this.getDependencies("animation"),this.getDependencies("camera")]).then(function(ot){var ge={scene:ot[0][Ge.scene||0],scenes:ot[0],animations:ot[1],cameras:ot[2],asset:Ge.asset,parser:We,userData:{}};he(ke,ge,Ge),Oe(ge,Ge),Ie(ge)}).catch(be)},yt.prototype.markDefs=function(){for(var Ie=this.json.nodes||[],be=this.json.skins||[],We=this.json.meshes||[],Ge={},ke={},ot=0,ge=be.length;ot<ge;ot++)for(var Ce=be[ot].joints,Ae=0,_e=Ce.length;Ae<_e;Ae++)Ie[Ce[Ae]].isBone=!0;for(var Ne=0,Je=Ie.length;Ne<Je;Ne++){var ct=Ie[Ne];ct.mesh!==void 0&&(Ge[ct.mesh]===void 0&&(Ge[ct.mesh]=ke[ct.mesh]=0),Ge[ct.mesh]++,ct.skin!==void 0&&(We[ct.mesh].isSkinnedMesh=!0))}this.json.meshReferences=Ge,this.json.meshUses=ke},yt.prototype.getDependency=function(Ie,be){var We=Ie+":"+be,Ge=this.cache.get(We);if(!Ge){switch(Ie){case"scene":Ge=this.loadScene(be);break;case"node":Ge=this.loadNode(be);break;case"mesh":Ge=this.loadMesh(be);break;case"accessor":Ge=this.loadAccessor(be);break;case"bufferView":Ge=this.loadBufferView(be);break;case"buffer":Ge=this.loadBuffer(be);break;case"material":Ge=this.loadMaterial(be);break;case"texture":Ge=this.loadTexture(be);break;case"skin":Ge=this.loadSkin(be);break;case"animation":Ge=this.loadAnimation(be);break;case"camera":Ge=this.loadCamera(be);break;case"light":Ge=this.extensions[i.KHR_LIGHTS_PUNCTUAL].loadLight(be);break;default:throw new Error("Unknown type: "+Ie)}this.cache.add(We,Ge)}return Ge},yt.prototype.getDependencies=function(Ie){var be=this.cache.get(Ie);if(!be){var We=this,Ge=this.json[Ie+(Ie==="mesh"?"es":"s")]||[];be=Promise.all(Ge.map(function(ke,ot){return We.getDependency(Ie,ot)})),this.cache.add(Ie,be)}return be},yt.prototype.loadBuffer=function(Ie){var be=this.json.buffers[Ie],We=this.fileLoader;if(be.type&&be.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+be.type+" buffer type is not supported.");if(be.uri===void 0&&Ie===0)return Promise.resolve(this.extensions[i.KHR_BINARY_GLTF].body);var Ge=this.options;return new Promise(function(ke,ot){We.load(fe(be.uri,Ge.path),ke,void 0,function(){ot(new Error('THREE.GLTFLoader: Failed to load buffer "'+be.uri+'".'))})})},yt.prototype.loadBufferView=function(Ie){var be=this.json.bufferViews[Ie];return this.getDependency("buffer",be.buffer).then(function(We){var Ge=be.byteLength||0,ke=be.byteOffset||0;return We.slice(ke,ke+Ge)})},yt.prototype.loadAccessor=function(Ie){var be=this,We=this.json,Ge=this.json.accessors[Ie];if(Ge.bufferView===void 0&&Ge.sparse===void 0)return Promise.resolve(null);var ke=[];return Ge.bufferView!==void 0?ke.push(this.getDependency("bufferView",Ge.bufferView)):ke.push(null),Ge.sparse!==void 0&&(ke.push(this.getDependency("bufferView",Ge.sparse.indices.bufferView)),ke.push(this.getDependency("bufferView",Ge.sparse.values.bufferView))),Promise.all(ke).then(function(ot){var ge=ot[0],Ce=ne[Ge.type],Ae=V[Ge.componentType],_e=Ae.BYTES_PER_ELEMENT,Ne=_e*Ce,Je=Ge.byteOffset||0,ct=Ge.bufferView!==void 0?We.bufferViews[Ge.bufferView].byteStride:void 0,wt=Ge.normalized===!0,Gt,pe;if(ct&&ct!==Ne){var Me=Math.floor(Je/ct),bt="InterleavedBuffer:"+Ge.bufferView+":"+Ge.componentType+":"+Me+":"+Ge.count,gt=be.cache.get(bt);gt||(Gt=new Ae(ge,Me*ct,Ge.count*ct/_e),gt=new ka(Gt,ct/_e),be.cache.add(bt,gt)),pe=new kh(gt,Ce,Je%ct/_e,wt)}else ge===null?Gt=new Ae(Ge.count*Ce):Gt=new Ae(ge,Je,Ge.count*Ce),pe=new kn(Gt,Ce,wt);if(Ge.sparse!==void 0){var bn=ne.SCALAR,hn=V[Ge.sparse.indices.componentType],nn=Ge.sparse.indices.byteOffset||0,pn=Ge.sparse.values.byteOffset||0,wn=new hn(ot[1],nn,Ge.sparse.count*bn),cn=new Ae(ot[2],pn,Ge.sparse.count*Ce);ge!==null&&(pe=new kn(pe.array.slice(),pe.itemSize,pe.normalized));for(var Wt=0,sn=wn.length;Wt<sn;Wt++){var Xt=wn[Wt];if(pe.setX(Xt,cn[Wt*Ce]),Ce>=2&&pe.setY(Xt,cn[Wt*Ce+1]),Ce>=3&&pe.setZ(Xt,cn[Wt*Ce+2]),Ce>=4&&pe.setW(Xt,cn[Wt*Ce+3]),Ce>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return pe})},yt.prototype.loadTexture=function(Ie){var be=this,We=this.json,Ge=this.options,ke=this.textureLoader,ot=window.URL||window.webkitURL,ge=We.textures[Ie],Ce=ge.extensions||{},Ae;Ce[i.MSFT_TEXTURE_DDS]?Ae=We.images[Ce[i.MSFT_TEXTURE_DDS].source]:Ae=We.images[ge.source];var _e=Ae.uri,Ne=!1;return Ae.bufferView!==void 0&&(_e=be.getDependency("bufferView",Ae.bufferView).then(function(Je){Ne=!0;var ct=new Blob([Je],{type:Ae.mimeType});return _e=ot.createObjectURL(ct),_e})),Promise.resolve(_e).then(function(Je){var ct=Ge.manager.getHandler(Je);return ct||(ct=Ce[i.MSFT_TEXTURE_DDS]?be.extensions[i.MSFT_TEXTURE_DDS].ddsLoader:ke),new Promise(function(wt,Gt){ct.load(fe(Je,Ge.path),wt,void 0,Gt)})}).then(function(Je){Ne===!0&&ot.revokeObjectURL(_e),Je.flipY=!1,ge.name!==void 0&&(Je.name=ge.name),Ae.mimeType in le&&(Je.format=le[Ae.mimeType]);var ct=We.samplers||{},wt=ct[ge.sampler]||{};return Je.magFilter=j[wt.magFilter]||$i,Je.minFilter=j[wt.minFilter]||oc,Je.wrapS=J[wt.wrapS]||Zs,Je.wrapT=J[wt.wrapT]||Zs,Je})},yt.prototype.assignTexture=function(Ie,be,We){var Ge=this;return this.getDependency("texture",We.index).then(function(ke){if(!ke.isCompressedTexture)switch(be){case"aoMap":case"emissiveMap":case"metalnessMap":case"normalMap":case"roughnessMap":ke.format=Ma;break}if(We.texCoord!==void 0&&We.texCoord!=0&&!(be==="aoMap"&&We.texCoord==1)&&console.warn("THREE.GLTFLoader: Custom UV set "+We.texCoord+" for texture "+be+" not yet supported."),Ge.extensions[i.KHR_TEXTURE_TRANSFORM]){var ot=We.extensions!==void 0?We.extensions[i.KHR_TEXTURE_TRANSFORM]:void 0;ot&&(ke=Ge.extensions[i.KHR_TEXTURE_TRANSFORM].extendTexture(ke,ot))}Ie[be]=ke})},yt.prototype.assignFinalMaterial=function(Ie){var be=Ie.geometry,We=Ie.material;this.extensions;var Ge=be.attributes.tangent!==void 0,ke=be.attributes.color!==void 0,ot=be.attributes.normal===void 0,ge=Ie.isSkinnedMesh===!0,Ce=Object.keys(be.morphAttributes).length>0,Ae=Ce&&be.morphAttributes.normal!==void 0;if(Ie.isPoints){var _e="PointsMaterial:"+We.uuid,Ne=this.cache.get(_e);Ne||(Ne=new ss,Rn.prototype.copy.call(Ne,We),Ne.color.copy(We.color),Ne.map=We.map,Ne.sizeAttenuation=!1,this.cache.add(_e,Ne)),We=Ne}else if(Ie.isLine){var _e="LineBasicMaterial:"+We.uuid,Je=this.cache.get(_e);Je||(Je=new Ri,Rn.prototype.copy.call(Je,We),Je.color.copy(We.color),this.cache.add(_e,Je)),We=Je}if(Ge||ke||ot||ge||Ce){var _e="ClonedMaterial:"+We.uuid+":";We.isGLTFSpecularGlossinessMaterial&&(_e+="specular-glossiness:"),ge&&(_e+="skinning:"),Ge&&(_e+="vertex-tangents:"),ke&&(_e+="vertex-colors:"),ot&&(_e+="flat-shading:"),Ce&&(_e+="morph-targets:"),Ae&&(_e+="morph-normals:");var ct=this.cache.get(_e);ct||(ct=We.clone(),ge&&(ct.skinning=!0),Ge&&(ct.vertexTangents=!0),ke&&(ct.vertexColors=ic),ot&&(ct.flatShading=!0),Ce&&(ct.morphTargets=!0),Ae&&(ct.morphNormals=!0),this.cache.add(_e,ct)),We=ct}We.aoMap&&be.attributes.uv2===void 0&&be.attributes.uv!==void 0&&be.setAttribute("uv2",new kn(be.attributes.uv.array,2)),We.normalScale&&!Ge&&(We.normalScale.y=-We.normalScale.y),Ie.material=We},yt.prototype.loadMaterial=function(Ie){var be=this,We=this.json,Ge=this.extensions,ke=We.materials[Ie],ot,ge={},Ce=ke.extensions||{},Ae=[];if(Ce[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var _e=Ge[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];ot=_e.getMaterialType(),Ae.push(_e.extendParams(ge,ke,be))}else if(Ce[i.KHR_MATERIALS_UNLIT]){var Ne=Ge[i.KHR_MATERIALS_UNLIT];ot=Ne.getMaterialType(),Ae.push(Ne.extendParams(ge,ke,be))}else{ot=Vr;var Je=ke.pbrMetallicRoughness||{};if(ge.color=new tn(1,1,1),ge.opacity=1,Array.isArray(Je.baseColorFactor)){var ct=Je.baseColorFactor;ge.color.fromArray(ct),ge.opacity=ct[3]}Je.baseColorTexture!==void 0&&Ae.push(be.assignTexture(ge,"map",Je.baseColorTexture)),ge.metalness=Je.metallicFactor!==void 0?Je.metallicFactor:1,ge.roughness=Je.roughnessFactor!==void 0?Je.roughnessFactor:1,Je.metallicRoughnessTexture!==void 0&&(Ae.push(be.assignTexture(ge,"metalnessMap",Je.metallicRoughnessTexture)),Ae.push(be.assignTexture(ge,"roughnessMap",Je.metallicRoughnessTexture)))}ke.doubleSided===!0&&(ge.side=hh);var wt=ke.alphaMode||ie.OPAQUE;return wt===ie.BLEND?ge.transparent=!0:(ge.transparent=!1,wt===ie.MASK&&(ge.alphaTest=ke.alphaCutoff!==void 0?ke.alphaCutoff:.5)),ke.normalTexture!==void 0&&ot!==cr&&(Ae.push(be.assignTexture(ge,"normalMap",ke.normalTexture)),ge.normalScale=new Lt(1,1),ke.normalTexture.scale!==void 0&&ge.normalScale.set(ke.normalTexture.scale,ke.normalTexture.scale)),ke.occlusionTexture!==void 0&&ot!==cr&&(Ae.push(be.assignTexture(ge,"aoMap",ke.occlusionTexture)),ke.occlusionTexture.strength!==void 0&&(ge.aoMapIntensity=ke.occlusionTexture.strength)),ke.emissiveFactor!==void 0&&ot!==cr&&(ge.emissive=new tn().fromArray(ke.emissiveFactor)),ke.emissiveTexture!==void 0&&ot!==cr&&Ae.push(be.assignTexture(ge,"emissiveMap",ke.emissiveTexture)),Promise.all(Ae).then(function(){var Gt;return ot===A?Gt=Ge[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(ge):Gt=new ot(ge),ke.name!==void 0&&(Gt.name=ke.name),Gt.map&&(Gt.map.encoding=_h),Gt.emissiveMap&&(Gt.emissiveMap.encoding=_h),Oe(Gt,ke),ke.extensions&&he(Ge,Gt,ke),Gt})};function Dt(Ie,be,We){var Ge=be.attributes,ke=new Po;if(Ge.POSITION!==void 0){var ot=We.json.accessors[Ge.POSITION],ge=ot.min,Ce=ot.max;if(ge!==void 0&&Ce!==void 0)ke.set(new Pe(ge[0],ge[1],ge[2]),new Pe(Ce[0],Ce[1],Ce[2]));else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;var Ae=be.targets;if(Ae!==void 0)for(var _e=new Pe,Ne=0,Je=Ae.length;Ne<Je;Ne++){var ct=Ae[Ne];if(ct.POSITION!==void 0){var ot=We.json.accessors[ct.POSITION],ge=ot.min,Ce=ot.max;ge!==void 0&&Ce!==void 0?(_e.setX(Math.max(Math.abs(ge[0]),Math.abs(Ce[0]))),_e.setY(Math.max(Math.abs(ge[1]),Math.abs(Ce[1]))),_e.setZ(Math.max(Math.abs(ge[2]),Math.abs(Ce[2]))),ke.expandByVector(_e)):console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}Ie.boundingBox=ke;var wt=new Da;ke.getCenter(wt.center),wt.radius=ke.min.distanceTo(ke.max)/2,Ie.boundingSphere=wt}function It(Ie,be,We){var Ge=be.attributes,ke=[];function ot(_e,Ne){return We.getDependency("accessor",_e).then(function(Je){Ie.setAttribute(Ne,Je)})}for(var ge in Ge){var Ce=H[ge]||ge.toLowerCase();Ce in Ie.attributes||ke.push(ot(Ge[ge],Ce))}if(be.indices!==void 0&&!Ie.index){var Ae=We.getDependency("accessor",be.indices).then(function(_e){Ie.setIndex(_e)});ke.push(Ae)}return Oe(Ie,be),Dt(Ie,be,We),Promise.all(ke).then(function(){return be.targets!==void 0?Ve(Ie,be.targets,We):Ie})}function Nt(Ie,be){var We=Ie.getIndex();if(We===null){var Ge=[],ke=Ie.getAttribute("position");if(ke!==void 0){for(var ot=0;ot<ke.count;ot++)Ge.push(ot);Ie.setIndex(Ge),We=Ie.getIndex()}else return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),Ie}var ge=We.count-2,Ce=[];if(be===Nx)for(var ot=1;ot<=ge;ot++)Ce.push(We.getX(0)),Ce.push(We.getX(ot)),Ce.push(We.getX(ot+1));else for(var ot=0;ot<ge;ot++)ot%2===0?(Ce.push(We.getX(ot)),Ce.push(We.getX(ot+1)),Ce.push(We.getX(ot+2))):(Ce.push(We.getX(ot+2)),Ce.push(We.getX(ot+1)),Ce.push(We.getX(ot)));Ce.length/3!==ge&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");var Ae=Ie.clone();return Ae.setIndex(Ce),Ae}return yt.prototype.loadGeometries=function(Ie){var be=this,We=this.extensions,Ge=this.primitiveCache;function ke(ct){return We[i.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(ct,be).then(function(wt){return It(wt,ct,be)})}for(var ot=[],ge=0,Ce=Ie.length;ge<Ce;ge++){var Ae=Ie[ge],_e=at(Ae),Ne=Ge[_e];if(Ne)ot.push(Ne.promise);else{var Je;Ae.extensions&&Ae.extensions[i.KHR_DRACO_MESH_COMPRESSION]?Je=ke(Ae):Je=It(new vn,Ae,be),Ge[_e]={primitive:Ae,promise:Je},ot.push(Je)}}return Promise.all(ot)},yt.prototype.loadMesh=function(Ie){for(var be=this,We=this.json,Ge=We.meshes[Ie],ke=Ge.primitives,ot=[],ge=0,Ce=ke.length;ge<Ce;ge++){var Ae=ke[ge].material===void 0?me(this.cache):this.getDependency("material",ke[ge].material);ot.push(Ae)}return ot.push(be.loadGeometries(ke)),Promise.all(ot).then(function(_e){for(var Ne=_e.slice(0,_e.length-1),Je=_e[_e.length-1],ct=[],wt=0,Gt=Je.length;wt<Gt;wt++){var pe=Je[wt],Me=ke[wt],bt,gt=Ne[wt];if(Me.mode===F.TRIANGLES||Me.mode===F.TRIANGLE_STRIP||Me.mode===F.TRIANGLE_FAN||Me.mode===void 0)bt=Ge.isSkinnedMesh===!0?new Oh(pe,gt):new Ai(pe,gt),bt.isSkinnedMesh===!0&&!bt.geometry.attributes.skinWeight.normalized&&bt.normalizeSkinWeights(),Me.mode===F.TRIANGLE_STRIP?bt.geometry=Nt(bt.geometry,PE):Me.mode===F.TRIANGLE_FAN&&(bt.geometry=Nt(bt.geometry,Nx));else if(Me.mode===F.LINES)bt=new Vi(pe,gt);else if(Me.mode===F.LINE_STRIP)bt=new so(pe,gt);else if(Me.mode===F.LINE_LOOP)bt=new If(pe,gt);else if(Me.mode===F.POINTS)bt=new zf(pe,gt);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+Me.mode);Object.keys(bt.geometry.morphAttributes).length>0&&He(bt,Ge),bt.name=Ge.name||"mesh_"+Ie,Je.length>1&&(bt.name+="_"+wt),Oe(bt,Ge),be.assignFinalMaterial(bt),ct.push(bt)}if(ct.length===1)return ct[0];for(var bn=new al,wt=0,Gt=ct.length;wt<Gt;wt++)bn.add(ct[wt]);return bn})},yt.prototype.loadCamera=function(Ie){var be,We=this.json.cameras[Ie],Ge=We[We.type];if(!Ge){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return We.type==="perspective"?be=new Xi(jn.radToDeg(Ge.yfov),Ge.aspectRatio||1,Ge.znear||1,Ge.zfar||2e6):We.type==="orthographic"&&(be=new tu(Ge.xmag/-2,Ge.xmag/2,Ge.ymag/2,Ge.ymag/-2,Ge.znear,Ge.zfar)),We.name!==void 0&&(be.name=We.name),Oe(be,We),Promise.resolve(be)},yt.prototype.loadSkin=function(Ie){var be=this.json.skins[Ie],We={joints:be.joints};return be.inverseBindMatrices===void 0?Promise.resolve(We):this.getDependency("accessor",be.inverseBindMatrices).then(function(Ge){return We.inverseBindMatrices=Ge,We})},yt.prototype.loadAnimation=function(Ie){for(var be=this.json,We=be.animations[Ie],Ge=[],ke=[],ot=[],ge=[],Ce=[],Ae=0,_e=We.channels.length;Ae<_e;Ae++){var Ne=We.channels[Ae],Je=We.samplers[Ne.sampler],ct=Ne.target,wt=ct.node!==void 0?ct.node:ct.id,Gt=We.parameters!==void 0?We.parameters[Je.input]:Je.input,pe=We.parameters!==void 0?We.parameters[Je.output]:Je.output;Ge.push(this.getDependency("node",wt)),ke.push(this.getDependency("accessor",Gt)),ot.push(this.getDependency("accessor",pe)),ge.push(Je),Ce.push(ct)}return Promise.all([Promise.all(Ge),Promise.all(ke),Promise.all(ot),Promise.all(ge),Promise.all(Ce)]).then(function(Me){for(var bt=Me[0],gt=Me[1],bn=Me[2],hn=Me[3],nn=Me[4],pn=[],wn=0,cn=bt.length;wn<cn;wn++){var Wt=bt[wn],sn=gt[wn],Xt=bn[wn],Xe=hn[wn],Ut=nn[wn];if(Wt!==void 0){Wt.updateMatrix(),Wt.matrixAutoUpdate=!0;var en;switch(Q[Ut.path]){case Q.weights:en=Jc;break;case Q.rotation:en=td;break;case Q.position:case Q.scale:default:en=Qc;break}var Pn=Wt.name?Wt.name:Wt.uuid,fn=Xe.interpolation!==void 0?ae[Xe.interpolation]:sc,On=[];Q[Ut.path]===Q.weights?Wt.traverse(function(_i){_i.isMesh===!0&&_i.morphTargetInfluences&&On.push(_i.name?_i.name:_i.uuid)}):On.push(Pn);var Gn=Xt.array;if(Xt.normalized){var qn;if(Gn.constructor===Int8Array)qn=1/127;else if(Gn.constructor===Uint8Array)qn=1/255;else if(Gn.constructor==Int16Array)qn=1/32767;else if(Gn.constructor===Uint16Array)qn=1/65535;else throw new Error("THREE.GLTFLoader: Unsupported output accessor component type.");for(var ji=new Float32Array(Gn.length),Nn=0,Di=Gn.length;Nn<Di;Nn++)ji[Nn]=Gn[Nn]*qn;Gn=ji}for(var Nn=0,Di=On.length;Nn<Di;Nn++){var ei=new en(On[Nn]+"."+Q[Ut.path],sn.array,Gn,fn);Xe.interpolation==="CUBICSPLINE"&&(ei.createInterpolant=function(Hr){return new R(this.times,this.values,this.getValueSize()/3,Hr)},ei.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),pn.push(ei)}}}var Ji=We.name!==void 0?We.name:"animation_"+Ie;return new vo(Ji,void 0,pn)})},yt.prototype.loadNode=function(Ie){var be=this.json,We=this.extensions,Ge=this,ke=be.meshReferences,ot=be.meshUses,ge=be.nodes[Ie];return function(){var Ce=[];return ge.mesh!==void 0&&Ce.push(Ge.getDependency("mesh",ge.mesh).then(function(Ae){var _e;if(ke[ge.mesh]>1){var Ne=ot[ge.mesh]++;_e=Ae.clone(),_e.name+="_instance_"+Ne}else _e=Ae;return ge.weights!==void 0&&_e.traverse(function(Je){if(Je.isMesh)for(var ct=0,wt=ge.weights.length;ct<wt;ct++)Je.morphTargetInfluences[ct]=ge.weights[ct]}),_e})),ge.camera!==void 0&&Ce.push(Ge.getDependency("camera",ge.camera)),ge.extensions&&ge.extensions[i.KHR_LIGHTS_PUNCTUAL]&&ge.extensions[i.KHR_LIGHTS_PUNCTUAL].light!==void 0&&Ce.push(Ge.getDependency("light",ge.extensions[i.KHR_LIGHTS_PUNCTUAL].light)),Promise.all(Ce)}().then(function(Ce){var Ae;if(ge.isBone===!0?Ae=new Xy:Ce.length>1?Ae=new al:Ce.length===1?Ae=Ce[0]:Ae=new on,Ae!==Ce[0])for(var _e=0,Ne=Ce.length;_e<Ne;_e++)Ae.add(Ce[_e]);if(ge.name!==void 0&&(Ae.userData.name=ge.name,Ae.name=gr.sanitizeNodeName(ge.name)),Oe(Ae,ge),ge.extensions&&he(We,Ae,ge),ge.matrix!==void 0){var Je=new Hn;Je.fromArray(ge.matrix),Ae.applyMatrix4(Je)}else ge.translation!==void 0&&Ae.position.fromArray(ge.translation),ge.rotation!==void 0&&Ae.quaternion.fromArray(ge.rotation),ge.scale!==void 0&&Ae.scale.fromArray(ge.scale);return Ae})},yt.prototype.loadScene=function(){function Ie(be,We,Ge,ke){var ot=Ge.nodes[be];return ke.getDependency("node",be).then(function(ge){if(ot.skin===void 0)return ge;var Ce;return ke.getDependency("skin",ot.skin).then(function(Ae){Ce=Ae;for(var _e=[],Ne=0,Je=Ce.joints.length;Ne<Je;Ne++)_e.push(ke.getDependency("node",Ce.joints[Ne]));return Promise.all(_e)}).then(function(Ae){return ge.traverse(function(_e){if(_e.isMesh){for(var Ne=[],Je=[],ct=0,wt=Ae.length;ct<wt;ct++){var Gt=Ae[ct];if(Gt){Ne.push(Gt);var pe=new Hn;Ce.inverseBindMatrices!==void 0&&pe.fromArray(Ce.inverseBindMatrices.array,ct*16),Je.push(pe)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',Ce.joints[ct])}_e.bind(new Af(Ne,Je),_e.matrixWorld)}}),ge})}).then(function(ge){We.add(ge);var Ce=[];if(ot.children)for(var Ae=ot.children,_e=0,Ne=Ae.length;_e<Ne;_e++){var Je=Ae[_e];Ce.push(Ie(Je,ge,Ge,ke))}return Promise.all(Ce)})}return function(We){var Ge=this.json,ke=this.extensions,ot=this.json.scenes[We],ge=this,Ce=new Ca;ot.name!==void 0&&(Ce.name=ot.name),Oe(Ce,ot),ot.extensions&&he(ke,Ce,ot);for(var Ae=ot.nodes||[],_e=[],Ne=0,Je=Ae.length;Ne<Je;Ne++)_e.push(Ie(Ae[Ne],Ce,Ge,ge));return Promise.all(_e).then(function(){return Ce})}}(),e}();function GR(e){new VR().load("./gis/34M_17.gltf",i=>{i.scene.position.set(116577.28779765591,19632.646909285337,0),i.scene.rotateX(Math.PI/2),i.scene.scale.set(2,2,2),e.addObject(i.scene)})}const cb=[{type:"参数绘图",name:"画直线",code:`import { MxCpp, McGePoint3d, McDbLine, McCmColor} from "mxcad";
- //画直线
- function drawLine() {
- const mxcad = MxCpp.getCurrentMxCAD();
- // 创建新画布
- mxcad.newFile();
- // 绘制直线
- let line_1 = new McDbLine()
- let pt1 = new McGePoint3d(1000, 200, 0)
- let pt2 = new McGePoint3d(-1000, -200, 0)
- line_1.startPoint = pt1
- line_1.endPoint = pt2
- line_1.trueColor = new McCmColor(0, 255, 0)
- mxcad.drawEntity(line_1)
- let line_2 = new McDbLine(1000, 500, 0, -1000, -500, 0)
- line_2.trueColor = new McCmColor(255, 0, 0)
- line_2.linetypeScale = 0.4
- mxcad.drawEntity(line_2)
- mxcad.drawLine(1000, 800, -1000, -800)
- mxcad.zoomAll()
- mxcad.zoomScale(0.8)
- };
- // 调用画直线方法
- drawLine();
- `},{type:"参数绘图",name:"画圆",code:`import {MxCpp, McDbCircle , McCmColor, McGePoint3d} from "mxcad"
- //画圆
- function drawCircle() {
- const mxcad = MxCpp.getCurrentMxCAD();
- // 创建新画布
- mxcad.newFile();
- //绘制圆
- const circle_1 = new McDbCircle(-100, 300, 0, 20)
- circle_1.trueColor = new McCmColor(255, 0, 0)
- mxcad.drawEntity(circle_1)
- const circle_2 = new McDbCircle()
- circle_2.center = new McGePoint3d(-100, 300, 0)
- circle_2.radius = 10
- circle_2.trueColor = new McCmColor(0, 255, 0)
- mxcad.drawEntity(circle_2)
- mxcad.drawCircle(-100, 300, 30)
- mxcad.zoomAll()
- mxcad.zoomScale(0.8)
- };
- // 调用画圆方法
- drawCircle();
- `},{type:"参数绘图",name:"画点",code:`import { MxCpp, McDbPoint, McCmColor } from "mxcad"
- //画点
- function drawPoint() {
- const mxcad = MxCpp.getCurrentMxCAD();
- // 创建新画布
- mxcad.newFile();
- // 循环画点
- const point = new McDbPoint()
- const color = new McCmColor(0, 255, 0)
- point.trueColor = color
- for (let i = 0; i < 100; i++) {
- point.setPosition(i, 200 + i)
- mxcad.drawEntity(point)
- }
- for (let i = 0; i < 100; i++) {
- mxcad.drawPoint(i, 150 + i)
- }
- mxcad.zoomAll()
- mxcad.zoomScale(0.8)
- };
- // 调用画点的函数
- drawPoint();`},{type:"参数绘图",name:"画圆弧",code:`import { MxCpp, McDbArc, McGePoint3d, McCmColor} from "mxcad";
- //画圆弧
- function drawArc() {
- const mxcad = MxCpp.getCurrentMxCAD();
- // 创建新画布
- mxcad.newFile();
- const arc = new McDbArc()
- arc.center = new McGePoint3d(-100, -100),
- arc.radius = 20
- arc.startAngle = Math.PI / 2
- arc.endAngle = Math.PI * 3 / 2
- arc.trueColor = new McCmColor(255, 233, 0)
- mxcad.drawEntity(arc)
- const arc_1 = new McDbArc()
- const pt1 = new McGePoint3d(-60, -80)
- const pt2 = new McGePoint3d(-80, -100)
- const pt3 = new McGePoint3d(-60, -120)
- arc_1.trueColor = new McCmColor(0, 255, 0)
- arc_1.computeArc(pt1.x, pt1.y, pt2.x, pt2.y, pt3.x, pt3.y)
- mxcad.drawEntity(arc_1)
- mxcad.drawArc(-120, -100, 20, 100, 250);
- mxcad.drawColor = new McCmColor(255, 0, 0)
- mxcad.drawArc2(-80, -80, -100, -100, -80, -120)
- mxcad.drawColor = new McCmColor(0, 0, 255)
- mxcad.drawArc3(-40, -80, -40, -120, 1)
- mxcad.zoomAll()
- mxcad.zoomScale(0.8)
- };
- // 调用绘圆方法
- drawArc()`},{type:"参数绘图",name:"画图片",code:`import { MxCpp, McGePoint3d } from "mxcad";
- //画图片
- function drawImg() {
- const mxcad = MxCpp.getCurrentMxCAD();
- // 创建新画布
- mxcad.newFile();
- //图片插入点
- const pt = new McGePoint3d(0, 0, 0)
- //图片地址
- let imagUrl = "https://cdn.pixabay.com/photo/2022/11/15/12/23/winter-7593872_960_720.jpg";
- mxcad.loadImage(imagUrl, (image) => {
- if (!image) {
- console.log("loadImage failed");
- return;
- }
- let width = mxcad.mxdraw.viewCoordLong2Cad(100);
- let height = (image.height / image.width) * width;
- mxcad.drawImage((pt as any).x, (pt as any).y, width, height, 0, imagUrl);
- mxcad.updateDisplay();
- });
- };
- // 调用绘图片方法
- drawImg();`},{type:"参数绘图",name:"画多段线",code:`import { MxCpp, McDbPolyline, McGePoint3d } from "mxcad"
- //画多段线
- function drawPolyline() {
- const mxcad = MxCpp.getCurrentMxCAD();
- // 创建新画布
- mxcad.newFile();
-
- // 画多段线
- const polyline = new McDbPolyline()
- polyline.isClosed = true // 设置闭合
- polyline.constantWidth = 5 // 设置线宽
- // 添加多段线顶点
- polyline.addVertexAt(new McGePoint3d(800, 300, 0))
- polyline.addVertexAt(new McGePoint3d(900, 300, 0))
- polyline.addVertexAt(new McGePoint3d(900, 400, 0))
- mxcad.drawEntity(polyline)
- mxcad.zoomAll()
- mxcad.zoomScale(0.8)
- }
- // 调用画多段线的方法
- drawPolyline()`},{type:"参数绘图",name:"画椭圆",code:`import {McDbEllipse, McGeVector3d, MxCpp, McGePoint3d, McCmColor } from "mxcad";
-
- //画椭圆弧
- function drawEllipse() {
- const mxcad = MxCpp.getCurrentMxCAD();
- // 创建新画布
- mxcad.newFile();
- //绘制椭圆
- const ellipse = new McDbEllipse();
- ellipse.center = new McGePoint3d(-200, -200);
- ellipse.majorAxis = new McGeVector3d(0, 300, 0);
- ellipse.radiusRatio = 0.5;
- ellipse.trueColor = new McCmColor(255, 233, 0);
- mxcad.drawEntity(ellipse);
- const ellipse_arc = new McDbEllipse();
- ellipse_arc.center = new McGePoint3d(-380, -200);
- ellipse_arc.majorAxis = new McGeVector3d(0, 150, 0);
- ellipse_arc.minorAxis = new McGeVector3d(280, 0, 0);
- ellipse_arc.startAngle = Math.PI / 2;
- ellipse_arc.endAngle = Math.PI * 3 / 2;
- ellipse_arc.trueColor = new McCmColor(0, 255, 255);
- mxcad.drawEntity(ellipse_arc);
- mxcad.drawEllipse(0, -200, 200, 0, 1.5);
- mxcad.drawColor = new McCmColor(0, 255, 0);
- mxcad.drawEllipseArc(200, -200, 200, 0, 1.5, 100, 650);
- mxcad.zoomAll();
- mxcad.zoomScale(0.8);
- };
- // 调用画椭圆的方法
- drawEllipse();`},{type:"参数绘图",name:"画文字",code:`import { MxCpp, McGePoint3d, McDbText, McCmColor } from "mxcad";
- function drawText() {
- const mxcad = MxCpp.getCurrentMxCAD();
- // 创建新画布
- mxcad.newFile();
- // 绘制文字
- let text = new McDbText()
- text.textString = 'Hello World'
- text.position = new McGePoint3d(1000, 200, 0)
- text.height = 50
- text.trueColor = new McCmColor(0, 255, 0)
- mxcad.drawEntity(text)
- mxcad.zoomAll()
- mxcad.zoomScale(0.8)
- };
- // 调用画文字的方法
- drawText();`},{type:"参数绘图",name:"画多行文字",code:`import { MxCpp } from "mxcad";\r
- \r
- function drawMtext() {\r
- let mxcad = MxCpp.getCurrentMxCAD();\r
- //清空当前显示内容\r
- mxcad.newFile();\r
- \r
- //把颜色改回黑白色\r
- mxcad.drawColorIndex = 0;\r
- \r
- mxcad.addLayer("MtextLayer");\r
- \r
- //设置当前图层为"MtextLayer"\r
- \r
- mxcad.drawLayer = "MtextLayer"; \r
- \r
- mxcad.drawTextStyle = "";\r
- \r
- mxcad.drawMText(0, -100, "控件:\\\\P多行文字测试", 50, 400, 0, 1);\r
- \r
- mxcad.zoomAll();\r
- mxcad.updateDisplay();\r
- };\r
- \r
- // 调用画多行文字的方法\r
- drawMtext();`},{type:"参数绘图",name:"画尺寸标注",code:`
- import { McDbAlignedDimension,McDb, McDbRotatedDimension, MxCpp, McGePoint3d, McCmColor } from "mxcad";
- //画标注
- function drawDimension() {
- const mxcad = MxCpp.getCurrentMxCAD();
- // 创建新画布
- mxcad.newFile();
- // 画标注
- const mDimension = new McDbAlignedDimension()
- mDimension.xLine1Point = new McGePoint3d(-1800, 800)
- mDimension.xLine2Point = new McGePoint3d(1800, 800)
- mDimension.dimLinePoint = new McGePoint3d(800, 500)
- mDimension.textAttachment = McDb.AttachmentPoint.kTopLeft
- mDimension.trueColor = new McCmColor(200, 255, 0)
- mDimension.oblique = 0
- mxcad.drawEntity(mDimension)
- const rDimension = new McDbRotatedDimension()
- rDimension.xLine1Point = new McGePoint3d(-1800, -800)
- rDimension.xLine2Point = new McGePoint3d(1800, -800)
- rDimension.dimLinePoint = new McGePoint3d(-800, -500)
- rDimension.textAttachment = McDb.AttachmentPoint.kTopLeft
- rDimension.textRotation = 0.6
- rDimension.trueColor = new McCmColor(200, 255, 0)
- rDimension.oblique = 0
- rDimension.rotation = 0
- rDimension.dimensionText = "标注文本"
- mxcad.drawEntity(rDimension)
- mxcad.zoomCenter(0, 0)
- };
- // 调用画标注方法
- drawDimension();`},{type:"参数绘图",name:"画路径",code:`import { MxCpp } from "mxcad";\r
- \r
- // 画路径\r
- function drawPath() {\r
- const mxcad = MxCpp.getCurrentMxCAD();\r
- // 创建新画布\r
- mxcad.newFile();\r
- //用路径 绘制矩形框\r
- //定义一个路径的开始点\r
- mxcad.pathMoveTo(0, 300);\r
- //路径的一下个点\r
- mxcad.pathLineTo(100, 300);\r
- //路径的一下个点\r
- mxcad.pathLineTo(100, 400);\r
- //路径的一下个点\r
- mxcad.pathLineTo(0, 400);\r
- //把路径设置成闭合\r
- mxcad.pathMakeClosed();\r
- //生成一个矩形框的多义线\r
- mxcad.drawPathToPolyline();\r
- \r
- //定义一个路径的开始点\r
- mxcad.pathMoveTo(170, 320)\r
- mxcad.pathLineTo(200, 320)\r
- mxcad.pathLineTo(200, 340)\r
- mxcad.pathLineTo(170, 340)\r
- // 把上面定义的路径定义填充排除区域.\r
- mxcad.pathMakeExclude(true)\r
- mxcad.pathMoveTo(150, 300)\r
- mxcad.pathLineTo(250, 300)\r
- mxcad.pathLineTo(250, 400)\r
- mxcad.pathLineTo(150, 400)\r
- mxcad.pathMakeClosed();\r
- // 将路径生成一个填充 这里的参数是图案缩放比例\r
- mxcad.drawPathToHatch(1);\r
- \r
- mxcad.zoomAll();\r
- mxcad.zoomScale(0.8)\r
- };\r
- \r
- // 调用画路径的函数\r
- drawPath();`},{type:"参数绘图",name:"画填充",code:`import { MxCpp, McCmColor } from "mxcad";\r
- \r
- // 画填充\r
- function drawHatch() {\r
- const mxcad = MxCpp.getCurrentMxCAD();\r
- // 创建新画布\r
- mxcad.newFile();\r
- // 绘制一个实心填充\r
- //定义一个路径的开始点\r
- mxcad.pathMoveTo(150, 3300);\r
- //路径的一下个点\r
- mxcad.pathLineTo(250, 3300);\r
- //路径的一下个点\r
- mxcad.pathLineTo(250, 3400);\r
- //路径的一下个点\r
- mxcad.pathLineTo(150, 3300);\r
- //把路径拟合成一个样线\r
- mxcad.drawColor = new McCmColor(255, 0, 0);\r
- mxcad.drawPathToHatch(1);\r
- \r
- // 绘制一个图形填充\r
- mxcad.addPatternDefinition("MyHatchPattern1", "((45, 0,0, 0,0.125))");\r
- mxcad.drawPatternDefinition = "MyHatchPattern1";\r
- //定义一个路径的开始点\r
- mxcad.pathMoveTo(250, 3300);\r
- //路径的一下个点\r
- mxcad.pathLineTo(350, 3300);\r
- //路径的一下个点\r
- mxcad.pathLineTo(350, 3400);\r
- //路径的一下个点\r
- mxcad.pathLineTo(250, 3300);\r
- mxcad.drawColor = new McCmColor(255, 255, 0);\r
- //把路径变成一个填充,80,是填充图案的缩放比例.\r
- mxcad.drawPathToHatch(100);\r
- mxcad.zoomAll()\r
- mxcad.zoomScale(0.8)\r
- };\r
- \r
- // 调用画填充的方法\r
- drawHatch();`},{type:"参数绘图",name:"画图块",code:`import { MxCpp, McDbBlockTableRecord, McDbLine, McDbCircle, McCmColor, McDbBlockReference, McGePoint3d } from "mxcad";\r
- \r
- // 画图块\r
- function drawBlock() {\r
- const mxcad = MxCpp.getCurrentMxCAD();\r
- // 创建新画布\r
- mxcad.newFile();\r
- \r
- // 先从数据库中得到图块表\r
- let blkTable = mxcad.getDatabase().getBlockTable();\r
- // 将一个新的图块记录添加到图块表中\r
- let blkRecId = blkTable.add(new McDbBlockTableRecord());\r
- \r
- // 根据ObjectId再次得到刚刚添加的图块记录\r
- let blkTableRecord = blkRecId.getMcDbBlockTableRecord()\r
- \r
- // 添加两条线段再图块记录中 这里每条线段的具体属性比如开始点和结束点自行赋值\r
- const line = new McDbLine(50, 50, 0, -50, -50, 0)\r
- line.trueColor = new McCmColor(0, 255, 0)\r
- const line1 = new McDbLine(-50, 50, 0, 50, -50, 0)\r
- const circle = new McDbCircle(0, 0, 0, 50)\r
- circle.trueColor = new McCmColor(255, 255, 0)\r
- blkTableRecord.appendAcDbEntity(line);\r
- blkTableRecord.appendAcDbEntity(line1);\r
- blkTableRecord.appendAcDbEntity(circle);\r
- \r
- // 设置图块的基点 一般是包围盒内的点, 可以任意指定\r
- blkTableRecord.origin = new McGePoint3d(0, 0, 0);\r
- \r
- // 实例化块参照 这里需要设置我们刚刚添加图块记录得到的ObjectId\r
- let blkRef = new McDbBlockReference();\r
- blkRef.blockTableRecordId = blkRecId;\r
- // 最后设置位置 渲染图块\r
- blkRef.position = new McGePoint3d(0, 0, 0);\r
- \r
- mxcad.drawEntity(blkRef);\r
- \r
- mxcad.zoomAll()\r
- mxcad.zoomScale(0.8)\r
- };\r
- \r
- // 调用画图块方法\r
- drawBlock();`},{type:"参数绘图",name:"画文本自定义实体",code:`import {\r
- MxCpp, McDbLine, McGePoint3d, McDbCustomEntity, IMcDbDwgFiler,MxCADWorldDraw,McGePoint3dArray,\r
- McGeVector3d,McDbText,McDb,MxCADResbuf,MxCADSelectionSet,McObjectId,McDbCircle } from "mxcad"\r
- \r
- // 线文本自定义实体\r
- // 新创建 McDbLineText 类,继承McDbCustomEntity\r
- class McDbTestLineText extends McDbCustomEntity {\r
- //设置McDbLineText类中的两个直线端点 pt1、pt2\r
- //以及显示线段长度的文字_text和文字大小_textsize\r
- private pt1: McGePoint3d = new McGePoint3d();\r
- private pt2: McGePoint3d = new McGePoint3d();\r
- private _text: string = "";\r
- private _textsize: number = 10;\r
- //构造函数\r
- constructor(imp?: any) {\r
- super(imp);\r
- }\r
- //创建函数\r
- public create(imp: any) {\r
- return new McDbTestLineText(imp)\r
- }\r
- //获取类型\r
- public getTypeName(): string {\r
- return "McDbTestLineText";\r
- }\r
- //设置或获取文本值\r
- public set text(val: string) {\r
- this._text = val;\r
- }\r
- public get text(): string {\r
- return this._text;\r
- }\r
- //设置或获取文本大小\r
- public set textsize(val: number) {\r
- this._textsize = val;\r
- }\r
- public get textsize(): number {\r
- return this._textsize;\r
- }\r
- //读取自定义实体数据pt1、pt2、_text、_textsize\r
- public dwgInFields(filter: IMcDbDwgFiler): boolean {\r
- this.pt1 = filter.readPoint("pt1").val;\r
- this.pt2 = filter.readPoint("pt2").val;\r
- this._text = filter.readString("text").val;\r
- this._textsize = filter.readDouble("textsize").val;\r
- return true;\r
- }\r
- //写入自定义实体数据pt1、pt2、_text、_textsize\r
- public dwgOutFields(filter: IMcDbDwgFiler): boolean {\r
- filter.writePoint("pt1", this.pt1);\r
- filter.writePoint("pt2", this.pt2);\r
- filter.writeString("text", this._text);\r
- filter.writeDouble("textsize", this._textsize);\r
- return true;\r
- }\r
- //自定义同步函数,当其他对象与该对象相连时同步数据\r
- private fineLink(pt: McGePoint3d): any {\r
- let ret: any = {};\r
- let myId = this.getObjectID();\r
- let dSearch = this._textsize * 0.5;;\r
- let filter = new MxCADResbuf();\r
- filter.AddString("McDbCustomEntity", 5020);\r
- let ss = new MxCADSelectionSet();\r
- ss.crossingSelect(pt.x - dSearch, pt.y - dSearch, pt.x + dSearch, pt.y + dSearch, filter);\r
- ss.forEach((id) => {\r
- if (id == myId)\r
- return;\r
- let ent = id.getMcDbEntity();\r
- if (!ent) return;\r
- if (ent instanceof McDbLineText) {\r
- let line = (ent as McDbLineText);\r
- let linkPoint = line.getPoint1();\r
- let link_pos = 0;\r
- // 得到直线与图块连接的端点坐标.\r
- let dist = line.getPoint1().distanceTo(pt);\r
- if (dist > line.getPoint2().distanceTo(pt)) {\r
- dist = line.getPoint2().distanceTo(pt);\r
- linkPoint = line.getPoint2();\r
- link_pos = 1;\r
- }\r
- if (dist < dSearch) {\r
- ret[id.id] = { link_point: linkPoint,link_pos:link_pos };\r
- }\r
- }\r
- });\r
- return ret;\r
- }\r
- //处理夹点编辑效果\r
- public moveGripPointsAt(iIndex: number, dXOffset: number, dYOffset: number, dZOffset: number) {\r
- this.assertWrite();\r
- let pt:McGePoint3d = this.pt1.clone();\r
- let new_pt:McGePoint3d = pt;\r
- if (iIndex == 0) {\r
- this.pt1.x += dXOffset;\r
- this.pt1.y += dYOffset;\r
- this.pt1.z += dZOffset;\r
- new_pt = this.pt1;\r
- }\r
- else if (iIndex == 1) {\r
- pt = this.pt2.clone();\r
- this.pt2.x += dXOffset;\r
- this.pt2.y += dYOffset;\r
- this.pt2.z += dZOffset;\r
- new_pt = this.pt2;\r
- }\r
- if (this.getObjectID().isValid()) {\r
- // 同步,与连接的其它对象。\r
- let linkobj = this.fineLink(pt)\r
- Object.keys(linkobj).forEach((id_val:any)=>{\r
- let idFind = new McObjectId(id_val);\r
- let lineFind = (idFind.getMcDbEntity() as McDbLineText);\r
- if(linkobj[id_val].link_pos == 0){\r
- lineFind.setPoint1(new_pt);\r
- }\r
- else{\r
- lineFind.setPoint2(new_pt);\r
- }\r
- });\r
- }\r
- };\r
- //设置对象编辑点位\r
- public getGripPoints(): McGePoint3dArray {\r
- let ret = new McGePoint3dArray()\r
- ret.append(this.pt1);\r
- ret.append(this.pt2);\r
- return ret;\r
- };\r
- //动态绘制\r
- public worldDraw(draw: MxCADWorldDraw): void {\r
- let circle_r = this._textsize * 0.4;\r
- let vec2 = this.pt2.sub(this.pt1);\r
- vec2.normalize().mult(circle_r);\r
- let tmpline = new McDbLine(this.pt1.clone().addvec(vec2),\r
- this.pt2.clone().subvec(vec2));\r
- draw.drawEntity(tmpline);\r
- let vec = this.pt2.sub(this.pt1).mult(0.5);\r
- let midpt = this.pt1.clone().addvec(vec);\r
- if (vec.dotProduct(McGeVector3d.kXAxis) < 0) {\r
- vec.negate();\r
- }\r
- let ange = vec.angleTo2(McGeVector3d.kXAxis, McGeVector3d.kNegateZAxis);\r
- let str = this._text;\r
- if (str.length == 0) {\r
- str = this.pt1.distanceTo(this.pt2).toFixed(2);\r
- }\r
- vec.perpVector();\r
- if (vec.dotProduct(McGeVector3d.kYAxis) < 0) {\r
- vec.negate();\r
- }\r
- vec.normalize().mult(this._textsize * 0.2);\r
- let text = new McDbText();\r
- text.textString = str;\r
- text.position = midpt.clone().addvec(vec);\r
- text.alignmentPoint = midpt.clone().addvec(vec);\r
- text.rotation = ange;\r
- text.verticalMode = McDb.TextVertMode.kTextBottom;\r
- text.horizontalMode = McDb.TextHorzMode.kTextCenter;\r
- text.height = this._textsize;\r
- draw.drawEntity(text)\r
- let circle1 = new McDbCircle();\r
- circle1.center = this.pt1;\r
- circle1.radius = circle_r;\r
- draw.drawEntity(circle1);\r
- \r
- let circle2= new McDbCircle();\r
- circle2.center = this.pt2;\r
- circle2.radius = circle_r;\r
- draw.drawEntity(circle2);\r
- }\r
- // 设置pt1\r
- public setPoint1(pt1: McGePoint3d) {\r
- this.assertWrite();\r
- this.pt1 = pt1.clone();\r
- }\r
- // 设置pt2\r
- public setPoint2(pt2: McGePoint3d) {\r
- this.assertWrite();\r
- this.pt2 = pt2.clone();\r
- }\r
- // 获取pt1\r
- public getPoint1() {\r
- return this.pt1;\r
- }\r
- //获取pt2\r
- public getPoint2() {\r
- return this.pt2;\r
- }\r
- }\r
- \r
- // 绘线文本自定义实体\r
- async function MxTest_LineText() {\r
- let mxcad = MxCpp.getCurrentMxCAD();\r
- //清空当前显示内容\r
- mxcad.newFile();\r
- \r
- let pt1 = new McGePoint3d(100, 100, 0);\r
- let pt2 = new McGePoint3d(200, 150, 0);\r
- let pt3 = new McGePoint3d(400, 50, 0);\r
- let pt4 = new McGePoint3d(600, 60, 0);\r
- let pt5 = new McGePoint3d(200, 300, 0);\r
- \r
- let textsize = 5;\r
- \r
- let myline1 = new McDbTestLineText();\r
- myline1.setPoint1(pt1);\r
- myline1.setPoint2(pt2);\r
- myline1.textsize = textsize;\r
- myline1.text = "xxxx";\r
- mxcad.drawEntity(myline1);\r
- \r
- \r
- let myline2 = new McDbTestLineText();\r
- myline2.setPoint1(pt2);\r
- myline2.setPoint2(pt3);\r
- myline2.textsize = textsize;\r
- mxcad.drawEntity(myline2);\r
- \r
- let myline3 = new McDbTestLineText();\r
- myline3.setPoint1(pt3);\r
- myline3.setPoint2(pt4);\r
- myline3.textsize = textsize;\r
- mxcad.drawEntity(myline3);\r
- \r
- \r
- let myline4 = new McDbTestLineText();\r
- myline4.setPoint1(pt2);\r
- myline4.setPoint2(pt5);\r
- myline4.textsize = textsize;\r
- mxcad.drawEntity(myline4);\r
- \r
- \r
- //把所有的实体都放到当前显示视区\r
- mxcad.zoomW(new McGePoint3d(-300, -300, 0), new McGePoint3d(650, 500, 0));\r
- //更新视区显示\r
- mxcad.updateDisplay();\r
- }\r
- \r
- // 自定义实体注册\r
- new McDbTestLineText().rxInit();\r
- // 调用绘线文本自定义实体方法\r
- MxTest_LineText();\r
- \r
- `},{type:"参数绘图",name:"画多种线型的直线",code:`import { McCmColor, MxCpp} from "mxcad"\r
- \r
- // 绘制多种线型直线\r
- function Mx_Test_DrawLine() {\r
- let mxcad = MxCpp.getCurrentMxCAD();\r
- //清空当前显示内容\r
- mxcad.newFile();\r
- //把颜色改回黑白色\r
- mxcad.drawColorIndex = 0;\r
- //把线型改成实线\r
- mxcad.drawLinetype = "";\r
- //设置线宽 4\r
- mxcad.drawLineWidth = 0;\r
- \r
- \r
- //创建一个图层,名为"LineLayer"\r
- mxcad.addLayer("LineLayer");\r
- //设置当前图层为"LineLayer"\r
- mxcad.drawLayer = "LineLayer";\r
- // 直接绘制一个实线\r
- // 参数一直线的开始点x坐标,参数二直线的开始点y坐标,参数三直线的结束点x坐标,参数四直线的结束点y坐标\r
- mxcad.drawLine(0, 0, 100, 0);\r
- // 绘制一个实斜线\r
- mxcad.drawLine(200, 0, 300, 100);\r
- \r
- \r
- //----------------------------------------------------------------------------------------------------------\r
- //绘制一个虚线\r
- //定义虚线数据据,"MyLineType"是线型名,"6,-8"是虚线的一个单位定义,6是实线长,-8是空格长。\r
- mxcad.addLinetype("MyLineType", "6,-10");\r
- //设计当前线型为"MyLineType"\r
- mxcad.drawLinetype = "MyLineType";\r
- // 绘制一个虚线\r
- mxcad.drawLine(0, 30, 100, 30);\r
- // 绘制一个斜虚线\r
- mxcad.drawLine(200, 30, 300, 130);\r
- \r
- //---------------------------------------------------------------------------------------------------------\r
- // 修改绘线的颜色为 16711680(蓝色), 16711680转成16进制是0xFF 00 00,其中,FF是蓝色,00是绿色,第个二00是红色。\r
- mxcad.drawColor = new McCmColor(0, 0, 255);\r
- // 绘制一个蓝色的虚线\r
- \r
- mxcad.drawLine(0, 60, 100, 60);\r
- // 绘制一个蓝色的斜虚线\r
- mxcad.drawLine(200, 60, 300, 160);\r
- //---------------------------------------------------------------------------------------------------------\r
- //把颜色改回黑白色\r
- mxcad.drawColorIndex = 0;\r
- //把线型改成实线\r
- mxcad.drawLinetype = "";\r
- //设置线宽 4\r
- mxcad.drawLineWidth = 4;\r
- //绘制一个带宽度的直线。\r
- mxcad.drawLine(0, 90, 100, 90);\r
- // 绘制一个带宽度的斜线\r
- mxcad.drawLine(200, 90, 300, 190);\r
- \r
- //---------------------------------------------------------------------------------------------------------\r
- //绘制一个点划线虚线\r
- mxcad.addLinetype("MyLineType2", "10,-2,3,-2");\r
- //把线型改点划线\r
- mxcad.drawLinetype = "MyLineType2";\r
- // 修改绘线的颜色为 255(红色), 255转成16进制是0x00 00 FF,其中,00是蓝色,第个二00是绿色,FF是红色。\r
- mxcad.drawColor = new McCmColor(255, 0, 0);\r
- //绘制一个带宽度的红色点划线。\r
- mxcad.drawLine(0, 120, 100, 120);\r
- // 绘制一个带宽度红色点划斜线\r
- mxcad.drawLine(200, 120, 300, 220);\r
- //---------------------------------------------------------------------------------------------------------\r
- //增加一个带有形的线型\r
- mxcad.addTextStyle("MyLineTypeTextStyle", "txt.shx", "hztxt.shx", 1);\r
- mxcad.addLinetypeEx("MyLineType3", "(12.7,(\\"T=MxDraw\\",\\"S=2.54\\",\\"L=-5.08\\",\\"R=0.0\\",\\"X=-2.54\\",\\"Y=-1.27\\"),-10.08)", "MyLineTypeTextStyle");\r
- mxcad.drawLinetype = "MyLineType3";\r
- mxcad.drawLineWidth = 0;\r
- //绘制一个带宽度的红色点划线。\r
- mxcad.drawLine(350, 120, 600, 120);\r
- //---------------------------------------------------------------------------------------------------------\r
- //增加一个带有形的线型\r
- //把颜色改回黑白色\r
- mxcad.drawColorIndex = 0;\r
- mxcad.drawLineWidth = 4;\r
- //绘制一个带宽度的红色点划线。\r
- mxcad.drawLine(350, 220, 600, 220);\r
- \r
- //把所有的实体都放到当前显示视区\r
- mxcad.zoomAll();\r
- //更新视区显示\r
- mxcad.updateDisplay();\r
- }\r
- \r
- // 调用绘制多种线型直线的方法\r
- Mx_Test_DrawLine()`},{type:"参数绘图",name:"画多种文字样式的文字",code:`import { MxCpp, McCmColor } from "mxcad";\r
- \r
- function Mx_Test_TrueText() {\r
- let mxcad = MxCpp.getCurrentMxCAD();\r
- //清空当前显示内容\r
- mxcad.newFile();\r
- MxCpp.App.loadFonts([], [], ["syadobe", "simsun"], () => {\r
- \r
- // 添加一个黑体文字样式\r
- mxcad.AddTureTypeTextStyle("ht_style", "syadobe");\r
- \r
- // 添加一个宋体文字样式\r
- mxcad.AddTureTypeTextStyle("st_style", "simsun");\r
- \r
- // 设置当前样式为黑体\r
- mxcad.drawTextStyle = "ht_style";\r
- \r
- mxcad.drawColor = new McCmColor(200, 255, 50);\r
- mxcad.drawText(0, 3500, "绘图控件TrueType文字测试1", 100, 0, 0, 1);\r
- \r
- // 设置当前样式为黑体\r
- mxcad.drawTextStyle = "st_style";\r
- mxcad.drawColor = new McCmColor(200, 100, 0);\r
- mxcad.drawText(0, 3200, "绘图控件TrueType文字测试2", 100, 0, 0, 1);\r
- \r
- mxcad.zoomAll();\r
- mxcad.regen();\r
- mxcad.updateDisplay();\r
- });\r
- };\r
- \r
- // 调用画多种文字样式的文字的方法\r
- Mx_Test_TrueText()`},{type:"交互绘图",name:"取点画圆弧",code:`import { MxCADUiPrPoint, McDbPolyline, McDbArc, MxCpp } from "mxcad";
- //画圆弧
- async function Mx_drawArc() {
- // 根据起点,中点,端点三个点确定一段圆弧
- // 获取起点
- let getFristPoint = new MxCADUiPrPoint();
- getFristPoint.setMessage('指定起点');
- let fristPoint = await getFristPoint.go();
- if (!fristPoint) return
- // 获取第二个点
- let getSecondPoint = new MxCADUiPrPoint();
- getSecondPoint.setMessage('指定圆弧的第二个点');
- //动态绘制取点对象
- getSecondPoint.setUserDraw((pt, pw) => {
- let pl = new McDbPolyline();
- pl.addVertexAt(fristPoint)
- pl.addVertexAt(pt);
- pw.drawMcDbEntity(pl)
- })
- let secondPoint = await getSecondPoint.go();
- if (!secondPoint) return;
- // 获取端点
- let getThirdPoint = new MxCADUiPrPoint();
- getThirdPoint.setMessage('指定圆弧的端点');
- //动态绘制圆弧
- getThirdPoint.setUserDraw((pt, pw) => {
- let arc = new McDbArc();
- arc.computeArc(fristPoint.x, fristPoint.y, secondPoint.x, secondPoint.y, pt.x, pt.y);//三点画圆弧
- pw.drawMcDbEntity(arc)
- });
- let thirdPoint = await getThirdPoint.go();
- if (!thirdPoint) return
- // 画圆弧
- let arc = new McDbArc();
- arc.computeArc(fristPoint.x, fristPoint.y, secondPoint.x, secondPoint.y, thirdPoint.x, thirdPoint.y);//三点画圆弧
- const mxcad = MxCpp.getCurrentMxCAD();
- mxcad.drawEntity(arc);
- };
- // 调用画圆弧的方法
- Mx_drawArc();
- `},{type:"交互绘图",name:"取点画直线",code:`import {MxCADUiPrPoint, McDbLine, MxCpp} from "mxcad";\r
- \r
- //画线\r
- async function Mx_drawLine() {\r
- // 获取线段起点\r
- let getFristPoint = new MxCADUiPrPoint();\r
- getFristPoint.setMessage("请点击确定起始点");\r
- let fristPoint: any = await getFristPoint.go();\r
- if (!fristPoint) return\r
- \r
- // 获取线段终点\r
- let getSecondPoint = new MxCADUiPrPoint();\r
- getSecondPoint.setMessage("请点击确定终点");\r
- getSecondPoint.setUserDraw((pt, pw) => {\r
- let line = new McDbLine(fristPoint.x, fristPoint.y, fristPoint.z, pt.x, pt.y, pt.z);\r
- pw.drawMcDbEntity(line)\r
- })\r
- let secondPoint: any = await getSecondPoint.go();\r
- if (!secondPoint) return\r
- \r
- // 绘制线段\r
- let line = new McDbLine(fristPoint.x, fristPoint.y, fristPoint.z, secondPoint.x, secondPoint.y, secondPoint.z);\r
- const mxcad = MxCpp.getCurrentMxCAD();\r
- mxcad.drawEntity(line)\r
- };\r
- \r
- // 调用画线的方法\r
- \r
- Mx_drawLine();`},{type:"交互绘图",name:"取点画文字",code:`import { McDbText, MxCADUiPrDist, MxCADUiPrPoint, MxCADUiPrString, MxCpp } from "mxcad";\r
- \r
- async function Mx_drawText() {\r
- // 创建文字对象\r
- const text = new McDbText();\r
- \r
- // 设置文字内容\r
- const getStr = new MxCADUiPrString()\r
- getStr.setMessage("请输入文字内容")\r
- const str = await getStr.go()\r
- if (!str) return\r
- text.textString = str;\r
- \r
- // 设置文字高度\r
- const getDist = new MxCADUiPrDist()\r
- getDist.setMessage("请输入文字高度")\r
- const height = await getDist.go()\r
- if (!height) return\r
- text.height = getDist.value();\r
- \r
- // 设置文字高度\r
- const getPoint = new MxCADUiPrPoint()\r
- getPoint.setMessage("请点击确定文字位置")\r
- getPoint.setUserDraw((pt, pw) => {\r
- text.position = pt;\r
- text.alignmentPoint = pt;\r
- pw.drawMcDbEntity(text)\r
- })\r
- const position = await getPoint.go()\r
- if (!position) return\r
- text.position = position;\r
- text.alignmentPoint = position\r
- \r
- const mxcad = MxCpp.getCurrentMxCAD();\r
- mxcad.drawEntity(text);\r
- };\r
- \r
- // 调用绘制文字的方法\r
- Mx_drawText();`},{type:"交互绘图",name:"取点画圆",code:`import {McDbCircle, MxCADUiPrDist, MxCADUiPrPoint, MxCpp} from "mxcad";\r
- \r
- // 画圆\r
- async function Mx_drawCircle(){\r
- // 创建圆\r
- const circle = new McDbCircle();\r
- \r
- // 获取圆心\r
- const getCenter = new MxCADUiPrPoint();\r
- getCenter.setMessage('请确定圆心位置\\n');\r
- const center = await getCenter.go();\r
- if (!center) return;\r
- circle.center = center;\r
- \r
- // 获取圆半径\r
- const getRadius = new MxCADUiPrDist();\r
- getRadius.setBasePt(center);\r
- getRadius.setMessage('请输入圆半径');\r
- // 动态绘制圆\r
- getRadius.setUserDraw((pt, pw) => {\r
- const r = pt.distanceTo(center);\r
- circle.radius = r;\r
- pw.drawMcDbEntity(circle)\r
- })\r
- const radiusVal = await getRadius.go();\r
- if (!radiusVal) return;\r
- circle.radius = getRadius.value();\r
- \r
- // 绘制圆\r
- const mxobj = MxCpp.getCurrentMxCAD();\r
- mxobj.drawEntity(circle);\r
- };\r
- \r
- // 调用画圆的方法\r
- Mx_drawCircle();`},{type:"交互绘图",name:"取点画图片",code:`import {MxCADUiPrPoint, MxCpp} from "mxcad";\r
- \r
- //画图片\r
- async function Mx_drawImg() {\r
- // 设置图片插入点\r
- const getPoint = new MxCADUiPrPoint();\r
- getPoint.setMessage("\\n指定插入点:");\r
- let pt = await getPoint.go();\r
- if (!pt) return;\r
- \r
- const mxcad = MxCpp.getCurrentMxCAD();\r
- // 设置图片地址\r
- let imagUrl = "https://cdn.pixabay.com/photo/2022/11/15/12/23/winter-7593872_960_720.jpg";\r
- mxcad.loadImage(imagUrl,(image)=>{\r
- if(!image ){ \r
- console.log("loadImage failed");\r
- return;\r
- }\r
- // 设置图片宽高\r
- let width = mxcad.mxdraw.viewCoordLong2Cad(100);\r
- let height = (image.height / image.width) * width;\r
- mxcad.drawImage((pt as any).x,(pt as any).y,width,height,0,imagUrl);\r
- mxcad.updateDisplay();\r
- });\r
- };\r
- \r
- // 调用画图片的方法\r
- Mx_drawImg();`},{type:"交互绘图",name:"取点画多段线",code:`import { MxCpp, MxCADUiPrPoint, McDbPolyline, MxCADUiPrDist, McGeVector3d, McGePoint3d, McDbArc, MxCADUtility, McDbLine, McDb} from "mxcad";\r
- \r
- // 画多段线\r
- async function Mx_drawPolyline() {\r
- // 获取画布实例\r
- const mxcad = MxCpp.App.getCurrentMxCAD();\r
- const getPoint = new MxCADUiPrPoint();\r
- getPoint.setMessage("\\n指定起点:");\r
- let firstPoint = await getPoint.go();\r
- if (!firstPoint) return;\r
- let pointArr: any[] = [];\r
- let drawObjIds: any[] = [];\r
- let isArc: boolean = false;\r
- let dStartWidth: number = 0;\r
- let dEndWidth: number = 0;\r
- pointArr.push({ pt: firstPoint, dBulge: 0, dStartWidth, dEndWidth })\r
- let isAutoClose: boolean = false;\r
- let isReverse: boolean = false;//圆弧方向是否取反\r
- let arcDirection: any = null //指定圆弧切向\r
- while (true) {\r
- if (!isArc) {\r
- //绘直线\r
- const getNextPoint = new MxCADUiPrPoint;\r
- getNextPoint.setMessage("\\n指定下一个点");\r
- // 提示消息\r
- if (pointArr.length < 2) {\r
- getNextPoint.setKeyWords('[圆弧(A)/宽度(W)]')\r
- } else {\r
- getNextPoint.setKeyWords('[放弃(U)/圆弧(A)/宽度(W)/闭合(C)]')\r
- }\r
- let lastPoint = pointArr[pointArr.length - 1];//鼠标点击的最后一个点\r
- // 等待鼠标点击期间会执行setUserDraw动态绘制函数中的回调函数\r
- getNextPoint.setUserDraw((pt, pw) => {\r
- // pt 就是鼠标所在图纸位置的坐标\r
- // pw 是提供了一些动态绘制方法的对象\r
- let pl = new McDbPolyline();\r
- pl.addVertexAt(lastPoint.pt, lastPoint.dBulge, lastPoint.dStartWidth, lastPoint.dEndWidth)\r
- pl.addVertexAt(pt, 0, dStartWidth, dEndWidth);\r
- pw.drawMcDbEntity(pl);\r
- })\r
- let nextPoint = await getNextPoint.go();\r
- if (nextPoint !== null) {\r
- // 获取到了鼠标点击点\r
- pointArr.push({ pt: nextPoint, dBulge: 0, dStartWidth, dEndWidth });\r
- let pl = new McDbPolyline();\r
- pl.addVertexAt(lastPoint.pt, lastPoint.dBulge, lastPoint.dStartWidth, lastPoint.dEndWidth);\r
- pl.addVertexAt(nextPoint, 0, dStartWidth, dEndWidth);\r
- drawObjIds.push(mxcad.drawEntity(pl))\r
- } else if (getNextPoint.getStatus() === Mx.MrxDbgUiPrBaseReturn.kKeyWord) {\r
- // 用户输入关键字\r
- let keyWord = getNextPoint.keyWordPicked()\r
- if (keyWord === 'A') {\r
- // 绘制圆弧\r
- isArc = true;\r
- } else if (keyWord === 'W') {\r
- // 设置宽度\r
- /**\r
- * 输入空格宽度不变\r
- */\r
- let getWidth = new MxCADUiPrDist();\r
- getWidth.setMessage('指定起点宽度:');\r
- // 获取线宽\r
- let dWVal = await getWidth.go();\r
- if (dWVal !== null && getWidth.getStatus() !== Mx.MrxDbgUiPrBaseReturn.kNone) {\r
- dStartWidth = getWidth.value();\r
- pointArr[pointArr.length - 1].dStartWidth = dStartWidth;\r
- }\r
- getWidth.setMessage('指定端点宽度');\r
- dWVal = await getWidth.go();\r
- if (dWVal !== null && getWidth.getStatus() !== Mx.MrxDbgUiPrBaseReturn.kNone) {\r
- dEndWidth = getWidth.value();\r
- pointArr[pointArr.length - 1].dEndWidth = dEndWidth;\r
- }\r
- } else if (keyWord === 'U') {\r
- // 回退操作\r
- if (pointArr.length > 1 && drawObjIds.length > 1) {\r
- pointArr.pop();\r
- drawObjIds[drawObjIds.length - 1].erase();\r
- drawObjIds.pop();\r
- }\r
- } else if (keyWord === 'C') {\r
- isAutoClose = true;\r
- break;\r
- }\r
- } else {\r
- break;\r
- }\r
- } else {\r
- // 绘制圆弧\r
- let getNextPoint = new MxCADUiPrPoint();\r
- getNextPoint.setMessage('指定圆弧的端点(按住 ctrl 键取相反方向)\\n');\r
- getNextPoint.setKeyWords('[第二个点(S)/角度(A)/圆心(CE)/放弃(U)/直线(L)/宽度(W)/闭合(CL)]');\r
- // 计算圆弧的切向量.\r
- let vecArcTangent = new McGeVector3d();\r
- // 开端的圆弧切向量取水平方向./获取圆弧切向\r
- if (pointArr.length < 2) {\r
- // 开端的圆弧切向量取水平方向.\r
- vecArcTangent.copy(McGeVector3d.kYAxis);\r
- } else {\r
- let length = pointArr.length;\r
- let p1 = pointArr[length - 2].pt;\r
- let dBulge = pointArr[length - 2].dBulge;\r
- let p2 = pointArr[length - 1].pt;\r
- if (dBulge === 0) {\r
- // 前一段是个直线.\r
- vecArcTangent = new McGePoint3d(p2.x, p2.y, 0.0).sub(new McGePoint3d(p1.x, p1.y, 0.0));\r
- }\r
- else {\r
- // 前一段为曲线,求圆弧的切向量\r
- let tmpPl = new McDbPolyline;\r
- tmpPl.addVertexAt(p1, dBulge);\r
- tmpPl.addVertexAt(p2);\r
- let tmpVec = tmpPl.getFirstDeriv(new McGePoint3d(p2.x, p2.y, 0.0));//曲线上任意一点的切向量\r
- if (tmpVec.ret) {\r
- vecArcTangent = tmpVec.val;\r
- }\r
- else {\r
- vecArcTangent.copy(McGeVector3d.kXAxis);\r
- }\r
- }\r
- }\r
- let lastPoint = pointArr[pointArr.length - 1];\r
- //监听ctrl键是否被按下\r
- document.addEventListener('keydown', function (event) {\r
- if (event.ctrlKey && event.keyCode === 17) {\r
- isReverse = true;\r
- }\r
- });\r
- // ctrl键松开\r
- document.addEventListener('keyup', function () {\r
- isReverse = false;\r
- });\r
- getNextPoint.setUserDraw((pt, pw) => {\r
- let pl = new McDbPolyline();\r
- let d = CMxDrawPolylineDragArcDraw_CalcArcBulge(lastPoint.pt, pt, arcDirection ? arcDirection : vecArcTangent);\r
- if (isReverse) d = -d;\r
- pl.addVertexAt(lastPoint.pt, d, lastPoint.dStartWidth, lastPoint.dEndWidth);\r
- pl.addVertexAt(pt, 0, dStartWidth, dEndWidth);\r
- pw.drawMcDbEntity(pl);\r
- })\r
- let nextPoint = await getNextPoint.go();\r
- if (nextPoint != null) {\r
- let dBulge = CMxDrawPolylineDragArcDraw_CalcArcBulge(lastPoint.pt, nextPoint, arcDirection ? arcDirection : vecArcTangent);\r
- if (isReverse) dBulge = -dBulge;\r
- lastPoint.dBulge = dBulge;\r
- pointArr.push({ pt: nextPoint, dBulge: 0, dStartWidth, dEndWidth });\r
- let pl = new McDbPolyline();\r
- pl.addVertexAt(lastPoint.pt, dBulge, lastPoint.dStartWidth, lastPoint.dEndWidth);\r
- pl.addVertexAt(nextPoint, 0, dStartWidth, dEndWidth);\r
- drawObjIds.push(mxcad.drawEntity(pl));\r
- } else if (getNextPoint.getStatus() === Mx.MrxDbgUiPrBaseReturn.kKeyWord) {\r
- // 获取用户输入关键字\r
- let keyWord = getNextPoint.keyWordPicked();\r
- if (keyWord === 'L') {\r
- // 变直线\r
- isArc = false;\r
- } else if (keyWord === 'U') {\r
- // 回退\r
- if (pointArr.length > 1 && drawObjIds.length > 1) {\r
- pointArr.pop();\r
- drawObjIds[drawObjIds.length - 1].erase();\r
- drawObjIds.pop();\r
- }\r
- } else if (keyWord === 'S') {\r
- // 用户指定圆弧的第二个点\r
- let getPoint2 = new MxCADUiPrPoint();//用户输入的指定点\r
- getPoint2.setMessage("指定圆弧的第二个点");\r
- let pt2: any = await getPoint2.go();\r
- if (pt2 === null) return\r
- let getPoint3 = new MxCADUiPrPoint();\r
- getPoint3.setMessage("指定圆弧的端点");\r
- let lastPoint = pointArr[pointArr.length - 1]\r
- getPoint3.setUserDraw((pt, pw) => {\r
- let arc = new McDbArc();\r
- arc.computeArc(lastPoint.pt.x, lastPoint.pt.y, pt2.x, pt2.y, pt.x, pt.y);//三点绘制圆弧\r
- pw.drawMcDbEntity(arc);\r
- });\r
- let pt3 = await getPoint3.go();\r
- if (!pt3) break;\r
- let retB = MxCADUtility.calcBulge(lastPoint.pt, pt2, pt3);//开始点,中点,结束点 三点计算当前弧线的凸度\r
- if (!retB.ret) break;\r
- pointArr[pointArr.length - 1] = retB.val;\r
- pointArr.push({ pt: pt3, dBulge: 0, dStartWidth, dEndWidth });//最后一个点\r
- let pl = new McDbPolyline();\r
- pl.addVertexAt(lastPoint.pt, retB.val, dStartWidth, dEndWidth);\r
- pl.addVertexAt(pt3);\r
- drawObjIds.push(mxcad.drawEntity(pl));\r
- } else if (keyWord === 'W') {\r
- // 设置宽度\r
- let getWidth = new MxCADUiPrDist();\r
- getWidth.setMessage('指定起点宽度:');\r
- // 获取线宽\r
- let dWVal = await getWidth.go();\r
- if (dWVal !== null && getWidth.getStatus() !== Mx.MrxDbgUiPrBaseReturn.kNone) {\r
- dStartWidth = getWidth.value();\r
- pointArr[pointArr.length - 1].dStartWidth = dStartWidth;\r
- }\r
- getWidth.setMessage('指定端点宽度');\r
- dWVal = await getWidth.go();\r
- if (dWVal !== null && getWidth.getStatus() !== Mx.MrxDbgUiPrBaseReturn.kNone) {\r
- dEndWidth = getWidth.value();\r
- pointArr[pointArr.length - 1].dEndWidth = dEndWidth;\r
- }\r
- } else if (keyWord === 'D') {\r
- // 指定圆弧切向\r
- let getDirection = new MxCADUiPrPoint();\r
- getDirection.setMessage('指定圆弧起点的切向:');\r
- let dirVal = await getDirection.go();\r
- if (dirVal === null) break;\r
- arcDirection = new McGeVector3d(dirVal.x, dirVal.y, dirVal.z)\r
- } else if (keyWord === 'CE') {\r
- // 确定圆心\r
- let getCenter = new MxCADUiPrPoint();\r
- getCenter.setMessage('指定圆弧的圆心:');\r
- let arcCenter: any = await getCenter.go();\r
- if (!arcCenter) return;\r
- // 起始角度:起点与圆心的连线与X轴正方向的夹角\r
- // 结束角度:结束点与圆心的连线与X轴正方向的夹角\r
- let getNextPoint = new MxCADUiPrPoint();\r
- let lastPoint = pointArr[pointArr.length - 1];\r
- let r: number = 0;//圆弧凸度\r
- let arc = new McDbArc();//圆弧\r
- // 开端的圆弧切向量取水平方向./获取圆弧切向\r
- getNextPoint.setUserDraw(async (pt, pw) => {\r
- // 起始角度\r
- arc.startAngle = lastPoint.pt.sub(arcCenter).angleTo1(new McGeVector3d(arcCenter.x, 0, 0))//始终不变\r
- arc.endAngle = pt.sub(arcCenter).angleTo1(new McGeVector3d(arcCenter.x, 0, 0))\r
- arc.center = arcCenter;\r
- arc.radius = arcCenter.distanceTo(lastPoint.pt);\r
- if (pt.y < arcCenter.y) arc.endAngle = -arc.endAngle;\r
- // // 获取圆弧上的第三个点\r
- let lineX = new McDbPolyline();\r
- lineX.addVertexAt(new McGePoint3d(arcCenter.x, 0, 0));\r
- lineX.addVertexAt(new McGePoint3d(0, 0, 0));\r
- let pointsX = arc.IntersectWith(lineX, 3);//X轴交点\r
- // 获取凸度\r
- let rLine = new McDbPolyline();\r
- rLine.addVertexAt(arcCenter);\r
- rLine.addVertexAt(pt);\r
- let currentPoint = arc.IntersectWith(rLine, 2);//当前线段与圆弧的交点\r
- let cp: any = null;\r
- if (currentPoint.length() === 1) {\r
- cp = currentPoint.at(0);\r
- } else {\r
- if (pt.distanceTo(currentPoint.at(0)) <= pt.distanceTo(currentPoint.at(1))) {\r
- cp = currentPoint.at(0);\r
- } else {\r
- cp = currentPoint.at(1);\r
- }\r
- }\r
- let retB = MxCADUtility.calcBulge(lastPoint.pt, pointsX.at(0), cp);\r
- if (retB.ret) {\r
- r = retB.val;\r
- let pl = new McDbPolyline()\r
- pl.addVertexAt(lastPoint.pt, r);\r
- pl.addVertexAt(cp);\r
- pw.drawMcDbEntity(pl)\r
- }\r
- })\r
- let nextPoint = await getNextPoint.go();\r
- if (!nextPoint) break;\r
- // 获取凸度\r
- let rLine = new McDbPolyline();\r
- rLine.addVertexAt(arcCenter);\r
- rLine.addVertexAt(nextPoint);\r
- let currentPoint = arc.IntersectWith(rLine, 2);\r
- let cp: any = null;\r
- if (currentPoint.length() === 1) {\r
- cp = currentPoint.at(0);\r
- } else {\r
- if (nextPoint.distanceTo(currentPoint.at(0)) <= nextPoint.distanceTo(currentPoint.at(1))) {\r
- cp = currentPoint.at(0);\r
- } else {\r
- cp = currentPoint.at(1);\r
- }\r
- }\r
- let pl = new McDbPolyline()\r
- pl.addVertexAt(lastPoint.pt, r, dStartWidth, dEndWidth);\r
- pl.addVertexAt(cp);\r
- pointArr[pointArr.length - 1].dBulge = r;\r
- pointArr.push({ pt: cp, dBulge: 0, dStartWidth, dEndWidth })\r
- drawObjIds.push(mxcad.drawEntity(pl));\r
- \r
- } else if (keyWord === 'CL') {\r
- // 闭合\r
- isAutoClose = true;\r
- break;\r
- }\r
- } else {\r
- break;\r
- }\r
- \r
- }\r
- }\r
- // 删除监听事件\r
- document.removeEventListener('keydown', () => isReverse = false)\r
- document.removeEventListener('keyup', () => isReverse = false)\r
- // 最终绘制\r
- /**\r
- * 先删除所有临时对象再重新绘制多边形\r
- */\r
- for (let i = 0; i < drawObjIds.length; i++) {\r
- drawObjIds[i].erase();\r
- }\r
- if (pointArr.length > 1) {\r
- let pl = new McDbPolyline();\r
- pointArr.forEach(item => {\r
- pl.addVertexAt(item.pt, item.dBulge, item.dStartWidth, item.dEndWidth)\r
- })\r
- pl.isClosed = isAutoClose;\r
- mxcad.drawEntity(pl);\r
- }\r
- }\r
- \r
- // 计算圆弧凸度\r
- function CMxDrawPolylineDragArcDraw_CalcArcBulge(firstPoint, nextPoint, vecArcTangent): number {\r
- if (firstPoint.isEqualTo(nextPoint))\r
- return 0.0;\r
- let midPt = firstPoint.c().addvec(nextPoint.c().sub(firstPoint).mult(0.5));\r
- \r
- let vecMid = nextPoint.c().sub(firstPoint);\r
- vecMid.rotateBy(Math.PI / 2.0, McGeVector3d.kZAxis);\r
- \r
- let tmpMidLine = new McDbLine(midPt, midPt.c().addvec(vecMid));\r
- \r
- let vecVertical = vecArcTangent.c();\r
- vecVertical.rotateBy(Math.PI / 2.0, McGeVector3d.kZAxis);\r
- \r
- let tmpVerticalLine = new McDbLine(firstPoint, firstPoint.c().addvec(vecVertical));\r
- \r
- let aryPoint = tmpMidLine.IntersectWith(tmpVerticalLine, McDb.Intersect.kExtendBoth);\r
- if (aryPoint.isEmpty())\r
- return 0.0;\r
- \r
- let arcCenPoint = aryPoint.at(0);\r
- \r
- let dR = arcCenPoint.distanceTo(firstPoint);\r
- \r
- vecMid.normalize();\r
- vecMid.mult(dR);\r
- \r
- let arcMidPt1 = arcCenPoint.c().addvec(vecMid);\r
- let arcMidPt2 = arcCenPoint.c().subvec(vecMid);\r
- let vecArcDir1 = arcMidPt1.c().sub(firstPoint);\r
- let vecArcDir2 = arcMidPt2.c().sub(firstPoint);\r
- let arcMidPt = arcMidPt1;\r
- if (vecArcDir1.angleTo1(vecArcTangent) > vecArcDir2.angleTo1(vecArcTangent)) {\r
- arcMidPt = arcMidPt2;\r
- }\r
- return MxCADUtility.calcBulge(firstPoint, arcMidPt, nextPoint).val;\r
- }\r
- \r
- // 调用画多段线的方法\r
- Mx_drawPolyline();`},{type:"交互绘图",name:"取点画椭圆",code:`import { McDbEllipse,MxCADUiPrPoint, McDbLine, McGePoint3d, MxCADUiPrDist, MxCpp } from "mxcad";\r
- \r
- // 绘制椭圆\r
- async function drawMxDbEllipse() {\r
- \r
- // 创建椭圆对象\r
- const ellipse = new McDbEllipse();\r
- \r
- // 指定椭圆的轴端点\r
- const getPt1 = new MxCADUiPrPoint();\r
- getPt1.setMessage("\\n指定椭圆的轴端点:");\r
- const pt1 = await getPt1.go();\r
- if (!pt1) return;\r
- \r
- // 指定椭圆轴的另一个端点\r
- const getPt2 = new MxCADUiPrPoint();\r
- getPt2.setMessage("\\n指定椭圆轴的另一个端点:");\r
- getPt2.setUserDraw((pt, pw) => {\r
- const line = new McDbLine(pt, pt1);\r
- pw.drawMcDbEntity(line);\r
- })\r
- const pt2 = await getPt2.go();\r
- if (!pt2) return;\r
- \r
- // 获取椭圆中心点\r
- const center = new McGePoint3d((pt1.x + pt2.x) / 2, (pt1.y + pt2.y) / 2);\r
- ellipse.center = center;\r
- ellipse.majorAxis = pt1.sub(pt2);\r
- const xRadius = pt1.distanceTo(pt2) / 2\r
- \r
- // 指定另一条半轴长度\r
- const getDist = new MxCADUiPrDist();\r
- getDist.setMessage("指定另一条半轴长度")\r
- getDist.setBasePt(center)\r
- getDist.setUserDraw((pt, pw) => {\r
- const yRadius = center.distanceTo(pt) / 2\r
- // 设置椭圆的副轴长度与主轴长度的比值\r
- ellipse.radiusRatio = yRadius / xRadius\r
- pw.drawMcDbEntity(ellipse)\r
- })\r
- let length = await getDist.go()\r
- if (!length) return\r
- if (getDist.getDetailedResult() === Mx.DetailedResult.kCoordIn) {\r
- const yRadius = length / 2\r
- ellipse.radiusRatio = yRadius / xRadius\r
- }\r
- MxCpp.getCurrentMxCAD().drawEntity(ellipse)\r
- };\r
- \r
- // 调用绘制椭圆的方法\r
- drawMxDbEllipse();`},{type:"交互绘图",name:"选点填充",code:`import { MxCADUiPrPoint, MxCADUtility, MxCpp } from "mxcad";\r
- \r
- // 选点填充\r
- async function MxTest_DrawHatchFormPoint() {\r
- // 指定填充区域内部一点\r
- const getPoint = new MxCADUiPrPoint();\r
- getPoint.setMessage("\\n指定填充区域内部一点:");\r
- getPoint.disableAllTrace(true);\r
- getPoint.setDisableOsnap(true);\r
- let pt = await getPoint.go();\r
- if (!pt) return;\r
- \r
- // 绘制填充\r
- let hatch = MxCADUtility.builderHatchFromPoint(pt);\r
- if (!hatch) {\r
- Mx.MxFun.acutPrintf("没有找到闭合区域\\n")\r
- return;\r
- }\r
- \r
- let mxcad = MxCpp.getCurrentMxCAD();\r
- mxcad.drawEntity(hatch);\r
- };\r
- \r
- // 调用选点填充的方法\r
- MxTest_DrawHatchFormPoint();`},{type:"交互绘图",name:"插入图块",code:`import { McDbBlockReference, MxCADUiPrPoint, MxCpp } from "mxcad";\r
- \r
- function getHostUrl(): string {\r
- let host = window.location.hostname;\r
- if (host.substring(0, 4) != "http") {\r
- host = document.location.protocol + "//" + host;\r
- }\r
- return host;\r
- }\r
- \r
- // 插入图块\r
- async function MxTest_InsertBlock() {\r
- let baseUrl = "http://localhost:3000/mxcad/"\r
- if (baseUrl.substring(0, 16) == "http://localhost") {\r
- baseUrl = getHostUrl() + baseUrl.substring(16);\r
- }\r
- // 设置图块路径\r
- let blkFilePath = baseUrl + "tree.mxweb";\r
- \r
- // 插入图块文件\r
- let mxcad = MxCpp.App.getCurrentMxCAD();\r
- let blkrecId = await mxcad.insertBlock(blkFilePath, "tree");\r
- if (!blkrecId.isValid()) {\r
- // 插入图块\r
- return;\r
- }\r
- \r
- // 设置图块大小\r
- let blkRef = new McDbBlockReference();\r
- blkRef.blockTableRecordId = blkrecId;\r
- let box = blkRef.getBoundingBox();\r
- if (box.ret) {\r
- let dLen = box.maxPt.distanceTo(box.minPt);\r
- if (dLen > 0.00001) {\r
- blkRef.setScale(mxcad.getMxDrawObject().screenCoordLong2Doc(100) / dLen);\r
- }\r
- }\r
- \r
- // 指定插入基点\r
- let getPoint = new MxCADUiPrPoint();\r
- getPoint.setMessage("\\指定插入基点");\r
- \r
- // 动态绘制图块\r
- getPoint.setUserDraw((v, worldDraw) => {\r
- blkRef.position = v;\r
- worldDraw.drawMcDbEntity(blkRef);\r
- });\r
- \r
- let pt = await getPoint.go();\r
- if (!pt) return;\r
- blkRef.position = pt;\r
- // 绘制图块\r
- let newBlkRefId = mxcad.drawEntity(blkRef);\r
- if (!newBlkRefId.isValid) {\r
- console.log("insert error");\r
- return;\r
- }\r
- };\r
- \r
- // 调用插入图块方法\r
- MxTest_InsertBlock();`},{type:"交互绘图",name:"绘制矩形",code:`import { IMcDbDwgFiler, McDbCustomEntity, McDbPolyline, McGePoint3d, McGePoint3dArray, MxCADUiPrPoint, MxCADWorldDraw, MxCpp } from "mxcad";\r
- \r
- // 新创建 McDbTestLineCustomEntity 类继承 McDbCustomEntity\r
- class McDbTestRectangle extends McDbCustomEntity {\r
- // 定义McDbTestLineCustomEntity内部的点对象 \r
- // 矩形角点pt1、pt2\r
- private pt1: McGePoint3d = new McGePoint3d();\r
- private pt2: McGePoint3d = new McGePoint3d();\r
- // 构造函数\r
- constructor(imp?: any) {\r
- super(imp);\r
- }\r
- // 创建函数\r
- public create(imp: any) {\r
- return new McDbTestRectangle(imp)\r
- }\r
- // 获取类名\r
- public getTypeName(): string {\r
- return "McDbTestRectangle";\r
- }\r
- // 读取自定义实体数据pt1、pt2\r
- public dwgInFields(filter: IMcDbDwgFiler): boolean {\r
- this.pt1 = filter.readPoint("pt1").val;\r
- this.pt2 = filter.readPoint("pt2").val;\r
- return true;\r
- }\r
- // 写入自定义实体数据pt1、pt2\r
- public dwgOutFields(filter: IMcDbDwgFiler): boolean {\r
- filter.writePoint("pt1", this.pt1);\r
- filter.writePoint("pt2", this.pt2);\r
- return true;\r
- }\r
- \r
- // 移动自定义对象的夹点\r
- public moveGripPointsAt(iIndex: number, dXOffset: number, dYOffset: number, dZOffset: number) {\r
- this.assertWrite();\r
- if (iIndex == 0) {\r
- this.pt1.x += dXOffset;\r
- this.pt1.y += dYOffset;\r
- this.pt1.z += dZOffset;\r
- }\r
- else if (iIndex == 1) {\r
- this.pt2.x += dXOffset;\r
- this.pt2.y += dYOffset;\r
- this.pt2.z += dZOffset;\r
- }\r
- };\r
- // 获取自定义对象的夹点\r
- public getGripPoints(): McGePoint3dArray {\r
- let ret = new McGePoint3dArray()\r
- ret.append(this.pt1);\r
- ret.append(this.pt2);\r
- return ret;\r
- };\r
- // 绘制实体\r
- public worldDraw(draw: MxCADWorldDraw): void {\r
- const pl = new McDbPolyline();\r
- pl.isClosed = true;\r
- pl.addVertexAt(this.pt1);\r
- pl.addVertexAt(new McGePoint3d(this.pt2.x, this.pt1.y));\r
- pl.addVertexAt(this.pt2);\r
- pl.addVertexAt(new McGePoint3d(this.pt1.x, this.pt2.y));\r
- draw.drawEntity(pl);\r
- }\r
- // 设置pt1\r
- public setPoint1(pt1: McGePoint3d) {\r
- this.assertWrite();\r
- this.pt1 = pt1.clone();\r
- }\r
- // 设置pt2\r
- public setPoint2(pt2: McGePoint3d) {\r
- this.assertWrite();\r
- this.pt2 = pt2.clone();\r
- }\r
- // 获取pt1\r
- public getPoint1() {\r
- return this.pt1;\r
- }\r
- // 获取pt2\r
- public getPoint2() {\r
- return this.pt2;\r
- }\r
- }\r
- \r
- \r
- async function MxTest_DrawCustomEntity() {\r
- let mxcad = MxCpp.getCurrentMxCAD();\r
- const getPoint = new MxCADUiPrPoint();\r
- getPoint.setMessage("\\n指定第一个角点:");\r
- let pt1 = await getPoint.go();\r
- if (!pt1) return;\r
- const myRect = new McDbTestRectangle();\r
- myRect.setPoint1(pt1);\r
- \r
- getPoint.setMessage("\\n指定第二个角点:");\r
- getPoint.setUserDraw((pt, pw) => {\r
- myRect.setPoint2(pt);\r
- pw.drawMcDbEntity(myRect);\r
- })\r
- let pt2 = await getPoint.go();\r
- if (!pt2) return;\r
- \r
- myRect.setPoint2(pt2);\r
- mxcad.drawEntity(myRect);\r
- }\r
- \r
- // 注册自定义实体\r
- new McDbTestRectangle().rxInit();\r
- // 调用方法绘制自定义实体\r
- MxTest_DrawCustomEntity();\r
- `},{type:"图纸数据库",name:"得到图纸所有对象",code:`import { McDbAlignedDimension, McDbArc, McDbBlockReference, McDbCircle, McDbDimension, McDbHatch, McDbLine, McDbMText, McDbPolyline, McDbRasterImage, McDbRotatedDimension, McDbText, MxCADSelectionSet } from "mxcad";\r
- \r
- \r
- // 点对象转字符串\r
- function McGePoint3dToString(pt): string {\r
- return "x=" + pt.x + ",y=" + pt.y + ",z=" + pt.z;\r
- }\r
- \r
- // 实体对象转json对象\r
- function McDbEntityToJsonObject(ent): object {\r
- let obj: any = {}\r
- obj.ObjectName = ent.objectName;// 对象名\r
- obj.id = ent.getObjectID().id;// 对象id\r
- obj.handle = ent.getHandle(); // 对象句柄\r
- obj.layer = ent.layer; // 对象所在图层\r
- obj.color = ent.trueColor.getColorString(); // 对象颜色说明字符串\r
- obj.colorVal = ent.trueColor.getColorValue(ent.layerId); // 对象颜色字符串\r
- obj.linetype = ent.linetype; // 对象线型\r
- obj.textStyle = ent.textStyle; // 对象文字样式\r
- obj.dxf0 = ent.dxf0;// 得到对象的DXF组码的类型名\r
- \r
- if (ent instanceof McDbText) {\r
- // 文字对象\r
- let txt = ent as McDbText;\r
- obj.position = McGePoint3dToString(txt.position);\r
- obj.textString = txt.textString;\r
- }\r
- else if (ent instanceof McDbMText) {\r
- // 多行文字对象\r
- let mtxt = ent as McDbMText;\r
- obj.contents = mtxt.contents;\r
- obj.location = McGePoint3dToString(mtxt.location);\r
- }\r
- else if (ent instanceof McDbLine) {\r
- // 直线对象\r
- let line = ent as McDbLine;\r
- obj.startPoint = McGePoint3dToString(line.startPoint);\r
- obj.endPoint = McGePoint3dToString(line.endPoint);\r
- }\r
- else if (ent instanceof McDbCircle) {\r
- // 圆对象\r
- let circle = ent as McDbCircle;\r
- obj.center = McGePoint3dToString(circle.center);\r
- obj.radius = circle.radius;\r
- }\r
- else if (ent instanceof McDbArc) {\r
- // 圆弧对象\r
- let arc = ent as McDbArc;\r
- obj.center = McGePoint3dToString(arc.center);\r
- obj.startAngle = arc.startAngle;\r
- obj.endAngle = arc.endAngle;\r
- }\r
- else if (ent instanceof McDbPolyline) {\r
- // 多段线对象\r
- let polyline = ent as McDbPolyline;\r
- let num = polyline.numVerts();\r
- obj.num = num;\r
- for (let i = 0; i < num; i++) {\r
- let pt = polyline.getPointAt(i);\r
- let bulge = polyline.getBulgeAt(i);\r
- obj["pt" + i] = McGePoint3dToString(pt.val);\r
- obj["bulge" + i] = bulge;\r
- }\r
- }\r
- else if (ent instanceof McDbBlockReference) {\r
- // 块引用对象\r
- let blkRef = ent as McDbBlockReference;\r
- obj.position = McGePoint3dToString(blkRef.position);\r
- obj.blockTransform = blkRef.blockTransform;\r
- obj.blockName = blkRef.blockName;\r
- }\r
- else if (ent instanceof McDbAlignedDimension) {\r
- // 对齐标注对象\r
- let alignedDim = ent as McDbAlignedDimension;\r
- obj.xLine1Point = McGePoint3dToString(alignedDim.xLine1Point);\r
- obj.xLine2Point = McGePoint3dToString(alignedDim.xLine2Point);\r
- let txts = alignedDim.GetAllText();\r
- txts.forEach((val, index) => {\r
- obj["txt:" + index] = val;\r
- });\r
- }\r
- else if (ent instanceof McDbRotatedDimension) {\r
- // 旋转标注对象\r
- let rotatedDim = ent as McDbRotatedDimension;\r
- obj.xLine1Point = McGePoint3dToString(rotatedDim.xLine1Point);\r
- obj.xLine2Point = McGePoint3dToString(rotatedDim.xLine2Point);\r
- let txts = rotatedDim.GetAllText();\r
- txts.forEach((val, index) => {\r
- obj["txt:" + index] = val;\r
- });\r
- }\r
- else if (ent instanceof McDbDimension) {\r
- // 标注对象\r
- let dim = ent as McDbDimension;\r
- let txts = dim.GetAllText();\r
- txts.forEach((val, index) => {\r
- obj["txt:" + index] = val;\r
- });\r
- }\r
- else if (ent instanceof McDbHatch) {\r
- // 填充对象\r
- let hatch = ent as McDbHatch;\r
- obj.patternType = hatch.patternType();\r
- obj.patternName = hatch.patternName();\r
- obj.patternAngle = hatch.patternAngle;\r
- obj.patternScale = hatch.patternScale;\r
- obj.patternSpace = hatch.patternSpace;\r
- obj.patternDouble = hatch.patternDouble;\r
- obj.hatchStyle = hatch.hatchStyle();\r
- obj.isSolid = hatch.isSolid();\r
- obj.numLoops = hatch.numLoops;\r
- for (let i = 0; i < obj.numLoops; i++) {\r
- let loop: any = hatch.getLoopAt(i);\r
- loop.vertices.forEach((val: any, inidex: number) => {\r
- loop["pt:" + inidex] = {};\r
- loop["pt:" + inidex].x = val.x;\r
- loop["pt:" + inidex].y = val.y;\r
- loop["pt:" + inidex].z = val.z;\r
- })\r
- obj["loop:" + i] = loop;\r
- };\r
- obj.numPatternDefinitions = hatch.numPatternDefinitions;\r
- for (let i = 0; i < obj.numPatternDefinitions; i++) {\r
- obj["patternDefinitions:" + i] = hatch.getPatternDefinitionAt(i);\r
- };\r
- }\r
- else if (ent instanceof McDbRasterImage) {\r
- // 位图对象\r
- let image = ent as McDbRasterImage;\r
- let orientation = image.getOrientation();\r
- obj.orientation = {};\r
- obj.orientation.origin = orientation.origin.toVector3();\r
- obj.orientation.uCorner = orientation.uCorner.toVector3();\r
- obj.orientation.vOnPlane = orientation.vOnPlane.toVector3();\r
- \r
- let clipBoundary = image.clipBoundary();\r
- obj.clipBoundary = {};\r
- clipBoundary.forEach((pt, index) => {\r
- obj.clipBoundary["pt" + index] = pt.toVector3();\r
- });\r
- \r
- obj.clipBoundaryType = image.clipBoundaryType();\r
- \r
- let imageDef = image.imageDefId().getMcDbRasterImageDef();\r
- if (imageDef) {\r
- obj.filePath = imageDef.sourceFileName;\r
- }\r
- }\r
- \r
- return obj;\r
- }\r
- // 得到图纸所有对象\r
- async function TestGetAllEntity() {\r
- \r
- let ss = new MxCADSelectionSet();\r
- ss.allSelect();\r
- ss.forEach((id) => {\r
- let ent: any = id.getMcDbEntity();\r
- if (!ent) return;\r
- ent = McDbEntityToJsonObject(ent);\r
- console.log(JSON.stringify(ent));\r
- })\r
- };\r
- \r
- // 调用得到图纸所有对象的方法\r
- TestGetAllEntity()`},{type:"图纸数据库",name:"添加图层",code:`import { McDbLayerTableRecord, MxCpp } from "mxcad";\r
- \r
- // 添加图层\r
- function MxTest_AddLayer() {\r
- // 获取当前mxcad对象\r
- let mxcad = MxCpp.App.getCurrentMxCAD();\r
- \r
- // 获取数据库图层表\r
- let layerTable = mxcad.getDatabase().getLayerTable();\r
- // 判断图层表中是否存在xxx11图层\r
- if (!layerTable.has("xxx11")) {\r
- // 不存在则创建xxx11图层\r
- let newLayer = new McDbLayerTableRecord();\r
- newLayer.name = "xxx11";\r
- layerTable.add(newLayer);\r
- }\r
- \r
- if (layerTable.has("xxx11")) {\r
- // 存在则打印日志\r
- console.log("add layer ok");\r
- }\r
- };\r
- \r
- // 调用添加图层的方法\r
- MxTest_AddLayer(); `},{type:"图纸数据库",name:"得到图纸所有图块",code:`import { MxCpp } from "mxcad";\r
- \r
- function MxTest_GetAllBlock() {\r
- // 获取当前mxcad对象\r
- let mxcad = MxCpp.App.getCurrentMxCAD();\r
- // 获取数据库块表\r
- let blockTable = mxcad.getDatabase().getBlockTable();\r
- // 获取所有块表记录的id数组\r
- let aryId = blockTable.getAllRecordId();\r
- // 遍历所有块表记录\r
- aryId.forEach((id) => {\r
- let blkRec = id.getMcDbBlockTableRecord();\r
- if (blkRec === null) return;\r
- console.log(blkRec);\r
- console.log("blkRec.name:" + blkRec.name);\r
- console.log("blkRec.origin:" + blkRec.origin);\r
- });\r
- };\r
- \r
- // 调用获取所有图块的方法\r
- MxTest_GetAllBlock();\r
- `},{type:"图纸数据库",name:"得到图纸所有图层",code:`import { MxCpp } from "mxcad";\r
- import { MxFun } from "mxdraw";\r
- \r
- // 获取所有图层\r
- function MxTest_GetAllLayer() {\r
- // 获取当前mxcad对象\r
- let mxcad = MxCpp.App.getCurrentMxCAD();\r
- // 获取图层表\r
- let layerTable = mxcad.getDatabase().getLayerTable();\r
- // 获取所有记录id\r
- let aryId = layerTable.getAllRecordId();\r
- let ret = [];\r
- // 遍历图层id\r
- aryId.forEach((id) => {\r
- let layerRec = id.getMcDbLayerTableRecord();\r
- if (layerRec === null) return;\r
- \r
- console.log(layerRec);\r
- console.log("layerRec.color:" + layerRec.color.getColorString());\r
- console.log("layerRec.name:" + layerRec.name);\r
- let layer: any = {};\r
- layer.name = layerRec.name;\r
- \r
- layer.color = layerRec.color.getColorString();\r
- ret.push(layer);\r
- });\r
- \r
- MxFun.postMessageToParentFrame(ret);\r
- return ret;\r
- };\r
- \r
- // 调用获取所有图层的方法\r
- MxTest_GetAllLayer();`},{type:"图纸数据库",name:"得到图纸所有线型样式",code:`import { MxCpp } from "mxcad"\r
- \r
- // 获取所有线型样式\r
- function MxTest_GetAllLinetype() {\r
- // 获取当前mxcad对象\r
- let mxobj = MxCpp.getCurrentMxCAD();\r
- // 获取数据库线型样式表\r
- let linetypeTable = mxobj.getDatabase().getLinetypeTable();\r
- // 获取所有线型记录的ID数组\r
- let aryId = linetypeTable.getAllRecordId();\r
- // 遍历线型记录\r
- aryId.forEach((id) => {\r
- let linetypeRec = id.getMcDbLinetypeTableRecord();\r
- if (linetypeRec === null) return;\r
- console.log(linetypeRec);\r
- });\r
- };\r
- \r
- // 调用获取所有线型样式\r
- MxTest_GetAllLinetype()`},{type:"图纸数据库",name:"得到图纸所有文字样式",code:`import { MxCpp } from "mxcad";\r
- \r
- // 获取所有文字样式\r
- function MxTest_GetAllTextStyle() {\r
- // 获取当前mxcad对象\r
- let mxobj = MxCpp.getCurrentMxCAD();\r
- // 获取文字样式表\r
- let textSyleTable = mxobj.getDatabase().getTextStyleTable();\r
- // 获取文字样式表记录id数组\r
- let aryId = textSyleTable.getAllRecordId();\r
- // 遍历文字样式表记录\r
- aryId.forEach((id) => {\r
- let textSyleRec = id.getMcDbTextStyleTableRecord();\r
- if (textSyleRec === null) return;\r
- let out: any = {};\r
- out.name = textSyleRec.name;\r
- out.font = textSyleRec.font();\r
- out.fileName = textSyleRec.fileName;\r
- out.bigFontFileName = textSyleRec.bigFontFileName;\r
- out.textSize = textSyleRec.textSize;\r
- out.xScale = textSyleRec.xScale;\r
- console.log(out);\r
- });\r
- };\r
- \r
- // 调用获取所有文字样式的方法\r
- MxTest_GetAllTextStyle();\r
- `},{type:"图纸数据库",name:"读扩展数据",code:`import { MxCADUiPrEntity } from "mxcad";\r
- \r
- // 读取扩展数据。\r
- async function MxTest_ReadxData() {\r
- // 选择对象\r
- let selEntity = new MxCADUiPrEntity();\r
- selEntity.setMessage("选择对象");\r
- let id = await selEntity.go();\r
- if (!id.isValid()) return;\r
- \r
- // 获取对象\r
- let ent = id.getMcDbEntity();\r
- if (ent === null) return; \r
- \r
- // 得到对象的扩展数据\r
- let data = ent.getxData();\r
- //data.PrintData();\r
- data.forEach((val, type, dxf) => {\r
- console.log(JSON.stringify({ val: val, type: type, dxf: dxf }));\r
- })\r
- \r
- //let data = ent.getxDataString("DataName");\r
- //MxFun.acutPrintf(data.val + "\\n");\r
- };\r
- \r
- // 调用读取扩展数据的方法\r
- MxTest_ReadxData()`},{type:"图纸数据库",name:"写入扩展数据",code:`import { MxCADUiPrEntity } from "mxcad";\r
- \r
- // 写扩展数据\r
- async function MxTest_WritexData() {\r
- // 选择对象\r
- let selEntity = new MxCADUiPrEntity();\r
- selEntity.setMessage("选择对象");\r
- let id = await selEntity.go();\r
- if (!id.isValid()) return;\r
- \r
- // 获取对象\r
- let ent = id.getMcDbEntity();\r
- if (ent === null) return;\r
- // 写扩展数据\r
- ent.setxDataString("DataName", "xxxxx");\r
- //ent.setxData(new MxCADResbuf([{type:MxCADResbufDataType.kExDataName,val:"DataName"},{type:MxCADResbufDataType.kString,val:"yyyyy"}]));\r
- };\r
- \r
- // 调用写扩展数据的方法\r
- MxTest_WritexData();\r
- \r
- `},{type:"图纸数据库",name:"得到命名字典",code:`import { MxCpp, McDbDictionary, McDbXrecord } from "mxcad";\r
- \r
- // 字典数据遍历\r
- function MxTest_DictionaryData(dict) {\r
- let aryName = dict.getAllObjectName();\r
- aryName.forEach((name) => {\r
- console.log(name);\r
- let id = dict.getAt(name);\r
- let obj = id.getMcDbObject();\r
- if (obj instanceof McDbDictionary) {\r
- let dict = obj as McDbDictionary;\r
- console.log(dict);\r
- MxTest_DictionaryData(dict);\r
- }\r
- else if (obj instanceof McDbXrecord) {\r
- let xrec = obj as McDbXrecord;\r
- let data = xrec.getData()\r
- data.PrintData();\r
- }\r
- })\r
- }\r
- \r
- // 得到命名字典\r
- async function MxTest_GetNamedObjectsDictionary() {\r
- let mxcad = MxCpp.getCurrentMxCAD();\r
- let dict = mxcad.getDatabase().getNamedObjectsDictionary();\r
- let aryName = dict.getAllObjectName();\r
- aryName.forEach((name) => {\r
- console.log(name);\r
- let id = dict.getAt(name);\r
- let obj = id.getMcDbObject();\r
- if (obj instanceof McDbDictionary) {\r
- let dict = obj as McDbDictionary;\r
- console.log(dict);\r
- MxTest_DictionaryData(dict);\r
- }\r
- })\r
- }\r
- \r
- // 调用得到命名字典方法\r
- MxTest_GetNamedObjectsDictionary()`}];function WR(e,t,i){const c=e.distanceTo(t)/2,h=c*i,f=(c*c+h*h)/(2*h),r=(e.x+t.x)/2,v=(e.y+t.y)/2;return new M.McGePoint3d(r,v).addvec(t.clone().sub(e).perpVector().normalize().mult(f-h))}function jR(e,t,i){const l=Math.PI*2/360;let c=Math.atan2(t.y-e.y,t.x-e.x)*180/Math.PI*l,h=Math.atan2(i.y-e.y,i.x-e.x)*180/Math.PI*l;return{startAngle:c,endAngle:h}}X.MxFun.addCommand("list",()=>Qe(this,null,function*(){const e=yield M.MxCADUtility.userSelect("选择对象"),t=new M.MxCADUiPrPoint;X.MxFun.acutPrintf("找到"+e.length+`个
- `);const i=e.pop();if(!i)return;const l=i.getMcDbEntity();if(!i.isValid()||!l)X.MxFun.acutPrintf(`对象无效
- `);else if((yield db(l))===!1)return;for(;e.length;){if(t.setMessage("按 ENTER 键继续"),t.setDisableDynInput(!0),yield t.go(),t.getDetailedResult()===X.DetailedResult.kCodeAbort||t.getDetailedResult()===X.DetailedResult.kEcsIn||t.getDetailedResult()===X.DetailedResult.kNewCommadIn)return;const c=e.pop();if(!c)break;const h=c.getMcDbEntity();if(!c.isValid()||!h){X.MxFun.acutPrintf(`对象无效
- `);continue}if((yield db(h))===!1)return}}));const HR={McDbPoint:"点",McDbLine:"直线",McDbPolyline:"多段线",McDbArc:"圆弧",McDbCircle:"圆",McDbEllipse:"椭圆",McDbHatch:"填充",McDbText:"单行文本",McDbMText:"多行文本",McDbRasterImage:"光栅图片",McDbBlockReference:"块参照"},ub={Top:"上",Middle:"中",Bottom:"下",Base:"基",Left:"左",Center:"中",Right:"右",Align:"对齐",Fit:"适应",Mid:"中"},hb=e=>e.replace(/k(\w+)/g,function(t,i){return i.replace(/([A-Z])/g,"-$1").split("-").reduce((f,r)=>ub[r]?f+ub[r]:"")});function db(e){return Qe(this,null,function*(){const t=e.layer,c=M.MxCpp.getCurrentDatabase().currentSpace.name==="*Model_Space"?"模型空间":"图纸空间",h=e.getHandle();console.log(e.objectName);let f=HR[e.objectName]||e.objectName;if(e instanceof M.McDbDimension&&(f="标注"),X.MxFun.acutPrintf(`
- ${f} 图层: "${t}"`),X.MxFun.acutPrintf(`
- 空间: "${c}"`),X.MxFun.acutPrintf(`
- 句柄 = ${h}`),e instanceof M.McDbPoint&&X.MxFun.acutPrintf(`
- 于 点, X= ${e.position.x.toFixed(4)} Y= ${e.position.y.toFixed(4)} Z= ${e.position.z.toFixed(4)}`),e instanceof M.McDbLine){X.MxFun.acutPrintf(`
- 自 点, X= ${e.startPoint.x.toFixed(4)} Y= ${e.startPoint.y.toFixed(4)} Z= ${e.startPoint.z.toFixed(4)}`),X.MxFun.acutPrintf(`
- 到 点, X= ${e.startPoint.x.toFixed(4)} Y= ${e.startPoint.y.toFixed(4)} Z= ${e.startPoint.z.toFixed(4)}`);let r=e.endPoint.x-e.startPoint.x,v=e.endPoint.y-e.startPoint.y,x=e.endPoint.z-e.startPoint.z,w=THREE.MathUtils.radToDeg(Math.atan2(v,r));X.MxFun.acutPrintf(`
- 长度 = ${e.getLength().val.toFixed(4)},在 XY 平面中的角度 = ${Math.floor(w)}`),X.MxFun.acutPrintf(`
- 增量 X = ${r.toFixed(4)},增量 Y = ${v.toFixed(4)},增量 Z = ${x.toFixed(4)}`)}if(e instanceof M.McDbPolyline){X.MxFun.acutPrintf(`
- ${e.isClosed?"闭合":"打开"}`),X.MxFun.acutPrintf(`
- 固定宽度 ${e.constantWidth.toFixed(4)}`),X.MxFun.acutPrintf(`
- 面积 ${e.getArea().val.toFixed(4)}`),X.MxFun.acutPrintf(`
- 周长 ${e.getLength().val.toFixed(4)}`);const r=e.numVerts(),v=new M.MxCADUiPrPoint,x=[],w=[];let b=!1;for(let P=0;P<r;P++){const R=e.getWidthsAt(P),F=e.getBulgeAt(P);(R.val1!==0||R.val2!==0)&&(b=!0),x.push(R),w.push(F)}let A=0;const L=3;for(let P=0;P<r;P++){if(A>L)for(;;){v.setMessage("按 ENTER 键继续"),v.disableAllTrace(),v.clearLastInputPoint(),v.setDynamicInputType(X.DynamicInputType.kNoInput);const V=yield v.go();if(v.getDetailedResult()===X.DetailedResult.kCodeAbort||v.getDetailedResult()===X.DetailedResult.kEcsIn)return;if(v.getDetailedResult()===X.DetailedResult.kNewCommadIn)return!1;if(v.getDetailedResult()===X.DetailedResult.kNullEnterIn||v.getDetailedResult()===X.DetailedResult.kNullSpaceIn||V){A=0;break}}const R=e.getPointAt(P).val,F=w[P];if(X.MxFun.acutPrintf(`
- 于端点 X= ${R.x.toFixed(1)} Y= ${R.y.toFixed(1)} Z= ${R.z.toFixed(1)}`),b&&(X.MxFun.acutPrintf(`
- 起点宽度 ${x[P].val1.toFixed(4)}`),X.MxFun.acutPrintf(`
- 端点宽度 ${x[P].val2.toFixed(4)}`)),Math.abs(F)>0){X.MxFun.acutPrintf(`
- 凸度 ${F.toFixed(1)}`);const V=e.getPointAt(P+1).val,j=WR(R,V,F);X.MxFun.acutPrintf(`
- 圆心 X= ${j.x.toFixed(1)} Y= ${j.y.toFixed(1)} Z= ${j.z.toFixed(1)}`),X.MxFun.acutPrintf(`
- 半径 ${j.distanceTo(R).toFixed(1)}`);const{startAngle:J,endAngle:ne}=jR(j,R,V);X.MxFun.acutPrintf(`
- 起点角度 ${THREE.MathUtils.radToDeg(J).toFixed(0)}`),X.MxFun.acutPrintf(`
- 端点角度 ${THREE.MathUtils.radToDeg(ne).toFixed(0)}`),P===r-1&&X.MxFun.acutPrintf(`
- 于端点 X= ${V.x.toFixed(1)} Y= ${V.y.toFixed(1)} Z= ${V.z.toFixed(1)}`)}A++}}if(e instanceof M.McDbArc&&(X.MxFun.acutPrintf(`
- 圆心 点, X= ${e.center.x.toFixed(4)} Y= ${e.center.y.toFixed(4)} Z= ${e.center.z.toFixed(4)}`),X.MxFun.acutPrintf(`
- 半径 ${e.radius.toFixed(4)}`),X.MxFun.acutPrintf(`
- 起点 角度 ${THREE.MathUtils.radToDeg(e.startAngle).toFixed(0)}`),X.MxFun.acutPrintf(`
- 端点 角度 ${THREE.MathUtils.radToDeg(e.endAngle).toFixed(0)}`),X.MxFun.acutPrintf(`
- 长度 ${e.getLength().val.toFixed(4)}`)),e instanceof M.McDbCircle&&(X.MxFun.acutPrintf(`
- 圆心 点, X= ${e.center.x.toFixed(4)} Y= ${e.center.y.toFixed(4)} Z= ${e.center.z.toFixed(4)}`),X.MxFun.acutPrintf(`
- 半径 ${e.radius.toFixed(4)}`),X.MxFun.acutPrintf(`
- 周长 ${e.getLength().val.toFixed(4)}`),X.MxFun.acutPrintf(`
- 面积 ${(Math.PI*e.radius*e.radius).toFixed(4)}`)),e instanceof M.McDbEllipse){const r=e.majorAxis.length(),v=e.minorAxis.length(),x=e.startAngle===0&&e.endAngle===2*Math.PI;if(x){const L=(P,R)=>{const F=Math.pow(P-R,2)/Math.pow(P+R,R);return Math.PI*(P+R)*(1+3*F/(10+Math.sqrt(4-3*F)))};X.MxFun.acutPrintf(`
- 面积: ${(Math.PI*r*v).toFixed(4)}`),X.MxFun.acutPrintf(`
- 圆周: ${L(r,v).toFixed(4)}`)}else{const L=(P,R,F,V,j)=>{const J=function(Q){return Math.sqrt(P*P*Math.sin(Q)*Math.sin(Q)+R*R*Math.cos(Q)*Math.cos(Q))};let ne=0;const H=(V-F)/j;for(let Q=0;Q<=j;Q++){const ae=F+Q*H;Q===0||Q===j?ne+=J(ae):Q%2===0?ne+=2*J(ae):ne+=4*J(ae)}return ne*=H/3,Math.abs(ne)};X.MxFun.acutPrintf(`
- 长度: ${L(r,v,e.startAngle,e.endAngle,30).toFixed(4)}`)}X.MxFun.acutPrintf(`
- 中心点: X = ${e.center.x.toFixed(4)} , Y = ${e.center.y.toFixed(4)} , Z = ${e.center.z.toFixed(4)}`);const w=r>v,b=w?e.majorAxis:e.minorAxis,A=w?e.minorAxis:e.majorAxis;if(X.MxFun.acutPrintf(`
- 长轴: X = ${b.x.toFixed(4)} , Y = ${b.y.toFixed(4)} , Z = ${b.z.toFixed(4)}`),X.MxFun.acutPrintf(`
- 短轴: X = ${A.x.toFixed(4)} , Y = ${A.y.toFixed(4)} , Z = ${A.z.toFixed(4)}`),!x){const L=(F,V,j,J,ne)=>{const H=F.x,Q=F.y,ae=V.x,ie=V.y,le=j.x,fe=j.y,me=Math.atan2(ie,ae),he=Math.sqrt(ae*ae+ie*ie),Oe=Math.sqrt(le*le+fe*fe),Ve=H+he*Math.cos(J)*Math.cos(me)-Oe*Math.sin(J)*Math.sin(me),He=Q+he*Math.cos(J)*Math.sin(me)+Oe*Math.sin(J)*Math.cos(me),at=H+he*Math.cos(ne)*Math.cos(me)-Oe*Math.sin(ne)*Math.sin(me),At=Q+he*Math.cos(ne)*Math.sin(me)+Oe*Math.sin(ne)*Math.cos(me);return{startPoint:new M.McGePoint3d(Ve,He),endPoint:new M.McGePoint3d(at,At)}},{startPoint:P,endPoint:R}=L(e.center,e.majorAxis,e.minorAxis,e.startAngle,e.endAngle);X.MxFun.acutPrintf(`
- 起点: X = ${P.x.toFixed(4)} , Y = ${P.y.toFixed(4)} , Z = ${P.z.toFixed(4)}`),X.MxFun.acutPrintf(`
- 端点: X = ${R.x.toFixed(4)} , Y = ${R.y.toFixed(4)} , Z = ${R.z.toFixed(4)}`),X.MxFun.acutPrintf(`
- 起点角度: ${THREE.MathUtils.radToDeg(e.startAngle).toFixed(0)}`),X.MxFun.acutPrintf(`
- 端点角度: ${THREE.MathUtils.radToDeg(e.endAngle).toFixed(0)}`)}X.MxFun.acutPrintf(`
- 半径比例: ${e.radiusRatio.toFixed(4)}`)}if(e instanceof M.McDbHatch){const r=e.patternName();X.MxFun.acutPrintf(`
- 填充图案 ${r}`),X.MxFun.acutPrintf(`
- 图案填充比例 ${e.patternScale.toFixed(4)}`),X.MxFun.acutPrintf(`
- 图案填充角度 ${THREE.MathUtils.radToDeg(e.patternAngle).toFixed(0)}`);const v=new M.McDbPolyline,x=[];v.isClosed=!0;for(let b=0;b<e.numLoops;b++){const{vertices:A,bulges:L}=e.getLoopAt(b);A.forEach((P,R)=>{const F=L[R];v.addVertexAt(P,Number(F.toFixed(14)))}),x.push(v),M.MxCpp.getCurrentMxCAD().drawEntity(v)}const w=x.reduce((b,A)=>b+A.getArea().val,0);X.MxFun.acutPrintf(`
- 面积 ${w.toFixed(4)}`)}if(e instanceof M.McDbText&&(X.MxFun.acutPrintf(`
- 样式 = "${e.textStyle}"`),X.MxFun.acutPrintf(`
- 起点 点, X= ${e.position.x.toFixed(4)} Y= ${e.position.y.toFixed(4)} Z= ${e.position.z.toFixed(4)}`),X.MxFun.acutPrintf(`
- 高度 ${e.height.toFixed(4)}`),X.MxFun.acutPrintf(`
- 文字 ${e.textString}`),X.MxFun.acutPrintf(`
- 旋转 角度 ${e.rotation.toFixed(0)}`),X.MxFun.acutPrintf(`
- 宽度 比例因子 ${e.widthFactor.toFixed(4)}`)),e instanceof M.McDbMText&&(X.MxFun.acutPrintf(`
- 样式 = "${e.textStyle}"`),X.MxFun.acutPrintf(`
- 位置: X= ${e.location.x.toFixed(4)} Y= ${e.location.y.toFixed(4)} Z= ${e.location.z.toFixed(4)}`),X.MxFun.acutPrintf(`
- 宽度: ${e.width.toFixed(4)}`),X.MxFun.acutPrintf(`
- 法向: X= ${e.normal.x.toFixed(4)} Y= ${e.normal.y.toFixed(4)} Z= ${e.normal.z.toFixed(4)}`),X.MxFun.acutPrintf(`
- 旋转: ${e.rotation.toFixed(0)}`),X.MxFun.acutPrintf(`
- 文字高度: ${e.textHeight.toFixed(4)}`),X.MxFun.acutPrintf(`
- 附着: ${hb(M.McDb.AttachmentPoint[e.attachment])}`),X.MxFun.acutPrintf(`
- 内容: ${e.contents}`)),e instanceof M.McDbRasterImage){const r=e.imageDefId().getMcDbRasterImageDef(),v=b=>b.split("/").pop().split("\\").pop();X.MxFun.acutPrintf(`
- 图像: ${v(r.sourceFileName)}`);const x=b=>{const A=b.clipBoundaryType();if(A===M.McDb.ClipBoundaryType.kInvalid)return"无效";if(A===M.McDb.ClipBoundaryType.kPoly)return"多边形";if(A===M.McDb.ClipBoundaryType.kRect)return"矩形"};X.MxFun.acutPrintf(`
- 剪裁边界类型: ${x(e)}`);const w=e.clipBoundary();X.MxFun.acutPrintf(`
- 边界点数目: ${w.length()}`),e.clipBoundary().forEach(b=>{X.MxFun.acutPrintf(`
- 位于点,X= ${b.x.toFixed(4)}, Y= ${b.y.toFixed(4)}, Z= ${b.z.toFixed(4)}`)})}if(e instanceof M.McDbBlockReference&&(X.MxFun.acutPrintf(`
- 块名: "${e.blockName}"`),X.MxFun.acutPrintf(`
- 插入点: X= ${e.position.x.toFixed(4)}, Y= ${e.position.y.toFixed(4)}, Z= ${e.position.z.toFixed(4)}`),X.MxFun.acutPrintf(`
- X 比例因子: ${e.scaleFactors.x.toFixed(4)}`),X.MxFun.acutPrintf(`
- Y 比例因子: ${e.scaleFactors.y.toFixed(4)}`),X.MxFun.acutPrintf(`
- 旋转角度: ${e.rotation.toFixed(0)}`),X.MxFun.acutPrintf(`
- Z 比例因子: ${e.scaleFactors.z.toFixed(4)}`),X.MxFun.acutPrintf(`
- Z 比例因子: ${e.scaleFactors.z.toFixed(4)}`),X.MxFun.acutPrintf(`
- 缩放比例: ${e.getScale().toFixed(4)}`)),e instanceof M.McDbDimension){X.MxFun.acutPrintf(`
- 文字位置: X= ${e.textPosition.x.toFixed(4)} Y= ${e.textPosition.y.toFixed(4)} Z= ${e.textPosition.z.toFixed(4)}`),X.MxFun.acutPrintf(`
- 是否使用的默认文字位置: ${e.isUsingDefaultTextPosition()}`),X.MxFun.acutPrintf(`
- 高度: ${e.elevation.toFixed(4)}`),X.MxFun.acutPrintf(`
- 文本内容: ${e.dimensionText}`),X.MxFun.acutPrintf(`
- 文本旋转角度: ${THREE.MathUtils.radToDeg(e.textRotation).toFixed(0)}`);const r=e.dimensionStyle.getMcDbDimStyleTableRecord();X.MxFun.acutPrintf(`
- 标注样式: ${r.name}`),X.MxFun.acutPrintf(`
- 文字附着: ${hb(M.McDb.AttachmentPoint[e.textAttachment])}`),X.MxFun.acutPrintf(`
- 水平旋转角度: ${THREE.MathUtils.radToDeg(e.horizontalRotation).toFixed(0)}`),X.MxFun.acutPrintf(`
- 水平旋转角度: ${THREE.MathUtils.radToDeg(e.horizontalRotation).toFixed(0)}`)}X.MxFun.acutPrintf(`
- 命令`)})}X.MxFun.addCommand("group",()=>Qe(this,null,function*(){let e,t="",i="",l;const c=M.MxCpp.getCurrentDatabase(),h=c.GetGroupDictionary();for(;;){const f=yield M.MxCADUtility.userSelect("选择对象",null,(r,v)=>{v.setKeyWords("[名称(N)/说明(D)]"),e=v});if(e.getDetailedResult()===X.DetailedResult.kEcsIn||e.getDetailedResult()===X.DetailedResult.kCodeAbort||e.getDetailedResult()===X.DetailedResult.kNewCommadIn)return;if(f&&(l=f),e.isKeyWordPicked("N")){for(;;){const r=new M.MxCADUiPrString;r.setMessage("输入编组名"),r.setKeyWords("[查询(A)]");const v=yield r.go();if(r.getDetailedResult()===X.DetailedResult.kCodeAbort||r.getDetailedResult()===X.DetailedResult.kEcsIn||r.getDetailedResult()===X.DetailedResult.kNewCommadIn)return;if(r.isKeyWordPicked("A")){r.setMessage("请输入要列出的编码组名<*>"),r.setKeyWords("");const b=yield r.go();if(console.log(b),r.getDetailedResult()===X.DetailedResult.kCodeAbort||r.getDetailedResult()===X.DetailedResult.kEcsIn||r.getDetailedResult()===X.DetailedResult.kNewCommadIn)return;if(b&&b!=="*"){const L=h.getAt(b).getMcDbObject();X.MxFun.acutPrintf(`
- 定义的编组:`),L&&X.MxFun.acutPrintf(`
- ${L.name}`)}else if(b==="*"||r.getDetailedResult()===X.DetailedResult.kNullEnterIn||r.getDetailedResult()===X.DetailedResult.kNullSpaceIn){const A=h.getAllObject();X.MxFun.acutPrintf(`
- 定义的编组:`),A.forEach(L=>{const P=L.getMcDbObject();P&&X.MxFun.acutPrintf(`
- ${P.name}`)})}continue}if(!v)return;const x=h.getAt(t);if(x.getMcDbObject()&&x.isValid()){X.MxFun.acutPrintf(`编组 ${t} 已经存在`);continue}t=v;break}continue}if(e.isKeyWordPicked("D")){const r=new M.MxCADUiPrString;r.setMessage("输入编组说明");const v=yield r.go();if(!v)return;i=v;continue}if(e.getDetailedResult()===X.DetailedResult.kNullEnterIn||e.getDetailedResult()===X.DetailedResult.kNullSpaceIn){if(l.some(v=>c.getEntitiesInTheGroup(v).length!==0)){const v=new M.MxCADUiPrKeyWord;v.setMessage("包含相同对象的组已经存在。仍要创建新的组?<N>"),v.setKeyWords("[是(Y)/否(N)]");const x=yield v.go();if((x==null?void 0:x.toLocaleUpperCase())==="N"||!x)return}if(c.CreateGroup(l,t)){const x=h.getAt(t).getMcDbObject();x.description=i}}break}})),X.MxFun.addCommand("ungroup",()=>Qe(this,null,function*(){let e;const i=M.MxCpp.getCurrentDatabase().GetGroupDictionary();for(;;){const l=new M.MxCADUiPrEntity;l.setMessage("选择对象"),l.setKeyWords("[名称(N)]");const c=yield l.go();if(l.getDetailedResult()===X.DetailedResult.kEcsIn||l.getDetailedResult()===X.DetailedResult.kCodeAbort||l.getDetailedResult()===X.DetailedResult.kNewCommadIn)return;if(l.isKeyWordPicked("N")){for(;;){const h=new M.MxCADUiPrString;h.setMessage("输入编组名"),h.setKeyWords("[查询(A)]");const f=yield h.go();if(h.getDetailedResult()===X.DetailedResult.kCodeAbort||h.getDetailedResult()===X.DetailedResult.kEcsIn||h.getDetailedResult()===X.DetailedResult.kNewCommadIn)return;if(h.isKeyWordPicked("A")){h.setMessage("请输入要列出的编码组名<*>"),h.setKeyWords("");const x=yield h.go();if(h.getDetailedResult()===X.DetailedResult.kCodeAbort||h.getDetailedResult()===X.DetailedResult.kEcsIn||h.getDetailedResult()===X.DetailedResult.kNewCommadIn)return;if(x&&x!=="*"){const b=i.getAt(x).getMcDbObject();X.MxFun.acutPrintf(`
- 定义的编组:`),b&&X.MxFun.acutPrintf(`
- ${b.name}`)}else if(x==="*"||h.getDetailedResult()===X.DetailedResult.kNullEnterIn||h.getDetailedResult()===X.DetailedResult.kNullSpaceIn){const w=i.getAllObject();X.MxFun.acutPrintf(`
- 定义的编组:`),w.forEach(b=>{const A=b.getMcDbObject();A&&X.MxFun.acutPrintf(`
- ${A.name}`)})}continue}if(!f)return;const r=i.getAt(e);if(r.getMcDbObject()&&r.isValid()){X.MxFun.acutPrintf(`编组 ${e} 已经存在`);continue}e=f;break}continue}if(c){const h=c.getMcDbEntity();if(h){const f=h.getHandle(),r=i.getAllObjectName(),v=r.length();for(let x=0;x<v;x++){const w=r.at(x),A=i.getAt(w).getMcDbObject();if(!A)continue;A.getAllEntityId().some(P=>{const R=P.getMcDbEntity();return(R==null?void 0:R.getHandle())===f?(e=w,!0):!1})}}}if(e){const f=i.getAt(e).getMcDbObject();if(f)f.clear(),i.remove(e),X.MxFun.acutPrintf(`
- 组 ${e} 已分解`);else{X.MxFun.acutPrintf(`
- 对象不是组成员`);continue}}else{X.MxFun.acutPrintf(`
- 对象不是组成员`);continue}break}}));const $R=`///////////////////////////////////////////////////////////////////////////////
- //版权所有(C)2002-2022,成都梦想凯德科技有限公司。
- //本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明
- //此应用程序应与成都梦想凯德科技有限公司达成协议,使用本软件、其文档或相关材料
- //https://www.mxdraw.com/
- ///////////////////////////////////////////////////////////////////////////////
- import { McDbEntity, McDbLine, McDbPoint, McDbPolyline, MxCADUiPrPoint, MxCADUtility, MxCpp, McGePoint3d, McDbArc, McDbCircle, McDbEllipse, McGeVector3d, McDbHatch, McDbText, McDbMText, McDb, McDbRasterImageDef, McDbRasterImage, McDbBlockReference, McDbDimension } from "mxcad";
- import { DetailedResult, DynamicInputType, MxDbRegularPolygonShape, MxFun } from "mxdraw";
- function calculateCenter(start: McGePoint3d, end: McGePoint3d, bulge: number) {
- const dist = start.distanceTo(end)
- const dx = dist / 2
- const dy = dx * bulge
- const r = (dx * dx + dy * dy) / (2 * dy)
- const midX = (start.x + end.x) / 2
- const midY = (start.y + end.y) / 2
- return new McGePoint3d(midX, midY).addvec(end.clone().sub(start).perpVector().normalize().mult(r - dy))
- }
- function calculateLineAngle(center: McGePoint3d, start: McGePoint3d, end: McGePoint3d) {
- const deg = (Math.PI * 2) / 360
- // 计算直线的角度
- let startAngle = ((Math.atan2(start.y - center.y, start.x - center.x) * 180) / Math.PI) * deg
- let endAngle = ((Math.atan2(end.y - center.y, end.x - center.x) * 180) / Math.PI) * deg
- return {
- startAngle,
- endAngle
- }
- }
- MxFun.addCommand("list", async () => {
- // 选择对象获取信息
- const objIds = await MxCADUtility.userSelect("选择对象")
- const getPoint = new MxCADUiPrPoint()
- MxFun.acutPrintf("找到" + objIds.length + "个\\n")
- const objId = objIds.pop()
- if (!objId) return
- const ent = objId.getMcDbEntity()
- if (!objId.isValid() || !ent) {
- MxFun.acutPrintf("对象无效\\n")
- } else {
- if (await printInfo(ent) === false) return
- }
- while (objIds.length) {
- getPoint.setMessage("按 ENTER 键继续")
- getPoint.setDisableDynInput(true)
- await getPoint.go()
- // 程序中止、按下Esc键、新的命令运行时退出
- if (getPoint.getDetailedResult() === DetailedResult.kCodeAbort) return
- if (getPoint.getDetailedResult() === DetailedResult.kEcsIn) return
- if (getPoint.getDetailedResult() === DetailedResult.kNewCommadIn) return
- const objId = objIds.pop()
- if (!objId) break;
- const ent = objId.getMcDbEntity()
- if (!objId.isValid() || !ent) {
- MxFun.acutPrintf("对象无效\\n")
- continue
- }
- if (await printInfo(ent) === false) return
- }
- })
- // 记录对象的名称
- const entNames = {
- "McDbPoint": "点",
- "McDbLine": "直线",
- "McDbPolyline": "多段线",
- "McDbArc": "圆弧",
- "McDbCircle": "圆",
- "McDbEllipse": "椭圆",
- "McDbHatch": "填充",
- "McDbText": "单行文本",
- "McDbMText": "多行文本",
- "McDbRasterImage": "光栅图片",
- "McDbBlockReference": "块参照",
- }
- // 附着名称字典
- const map = {
- Top: "上",
- Middle: "中",
- Bottom: "下",
- Base: "基",
- Left: "左",
- Center: "中",
- Right: "右",
- Align: "对齐",
- Fit: "适应",
- Mid: "中"
- };
- // 获取文字的附着名称
- const getAttachmentName = (str: string) => {
- return str.replace(/k(\\w+)/g, function (_, p1) {
- let key = p1.replace(/([A-Z])/g, "-$1") as string
- const arr = key.split("-")
- const name = arr.reduce((name, key) => {
- if (map[key]) {
- return name + map[key];
- } else {
- return "";
- }
- })
- return name
- });
- }
- // 打印信息
- async function printInfo(ent: McDbEntity) {
- // 得到所有对象的基本信息
- const layer = ent.layer
- const layoutBlockName = MxCpp.getCurrentDatabase().currentSpace.name
- const isMainModel = layoutBlockName === "*Model_Space"
- const modeName = isMainModel ? "模型空间" : "图纸空间"
- const handle = ent.getHandle()
- console.log(ent.objectName)
- let entName = entNames[ent.objectName] || ent.objectName
- if(ent instanceof McDbDimension) {
- entName = "标注"
- }
- MxFun.acutPrintf(\`\\n \${entName} 图层: "\${layer}"\`)
- MxFun.acutPrintf(\`\\n 空间: "\${modeName}"\`)
- MxFun.acutPrintf(\`\\n 句柄 = \${handle}\`)
- // 点对象的信息
- if (ent instanceof McDbPoint) {
- MxFun.acutPrintf(\`\\n 于 点, X= \${ent.position.x.toFixed(4)} Y= \${ent.position.y.toFixed(4)} Z= \${ent.position.z.toFixed(4)}\`)
- }
- // 直线对象的信息
- if (ent instanceof McDbLine) {
- MxFun.acutPrintf(\`\\n 自 点, X= \${ent.startPoint.x.toFixed(4)} Y= \${ent.startPoint.y.toFixed(4)} Z= \${ent.startPoint.z.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 到 点, X= \${ent.startPoint.x.toFixed(4)} Y= \${ent.startPoint.y.toFixed(4)} Z= \${ent.startPoint.z.toFixed(4)}\`)
- let deltaX = ent.endPoint.x - ent.startPoint.x;
- let deltaY = ent.endPoint.y - ent.startPoint.y;
- let deltaZ = ent.endPoint.z - ent.startPoint.z;
- // 使用atan2计算角度,结果是弧度,转换为度
- let angleInDegrees = THREE.MathUtils.radToDeg(Math.atan2(deltaY, deltaX));
- MxFun.acutPrintf(\`\\n 长度 = \${ent.getLength().val.toFixed(4)},在 XY 平面中的角度 = \${Math.floor(angleInDegrees)}\`)
- MxFun.acutPrintf(\`\\n 增量 X = \${deltaX.toFixed(4)},增量 Y = \${deltaY.toFixed(4)},增量 Z = \${deltaZ.toFixed(4)}\`)
- }
- // 多段线对象的信息
- if (ent instanceof McDbPolyline) {
- MxFun.acutPrintf(\`\\n \${ent.isClosed ? "闭合" : "打开"}\`)
- MxFun.acutPrintf(\`\\n 固定宽度 \${ent.constantWidth.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 面积 \${ent.getArea().val.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 周长 \${ent.getLength().val.toFixed(4)}\`)
- // 输出多段线的每个点的信息
- const num = ent.numVerts()
- // 通过取点对象控制输出量 只有在按下空格或者回车才会继续打印剩余信息
- const getPoint = new MxCADUiPrPoint()
- // 记录点包含的其他信息如线宽、凸度值等
- const widthInfos: {
- val1: number;
- val2: number;
- ret: boolean;
- }[] = []
- const bulges: number[] = []
- // 记录是否打印线宽
- let isPrintWidth = false
- for (let index = 0; index < num; index++) {
- const width = ent.getWidthsAt(index)
- const bulge = ent.getBulgeAt(index)
- if (width.val1 !== 0 || width.val2 !== 0) {
- isPrintWidth = true
- }
- widthInfos.push(width)
- bulges.push(bulge)
- }
- // 控制输出打印量
- let accumulated = 0
- const maxIndex = 3
- for (let index = 0; index < num; index++) {
- if (accumulated > maxIndex) {
- while (true) {
- getPoint.setMessage("按 ENTER 键继续")
- getPoint.disableAllTrace()
- getPoint.clearLastInputPoint()
- // 设置不需要动态的输入框
- getPoint.setDynamicInputType(DynamicInputType.kNoInput)
- const pt = await getPoint.go()
- if (getPoint.getDetailedResult() === DetailedResult.kCodeAbort) return
- if (getPoint.getDetailedResult() === DetailedResult.kEcsIn) return
- if (getPoint.getDetailedResult() === DetailedResult.kNewCommadIn) return false
- // 只有回车和空格或者鼠标左键点击才能继续往下走打印的流程, 否则始终循环等待用户输入
- if (getPoint.getDetailedResult() === DetailedResult.kNullEnterIn || getPoint.getDetailedResult() === DetailedResult.kNullSpaceIn || pt) {
- accumulated = 0
- break;
- }
- }
- }
- const point = ent.getPointAt(index).val
- const bulge = bulges[index]
- MxFun.acutPrintf(\`\\n 于端点 X= \${point.x.toFixed(1)} Y= \${point.y.toFixed(1)} Z= \${point.z.toFixed(1)}\`)
- if (isPrintWidth) {
- MxFun.acutPrintf(\`\\n 起点宽度 \${widthInfos[index].val1.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 端点宽度 \${widthInfos[index].val2.toFixed(4)}\`)
- }
- // 凸度不为0时 且
- if (Math.abs(bulge) > 0) {
- MxFun.acutPrintf(\`\\n 凸度 \${bulge.toFixed(1)}\`)
- const nextPoint = ent.getPointAt(index + 1).val
- const center = calculateCenter(point, nextPoint, bulge)
- MxFun.acutPrintf(\`\\n 圆心 X= \${center.x.toFixed(1)} Y= \${center.y.toFixed(1)} Z= \${center.z.toFixed(1)}\`)
- MxFun.acutPrintf(\`\\n 半径 \${center.distanceTo(point).toFixed(1)}\`)
- const { startAngle, endAngle } = calculateLineAngle(center, point, nextPoint)
- MxFun.acutPrintf(\`\\n 起点角度 \${THREE.MathUtils.radToDeg(startAngle).toFixed(0)}\`)
- MxFun.acutPrintf(\`\\n 端点角度 \${THREE.MathUtils.radToDeg(endAngle).toFixed(0)}\`)
- // 最后一次循环加上最后一个端点信息
- if (index === num - 1) {
- MxFun.acutPrintf(\`\\n 于端点 X= \${nextPoint.x.toFixed(1)} Y= \${nextPoint.y.toFixed(1)} Z= \${nextPoint.z.toFixed(1)}\`)
- }
- }
- accumulated++
- }
- }
- // 圆弧的信息
- if (ent instanceof McDbArc) {
- MxFun.acutPrintf(\`\\n 圆心 点, X= \${ent.center.x.toFixed(4)} Y= \${ent.center.y.toFixed(4)} Z= \${ent.center.z.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 半径 \${ent.radius.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 起点 角度 \${THREE.MathUtils.radToDeg(ent.startAngle).toFixed(0)}\`)
- MxFun.acutPrintf(\`\\n 端点 角度 \${THREE.MathUtils.radToDeg(ent.endAngle).toFixed(0)}\`)
- MxFun.acutPrintf(\`\\n 长度 \${ent.getLength().val.toFixed(4)}\`)
- }
- // 圆的信息
- if (ent instanceof McDbCircle) {
- MxFun.acutPrintf(\`\\n 圆心 点, X= \${ent.center.x.toFixed(4)} Y= \${ent.center.y.toFixed(4)} Z= \${ent.center.z.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 半径 \${ent.radius.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 周长 \${ent.getLength().val.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 面积 \${(Math.PI * ent.radius * ent.radius).toFixed(4)}\`)
- }
- // 椭圆的信息
- if (ent instanceof McDbEllipse) {
- // 得到椭圆的半轴长度
- const radius1 = ent.majorAxis.length()
- const radius2 = ent.minorAxis.length()
- // 是否是椭圆 为false表示是椭圆弧
- const isEllipse = ent.startAngle === 0 && ent.endAngle === 2 * Math.PI
- if (isEllipse) {
- const calculateEllipseCircumference = (radius1: number, radius2: number) => {
- const h = Math.pow((radius1 - radius2), 2) / Math.pow((radius1 + radius2), radius2);
- const circumference = Math.PI * (radius1 + radius2) * (1 + (3 * h) / (10 + Math.sqrt(4 - 3 * h)));
- return circumference;
- }
- MxFun.acutPrintf(\`\\n 面积: \${(Math.PI * radius1 * radius2).toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 圆周: \${calculateEllipseCircumference(radius1, radius2).toFixed(4)}\`)
- }
- else {
- // 计算椭圆弧的长度
- const arcLengthOfEllipse = (a: number, b: number, theta1: number, theta2: number, numSteps: number) => {
- // a: 长半轴
- // b: 短半轴
- // 定义被积函数
- const integrand = function (theta: number) {
- return Math.sqrt(a * a * Math.sin(theta) * Math.sin(theta) + b * b * Math.cos(theta) * Math.cos(theta));
- };
- // 使用复合辛普森法则进行数值积分
- let integral = 0;
- const stepSize = (theta2 - theta1) / numSteps;
- for (let i = 0; i <= numSteps; i++) {
- const theta = theta1 + i * stepSize;
- if (i === 0 || i === numSteps) {
- integral += integrand(theta);
- } else if (i % 2 === 0) {
- integral += 2 * integrand(theta);
- } else {
- integral += 4 * integrand(theta);
- }
- }
- integral *= stepSize / 3;
- return Math.abs(integral);
- }
- MxFun.acutPrintf(\`\\n 长度: \${arcLengthOfEllipse(radius1, radius2, ent.startAngle, ent.endAngle, 30).toFixed(4)}\`)
- }
- MxFun.acutPrintf(\`\\n 中心点: X = \${ent.center.x.toFixed(4)} , Y = \${ent.center.y.toFixed(4)} , Z = \${ent.center.z.toFixed(4)}\`)
- // 判断哪个是半轴长度较长的轴
- const isMaxAxis = radius1 > radius2
- const maxAxis = isMaxAxis ? ent.majorAxis : ent.minorAxis
- const minAxis = isMaxAxis ? ent.minorAxis : ent.majorAxis
- MxFun.acutPrintf(\`\\n 长轴: X = \${maxAxis.x.toFixed(4)} , Y = \${maxAxis.y.toFixed(4)} , Z = \${maxAxis.z.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 短轴: X = \${minAxis.x.toFixed(4)} , Y = \${minAxis.y.toFixed(4)} , Z = \${minAxis.z.toFixed(4)}\`)
- // 椭圆弧的其他信息
- if (!isEllipse) {
- // 计算椭圆弧的起点和端点
- const calculateEllipseEndpoints = (center: McGePoint3d, v1: McGeVector3d, v2: McGeVector3d, theta1: number, theta2: number) => {
- // 椭圆中心坐标
- const cx = center.x;
- const cy = center.y;
- // 主轴向量
- const vx1 = v1.x;
- const vy1 = v1.y;
- // 副轴向量
- const vx2 = v2.x;
- const vy2 = v2.y;
- // 计算椭圆的起始点和结束点
- const alpha = Math.atan2(vy1, vx1)
- const a = Math.sqrt(vx1 * vx1 + vy1 * vy1); // 长轴半径
- const b = Math.sqrt(vx2 * vx2 + vy2 * vy2); // 短轴半径
- // 根据角度计算起始点和结束点
- const startEndpointX = cx + a * Math.cos(theta1) * Math.cos(alpha) - b * Math.sin(theta1) * Math.sin(alpha);
- const startEndpointY = cy + a * Math.cos(theta1) * Math.sin(alpha) + b * Math.sin(theta1) * Math.cos(alpha);
- const endEndpointX = cx + a * Math.cos(theta2) * Math.cos(alpha) - b * Math.sin(theta2) * Math.sin(alpha);
- const endEndpointY = cy + a * Math.cos(theta2) * Math.sin(alpha) + b * Math.sin(theta2) * Math.cos(alpha);
- return {
- startPoint: new McGePoint3d(startEndpointX, startEndpointY),
- endPoint: new McGePoint3d(endEndpointX, endEndpointY)
- };
- }
- const { startPoint, endPoint } = calculateEllipseEndpoints(ent.center, ent.majorAxis, ent.minorAxis, ent.startAngle, ent.endAngle)
- MxFun.acutPrintf(\`\\n 起点: X = \${startPoint.x.toFixed(4)} , Y = \${startPoint.y.toFixed(4)} , Z = \${startPoint.z.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 端点: X = \${endPoint.x.toFixed(4)} , Y = \${endPoint.y.toFixed(4)} , Z = \${endPoint.z.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 起点角度: \${THREE.MathUtils.radToDeg(ent.startAngle).toFixed(0)}\`)
- MxFun.acutPrintf(\`\\n 端点角度: \${THREE.MathUtils.radToDeg(ent.endAngle).toFixed(0)}\`)
- }
- MxFun.acutPrintf(\`\\n 半径比例: \${ent.radiusRatio.toFixed(4)}\`)
- }
- // 填充对象信息
- if(ent instanceof McDbHatch) {
- const patternName = ent.patternName()
- MxFun.acutPrintf(\`\\n 填充图案 \${patternName}\`)
- MxFun.acutPrintf(\`\\n 图案填充比例 \${ent.patternScale.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 图案填充角度 \${THREE.MathUtils.radToDeg(ent.patternAngle).toFixed(0)}\`)
- const pl = new McDbPolyline()
- const pls: McDbPolyline[] = []
- pl.isClosed = true
- for (let index = 0; index < ent.numLoops; index++) {
- const { vertices, bulges } = ent.getLoopAt(index)
- vertices.forEach((pt, index)=> {
- const bulge = bulges[index]
- pl.addVertexAt(pt, Number(bulge.toFixed(14)))
- })
- pls.push(pl)
- MxCpp.getCurrentMxCAD().drawEntity(pl)
- }
- const totalArea = pls.reduce((totalArea, pl)=> totalArea + pl.getArea().val, 0)
- MxFun.acutPrintf(\`\\n 面积 \${totalArea.toFixed(4)}\`)
- }
- // 单行文字信息
- if(ent instanceof McDbText) {
- MxFun.acutPrintf(\`\\n 样式 = "\${ent.textStyle}"\`)
- MxFun.acutPrintf(\`\\n 起点 点, X= \${ent.position.x.toFixed(4)} Y= \${ent.position.y.toFixed(4)} Z= \${ent.position.z.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 高度 \${ent.height.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 文字 \${ent.textString}\`)
- MxFun.acutPrintf(\`\\n 旋转 角度 \${ent.rotation.toFixed(0)}\`)
- MxFun.acutPrintf(\`\\n 宽度 比例因子 \${ent.widthFactor.toFixed(4)}\`)
- }
- // 多行文字信息
- if(ent instanceof McDbMText) {
- MxFun.acutPrintf(\`\\n 样式 = "\${ent.textStyle}"\`)
- MxFun.acutPrintf(\`\\n位置: X= \${ent.location.x.toFixed(4)} Y= \${ent.location.y.toFixed(4)} Z= \${ent.location.z.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n宽度: \${ent.width.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n法向: X= \${ent.normal.x.toFixed(4)} Y= \${ent.normal.y.toFixed(4)} Z= \${ent.normal.z.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n旋转: \${ent.rotation.toFixed(0)}\`)
- MxFun.acutPrintf(\`\\n文字高度: \${ent.textHeight.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n附着: \${getAttachmentName(McDb.AttachmentPoint[ent.attachment])}\`)
- MxFun.acutPrintf(\`\\n内容: \${ent.contents}\`)
- }
- // 光栅图片信息
- if(ent instanceof McDbRasterImage) {
- const imgDef = ent.imageDefId().getMcDbRasterImageDef()
- const getFileNameFromPath = (path: string)=> {
- return path.split('/').pop().split('\\\\').pop();
- }
- MxFun.acutPrintf(\`\\n图像: \${getFileNameFromPath(imgDef.sourceFileName)}\`)
- const getClipBoundaryType = (ent: McDbRasterImage)=> {
- const type = ent.clipBoundaryType()
- if(type === McDb.ClipBoundaryType.kInvalid) return "无效"
- if(type === McDb.ClipBoundaryType.kPoly) return "多边形"
- if(type === McDb.ClipBoundaryType.kRect) return "矩形"
- }
- MxFun.acutPrintf(\`\\n剪裁边界类型: \${getClipBoundaryType(ent)}\`)
- const clipBoundary = ent.clipBoundary()
- MxFun.acutPrintf(\`\\n边界点数目: \${clipBoundary.length()}\`)
- ent.clipBoundary().forEach((pt)=> {
- MxFun.acutPrintf(\`\\n 位于点,X= \${pt.x.toFixed(4)}, Y= \${pt.y.toFixed(4)}, Z= \${pt.z.toFixed(4)}\`)
- })
- }
- // 图块信息
- if(ent instanceof McDbBlockReference) {
- MxFun.acutPrintf(\`\\n块名: "\${ent.blockName}"\`)
- MxFun.acutPrintf(\`\\n插入点: X= \${ent.position.x.toFixed(4)}, Y= \${ent.position.y.toFixed(4)}, Z= \${ent.position.z.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\nX 比例因子: \${ent.scaleFactors.x.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\nY 比例因子: \${ent.scaleFactors.y.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 旋转角度: \${ent.rotation.toFixed(0)}\`)
- MxFun.acutPrintf(\`\\nZ 比例因子: \${ent.scaleFactors.z.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\nZ 比例因子: \${ent.scaleFactors.z.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n 缩放比例: \${ent.getScale().toFixed(4)}\`)
- }
- // 标注信息
- if(ent instanceof McDbDimension) {
- MxFun.acutPrintf(\`\\n文字位置: X= \${ent.textPosition.x.toFixed(4)} Y= \${ent.textPosition.y.toFixed(4)} Z= \${ent.textPosition.z.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n是否使用的默认文字位置: \${ent.isUsingDefaultTextPosition()}\`)
- MxFun.acutPrintf(\`\\n高度: \${ent.elevation.toFixed(4)}\`)
- MxFun.acutPrintf(\`\\n文本内容: \${ent.dimensionText}\`)
- MxFun.acutPrintf(\`\\n文本旋转角度: \${THREE.MathUtils.radToDeg(ent.textRotation).toFixed(0)}\`)
- const dimStyle = ent.dimensionStyle.getMcDbDimStyleTableRecord()
- MxFun.acutPrintf(\`\\n标注样式: \${dimStyle.name}\`)
- MxFun.acutPrintf(\`\\n文字附着: \${getAttachmentName(McDb.AttachmentPoint[ent.textAttachment])}\`)
- MxFun.acutPrintf(\`\\n水平旋转角度: \${THREE.MathUtils.radToDeg(ent.horizontalRotation).toFixed(0)}\`)
- MxFun.acutPrintf(\`\\n水平旋转角度: \${THREE.MathUtils.radToDeg(ent.horizontalRotation).toFixed(0)}\`)
- }
- MxFun.acutPrintf("\\n命令")
- }
- `,qR=e=>{const t=/\/\/{24}[\s\S]*\/\/{24}/g;return e.replace(t,"")};(e=>{e.push({type:"命令实现",name:"list 命令",code:qR($R)})})(cb);class XR extends M.MxCADPluginBase{constructor(){super(),this.map_default_data=OR(),this.sampleCode=cb}}let lu;const{showModal:ZR,hideModal:vl,showTools:YR}=$p();function KR(){return Qe(this,null,function*(){ZR({title:"My Test Draw",text:"测试Modal",oncancel:()=>{vl()},onsubmit:()=>{vl()},ongetallentity:()=>{vl(),X.MxFun.sendStringToExecute("TestGetAllEntity")},ondrawline:()=>{vl(),X.MxFun.sendStringToExecute("Mx_Circle")},docommand:e=>{vl(),X.MxFun.sendStringToExecute(e)}})})}function JR(){return Qe(this,null,function*(){YR({title:"My Extension Tools",text:"扩展工具",oncancel:()=>{vl()},docommand:e=>{vl(),X.MxFun.sendStringToExecute(e)}})})}const pb=document.createElement("div");document.body.appendChild(pb),q.createApp(W2).mount(pb),H2(),X.MxFun.onInitSync(()=>new Promise(e=>{e(!0)})),X.MxFun.on("mxcadApplicationStart",e=>{lu=e,lu.init(new XR)}),X.MxFun.on("mxcadApplicationInitMap",()=>{NR(lu.mxmap)}),X.MxFun.on("mxcadApplicationStartCreatingMxCADObject",e=>{let t=e.mxdraw;t.setViewMovementMethod(!0),t.on("openFileComplete",()=>{window.parent.postMessage({cmd:"MKY_Open_File_Complete"})}),t.addControlsEvent("mousedown",i=>{let l=i.offsetX,c=i.offsetY,h=t.viewCoord2Cad(l,c,0);return console.log("mousedown:",h),0})}),X.MxFun.on("mxcadApplicationCreatedMxCADObject",e=>{let t=lu.getServerConfig();M.MxCpp.App.addNetworkLoadingFont(t.font||["txt.shx","simplex.shx","gdt.shx","aaa.shx","ltypeshp.shx","complex.shx"]),M.MxCpp.App.addNetworkLoadingBigFont(t.bigFont||["hztxt.shx","gbcbig.shx"]),t.trueTypeFont?M.MxCpp.App.addNetworkLoadingTrueTypeFont(t.trueTypeFont[0],t.trueTypeFont[1],t.trueTypeFont[2]):M.MxCpp.App.addNetworkLoadingTrueTypeFont(["syadobe"],["思原黑体"],["syadobe.otf"]);let i=e.mxcad;i.setAttribute({DisplayPrecision:35}),i.on("selectChange",l=>{if(l.length==0)return;let c=l[0],h=c.getMxDbEntity();if(h!==null){console.log(h.getTypeName()),h instanceof X.MxDbRectBoxLeadComment&&console.log(h.text);return}let f=c.getMcDbEntity();f!==null&&(console.log(f.objectName),f instanceof M.McDbText?console.log(f.textString):f instanceof M.McDbBlockReference&&f.getAllAttribute().forEach(x=>{let w=x.getMcDbEntity();console.log(w.textString),console.log(w.tag)}))}),M.MxCpp.PropertiesWindow.onEvent_getProperties(l=>{let c=l.getMcDbEntity();if(!c)return[];let h=c.getxDataDouble("DN"),f=c.getxDataDouble("LEN"),r=[];return h.ret&&r.push({sVarName:"DN",iVarType:M.MxPropertiesWindowCustomValueType.kDouble,val:h.val,isOnlyRead:!1}),f.ret&&r.push({sVarName:"LEN",iVarType:M.MxPropertiesWindowCustomValueType.kDouble,val:f.val,isOnlyRead:!1}),r}),M.MxCpp.PropertiesWindow.onEvent_setProperties((l,c)=>{let h=l.getMcDbEntity();h&&(c.sVarName=="DN"?h.setxDataDouble("DN",c.val):c.sVarName=="LEN"&&h.setxDataDouble("LEN",c.val))})});function xl(){return lu}function Cr(e){return"x="+e.x+",y="+e.y+",z="+e.z}function QR(){window.open("https://demo.mxdraw3d.com:3562/MxCADCode.7z")}function ek(){window.open("https://demo.mxdraw3d.com:3562/MxDrawCloudServer1.0TryVersion.7z")}function cu(e){var t=window.location.href;return t.indexOf("?")!=-1&&(t=t.replace(/(\?|#)[^'"]*/,"")),`${t}?map=true&maptype=${e}`}function tk(){window.open(cu("gdslwzj"))}function nk(){window.open(cu("google"))}function ik(){window.open(cu("gdyx"))}function rk(){window.open(cu("tdtsl"))}function ok(){window.open(cu("bdsl"))}function ak(){window.open(cu("geoq"))}function sk(){M.MxCpp.getCurrentMxCAD().setViewBackgroundColor(255,255,255),X.MxFun.callEvent("updateBackgroundColor",new M.McCmColor(255,255,255))}function fb(){return Qe(this,null,function*(){let e=new M.MxCADUiPrEntity;e.setMessage("选择要需要开启自定义属性的对象");let t=yield e.go();if(!t.isValid())return;let i=t.getMcDbEntity();M.MxCpp.PropertiesWindow.setEntitySupportCustom(t),i.setxDataDouble("DN",100),i.setxDataDouble("LEN",2e3)})}function lk(){M.MxCpp.getCurrentMxCAD().openWebFile("http://localhost:1337/mxcad/file/a9cbed3d3a351b79f24484e87bd78338.DWG.mxweb")}function ck(){return Qe(this,null,function*(){})}function uk(){return Qe(this,null,function*(){let e=new M.MxCADUiPrEntity;e.setMessage("选择要隐藏的对象");let t=yield e.go();if(!t.isValid())return;let i=t.getMcDbEntity(),l=M.MxCpp.getCurrentMxCAD(),f=l.getDatabase().getLayerTable().get(i.layer).getMcDbLayerTableRecord();f!==null&&(f.isOff=!0,l.updateLayerDisplayStatus(),l.updateDisplay())})}function hk(){return window.location.origin+window.location.pathname}let H_;function dk(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage(`
- 指定插入点:`);let t=yield e.go();if(!t)return;let i=M.MxCpp.getCurrentMxCAD(),l=hk()+"mxcad.jpg";i.loadImage(l,c=>{if(!c){console.log("loadImage failed");return}let h=i.mxdraw.viewCoordLong2Cad(100),f=c.height/c.width*h;H_=i.drawImage(t.x,t.y,h,f,0,l,!0),i.updateDisplay()})})}function pk(){if(!H_)return;let e=M.MxCpp.getCurrentMxCAD(),t="https://cdn.pixabay.com/photo/2022/11/15/12/23/winter-7593872_960_720.jpg";e.loadImage(t,i=>{if(!i){console.log("loadImage failed");return}let l=e.addImageDefine(t,"winter-7593872_960_720.jpg",!0),c=H_.getMcDbEntity();c&&c.setImageDefId(l),e.updateDisplay()})}function mb(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD(),t=new M.MxCADUiPrPoint,i=yield t.go();if(i==null)return;t.setBasePt(i);let l=yield t.go();if(l==null)return;let c=e.drawLine(i.x,i.y,l.x,l.y);e.addCurrentSelect(c)})}let gb=0;function yb(){return Qe(this,null,function*(){gb+=Math.PI*.5,M.MxCpp.getCurrentMxCAD().zoomAngle(gb)})}function _b(){M.MxCpp.getCurrentMxCAD().zoomCenter(900,900)}function fk(){let e=M.MxCpp.getCurrentMxCAD();e.newFile();let t=new M.McDbPolyline;t.setType(M.McDb.PolylineType.k3dPolyline),t.addVertexAt(new M.McGePoint3d(100,100,100)),t.addVertexAt(new M.McGePoint3d(200,100,500)),t.addVertexAt(new M.McGePoint3d(300,400,200)),e.drawEntity(t),e.zoomAll(),e.updateDisplay()}function mk(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage(`
- 指定一点:`);let t=yield e.go();if(!t)return;const i=new M.MxCADUiPrAngle;i.setMessage("指定夹角"),i.setKeyWords(""),i.setBasePt(t);const l=yield i.go();console.log(l)})}function gk(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage(`
- 指定一点:`),e.setOffsetInputPostion(!0);let t=yield e.go();if(!t)return;e.setBasePt(t),e.setUseBasePt(!0),e.setMessage(`
- 指定二点:`);let i=yield e.go();i&&M.MxCpp.getCurrentMxCAD().drawLine(t.x,t.y,i.x,i.y)})}function yk(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet;if(!(yield e.userSelect("选择要做成组的对象:"))||e.count()==0)return;M.MxCpp.getCurrentMxCAD().getDatabase().CreateGroup(e.getIds())})}function _k(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD();const t=new M.MxCADUiPrPoint;t.setMessage(`
- 指定第一点:`);let i=yield t.go();if(!i)return;t.setMessage(`
- 指定第二点:`),t.setBasePt(i);let l=yield t.go();if(!l)return;let c=l.sub(i);c.rotateBy(Math.PI*.5).normalize().mult(X.MxFun.screenCoordLong2Doc(10));let h=i.clone().addvec(c),f=i.clone().subvec(c),r=l.clone().addvec(c),v=l.clone().subvec(c),x=new M.McGeBound([h,f,r,v]),w=x.minPoint,b=x.maxPoint,A=new M.MxCADSelectionSet;A.crossingSelect(w.x,w.y,b.x,b.y,new M.MxCADResbuf([M.DxfCode.kEntityType,"LINE,ARC,CIRCLE,LWPOLYLINE"]));let L=X.MxFun.screenCoordLong2Doc(5),P=new M.McDbLine(i,l);A.forEach(R=>{let V=R.getMcDbEntity().IntersectWith(P,M.McDb.Intersect.kOnBothOperands);if(V.length()!=0){let j=V.at(0);e.drawCircle(j.x,j.y,L)}})})}X.MxFun.on("mxcadApplicationCreatedMxCADObject",e=>{e.mxcad.on("selectChange",i=>{if(i.length==0)return;let l=i[0],c=l.getMxDbEntity();if(c!==null){console.log(c.getTypeName()),c instanceof X.MxDbRectBoxLeadComment&&console.log(c.text);return}let h=l.getMcDbEntity();h!==null&&(console.log(h.objectName),h instanceof M.McDbText?console.log(h.textString):h instanceof M.McDbBlockReference&&h.getAllAttribute().forEach(v=>{let x=v.getMcDbEntity();console.log(x.textString),console.log(x.tag)}))}),M.MxCpp.PropertiesWindow.onEvent_getProperties(i=>{let l=i.getMcDbEntity();if(!l)return[];let c=l.getxDataDouble("DN"),h=l.getxDataDouble("LEN"),f=[];return c.ret&&f.push({sVarName:"DN",iVarType:M.MxPropertiesWindowCustomValueType.kDouble,val:c.val,isOnlyRead:!1}),h.ret&&f.push({sVarName:"LEN",iVarType:M.MxPropertiesWindowCustomValueType.kDouble,val:h.val,isOnlyRead:!1}),f}),M.MxCpp.PropertiesWindow.onEvent_setProperties((i,l)=>{let c=i.getMcDbEntity();c&&(l.sVarName=="DN"?c.setxDataDouble("DN",l.val):l.sVarName=="LEN"&&c.setxDataDouble("LEN",l.val))}),wk()});function vk(){return Qe(this,null,function*(){const e=yield M.MxCADUtility.getCorner("选择截图范围",void 0,void 0,!1,!0);if(!e)return;let t=M.MxCpp.getCurrentMxCAD(),i=Math.abs(e.pt1.x-e.pt2.x),l=Math.abs(e.pt1.y-e.pt2.y);if(i<1||l<1)return;let c=200,h=c*l/i;t.mxdraw.createCanvasImageData(f=>{let r=window.open();r!=null&&r.document.write('<img src="'+f+'"/>')},{width:c,height:h,range_pt1:e.pt1.toVector3(),range_pt2:e.pt2.toVector3()})})}function xk(){return Qe(this,null,function*(){for(;;){const e=new M.MxCADUiPrPoint;e.setMessage(`
- 指定一点:`),e.setOffsetInputPostion(!0),e.clearLastInputPoint();let t=yield e.go();if(!t)return;let i=X.MxFun.getCurrentDraw();i.getTempMarkDraw().drawCircleMark(t.toVector3(),i.viewCoordLong2Cad(50),16711680),i.updateDisplay()}})}function bk(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage(`
- 指定第一点:`);let t=yield e.go();if(!t)return;let i=yield M.MxCADUtility.getCorner(`
- 指定第二点:`,t);if(!i)return;let l=i.pt2,c=new M.McGePoint3dArray;c.append(t),c.append(new M.McGePoint3d(t.x,l.y,0)),c.append(new M.McGePoint3d(l.x,l.y,0)),c.append(new M.McGePoint3d(l.x,t.y,0));let h=new M.McDbWipeout;h.setVertices(c),h=M.MxCpp.getCurrentMxCAD().drawEntity(h).getMcDbObject();let v=M.MxCpp.getCurrentDatabase().currentSpace.getMinMaxDrawOrder().maxDrawOrder+1;h.drawOrder=v})}function wk(){X.MxFun.addCommand("My_PluginTest",KR),X.MxFun.addCommand("My_Extool",JR),X.MxFun.addCommand("Mx_Open_DemoCode",QR),X.MxFun.addCommand("Mx_Open_DevInstall",ek),X.MxFun.addCommand("Mx_Open_Map_gdslwzj",tk),X.MxFun.addCommand("Mx_Open_Map_gdyx",ik),X.MxFun.addCommand("Mx_Open_Map_tdtsl",rk),X.MxFun.addCommand("Mx_Open_Map_bdsl",ok),X.MxFun.addCommand("Mx_Open_Map_geoq",ak),X.MxFun.addCommand("Mx_Open_Map_googlecn",nk),X.MxFun.addCommand("Mx_ViewBackgroundColor",sk),X.MxFun.addCommand("Mx_TestExProp",fb),X.MxFun.addCommand("Mx_Test_OpenFile",lk),X.MxFun.addCommand("Mx_Test_GetFile",ck),X.MxFun.addCommand("Mx_TestExProp",fb),X.MxFun.addCommand("Mx_SelectEntitHideLayer",uk),X.MxFun.addCommand("MxTest_TestAddCurrentSelect",mb),X.MxFun.addCommand("MxTest_TestSetViewAngle",yb),X.MxFun.addCommand("MxText_ZoomCenter",_b),X.MxFun.addCommand("MxTest_Map_Download",UR),X.MxFun.addCommand("Mx_Test_DrawImage",dk),X.MxFun.addCommand("Mx_Test_ModifyImage",pk),X.MxFun.addCommand("Mx_Test_Draw3DPolyline",fk),X.MxFun.addCommand("MxTemp_Test",mk),X.MxFun.addCommand("Mx_Test_IntersectWith",_k),X.MxFun.addCommand("Mx_Test_OffsetIn_DrawLine",gk),X.MxFun.addCommand("Mx_Test_CreateGroup",yk),X.MxFun.addCommand("Mx_ScreenToJpg",vk),X.MxFun.addCommand("Mx_Test_DrawMarkCircle",xk),X.MxFun.addCommand("Mx_Test_Wipeout",bk),eT(),yT(),jS(),$S(),E3(),k3(),O3(),W3(),H3(),bL(),DL(),U3(),zL(),cI(),LI(),$I(),lR(),SR(),NL(),lu.mxmap&&GR(X.MxFun.getCurrentDraw())}return ar.McGePoint3dToString=Cr,ar.MxTest_TestAddCurrentSelect=mb,ar.MxTest_TestSetViewAngle=yb,ar.MxText_ZoomCenter=_b,ar.getMxCADUi=xl,Object.defineProperty(ar,Symbol.toStringTag,{value:"Module"}),ar}({},Mx,MxCAD,Vue,axios);
- //# sourceMappingURL=test.js.map
|