var Qv=Math.pow;var wn=(wo,tt,te)=>new Promise((ct,Fp)=>{var Op=na=>{try{th(te.next(na))}catch(nh){Fp(nh)}},eh=na=>{try{th(te.throw(na))}catch(nh){Fp(nh)}},th=na=>na.done?ct(na.value):Promise.resolve(na.value).then(Op,eh);th((te=te.apply(wo,tt)).next())});var test=function(wo,tt,te,ct,Fp){var Op=document.createElement("style");Op.textContent=`.heading[data-v-9bd7093d]{font-size:1.5em;margin-bottom:12px}.card[data-v-9bd7093d]{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-9bd7093d]{font-size:1.1em;margin-bottom:44px}.content-wrapper[data-v-9bd7093d]:last-child{margin-bottom:0}.button[data-v-9bd7093d]{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-9bd7093d]:focus{border:2px solid transparent;box-shadow:0 0 0 2px #121943;outline:solid 4px transparent}.link[data-v-9bd7093d]{color:#121943}.link[data-v-9bd7093d]:focus{box-shadow:0 0 0 2px #121943}.input-wrapper[data-v-9bd7093d]{display:flex;flex-direction:column}.input-wrapper .label[data-v-9bd7093d]{align-items:baseline;display:flex;font-weight:700;justify-content:space-between;margin-bottom:8px}.input-wrapper .optional[data-v-9bd7093d]{color:#5a72b5;font-size:.9em}.input-wrapper .input[data-v-9bd7093d]{border:1px solid #5a72b5;border-radius:4px;height:40px;padding:8px}code[data-v-9bd7093d]{background:#e5efe9;border:1px solid #5a72b5;border-radius:4px;padding:2px 4px}.modal-header[data-v-9bd7093d]{align-items:baseline;display:flex;justify-content:space-between}.close[data-v-9bd7093d]{background:none;border:none;cursor:pointer;display:flex;height:16px;text-decoration:none;width:16px}.close svg[data-v-9bd7093d]{width:16px}.modal-wrapper[data-v-9bd7093d]{align-items:center;background:rgba(0,0,0,.7);display:flex;justify-content:center;inset:0;position:fixed}#modal[data-v-9bd7093d]{transition:opacity .25s ease-in-out}#modal .modal-body[data-v-9bd7093d]{max-width:830px;opacity:1;transform:translateY(-100px);transition:opacity .25s ease-in-out;width:100%;z-index:1}.outside-trigger[data-v-9bd7093d]{cursor:default;inset:0;position:fixed}.button__link[data-v-9bd7093d]{text-decoration:none}.button[data-v-9bd7093d]{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-9bd7093d]{background-color:#fff;color:#000;border:2px solid #4caf50}.button1[data-v-9bd7093d]:hover{background-color:#4caf50;color:#fff}.button2[data-v-9bd7093d]{background-color:#fff;color:#000;border:2px solid #008cba}.button2[data-v-9bd7093d]:hover{background-color:#008cba;color:#fff}.btn_box[data-v-9bd7093d]{width:100%;display:flex;justify-items:center;justify-content:start;align-items:start} `,document.head.appendChild(Op);const eh=ct.ref(!1),th=e=>{eh.value=!0,Ug.value=Object.assign(Ug.value,e||{})},na=()=>{eh.value=!1},nh={title:"Modal",text:"",oncancel:na,onsubmit:na,ongetallentity:na,ondrawline:na,docommand:e=>{}},Ug=ct.ref(nh),e0=()=>({isModalVisible:eh,showModal:th,hideModal:na,modalOptions:Ug}),tM=e=>(ct.pushScopeId("data-v-9bd7093d"),e=e(),ct.popScopeId(),e),nM={key:0,class:"modal-wrapper",id:"modal"},iM={class:"modal-body card"},rM={class:"modal-header"},aM={class:"heading"},oM=[tM(()=>ct.createElementVNode("svg",{viewBox:"0 0 24 24"},[ct.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))],sM={style:{"overflow-y":"auto",height:"500px"}},lM={class:"btn_box"},cM={class:"btn_box"},uM={class:"btn_box"},hM={class:"btn_box"},dM={class:"btn_box"},pM={class:"btn_box"},fM={class:"btn_box"},mM={class:"btn_box"},gM={class:"btn_box"},_M={class:"btn_box"},yM={class:"btn_box"},vM={class:"btn_box"},xM={class:"btn_box"},bM={class:"btn_box"},wM=ct.defineComponent({__name:"Modal",setup(e){const{isModalVisible:n,hideModal:i,modalOptions:l}=e0();return i(),(h,p)=>(ct.openBlock(),ct.createBlock(ct.Teleport,{to:"body"},[ct.createTextVNode(" 2356788909-80976564578697809-090897867 "),ct.unref(n)?(ct.openBlock(),ct.createElementBlock("div",nM,[ct.createElementVNode("div",iM,[ct.createElementVNode("div",rM,[ct.createElementVNode("h2",aM,ct.toDisplayString(ct.unref(l).title),1),ct.createElementVNode("a",{href:"#!",onClick:p[0]||(p[0]=(..._)=>ct.unref(i)&&ct.unref(i)(..._)),role:"button",class:"close","aria-label":"close this modal"},oM)]),ct.createElementVNode("div",sM,[ct.createElementVNode("div",lM,[ct.createElementVNode("button",{class:"button button2",onClick:p[1]||(p[1]=_=>ct.unref(l).docommand("Mx_Open_DemoCode"))}," 下载开Demo代码 "),ct.createElementVNode("button",{class:"button button2",onClick:p[2]||(p[2]=_=>ct.unref(l).docommand("Mx_Open_DevInstall"))}," 下载开发包 "),ct.createElementVNode("button",{class:"button button2",onClick:p[3]||(p[3]=(..._)=>ct.unref(l).ondrawline&&ct.unref(l).ondrawline(..._))}," 调用画圆线命令 "),ct.createElementVNode("button",{class:"button button2",onClick:p[4]||(p[4]=_=>ct.unref(l).docommand("MxTest_DrawLine"))}," 交互画直线 ")]),ct.createElementVNode("div",cM,[ct.createElementVNode("button",{class:"button button2",onClick:p[5]||(p[5]=_=>ct.unref(l).docommand("MxTest_AddLayer"))}," 添加图层 "),ct.createElementVNode("button",{class:"button button2",onClick:p[6]||(p[6]=_=>ct.unref(l).docommand("MxTest_GetAllLayer"))}," 得到所有图层 "),ct.createElementVNode("button",{class:"button button2",onClick:p[7]||(p[7]=_=>ct.unref(l).docommand("MxTest_GetAllTextStyle"))}," 得到所有文字样式 "),ct.createElementVNode("button",{class:"button button2",onClick:p[8]||(p[8]=_=>ct.unref(l).docommand("MxTest_GetAllBlock"))}," 得到所有图块 ")]),ct.createElementVNode("div",uM,[ct.createElementVNode("button",{class:"button button2",onClick:p[9]||(p[9]=_=>ct.unref(l).docommand("MxTest_GetAllLinetype"))}," 得到所有线型 "),ct.createElementVNode("button",{class:"button button2",onClick:p[10]||(p[10]=_=>ct.unref(l).docommand("MxTest_WritexData"))}," 写扩展数据 "),ct.createElementVNode("button",{class:"button button2",onClick:p[11]||(p[11]=_=>ct.unref(l).docommand("MxTest_ReadxData"))}," 读扩展数据 "),ct.createElementVNode("button",{class:"button button2",onClick:p[12]||(p[12]=_=>ct.unref(l).docommand("MxTest_InsertBlock"))}," 测试插入一个图块 ")]),ct.createElementVNode("div",hM,[ct.createElementVNode("button",{class:"button button2",onClick:p[13]||(p[13]=_=>ct.unref(l).docommand("Mx_Test_DrawLine"))}," 绘直线 "),ct.createElementVNode("button",{class:"button button2",onClick:p[14]||(p[14]=_=>ct.unref(l).docommand("Mx_Test_DrawArc"))}," 绘圆弧 "),ct.createElementVNode("button",{class:"button button2",onClick:p[15]||(p[15]=_=>ct.unref(l).docommand("Mx_Test_DrawCircle"))}," 绘圆 "),ct.createElementVNode("button",{class:"button button2",onClick:p[16]||(p[16]=_=>ct.unref(l).docommand("Mx_Test_DrawPolyline"))}," 绘PL线 ")]),ct.createElementVNode("div",dM,[ct.createElementVNode("button",{class:"button button2",onClick:p[17]||(p[17]=_=>ct.unref(l).docommand("Mx_Test_DrawHatch"))}," 绘填充 "),ct.createElementVNode("button",{class:"button button2",onClick:p[18]||(p[18]=_=>ct.unref(l).docommand("Mx_Test_DrawText"))}," 绘文字 "),ct.createElementVNode("button",{class:"button button2",onClick:p[19]||(p[19]=_=>ct.unref(l).docommand("Mx_Test_Ellipse"))}," 绘椭圆 "),ct.createElementVNode("button",{class:"button button2",onClick:p[20]||(p[20]=_=>ct.unref(l).docommand("Mx_Test_EllipseArc"))}," 绘椭圆弧 ")]),ct.createElementVNode("div",pM,[ct.createElementVNode("button",{class:"button button2",onClick:p[21]||(p[21]=_=>ct.unref(l).docommand("Mx_Test_MText"))}," 绘制多行文字 "),ct.createElementVNode("button",{class:"button button2",onClick:p[22]||(p[22]=_=>ct.unref(l).docommand("Mx_Test_DrawTable"))}," 绘制表格 "),ct.createElementVNode("button",{class:"button button2",onClick:p[23]||(p[23]=_=>ct.unref(l).docommand("Mx_Test_QRCode"))}," 绘制二维码 "),ct.createElementVNode("button",{class:"button button2",onClick:p[24]||(p[24]=_=>ct.unref(l).docommand("MxTest_InsertStamp"))}," 插入图章 ")]),ct.createElementVNode("div",fM,[ct.createElementVNode("button",{class:"button button2",onClick:p[25]||(p[25]=(..._)=>ct.unref(l).ongetallentity&&ct.unref(l).ongetallentity(..._))}," 得到所有对象 "),ct.createElementVNode("button",{class:"button button2",onClick:p[26]||(p[26]=_=>ct.unref(l).docommand("MxTest_SelectEntity"))}," 交互选择对象 "),ct.createElementVNode("button",{class:"button button2",onClick:p[27]||(p[27]=_=>ct.unref(l).docommand("Mx_Export_MxWeb"))}," 保存mxweb到服务器 "),ct.createElementVNode("button",{class:"button button2",onClick:p[28]||(p[28]=_=>ct.unref(l).docommand("MxTest_GetSysVars"))}," 得到系统变量 ")]),ct.createElementVNode("div",mM,[ct.createElementVNode("button",{class:"button button2",onClick:p[29]||(p[29]=_=>ct.unref(l).docommand("MxTest_NewFile"))}," 新建图纸 "),ct.createElementVNode("button",{class:"button button2",onClick:p[30]||(p[30]=_=>ct.unref(l).docommand("Mx_ViewBackgroundColor"))}," 白色背景色 "),ct.createElementVNode("button",{class:"button button2",onClick:p[31]||(p[31]=_=>ct.unref(l).docommand("MxTest_FindText"))}," 文字查找定位 "),ct.createElementVNode("button",{class:"button button2",onClick:p[32]||(p[32]=_=>ct.unref(l).docommand("MxTest_SelectEntitysToBlock"))}," 选择实体做块 ")]),ct.createElementVNode("div",gM,[ct.createElementVNode("button",{class:"button button2",onClick:p[33]||(p[33]=_=>ct.unref(l).docommand("Mx_Test_Text"))}," 绘制单行文字 "),ct.createElementVNode("button",{class:"button button2",onClick:p[34]||(p[34]=_=>ct.unref(l).docommand("MxTest_DrawHatchFormPoint"))}," 选点填充 "),ct.createElementVNode("button",{class:"button button2",onClick:p[35]||(p[35]=_=>ct.unref(l).docommand("Mx_TestExProp"))}," 设置扩展属性 "),ct.createElementVNode("button",{class:"button button2",onClick:p[36]||(p[36]=_=>ct.unref(l).docommand("Mx_Test_DimAligned"))}," 绘制对齐标注 ")]),ct.createElementVNode("div",_M,[ct.createElementVNode("button",{class:"button button2",onClick:p[37]||(p[37]=_=>ct.unref(l).docommand("Mx_Test_DrawDimRotated"))}," 绘性线标注 "),ct.createElementVNode("button",{class:"button button2",onClick:p[38]||(p[38]=_=>ct.unref(l).docommand("Mx_Test_DrawDimAngular"))}," 角度标注 "),ct.createElementVNode("button",{class:"button button2",onClick:p[39]||(p[39]=_=>ct.unref(l).docommand("MxTest_LineTypeTest"))}," 修改对象线型 "),ct.createElementVNode("button",{class:"button button2",onClick:p[40]||(p[40]=_=>ct.unref(l).docommand("Mx_SelectEntitHideLayer"))}," 选择隐藏对象层 ")]),ct.createElementVNode("div",yM,[ct.createElementVNode("button",{class:"button button2",onClick:p[41]||(p[41]=_=>ct.unref(l).docommand("MxTest_TestAddCurrentSelect"))}," 添加到当前选择 "),ct.createElementVNode("button",{class:"button button2",onClick:p[42]||(p[42]=_=>ct.unref(l).docommand("MxTest_TestSetViewAngle"))}," 视区旋转 "),ct.createElementVNode("button",{class:"button button2",onClick:p[43]||(p[43]=_=>ct.unref(l).docommand("MxTest_WriteXRecord"))}," 写扩展记录 "),ct.createElementVNode("button",{class:"button button2",onClick:p[44]||(p[44]=_=>ct.unref(l).docommand("MxTest_GetNamedObjectsDictionary"))}," 得到命名字典 ")]),ct.createElementVNode("div",vM,[ct.createElementVNode("button",{class:"button button2",onClick:p[45]||(p[45]=_=>ct.unref(l).docommand("MxTest_AddTextStyleTable"))}," 添加文字样式 "),ct.createElementVNode("button",{class:"button button2",onClick:p[46]||(p[46]=_=>ct.unref(l).docommand("MxTest_DrawCustomEntity"))}," 绘自定义实体 "),ct.createElementVNode("button",{class:"button button2",onClick:p[47]||(p[47]=_=>ct.unref(l).docommand("Mx_Test_ChangeColor"))}," 修改对象颜色 "),ct.createElementVNode("button",{class:"button button2",onClick:p[48]||(p[48]=_=>ct.unref(l).docommand("Mx_Test_ChangeVisible"))}," 修改对象不可见 ")]),ct.createElementVNode("div",xM,[ct.createElementVNode("button",{class:"button button2",onClick:p[49]||(p[49]=_=>ct.unref(l).docommand("Mx_Test_ChangeEntityLayer"))}," 修改对象层 "),ct.createElementVNode("button",{class:"button button2",onClick:p[50]||(p[50]=_=>ct.unref(l).docommand("Mx_ChaneEntityDrawOrder"))}," 修改对象显示顺序 "),ct.createElementVNode("button",{class:"button button2",onClick:p[51]||(p[51]=_=>ct.unref(l).docommand("Mx_Export_Pdf"))}," 指定范围输出pdf "),ct.createElementVNode("button",{class:"button button2",onClick:p[52]||(p[52]=_=>ct.unref(l).docommand("Mx_Test_DrawImage"))}," 绘制image ")]),ct.createElementVNode("div",bM,[ct.createElementVNode("button",{class:"button button2",onClick:p[53]||(p[53]=_=>ct.unref(l).docommand("MxTest_GetObjectExDictionaryData"))}," 读取对象扩展字典 ")])])])])):ct.createCommentVNode("",!0)]))}}),iR="",t0=(e,n)=>{const i=e.__vccOpts||e;for(const[l,h]of n)i[l]=h;return i},MM=t0(wM,[["__scopeId","data-v-9bd7093d"],["__file","Modal.vue"]]),TM=t0(ct.defineComponent({__name:"Test",setup(e){return(n,i)=>(ct.openBlock(),ct.createElementBlock("div",null,[ct.createVNode(MM)]))}}),[["__file","Test.vue"]]),EM={init(){tt.MxFun.setPostMessageToParentFrameFunction(function(e){top.postMessage(e,"*")}),window.addEventListener("message",function(e){e.data.type==="sendStringToExecute"?tt.MxFun.sendStringToExecute(e.data.cmd,e.data):(console.log("mx:unprocessed message:"),console.log(e.data))},!1)}};function SM(){EM.init()}function AM(){return wn(this,null,function*(){const e=new tt.MrxDbgUiPrPoint;e.setMessage(` 指定第一点:`),e.go(n=>{if(n!=0)return;const i=e.value();let l=new tt.MxDbLeadComment;l.point1=i.clone(),l.textHeight=tt.MxFun.screenCoordLong2Doc(50),l.text="测试Test1",l.textWidth=tt.MxFun.screenCoordLong2Doc(300),l.fixedSize=!0,l.fixedSize&&(l.textHeight=50,l.textWidth=250),l.color=te.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();const h=new tt.McEdGetPointWorldDrawObject;h.setDraw((p,_)=>{l.point2=p,_.drawCustomEntity(l)}),e.setBasePt(i),e.setUseBasePt(!0),e.setUserDraw(h),e.setMessage(` 指定第二点:`),e.go(p=>{if(p!=0){console.log(p);return}const _=e.value();l.point2=_,tt.MxFun.addToCurrentSpace(l)})})})}function CM(){tt.MxFun.getCurrentDraw().createCanvasImageData(e=>{const n=window.open();n!=null&&(n.document.write(''),setTimeout(()=>{n.print()},300))},{width:349,height:536})}function PM(){return wn(this,null,function*(){let e=te.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();const n=new tt.MrxDbgUiPrPoint,i=tt.MxFun.getCurrentDraw(),l=new tt.McEdGetPointWorldDrawObject,h=new tt.MxDbRectBoxLeadComment;h.color=e.getHex(),h.color==0&&(h.color=65793),h.radius=tt.MxFun.screenCoordLong2Doc(8),h.setLineWidth(3),h.setLineWidthByPixels(!0),n.setMessage(` 云线框起始点:`),n.go(p=>{p==tt.MrxDbgUiPrBaseReturn.kOk&&(h.point1=n.value(),l.setDraw(_=>{h.point2=_,l.drawCustomEntity(h)}),n.setUserDraw(l),n.setMessage(` 云线框结束点:`),n.go(_=>{_==tt.MrxDbgUiPrBaseReturn.kOk&&(h.point2=n.value(),l.setDraw(s=>{h.point3=s,l.drawCustomEntity(h)}),h.text="审图批注XXXXXXXXXX",h.textWidth=tt.MxFun.screenCoordLong2Doc(200),h.textHeight=tt.MxFun.screenCoordLong2Doc(50),h.fixedSize=!0,h.fixedSize&&(h.textHeight=20,h.textWidth=230),n.setMessage(` 审图标注点:`),n.go(s=>{s==tt.MrxDbgUiPrBaseReturn.kOk&&(h.point3=n.value(),i.addMxEntity(h))}))}))})})}function Vg(e,n){let i=tt.MxFun.screenCoordLong2World(n?e:e-e/3);return i=tt.MxFun.worldCoordLong2Doc(i),i}function LM(){const e=new tt.McEdGetPointWorldDrawObject,n=new tt.MxDbArrow,i=tt.MxFun.getCurrentDraw(),l=new tt.MrxDbgUiPrPoint;l.setUserDraw(e),n.setLineWidth(10),n.innerOffset=Vg(10),n.outerOffset=Vg(22),n.topOffset=Vg(36),n.color=te.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor(),l.go(()=>{n.startPoint=l.value(),e.setDraw(h=>{n.endPoint=h,e.drawCustomEntity(n)}),l.go(h=>wn(this,null,function*(){n.endPoint=l.value(),i.addMxEntity(n)}))})}function DM(){const e=new tt.MrxDbgUiPrPoint,n=tt.MxFun.getCurrentDraw(),i=new tt.McEdGetPointWorldDrawObject,l=tt.MxFun.screenCoordLong2Doc(16);e.setMessage(` 点击开启绘制云线:`),e.go(()=>{let h=e.value();const p=new tt.MxDbCloudLine;p.setRadius(l),p.addPoint(h),p.color=te.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor(),i.setDraw(_=>{h.distanceTo(_)>l&&(h=_.clone(),p.addPoint(_,!0)),i.drawCustomEntity(p)}),e.setUserDraw(i),e.setMessage(` 再次点击结束绘制云线:`),e.go(()=>{n.addMxEntity(p)})})}let Np="";function IM(){Np=tt.MxFun.getCurrentDraw().saveMxEntityToJson(),console.log(Np)}function RM(){return wn(this,null,function*(){if(Np.length==0)return;let e=tt.MxFun.getCurrentDraw();yield e.loadMxEntityFromJson(Np,["models/svg/mark.svg"]),e.updateDisplay()})}function zM(){const e=new tt.MrxDbgUiPrPoint;e.setMessage(` 指定第一点:`),e.go(n=>{if(n!=0)return;const i=e.value();let l=new tt.MxDbArea;l.addPoint(i),l.color=te.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();const h=new tt.McEdGetPointWorldDrawObject;h.setDraw((p,_)=>{let s=l.clone();s.addPoint(p),h.drawCustomEntity(s)}),e.setUserDraw(h),e.setMessage(` 指定下一点:`),e.goWhile(p=>{if(p==0){const _=e.value();l.addPoint(_)}},p=>{l.isFill=!0,l.fillOpacity=.7,l.fillColor=6697540,tt.MxFun.getCurrentDraw().addMxEntity(l)})})}function kM(){tt.MxFun.addCommand("BR_Comment",AM),tt.MxFun.addCommand("BR_CheckDraw",PM),tt.MxFun.addCommand("BR_Arrow",LM),tt.MxFun.addCommand("BR_CloudLine",DM),tt.MxFun.addCommand("BR_Print",CM),tt.MxFun.addCommand("BR_SaveAllMxEntity",IM),tt.MxFun.addCommand("BR_LoadAllMxEntity",RM),tt.MxFun.addCommand("BR_Area",zM)}function BM(){let e=te.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 te.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 te.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 FM(){let e=te.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 te.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 OM(){let e=te.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 te.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 NM(){let e=te.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 te.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 te.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 te.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 te.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 te.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 te.McCmColor(255,255,25),e.drawLinetype="MyLineType3",e.drawPathToPolyline(),e.zoomAll(),e.regen(),e.updateDisplay()}function UM(){let e=te.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 te.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 te.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 te.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 VM(){let e=te.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.addLayer("TextLayer"),e.drawLayer="TextLayer",e.drawText(0,1900,"绘图控件文字测试",100,0,0,1),e.drawColor=new te.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 te.McCmColor(255,0,0),e.drawText(0,3e3,"绘图控件文字测试",100,0,0,1),e.AddTureTypeTextStyle("MyTrueTypeTextStyle"),e.drawTextStyle="MyTrueTypeTextStyle",e.drawColor=new te.McCmColor(200,255,50),e.drawText(0,3500,"绘图控件TrueType文字测试",100,0,0,1),e.zoomAll(),e.regen(),e.updateDisplay()}function GM(){let e=te.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 te.McCmColor(200,0,0),e.drawEllipse(200,1400,80,30,.5),e.zoomAll(),e.regen(),e.updateDisplay()}function HM(){let e=te.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 te.McCmColor(200,200,0),e.drawEllipseArc(200,1600,-80,30,.5,60,300),e.drawLinetype="",e.zoomAll(),e.regen(),e.updateDisplay()}function WM(){let e=te.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 jM(e){if(!e||!e.param)return;let n=te.MxCpp.getCurrentMxCAD();n.newFile(),n.drawColorIndex=0,n.drawLinetype="",n.drawLineWidth=0,n.addLayer("LineLayer"),n.drawLayer="LineLayer",n.drawLine(e.param.x1,e.param.y1,e.param.x2,e.param.y2),n.zoomAll(),n.updateDisplay(),tt.MxFun.postMessageToParentFrame({cmd:"Mx_ParamDrawLine",message:"ok"})}function qM(){let e=te.MxCpp.getCurrentMxCAD();e.newFile(),e.drawText(350831.77,1940511845e-2,"1.034",10,0,te.McDb.TextHorzMode.kTextLeft,te.McDb.TextVertMode.kTextVertMid),e.zoomAll(),e.regen(100)}function ZM(){let e=te.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 XM(){let e=te.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.drawDimRotated(0,7e3,600,7e3,250,7050,0),e.drawDimRotated(0,7200,0,7600,150,7300,.771),e.zoomAll(),e.updateDisplay()}function YM(){let e=te.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 $M(){tt.MxFun.addCommand("Mx_Test_DrawLine",BM),tt.MxFun.addCommand("Mx_Test_DrawArc",FM),tt.MxFun.addCommand("Mx_Test_DrawCircle",OM),tt.MxFun.addCommand("Mx_Test_DrawPolyline",NM),tt.MxFun.addCommand("Mx_Test_DrawHatch",UM),tt.MxFun.addCommand("Mx_Test_DrawText",VM),tt.MxFun.addCommand("Mx_Test_Ellipse",GM),tt.MxFun.addCommand("Mx_Test_EllipseArc",HM),tt.MxFun.addCommand("Mx_Test_MText",WM),tt.MxFun.addCommand("Mx_Test_Text",qM),tt.MxFun.addCommand("Mx_ParamDrawLine",jM),tt.MxFun.addCommand("Mx_Test_DimAligned",ZM),tt.MxFun.addCommand("Mx_Test_DrawDimRotated",XM),tt.MxFun.addCommand("Mx_Test_DrawDimAngular",YM)}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 n=Object(e),i=1;i>8&255]+or[e>>16&255]+or[e>>24&255]+"-"+or[n&255]+or[n>>8&255]+"-"+or[n>>16&15|64]+or[n>>24&255]+"-"+or[i&63|128]+or[i>>8&255]+"-"+or[i>>16&255]+or[i>>24&255]+or[l&255]+or[l>>8&255]+or[l>>16&255]+or[l>>24&255];return h.toUpperCase()},clamp:function(e,n,i){return Math.max(n,Math.min(i,e))},euclideanModulo:function(e,n){return(e%n+n)%n},mapLinear:function(e,n,i,l,h){return l+(e-n)*(h-l)/(i-n)},lerp:function(e,n,i){return(1-i)*e+i*n},smoothstep:function(e,n,i){return e<=n?0:e>=i?1:(e=(e-n)/(i-n),e*e*(3-2*e))},smootherstep:function(e,n,i){return e<=n?0:e>=i?1:(e=(e-n)/(i-n),e*e*e*(e*(e*6-15)+10))},randInt:function(e,n){return e+Math.floor(Math.random()*(n-e+1))},randFloat:function(e,n){return e+Math.random()*(n-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*Wn.DEG2RAD},radToDeg:function(e){return e*Wn.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,n,i,l,h){var p=Math.cos,_=Math.sin,s=p(i/2),M=_(i/2),T=p((n+l)/2),C=_((n+l)/2),E=p((n-l)/2),L=_((n-l)/2),I=p((l-n)/2),B=_((l-n)/2);h==="XYX"?e.set(s*C,M*E,M*L,s*T):h==="YZY"?e.set(M*L,s*C,M*E,s*T):h==="ZXZ"?e.set(M*E,M*L,s*C,s*T):h==="XZX"?e.set(s*C,M*B,M*I,s*T):h==="YXY"?e.set(M*I,s*C,M*B,s*T):h==="ZYZ"?e.set(M*B,M*I,s*C,s*T):console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order.")}};function Lt(e,n){this.x=e||0,this.y=n||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,n){return this.x=e,this.y=n,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,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this},getComponent: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,n){return n!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,n)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this},addScaledVector:function(e,n){return this.x+=e.x*n,this.y+=e.y*n,this},sub:function(e,n){return n!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,n)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,n){return this.x=e.x-n.x,this.y=e.y-n.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 n=this.x,i=this.y,l=e.elements;return this.x=l[0]*n+l[3]*i+l[6],this.y=l[1]*n+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,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this},clampScalar:function(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this},clampLength:function(e,n){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(n,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 n=this.x-e.x,i=this.y-e.y;return n*n+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,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this},lerpVectors:function(e,n,i){return this.subVectors(n,e).multiplyScalar(i).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,n){return n===void 0&&(n=0),this.x=e[n],this.y=e[n+1],this},toArray:function(e,n){return e===void 0&&(e=[]),n===void 0&&(n=0),e[n]=this.x,e[n+1]=this.y,e},fromBufferAttribute:function(e,n,i){return i!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(n),this.y=e.getY(n),this},rotateAround:function(e,n){var i=Math.cos(n),l=Math.sin(n),h=this.x-e.x,p=this.y-e.y;return this.x=h*i-p*l+e.x,this.y=h*l+p*i+e.y,this}});function dr(){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(dr.prototype,{isMatrix3:!0,set:function(e,n,i,l,h,p,_,s,M){var T=this.elements;return T[0]=e,T[1]=l,T[2]=_,T[3]=n,T[4]=h,T[5]=s,T[6]=i,T[7]=p,T[8]=M,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 n=this.elements,i=e.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],this},setFromMatrix4:function(e){var n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this},multiply:function(e){return this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,n){var i=e.elements,l=n.elements,h=this.elements,p=i[0],_=i[3],s=i[6],M=i[1],T=i[4],C=i[7],E=i[2],L=i[5],I=i[8],B=l[0],O=l[3],U=l[6],q=l[1],ee=l[4],he=l[7],Ce=l[2],K=l[5],ie=l[8];return h[0]=p*B+_*q+s*Ce,h[3]=p*O+_*ee+s*K,h[6]=p*U+_*he+s*ie,h[1]=M*B+T*q+C*Ce,h[4]=M*O+T*ee+C*K,h[7]=M*U+T*he+C*ie,h[2]=E*B+L*q+I*Ce,h[5]=E*O+L*ee+I*K,h[8]=E*U+L*he+I*ie,this},multiplyScalar:function(e){var n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this},determinant:function(){var e=this.elements,n=e[0],i=e[1],l=e[2],h=e[3],p=e[4],_=e[5],s=e[6],M=e[7],T=e[8];return n*p*T-n*_*M-i*h*T+i*_*s+l*h*M-l*p*s},getInverse:function(e,n){e&&e.isMatrix4&&console.error("THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument.");var i=e.elements,l=this.elements,h=i[0],p=i[1],_=i[2],s=i[3],M=i[4],T=i[5],C=i[6],E=i[7],L=i[8],I=L*M-T*E,B=T*C-L*s,O=E*s-M*C,U=h*I+p*B+_*O;if(U===0){var q="THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0";if(n===!0)throw new Error(q);return console.warn(q),this.identity()}var ee=1/U;return l[0]=I*ee,l[1]=(_*E-L*p)*ee,l[2]=(T*p-_*M)*ee,l[3]=B*ee,l[4]=(L*h-_*C)*ee,l[5]=(_*s-T*h)*ee,l[6]=O*ee,l[7]=(p*C-E*h)*ee,l[8]=(M*h-p*s)*ee,this},transpose:function(){var e,n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this},getNormalMatrix:function(e){return this.setFromMatrix4(e).getInverse(this).transpose()},transposeIntoArray:function(e){var n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this},setUvTransform:function(e,n,i,l,h,p,_){var s=Math.cos(h),M=Math.sin(h);this.set(i*s,i*M,-i*(s*p+M*_)+p+e,-l*M,l*s,-l*(-M*p+s*_)+_+n,0,0,1)},scale:function(e,n){var i=this.elements;return i[0]*=e,i[3]*=e,i[6]*=e,i[1]*=n,i[4]*=n,i[7]*=n,this},rotate:function(e){var n=Math.cos(e),i=Math.sin(e),l=this.elements,h=l[0],p=l[3],_=l[6],s=l[1],M=l[4],T=l[7];return l[0]=n*h+i*s,l[3]=n*p+i*M,l[6]=n*_+i*T,l[1]=-i*h+n*s,l[4]=-i*p+n*M,l[7]=-i*_+n*T,this},translate:function(e,n){var i=this.elements;return i[0]+=e*i[2],i[3]+=e*i[5],i[6]+=e*i[8],i[1]+=n*i[2],i[4]+=n*i[5],i[7]+=n*i[8],this},equals:function(e){for(var n=this.elements,i=e.elements,l=0;l<9;l++)if(n[l]!==i[l])return!1;return!0},fromArray:function(e,n){n===void 0&&(n=0);for(var i=0;i<9;i++)this.elements[i]=e[i+n];return this},toArray:function(e,n){e===void 0&&(e=[]),n===void 0&&(n=0);var i=this.elements;return e[n]=i[0],e[n+1]=i[1],e[n+2]=i[2],e[n+3]=i[3],e[n+4]=i[4],e[n+5]=i[5],e[n+6]=i[6],e[n+7]=i[7],e[n+8]=i[8],e}});var ac,Ys={getDataURL:function(e){var n;if(typeof HTMLCanvasElement=="undefined")return e.src;if(e instanceof HTMLCanvasElement)n=e;else{ac===void 0&&(ac=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),ac.width=e.width,ac.height=e.height;var i=ac.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=ac}return n.width>2048||n.height>2048?n.toDataURL("image/jpeg",.6):n.toDataURL("image/png")}},f2=0;function mi(e,n,i,l,h,p,_,s,M,T){Object.defineProperty(this,"id",{value:f2++}),this.uuid=Wn.generateUUID(),this.name="",this.image=e!==void 0?e:mi.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=n!==void 0?n:mi.DEFAULT_MAPPING,this.wrapS=i!==void 0?i:wr,this.wrapT=l!==void 0?l:wr,this.magFilter=h!==void 0?h:qi,this.minFilter=p!==void 0?p:ec,this.anisotropy=M!==void 0?M:1,this.format=_!==void 0?_:Aa,this.internalFormat=null,this.type=s!==void 0?s:Wp,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 dr,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=T!==void 0?T:ia,this.version=0,this.onUpdate=null}mi.DEFAULT_IMAGE=void 0,mi.DEFAULT_MAPPING=Wg,mi.prototype=Object.assign(Object.create(To.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 n=e===void 0||typeof e=="string";if(!n&&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=Wn.generateUUID()),!n&&e.images[l.uuid]===void 0){var h;if(Array.isArray(l)){h=[];for(var p=0,_=l.length;p<_;p++)h.push(Ys.getDataURL(l[p]))}else h=Ys.getDataURL(l);e.images[l.uuid]={uuid:l.uuid,url:h}}i.image=l.uuid}return n||(e.textures[this.uuid]=i),i},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(e){if(this.mapping!==Wg)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 wr:e.x=e.x<0?0:1;break;case sh: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 wr:e.y=e.y<0?0:1;break;case sh: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,n,i,l){this.x=e||0,this.y=n||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,n,i,l){return this.x=e,this.y=n,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,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this},getComponent: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,n){return n!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,n)):(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,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this},addScaledVector:function(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this},sub:function(e,n){return n!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,n)):(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,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var n=this.x,i=this.y,l=this.z,h=this.w,p=e.elements;return this.x=p[0]*n+p[4]*i+p[8]*l+p[12]*h,this.y=p[1]*n+p[5]*i+p[9]*l+p[13]*h,this.z=p[2]*n+p[6]*i+p[10]*l+p[14]*h,this.w=p[3]*n+p[7]*i+p[11]*l+p[15]*h,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this},setAxisAngleFromRotationMatrix:function(e){var n,i,l,h,p=.01,_=.1,s=e.elements,M=s[0],T=s[4],C=s[8],E=s[1],L=s[5],I=s[9],B=s[2],O=s[6],U=s[10];if(Math.abs(T-E)ee&&q>he?qhe?ee=0?1:-1,ee=1-U*U;if(ee>Number.EPSILON){var he=Math.sqrt(ee),Ce=Math.atan2(he,U*q);O=Math.sin(O*Ce)/he,_=Math.sin(_*Ce)/he}var K=_*q;if(s=s*O+E*K,M=M*O+L*K,T=T*O+I*K,C=C*O+B*K,O===1-_){var ie=1/Math.sqrt(s*s+M*M+T*T+C*C);s*=ie,M*=ie,T*=ie,C*=ie}}e[n]=s,e[n+1]=M,e[n+2]=T,e[n+3]=C}}),Object.defineProperties(Or.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(Or.prototype,{isQuaternion:!0,set:function(e,n,i,l){return this._x=e,this._y=n,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,n){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,h=e._z,p=e.order,_=Math.cos,s=Math.sin,M=_(i/2),T=_(l/2),C=_(h/2),E=s(i/2),L=s(l/2),I=s(h/2);return p==="XYZ"?(this._x=E*T*C+M*L*I,this._y=M*L*C-E*T*I,this._z=M*T*I+E*L*C,this._w=M*T*C-E*L*I):p==="YXZ"?(this._x=E*T*C+M*L*I,this._y=M*L*C-E*T*I,this._z=M*T*I-E*L*C,this._w=M*T*C+E*L*I):p==="ZXY"?(this._x=E*T*C-M*L*I,this._y=M*L*C+E*T*I,this._z=M*T*I+E*L*C,this._w=M*T*C-E*L*I):p==="ZYX"?(this._x=E*T*C-M*L*I,this._y=M*L*C+E*T*I,this._z=M*T*I-E*L*C,this._w=M*T*C+E*L*I):p==="YZX"?(this._x=E*T*C+M*L*I,this._y=M*L*C+E*T*I,this._z=M*T*I-E*L*C,this._w=M*T*C-E*L*I):p==="XZY"&&(this._x=E*T*C-M*L*I,this._y=M*L*C-E*T*I,this._z=M*T*I+E*L*C,this._w=M*T*C+E*L*I),n!==!1&&this._onChangeCallback(),this},setFromAxisAngle:function(e,n){var i=n/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 n=e.elements,i=n[0],l=n[4],h=n[8],p=n[1],_=n[5],s=n[9],M=n[2],T=n[6],C=n[10],E=i+_+C,L;return E>0?(L=.5/Math.sqrt(E+1),this._w=.25/L,this._x=(T-s)*L,this._y=(h-M)*L,this._z=(p-l)*L):i>_&&i>C?(L=2*Math.sqrt(1+i-_-C),this._w=(T-s)/L,this._x=.25*L,this._y=(l+p)/L,this._z=(h+M)/L):_>C?(L=2*Math.sqrt(1+_-i-C),this._w=(h-M)/L,this._x=(l+p)/L,this._y=.25*L,this._z=(s+T)/L):(L=2*Math.sqrt(1+C-i-_),this._w=(p-l)/L,this._x=(h+M)/L,this._y=(s+T)/L,this._z=.25*L),this._onChangeCallback(),this},setFromUnitVectors:function(e,n){var i=1e-6,l=e.dot(n)+1;return lMath.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*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=l),this.normalize()},angleTo:function(e){return 2*Math.acos(Math.abs(Wn.clamp(this.dot(e),-1,1)))},rotateTowards:function(e,n){var i=this.angleTo(e);if(i===0)return this;var l=Math.min(1,n/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,n){return n!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,n)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,n){var i=e._x,l=e._y,h=e._z,p=e._w,_=n._x,s=n._y,M=n._z,T=n._w;return this._x=i*T+p*_+l*M-h*s,this._y=l*T+p*s+h*_-i*M,this._z=h*T+p*M+i*s-l*_,this._w=p*T-i*_-l*s-h*M,this._onChangeCallback(),this},slerp:function(e,n){if(n===0)return this;if(n===1)return this.copy(e);var i=this._x,l=this._y,h=this._z,p=this._w,_=p*e._w+i*e._x+l*e._y+h*e._z;if(_<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,_=-_):this.copy(e),_>=1)return this._w=p,this._x=i,this._y=l,this._z=h,this;var s=1-_*_;if(s<=Number.EPSILON){var M=1-n;return this._w=M*p+n*this._w,this._x=M*i+n*this._x,this._y=M*l+n*this._y,this._z=M*h+n*this._z,this.normalize(),this._onChangeCallback(),this}var T=Math.sqrt(s),C=Math.atan2(T,_),E=Math.sin((1-n)*C)/T,L=Math.sin(n*C)/T;return this._w=p*E+this._w*L,this._x=i*E+this._x*L,this._y=l*E+this._y*L,this._z=h*E+this._z*L,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,n){return n===void 0&&(n=0),this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this},toArray:function(e,n){return e===void 0&&(e=[]),n===void 0&&(n=0),e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e},_onChange:function(e){return this._onChangeCallback=e,this},_onChangeCallback:function(){}});var e_=new Ee,L0=new Or;function Ee(e,n,i){this.x=e||0,this.y=n||0,this.z=i||0}Object.assign(Ee.prototype,{isVector3:!0,set:function(e,n,i){return this.x=e,this.y=n,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,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this},getComponent: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,n){return n!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,n)):(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,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this},addScaledVector:function(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this},sub:function(e,n){return n!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,n)):(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,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this},multiply:function(e,n){return n!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,n)):(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,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.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(L0.setFromEuler(e))},applyAxisAngle:function(e,n){return this.applyQuaternion(L0.setFromAxisAngle(e,n))},applyMatrix3:function(e){var n=this.x,i=this.y,l=this.z,h=e.elements;return this.x=h[0]*n+h[3]*i+h[6]*l,this.y=h[1]*n+h[4]*i+h[7]*l,this.z=h[2]*n+h[5]*i+h[8]*l,this},applyNormalMatrix:function(e){return this.applyMatrix3(e).normalize()},applyMatrix4:function(e){var n=this.x,i=this.y,l=this.z,h=e.elements,p=1/(h[3]*n+h[7]*i+h[11]*l+h[15]);return this.x=(h[0]*n+h[4]*i+h[8]*l+h[12])*p,this.y=(h[1]*n+h[5]*i+h[9]*l+h[13])*p,this.z=(h[2]*n+h[6]*i+h[10]*l+h[14])*p,this},applyQuaternion:function(e){var n=this.x,i=this.y,l=this.z,h=e.x,p=e.y,_=e.z,s=e.w,M=s*n+p*l-_*i,T=s*i+_*n-h*l,C=s*l+h*i-p*n,E=-h*n-p*i-_*l;return this.x=M*s+E*-h+T*-_-C*-p,this.y=T*s+E*-p+C*-h-M*-_,this.z=C*s+E*-_+M*-p-T*-h,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 n=this.x,i=this.y,l=this.z,h=e.elements;return this.x=h[0]*n+h[4]*i+h[8]*l,this.y=h[1]*n+h[5]*i+h[9]*l,this.z=h[2]*n+h[6]*i+h[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,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this},clampScalar:function(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this},clampLength:function(e,n){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(n,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,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this},lerpVectors:function(e,n,i){return this.subVectors(n,e).multiplyScalar(i).add(e)},cross:function(e,n){return n!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,n)):this.crossVectors(this,e)},crossVectors:function(e,n){var i=e.x,l=e.y,h=e.z,p=n.x,_=n.y,s=n.z;return this.x=l*s-h*_,this.y=h*p-i*s,this.z=i*_-l*p,this},projectOnVector:function(e){var n=e.lengthSq();if(n===0)return this.set(0,0,0);var i=e.dot(this)/n;return this.copy(e).multiplyScalar(i)},projectOnPlane:function(e){return e_.copy(this).projectOnVector(e),this.sub(e_)},reflect:function(e){return this.sub(e_.copy(e).multiplyScalar(2*this.dot(e)))},angleTo:function(e){var n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;var i=this.dot(e)/n;return Math.acos(Wn.clamp(i,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var n=this.x-e.x,i=this.y-e.y,l=this.z-e.z;return n*n+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,n,i){var l=Math.sin(n)*e;return this.x=l*Math.sin(i),this.y=Math.cos(n)*e,this.z=l*Math.cos(i),this},setFromCylindrical:function(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)},setFromCylindricalCoords:function(e,n,i){return this.x=e*Math.sin(n),this.y=i,this.z=e*Math.cos(n),this},setFromMatrixPosition:function(e){var n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this},setFromMatrixScale:function(e){var n=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),l=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=i,this.z=l,this},setFromMatrixColumn:function(e,n){return this.fromArray(e.elements,n*4)},setFromMatrix3Column:function(e,n){return this.fromArray(e.elements,n*3)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,n){return n===void 0&&(n=0),this.x=e[n],this.y=e[n+1],this.z=e[n+2],this},toArray:function(e,n){return e===void 0&&(e=[]),n===void 0&&(n=0),e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e},fromBufferAttribute:function(e,n,i){return i!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}});var oc=new Ee,Ca=new jn,m2=new Ee(0,0,0),g2=new Ee(1,1,1),es=new Ee,Yp=new Ee,ra=new Ee;function jn(){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(jn.prototype,{isMatrix4:!0,set:function(e,n,i,l,h,p,_,s,M,T,C,E,L,I,B,O){var U=this.elements;return U[0]=e,U[4]=n,U[8]=i,U[12]=l,U[1]=h,U[5]=p,U[9]=_,U[13]=s,U[2]=M,U[6]=T,U[10]=C,U[14]=E,U[3]=L,U[7]=I,U[11]=B,U[15]=O,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 jn().fromArray(this.elements)},copy:function(e){var n=this.elements,i=e.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],n[9]=i[9],n[10]=i[10],n[11]=i[11],n[12]=i[12],n[13]=i[13],n[14]=i[14],n[15]=i[15],this},copyPosition:function(e){var n=this.elements,i=e.elements;return n[12]=i[12],n[13]=i[13],n[14]=i[14],this},extractBasis:function(e,n,i){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(e,n,i){return this.set(e.x,n.x,i.x,0,e.y,n.y,i.y,0,e.z,n.z,i.z,0,0,0,0,1),this},extractRotation:function(e){var n=this.elements,i=e.elements,l=1/oc.setFromMatrixColumn(e,0).length(),h=1/oc.setFromMatrixColumn(e,1).length(),p=1/oc.setFromMatrixColumn(e,2).length();return n[0]=i[0]*l,n[1]=i[1]*l,n[2]=i[2]*l,n[3]=0,n[4]=i[4]*h,n[5]=i[5]*h,n[6]=i[6]*h,n[7]=0,n[8]=i[8]*p,n[9]=i[9]*p,n[10]=i[10]*p,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[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 n=this.elements,i=e.x,l=e.y,h=e.z,p=Math.cos(i),_=Math.sin(i),s=Math.cos(l),M=Math.sin(l),T=Math.cos(h),C=Math.sin(h);if(e.order==="XYZ"){var E=p*T,L=p*C,I=_*T,B=_*C;n[0]=s*T,n[4]=-s*C,n[8]=M,n[1]=L+I*M,n[5]=E-B*M,n[9]=-_*s,n[2]=B-E*M,n[6]=I+L*M,n[10]=p*s}else if(e.order==="YXZ"){var O=s*T,U=s*C,q=M*T,ee=M*C;n[0]=O+ee*_,n[4]=q*_-U,n[8]=p*M,n[1]=p*C,n[5]=p*T,n[9]=-_,n[2]=U*_-q,n[6]=ee+O*_,n[10]=p*s}else if(e.order==="ZXY"){var O=s*T,U=s*C,q=M*T,ee=M*C;n[0]=O-ee*_,n[4]=-p*C,n[8]=q+U*_,n[1]=U+q*_,n[5]=p*T,n[9]=ee-O*_,n[2]=-p*M,n[6]=_,n[10]=p*s}else if(e.order==="ZYX"){var E=p*T,L=p*C,I=_*T,B=_*C;n[0]=s*T,n[4]=I*M-L,n[8]=E*M+B,n[1]=s*C,n[5]=B*M+E,n[9]=L*M-I,n[2]=-M,n[6]=_*s,n[10]=p*s}else if(e.order==="YZX"){var he=p*s,Ce=p*M,K=_*s,ie=_*M;n[0]=s*T,n[4]=ie-he*C,n[8]=K*C+Ce,n[1]=C,n[5]=p*T,n[9]=-_*T,n[2]=-M*T,n[6]=Ce*C+K,n[10]=he-ie*C}else if(e.order==="XZY"){var he=p*s,Ce=p*M,K=_*s,ie=_*M;n[0]=s*T,n[4]=-C,n[8]=M*T,n[1]=he*C+ie,n[5]=p*T,n[9]=Ce*C-K,n[2]=K*C-Ce,n[6]=_*T,n[10]=ie*C+he}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this},makeRotationFromQuaternion:function(e){return this.compose(m2,e,g2)},lookAt:function(e,n,i){var l=this.elements;return ra.subVectors(e,n),ra.lengthSq()===0&&(ra.z=1),ra.normalize(),es.crossVectors(i,ra),es.lengthSq()===0&&(Math.abs(i.z)===1?ra.x+=1e-4:ra.z+=1e-4,ra.normalize(),es.crossVectors(i,ra)),es.normalize(),Yp.crossVectors(ra,es),l[0]=es.x,l[4]=Yp.x,l[8]=ra.x,l[1]=es.y,l[5]=Yp.y,l[9]=ra.y,l[2]=es.z,l[6]=Yp.z,l[10]=ra.z,this},multiply:function(e,n){return n!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,n)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,n){var i=e.elements,l=n.elements,h=this.elements,p=i[0],_=i[4],s=i[8],M=i[12],T=i[1],C=i[5],E=i[9],L=i[13],I=i[2],B=i[6],O=i[10],U=i[14],q=i[3],ee=i[7],he=i[11],Ce=i[15],K=l[0],ie=l[4],ue=l[8],ae=l[12],le=l[1],De=l[5],ye=l[9],se=l[13],Ue=l[2],Oe=l[6],We=l[10],st=l[14],St=l[3],gt=l[7],At=l[11],Dt=l[15];return h[0]=p*K+_*le+s*Ue+M*St,h[4]=p*ie+_*De+s*Oe+M*gt,h[8]=p*ue+_*ye+s*We+M*At,h[12]=p*ae+_*se+s*st+M*Dt,h[1]=T*K+C*le+E*Ue+L*St,h[5]=T*ie+C*De+E*Oe+L*gt,h[9]=T*ue+C*ye+E*We+L*At,h[13]=T*ae+C*se+E*st+L*Dt,h[2]=I*K+B*le+O*Ue+U*St,h[6]=I*ie+B*De+O*Oe+U*gt,h[10]=I*ue+B*ye+O*We+U*At,h[14]=I*ae+B*se+O*st+U*Dt,h[3]=q*K+ee*le+he*Ue+Ce*St,h[7]=q*ie+ee*De+he*Oe+Ce*gt,h[11]=q*ue+ee*ye+he*We+Ce*At,h[15]=q*ae+ee*se+he*st+Ce*Dt,this},multiplyScalar:function(e){var n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this},determinant:function(){var e=this.elements,n=e[0],i=e[4],l=e[8],h=e[12],p=e[1],_=e[5],s=e[9],M=e[13],T=e[2],C=e[6],E=e[10],L=e[14],I=e[3],B=e[7],O=e[11],U=e[15];return I*(+h*s*C-l*M*C-h*_*E+i*M*E+l*_*L-i*s*L)+B*(+n*s*L-n*M*E+h*p*E-l*p*L+l*M*T-h*s*T)+O*(+n*M*C-n*_*L-h*p*C+i*p*L+h*_*T-i*M*T)+U*(-l*_*T-n*s*C+n*_*E+l*p*C-i*p*E+i*s*T)},transpose:function(){var e=this.elements,n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this},setPosition:function(e,n,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]=n,l[14]=i),this},getInverse:function(e,n){var i=this.elements,l=e.elements,h=l[0],p=l[1],_=l[2],s=l[3],M=l[4],T=l[5],C=l[6],E=l[7],L=l[8],I=l[9],B=l[10],O=l[11],U=l[12],q=l[13],ee=l[14],he=l[15],Ce=I*ee*E-q*B*E+q*C*O-T*ee*O-I*C*he+T*B*he,K=U*B*E-L*ee*E-U*C*O+M*ee*O+L*C*he-M*B*he,ie=L*q*E-U*I*E+U*T*O-M*q*O-L*T*he+M*I*he,ue=U*I*C-L*q*C-U*T*B+M*q*B+L*T*ee-M*I*ee,ae=h*Ce+p*K+_*ie+s*ue;if(ae===0){var le="THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0";if(n===!0)throw new Error(le);return console.warn(le),this.identity()}var De=1/ae;return i[0]=Ce*De,i[1]=(q*B*s-I*ee*s-q*_*O+p*ee*O+I*_*he-p*B*he)*De,i[2]=(T*ee*s-q*C*s+q*_*E-p*ee*E-T*_*he+p*C*he)*De,i[3]=(I*C*s-T*B*s-I*_*E+p*B*E+T*_*O-p*C*O)*De,i[4]=K*De,i[5]=(L*ee*s-U*B*s+U*_*O-h*ee*O-L*_*he+h*B*he)*De,i[6]=(U*C*s-M*ee*s-U*_*E+h*ee*E+M*_*he-h*C*he)*De,i[7]=(M*B*s-L*C*s+L*_*E-h*B*E-M*_*O+h*C*O)*De,i[8]=ie*De,i[9]=(U*I*s-L*q*s-U*p*O+h*q*O+L*p*he-h*I*he)*De,i[10]=(M*q*s-U*T*s+U*p*E-h*q*E-M*p*he+h*T*he)*De,i[11]=(L*T*s-M*I*s-L*p*E+h*I*E+M*p*O-h*T*O)*De,i[12]=ue*De,i[13]=(L*q*_-U*I*_+U*p*B-h*q*B-L*p*ee+h*I*ee)*De,i[14]=(U*T*_-M*q*_-U*p*C+h*q*C+M*p*ee-h*T*ee)*De,i[15]=(M*I*_-L*T*_+L*p*C-h*I*C-M*p*B+h*T*B)*De,this},scale:function(e){var n=this.elements,i=e.x,l=e.y,h=e.z;return n[0]*=i,n[4]*=l,n[8]*=h,n[1]*=i,n[5]*=l,n[9]*=h,n[2]*=i,n[6]*=l,n[10]*=h,n[3]*=i,n[7]*=l,n[11]*=h,this},getMaxScaleOnAxis:function(){var e=this.elements,n=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(n,i,l))},makeTranslation:function(e,n,i){return this.set(1,0,0,e,0,1,0,n,0,0,1,i,0,0,0,1),this},makeRotationX:function(e){var n=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,n,-i,0,0,i,n,0,0,0,0,1),this},makeRotationY:function(e){var n=Math.cos(e),i=Math.sin(e);return this.set(n,0,i,0,0,1,0,0,-i,0,n,0,0,0,0,1),this},makeRotationZ:function(e){var n=Math.cos(e),i=Math.sin(e);return this.set(n,-i,0,0,i,n,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(e,n){var i=Math.cos(n),l=Math.sin(n),h=1-i,p=e.x,_=e.y,s=e.z,M=h*p,T=h*_;return this.set(M*p+i,M*_-l*s,M*s+l*_,0,M*_+l*s,T*_+i,T*s-l*p,0,M*s-l*_,T*s+l*p,h*s*s+i,0,0,0,0,1),this},makeScale:function(e,n,i){return this.set(e,0,0,0,0,n,0,0,0,0,i,0,0,0,0,1),this},makeShear:function(e,n,i){return this.set(1,n,i,0,e,1,i,0,e,n,1,0,0,0,0,1),this},compose:function(e,n,i){var l=this.elements,h=n._x,p=n._y,_=n._z,s=n._w,M=h+h,T=p+p,C=_+_,E=h*M,L=h*T,I=h*C,B=p*T,O=p*C,U=_*C,q=s*M,ee=s*T,he=s*C,Ce=i.x,K=i.y,ie=i.z;return l[0]=(1-(B+U))*Ce,l[1]=(L+he)*Ce,l[2]=(I-ee)*Ce,l[3]=0,l[4]=(L-he)*K,l[5]=(1-(E+U))*K,l[6]=(O+q)*K,l[7]=0,l[8]=(I+ee)*ie,l[9]=(O-q)*ie,l[10]=(1-(E+B))*ie,l[11]=0,l[12]=e.x,l[13]=e.y,l[14]=e.z,l[15]=1,this},decompose:function(e,n,i){var l=this.elements,h=oc.set(l[0],l[1],l[2]).length(),p=oc.set(l[4],l[5],l[6]).length(),_=oc.set(l[8],l[9],l[10]).length(),s=this.determinant();s<0&&(h=-h),e.x=l[12],e.y=l[13],e.z=l[14],Ca.copy(this);var M=1/h,T=1/p,C=1/_;return Ca.elements[0]*=M,Ca.elements[1]*=M,Ca.elements[2]*=M,Ca.elements[4]*=T,Ca.elements[5]*=T,Ca.elements[6]*=T,Ca.elements[8]*=C,Ca.elements[9]*=C,Ca.elements[10]*=C,n.setFromRotationMatrix(Ca),i.x=h,i.y=p,i.z=_,this},makePerspective:function(e,n,i,l,h,p){p===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var _=this.elements,s=2*h/(n-e),M=2*h/(i-l),T=(n+e)/(n-e),C=(i+l)/(i-l),E=-(p+h)/(p-h),L=-2*p*h/(p-h);return _[0]=s,_[4]=0,_[8]=T,_[12]=0,_[1]=0,_[5]=M,_[9]=C,_[13]=0,_[2]=0,_[6]=0,_[10]=E,_[14]=L,_[3]=0,_[7]=0,_[11]=-1,_[15]=0,this},makeOrthographic:function(e,n,i,l,h,p){var _=this.elements,s=1/(n-e),M=1/(i-l),T=1/(p-h),C=(n+e)*s,E=(i+l)*M,L=(p+h)*T;return _[0]=2*s,_[4]=0,_[8]=0,_[12]=-C,_[1]=0,_[5]=2*M,_[9]=0,_[13]=-E,_[2]=0,_[6]=0,_[10]=-2*T,_[14]=-L,_[3]=0,_[7]=0,_[11]=0,_[15]=1,this},equals:function(e){for(var n=this.elements,i=e.elements,l=0;l<16;l++)if(n[l]!==i[l])return!1;return!0},fromArray:function(e,n){n===void 0&&(n=0);for(var i=0;i<16;i++)this.elements[i]=e[i+n];return this},toArray:function(e,n){e===void 0&&(e=[]),n===void 0&&(n=0);var i=this.elements;return e[n]=i[0],e[n+1]=i[1],e[n+2]=i[2],e[n+3]=i[3],e[n+4]=i[4],e[n+5]=i[5],e[n+6]=i[6],e[n+7]=i[7],e[n+8]=i[8],e[n+9]=i[9],e[n+10]=i[10],e[n+11]=i[11],e[n+12]=i[12],e[n+13]=i[13],e[n+14]=i[14],e[n+15]=i[15],e}});var D0=new jn,I0=new Or;function sc(e,n,i,l){this._x=e||0,this._y=n||0,this._z=i||0,this._order=l||sc.DefaultOrder}sc.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],sc.DefaultOrder="XYZ",Object.defineProperties(sc.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(sc.prototype,{isEuler:!0,set:function(e,n,i,l){return this._x=e,this._y=n,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,n,i){var l=Wn.clamp,h=e.elements,p=h[0],_=h[4],s=h[8],M=h[1],T=h[5],C=h[9],E=h[2],L=h[6],I=h[10];return n=n||this._order,n==="XYZ"?(this._y=Math.asin(l(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-C,I),this._z=Math.atan2(-_,p)):(this._x=Math.atan2(L,T),this._z=0)):n==="YXZ"?(this._x=Math.asin(-l(C,-1,1)),Math.abs(C)<.9999999?(this._y=Math.atan2(s,I),this._z=Math.atan2(M,T)):(this._y=Math.atan2(-E,p),this._z=0)):n==="ZXY"?(this._x=Math.asin(l(L,-1,1)),Math.abs(L)<.9999999?(this._y=Math.atan2(-E,I),this._z=Math.atan2(-_,T)):(this._y=0,this._z=Math.atan2(M,p))):n==="ZYX"?(this._y=Math.asin(-l(E,-1,1)),Math.abs(E)<.9999999?(this._x=Math.atan2(L,I),this._z=Math.atan2(M,p)):(this._x=0,this._z=Math.atan2(-_,T))):n==="YZX"?(this._z=Math.asin(l(M,-1,1)),Math.abs(M)<.9999999?(this._x=Math.atan2(-C,T),this._y=Math.atan2(-E,p)):(this._x=0,this._y=Math.atan2(s,I))):n==="XZY"?(this._z=Math.asin(-l(_,-1,1)),Math.abs(_)<.9999999?(this._x=Math.atan2(L,T),this._y=Math.atan2(s,p)):(this._x=Math.atan2(-C,I),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+n),this._order=n,i!==!1&&this._onChangeCallback(),this},setFromQuaternion:function(e,n,i){return D0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(D0,n,i)},setFromVector3:function(e,n){return this.set(e.x,e.y,e.z,n||this._order)},reorder:function(e){return I0.setFromEuler(this),this.setFromQuaternion(I0,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,n){return e===void 0&&(e=[]),n===void 0&&(n=0),e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new Ee(this._x,this._y,this._z)},_onChange:function(e){return this._onChangeCallback=e,this},_onChangeCallback:function(){}});function R0(){this.mask=1}Object.assign(R0.prototype,{set:function(e){this.mask=1<1){for(var n=0;n1){for(var n=0;n0){l.children=[];for(var s=0;s0&&(i.geometries=E),L.length>0&&(i.materials=L),I.length>0&&(i.textures=I),B.length>0&&(i.images=B),_.length>0&&(i.shapes=_)}return i.object=l,i;function O(U){var q=[];for(var ee in U){var he=U[ee];delete he.metadata,q.push(he)}return q}},clone:function(e){return new this.constructor().copy(this,e)},copy:function(e,n){if(n===void 0&&(n=!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)),n===!0)for(var i=0;ih&&(h=T),C>p&&(p=C),E>_&&(_=E)}return this.min.set(n,i,l),this.max.set(h,p,_),this},setFromBufferAttribute:function(e){for(var n=1/0,i=1/0,l=1/0,h=-1/0,p=-1/0,_=-1/0,s=0,M=e.count;sh&&(h=T),C>p&&(p=C),E>_&&(_=E)}return this.min.set(n,i,l),this.max.set(h,p,_),this},setFromPoints:function(e){this.makeEmpty();for(var n=0,i=e.length;nthis.max.x||e.ythis.max.y||e.zthis.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,n){return n===void 0&&(console.warn("THREE.Box3: .getParameter() target is now required"),n=new Ee),n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},intersectsSphere:function(e){return this.clampPoint(e.center,mh),mh.distanceToSquared(e.center)<=e.radius*e.radius},intersectsPlane:function(e){var n,i;return e.normal.x>0?(n=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),n<=-e.constant&&i>=-e.constant},intersectsTriangle:function(e){if(this.isEmpty())return!1;this.getCenter(gh),Kp.subVectors(this.max,gh),cc.subVectors(e.a,gh),uc.subVectors(e.b,gh),hc.subVectors(e.c,gh),ts.subVectors(uc,cc),ns.subVectors(hc,uc),$s.subVectors(cc,hc);var n=[0,-ts.z,ts.y,0,-ns.z,ns.y,0,-$s.z,$s.y,ts.z,0,-ts.x,ns.z,0,-ns.x,$s.z,0,-$s.x,-ts.y,ts.x,0,-ns.y,ns.x,0,-$s.y,$s.x,0];return!t_(n,cc,uc,hc,Kp)||(n=[1,0,0,0,1,0,0,0,1],!t_(n,cc,uc,hc,Kp))?!1:(Qp.crossVectors(ts,ns),n=[Qp.x,Qp.y,Qp.z],t_(n,cc,uc,hc,Kp))},clampPoint:function(e,n){return n===void 0&&(console.warn("THREE.Box3: .clampPoint() target is now required"),n=new Ee),n.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){var n=mh.copy(e).clamp(this.min,this.max);return n.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(mh).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:(Ao[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ao[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ao[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ao[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ao[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ao[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ao[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ao[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ao),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 t_(e,n,i,l,h){var p,_;for(p=0,_=e.length-3;p<=_;p+=3){Js.fromArray(e,p);var s=h.x*Math.abs(Js.x)+h.y*Math.abs(Js.y)+h.z*Math.abs(Js.z),M=n.dot(Js),T=i.dot(Js),C=l.dot(Js);if(Math.max(-Math.max(M,T,C),Math.min(M,T,C))>s)return!1}return!0}var w2=new Pa;function Co(e,n){this.center=e!==void 0?e:new Ee,this.radius=n!==void 0?n:0}Object.assign(Co.prototype,{set:function(e,n){return this.center.copy(e),this.radius=n,this},setFromPoints:function(e,n){var i=this.center;n!==void 0?i.copy(n):w2.setFromPoints(e).getCenter(i);for(var l=0,h=0,p=e.length;hthis.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n},getBoundingBox:function(e){return e===void 0&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),e=new Pa),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 Po=new Ee,n_=new Ee,ef=new Ee,is=new Ee,i_=new Ee,tf=new Ee,r_=new Ee;function dc(e,n){this.origin=e!==void 0?e:new Ee,this.direction=n!==void 0?n:new Ee(0,0,-1)}Object.assign(dc.prototype,{set:function(e,n){return this.origin.copy(e),this.direction.copy(n),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,n){return n===void 0&&(console.warn("THREE.Ray: .at() target is now required"),n=new Ee),n.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,Po)),this},closestPointToPoint:function(e,n){n===void 0&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),n=new Ee),n.subVectors(e,this.origin);var i=n.dot(this.direction);return i<0?n.copy(this.origin):n.copy(this.direction).multiplyScalar(i).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(e){var n=Po.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Po.copy(this.direction).multiplyScalar(n).add(this.origin),Po.distanceToSquared(e))},distanceSqToSegment:function(e,n,i,l){n_.copy(e).add(n).multiplyScalar(.5),ef.copy(n).sub(e).normalize(),is.copy(this.origin).sub(n_);var h=e.distanceTo(n)*.5,p=-this.direction.dot(ef),_=is.dot(this.direction),s=-is.dot(ef),M=is.lengthSq(),T=Math.abs(1-p*p),C,E,L,I;if(T>0)if(C=p*s-_,E=p*_-s,I=h*T,C>=0)if(E>=-I)if(E<=I){var B=1/T;C*=B,E*=B,L=C*(C+p*E+2*_)+E*(p*C+E+2*s)+M}else E=h,C=Math.max(0,-(p*E+_)),L=-C*C+E*(E+2*s)+M;else E=-h,C=Math.max(0,-(p*E+_)),L=-C*C+E*(E+2*s)+M;else E<=-I?(C=Math.max(0,-(-p*h+_)),E=C>0?-h:Math.min(Math.max(-h,-s),h),L=-C*C+E*(E+2*s)+M):E<=I?(C=0,E=Math.min(Math.max(-h,-s),h),L=E*(E+2*s)+M):(C=Math.max(0,-(p*h+_)),E=C>0?h:Math.min(Math.max(-h,-s),h),L=-C*C+E*(E+2*s)+M);else E=p>0?-h:h,C=Math.max(0,-(p*E+_)),L=-C*C+E*(E+2*s)+M;return i&&i.copy(this.direction).multiplyScalar(C).add(this.origin),l&&l.copy(ef).multiplyScalar(E).add(n_),L},intersectSphere:function(e,n){Po.subVectors(e.center,this.origin);var i=Po.dot(this.direction),l=Po.dot(Po)-i*i,h=e.radius*e.radius;if(l>h)return null;var p=Math.sqrt(h-l),_=i-p,s=i+p;return _<0&&s<0?null:_<0?this.at(s,n):this.at(_,n)},intersectsSphere:function(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius},distanceToPlane:function(e){var n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;var i=-(this.origin.dot(e.normal)+e.constant)/n;return i>=0?i:null},intersectPlane:function(e,n){var i=this.distanceToPlane(e);return i===null?null:this.at(i,n)},intersectsPlane:function(e){var n=e.distanceToPoint(this.origin);if(n===0)return!0;var i=e.normal.dot(this.direction);return i*n<0},intersectBox:function(e,n){var i,l,h,p,_,s,M=1/this.direction.x,T=1/this.direction.y,C=1/this.direction.z,E=this.origin;return M>=0?(i=(e.min.x-E.x)*M,l=(e.max.x-E.x)*M):(i=(e.max.x-E.x)*M,l=(e.min.x-E.x)*M),T>=0?(h=(e.min.y-E.y)*T,p=(e.max.y-E.y)*T):(h=(e.max.y-E.y)*T,p=(e.min.y-E.y)*T),i>p||h>l||((h>i||i!==i)&&(i=h),(p=0?(_=(e.min.z-E.z)*C,s=(e.max.z-E.z)*C):(_=(e.max.z-E.z)*C,s=(e.min.z-E.z)*C),i>s||_>l)||((_>i||i!==i)&&(i=_),(s=0?i:l,n)},intersectsBox:function(e){return this.intersectBox(e,Po)!==null},intersectTriangle:function(e,n,i,l,h){i_.subVectors(n,e),tf.subVectors(i,e),r_.crossVectors(i_,tf);var p=this.direction.dot(r_),_;if(p>0){if(l)return null;_=1}else if(p<0)_=-1,p=-p;else return null;is.subVectors(this.origin,e);var s=_*this.direction.dot(tf.crossVectors(is,tf));if(s<0)return null;var M=_*this.direction.dot(i_.cross(is));if(M<0||s+M>p)return null;var T=-_*is.dot(r_);return T<0?null:this.at(T/p,h)},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 a_=new Ee,M2=new Ee,T2=new dr;function ja(e,n){this.normal=e!==void 0?e:new Ee(1,0,0),this.constant=n!==void 0?n:0}Object.assign(ja.prototype,{isPlane:!0,set:function(e,n){return this.normal.copy(e),this.constant=n,this},setComponents:function(e,n,i,l){return this.normal.set(e,n,i),this.constant=l,this},setFromNormalAndCoplanarPoint:function(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this},setFromCoplanarPoints:function(e,n,i){var l=a_.subVectors(i,n).cross(M2.subVectors(e,n)).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,n){return n===void 0&&(console.warn("THREE.Plane: .projectPoint() target is now required"),n=new Ee),n.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(e,n){n===void 0&&(console.warn("THREE.Plane: .intersectLine() target is now required"),n=new Ee);var i=e.delta(a_),l=this.normal.dot(i);if(l===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):void 0;var h=-(e.start.dot(this.normal)+this.constant)/l;if(!(h<0||h>1))return n.copy(i).multiplyScalar(h).add(e.start)},intersectsLine:function(e){var n=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return n<0&&i>0||i<0&&n>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 Ee),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(e,n){var i=n||T2.getNormalMatrix(e),l=this.coplanarPoint(a_).applyMatrix4(e),h=this.normal.applyMatrix3(i).normalize();return this.constant=-l.dot(h),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 La=new Ee,Lo=new Ee,o_=new Ee,Do=new Ee,pc=new Ee,fc=new Ee,O0=new Ee,s_=new Ee,l_=new Ee,c_=new Ee;function sr(e,n,i){this.a=e!==void 0?e:new Ee,this.b=n!==void 0?n:new Ee,this.c=i!==void 0?i:new Ee}Object.assign(sr,{getNormal:function(e,n,i,l){l===void 0&&(console.warn("THREE.Triangle: .getNormal() target is now required"),l=new Ee),l.subVectors(i,n),La.subVectors(e,n),l.cross(La);var h=l.lengthSq();return h>0?l.multiplyScalar(1/Math.sqrt(h)):l.set(0,0,0)},getBarycoord:function(e,n,i,l,h){La.subVectors(l,n),Lo.subVectors(i,n),o_.subVectors(e,n);var p=La.dot(La),_=La.dot(Lo),s=La.dot(o_),M=Lo.dot(Lo),T=Lo.dot(o_),C=p*M-_*_;if(h===void 0&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),h=new Ee),C===0)return h.set(-2,-1,-1);var E=1/C,L=(M*s-_*T)*E,I=(p*T-_*s)*E;return h.set(1-L-I,I,L)},containsPoint:function(e,n,i,l){return sr.getBarycoord(e,n,i,l,Do),Do.x>=0&&Do.y>=0&&Do.x+Do.y<=1},getUV:function(e,n,i,l,h,p,_,s){return this.getBarycoord(e,n,i,l,Do),s.set(0,0),s.addScaledVector(h,Do.x),s.addScaledVector(p,Do.y),s.addScaledVector(_,Do.z),s},isFrontFacing:function(e,n,i,l){return La.subVectors(i,n),Lo.subVectors(e,n),La.cross(Lo).dot(l)<0}}),Object.assign(sr.prototype,{set:function(e,n,i){return this.a.copy(e),this.b.copy(n),this.c.copy(i),this},setFromPointsAndIndices:function(e,n,i,l){return this.a.copy(e[n]),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 La.subVectors(this.c,this.b),Lo.subVectors(this.a,this.b),La.cross(Lo).length()*.5},getMidpoint:function(e){return e===void 0&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),e=new Ee),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(.3333333333333333)},getNormal:function(e){return sr.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 ja),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,n){return sr.getBarycoord(e,this.a,this.b,this.c,n)},getUV:function(e,n,i,l,h){return sr.getUV(e,this.a,this.b,this.c,n,i,l,h)},containsPoint:function(e){return sr.containsPoint(e,this.a,this.b,this.c)},isFrontFacing:function(e){return sr.isFrontFacing(this.a,this.b,this.c,e)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:function(e,n){n===void 0&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),n=new Ee);var i=this.a,l=this.b,h=this.c,p,_;pc.subVectors(l,i),fc.subVectors(h,i),s_.subVectors(e,i);var s=pc.dot(s_),M=fc.dot(s_);if(s<=0&&M<=0)return n.copy(i);l_.subVectors(e,l);var T=pc.dot(l_),C=fc.dot(l_);if(T>=0&&C<=T)return n.copy(l);var E=s*C-T*M;if(E<=0&&s>=0&&T<=0)return p=s/(s-T),n.copy(i).addScaledVector(pc,p);c_.subVectors(e,h);var L=pc.dot(c_),I=fc.dot(c_);if(I>=0&&L<=I)return n.copy(h);var B=L*M-s*I;if(B<=0&&M>=0&&I<=0)return _=M/(M-I),n.copy(i).addScaledVector(fc,_);var O=T*I-L*C;if(O<=0&&C-T>=0&&L-I>=0)return O0.subVectors(h,l),_=(C-T)/(C-T+(L-I)),n.copy(l).addScaledVector(O0,_);var U=1/(O+B+E);return p=B*U,_=E*U,n.copy(i).addScaledVector(pc,p).addScaledVector(fc,_)},equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}});var N0={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},Da={h:0,s:0,l:0},nf={h:0,s:0,l:0};function en(e,n,i){return n===void 0&&i===void 0?this.set(e):this.setRGB(e,n,i)}function u_(e,n,i){return i<0&&(i+=1),i>1&&(i-=1),i<.16666666666666666?e+(n-e)*6*i:i<.5?n:i<.6666666666666666?e+(n-e)*6*(.6666666666666666-i):e}function h_(e){return e<.04045?e*.0773993808:Math.pow(e*.9478672986+.0521327014,2.4)}function d_(e){return e<.0031308?e*12.92:1.055*Math.pow(e,.41666)-.055}Object.assign(en.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,n,i){return this.r=e,this.g=n,this.b=i,this},setHSL:function(e,n,i){if(e=Wn.euclideanModulo(e,1),n=Wn.clamp(n,0,1),i=Wn.clamp(i,0,1),n===0)this.r=this.g=this.b=i;else{var l=i<=.5?i*(1+n):i+n-i*n,h=2*i-l;this.r=u_(h,l,e+.3333333333333333),this.g=u_(h,l,e),this.b=u_(h,l,e-.3333333333333333)}return this},setStyle:function(e){function n(E){E!==void 0&&parseFloat(E)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var l,h=i[1],p=i[2];switch(h){case"rgb":case"rgba":if(l=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(p))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,n(l[5]),this;if(l=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(p))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,n(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(p)){var _=parseFloat(l[1])/360,s=parseInt(l[2],10)/100,M=parseInt(l[3],10)/100;return n(l[5]),this.setHSL(_,s,M)}break}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(e)){var T=i[1],C=T.length;if(C===3)return this.r=parseInt(T.charAt(0)+T.charAt(0),16)/255,this.g=parseInt(T.charAt(1)+T.charAt(1),16)/255,this.b=parseInt(T.charAt(2)+T.charAt(2),16)/255,this;if(C===6)return this.r=parseInt(T.charAt(0)+T.charAt(1),16)/255,this.g=parseInt(T.charAt(2)+T.charAt(3),16)/255,this.b=parseInt(T.charAt(4)+T.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this},setColorName:function(e){var n=N0[e];return n!==void 0?this.setHex(n):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,n){return n===void 0&&(n=2),this.r=Math.pow(e.r,n),this.g=Math.pow(e.g,n),this.b=Math.pow(e.b,n),this},copyLinearToGamma:function(e,n){n===void 0&&(n=2);var i=n>0?1/n: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=h_(e.r),this.g=h_(e.g),this.b=h_(e.b),this},copyLinearToSRGB:function(e){return this.r=d_(e.r),this.g=d_(e.g),this.b=d_(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 n=this.r,i=this.g,l=this.b,h=Math.max(n,i,l),p=Math.min(n,i,l),_,s,M=(p+h)/2;if(p===h)_=0,s=0;else{var T=h-p;switch(s=M<=.5?T/(h+p):T/(2-h-p),h){case n:_=(i-l)/T+(i0&&(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(_){var s=[];for(var M in _){var T=_[M];delete T.metadata,s.push(T)}return s}if(n){var h=l(e.textures),p=l(e.images);h.length>0&&(i.textures=h),p.length>0&&(i.images=p)}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 n=e.clippingPlanes,i=null;if(n!==null){var l=n.length;i=new Array(l);for(var h=0;h!==l;++h)i[h]=n[h].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 lr(e){Rn.call(this),this.type="MeshBasicMaterial",this.color=new en(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=Up,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)}lr.prototype=Object.create(Rn.prototype),lr.prototype.constructor=lr,lr.prototype.isMeshBasicMaterial=!0,lr.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 Ee;function zn(e,n,i){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=i===!0,this.usage=Xp,this.updateRange={offset:0,count:-1},this.version=0}Object.defineProperty(zn.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(zn.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,n,i){e*=this.itemSize,i*=n.itemSize;for(var l=0,h=this.itemSize;l0,p=l[1]&&l[1].length>0,_=e.morphTargets,s=_.length,M;if(s>0){M=[];for(var T=0;T0){L=[];for(var T=0;T0&&n.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(var T=0;Tn&&(n=e[i]);return n}var S2=1,qa=new jn,v_=new rn,mc=new Ee,aa=new Pa,vh=new Pa,Zi=new Ee;function yn(){Object.defineProperty(this,"id",{value:S2+=2}),this.uuid=Wn.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={}}yn.prototype=Object.assign(Object.create(To.prototype),{constructor:yn,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(e){Array.isArray(e)?this.index=new(V0(e)>65535?yh:_h)(e,1):this.index=e},getAttribute:function(e){return this.attributes[e]},setAttribute:function(e,n){return this.attributes[e]=n,this},deleteAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,n,i){this.groups.push({start:e,count:n,materialIndex:i!==void 0?i:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,n){this.drawRange.start=e,this.drawRange.count=n},applyMatrix4:function(e){var n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);var i=this.attributes.normal;if(i!==void 0){var l=new dr().getNormalMatrix(e);i.applyNormalMatrix(l),i.needsUpdate=!0}var h=this.attributes.tangent;return h!==void 0&&(h.transformDirection(e),h.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this},rotateX:function(e){return qa.makeRotationX(e),this.applyMatrix4(qa),this},rotateY:function(e){return qa.makeRotationY(e),this.applyMatrix4(qa),this},rotateZ:function(e){return qa.makeRotationZ(e),this.applyMatrix4(qa),this},translate:function(e,n,i){return qa.makeTranslation(e,n,i),this.applyMatrix4(qa),this},scale:function(e,n,i){return qa.makeScale(e,n,i),this.applyMatrix4(qa),this},lookAt:function(e){return v_.lookAt(e),v_.updateMatrix(),this.applyMatrix4(v_.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(mc).negate(),this.translate(mc.x,mc.y,mc.z),this},setFromObject:function(e){var n=e.geometry;if(e.isPoints||e.isLine){var i=new sn(n.vertices.length*3,3),l=new sn(n.colors.length*3,3);if(this.setAttribute("position",i.copyVector3sArray(n.vertices)),this.setAttribute("color",l.copyColorsArray(n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){var h=new sn(n.lineDistances.length,1);this.setAttribute("lineDistance",h.copyArray(n.lineDistances))}n.boundingSphere!==null&&(this.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(this.boundingBox=n.boundingBox.clone())}else e.isMesh&&n&&n.isGeometry&&this.fromGeometry(n);return this},setFromPoints:function(e){for(var n=[],i=0,l=e.length;i0){var i=new Float32Array(e.normals.length*3);this.setAttribute("normal",new zn(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var l=new Float32Array(e.colors.length*3);this.setAttribute("color",new zn(l,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var h=new Float32Array(e.uvs.length*2);this.setAttribute("uv",new zn(h,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var p=new Float32Array(e.uvs2.length*2);this.setAttribute("uv2",new zn(p,2).copyVector2sArray(e.uvs2))}this.groups=e.groups;for(var _ in e.morphTargets){for(var s=[],M=e.morphTargets[_],T=0,C=M.length;T0){var I=new sn(e.skinIndices.length*4,4);this.setAttribute("skinIndex",I.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var B=new sn(e.skinWeights.length*4,4);this.setAttribute("skinWeight",B.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 Pa);var e=this.attributes.position,n=this.morphAttributes.position;if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(var i=0,l=n.length;i0&&(e.userData=this.userData),this.parameters!==void 0){var n=this.parameters;for(var i in n)n[i]!==void 0&&(e[i]=n[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 h=this.attributes;for(var i in h){var p=h[i],_=p.toJSON();p.name!==""&&(_.name=p.name),e.data.attributes[i]=_}var s={},M=!1;for(var i in this.morphAttributes){for(var T=this.morphAttributes[i],C=[],E=0,L=T.length;E0&&(s[i]=C,M=!0)}M&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);var I=this.groups;I.length>0&&(e.data.groups=JSON.parse(JSON.stringify(I)));var B=this.boundingSphere;return B!==null&&(e.data.boundingSphere={center:B.center.toArray(),radius:B.radius}),e},clone:function(){return new yn().copy(this)},copy:function(e){var n,i,l;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var h=e.index;h!==null&&this.setIndex(h.clone());var p=e.attributes;for(n in p){var _=p[n];this.setAttribute(n,_.clone())}var s=e.morphAttributes;for(n in s){var M=[],T=s[n];for(i=0,l=T.length;i0){var _=h[p[0]];if(_!==void 0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},n=0,i=_.length;n0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(e,n){var i=this.geometry,l=this.material,h=this.matrixWorld;if(l!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),x_.copy(i.boundingSphere),x_.applyMatrix4(h),e.ray.intersectsSphere(x_)!==!1&&(G0.getInverse(h),Ks.copy(e.ray).applyMatrix4(G0),!(i.boundingBox!==null&&Ks.intersectsBox(i.boundingBox)===!1)))){var p;if(i.isBufferGeometry){var _,s,M,T=i.index,C=i.attributes.position,E=i.morphAttributes.position,L=i.morphTargetsRelative,I=i.attributes.uv,B=i.attributes.uv2,O=i.groups,U=i.drawRange,q,ee,he,Ce,K,ie,ue,ae;if(T!==null)if(Array.isArray(l))for(q=0,he=O.length;q0&&(We=st);for(var St=0,gt=Oe.length;Sti.far?null:{distance:T,point:lf.clone(),object:e}}function cf(e,n,i,l,h,p,_,s,M,T,C,E){Qs.fromBufferAttribute(h,T),el.fromBufferAttribute(h,C),tl.fromBufferAttribute(h,E);var L=e.morphTargetInfluences;if(n.morphTargets&&p&&L){af.set(0,0,0),of.set(0,0,0),sf.set(0,0,0);for(var I=0,B=p.length;I0)for(var T=0;T0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,n,i;for(this.computeFaceNormals(),e=0,n=this.faces.length;e0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,n,i,l,h;for(i=0,l=this.faces.length;i=0;s--){var O=I[s];for(this.faces.splice(O,1),E=0,L=this.faceVertexUvs.length;E0,ee=I.vertexNormals.length>0,he=I.color.r!==1||I.color.g!==1||I.color.b!==1,Ce=I.vertexColors.length>0,K=0;if(K=le(K,0,0),K=le(K,1,B),K=le(K,2,O),K=le(K,3,U),K=le(K,4,q),K=le(K,5,ee),K=le(K,6,he),K=le(K,7,Ce),_.push(K),_.push(I.a,I.b,I.c),_.push(I.materialIndex),U){var ie=this.faceVertexUvs[0][h];_.push(se(ie[0]),se(ie[1]),se(ie[2]))}if(q&&_.push(De(I.normal)),ee){var ue=I.vertexNormals;_.push(De(ue[0]),De(ue[1]),De(ue[2]))}if(he&&_.push(ye(I.color)),Ce){var ae=I.vertexColors;_.push(ye(ae[0]),ye(ae[1]),ye(ae[2]))}}function le(Ue,Oe,We){return We?Ue|1<0&&(e.data.colors=T),E.length>0&&(e.data.uvs=[E]),e.data.faces=_,e},clone:function(){return new Fn().copy(this)},copy:function(e){var n,i,l,h,p,_;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 s=e.vertices;for(n=0,i=s.length;n0?1:-1,C.push(Ot.x,Ot.y,Ot.z),E.push(At/ue),E.push(1-Dt/ae),St+=1}}for(Dt=0;Dt0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader;var p={};for(var _ in this.extensions)this.extensions[_]===!0&&(p[_]=!0);return Object.keys(p).length>0&&(n.extensions=p),n};function Io(){rn.call(this),this.type="Camera",this.matrixWorldInverse=new jn,this.projectionMatrix=new jn,this.projectionMatrixInverse=new jn}Io.prototype=Object.assign(Object.create(rn.prototype),{constructor:Io,isCamera:!0,copy:function(e,n){return rn.prototype.copy.call(this,e,n),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 Ee),this.updateMatrixWorld(!0);var n=this.matrixWorld.elements;return e.set(-n[8],-n[9],-n[10]).normalize()},updateMatrixWorld:function(e){rn.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.getInverse(this.matrixWorld)},updateWorldMatrix:function(e,n){rn.prototype.updateWorldMatrix.call(this,e,n),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return new this.constructor().copy(this)}});function Xi(e,n,i,l){Io.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=n!==void 0?n:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}Xi.prototype=Object.assign(Object.create(Io.prototype),{constructor:Xi,isPerspectiveCamera:!0,copy:function(e,n){return Io.prototype.copy.call(this,e,n),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this},setFocalLength:function(e){var n=.5*this.getFilmHeight()/e;this.fov=Wn.RAD2DEG*2*Math.atan(n),this.updateProjectionMatrix()},getFocalLength:function(){var e=Math.tan(Wn.DEG2RAD*.5*this.fov);return .5*this.getFilmHeight()/e},getEffectiveFOV:function(){return Wn.RAD2DEG*2*Math.atan(Math.tan(Wn.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,n,i,l,h,p){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=i,this.view.offsetY=l,this.view.width=h,this.view.height=p,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e=this.near,n=e*Math.tan(Wn.DEG2RAD*.5*this.fov)/this.zoom,i=2*n,l=this.aspect*i,h=-.5*l,p=this.view;if(this.view!==null&&this.view.enabled){var _=p.fullWidth,s=p.fullHeight;h+=p.offsetX*l/_,n-=p.offsetY*i/s,l*=p.width/_,i*=p.height/s}var M=this.filmOffset;M!==0&&(h+=e*M/this.getFilmWidth()),this.projectionMatrix.makePerspective(h,h+l,n,n-i,e,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){var n=rn.prototype.toJSON.call(this,e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}});var xc=90,bc=1;function bh(e,n,i,l){rn.call(this),this.type="CubeCamera";var h=new Xi(xc,bc,e,n);h.up.set(0,-1,0),h.lookAt(new Ee(1,0,0)),this.add(h);var p=new Xi(xc,bc,e,n);p.up.set(0,-1,0),p.lookAt(new Ee(-1,0,0)),this.add(p);var _=new Xi(xc,bc,e,n);_.up.set(0,0,1),_.lookAt(new Ee(0,1,0)),this.add(_);var s=new Xi(xc,bc,e,n);s.up.set(0,0,-1),s.lookAt(new Ee(0,-1,0)),this.add(s);var M=new Xi(xc,bc,e,n);M.up.set(0,-1,0),M.lookAt(new Ee(0,0,1)),this.add(M);var T=new Xi(xc,bc,e,n);T.up.set(0,-1,0),T.lookAt(new Ee(0,0,-1)),this.add(T),l=l||{format:Mo,magFilter:qi,minFilter:qi},this.renderTarget=new wc(i,l),this.renderTarget.texture.name="CubeCamera",this.update=function(C,E){this.parent===null&&this.updateMatrixWorld();var L=C.getRenderTarget(),I=this.renderTarget,B=I.texture.generateMipmaps;I.texture.generateMipmaps=!1,C.setRenderTarget(I,0),C.render(E,h),C.setRenderTarget(I,1),C.render(E,p),C.setRenderTarget(I,2),C.render(E,_),C.setRenderTarget(I,3),C.render(E,s),C.setRenderTarget(I,4),C.render(E,M),I.texture.generateMipmaps=B,C.setRenderTarget(I,5),C.render(E,T),C.setRenderTarget(L)},this.clear=function(C,E,L,I){for(var B=C.getRenderTarget(),O=this.renderTarget,U=0;U<6;U++)C.setRenderTarget(O,U),C.clear(E,L,I);C.setRenderTarget(B)}}bh.prototype=Object.create(rn.prototype),bh.prototype.constructor=bh;function wc(e,n,i){Number.isInteger(n)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),n=i),Mr.call(this,e,e,n)}wc.prototype=Object.create(Mr.prototype),wc.prototype.constructor=wc,wc.prototype.isWebGLCubeRenderTarget=!0,wc.prototype.fromEquirectangularTexture=function(e,n){this.texture.type=n.type,this.texture.format=n.format,this.texture.encoding=n.encoding;var i=new So,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 "," #include ","}"].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(` `)},h=new Nr({type:"CubemapFromEquirect",uniforms:vc(l.uniforms),vertexShader:l.vertexShader,fragmentShader:l.fragmentShader,side:tr,blending:Qo});h.uniforms.tEquirect.value=n;var p=new Ai(new hf(5,5,5),h);i.add(p);var _=new bh(1,10,1);return _.renderTarget=this,_.renderTarget.texture.name="CubeCameraTexture",_.update(e,i),p.geometry.dispose(),p.material.dispose(),this};function Mc(e,n,i,l,h,p,_,s,M,T,C,E){mi.call(this,null,p,_,s,M,T,l,h,C,E),this.image={data:e||null,width:n||1,height:i||1},this.magFilter=M!==void 0?M:Ui,this.minFilter=T!==void 0?T:Ui,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}Mc.prototype=Object.create(mi.prototype),Mc.prototype.constructor=Mc,Mc.prototype.isDataTexture=!0;var Tc=new Co,df=new Ee;function wh(e,n,i,l,h,p){this.planes=[e!==void 0?e:new ja,n!==void 0?n:new ja,i!==void 0?i:new ja,l!==void 0?l:new ja,h!==void 0?h:new ja,p!==void 0?p:new ja]}Object.assign(wh.prototype,{set:function(e,n,i,l,h,p){var _=this.planes;return _[0].copy(e),_[1].copy(n),_[2].copy(i),_[3].copy(l),_[4].copy(h),_[5].copy(p),this},clone:function(){return new this.constructor().copy(this)},copy:function(e){for(var n=this.planes,i=0;i<6;i++)n[i].copy(e.planes[i]);return this},setFromProjectionMatrix:function(e){var n=this.planes,i=e.elements,l=i[0],h=i[1],p=i[2],_=i[3],s=i[4],M=i[5],T=i[6],C=i[7],E=i[8],L=i[9],I=i[10],B=i[11],O=i[12],U=i[13],q=i[14],ee=i[15];return n[0].setComponents(_-l,C-s,B-E,ee-O).normalize(),n[1].setComponents(_+l,C+s,B+E,ee+O).normalize(),n[2].setComponents(_+h,C+M,B+L,ee+U).normalize(),n[3].setComponents(_-h,C-M,B-L,ee-U).normalize(),n[4].setComponents(_-p,C-T,B-I,ee-q).normalize(),n[5].setComponents(_+p,C+T,B+I,ee+q).normalize(),this},intersectsObject:function(e){var n=e.geometry;return n.boundingSphere===null&&n.computeBoundingSphere(),Tc.copy(n.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Tc)},intersectsSprite:function(e){return Tc.center.set(0,0,0),Tc.radius=.7071067811865476,Tc.applyMatrix4(e.matrixWorld),this.intersectsSphere(Tc)},intersectsSphere:function(e){for(var n=this.planes,i=e.center,l=-e.radius,h=0;h<6;h++){var p=n[h].distanceToPoint(i);if(p0?e.max.x:e.min.x,df.y=l.normal.y>0?e.max.y:e.min.y,df.z=l.normal.z>0?e.max.z:e.min.z,l.distanceToPoint(df)<0)return!1}return!0},containsPoint:function(e){for(var n=this.planes,i=0;i<6;i++)if(n[i].distanceToPoint(e)<0)return!1;return!0}});var an={common:{diffuse:{value:new en(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new dr},uv2Transform:{value:new dr},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 en(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 en(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new dr}},sprite:{diffuse:{value:new en(15658734)},opacity:{value:1},center:{value:new Lt(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new dr}}};function W0(){var e=null,n=!1,i=null;function l(h,p){n!==!1&&(i(h,p),e.requestAnimationFrame(l))}return{start:function(){n!==!0&&i!==null&&(e.requestAnimationFrame(l),n=!0)},stop:function(){n=!1},setAnimationLoop:function(h){i=h},setContext:function(h){e=h}}}function I2(e,n){var i=n.isWebGL2,l=new WeakMap;function h(T,C){var E=T.array,L=T.usage,I=e.createBuffer();e.bindBuffer(C,I),e.bufferData(C,E,L),T.onUploadCallback();var B=5126;return E instanceof Float32Array?B=5126:E instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):E instanceof Uint16Array?B=5123:E instanceof Int16Array?B=5122:E instanceof Uint32Array?B=5125:E instanceof Int32Array?B=5124:E instanceof Int8Array?B=5120:E instanceof Uint8Array&&(B=5121),{buffer:I,type:B,bytesPerElement:E.BYTES_PER_ELEMENT,version:T.version}}function p(T,C,E){var L=C.array,I=C.updateRange;e.bindBuffer(E,T),I.count===-1?e.bufferSubData(E,0,L):(i?e.bufferSubData(E,I.offset*L.BYTES_PER_ELEMENT,L,I.offset,I.count):e.bufferSubData(E,I.offset*L.BYTES_PER_ELEMENT,L.subarray(I.offset,I.offset+I.count)),I.count=-1)}function _(T){return T.isInterleavedBufferAttribute&&(T=T.data),l.get(T)}function s(T){T.isInterleavedBufferAttribute&&(T=T.data);var C=l.get(T);C&&(e.deleteBuffer(C.buffer),l.delete(T))}function M(T,C){T.isInterleavedBufferAttribute&&(T=T.data);var E=l.get(T);E===void 0?l.set(T,h(T,C)):E.version 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`,V2=`#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`,G2=`#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`,H2=`#if NUM_CLIPPING_PLANES > 0 #if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP ) varying vec3 vViewPosition; #endif uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,W2=`#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP ) varying vec3 vViewPosition; #endif`,j2=`#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP ) vViewPosition = - mvPosition.xyz; #endif`,q2=`#ifdef USE_COLOR diffuseColor.rgb *= vColor; #endif`,Z2=`#ifdef USE_COLOR varying vec3 vColor; #endif`,X2=`#ifdef USE_COLOR varying vec3 vColor; #endif`,Y2=`#ifdef USE_COLOR vColor.xyz = color.xyz; #endif`,$2=`#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; }`,J2=`#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`,K2=`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`,Q2=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,eE=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias ); #endif`,tE=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vUv ); emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb; totalEmissiveRadiance *= emissiveColor.rgb; #endif`,nE=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,iE="gl_FragColor = linearToOutputTexel( gl_FragColor );",rE=` 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 ); }`,aE=`#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`,oE=`#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`,sE=`#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`,lE=`#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`,cE=`#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`,uE=`#ifdef USE_FOG fogDepth = -mvPosition.z; #endif`,hE=`#ifdef USE_FOG varying float fogDepth; #endif`,dE=`#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`,pE=`#ifdef USE_FOG uniform vec3 fogColor; varying float fogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,fE=`#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 }`,mE=`#ifdef USE_LIGHTMAP vec4 lightMapTexel= texture2D( lightMap, vUv2 ); reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; #endif`,gE=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,_E=`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`,yE=`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`,vE=`#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`,xE=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,bE=`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)`,wE=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,ME=`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)`,TE=`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`,EE=`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 ); }`,SE=` 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`,AE=`#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`,CE=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); #endif`,PE=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,LE=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,DE=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif #endif`,IE=`#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`,RE=`#ifdef USE_MAP vec4 texelColor = texture2D( map, vUv ); texelColor = mapTexelToLinear( texelColor ); diffuseColor *= texelColor; #endif`,zE=`#ifdef USE_MAP uniform sampler2D map; #endif`,kE=`#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`,BE=`#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`,FE=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vUv ); metalnessFactor *= texelMetalness.b; #endif`,OE=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,NE=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; #endif`,UE=`#ifdef USE_MORPHTARGETS uniform float morphTargetBaseInfluence; #ifndef USE_MORPHNORMALS uniform float morphTargetInfluences[ 8 ]; #else uniform float morphTargetInfluences[ 4 ]; #endif #endif`,VE=`#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`,GE=`#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;`,HE=`#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`,WE=`#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`,jE=`#ifdef CLEARCOAT vec3 clearcoatNormal = geometryNormal; #endif`,qE=`#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`,ZE=`#ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif`,XE=`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 ); }`,YE=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,$E=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,JE=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,KE=`#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`,QE=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vUv ); roughnessFactor *= texelRoughness.g; #endif`,eS=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,tS=`#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`,nS=`#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`,iS=`#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`,rS=`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; }`,aS=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,oS=`#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`,sS=`#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`,lS=`#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`,cS=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,uS=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,hS=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,dS=`#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 ) ); }`,pS=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) ) varying vec2 vUv; #endif`,fS=`#ifdef USE_UV #ifdef UVS_VERTEX_ONLY vec2 vUv; #else varying vec2 vUv; #endif uniform mat3 uvTransform; #endif`,mS=`#ifdef USE_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif`,gS=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) varying vec2 vUv2; #endif`,_S=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) attribute vec2 uv2; varying vec2 vUv2; uniform mat3 uv2Transform; #endif`,yS=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; #endif`,vS=`#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`,xS=`uniform sampler2D t2D; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); gl_FragColor = mapTexelToLinear( texColor ); #include #include }`,bS=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,wS=`#include uniform float opacity; varying vec3 vWorldDirection; #include void main() { vec3 vReflect = vWorldDirection; #include gl_FragColor = envColor; gl_FragColor.a *= opacity; #include #include }`,MS=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,TS=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( 1.0 ); #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include #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 }`,ES=`#include #include #include #include #include #include #include void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include }`,SS=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include void main () { #include vec4 diffuseColor = vec4( 1.0 ); #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,AS=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,CS=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include 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 #include }`,PS=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,LS=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include void main() { #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include outgoingLight = diffuseColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include }`,DS=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include void main() { #include vLineDistance = scale * lineDistance; vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); gl_Position = projectionMatrix * mvPosition; #include #include #include }`,IS=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include 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 reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include }`,RS=`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #ifdef USE_ENVMAP #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,zS=`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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include reflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor ); #ifdef DOUBLE_SIDED reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack; #else reflectedLight.indirectDiffuse += vIndirectFront; #endif #include 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 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,kS=`#define LAMBERT varying vec3 vLightFront; varying vec3 vIndirectFront; #ifdef DOUBLE_SIDED varying vec3 vLightBack; varying vec3 vIndirectBack; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,BS=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include 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 #include #include #include }`,FS=`#define MATCAP varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #endif #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,OS=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,NS=`#define TOON varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #endif #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,US=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,VS=`#define PHONG varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #endif #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,GS=`#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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include 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 #include #include #include #include }`,HS=`#define STANDARD varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,WS=`#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 #include #include #include #include #include void main() { #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); }`,jS=`#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 #include #include #include #include #include #include void main() { #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) vViewPosition = - mvPosition.xyz; #endif }`,qS=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include }`,ZS=`uniform float size; uniform float scale; #include #include #include #include #include #include void main() { #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,XS=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,YS=`#include #include void main() { #include #include #include #include #include }`,$S=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include }`,JS=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include 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 #include #include }`,Yn={alphamap_fragment:R2,alphamap_pars_fragment:z2,alphatest_fragment:k2,aomap_fragment:B2,aomap_pars_fragment:F2,begin_vertex:O2,beginnormal_vertex:N2,bsdfs:U2,bumpmap_pars_fragment:V2,clipping_planes_fragment:G2,clipping_planes_pars_fragment:H2,clipping_planes_pars_vertex:W2,clipping_planes_vertex:j2,color_fragment:q2,color_pars_fragment:Z2,color_pars_vertex:X2,color_vertex:Y2,common:$2,cube_uv_reflection_fragment:J2,defaultnormal_vertex:K2,displacementmap_pars_vertex:Q2,displacementmap_vertex:eE,emissivemap_fragment:tE,emissivemap_pars_fragment:nE,encodings_fragment:iE,encodings_pars_fragment:rE,envmap_fragment:aE,envmap_common_pars_fragment:oE,envmap_pars_fragment:sE,envmap_pars_vertex:lE,envmap_physical_pars_fragment:vE,envmap_vertex:cE,fog_vertex:uE,fog_pars_vertex:hE,fog_fragment:dE,fog_pars_fragment:pE,gradientmap_pars_fragment:fE,lightmap_fragment:mE,lightmap_pars_fragment:gE,lights_lambert_vertex:_E,lights_pars_begin:yE,lights_toon_fragment:xE,lights_toon_pars_fragment:bE,lights_phong_fragment:wE,lights_phong_pars_fragment:ME,lights_physical_fragment:TE,lights_physical_pars_fragment:EE,lights_fragment_begin:SE,lights_fragment_maps:AE,lights_fragment_end:CE,logdepthbuf_fragment:PE,logdepthbuf_pars_fragment:LE,logdepthbuf_pars_vertex:DE,logdepthbuf_vertex:IE,map_fragment:RE,map_pars_fragment:zE,map_particle_fragment:kE,map_particle_pars_fragment:BE,metalnessmap_fragment:FE,metalnessmap_pars_fragment:OE,morphnormal_vertex:NE,morphtarget_pars_vertex:UE,morphtarget_vertex:VE,normal_fragment_begin:GE,normal_fragment_maps:HE,normalmap_pars_fragment:WE,clearcoat_normal_fragment_begin:jE,clearcoat_normal_fragment_maps:qE,clearcoat_normalmap_pars_fragment:ZE,packing:XE,premultiplied_alpha_fragment:YE,project_vertex:$E,dithering_fragment:JE,dithering_pars_fragment:KE,roughnessmap_fragment:QE,roughnessmap_pars_fragment:eS,shadowmap_pars_fragment:tS,shadowmap_pars_vertex:nS,shadowmap_vertex:iS,shadowmask_pars_fragment:rS,skinbase_vertex:aS,skinning_pars_vertex:oS,skinning_vertex:sS,skinnormal_vertex:lS,specularmap_fragment:cS,specularmap_pars_fragment:uS,tonemapping_fragment:hS,tonemapping_pars_fragment:dS,uv_pars_fragment:pS,uv_pars_vertex:fS,uv_vertex:mS,uv2_pars_fragment:gS,uv2_pars_vertex:_S,uv2_vertex:yS,worldpos_vertex:vS,background_frag:xS,background_vert:bS,cube_frag:wS,cube_vert:MS,depth_frag:TS,depth_vert:ES,distanceRGBA_frag:SS,distanceRGBA_vert:AS,equirect_frag:CS,equirect_vert:PS,linedashed_frag:LS,linedashed_vert:DS,meshbasic_frag:IS,meshbasic_vert:RS,meshlambert_frag:zS,meshlambert_vert:kS,meshmatcap_frag:BS,meshmatcap_vert:FS,meshtoon_frag:OS,meshtoon_vert:NS,meshphong_frag:US,meshphong_vert:VS,meshphysical_frag:GS,meshphysical_vert:HS,normal_frag:WS,normal_vert:jS,points_frag:qS,points_vert:ZS,shadow_frag:XS,shadow_vert:YS,sprite_frag:$S,sprite_vert:JS},Ro={basic:{uniforms:pr([an.common,an.specularmap,an.envmap,an.aomap,an.lightmap,an.fog]),vertexShader:Yn.meshbasic_vert,fragmentShader:Yn.meshbasic_frag},lambert:{uniforms:pr([an.common,an.specularmap,an.envmap,an.aomap,an.lightmap,an.emissivemap,an.fog,an.lights,{emissive:{value:new en(0)}}]),vertexShader:Yn.meshlambert_vert,fragmentShader:Yn.meshlambert_frag},phong:{uniforms:pr([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 en(0)},specular:{value:new en(1118481)},shininess:{value:30}}]),vertexShader:Yn.meshphong_vert,fragmentShader:Yn.meshphong_frag},standard:{uniforms:pr([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 en(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Yn.meshphysical_vert,fragmentShader:Yn.meshphysical_frag},toon:{uniforms:pr([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 en(0)},specular:{value:new en(1118481)},shininess:{value:30}}]),vertexShader:Yn.meshtoon_vert,fragmentShader:Yn.meshtoon_frag},matcap:{uniforms:pr([an.common,an.bumpmap,an.normalmap,an.displacementmap,an.fog,{matcap:{value:null}}]),vertexShader:Yn.meshmatcap_vert,fragmentShader:Yn.meshmatcap_frag},points:{uniforms:pr([an.points,an.fog]),vertexShader:Yn.points_vert,fragmentShader:Yn.points_frag},dashed:{uniforms:pr([an.common,an.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Yn.linedashed_vert,fragmentShader:Yn.linedashed_frag},depth:{uniforms:pr([an.common,an.displacementmap]),vertexShader:Yn.depth_vert,fragmentShader:Yn.depth_frag},normal:{uniforms:pr([an.common,an.bumpmap,an.normalmap,an.displacementmap,{opacity:{value:1}}]),vertexShader:Yn.normal_vert,fragmentShader:Yn.normal_frag},sprite:{uniforms:pr([an.sprite,an.fog]),vertexShader:Yn.sprite_vert,fragmentShader:Yn.sprite_frag},background:{uniforms:{uvTransform:{value:new dr},t2D:{value:null}},vertexShader:Yn.background_vert,fragmentShader:Yn.background_frag},cube:{uniforms:pr([an.envmap,{opacity:{value:1}}]),vertexShader:Yn.cube_vert,fragmentShader:Yn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Yn.equirect_vert,fragmentShader:Yn.equirect_frag},distanceRGBA:{uniforms:pr([an.common,an.displacementmap,{referencePosition:{value:new Ee},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Yn.distanceRGBA_vert,fragmentShader:Yn.distanceRGBA_frag},shadow:{uniforms:pr([an.lights,an.fog,{color:{value:new en(0)},opacity:{value:1}}]),vertexShader:Yn.shadow_vert,fragmentShader:Yn.shadow_frag}};Ro.physical={uniforms:pr([Ro.standard.uniforms,{transparency:{value:0},clearcoat:{value:0},clearcoatRoughness:{value:0},sheen:{value:new en(0)},clearcoatNormalScale:{value:new Lt(1,1)},clearcoatNormalMap:{value:null}}]),vertexShader:Yn.meshphysical_vert,fragmentShader:Yn.meshphysical_frag};function KS(e,n,i,l){var h=new en(0),p=0,_,s,M=null,T=0,C=null;function E(I,B,O,U){var q=B.background,ee=e.xr,he=ee.getSession&&ee.getSession();if(he&&he.environmentBlendMode==="additive"&&(q=null),q===null?L(h,p):q&&q.isColor&&(L(q,1),U=!0),(e.autoClear||U)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),q&&(q.isCubeTexture||q.isWebGLCubeRenderTarget||q.mapping===oh)){s===void 0&&(s=new Ai(new hf(1,1,1),new Nr({type:"BackgroundCubeMaterial",uniforms:vc(Ro.cube.uniforms),vertexShader:Ro.cube.vertexShader,fragmentShader:Ro.cube.fragmentShader,side:tr,depthTest:!1,depthWrite:!1,fog:!1})),s.geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(K,ie,ue){this.matrixWorld.copyPosition(ue.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(s));var Ce=q.isWebGLCubeRenderTarget?q.texture:q;s.material.uniforms.envMap.value=Ce,s.material.uniforms.flipEnvMap.value=Ce.isCubeTexture?-1:1,(M!==q||T!==Ce.version||C!==e.toneMapping)&&(s.material.needsUpdate=!0,M=q,T=Ce.version,C=e.toneMapping),I.unshift(s,s.geometry,s.material,0,0,null)}else q&&q.isTexture&&(_===void 0&&(_=new Ai(new Ec(2,2),new Nr({type:"BackgroundMaterial",uniforms:vc(Ro.background.uniforms),vertexShader:Ro.background.vertexShader,fragmentShader:Ro.background.fragmentShader,side:Jl,depthTest:!1,depthWrite:!1,fog:!1})),_.geometry.deleteAttribute("normal"),Object.defineProperty(_.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(_)),_.material.uniforms.t2D.value=q,q.matrixAutoUpdate===!0&&q.updateMatrix(),_.material.uniforms.uvTransform.value.copy(q.matrix),(M!==q||T!==q.version||C!==e.toneMapping)&&(_.material.needsUpdate=!0,M=q,T=q.version,C=e.toneMapping),I.unshift(_,_.geometry,_.material,0,0,null))}function L(I,B){n.buffers.color.setClear(I.r,I.g,I.b,B,l)}return{getClearColor:function(){return h},setClearColor:function(I,B){h.set(I),p=B!==void 0?B:1,L(h,p)},getClearAlpha:function(){return p},setClearAlpha:function(I){p=I,L(h,p)},render:E}}function QS(e,n,i,l){var h=l.isWebGL2,p;function _(T){p=T}function s(T,C){e.drawArrays(p,T,C),i.update(C,p)}function M(T,C,E,L){if(L!==0){var I,B;if(h)I=e,B="drawArraysInstanced";else if(I=n.get("ANGLE_instanced_arrays"),B="drawArraysInstancedANGLE",I===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}I[B](p,C,E,L),i.update(E,p,L)}}this.setMode=_,this.render=s,this.renderInstances=M}function eA(e,n,i){var l;function h(){if(l!==void 0)return l;var ie=n.get("EXT_texture_filter_anisotropic");return ie!==null?l=e.getParameter(ie.MAX_TEXTURE_MAX_ANISOTROPY_EXT):l=0,l}function p(ie){if(ie==="highp"){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";ie="mediump"}return ie==="mediump"&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}var _=typeof WebGL2RenderingContext!="undefined"&&e instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext!="undefined"&&e instanceof WebGL2ComputeRenderingContext,s=i.precision!==void 0?i.precision:"highp",M=p(s);M!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",M,"instead."),s=M);var T=i.logarithmicDepthBuffer===!0,C=e.getParameter(34930),E=e.getParameter(35660),L=e.getParameter(3379),I=e.getParameter(34076),B=e.getParameter(34921),O=e.getParameter(36347),U=e.getParameter(36348),q=e.getParameter(36349),ee=E>0,he=_||!!n.get("OES_texture_float"),Ce=ee&&he,K=_?e.getParameter(36183):0;return{isWebGL2:_,getMaxAnisotropy:h,getMaxPrecision:p,precision:s,logarithmicDepthBuffer:T,maxTextures:C,maxVertexTextures:E,maxTextureSize:L,maxCubemapSize:I,maxAttributes:B,maxVertexUniforms:O,maxVaryings:U,maxFragmentUniforms:q,vertexTextures:ee,floatFragmentTextures:he,floatVertexTextures:Ce,maxSamples:K}}function tA(){var e=this,n=null,i=0,l=!1,h=!1,p=new ja,_=new dr,s={value:null,needsUpdate:!1};this.uniform=s,this.numPlanes=0,this.numIntersection=0,this.init=function(C,E,L){var I=C.length!==0||E||i!==0||l;return l=E,n=T(C,L,0),i=C.length,I},this.beginShadows=function(){h=!0,T(null)},this.endShadows=function(){h=!1,M()},this.setState=function(C,E,L,I,B,O){if(!l||C===null||C.length===0||h&&!L)h?T(null):M();else{var U=h?0:i,q=U*4,ee=B.clippingState||null;s.value=ee,ee=T(C,I,q,O);for(var he=0;he!==q;++he)ee[he]=n[he];B.clippingState=ee,this.numIntersection=E?this.numPlanes:0,this.numPlanes+=U}};function M(){s.value!==n&&(s.value=n,s.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function T(C,E,L,I){var B=C!==null?C.length:0,O=null;if(B!==0){if(O=s.value,I!==!0||O===null){var U=L+B*4,q=E.matrixWorldInverse;_.getNormalMatrix(q),(O===null||O.length65535?yh:_h)(E,1);K.version=B,n.update(K,34963);var ie=h.get(C);ie&&n.remove(ie),h.set(C,K)}function T(C){var E=h.get(C);if(E){var L=C.index;L!==null&&E.version0)return e;var h=n*i,p=Z0[h];if(p===void 0&&(p=new Float32Array(h),Z0[h]=p),n!==0){l.toArray(p,0);for(var _=1,s=0;_!==n;++_)s+=i,e[_].toArray(p,s)}return p}function ya(e,n){if(e.length!==n.length)return!1;for(var i=0,l=e.length;i/gm;function S_(e){return e.replace(JA,KA)}function KA(e,n){var i=Yn[n];if(i===void 0)throw new Error("Can not resolve #include <"+n+">");return S_(i)}var QA=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;function sx(e){return e.replace(QA,eC)}function eC(e,n,i,l){for(var h="",p=parseInt(n);p0?e.gammaFactor:1,L=i.isWebGL2?"":XA(i),I=YA(h),B=l.createProgram(),O,U,q=i.numMultiviewViews;if(i.isRawShaderMaterial?(O=[I].filter(Sh).join(` `),O.length>0&&(O+=` `),U=[L,I].filter(Sh).join(` `),U.length>0&&(U+=` `)):(O=[lx(i),"#define SHADER_NAME "+i.shaderName,I,i.instancing?"#define USE_INSTANCING":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+E,"#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 "+T:"",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 "+s:"",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(Sh).join(` `),U=[L,lx(i),"#define SHADER_NAME "+i.shaderName,I,i.alphaTest?"#define ALPHATEST "+i.alphaTest+(i.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+E,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 "+M:"",i.envMap?"#define "+T:"",i.envMap?"#define "+C:"",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 "+s:"",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!==Vp?"#define TONE_MAPPING":"",i.toneMapping!==Vp?Yn.tonemapping_pars_fragment:"",i.toneMapping!==Vp?ZA("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.outputEncoding||i.mapEncoding||i.matcapEncoding||i.envMapEncoding||i.emissiveMapEncoding||i.lightMapEncoding?Yn.encodings_pars_fragment:"",i.mapEncoding?Eh("mapTexelToLinear",i.mapEncoding):"",i.matcapEncoding?Eh("matcapTexelToLinear",i.matcapEncoding):"",i.envMapEncoding?Eh("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMapEncoding?Eh("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.lightMapEncoding?Eh("lightMapTexelToLinear",i.lightMapEncoding):"",i.outputEncoding?qA("linearToOutputTexel",i.outputEncoding):"",i.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"",` `].filter(Sh).join(` `)),p=S_(p),p=ax(p,i),p=ox(p,i),_=S_(_),_=ax(_,i),_=ox(_,i),p=sx(p),_=sx(_),i.isWebGL2&&!i.isRawShaderMaterial){var ee=!1,he=/^\s*#version\s+300\s+es\s*\n/;i.isShaderMaterial&&p.match(he)!==null&&_.match(he)!==null&&(ee=!0,p=p.replace(he,""),_=_.replace(he,"")),O=[`#version 300 es `,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+O,U=[`#version 300 es `,"#define varying in",ee?"":"out highp vec4 pc_fragColor;",ee?"":"#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(` `)+` `+U,q>0&&(O=O.replace(`#version 300 es `,[`#version 300 es `,"#extension GL_OVR_multiview2 : require","layout(num_views = "+q+") in;","#define VIEW_ID gl_ViewID_OVR"].join(` `)),O=O.replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join(` `),["uniform mat4 modelViewMatrices["+q+"];","uniform mat4 projectionMatrices["+q+"];","uniform mat4 viewMatrices["+q+"];","uniform mat3 normalMatrices["+q+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join(` `)),U=U.replace(`#version 300 es `,[`#version 300 es `,"#extension GL_OVR_multiview2 : require","#define VIEW_ID gl_ViewID_OVR"].join(` `)),U=U.replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+q+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join(` `)))}var Ce=O+p,K=U+_,ie=nx(l,35633,Ce),ue=nx(l,35632,K);if(l.attachShader(B,ie),l.attachShader(B,ue),i.index0AttributeName!==void 0?l.bindAttribLocation(B,0,i.index0AttributeName):i.morphTargets===!0&&l.bindAttribLocation(B,0,"position"),l.linkProgram(B),e.debug.checkShaderErrors){var ae=l.getProgramInfoLog(B).trim(),le=l.getShaderInfoLog(ie).trim(),De=l.getShaderInfoLog(ue).trim(),ye=!0,se=!0;if(l.getProgramParameter(B,35714)===!1){ye=!1;var Ue=rx(l,ie,"vertex"),Oe=rx(l,ue,"fragment");console.error("THREE.WebGLProgram: shader error: ",l.getError(),"35715",l.getProgramParameter(B,35715),"gl.getProgramInfoLog",ae,Ue,Oe)}else ae!==""?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",ae):(le===""||De==="")&&(se=!1);se&&(this.diagnostics={runnable:ye,programLog:ae,vertexShader:{log:le,prefix:O},fragmentShader:{log:De,prefix:U}})}l.deleteShader(ie),l.deleteShader(ue);var We;this.getUniforms=function(){return We===void 0&&(We=new as(l,B)),We};var st;return this.getAttributes=function(){return st===void 0&&(st=$A(l,B)),st},this.destroy=function(){l.deleteProgram(B),this.program=void 0},this.name=i.shaderName,this.id=WA++,this.cacheKey=n,this.usedTimes=1,this.program=B,this.vertexShader=ie,this.fragmentShader=ue,this.numMultiviewViews=q,this}function oC(e,n,i){var l=[],h=i.isWebGL2,p=i.logarithmicDepthBuffer,_=i.floatVertexTextures,s=i.precision,M=i.maxVertexUniforms,T=i.vertexTextures,C={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"},E=["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 L(O,U){var q;if(U){var ee=Ro[U];q={name:O.type,uniforms:P2.clone(ee.uniforms),vertexShader:ee.vertexShader,fragmentShader:ee.fragmentShader}}else q={name:O.type,uniforms:O.uniforms,vertexShader:O.vertexShader,fragmentShader:O.fragmentShader};return q}function I(O){var U=O.skeleton,q=U.bones;if(_)return 1024;var ee=M,he=Math.floor((ee-20)/4),Ce=Math.min(he,q.length);return Ce0,maxBones:De,useVertexTexture:_,morphTargets:O.morphTargets,morphNormals:O.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:U.directional.length,numPointLights:U.point.length,numSpotLights:U.spot.length,numRectAreaLights:U.rectArea.length,numHemiLights:U.hemi.length,numDirLightShadows:U.directionalShadowMap.length,numPointLightShadows:U.pointShadowMap.length,numSpotLightShadows:U.spotShadowMap.length,numClippingPlanes:he,numClipIntersection:Ce,dithering:O.dithering,shadowMapEnabled:e.shadowMap.enabled&&q.length>0,shadowMapType:e.shadowMap.type,toneMapping:O.toneMapped?e.toneMapping:Vp,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:O.premultipliedAlpha,alphaTest:O.alphaTest,doubleSided:O.side===rh,flipSided:O.side===tr,depthPacking:O.depthPacking!==void 0?O.depthPacking:!1,index0AttributeName:O.index0AttributeName,extensionDerivatives:O.extensions&&O.extensions.derivatives,extensionFragDepth:O.extensions&&O.extensions.frawbuffers,extensionDrawbuffers:O.extensions&&O.extensions.drawbuffers,extensionShaderTextureLOD:O.extensions&&O.extensions.shaderTextureLOD,rendererExtensionFragDepth:h||n.get("EXT_frag_depth")!==null,rendererExtensionDrawBuffers:h||n.get("WEBGL_draw_buffers")!==null,rendererExtensionShaderTextureLod:h||n.get("EXT_shader_texture_lod")!==null,onBeforeCompile:O.onBeforeCompile};return Oe},this.getProgramCacheKey=function(O){var U=[];if(O.shaderID?U.push(O.shaderID):(U.push(O.fragmentShader),U.push(O.vertexShader)),O.defines!==void 0)for(var q in O.defines)U.push(q),U.push(O.defines[q]);if(O.isRawShaderMaterial===void 0){for(var ee=0;ee1&&i.sort(C||lC),l.length>1&&l.sort(E||cC)}return{opaque:i,transparent:l,init:p,push:s,unshift:M,sort:T}}function uC(){var e=new WeakMap;function n(h){var p=h.target;p.removeEventListener("dispose",n),e.delete(p)}function i(h,p){var _=e.get(h),s;return _===void 0?(s=new cx,e.set(h,new WeakMap),e.get(h).set(p,s),h.addEventListener("dispose",n)):(s=_.get(p),s===void 0&&(s=new cx,_.set(p,s))),s}function l(){e=new WeakMap}return{get:i,dispose:l}}function hC(){var e={};return{get:function(n){if(e[n.id]!==void 0)return e[n.id];var i;switch(n.type){case"DirectionalLight":i={direction:new Ee,color:new en,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Lt};break;case"SpotLight":i={position:new Ee,direction:new Ee,color:new en,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Lt};break;case"PointLight":i={position:new Ee,color:new en,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Lt,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":i={direction:new Ee,skyColor:new en,groundColor:new en};break;case"RectAreaLight":i={color:new en,position:new Ee,halfWidth:new Ee,halfHeight:new Ee};break}return e[n.id]=i,i}}}var dC=0;function pC(e,n){return(n.castShadow?1:0)-(e.castShadow?1:0)}function fC(){for(var e=new hC,n={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++)n.probe.push(new Ee);var l=new Ee,h=new jn,p=new jn;function _(s,M,T){for(var C=0,E=0,L=0,I=0;I<9;I++)n.probe[I].set(0,0,0);var B=0,O=0,U=0,q=0,ee=0,he=0,Ce=0,K=0,ie=T.matrixWorldInverse;s.sort(pC);for(var I=0,ue=s.length;I 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 ) ); }`,_C=`void main() { gl_Position = vec4( position, 1.0 ); }`;function hx(e,n,i){var l=new wh,h=new Lt,p=new Lt,_=new gi,s=[],M=[],T={},C={0:tr,1:Jl,2:rh},E=new Nr({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new Lt},radius:{value:4}},vertexShader:_C,fragmentShader:gC}),L=E.clone();L.defines.HORIZONAL_PASS=1;var I=new yn;I.setAttribute("position",new zn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var B=new Ai(I,E),O=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=i0,this.render=function(K,ie,ue){if(O.enabled!==!1&&!(O.autoUpdate===!1&&O.needsUpdate===!1)&&K.length!==0){var ae=e.getRenderTarget(),le=e.getActiveCubeFace(),De=e.getActiveMipmapLevel(),ye=e.state;ye.setBlending(Qo),ye.buffers.color.setClear(1,1,1,1),ye.buffers.depth.setTest(!0),ye.setScissorTest(!1);for(var se=0,Ue=K.length;sei||h.y>i)&&(console.warn("THREE.WebGLShadowMap:",Oe,"has shadow exceeding max texture size, reducing"),h.x>i&&(p.x=Math.floor(i/st.x),h.x=p.x*st.x,We.mapSize.x=p.x),h.y>i&&(p.y=Math.floor(i/st.y),h.y=p.y*st.y,We.mapSize.y=p.y)),We.map===null&&!We.isPointLightShadow&&this.type===ih){var St={minFilter:qi,magFilter:qi,format:Aa};We.map=new Mr(h.x,h.y,St),We.map.texture.name=Oe.name+".shadowMap",We.mapPass=new Mr(h.x,h.y,St),We.camera.updateProjectionMatrix()}if(We.map===null){var St={minFilter:Ui,magFilter:Ui,format:Aa};We.map=new Mr(h.x,h.y,St),We.map.texture.name=Oe.name+".shadowMap",We.camera.updateProjectionMatrix()}e.setRenderTarget(We.map),e.clear();for(var gt=We.getViewportCount(),At=0;At0:ye.isGeometry===!0&&(We=ye.morphTargets&&ye.morphTargets.length>0));var st=!1;K.isSkinnedMesh===!0&&(ie.skinning===!0?st=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",K));var St=K.isInstancedMesh===!0;se=Ue(We,st,St)}else se=Oe;if(e.localClippingEnabled&&ie.clipShadows===!0&&ie.clippingPlanes.length!==0){var gt=se.uuid,At=ie.uuid,Dt=T[gt];Dt===void 0&&(Dt={},T[gt]=Dt);var Ot=Dt[At];Ot===void 0&&(Ot=se.clone(),Dt[At]=Ot),se=Ot}return se.visible=ie.visible,se.wireframe=ie.wireframe,De===ih?se.side=ie.shadowSide!==null?ie.shadowSide:ie.side:se.side=ie.shadowSide!==null?ie.shadowSide:C[ie.side],se.clipShadows=ie.clipShadows,se.clippingPlanes=ie.clippingPlanes,se.clipIntersection=ie.clipIntersection,se.wireframeLinewidth=ie.wireframeLinewidth,se.linewidth=ie.linewidth,ue.isPointLight===!0&&se.isMeshDistanceMaterial===!0&&(se.referencePosition.setFromMatrixPosition(ue.matrixWorld),se.nearDistance=ae,se.farDistance=le),se}function Ce(K,ie,ue,ae,le){if(K.visible!==!1){var De=K.layers.test(ie.layers);if(De&&(K.isMesh||K.isLine||K.isPoints)&&(K.castShadow||K.receiveShadow&&le===ih)&&(!K.frustumCulled||l.intersectsObject(K))){K.modelViewMatrix.multiplyMatrices(ue.matrixWorldInverse,K.matrixWorld);var ye=n.update(K),se=K.material;if(Array.isArray(se))for(var Ue=ye.groups,Oe=0,We=Ue.length;Oe=1):St.indexOf("OpenGL ES")!==-1&&(st=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(St)[1]),We=st>=2);var gt=null,At={},Dt=new gi,Ot=new gi;function Pe(qe,Nt,Qt){var Pn=new Uint8Array(4),pn=e.createTexture();e.bindTexture(qe,pn),e.texParameteri(qe,10241,9728),e.texParameteri(qe,10240,9728);for(var On=0;Onmt||oe.height>mt)&&(xn=mt/Math.max(oe.width,oe.height)),xn<1||ve===!0)if(typeof HTMLImageElement!="undefined"&&oe instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&oe instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&oe instanceof ImageBitmap){var un=ve?Wn.floorPowerOfTwo:Math.floor,tn=un(xn*oe.width),dn=un(xn*oe.height);I===void 0&&(I=O(tn,dn));var bn=xt?O(tn,dn):I;bn.width=tn,bn.height=dn;var ln=bn.getContext("2d");return ln.drawImage(oe,0,0,tn,dn),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+oe.width+"x"+oe.height+") to ("+tn+"x"+dn+")."),bn}else return"data"in oe&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+oe.width+"x"+oe.height+")."),oe;return oe}function q(oe){return Wn.isPowerOfTwo(oe.width)&&Wn.isPowerOfTwo(oe.height)}function ee(oe){return s?!1:oe.wrapS!==wr||oe.wrapT!==wr||oe.minFilter!==Ui&&oe.minFilter!==qi}function he(oe,ve){return oe.generateMipmaps&&ve&&oe.minFilter!==Ui&&oe.minFilter!==qi}function Ce(oe,ve,xt,mt){e.generateMipmap(oe);var xn=l.get(ve);xn.__maxMipLevel=Math.log(Math.max(xt,mt))*Math.LOG2E}function K(oe,ve,xt){if(s===!1)return ve;if(oe!==null){if(e[oe]!==void 0)return e[oe];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+oe+"'")}var mt=ve;return ve===6403&&(xt===5126&&(mt=33326),xt===5131&&(mt=33325),xt===5121&&(mt=33321)),ve===6407&&(xt===5126&&(mt=34837),xt===5131&&(mt=34843),xt===5121&&(mt=32849)),ve===6408&&(xt===5126&&(mt=34836),xt===5131&&(mt=34842),xt===5121&&(mt=32856)),mt===33325||mt===33326||mt===34842||mt===34836?n.get("EXT_color_buffer_float"):(mt===34843||mt===34837)&&console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead."),mt}function ie(oe){return oe===Ui||oe===Gp||oe===Hp?9728:9729}function ue(oe){var ve=oe.target;ve.removeEventListener("dispose",ue),le(ve),ve.isVideoTexture&&L.delete(ve),_.memory.textures--}function ae(oe){var ve=oe.target;ve.removeEventListener("dispose",ae),De(ve),_.memory.textures--}function le(oe){var ve=l.get(oe);ve.__webglInit!==void 0&&(e.deleteTexture(ve.__webglTexture),l.remove(oe))}function De(oe){var ve=l.get(oe),xt=l.get(oe.texture);if(oe){if(xt.__webglTexture!==void 0&&e.deleteTexture(xt.__webglTexture),oe.depthTexture&&oe.depthTexture.dispose(),oe.isWebGLCubeRenderTarget)for(var mt=0;mt<6;mt++)e.deleteFramebuffer(ve.__webglFramebuffer[mt]),ve.__webglDepthbuffer&&e.deleteRenderbuffer(ve.__webglDepthbuffer[mt]);else e.deleteFramebuffer(ve.__webglFramebuffer),ve.__webglDepthbuffer&&e.deleteRenderbuffer(ve.__webglDepthbuffer);if(oe.isWebGLMultiviewRenderTarget){e.deleteTexture(ve.__webglColorTexture),e.deleteTexture(ve.__webglDepthStencilTexture),_.memory.textures-=2;for(var mt=0,xn=ve.__webglViewFramebuffers.length;mt=M&&console.warn("THREE.WebGLTextures: Trying to use "+oe+" texture units while this GPU supports only "+M),ye+=1,oe}function Oe(oe,ve){var xt=l.get(oe);if(oe.isVideoTexture&&Be(oe),oe.version>0&&xt.__version!==oe.version){var mt=oe.image;if(mt===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(mt.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ge(xt,oe,ve);return}}i.activeTexture(33984+ve),i.bindTexture(3553,xt.__webglTexture)}function We(oe,ve){var xt=l.get(oe);if(oe.version>0&&xt.__version!==oe.version){ge(xt,oe,ve);return}i.activeTexture(33984+ve),i.bindTexture(35866,xt.__webglTexture)}function st(oe,ve){var xt=l.get(oe);if(oe.version>0&&xt.__version!==oe.version){ge(xt,oe,ve);return}i.activeTexture(33984+ve),i.bindTexture(32879,xt.__webglTexture)}function St(oe,ve){if(oe.image.length===6){var xt=l.get(oe);if(oe.version>0&&xt.__version!==oe.version){Pe(xt,oe),i.activeTexture(33984+ve),i.bindTexture(34067,xt.__webglTexture),e.pixelStorei(37440,oe.flipY);for(var mt=oe&&(oe.isCompressedTexture||oe.image[0].isCompressedTexture),xn=oe.image[0]&&oe.image[0].isDataTexture,un=[],tn=0;tn<6;tn++)!mt&&!xn?un[tn]=U(oe.image[tn],!1,!0,T):un[tn]=xn?oe.image[tn].image:oe.image[tn];var dn=un[0],bn=q(dn)||s,ln=p.convert(oe.format),Gt=p.convert(oe.type),on=K(oe.internalFormat,ln,Gt);Ot(34067,oe,bn);var Zt;if(mt){for(var tn=0;tn<6;tn++){Zt=un[tn].mipmaps;for(var qe=0;qe1||l.get(ve).__currentAnisotropy)&&(e.texParameterf(oe,mt.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(ve.anisotropy,h.getMaxAnisotropy())),l.get(ve).__currentAnisotropy=ve.anisotropy)}}function Pe(oe,ve){oe.__webglInit===void 0&&(oe.__webglInit=!0,ve.addEventListener("dispose",ue),oe.__webglTexture=e.createTexture(),_.memory.textures++)}function ge(oe,ve,xt){var mt=3553;ve.isDataTexture2DArray&&(mt=35866),ve.isDataTexture3D&&(mt=32879),Pe(oe,ve),i.activeTexture(33984+xt),i.bindTexture(mt,oe.__webglTexture),e.pixelStorei(37440,ve.flipY),e.pixelStorei(37441,ve.premultiplyAlpha),e.pixelStorei(3317,ve.unpackAlignment);var xn=ee(ve)&&q(ve.image)===!1,un=U(ve.image,xn,!1,C),tn=q(un)||s,dn=p.convert(ve.format),bn=p.convert(ve.type),ln=K(ve.internalFormat,dn,bn);Ot(mt,ve,tn);var Gt,on=ve.mipmaps;if(ve.isDepthTexture){if(ln=6402,ve.type===lh){if(s===!1)throw new Error("Float Depth Texture only supported in WebGL2.0");ln=36012}else s&&(ln=33189);ve.format===tc&&ln===6402&&ve.type!==jp&&ve.type!==m0&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),ve.type=jp,bn=p.convert(ve.type)),ve.format===ch&&(ln=34041,ve.type!==qp&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),ve.type=qp,bn=p.convert(ve.type))),i.texImage2D(3553,0,ln,un.width,un.height,0,dn,bn,null)}else if(ve.isDataTexture)if(on.length>0&&tn){for(var Zt=0,qe=on.length;Zt0&&tn){for(var Zt=0,qe=on.length;ZtL)return!1;for(var le=1,De=ae.length;le=0){var Dn=Mt[nn];if(Dn!==void 0){var wt=Dn.normalized,cn=Dn.itemSize,$t=ot.get(Dn);if($t===void 0)continue;var fn=$t.buffer,Tn=$t.type,Sn=$t.bytesPerElement;if(Dn.isInterleavedBufferAttribute){var di=Dn.data,Ar=di.stride,ai=Dn.offset;di&&di.isInstancedInterleavedBuffer?(Me.enableAttributeAndDivisor(Ln,di.meshPerAttribute),Y.maxInstancedCount===void 0&&(Y.maxInstancedCount=di.meshPerAttribute*di.count)):Me.enableAttribute(Ln),Ie.bindBuffer(34962,fn),Ie.vertexAttribPointer(Ln,cn,Tn,wt,Ar*Sn,ai*Sn)}else Dn.isInstancedBufferAttribute?(Me.enableAttributeAndDivisor(Ln,Dn.meshPerAttribute),Y.maxInstancedCount===void 0&&(Y.maxInstancedCount=Dn.meshPerAttribute*Dn.count)):Me.enableAttribute(Ln),Ie.bindBuffer(34962,fn),Ie.vertexAttribPointer(Ln,cn,Tn,wt,0,0)}else if(nn==="instanceMatrix"){var $t=ot.get(W.instanceMatrix);if($t===void 0)continue;var fn=$t.buffer,Tn=$t.type;Me.enableAttributeAndDivisor(Ln+0,1),Me.enableAttributeAndDivisor(Ln+1,1),Me.enableAttributeAndDivisor(Ln+2,1),Me.enableAttributeAndDivisor(Ln+3,1),Ie.bindBuffer(34962,fn),Ie.vertexAttribPointer(Ln+0,4,Tn,!1,64,0),Ie.vertexAttribPointer(Ln+1,4,Tn,!1,64,16),Ie.vertexAttribPointer(Ln+2,4,Tn,!1,64,32),Ie.vertexAttribPointer(Ln+3,4,Tn,!1,64,48)}else if(Ft!==void 0){var li=Ft[nn];if(li!==void 0)switch(li.length){case 2:Ie.vertexAttrib2fv(Ln,li);break;case 3:Ie.vertexAttrib3fv(Ln,li);break;case 4:Ie.vertexAttrib4fv(Ln,li);break;default:Ie.vertexAttrib1fv(Ln,li)}}}}Me.disableUnusedAttributes()}}this.compile=function(W,Y){L=xt.get(W,Y),L.init(),W.traverse(function(xe){xe.isLight&&(L.pushLight(xe),xe.castShadow&&L.pushShadow(xe))}),L.setupLights(Y);var ze={};W.traverse(function(xe){if(xe.material)if(Array.isArray(xe.material))for(var Mt=0;Mt=0&&W.numSupportedMorphTargets++}if(W.morphNormals){W.numSupportedMorphNormals=0;for(var $t=0;$t=0&&W.numSupportedMorphNormals++}var fn=xe.uniforms;(!W.isShaderMaterial&&!W.isRawShaderMaterial||W.clipping===!0)&&(xe.numClippingPlanes=Dt.numPlanes,xe.numIntersection=Dt.numIntersection,fn.clippingPlanes=Dt.uniform),xe.fog=Y.fog,xe.needsLights=_n(W),xe.lightsStateVersion=Ft,xe.needsLights&&(fn.ambientLightColor.value=Mt.state.ambient,fn.lightProbe.value=Mt.state.probe,fn.directionalLights.value=Mt.state.directional,fn.spotLights.value=Mt.state.spot,fn.rectAreaLights.value=Mt.state.rectArea,fn.pointLights.value=Mt.state.point,fn.hemisphereLights.value=Mt.state.hemi,fn.directionalShadowMap.value=Mt.state.directionalShadowMap,fn.directionalShadowMatrix.value=Mt.state.directionalShadowMatrix,fn.spotShadowMap.value=Mt.state.spotShadowMap,fn.spotShadowMatrix.value=Mt.state.spotShadowMatrix,fn.pointShadowMap.value=Mt.state.pointShadowMap,fn.pointShadowMatrix.value=Mt.state.pointShadowMatrix);var Tn=xe.program.getUniforms(),Sn=as.seqWithValue(Tn.seq,fn);xe.uniformsList=Sn}function Hr(W,Y,ze,xe){$e.resetTextureUnits();var Mt=Y.fog,_t=ze.isMeshStandardMaterial?Y.environment:null,Ft=Be.get(ze),nn=L.state.lights;if(Ot&&(Pe||W!==ie)){var Ln=W===ie&&ze.id===Ce;Dt.setState(ze.clippingPlanes,ze.clipIntersection,ze.clipShadows,W,Ft,Ln)}ze.version===Ft.__version?(Ft.program===void 0||ze.fog&&Ft.fog!==Mt||Ft.environment!==_t||Ft.needsLights&&Ft.lightsStateVersion!==nn.state.version||Ft.numClippingPlanes!==void 0&&(Ft.numClippingPlanes!==Dt.numPlanes||Ft.numIntersection!==Dt.numIntersection)||Ft.outputEncoding!==I.outputEncoding)&&yi(ze,Y,xe):(yi(ze,Y,xe),Ft.__version=ze.version);var Dn=!1,wt=!1,cn=!1,$t=Ft.program,fn=$t.getUniforms(),Tn=Ft.uniforms;if(Me.useProgram($t.program)&&(Dn=!0,wt=!0,cn=!0),ze.id!==Ce&&(Ce=ze.id,wt=!0),Dn||ie!==W){if($t.numMultiviewViews>0?Gt.updateCameraProjectionMatricesUniform(W,fn):fn.setValue(Ie,"projectionMatrix",W.projectionMatrix),we.logarithmicDepthBuffer&&fn.setValue(Ie,"logDepthBufFC",2/(Math.log(W.far+1)/Math.LN2)),ie!==W&&(ie=W,wt=!0,cn=!0),ze.isShaderMaterial||ze.isMeshPhongMaterial||ze.isMeshToonMaterial||ze.isMeshStandardMaterial||ze.envMap){var Sn=fn.map.cameraPosition;Sn!==void 0&&Sn.setValue(Ie,Ve.setFromMatrixPosition(W.matrixWorld))}(ze.isMeshPhongMaterial||ze.isMeshToonMaterial||ze.isMeshLambertMaterial||ze.isMeshBasicMaterial||ze.isMeshStandardMaterial||ze.isShaderMaterial)&&fn.setValue(Ie,"isOrthographic",W.isOrthographicCamera===!0),(ze.isMeshPhongMaterial||ze.isMeshToonMaterial||ze.isMeshLambertMaterial||ze.isMeshBasicMaterial||ze.isMeshStandardMaterial||ze.isShaderMaterial||ze.skinning)&&($t.numMultiviewViews>0?Gt.updateCameraViewMatricesUniform(W,fn):fn.setValue(Ie,"viewMatrix",W.matrixWorldInverse))}if(ze.skinning){fn.setOptional(Ie,xe,"bindMatrix"),fn.setOptional(Ie,xe,"bindMatrixInverse");var di=xe.skeleton;if(di){var Ar=di.bones;if(we.floatVertexTextures){if(di.boneTexture===void 0){var ai=Math.sqrt(Ar.length*4);ai=Wn.ceilPowerOfTwo(ai),ai=Math.max(ai,4);var li=new Float32Array(ai*ai*4);li.set(di.boneMatrices);var oi=new Mc(li,ai,ai,Aa,lh);di.boneMatrices=li,di.boneTexture=oi,di.boneTextureSize=ai}fn.setValue(Ie,"boneTexture",di.boneTexture,$e),fn.setValue(Ie,"boneTextureSize",di.boneTextureSize)}else fn.setOptional(Ie,di,"boneMatrices")}}return(wt||Ft.receiveShadow!==xe.receiveShadow)&&(Ft.receiveShadow=xe.receiveShadow,fn.setValue(Ie,"receiveShadow",xe.receiveShadow)),wt&&(fn.setValue(Ie,"toneMappingExposure",I.toneMappingExposure),fn.setValue(Ie,"toneMappingWhitePoint",I.toneMappingWhitePoint),Ft.needsLights&&Et(Tn,cn),Mt&&ze.fog&&Z(Tn,Mt),ze.isMeshBasicMaterial?ki(Tn,ze):ze.isMeshLambertMaterial?(ki(Tn,ze),de(Tn,ze)):ze.isMeshToonMaterial?(ki(Tn,ze),Ge(Tn,ze)):ze.isMeshPhongMaterial?(ki(Tn,ze),Le(Tn,ze)):ze.isMeshStandardMaterial?(ki(Tn,ze,_t),ze.isMeshPhysicalMaterial?Ke(Tn,ze,_t):Je(Tn,ze,_t)):ze.isMeshMatcapMaterial?(ki(Tn,ze),je(Tn,ze)):ze.isMeshDepthMaterial?(ki(Tn,ze),nt(Tn,ze)):ze.isMeshDistanceMaterial?(ki(Tn,ze),yt(Tn,ze)):ze.isMeshNormalMaterial?(ki(Tn,ze),Ut(Tn,ze)):ze.isLineBasicMaterial?(Wr(Tn,ze),ze.isLineDashedMaterial&&Sr(Tn,ze)):ze.isPointsMaterial?_e(Tn,ze):ze.isSpriteMaterial?G(Tn,ze):ze.isShadowMaterial&&(Tn.color.value.copy(ze.color),Tn.opacity.value=ze.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(Ie,Ft.uniformsList,Tn,$e),ze.isShaderMaterial&&(ze.uniformsNeedUpdate=!1)),ze.isShaderMaterial&&ze.uniformsNeedUpdate===!0&&(as.upload(Ie,Ft.uniformsList,Tn,$e),ze.uniformsNeedUpdate=!1),ze.isSpriteMaterial&&fn.setValue(Ie,"center",xe.center),$t.numMultiviewViews>0?Gt.updateObjectMatricesUniforms(xe,W,fn):(fn.setValue(Ie,"modelViewMatrix",xe.modelViewMatrix),fn.setValue(Ie,"normalMatrix",xe.normalMatrix)),fn.setValue(Ie,"modelMatrix",xe.matrixWorld),$t}function ki(W,Y,ze){W.opacity.value=Y.opacity,Y.color&&W.diffuse.value.copy(Y.color),Y.emissive&&W.emissive.value.copy(Y.emissive).multiplyScalar(Y.emissiveIntensity),Y.map&&(W.map.value=Y.map),Y.alphaMap&&(W.alphaMap.value=Y.alphaMap),Y.specularMap&&(W.specularMap.value=Y.specularMap);var xe=Y.envMap||ze;xe&&(W.envMap.value=xe,W.flipEnvMap.value=xe.isCubeTexture?-1:1,W.reflectivity.value=Y.reflectivity,W.refractionRatio.value=Y.refractionRatio,W.maxMipLevel.value=Be.get(xe).__maxMipLevel),Y.lightMap&&(W.lightMap.value=Y.lightMap,W.lightMapIntensity.value=Y.lightMapIntensity),Y.aoMap&&(W.aoMap.value=Y.aoMap,W.aoMapIntensity.value=Y.aoMapIntensity);var Mt;Y.map?Mt=Y.map:Y.specularMap?Mt=Y.specularMap:Y.displacementMap?Mt=Y.displacementMap:Y.normalMap?Mt=Y.normalMap:Y.bumpMap?Mt=Y.bumpMap:Y.roughnessMap?Mt=Y.roughnessMap:Y.metalnessMap?Mt=Y.metalnessMap:Y.alphaMap?Mt=Y.alphaMap:Y.emissiveMap&&(Mt=Y.emissiveMap),Mt!==void 0&&(Mt.isWebGLRenderTarget&&(Mt=Mt.texture),Mt.matrixAutoUpdate===!0&&Mt.updateMatrix(),W.uvTransform.value.copy(Mt.matrix));var _t;Y.aoMap?_t=Y.aoMap:Y.lightMap&&(_t=Y.lightMap),_t!==void 0&&(_t.isWebGLRenderTarget&&(_t=_t.texture),_t.matrixAutoUpdate===!0&&_t.updateMatrix(),W.uv2Transform.value.copy(_t.matrix))}function Wr(W,Y){W.diffuse.value.copy(Y.color),W.opacity.value=Y.opacity}function Sr(W,Y){W.dashSize.value=Y.dashSize,W.totalSize.value=Y.dashSize+Y.gapSize,W.scale.value=Y.scale}function _e(W,Y){W.diffuse.value.copy(Y.color),W.opacity.value=Y.opacity,W.size.value=Y.size*Ue,W.scale.value=se*.5,Y.map&&(W.map.value=Y.map),Y.alphaMap&&(W.alphaMap.value=Y.alphaMap);var ze;Y.map?ze=Y.map:Y.alphaMap&&(ze=Y.alphaMap),ze!==void 0&&(ze.matrixAutoUpdate===!0&&ze.updateMatrix(),W.uvTransform.value.copy(ze.matrix))}function G(W,Y){W.diffuse.value.copy(Y.color),W.opacity.value=Y.opacity,W.rotation.value=Y.rotation,Y.map&&(W.map.value=Y.map),Y.alphaMap&&(W.alphaMap.value=Y.alphaMap);var ze;Y.map?ze=Y.map:Y.alphaMap&&(ze=Y.alphaMap),ze!==void 0&&(ze.matrixAutoUpdate===!0&&ze.updateMatrix(),W.uvTransform.value.copy(ze.matrix))}function Z(W,Y){W.fogColor.value.copy(Y.color),Y.isFog?(W.fogNear.value=Y.near,W.fogFar.value=Y.far):Y.isFogExp2&&(W.fogDensity.value=Y.density)}function de(W,Y){Y.emissiveMap&&(W.emissiveMap.value=Y.emissiveMap)}function Le(W,Y){W.specular.value.copy(Y.specular),W.shininess.value=Math.max(Y.shininess,1e-4),Y.emissiveMap&&(W.emissiveMap.value=Y.emissiveMap),Y.bumpMap&&(W.bumpMap.value=Y.bumpMap,W.bumpScale.value=Y.bumpScale,Y.side===tr&&(W.bumpScale.value*=-1)),Y.normalMap&&(W.normalMap.value=Y.normalMap,W.normalScale.value.copy(Y.normalScale),Y.side===tr&&W.normalScale.value.negate()),Y.displacementMap&&(W.displacementMap.value=Y.displacementMap,W.displacementScale.value=Y.displacementScale,W.displacementBias.value=Y.displacementBias)}function Ge(W,Y){W.specular.value.copy(Y.specular),W.shininess.value=Math.max(Y.shininess,1e-4),Y.gradientMap&&(W.gradientMap.value=Y.gradientMap),Y.emissiveMap&&(W.emissiveMap.value=Y.emissiveMap),Y.bumpMap&&(W.bumpMap.value=Y.bumpMap,W.bumpScale.value=Y.bumpScale,Y.side===tr&&(W.bumpScale.value*=-1)),Y.normalMap&&(W.normalMap.value=Y.normalMap,W.normalScale.value.copy(Y.normalScale),Y.side===tr&&W.normalScale.value.negate()),Y.displacementMap&&(W.displacementMap.value=Y.displacementMap,W.displacementScale.value=Y.displacementScale,W.displacementBias.value=Y.displacementBias)}function Je(W,Y,ze){W.roughness.value=Y.roughness,W.metalness.value=Y.metalness,Y.roughnessMap&&(W.roughnessMap.value=Y.roughnessMap),Y.metalnessMap&&(W.metalnessMap.value=Y.metalnessMap),Y.emissiveMap&&(W.emissiveMap.value=Y.emissiveMap),Y.bumpMap&&(W.bumpMap.value=Y.bumpMap,W.bumpScale.value=Y.bumpScale,Y.side===tr&&(W.bumpScale.value*=-1)),Y.normalMap&&(W.normalMap.value=Y.normalMap,W.normalScale.value.copy(Y.normalScale),Y.side===tr&&W.normalScale.value.negate()),Y.displacementMap&&(W.displacementMap.value=Y.displacementMap,W.displacementScale.value=Y.displacementScale,W.displacementBias.value=Y.displacementBias),(Y.envMap||ze)&&(W.envMapIntensity.value=Y.envMapIntensity)}function Ke(W,Y,ze){Je(W,Y,ze),W.reflectivity.value=Y.reflectivity,W.clearcoat.value=Y.clearcoat,W.clearcoatRoughness.value=Y.clearcoatRoughness,Y.sheen&&W.sheen.value.copy(Y.sheen),Y.clearcoatNormalMap&&(W.clearcoatNormalScale.value.copy(Y.clearcoatNormalScale),W.clearcoatNormalMap.value=Y.clearcoatNormalMap,Y.side===tr&&W.clearcoatNormalScale.value.negate()),W.transparency.value=Y.transparency}function je(W,Y){Y.matcap&&(W.matcap.value=Y.matcap),Y.bumpMap&&(W.bumpMap.value=Y.bumpMap,W.bumpScale.value=Y.bumpScale,Y.side===tr&&(W.bumpScale.value*=-1)),Y.normalMap&&(W.normalMap.value=Y.normalMap,W.normalScale.value.copy(Y.normalScale),Y.side===tr&&W.normalScale.value.negate()),Y.displacementMap&&(W.displacementMap.value=Y.displacementMap,W.displacementScale.value=Y.displacementScale,W.displacementBias.value=Y.displacementBias)}function nt(W,Y){Y.displacementMap&&(W.displacementMap.value=Y.displacementMap,W.displacementScale.value=Y.displacementScale,W.displacementBias.value=Y.displacementBias)}function yt(W,Y){Y.displacementMap&&(W.displacementMap.value=Y.displacementMap,W.displacementScale.value=Y.displacementScale,W.displacementBias.value=Y.displacementBias),W.referencePosition.value.copy(Y.referencePosition),W.nearDistance.value=Y.nearDistance,W.farDistance.value=Y.farDistance}function Ut(W,Y){Y.bumpMap&&(W.bumpMap.value=Y.bumpMap,W.bumpScale.value=Y.bumpScale,Y.side===tr&&(W.bumpScale.value*=-1)),Y.normalMap&&(W.normalMap.value=Y.normalMap,W.normalScale.value.copy(Y.normalScale),Y.side===tr&&W.normalScale.value.negate()),Y.displacementMap&&(W.displacementMap.value=Y.displacementMap,W.displacementScale.value=Y.displacementScale,W.displacementBias.value=Y.displacementBias)}function Et(W,Y){W.ambientLightColor.needsUpdate=Y,W.lightProbe.needsUpdate=Y,W.directionalLights.needsUpdate=Y,W.pointLights.needsUpdate=Y,W.spotLights.needsUpdate=Y,W.rectAreaLights.needsUpdate=Y,W.hemisphereLights.needsUpdate=Y}function _n(W){return W.isMeshLambertMaterial||W.isMeshToonMaterial||W.isMeshPhongMaterial||W.isMeshStandardMaterial||W.isShadowMaterial||W.isShaderMaterial&&W.lights===!0}this.setFramebuffer=function(W){O!==W&&ee===null&&Ie.bindFramebuffer(36160,W),O=W},this.getActiveCubeFace=function(){return U},this.getActiveMipmapLevel=function(){return q},this.getRenderTarget=function(){return ee},this.setRenderTarget=function(W,Y,ze){ee=W,U=Y,q=ze,W&&Be.get(W).__webglFramebuffer===void 0&&$e.setupRenderTarget(W);var xe=O,Mt=!1;if(W){var _t=Be.get(W).__webglFramebuffer;W.isWebGLCubeRenderTarget?(xe=_t[Y||0],Mt=!0):W.isWebGLMultisampleRenderTarget?xe=Be.get(W).__webglMultisampledFramebuffer:xe=_t,ae.copy(W.viewport),le.copy(W.scissor),De=W.scissorTest}else ae.copy(st).multiplyScalar(Ue).floor(),le.copy(St).multiplyScalar(Ue).floor(),De=gt;if(he!==xe&&(Ie.bindFramebuffer(36160,xe),he=xe),Me.viewport(ae),Me.scissor(le),Me.setScissorTest(De),Mt){var Ft=Be.get(W.texture);Ie.framebufferTexture2D(36160,36064,34069+(Y||0),Ft.__webglTexture,ze||0)}},this.readRenderTargetPixels=function(W,Y,ze,xe,Mt,_t,Ft){if(!(W&&W.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}var nn=Be.get(W).__webglFramebuffer;if(W.isWebGLCubeRenderTarget&&Ft!==void 0&&(nn=nn[Ft]),nn){var Ln=!1;nn!==he&&(Ie.bindFramebuffer(36160,nn),Ln=!0);try{var Dn=W.texture,wt=Dn.format,cn=Dn.type;if(wt!==Aa&&dn.convert(wt)!==Ie.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(cn!==Wp&&dn.convert(cn)!==Ie.getParameter(35738)&&!(cn===lh&&(we.isWebGL2||ce.get("OES_texture_float")||ce.get("WEBGL_color_buffer_float")))&&!(cn===$g&&(we.isWebGL2?ce.get("EXT_color_buffer_float"):ce.get("EXT_color_buffer_half_float")))){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ie.checkFramebufferStatus(36160)===36053?Y>=0&&Y<=W.width-xe&&ze>=0&&ze<=W.height-Mt&&Ie.readPixels(Y,ze,xe,Mt,dn.convert(wt),dn.convert(cn),_t):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{Ln&&Ie.bindFramebuffer(36160,he)}}},this.copyFramebufferToTexture=function(W,Y,ze){ze===void 0&&(ze=0);var xe=Math.pow(2,-ze),Mt=Math.floor(Y.image.width*xe),_t=Math.floor(Y.image.height*xe),Ft=dn.convert(Y.format);$e.setTexture2D(Y,0),Ie.copyTexImage2D(3553,ze,Ft,W.x,W.y,Mt,_t,0),Me.unbindTexture()},this.copyTextureToTexture=function(W,Y,ze,xe){var Mt=Y.image.width,_t=Y.image.height,Ft=dn.convert(ze.format),nn=dn.convert(ze.type);$e.setTexture2D(ze,0),Y.isDataTexture?Ie.texSubImage2D(3553,xe||0,W.x,W.y,Mt,_t,Ft,nn,Y.image.data):Ie.texSubImage2D(3553,xe||0,W.x,W.y,Ft,nn,Y.image),Me.unbindTexture()},this.initTexture=function(W){$e.setTexture2D(W,0),Me.unbindTexture()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function P_(e,n){this.name="",this.color=new en(e),this.density=n!==void 0?n:25e-5}Object.assign(P_.prototype,{isFogExp2:!0,clone:function(){return new P_(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}});function L_(e,n,i){this.name="",this.color=new en(e),this.near=n!==void 0?n:1,this.far=i!==void 0?i:1e3}Object.assign(L_.prototype,{isFog:!0,clone:function(){return new L_(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}});function zo(e,n){this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=Xp,this.updateRange={offset:0,count:-1},this.version=0}Object.defineProperty(zo.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(zo.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,n,i){e*=this.stride,i*=n.stride;for(var l=0,h=this.stride;le.far||n.push({distance:s,point:Ch.clone(),uv:sr.getUV(Ch,ff,Lh,mf,mx,D_,gx,new Lt),face:null,object:this})}},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return rn.prototype.copy.call(this,e),e.center!==void 0&&this.center.copy(e.center),this}});function gf(e,n,i,l,h,p){Lc.subVectors(e,i).addScalar(.5).multiply(l),h!==void 0?(Ph.x=p*Lc.x-h*Lc.y,Ph.y=h*Lc.x+p*Lc.y):Ph.copy(Lc),e.copy(n),e.x+=Ph.x,e.y+=Ph.y,e.applyMatrix4(fx)}var _f=new Ee,_x=new Ee;function yf(){rn.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}yf.prototype=Object.assign(Object.create(rn.prototype),{constructor:yf,isLOD:!0,copy:function(e){rn.prototype.copy.call(this,e,!1);for(var n=e.levels,i=0,l=n.length;i0){for(var i=1,l=n.length;i0){_f.setFromMatrixPosition(this.matrixWorld);var l=e.ray.origin.distanceTo(_f);this.getObjectForDistance(l).raycast(e,n)}},update:function(e){var n=this.levels;if(n.length>1){_f.setFromMatrixPosition(e.matrixWorld),_x.setFromMatrixPosition(this.matrixWorld);var i=_f.distanceTo(_x);n[0].object.visible=!0;for(var l=1,h=n.length;l=n[l].distance;l++)n[l-1].object.visible=!1,n[l].object.visible=!0;for(;l0&&(Dc[0].instanceId=h,Dc[0].object=this,n.push(Dc[0]),Dc.length=0)},setMatrixAt:function(e,n){n.toArray(this.instanceMatrix.array,e*16)},updateMorphTargets:function(){}});function Ri(e){Rn.call(this),this.type="LineBasicMaterial",this.color=new en(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 bx=new Ee,wx=new Ee,Tx=new jn,xf=new dc,bf=new Co;function sa(e,n,i){i===1&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead."),rn.call(this),this.type="Line",this.geometry=e!==void 0?e:new yn,this.material=n!==void 0?n:new Ri}sa.prototype=Object.assign(Object.create(rn.prototype),{constructor:sa,isLine:!0,computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(e.index===null){for(var n=e.attributes.position,i=[0],l=1,h=n.count;l_)){C.applyMatrix4(this.matrixWorld);var K=e.ray.origin.distanceTo(C);Ke.far||n.push({distance:K,point:T.clone().applyMatrix4(this.matrixWorld),index:U,face:null,faceIndex:null,object:this})}}else for(var U=0,q=B.length/3-1;U_)){C.applyMatrix4(this.matrixWorld);var K=e.ray.origin.distanceTo(C);Ke.far||n.push({distance:K,point:T.clone().applyMatrix4(this.matrixWorld),index:U,face:null,faceIndex:null,object:this})}}}else if(l.isGeometry)for(var ie=l.vertices,ue=ie.length,U=0;U_)){C.applyMatrix4(this.matrixWorld);var K=e.ray.origin.distanceTo(C);Ke.far||n.push({distance:K,point:T.clone().applyMatrix4(this.matrixWorld),index:U,face:null,faceIndex:null,object:this})}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var wf=new Ee,Mf=new Ee;function Vi(e,n){sa.call(this,e,n),this.type="LineSegments"}Vi.prototype=Object.assign(Object.create(sa.prototype),{constructor:Vi,isLineSegments:!0,computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(e.index===null){for(var n=e.attributes.position,i=[],l=0,h=n.count;l0){var _=h[p[0]];if(_!==void 0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},n=0,i=_.length;n0&&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 B_(e,n,i,l,h,p,_){var s=k_.distanceSqToPoint(e);if(sh.far)return;p.push({distance:T,distanceToRay:Math.sqrt(s),point:M,index:n,face:null,object:_})}}function Sx(e,n,i,l,h,p,_,s,M){mi.call(this,e,n,i,l,h,p,_,s,M),this.format=_!==void 0?_:Mo,this.minFilter=p!==void 0?p:qi,this.magFilter=h!==void 0?h:qi,this.generateMipmaps=!1}Sx.prototype=Object.assign(Object.create(mi.prototype),{constructor:Sx,isVideoTexture:!0,update:function(){var e=this.image;e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});function Rh(e,n,i,l,h,p,_,s,M,T,C,E){mi.call(this,null,p,_,s,M,T,l,h,C,E),this.image={width:n,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}Rh.prototype=Object.create(mi.prototype),Rh.prototype.constructor=Rh,Rh.prototype.isCompressedTexture=!0;function Cf(e,n,i,l,h,p,_,s,M){mi.call(this,e,n,i,l,h,p,_,s,M),this.needsUpdate=!0}Cf.prototype=Object.create(mi.prototype),Cf.prototype.constructor=Cf,Cf.prototype.isCanvasTexture=!0;function Pf(e,n,i,l,h,p,_,s,M,T){if(T=T!==void 0?T:tc,T!==tc&&T!==ch)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&T===tc&&(i=jp),i===void 0&&T===ch&&(i=qp),mi.call(this,null,l,h,p,_,s,T,i,M),this.image={width:e,height:n},this.magFilter=_!==void 0?_:Ui,this.minFilter=s!==void 0?s:Ui,this.flipY=!1,this.generateMipmaps=!1}Pf.prototype=Object.create(mi.prototype),Pf.prototype.constructor=Pf,Pf.prototype.isDepthTexture=!0;function Lf(e){yn.call(this),this.type="WireframeGeometry";var n=[],i,l,h,p,_,s=[0,0],M={},T,C,E,L,I=["a","b","c"],B;if(e&&e.isGeometry){var O=e.faces;for(i=0,h=O.length;i=0?(e(q-s,U,C),E.subVectors(T,C)):(e(q+s,U,C),E.subVectors(C,T)),U-s>=0?(e(q,U-s,C),L.subVectors(T,C)):(e(q,U+s,C),L.subVectors(C,T)),M.crossVectors(E,L).normalize(),p.push(M.x,M.y,M.z),_.push(q,U)}}for(I=0;I.9&&ie<.1&&(ee<.2&&(p[q+0]+=1),he<.2&&(p[q+2]+=1),Ce<.2&&(p[q+4]+=1))}}function E(q){h.push(q.x,q.y,q.z)}function L(q,ee){var he=q*3;ee.x=e[he+0],ee.y=e[he+1],ee.z=e[he+2]}function I(){for(var q=new Ee,ee=new Ee,he=new Ee,Ce=new Ee,K=new Lt,ie=new Lt,ue=new Lt,ae=0,le=0;ae80*i){s=T=e[0],M=C=e[1];for(var B=i;BT&&(T=E),L>C&&(C=L);I=Math.max(T-s,C-M),I=I!==0?1/I:0}return Vh(p,_,i,s,M,I),_}};function Ax(e,n,i,l,h){var p,_;if(h===OC(e,n,i,l)>0)for(p=n;p=n;p-=l)_=Lx(p,e[p],e[p+1],_);return _&&sl(_,_.next)&&(Hh(_),_=_.next),_}function Uh(e,n){if(!e)return e;n||(n=e);var i=e,l;do if(l=!1,!i.steiner&&(sl(i,i.next)||cr(i.prev,i,i.next)===0)){if(Hh(i),i=n=i.prev,i===i.next)break;l=!0}else i=i.next;while(l||i!==n);return n}function Vh(e,n,i,l,h,p,_){if(e){!_&&p&&IC(e,l,h,p);for(var s=e,M,T;e.prev!==e.next;){if(M=e.prev,T=e.next,p?EC(e,l,h,p):TC(e)){n.push(M.i/i),n.push(e.i/i),n.push(T.i/i),Hh(e),e=T.next,s=T.next;continue}if(e=T,e===s){_?_===1?(e=SC(e,n,i),Vh(e,n,i,l,h,p,2)):_===2&&AC(e,n,i,l,h,p):Vh(Uh(e),n,i,l,h,p,1);break}}}}function TC(e){var n=e.prev,i=e,l=e.next;if(cr(n,i,l)>=0)return!1;for(var h=e.next.next;h!==e.prev;){if(zc(n.x,n.y,i.x,i.y,l.x,l.y,h.x,h.y)&&cr(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function EC(e,n,i,l){var h=e.prev,p=e,_=e.next;if(cr(h,p,_)>=0)return!1;for(var s=h.xp.x?h.x>_.x?h.x:_.x:p.x>_.x?p.x:_.x,C=h.y>p.y?h.y>_.y?h.y:_.y:p.y>_.y?p.y:_.y,E=F_(s,M,n,i,l),L=F_(T,C,n,i,l),I=e.prevZ,B=e.nextZ;I&&I.z>=E&&B&&B.z<=L;){if(I!==e.prev&&I!==e.next&&zc(h.x,h.y,p.x,p.y,_.x,_.y,I.x,I.y)&&cr(I.prev,I,I.next)>=0||(I=I.prevZ,B!==e.prev&&B!==e.next&&zc(h.x,h.y,p.x,p.y,_.x,_.y,B.x,B.y)&&cr(B.prev,B,B.next)>=0))return!1;B=B.nextZ}for(;I&&I.z>=E;){if(I!==e.prev&&I!==e.next&&zc(h.x,h.y,p.x,p.y,_.x,_.y,I.x,I.y)&&cr(I.prev,I,I.next)>=0)return!1;I=I.prevZ}for(;B&&B.z<=L;){if(B!==e.prev&&B!==e.next&&zc(h.x,h.y,p.x,p.y,_.x,_.y,B.x,B.y)&&cr(B.prev,B,B.next)>=0)return!1;B=B.nextZ}return!0}function SC(e,n,i){var l=e;do{var h=l.prev,p=l.next.next;!sl(h,p)&&Cx(h,l,l.next,p)&&Gh(h,p)&&Gh(p,h)&&(n.push(h.i/i),n.push(l.i/i),n.push(p.i/i),Hh(l),Hh(l.next),l=e=p),l=l.next}while(l!==e);return l}function AC(e,n,i,l,h,p){var _=e;do{for(var s=_.next.next;s!==_.prev;){if(_.i!==s.i&&kC(_,s)){var M=Px(_,s);_=Uh(_,_.next),M=Uh(M,M.next),Vh(_,n,i,l,h,p),Vh(M,n,i,l,h,p);return}s=s.next}_=_.next}while(_!==e)}function CC(e,n,i,l){var h=[],p,_,s,M,T;for(p=0,_=n.length;p<_;p++)s=n[p]*l,M=p<_-1?n[p+1]*l:e.length,T=Ax(e,s,M,l,!1),T===T.next&&(T.steiner=!0),h.push(zC(T));for(h.sort(PC),p=0;p=i.next.y&&i.next.y!==i.y){var s=i.x+(h-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=l&&s>p){if(p=s,s===l){if(h===i.y)return i;if(h===i.next.y)return i.next}_=i.x=i.x&&i.x>=T&&l!==i.x&&zc(h_.x)&&Gh(i,e)&&(_=i,E=L)),i=i.next;return _}function IC(e,n,i,l){var h=e;do h.z===null&&(h.z=F_(h.x,h.y,n,i,l)),h.prevZ=h.prev,h.nextZ=h.next,h=h.next;while(h!==e);h.prevZ.nextZ=null,h.prevZ=null,RC(h)}function RC(e){var n,i,l,h,p,_,s,M,T=1;do{for(i=e,e=null,p=null,_=0;i;){for(_++,l=i,s=0,n=0;n0||M>0&&l;)s!==0&&(M===0||!l||i.z<=l.z)?(h=i,i=i.nextZ,s--):(h=l,l=l.nextZ,M--),p?p.nextZ=h:e=h,h.prevZ=p,p=h;i=l}p.nextZ=null,T*=2}while(_>1);return e}function F_(e,n,i,l,h){return e=32767*(e-i)*h,n=32767*(n-l)*h,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e|n<<1}function zC(e){var n=e,i=e;do(n.x=0&&(e-_)*(l-s)-(i-_)*(n-s)>=0&&(i-_)*(p-s)-(h-_)*(l-s)>=0}function kC(e,n){return e.next.i!==n.i&&e.prev.i!==n.i&&!BC(e,n)&&Gh(e,n)&&Gh(n,e)&&FC(e,n)}function cr(e,n,i){return(n.y-e.y)*(i.x-n.x)-(n.x-e.x)*(i.y-n.y)}function sl(e,n){return e.x===n.x&&e.y===n.y}function Cx(e,n,i,l){return sl(e,i)&&sl(n,l)||sl(e,l)&&sl(i,n)?!0:cr(e,n,i)>0!=cr(e,n,l)>0&&cr(i,l,e)>0!=cr(i,l,n)>0}function BC(e,n){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==n.i&&i.next.i!==n.i&&Cx(i,i.next,e,n))return!0;i=i.next}while(i!==e);return!1}function Gh(e,n){return cr(e.prev,e,e.next)<0?cr(e,n,e.next)>=0&&cr(e,e.prev,n)>=0:cr(e,n,e.prev)<0||cr(e,e.next,n)<0}function FC(e,n){var i=e,l=!1,h=(e.x+n.x)/2,p=(e.y+n.y)/2;do i.y>p!=i.next.y>p&&i.next.y!==i.y&&h<(i.next.x-i.x)*(p-i.y)/(i.next.y-i.y)+i.x&&(l=!l),i=i.next;while(i!==e);return l}function Px(e,n){var i=new O_(e.i,e.x,e.y),l=new O_(n.i,n.x,n.y),h=e.next,p=n.prev;return e.next=n,n.prev=e,i.next=h,h.prev=i,l.next=i,i.prev=l,p.next=l,l.prev=p,l}function Lx(e,n,i,l){var h=new O_(e,n,i);return l?(h.next=l.next,h.prev=l,l.next.prev=h,l.next=h):(h.prev=h,h.next=h),h}function Hh(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 O_(e,n,i){this.i=e,this.x=n,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function OC(e,n,i,l){for(var h=0,p=n,_=i-l;p2&&e[n-1].equals(e[0])&&e.pop()}function Ix(e,n){for(var i=0;iNumber.EPSILON){var Nn=Math.sqrt(Zn),Ci=Math.sqrt(On*On+Gn*Gn),ei=on.x-pn/Nn,Ki=on.y+Pn/Nn,yi=Zt.x-Gn/Ci,Hr=Zt.y+On/Ci,ki=((yi-ei)*Gn-(Hr-Ki)*On)/(Pn*Gn-pn*On);qe=ei+Pn*ki-Gt.x,Nt=Ki+pn*ki-Gt.y;var Wr=qe*qe+Nt*Nt;if(Wr<=2)return new Lt(qe,Nt);Qt=Math.sqrt(Wr/2)}else{var Sr=!1;Pn>Number.EPSILON?On>Number.EPSILON&&(Sr=!0):Pn<-Number.EPSILON?On<-Number.EPSILON&&(Sr=!0):Math.sign(pn)===Math.sign(Gn)&&(Sr=!0),Sr?(qe=-pn,Nt=Pn,Qt=Math.sqrt(Zn)):(qe=Pn,Nt=pn,Qt=Math.sqrt(Zn/2))}return new Lt(qe/Qt,Nt/Qt)}for(var Me=[],pe=0,Be=At.length,$e=Be-1,ot=pe+1;pe=0;Ot--){for(ge=Ot/ee,Ve=O*Math.cos(ge*Math.PI/2),Pe=U*Math.sin(ge*Math.PI/2)+q,pe=0,Be=At.length;pe=0;){Zt=pe,qe=pe-1,qe<0&&(qe=Gt.length-1);var Nt=0,Qt=L+ee*2;for(Nt=0;Nt0)&&B.push(ie,ue,le),(T!==i-1||s0&&ee(!0),n>0&&ee(!1)),this.setIndex(T),this.setAttribute("position",new sn(C,3)),this.setAttribute("normal",new sn(E,3)),this.setAttribute("uv",new sn(L,2));function q(){var he,Ce,K=new Ee,ie=new Ee,ue=0,ae=(n-e)/i;for(Ce=0;Ce<=h;Ce++){var le=[],De=Ce/h,ye=De*(n-e)+e;for(he=0;he<=l;he++){var se=he/l,Ue=se*s+_,Oe=Math.sin(Ue),We=Math.cos(Ue);ie.x=ye*Oe,ie.y=-De*i+O,ie.z=ye*We,C.push(ie.x,ie.y,ie.z),K.set(Oe,ae,We).normalize(),E.push(K.x,K.y,K.z),L.push(se,1-De),le.push(I++)}B.push(le)}for(he=0;he=l)){C.push(M.times[L]);for(var B=0;Bp.tracks[s].times[0]&&(O=p.tracks[s].times[0]);for(var s=0;s=h)){var s=n[1];e=h)break t}p=i,i=0;break n}break e}for(;i>>1;en;)--p;if(++p,h!==0||p!==l){h>=p&&(p=Math.max(p,1),h=p-1);var _=this.getValueSize();this.times=Gi.arraySlice(i,h,p),this.values=Gi.arraySlice(this.values,h*_,p*_)}return this},validate:function(){var e=!0,n=this.getValueSize();n-Math.floor(n)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);var i=this.times,l=this.values,h=i.length;h===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);for(var p=null,_=0;_!==h;_++){var s=i[_];if(typeof s=="number"&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,_,s),e=!1;break}if(p!==null&&p>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,_,s,p),e=!1;break}p=s}if(l!==void 0&&Gi.isTypedArray(l))for(var _=0,M=l.length;_!==M;++_){var T=l[_];if(isNaN(T)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,_,T),e=!1;break}}return e},optimize:function(){for(var e=Gi.arraySlice(this.times),n=Gi.arraySlice(this.values),i=this.getValueSize(),l=this.getInterpolation()===Jg,h=1,p=e.length-1,_=1;_0){e[h]=e[p];for(var O=p*i,U=h*i,I=0;I!==i;++I)n[U+I]=n[O+I];++h}return h!==e.length?(this.times=Gi.arraySlice(e,0,h),this.values=Gi.arraySlice(n,0,h*i)):(this.times=e,this.values=n),this},clone:function(){var e=Gi.arraySlice(this.times,0),n=Gi.arraySlice(this.values,0),i=this.constructor,l=new i(this.name,e,n);return l.createInterpolant=this.createInterpolant,l}});function V_(e,n,i){fr.call(this,e,n,i)}V_.prototype=Object.assign(Object.create(fr.prototype),{constructor:V_,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:uh,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function G_(e,n,i,l){fr.call(this,e,n,i,l)}G_.prototype=Object.assign(Object.create(fr.prototype),{constructor:G_,ValueTypeName:"color"});function Zc(e,n,i,l){fr.call(this,e,n,i,l)}Zc.prototype=Object.assign(Object.create(fr.prototype),{constructor:Zc,ValueTypeName:"number"});function H_(e,n,i,l){Vr.call(this,e,n,i,l)}H_.prototype=Object.assign(Object.create(Vr.prototype),{constructor:H_,interpolate_:function(e,n,i,l){for(var h=this.resultBuffer,p=this.sampleValues,_=this.valueSize,s=e*_,M=(i-n)/(l-n),T=s+_;s!==T;s+=4)Or.slerpFlat(h,0,p,s-_,p,s,M);return h}});function Xh(e,n,i,l){fr.call(this,e,n,i,l)}Xh.prototype=Object.assign(Object.create(fr.prototype),{constructor:Xh,ValueTypeName:"quaternion",DefaultInterpolation:nc,InterpolantFactoryMethodLinear:function(e){return new H_(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0});function W_(e,n,i,l){fr.call(this,e,n,i,l)}W_.prototype=Object.assign(Object.create(fr.prototype),{constructor:W_,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:uh,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function Xc(e,n,i,l){fr.call(this,e,n,i,l)}Xc.prototype=Object.assign(Object.create(fr.prototype),{constructor:Xc,ValueTypeName:"vector"});function va(e,n,i){this.name=e,this.tracks=i,this.duration=n!==void 0?n:-1,this.uuid=Wn.generateUUID(),this.duration<0&&this.resetDuration()}function VC(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Zc;case"vector":case"vector2":case"vector3":case"vector4":return Xc;case"color":return G_;case"quaternion":return Xh;case"bool":case"boolean":return V_;case"string":return W_}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function GC(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");var n=VC(e.type);if(e.times===void 0){var i=[],l=[];Gi.flattenJSON(e.keys,i,l,"value"),e.times=i,e.values=l}return n.parse!==void 0?n.parse(e):new n(e.name,e.times,e.values,e.interpolation)}Object.assign(va,{parse:function(e){for(var n=[],i=e.tracks,l=1/(e.fps||1),h=0,p=i.length;h!==p;++h)n.push(GC(i[h]).scale(l));return new va(e.name,e.duration,n)},toJSON:function(e){for(var n=[],i=e.tracks,l={name:e.name,duration:e.duration,tracks:n,uuid:e.uuid},h=0,p=i.length;h!==p;++h)n.push(fr.toJSON(i[h]));return l},CreateFromMorphTargetSequence:function(e,n,i,l){for(var h=n.length,p=[],_=0;_1){var T=M[1],C=l[T];C||(l[T]=C=[]),C.push(s)}}var E=[];for(var T in l)E.push(va.CreateFromMorphTargetSequence(T,l[T],n,i));return E},parseAnimation:function(e,n){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var i=function(he,Ce,K,ie,ue){if(K.length!==0){var ae=[],le=[];Gi.flattenJSON(K,ae,le,ie),ae.length!==0&&ue.push(new he(Ce,ae,le))}},l=[],h=e.name||"default",p=e.length||-1,_=e.fps||30,s=e.hierarchy||[],M=0;M0||e.search(/^data\:image\/jpeg/)===0;h.format=s?Mo:Aa,h.needsUpdate=!0,n!==void 0&&n(h)},i,l),h}});function Cn(){this.type="Curve",this.arcLengthDivisions=200}Object.assign(Cn.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(e,n){var i=this.getUtoTmapping(e);return this.getPoint(i,n)},getPoints:function(e){e===void 0&&(e=5);for(var n=[],i=0;i<=e;i++)n.push(this.getPoint(i/e));return n},getSpacedPoints:function(e){e===void 0&&(e=5);for(var n=[],i=0;i<=e;i++)n.push(this.getPointAt(i/e));return n},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 n=[],i,l=this.getPoint(0),h,p=0;for(n.push(0),h=1;h<=e;h++)i=this.getPoint(h/e),p+=i.distanceTo(l),n.push(p),l=i;return this.cacheArcLengths=n,n},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,n){var i=this.getLengths(),l=0,h=i.length,p;n?p=n:p=e*i[h-1];for(var _=0,s=h-1,M;_<=s;)if(l=Math.floor(_+(s-_)/2),M=i[l]-p,M<0)_=l+1;else if(M>0)s=l-1;else{s=l;break}if(l=s,i[l]===p)return l/(h-1);var T=i[l],C=i[l+1],E=C-T,L=(p-T)/E,I=(l+L)/(h-1);return I},getTangent:function(e){var n=1e-4,i=e-n,l=e+n;i<0&&(i=0),l>1&&(l=1);var h=this.getPoint(i),p=this.getPoint(l),_=p.clone().sub(h);return _.normalize()},getTangentAt:function(e){var n=this.getUtoTmapping(e);return this.getTangent(n)},computeFrenetFrames:function(e,n){var i=new Ee,l=[],h=[],p=[],_=new Ee,s=new jn,M,T,C;for(M=0;M<=e;M++)T=M/e,l[M]=this.getTangentAt(T),l[M].normalize();h[0]=new Ee,p[0]=new Ee;var E=Number.MAX_VALUE,L=Math.abs(l[0].x),I=Math.abs(l[0].y),B=Math.abs(l[0].z);for(L<=E&&(E=L,i.set(1,0,0)),I<=E&&(E=I,i.set(0,1,0)),B<=E&&i.set(0,0,1),_.crossVectors(l[0],i).normalize(),h[0].crossVectors(l[0],_),p[0].crossVectors(l[0],h[0]),M=1;M<=e;M++)h[M]=h[M-1].clone(),p[M]=p[M-1].clone(),_.crossVectors(l[M-1],l[M]),_.length()>Number.EPSILON&&(_.normalize(),C=Math.acos(Wn.clamp(l[M-1].dot(l[M]),-1,1)),h[M].applyMatrix4(s.makeRotationAxis(_,C))),p[M].crossVectors(l[M],h[M]);if(n===!0)for(C=Math.acos(Wn.clamp(h[0].dot(h[e]),-1,1)),C/=e,l[0].dot(_.crossVectors(h[0],h[e]))>0&&(C=-C),M=1;M<=e;M++)h[M].applyMatrix4(s.makeRotationAxis(l[M],C*M)),p[M].crossVectors(l[M],h[M]);return{tangents:l,normals:h,binormals:p}},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 ba(e,n,i,l,h,p,_,s){Cn.call(this),this.type="EllipseCurve",this.aX=e||0,this.aY=n||0,this.xRadius=i||1,this.yRadius=l||1,this.aStartAngle=h||0,this.aEndAngle=p||2*Math.PI,this.aClockwise=_||!1,this.aRotation=s||0}ba.prototype=Object.create(Cn.prototype),ba.prototype.constructor=ba,ba.prototype.isEllipseCurve=!0,ba.prototype.getPoint=function(e,n){for(var i=n||new Lt,l=Math.PI*2,h=this.aEndAngle-this.aStartAngle,p=Math.abs(h)l;)h-=l;h0?0:(Math.floor(Math.abs(_)/h)+1)*h:s===0&&_===h-1&&(_=h-2,s=1);var M,T,C,E;if(this.closed||_>0?M=l[(_-1)%h]:(Yf.subVectors(l[0],l[1]).add(l[0]),M=Yf),T=l[_%h],C=l[(_+1)%h],this.closed||_+2l.length-2?l.length-1:p+1],C=l[p>l.length-3?l.length-1:p+2];return i.set(Nx(_,s.x,M.x,T.x,C.x),Nx(_,s.y,M.y,T.y,C.y)),i},Ja.prototype.copy=function(e){Cn.prototype.copy.call(this,e),this.points=[];for(var n=0,i=e.points.length;n=n){var h=i[l]-n,p=this.curves[l],_=p.getLength(),s=_===0?0:1-h/_;return p.getPointAt(s)}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=[],n=0,i=0,l=this.curves.length;i1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},copy:function(e){Cn.prototype.copy.call(this,e),this.curves=[];for(var n=0,i=e.curves.length;n0){var T=M.getPoint(0);T.equals(this.currentPoint)||this.lineTo(T.x,T.y)}this.curves.push(M);var C=M.getPoint(1);return this.currentPoint.copy(C),this},copy:function(e){return us.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){var e=us.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return us.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}});function cl(e){Ka.call(this,e),this.uuid=Wn.generateUUID(),this.type="Shape",this.holes=[]}cl.prototype=Object.assign(Object.create(Ka.prototype),{constructor:cl,getPointsHoles:function(e){for(var n=[],i=0,l=this.holes.length;i0){var p=new kx(n),_=new Yh(p);_.setCrossOrigin(this.crossOrigin);for(var s=0,M=e.length;s0?l=new Dh(_,s):l=new Ai(_,s);break;case"InstancedMesh":var _=h(e.geometry),s=p(e.material),M=e.count,T=e.instanceMatrix;l=new z_(_,s,M),l.instanceMatrix=new zn(new Float32Array(T.array),16);break;case"LOD":l=new yf;break;case"Line":l=new sa(h(e.geometry),p(e.material),e.mode);break;case"LineLoop":l=new Tf(h(e.geometry),p(e.material));break;case"LineSegments":l=new Vi(h(e.geometry),p(e.material));break;case"PointCloud":case"Points":l=new Af(h(e.geometry),p(e.material));break;case"Sprite":l=new I_(p(e.material));break;case"Group":l=new rl;break;default:l=new rn}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 C=e.children,E=0;ENumber.EPSILON){if(Ve<0&&(Ot=st[Dt],ge=-ge,Pe=st[At],Ve=-Ve),We.yPe.y)continue;if(We.y===Ot.y){if(We.x===Ot.x)return!0}else{var Ne=Ve*(We.x-Ot.x)-ge*(We.y-Ot.y);if(Ne===0)return!0;if(Ne<0)continue;gt=!gt}}else{if(We.y!==Ot.y)continue;if(Pe.x<=We.x&&We.x<=Ot.x||Ot.x<=We.x&&We.x<=Pe.x)return!0}}return gt}var h=ss.isClockWise,p=this.subPaths;if(p.length===0)return[];if(n===!0)return i(p);var _,s,M,T=[];if(p.length===1)return s=p[0],M=new cl,M.curves=s.curves,T.push(M),T;var C=!h(p[0].getPoints());C=e?!C:C;var E=[],L=[],I=[],B=0,O;L[B]=void 0,I[B]=[];for(var U=0,q=p.length;U1){for(var ee=!1,he=[],Ce=0,K=L.length;Ce0&&(ee||(I=E))}for(var ye,U=0,se=L.length;U0){this.source.connect(this.filters[0]);for(var e=1,n=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(var e=1,n=this.filters.length;e=.5)for(var p=0;p!==h;++p)e[n+p]=e[i+p]},_slerp:function(e,n,i,l){Or.slerpFlat(e,n,e,n,e,i,l)},_lerp:function(e,n,i,l,h){for(var p=1-l,_=0;_!==h;++_){var s=n+_;e[s]=e[s]*p+e[i+_]*l}}});var hy="\\[\\]\\.:\\/",iP=new RegExp("["+hy+"]","g"),dy="[^"+hy+"]",rP="[^"+hy.replace("\\.","")+"]",aP=/((?:WC+[\/:])*)/.source.replace("WC",dy),oP=/(WCOD+)?/.source.replace("WCOD",rP),sP=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",dy),lP=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",dy),cP=new RegExp("^"+aP+oP+sP+lP+"$"),uP=["material","materials","bones"];function r1(e,n,i){var l=i||mr.parseTrackName(n);this._targetGroup=e,this._bindings=e.subscribe_(n,l)}Object.assign(r1.prototype,{getValue:function(e,n){this.bind();var i=this._targetGroup.nCachedObjects_,l=this._bindings[i];l!==void 0&&l.getValue(e,n)},setValue:function(e,n){for(var i=this._bindings,l=this._targetGroup.nCachedObjects_,h=i.length;l!==h;++l)i[l].setValue(e,n)},bind:function(){for(var e=this._bindings,n=this._targetGroup.nCachedObjects_,i=e.length;n!==i;++n)e[n].bind()},unbind:function(){for(var e=this._bindings,n=this._targetGroup.nCachedObjects_,i=e.length;n!==i;++n)e[n].unbind()}});function mr(e,n,i){this.path=n,this.parsedPath=i||mr.parseTrackName(n),this.node=mr.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}Object.assign(mr,{Composite:r1,create:function(e,n,i){return e&&e.isAnimationObjectGroup?new mr.Composite(e,n,i):new mr(e,n,i)},sanitizeNodeName:function(e){return e.replace(/\s/g,"_").replace(iP,"")},parseTrackName:function(e){var n=cP.exec(e);if(!n)throw new Error("PropertyBinding: Cannot parse trackName: "+e);var i={nodeName:n[2],objectName:n[3],objectIndex:n[4],propertyName:n[5],propertyIndex:n[6]},l=i.nodeName&&i.nodeName.lastIndexOf(".");if(l!==void 0&&l!==-1){var h=i.nodeName.substring(l+1);uP.indexOf(h)!==-1&&(i.nodeName=i.nodeName.substring(0,l),i.objectName=h)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i},findNode:function(e,n){if(!n||n===""||n==="root"||n==="."||n===-1||n===e.name||n===e.uuid)return e;if(e.skeleton){var i=e.skeleton.getBoneByName(n);if(i!==void 0)return i}if(e.children){var l=function(p){for(var _=0;_=n){var C=n++,E=e[C];i[E.uuid]=T,e[T]=E,i[M]=C,e[C]=s;for(var L=0,I=h;L!==I;++L){var B=l[L],O=B[C],U=B[T];B[T]=O,B[C]=U}}}this.nCachedObjects_=n},uncache:function(){for(var e=this._objects,n=e.length,i=this.nCachedObjects_,l=this._indicesByUUID,h=this._bindings,p=h.length,_=0,s=arguments.length;_!==s;++_){var M=arguments[_],T=M.uuid,C=l[T];if(C!==void 0)if(delete l[T],C0)for(var M=this._interpolants,T=this._propertyBindings,C=0,E=M.length;C!==E;++C)M[C].evaluate(_),T[C].accumulate(l,s)},_updateWeight:function(e){var n=0;if(this.enabled){n=this.weight;var i=this._weightInterpolant;if(i!==null){var l=i.evaluate(e)[0];n*=l,e>i.parameterPositions[1]&&(this.stopFading(),l===0&&(this.enabled=!1))}}return this._effectiveWeight=n,n},_updateTimeScale:function(e){var n=0;if(!this.paused){n=this.timeScale;var i=this._timeScaleInterpolant;if(i!==null){var l=i.evaluate(e)[0];n*=l,e>i.parameterPositions[1]&&(this.stopWarping(),n===0?this.paused=!0:this.timeScale=n)}}return this._effectiveTimeScale=n,n},_updateTime:function(e){var n=this.time+e,i=this._clip.duration,l=this.loop,h=this._loopCount,p=l===o2;if(e===0)return h===-1?n:p&&(h&1)===1?i-n:n;if(l===r2){h===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=i)n=i;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(h===-1&&(e>=0?(h=0,this._setEndings(!0,this.repetitions===0,p)):this._setEndings(this.repetitions===0,!0,p)),n>=i||n<0){var _=Math.floor(n/i);n-=i*_,h+=Math.abs(_);var s=this.repetitions-h;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?i:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(s===1){var M=e<0;this._setEndings(M,!M,p)}else this._setEndings(!1,!1,p);this._loopCount=h,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:_})}}else this.time=n;if(p&&(h&1)===1)return i-n}return n},_setEndings:function(e,n,i){var l=this._interpolantSettings;i?(l.endingStart=rc,l.endingEnd=rc):(e?l.endingStart=this.zeroSlopeAtStart?rc:ic:l.endingStart=Zp,n?l.endingEnd=this.zeroSlopeAtEnd?rc:ic:l.endingEnd=Zp)},_scheduleFading:function(e,n,i){var l=this._mixer,h=l.time,p=this._weightInterpolant;p===null&&(p=l._lendControlInterpolant(),this._weightInterpolant=p);var _=p.parameterPositions,s=p.sampleValues;return _[0]=h,s[0]=n,_[1]=h+e,s[1]=i,this}});function o1(e){this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}o1.prototype=Object.assign(Object.create(To.prototype),{constructor:o1,_bindAction:function(e,n){var i=e._localRoot||this._root,l=e._clip.tracks,h=l.length,p=e._propertyBindings,_=e._interpolants,s=i.uuid,M=this._bindingsByRootAndName,T=M[s];T===void 0&&(T={},M[s]=T);for(var C=0;C!==h;++C){var E=l[C],L=E.name,I=T[L];if(I!==void 0)p[C]=I;else{if(I=p[C],I!==void 0){I._cacheIndex===null&&(++I.referenceCount,this._addInactiveBinding(I,s,L));continue}var B=n&&n._propertyBindings[C].binding.parsedPath;I=new i1(mr.create(i,L,B),E.ValueTypeName,E.getValueSize()),++I.referenceCount,this._addInactiveBinding(I,s,L),p[C]=I}_[C].resultBuffer=I.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){var n=(e._localRoot||this._root).uuid,i=e._clip.uuid,l=this._actionsByClip[i];this._bindAction(e,l&&l.knownActions[0]),this._addInactiveAction(e,i,n)}for(var h=e._propertyBindings,p=0,_=h.length;p!==_;++p){var s=h[p];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var n=e._propertyBindings,i=0,l=n.length;i!==l;++i){var h=n[i];--h.useCount===0&&(h.restoreOriginalState(),this._takeBackBinding(h))}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 n=e._cacheIndex;return n!==null&&nthis.max.x||e.ythis.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,n){return n===void 0&&(console.warn("THREE.Box2: .getParameter() target is now required"),n=new Lt),n.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.xthis.max.x||e.max.ythis.max.y)},clampPoint:function(e,n){return n===void 0&&(console.warn("THREE.Box2: .clampPoint() target is now required"),n=new Lt),n.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){var n=c1.copy(e).clamp(this.min,this.max);return n.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 h1=new Ee,em=new Ee;function d1(e,n){this.start=e!==void 0?e:new Ee,this.end=n!==void 0?n:new Ee}Object.assign(d1.prototype,{set:function(e,n){return this.start.copy(e),this.end.copy(n),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 Ee),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 Ee),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,n){return n===void 0&&(console.warn("THREE.Line3: .at() target is now required"),n=new Ee),this.delta(n).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(e,n){h1.subVectors(e,this.start),em.subVectors(this.end,this.start);var i=em.dot(em),l=em.dot(h1),h=l/i;return n&&(h=Wn.clamp(h,0,1)),h},closestPointToPoint:function(e,n,i){var l=this.closestPointToPointParameter(e,n);return i===void 0&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),i=new Ee),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 tm(e){rn.call(this),this.material=e,this.render=function(){}}tm.prototype=Object.create(rn.prototype),tm.prototype.constructor=tm,tm.prototype.isImmediateRenderObject=!0;var p1=new Ee;function td(e,n){rn.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;for(var i=new yn,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],h=0,p=1,_=32;h<_;h++,p++){var s=h/_*Math.PI*2,M=p/_*Math.PI*2;l.push(Math.cos(s),Math.sin(s),1,Math.cos(M),Math.sin(M),1)}i.setAttribute("position",new sn(l,3));var T=new Ri({fog:!1});this.cone=new Vi(i,T),this.add(this.cone),this.update()}td.prototype=Object.create(rn.prototype),td.prototype.constructor=td,td.prototype.dispose=function(){this.cone.geometry.dispose(),this.cone.material.dispose()},td.prototype.update=function(){this.light.updateMatrixWorld();var e=this.light.distance?this.light.distance:1e3,n=e*Math.tan(this.light.angle);this.cone.scale.set(n,n,e),p1.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(p1),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)};var hs=new Ee,nm=new jn,my=new jn;function f1(e){var n=[];e&&e.isBone&&n.push(e);for(var i=0;i.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{v1.set(e.z,0,-e.x).normalize();var n=Math.acos(e.y);this.quaternion.setFromAxisAngle(v1,n)}},ds.prototype.setLength=function(e,n,i){n===void 0&&(n=.2*e),i===void 0&&(i=.2*n),this.line.scale.set(1,Math.max(1e-4,e-n),1),this.line.updateMatrix(),this.cone.scale.set(i,n,i),this.cone.position.y=e,this.cone.updateMatrix()},ds.prototype.setColor=function(e){this.line.material.color.set(e),this.cone.material.color.set(e)},ds.prototype.copy=function(e){return rn.prototype.copy.call(this,e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this},ds.prototype.clone=function(){return new this.constructor().copy(this)};function vy(e){e=e||1;var n=[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 yn;l.setAttribute("position",new sn(n,3)),l.setAttribute("color",new sn(i,3));var h=new Ri({vertexColors:Kl});Vi.call(this,l,h)}vy.prototype=Object.create(Vi.prototype),vy.prototype.constructor=vy;var Jc=4,ps=8,eo=Math.pow(2,ps),x1=[.125,.215,.35,.446,.526,.582],b1=ps-Jc+1+x1.length,Kc=20,to={[ia]:0,[hh]:1,[Kg]:2,[S0]:3,[A0]:4,[C0]:5,[E0]:6},xy=new $c,um=vP(Kc),fs=null,ms=null,{_lodPlanes:od,_sizeLods:w1,_sigmas:hm}=gP(),dm=null,_i=null,by=null,gl=(1+Math.sqrt(5))/2,Qc=1/gl,M1=[new Ee(1,1,1),new Ee(-1,1,1),new Ee(1,1,-1),new Ee(-1,1,-1),new Ee(0,gl,Qc),new Ee(0,gl,-Qc),new Ee(Qc,0,gl),new Ee(-Qc,0,gl),new Ee(gl,Qc,0),new Ee(-gl,Qc,0)];function T1(e){_i=e,wy(um)}T1.prototype={constructor:T1,fromScene:function(e,n=0,i=.1,l=100){by=_i.getRenderTarget();var h=E1();return _P(e,i,l,h),n>0&&P1(h,0,0,n),C1(h),S1(h),h},fromEquirectangular:function(e){return e.magFilter=Ui,e.minFilter=Ui,e.generateMipmaps=!1,this.fromCubemap(e)},fromCubemap:function(e){by=_i.getRenderTarget();var n=E1(e);return yP(e,n),C1(n),S1(n),n},compileCubemapShader:function(){ms==null&&(ms=I1(),wy(ms))},compileEquirectangularShader:function(){fs==null&&(fs=D1(),wy(fs))},dispose:function(){um.dispose(),ms!=null&&ms.dispose(),fs!=null&&fs.dispose();for(var e=0;eps-Jc?_=x1[h-ps+Jc-1]:h==0&&(_=0),i.push(_);for(var s=1/(p-1),M=-s/2,T=1+s/2,C=[M,M,T,M,T,T,M,M,T,T,M,T],E=6,L=6,I=3,B=2,O=1,U=new Float32Array(I*L*E),q=new Float32Array(B*L*E),ee=new Float32Array(O*L*E),he=0;he2?0:-1,ie=[Ce,K,0,Ce+2/3,K,0,Ce+2/3,K+1,0,Ce,K,0,Ce+2/3,K+1,0,Ce,K+1,0];U.set(ie,I*L*he),q.set(C,B*L*he);var ue=[he,he,he,he,he,he];ee.set(ue,O*L*he)}var ae=new yn;ae.setAttribute("position",new zn(U,I)),ae.setAttribute("uv",new zn(q,B)),ae.setAttribute("faceIndex",new zn(ee,O)),e.push(ae),l>Jc&&l--}return{_lodPlanes:e,_sizeLods:n,_sigmas:i}}function E1(e){var n={magFilter:Ui,minFilter:Ui,generateMipmaps:!1,type:e?e.type:Wp,format:e?e.format:BT,encoding:e?e.encoding:Kg,depthBuffer:!1,stencilBuffer:!1},i=A1(n);return i.depthBuffer=!e,dm=A1(n),i}function S1(e){dm.dispose(),_i.setRenderTarget(by),e.scissorTest=!1,e.setSize(e.width,e.height)}function _P(e,n,i,l){var h=90,p=1,_=new Xi(h,p,n,i),s=[1,1,1,1,-1,1],M=[1,1,-1,-1,-1,1],T=_i.outputEncoding,C=_i.toneMapping,E=_i.toneMappingExposure,L=_i.getClearColor(),I=_i.getClearAlpha();_i.toneMapping=Hg,_i.toneMappingExposure=1,_i.outputEncoding=ia,e.scale.z*=-1;var B=e.background;if(B&&B.isColor){B.convertSRGBToLinear();var O=Math.max(B.r,B.g,B.b),U=Math.min(Math.max(Math.ceil(Math.log2(O)),-128),127);B=B.multiplyScalar(Math.pow(2,-U));var q=(U+128)/255;_i.setClearColor(B,q),e.background=null}for(var ee=0;ee<6;ee++){var he=ee%3;he==0?(_.up.set(0,s[ee],0),_.lookAt(M[ee],0,0)):he==1?(_.up.set(0,0,s[ee]),_.lookAt(0,M[ee],0)):(_.up.set(0,s[ee],0),_.lookAt(0,0,M[ee])),My(l,he*eo,ee>2?eo:0,eo,eo),_i.setRenderTarget(l),_i.render(e,_)}_i.toneMapping=C,_i.toneMappingExposure=E,_i.outputEncoding=T,_i.setClearColor(L,I),e.scale.z*=-1}function yP(e,n){var i=new So;e.isCubeTexture?ms==null&&(ms=I1()):fs==null&&(fs=D1());var l=e.isCubeTexture?ms:fs;i.add(new Ai(od[0],l));var h=l.uniforms;h.envMap.value=e,e.isCubeTexture||h.texelSize.value.set(1/e.image.width,1/e.image.height),h.inputEncoding.value=to[e.encoding],h.outputEncoding.value=to[e.encoding],My(n,0,0,3*eo,2*eo),_i.setRenderTarget(n),_i.render(i,xy)}function wy(e){var n=new So;n.add(new Ai(od[0],e)),_i.compile(n,xy)}function A1(e){var n=new Mr(3*eo,3*eo,e);return n.texture.mapping=oh,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function My(e,n,i,l,h){e.viewport.set(n,i,l,h),e.scissor.set(n,i,l,h)}function C1(e){var n=_i.autoClear;_i.autoClear=!1;for(var i=1;iKc&&console.warn(`sigmaRadians, ${h}, is too large and will clip, as it requested ${I} samples when the maximum is set to ${Kc}`);for(var B=[],O=0,U=0;Ups-Jc?l-ps+Jc:0);My(n,he,Ce,3*ee,2*ee),_i.setRenderTarget(n),_i.render(M,xy)}function vP(e){var n=new Float32Array(e),i=new Ee(0,1,0),l=new cs({defines:{n:e},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i},inputEncoding:{value:to[ia]},outputEncoding:{value:to[ia]}},vertexShader:Ty(),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; ${Ey()} #define ENVMAP_TYPE_CUBE_UV #include 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:Qo,depthTest:!1,depthWrite:!1});return l.type="SphericalGaussianBlur",l}function D1(){var e=new Lt(1,1),n=new cs({uniforms:{envMap:{value:null},texelSize:{value:e},inputEncoding:{value:to[ia]},outputEncoding:{value:to[ia]}},vertexShader:Ty(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform vec2 texelSize; ${Ey()} #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:Qo,depthTest:!1,depthWrite:!1});return n.type="EquirectangularToCubeUV",n}function I1(){var e=new cs({uniforms:{envMap:{value:null},inputEncoding:{value:to[ia]},outputEncoding:{value:to[ia]}},vertexShader:Ty(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform samplerCube envMap; ${Ey()} 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:Qo,depthTest:!1,depthWrite:!1});return e.type="CubemapToCubeUV",e}function Ty(){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 Ey(){return` uniform int inputEncoding; uniform int outputEncoding; #include 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); } `}Cn.create=function(e,n){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(Cn.prototype),e.prototype.constructor=e,e.prototype.getPoint=n,e},Object.assign(us.prototype,{createPointsGeometry:function(e){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var n=this.getPoints(e);return this.createGeometry(n)},createSpacedPointsGeometry:function(e){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var n=this.getSpacedPoints(e);return this.createGeometry(n)},createGeometry:function(e){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var n=new Fn,i=0,l=e.length;i{if(n!=0)return;const i=e.value();let l=new pm;l.setPoint1(i),l.setColor(65314);const h=new tt.McEdGetPointWorldDrawObject;h.setDraw(p=>{l.setPoint2(p),h.drawCustomEntity(l)}),e.setBasePt(i),e.setUseBasePt(!0),e.setUserDraw(h),e.setMessage(` 指定第二点:`),e.setInputToucheType(tt.MxType.InputToucheType.kGetEnd),e.go(p=>{if(p!=0){console.log(p);return}const _=e.value();l.setPoint2(_),tt.MxFun.getCurrentDraw().addMxEntity(l),alert("测试长度是:"+l.getDimText())})})})}function bP(){const e=new tt.MrxDbgUiPrPoint,n=tt.MxFun.getCurrentDraw(),i=new tt.MxDb2LineAngularDimension;i.color=te.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();const l=new tt.McEdGetPointWorldDrawObject;l.setColor(te.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor()),e.setMessage(` 指定第一点:`),e.go(h=>{h===0&&(e.setMessage(` 指定第二个角度点:`),i.point1=e.value(),l.setDraw((p,_)=>{i.point2=p,_.drawLine(i.point1,p)}),e.setUserDraw(l),e.go(p=>{e.setMessage(` 指定最后一个点:`),p===0&&(i.point2=e.value(),l.setDraw((_,s)=>{i.point3=_,l.drawCustomEntity(i)}),e.go(_=>{_===0&&n.addMxEntity(i)}))}))})}function wP(){const e=new tt.MrxDbgUiPrPoint;e.setMessage(` 指定坐标点:`),e.go(n=>{if(n!=0)return;const i=e.value();let l=new tt.MxDbCoord;l.point1=i,l.point2=i.clone(),l.color=te.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor(),e.setBasePt(i),e.setUseBasePt(!0),e.setUserDraw((h,p)=>{l.point2=h,p.drawCustomEntity(l)}),e.setMessage(` 指定标注点:`),e.go(h=>{if(h!=0){console.log(h);return}l.point2=e.value(),tt.MxFun.addToCurrentSpace(l)})})}function MP(){new pm().rxInit(),tt.MxFun.addCommand("Mx_Linear",xP),tt.MxFun.addCommand("BR_AngleMeasure",bP),tt.MxFun.addCommand("BR_CoordMeasure",wP)}function TP(){return wn(this,null,function*(){let e=new te.MxCADUiPrEntity;e.setMessage("select entity:");let i=(yield e.go()).getMcDbEntity();if(i!==null){if(console.log("ent.objectName",i.objectName),i instanceof te.McDbBlockReference){let h=i.explode();if(h.GetCount()==0)return;let p=h.GetCount();for(let _=0;_=7&&Ot(ce),Ue==null&&(Ue=Ne(le,De,Oe)),ge(Ue,we)},St=function(ce,we){for(var Me=-1;Me<=7;Me+=1)if(!(ce+Me<=-1||se<=ce+Me))for(var pe=-1;pe<=7;pe+=1)we+pe<=-1||se<=we+pe||(0<=Me&&Me<=6&&(pe==0||pe==6)||0<=pe&&pe<=6&&(Me==0||Me==6)||2<=Me&&Me<=4&&2<=pe&&pe<=4?ye[ce+Me][we+pe]=!0:ye[ce+Me][we+pe]=!1)},gt=function(){for(var ce=0,we=0,Me=0;Me<8;Me+=1){st(!0,Me);var pe=s.getLostPoint(We);(Me==0||ce>pe)&&(ce=pe,we=Me)}return we},At=function(){for(var ce=8;ce>Me&1)==1;ye[Math.floor(Me/3)][Me%3+se-8-3]=pe}for(var Me=0;Me<18;Me+=1){var pe=!ce&&(we>>Me&1)==1;ye[Me%3+se-8-3][Math.floor(Me/3)]=pe}},Pe=function(ce,we){for(var Me=De<<3|we,pe=s.getBCHTypeInfo(Me),Be=0;Be<15;Be+=1){var $e=!ce&&(pe>>Be&1)==1;Be<6?ye[Be][8]=$e:Be<8?ye[Be+1][8]=$e:ye[se-15+Be][8]=$e}for(var Be=0;Be<15;Be+=1){var $e=!ce&&(pe>>Be&1)==1;Be<8?ye[8][se-Be-1]=$e:Be<9?ye[8][15-Be-1+1]=$e:ye[8][15-Be-1]=$e}ye[se-8][8]=!ce},ge=function(ce,we){for(var Me=-1,pe=se-1,Be=7,$e=0,ot=s.getMaskFunction(we),bt=se-1;bt>0;bt-=2)for(bt==6&&(bt-=1);;){for(var Vt=0;Vt<2;Vt+=1)if(ye[pe][bt-Vt]==null){var oe=!1;$e>>Be&1)==1);var ve=ot(pe,bt-Vt);ve&&(oe=!oe),ye[pe][bt-Vt]=oe,Be-=1,Be==-1&&($e+=1,Be=7)}if(pe+=Me,pe<0||se<=pe){pe-=Me,Me=-Me;break}}},Ve=function(ce,we){for(var Me=0,pe=0,Be=0,$e=new Array(we.length),ot=new Array(we.length),bt=0;bt=0?xn.getAt(un):0}}for(var tn=0,ve=0;vebt*8)throw"code length overflow. ("+Be.getLengthInBits()+">"+bt*8+")";for(Be.getLengthInBits()+4<=bt*8&&Be.put(0,4);Be.getLengthInBits()%8!=0;)Be.putBit(!1);for(;!(Be.getLengthInBits()>=bt*8||(Be.put(ue,8),Be.getLengthInBits()>=bt*8));)Be.put(ae,8);return Ve(Be,pe)};We.addData=function(ce,we){we=we||"Byte";var Me=null;switch(we){case"Numeric":Me=L(ce);break;case"Alphanumeric":Me=I(ce);break;case"Byte":Me=B(ce);break;case"Kanji":Me=O(ce);break;default:throw"mode:"+we}Oe.push(Me),Ue=null},We.isDark=function(ce,we){if(ce<0||se<=ce||we<0||se<=we)throw ce+","+we;return ye[ce][we]},We.getModuleCount=function(){return se},We.make=function(){if(le<1){for(var ce=1;ce<40;ce++){for(var we=C.getRSBlocks(ce,De),Me=E(),pe=0;pe";for(var Be=0;Be';Me+=""}return Me+="",Me+="",Me},We.createSvgTag=function(ce,we,Me,pe){var Be={};typeof arguments[0]=="object"&&(Be=arguments[0],ce=Be.cellSize,we=Be.margin,Me=Be.alt,pe=Be.title),ce=ce||2,we=typeof we=="undefined"?ce*4:we,Me=typeof Me=="string"?{text:Me}:Me||{},Me.text=Me.text||null,Me.id=Me.text?Me.id||"qrcode-description":null,pe=typeof pe=="string"?{text:pe}:pe||{},pe.text=pe.text||null,pe.id=pe.text?pe.id||"qrcode-title":null;var $e=We.getModuleCount()*ce+we*2,ot,bt,Vt,oe,ve="",xt;for(xt="l"+ce+",0 0,"+ce+" -"+ce+",0 0,-"+ce+"z ",ve+=''+Ie(pe.text)+"":"",ve+=Me.text?''+Ie(Me.text)+"":"",ve+='',ve+='":we+=">";break;case"&":we+="&";break;case'"':we+=""";break;default:we+=pe;break}}return we},it=function(ce){var we=1;ce=typeof ce=="undefined"?we*2:ce;var Me=We.getModuleCount()*we+ce*2,pe=ce,Be=Me-ce,$e,ot,bt,Vt,oe,ve={"██":"█","█ ":"▀"," █":"▄"," ":" "},xt={"██":"▀","█ ":"▀"," █":" "," ":" "},mt="";for($e=0;$e=Be?xt[oe]:ve[oe];mt+=` `}return Me%2&&ce>0?mt.substring(0,mt.length-Me-1)+Array(Me+1).join("▀"):mt.substring(0,mt.length-1)};return We.createASCII=function(ce,we){if(ce=ce||1,ce<2)return it(we);ce-=1,we=typeof we=="undefined"?ce*2:we;var Me=We.getModuleCount()*ce+we*2,pe=we,Be=Me-we,$e,ot,bt,Vt,oe=Array(ce+1).join("██"),ve=Array(ce+1).join(" "),xt="",mt="";for($e=0;$e>>8),De.push(Ue&255)):De.push(ae)}}return De}};var h={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},p={L:1,M:0,Q:3,H:2},_={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},s=function(){var K=[[],[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]],ie=1335,ue=7973,ae=21522,le={},De=function(ye){for(var se=0;ye!=0;)se+=1,ye>>>=1;return se};return le.getBCHTypeInfo=function(ye){for(var se=ye<<10;De(se)-De(ie)>=0;)se^=ie<=0;)se^=ue<5&&(Ue+=3+st-5)}for(var Oe=0;Oe=256;)le-=255;return K[le]},ae}();function T(K,ie){if(typeof K.length=="undefined")throw K.length+"/"+ie;var ue=function(){for(var le=0;le>>7-ae%8&1)==1},ue.put=function(ae,le){for(var De=0;De>>le-De-1&1)==1)},ue.getLengthInBits=function(){return ie},ue.putBit=function(ae){var le=Math.floor(ie/8);K.length<=le&&K.push(0),ae&&(K[le]|=128>>>ie%8),ie+=1},ue},L=function(K){var ie=h.MODE_NUMBER,ue=K,ae={};ae.getMode=function(){return ie},ae.getLength=function(ye){return ue.length},ae.write=function(ye){for(var se=ue,Ue=0;Ue+2>>8&255)*192+(Ue&255),De.put(Ue,13),se+=2}if(se>>8)},ie.writeBytes=function(ue,ae,le){ae=ae||0,le=le||ue.length;for(var De=0;De0&&(ue+=","),ue+=K[ae];return ue+="]",ue},ie},q=function(){var K=0,ie=0,ue=0,ae="",le={},De=function(se){ae+=String.fromCharCode(ye(se&63))},ye=function(se){if(!(se<0)){if(se<26)return 65+se;if(se<52)return 97+(se-26);if(se<62)return 48+(se-52);if(se==62)return 43;if(se==63)return 47}throw"n:"+se};return le.writeByte=function(se){for(K=K<<8|se&255,ie+=8,ue+=1;ie>=6;)De(K>>>ie-6),ie-=6},le.flush=function(){if(ie>0&&(De(K<<6-ie),K=0,ie=0),ue%3!=0)for(var se=3-ue%3,Ue=0;Ue=ie.length){if(le==0)return-1;throw"unexpected end of file./"+le}var se=ie.charAt(ue);if(ue+=1,se=="=")return le=0,-1;if(se.match(/^\s$/))continue;ae=ae<<6|ye(se.charCodeAt(0)),le+=6}var Ue=ae>>>le-8&255;return le-=8,Ue};var ye=function(se){if(65<=se&&se<=90)return se-65;if(97<=se&&se<=122)return se-97+26;if(48<=se&&se<=57)return se-48+52;if(se==43)return 62;if(se==47)return 63;throw"c:"+se};return De},he=function(K,ie){var ue=K,ae=ie,le=new Array(K*ie),De={};De.setPixel=function(Oe,We,st){le[We*ue+Oe]=st},De.write=function(Oe){Oe.writeString("GIF87a"),Oe.writeShort(ue),Oe.writeShort(ae),Oe.writeByte(128),Oe.writeByte(0),Oe.writeByte(0),Oe.writeByte(0),Oe.writeByte(0),Oe.writeByte(0),Oe.writeByte(255),Oe.writeByte(255),Oe.writeByte(255),Oe.writeString(","),Oe.writeShort(0),Oe.writeShort(0),Oe.writeShort(ue),Oe.writeShort(ae),Oe.writeByte(0);var We=2,st=se(We);Oe.writeByte(We);for(var St=0;st.length-St>255;)Oe.writeByte(255),Oe.writeBytes(st,St,255),St+=255;Oe.writeByte(st.length-St),Oe.writeBytes(st,St,st.length-St),Oe.writeByte(0),Oe.writeString(";")};var ye=function(Oe){var We=Oe,st=0,St=0,gt={};return gt.write=function(At,Dt){if(At>>>Dt)throw"length over";for(;st+Dt>=8;)We.writeByte(255&(At<>>=8-st,St=0,st=0;St=At<0&&We.writeByte(St)},gt},se=function(Oe){for(var We=1<>6,128|M&63):M<55296||M>=57344?_.push(224|M>>12,128|M>>6&63,128|M&63):(s++,M=65536+((M&1023)<<10|p.charCodeAt(s)&1023),_.push(240|M>>18,128|M>>12&63,128|M>>6&63,128|M&63))}return _}return h(l)}})(),function(l){e.exports=l()}(function(){return i})})(k1);var PP=k1.exports;const LP=z1(PP);function DP(e){let n={};if(n.ObjectName=e.objectName,n.id=e.getObjectID().id,n.handle=e.getHandle(),n.layer=e.layer,n.color=e.trueColor.getColorString(),n.colorVal=e.trueColor.getColorValue(e.layerId),n.linetype=e.linetype,n.textStyle=e.textStyle,n.type=e.objectName,n.dxf0=e.dxf0,e instanceof te.McDbText){let i=e;n.position=Er(i.position),n.textString=i.textString}else if(e instanceof te.McDbMText){let i=e;n.contents=i.contents,n.location=Er(i.location)}else if(e instanceof te.McDbLine){let i=e;n.startPoint=Er(i.startPoint),n.endPoint=Er(i.endPoint)}else if(e instanceof te.McDbCircle){let i=e;n.center=Er(i.center),n.radius=i.radius}else if(e instanceof te.McDbArc){let i=e;n.center=Er(i.center),n.startAngle=i.startAngle,n.endAngle=i.endAngle}else if(e instanceof te.McDbPolyline){let i=e,l=i.numVerts();n.num=l;for(let h=0;h{n["txt:"+p]=h})}else if(e instanceof te.McDbRotatedDimension){let i=e;n.xLine1Point=Er(i.xLine1Point),n.xLine2Point=Er(i.xLine2Point),i.GetAllText().forEach((h,p)=>{n["txt:"+p]=h})}else if(e instanceof te.McDbDimension)e.GetAllText().forEach((h,p)=>{n["txt:"+p]=h});else if(e instanceof te.McDbHatch){let i=e;n.patternType=i.patternType(),n.patternName=i.patternName(),n.patternAngle=i.patternAngle,n.patternScale=i.patternScale,n.patternSpace=i.patternSpace,n.patternDouble=i.patternDouble,n.hatchStyle=i.hatchStyle(),n.isSolid=i.isSolid(),n.numLoops=i.numLoops;for(let l=0;l{h["pt:"+_]={},h["pt:"+_].x=p.x,h["pt:"+_].y=p.y,h["pt:"+_].z=p.z}),n["loop:"+l]=h}n.numPatternDefinitions=i.numPatternDefinitions;for(let l=0;l{n.clipBoundary["pt"+s]=_.toVector3()}),n.clipBoundaryType=i.clipBoundaryType();let p=i.imageDefId().getMcDbRasterImageDef();p&&(n.filePath=p.sourceFileName)}return n}function IP(){return wn(this,null,function*(){let e=new te.MxCADSelectionSet;e.allSelect(),e.forEach(n=>{let i=n.getMcDbEntity();i&&(i=DP(i),console.log(JSON.stringify(i)))})})}function RP(){return wn(this,null,function*(){let e=new te.MxCADSelectionSet,n=new te.MxCADResbuf;n.AddString("0",8),e.allSelect(n),e.forEach(i=>{let l=i.getMcDbEntity();if(l&&l instanceof te.McDbHatch){let h={},p=l;h.patternType=p.patternType(),h.patternName=p.patternName(),h.patternAngle=p.patternAngle,h.patternScale=p.patternScale,h.patternSpace=p.patternSpace,h.patternDouble=p.patternDouble,h.hatchStyle=p.hatchStyle(),h.isSolid=p.isSolid(),h.numLoops=p.numLoops;for(let _=0;_{s["pt:"+T]={},s["pt:"+T].x=M.x,s["pt:"+T].y=M.y,s["pt:"+T].z=M.z}),h["loop:"+_]=s}h.numPatternDefinitions=p.numPatternDefinitions;for(let _=0;_{console.log(JSON.stringify({val:h,type:p,dxf:_}))})})}function BP(){return wn(this,null,function*(){let e=new te.MxCADUiPrEntity;e.setMessage("选择对象");let n=yield e.go();if(!n.isValid())return;let i=n.getMcDbEntity();i!==null&&i.setxDataString("DataName","xxxxx")})}function FP(){return wn(this,null,function*(){const e=new te.MxCADUiPrPoint;e.setMessage(` 指定第一点:`);let n=yield e.go();if(n)for(e.setMessage(` 指定下一个点:`);;){e.setBasePt(n);let i=yield e.go();if(!i)return;let l=new te.McDbLine(n,i);te.MxCpp.getCurrentMxCAD().drawEntity(l),n=i}})}function B1(){let e=window.location.hostname;return e.substring(0,4)!="http"&&(e=document.location.protocol+"//"+e),e}function OP(){return wn(this,null,function*(){let e="http://localhost:3000/mxcad/";e.substring(0,16)=="http://localhost"&&(e=B1()+e.substring(16));let n=e+"tree.mxweb",i=te.MxCpp.App.getCurrentMxCAD(),l=yield i.insertBlock(n,"tree");if(!l.isValid())return;let h=new te.McDbBlockReference;h.blockTableRecordId=l;let p=h.getBoundingBox();if(p.ret){let E=p.maxPt.distanceTo(p.minPt);E>1e-5&&h.setScale(i.getMxDrawObject().screenCoordLong2Doc(100)/E)}let _=new te.MxCADUiPrPoint;_.setMessage("指定插入基点"),_.setUserDraw((E,L)=>{h.position=E,L.drawMcDbEntity(h)});let s=yield _.go();if(!s)return;h.position=s;let M=i.drawEntity(h);if(!M.isValid){console.log("insert error");return}h=M.getMcDbEntity(),h.disableDisplay(!0),l.getMcDbBlockTableRecord().getAllEntityId().forEach((E,L)=>{if(!E.isKindOf("McDbAttributeDefinition"))return;let I=E.getMcDbEntity(),B=I.tag,O=I.textString,U=new te.McDbAttribute;U.position=I.position,U.alignmentPoint=I.alignmentPoint,U.height=I.height,U.trueColor=I.trueColor,U.widthFactor=I.widthFactor,O.length>0?U.textString=O:U.textString="test"+L,U.tag=B,U.isInvisible=I.isInvisible,U.transformBy(h.blockTransform),U=h.appendAttribute(U).getMcDbEntity(),U.textStyle=I.textStyle,U.layer=I.layer}),h.disableDisplay(!1)})}function NP(){let i=te.MxCpp.App.getCurrentMxCAD().getDatabase().getLayerTable().getAllRecordId(),l=[];return i.forEach(h=>{let p=h.getMcDbLayerTableRecord();if(p===null)return;console.log(p),console.log("layerRec.color:"+p.color.getColorString()),console.log("layerRec.name:"+p.name);let _={};_.name=p.name,_.color=p.color.getColorString(),l.push(_)}),tt.MxFun.postMessageToParentFrame(l),l}function UP(){let n=te.MxCpp.App.getCurrentMxCAD().getDatabase().getLayerTable();if(!n.has("xxx11")){let i=new te.McDbLayerTableRecord;i.name="xxx11",n.add(i)}n.has("xxx11")&&console.log("add layer ok")}function VP(){te.MxCpp.App.getCurrentMxCAD().getDatabase().getLinetypeTable().getAllRecordId().forEach(l=>{let h=l.getMcDbLinetypeTableRecord();h!==null&&console.log(h)})}function GP(){te.MxCpp.getCurrentMxCAD().getDatabase().getTextStyleTable().getAllRecordId().forEach(l=>{let h=l.getMcDbTextStyleTableRecord();if(h===null)return;let p={};p.name=h.name,p.font=h.font(),p.fileName=h.fileName,p.bigFontFileName=h.bigFontFileName,p.textSize=h.textSize,p.xScale=h.xScale,console.log(p)})}function HP(){return wn(this,null,function*(){let n=te.MxCpp.getCurrentMxCAD().getDatabase().getTextStyleTable(),i="MyTextStyle";n.has(i,!1)&&n.get(i,!1).erase(!1);let l=new te.McDbTextStyleTableRecord;l.fileName="txt.shx",l.bigFontFileName="hztxt.shx",l.textSize=10,l.name=i,l.xScale=.7,n.add(l).isValid()&&console.log("add ok")})}function WP(){te.MxCpp.App.getCurrentMxCAD().getDatabase().getBlockTable().getAllRecordId().forEach(l=>{let h=l.getMcDbBlockTableRecord();h!==null&&(console.log(h),console.log("blkRec.name:"+h.name),console.log("blkRec.origin:"+h.origin))})}function jP(){return wn(this,null,function*(){let e=new AP;e.data.addColumn("序号",30),e.data.addColumn("名称",45),e.data.addColumn("材料",60),e.data.addColumn("长度",50);for(let h=0;h<10;h++){let p=""+h;e.data.addRow([p,"AAAA","BBBB","1000"])}let n=new te.MxCADUiPrPoint;n.setMessage(` 指定表格插入点:`);let i=yield n.go();if(!i)return;let l=tt.MxFun.screenCoordLong2Doc(100)/200;e.draw(i,l)})}function qP(){return wn(this,null,function*(){const e=new tt.MrxDbgUiPrPoint;e.setMessage(` 指定插入点:`);let n=yield e.go();if(!n)return;let i=tt.MxFun.getCurrentDraw();const l=LP(5,"L");l.addData("https://www.mxdraw3d.com"),l.make();const h=l.createDataURL(),p=new $h().load(h),_=new lr({map:p});let s=tt.MxFun.screenCoordLong2Doc(80),M=tt.MxFun.screenCoordLong2Doc(80),T=new tt.MxDbImage;T.setRenderOrder(tt.MxType.MxDefaultRenderOrder.kCADMeshRenderOrder-1),T.setPoint1(n);let C=new Ee(n.x+s,n.y+M,n.z);T.setPoint2(C),T.setMaterial(_),i.addMxEntity(T),setInterval(()=>{i.updateDisplay()},100)})}function ZP(){return wn(this,null,function*(){let e="http://localhost:3000/mxcad/";e.substring(0,16)=="http://localhost"&&(e=B1()+e.substring(16));let n=e+"stamp.mxweb",i=te.MxCpp.App.getCurrentMxCAD(),l=yield i.insertBlock(n,"stamp");if(!l.isValid())return;let h=new te.McDbBlockReference;h.blockTableRecordId=l;let p=h.getBoundingBox();if(p.ret){let M=p.maxPt.distanceTo(p.minPt);M>1e-5&&h.setScale(i.getMxDrawObject().screenCoordLong2Doc(100)/M)}let _=new te.MxCADUiPrPoint;_.setMessage("指定插入基点"),_.setUserDraw((M,T)=>{h.position=M,T.drawMcDbEntity(h)});let s=yield _.go();s&&(h.position=s,i.drawEntity(h))})}function XP(){return wn(this,null,function*(){let e=te.MxCpp.getCurrentMxCAD(),n=e.database.getLinetypeTable().get("TestMyLine");n.isErase()||n.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 p=(yield new te.MxCADUiPrEntity().go()).getMcDbEntity();p&&(p.linetypeId=i)})}function Sy(e){e.getAllObjectName().forEach(i=>{console.log(i);let h=e.getAt(i).getMcDbObject();if(h instanceof te.McDbDictionary){let p=h;console.log(p),Sy(p)}else h instanceof te.McDbXrecord&&h.getData().PrintData()})}function YP(){return wn(this,null,function*(){let e=new te.MxCADUiPrEntity;e.setMessage("选择标注对象");let n=yield e.go();if(!n.isValid())return;let i=n.getMcDbEntity();if(i&&i.isHaveExtensionDictionary()){let l=i.getExtensionDictionary();Sy(l)}})}function $P(){return wn(this,null,function*(){let n=te.MxCpp.getCurrentMxCAD().getDatabase().getNamedObjectsDictionary();n.getAllObjectName().forEach(l=>{console.log(l);let p=n.getAt(l).getMcDbObject();if(p instanceof te.McDbDictionary){let _=p;console.log(_),Sy(_)}})})}function JP(){return wn(this,null,function*(){let n=te.MxCpp.getCurrentMxCAD().getDatabase().getNamedObjectsDictionary(),i="MyDict",l=n.getAt(i);if(l.isNull()){let p=new te.McDbDictionary;l=n.addObject(i,p)}let h=l.getMcDbDictionary();if(h){let p=new te.McDbXrecord,_=new te.MxCADResbuf;_.AddString("TestData"),p.setData(_),h.addObject("MyRecord",p),console.log("write xrecord ok")}})}function KP(){return wn(this,null,function*(){let e=new te.MxCADUiPrEntity;e.setMessage("选择标注对象");let n=yield e.go();if(!n.isValid())return;let i=n.getMcDbEntity();i&&(i.trueColor=new te.McCmColor(255,0,255))})}let Ay;function QP(){return wn(this,null,function*(){if(Ay){let e=Ay.getMcDbEntity();if(!e)return;e.visible=!0}else{let e=new te.MxCADUiPrEntity;e.setMessage("选择标注对象");let n=yield e.go();if(!n.isValid())return;let i=n.getMcDbEntity();if(!i)return;i.visible=!1,Ay=n}})}function e3(){return wn(this,null,function*(){let e="WALL";te.MxCpp.getCurrentMxCAD().database.layerTable.has(e)||console.log("no have layer:"+e);let i=new te.MxCADUiPrEntity;i.setMessage("选择对象");let l=yield i.go();if(!l.isValid())return;let h=l.getMcDbEntity();h&&(h.layer=e)})}function t3(){return wn(this,null,function*(){let e=new te.MxCADSelectionSet;if(!(yield e.userSelect(` 选择对象`)))return;let i=te.MxCpp.getCurrentDatabase().currentSpace.getMinMaxDrawOrder().maxDrawOrder+1;e.forEach(l=>{let h=l.getMcDbEntity();h&&(h.drawOrder=i)})})}function n3(){tt.MxFun.addCommand("TestGetAllEntity",IP),tt.MxFun.addCommand("MxTest_GetSysVars",zP),tt.MxFun.addCommand("MxTest_ReadxData",kP),tt.MxFun.addCommand("MxTest_WritexData",BP),tt.MxFun.addCommand("MxTest_DrawLine",FP),tt.MxFun.addCommand("MxTest_InsertBlock",OP),tt.MxFun.addCommand("MxTest_GetAllLayer",NP),tt.MxFun.addCommand("MxTest_AddLayer",UP),tt.MxFun.addCommand("MxTest_GetAllTextStyle",GP),tt.MxFun.addCommand("MxTest_GetAllBlock",WP),tt.MxFun.addCommand("MxTest_GetAllLinetype",VP),tt.MxFun.addCommand("Mx_Test_DrawTable",jP),tt.MxFun.addCommand("Mx_Test_QRCode",qP),tt.MxFun.addCommand("MxTest_InsertStamp",ZP),tt.MxFun.addCommand("MxTest_LineTypeTest",XP),tt.MxFun.addCommand("TestGentEntityOnLayer",RP),tt.MxFun.addCommand("MxTest_GetNamedObjectsDictionary",$P),tt.MxFun.addCommand("MxTest_GetObjectExDictionaryData",YP),tt.MxFun.addCommand("MxTest_WriteXRecord",JP),tt.MxFun.addCommand("MxTest_AddTextStyleTable",HP),tt.MxFun.addCommand("Mx_Test_ChangeColor",KP),tt.MxFun.addCommand("Mx_Test_ChangeVisible",QP),tt.MxFun.addCommand("Mx_Test_ChangeEntityLayer",e3),tt.MxFun.addCommand("Mx_ChaneEntityDrawOrder",t3)}function i3(){return wn(this,null,function*(){let{baseUrl:e="",saveDwgUrl:n="",mxfilepath:i=""}=vd().getUploadFileConfig();te.MxCpp.getCurrentMxCAD().saveFileToUrl(n,(l,h)=>{try{let p=JSON.parse(h);if(p.ret=="ok"){let _=e+i+p.file;fetch(_).then(s=>wn(this,null,function*(){const M=yield s.blob();te.MxTools.saveAsFileDialog({blob:M,filename:p.file,types:[{description:"dwg图纸",accept:{"application/octet-stream":[".dwg"]}}]})}))}else console.log(h)}catch(p){console.log("Mx: sserverResult error")}})})}function r3(){return wn(this,null,function*(){let{baseUrl:e="",mxfilepath:n="",saveUrl:i=""}=vd().getUploadFileConfig();te.MxCpp.getCurrentMxCAD().saveFileToUrl(i,(l,h)=>{try{let p=JSON.parse(h);if(p.ret=="ok"){let _=e+n+p.file;te.MxTools.downloadFileFromUrl(_,p.file)}else console.log(h)}catch(p){console.log("Mx: sserverResult error")}})})}function a3(){return wn(this,null,function*(){te.MxCpp.getCurrentMxCAD().openWebFile("http://localhost:1337/mxcad/file/8c79da20e232495888dbb0da17459399.mxweb")})}function o3(){return wn(this,null,function*(){te.MxCpp.getCurrentMxCAD().newFile()})}function s3(){return wn(this,null,function*(){let e=new te.MxCADUiPrPoint;e.setMessage(` 指定输出范围第一点:`);let n=yield e.go();if(!n)return;e.setMessage(` 指定输出范围第二点:`),e.setUserDraw((s,M)=>{M.setColor(16711680);let T=new te.McDbPolyline;T.addVertexAt(n),T.addVertexAt(new te.McGePoint3d(n.x,s.y)),T.addVertexAt(s),T.addVertexAt(new te.McGePoint3d(s.x,n.y)),T.constantWidth=tt.MxFun.screenCoordLong2Doc(2),T.isClosed=!0,M.drawMcDbEntity(T);let C=[];C.push(n.toVector3()),C.push(new THREE.Vector3(n.x,s.y)),C.push(s.toVector3()),C.push(new THREE.Vector3(s.x,n.y)),M.setColor(12868),M.drawSolid(C,.5)}),e.setDisableOsnap(!0),e.setDisableOrthoTrace(!0),e.setDynamicInputType(tt.DynamicInputType.kXYCoordInput);let i=yield e.go();if(!i)return;let{baseUrl:l="",mxfilepath:h="",printPdfUrl:p=""}=vd().getUploadFileConfig();console.log(vd().getUploadFileConfig());let _={width:"2100",height:"2970",bd_pt1_x:""+n.x,bd_pt1_y:""+n.y,bd_pt2_x:""+i.x,bd_pt2_y:""+i.y};te.MxCpp.getCurrentMxCAD().saveFileToUrl(p,(s,M)=>{try{let T=JSON.parse(M);if(T.ret=="ok"){let C=l+h+T.file;te.MxTools.downloadFileFromUrl(C,T.file)}else console.log(M)}catch(T){console.log("Mx: sserverResult error")}},void 0,JSON.stringify(_))})}function l3(n){return wn(this,arguments,function*({param:e}){te.MxCpp.getCurrentMxCAD().openWebFile(e)})}function c3(){return wn(this,null,function*(){const e=te.MxCpp.getCurrentMxCAD();e.saveFile(e.getCurrentFileName(),n=>{window.parent.postMessage({cmd:"MKY_Download_Mxweb",file:n})},!1,!1)})}function u3(){tt.MxFun.addCommand("Mx_Export_DWG",i3),tt.MxFun.addCommand("Mx_Export_MxWeb",r3),tt.MxFun.addCommand("Mx_Open_MxWeb",a3),tt.MxFun.addCommand("MxTest_NewFile",o3),tt.MxFun.addCommand("Mx_Export_Pdf",s3),tt.MxFun.addCommand("MKY_Open_Mxweb",l3),tt.MxFun.addCommand("MKY_Download_Mxweb",c3)}function h3(){return wn(this,null,function*(){let e="0601",n="001A",i=new te.MxCADSelectionSet,l=new te.MxCADResbuf;l.AddMcDbEntityTypes("TEXT,MTEXT,INSERT,ACAD_PROXY_ENTITY"),i.allSelect(l);let h,p,_=i.count();for(let s=0;s<_;s++){let T=i.item(s).getMcDbEntity();if(!T)return;if(T instanceof te.McDbText){let C=T;if(C.textString==e){h=C.position,p=C.getBoundingBox();break}}else if(T instanceof te.McDbMText){let C=T;if(C.contents==e){h=C.location,p=C.getBoundingBox();break}}else if(T instanceof te.McDbBlockReference){let C=T,E=C.getAllAttribute(),L=0;if(E.forEach(I=>{let B=I.getMcDbEntity();(B.textString==e||B.textString==n)&&L++}),L==2){h=C.position,p=C.getBoundingBox();break}}else if(T instanceof te.McDbProxyEntity){let C=T,E=C.getAllTextContent(),L=0;if(E.forEach(I=>{I==e&&L++}),L>=1){p=C.getBoundingBox(),p&&p.ret&&(h=new te.McGePoint3d(p.minPt.x+(p.maxPt.x-p.minPt.x)*.5,p.minPt.y+(p.maxPt.y-p.minPt.y)*.5));break}}}if(p&&p.ret){console.log(p);let s=p.minPt.distanceTo(p.maxPt)*2;tt.MxFun.getCurrentDraw().zoomW(new THREE.Vector3(p.minPt.x-s,p.minPt.y-s,0),new THREE.Vector3(p.maxPt.x+s,p.maxPt.y+s,0))}else h?tt.MxFun.getCurrentDraw().zoomCenter(h.x,h.y):console.log("没有找到文字:"+e)})}function d3(){tt.MxFun.addCommand("MxTest_FindText",h3)}class fm extends te.McDbCustomEntity{constructor(n){super(n),this.pt1=new te.McGePoint3d,this.pt2=new te.McGePoint3d}create(n){return new fm(n)}getTypeName(){return"McDbTestLineCustomEntity"}dwgInFields(n){return this.pt1=n.readPoint("pt1").val,this.pt2=n.readPoint("pt2").val,!0}dwgOutFields(n){return n.writePoint("pt1",this.pt1),n.writePoint("pt2",this.pt2),!0}moveGripPointsAt(n,i,l,h){this.assertWrite(),n==0?(this.pt1.x+=i,this.pt1.y+=l,this.pt1.z+=h):n==1&&(this.pt2.x+=i,this.pt2.y+=l,this.pt2.z+=h)}getGripPoints(){let n=new te.McGePoint3dArray;return n.append(this.pt1),n.append(this.pt2),n}worldDraw(n){let i=new te.McDbLine(this.pt1,this.pt2);n.drawEntity(i)}setPoint1(n){this.assertWrite(),this.pt1=n.clone()}setPoint2(n){this.assertWrite(),this.pt2=n.clone()}getPoint1(){return this.pt1}getPoint2(){return this.pt2}}function p3(){return wn(this,null,function*(){let e=te.MxCpp.getCurrentMxCAD();const n=new te.MxCADUiPrPoint;n.setMessage(` 指定一点:`);let i=yield n.go();if(!i)return;n.setBasePt(i),n.setUseBasePt(!0),n.setMessage(` 指定二点:`);let l=yield n.go();if(!l)return;let h=new fm;h.setPoint1(i),h.setPoint2(l),e.drawEntity(h)})}function f3(){new fm().rxInit(),tt.MxFun.addCommand("MxTest_DrawCustomEntity",p3)}function m3(){return wn(this,null,function*(){let e=new te.MxCADSelectionSet;if(!(yield e.userSelect("选择要做成块的对象:"))||e.count()==0)return;let n=te.MxCpp.getCurrentMxCAD(),l=n.getDatabase().getBlockTable().add(new te.McDbBlockTableRecord),h=l.getMcDbBlockTableRecord();if(h==null)return;let p,_,s,M;if(e.forEach(L=>{let I=L.getMcDbEntity();if(!I)return;let B=I.clone();h.appendAcDbEntity(B);let O=I.getBoundingBox();O.ret&&(p?(p>O.minPt.x&&(p=O.minPt.x),_>O.minPt.y&&(_=O.minPt.y),s{let I=L.getMcDbEntity();I&&I.erase()})})}function g3(){tt.MxFun.addCommand("MxTest_SelectEntitysToBlock",m3)}function _3(){return wn(this,null,function*(){const e=new te.MxCADUiPrPoint;e.setMessage(` 指定填充区域内部一点:`),e.disableAllTrace(!0),e.setDisableOsnap(!0);let n=yield e.go();if(!n)return;let i=te.MxCADUtility.builderHatchFromPoint(n);if(!i){tt.MxFun.acutPrintf(`没有找到闭合区域 `);return}te.MxCpp.getCurrentMxCAD().drawEntity(i)})}function y3(){tt.MxFun.addCommand("MxTest_DrawHatchFormPoint",_3)}const Cy={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 v3(e){if(/^\d+,\s*\d+,\s*\d+$/.test(e))return e.split(",").map(Number);if(/^0x[0-9a-fA-F]{6}$/.test(e)){const n=parseInt(e,16);return[n>>16&255,n>>8&255,n&255]}else if(/^#[0-9a-fA-F]{6}$/.test(e)){const n=parseInt(e.slice(1),16);return[n>>16&255,n>>8&255,n&255]}else if(Cy[e.toLowerCase()]){const n=e.toLowerCase();if(Cy[n])return Cy[n]}else{const n=new te.McCmColor;return n.setColorIndex(256),[n.red,n.green,n.blue]}}const x3=e=>{const n=te.MxCpp.getCurrentDatabase().layerTable;if(n.has(e))return;const i=new te.McDbLayerTableRecord;i.color=new te.McCmColor(0,0,0),i.isFrozen=!1,i.isLocked=!1,i.isOff=!1,i.lineWeight=te.McDb.LineWeight.kLnWtByLayer,i.name=e,n.add(i)},gs=[{name:"color",description:"颜色",type:"str",required:!0},{name:"layer",description:"图层",type:"str",required:!0},{name:"lineweight",description:"线重",type:"float",required:!0}],_s=(e,n)=>{n.layer&&x3(n.layer);const i=l=>{n.color?l.trueColor=new te.McCmColor(...v3(n.color)):l.trueColor=new te.McCmColor(te.MxCpp.getCurrentDatabase().getCurrentlyDrawColor()),n.layer?l.layer=n.layer:l.layer=te.MxCpp.getCurrentDatabase().getCurrentlyLayerName(),n.lineweight&&(l.lineweight=n.lineweight)};Array.isArray(e)?e.forEach(i):e&&i(e)},b3=e=>{const n=e.split(",").map(h=>Number(h)),i=[];let l=0;for(;l{if(typeof e=="object"&&"x"in e&&"y"in e)return new te.McGePoint3d(e.x,e.y);if(Array.isArray(e))return new te.McGePoint3d(e[0],e[1]);if(typeof e=="string"){const[n,i]=e.split(",").map(l=>Number(l));if(typeof n=="number"&&typeof i=="number")return new te.McGePoint3d(n,i)}};class w3{call(n){if(console.log(n),n&&n.pt1&&n.pt2){let i=te.MxCpp.getCurrentMxCAD();n.pt1&&(n.pt1=ur(n.pt1)),n.pt2&&(n.pt2=ur(n.pt2));const l=i.drawLine(n.pt1.x,n.pt1.y,n.pt2.x,n.pt2.y);_s(l.getMcDbEntity(),n),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},...gs]}}}function M3(){wa.regist(w3)}class T3{call(n){if(console.log(n),n&&n.cen&&n.radius){n.cen&&(n.center=ur(n.cen));let i=te.MxCpp.getCurrentMxCAD();const l=i.drawCircle(n.center.x,n.center.y,n.radius);_s(l.getMcDbEntity(),n),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},...gs]}}}const E3=()=>{wa.regist(T3)};function Gr(e,n,i,l,h){const p=e.x,_=e.y,s=n.x,M=n.y,T=i.x,C=i.y,E=l.x,L=l.y,I=(p-s)*(C-L)-(_-M)*(T-E);if(I===0)return null;const B=((p-T)*(C-L)-(_-C)*(T-E))/I,O=-((p-s)*(_-C)-(_-M)*(p-T))/I,U=p+B*(s-p),q=_+B*(M-_),ee=new te.McGePoint3d(U,q,0);return h||B>0&&B<1&&O>0&&O<1?ee:null}function eu(e,n){const i=n.x,l=n.y;let h=!1;for(let p=0,_=e.length-1;pl!=C>l&&i<(T-s)*(l-M)/(C-M)+s&&(h=!h)}return h}function sd(e,n,i,l){const h=e-i,p=n-l;let _=0;return h==0?_=Math.PI/2:_=Math.atan(Math.abs(p/h)),h<0&&p>=0?_=Math.PI-_:h<0&&p<0?_=Math.PI+_:h>=0&&p<0&&(_=Math.PI*2-_),_}function ld(e,n,i,l){const h=new te.McDbArc;return h.center=e,h.radius=n,h.startAngle=i,h.endAngle=l,h}class S3{call(n){return wn(this,null,function*(){console.log(n);let{center:i,radius:l,startAngle:h,endAngle:p,is3PDraw:_,point1:s,point2:M,point3:T}=n,C=te.MxCpp.getCurrentMxCAD();C.newFile(),C.zoomAll();const E=new te.MxCADUiPrPoint,L=new te.MxCADUiPrDist;if(_){if(s&&(s=ur(s)),M&&(M=ur(M)),T&&(T=ur(T)),E.setKeyWords(""),!s&&(E.setMessage("指定圆弧起点"),E.setUserDraw((B,O)=>{if(!M||!T)return;const U=new te.McDbArc;U.computeArc(B.x,B.y,M.x,M.y,T.x,T.y),O.drawMcDbEntity(U)}),s=yield E.go(),!s)||!M&&(E.setMessage("指定圆弧第二个点"),E.setUserDraw((B,O)=>{if(!s||!T)return;const U=new te.McDbArc;U.computeArc(s.x,s.y,B.x,B.y,T.x,T.y),O.drawMcDbEntity(U)}),M=yield E.go(),!M)||!T&&(E.setMessage("指定圆弧的端点"),E.setUserDraw((B,O)=>{if(!s||!M)return;const U=new te.McDbArc;U.computeArc(s.x,s.y,M.x,M.y,B.x,B.y),O.drawMcDbEntity(U)}),T=yield E.go(),!T))return;const I=new te.McDbArc;console.log(s.x,s.y,M.x,M.y,T.x,T.y),I.computeArc(s.x,s.y,M.x,M.y,T.x,T.y),_s(I,n),C.drawEntity(I),C.updateDisplay()}else{if(i&&(i=ur(i)),h&&(h=h*(Math.PI/180)),p&&(p=p*(Math.PI/180)),!i){E.setMessage("指定圆弧圆心"),E.setKeyWords(""),E.setUserDraw((O,U)=>{l&&U.drawMcDbEntity(ld(O,l,h||0,p||Math.PI*2))});const B=yield E.go();if(!B)return;i=B}if(!l&&(L.setBasePt(i),L.setMessage(te._ML_String("MxAiDrawCircleArc_Radius","指定圆弧半径")),L.setKeyWords(""),L.setUserDraw((B,O)=>{if(!i)return;const U=B.distanceTo(i);O.drawMcDbEntity(ld(i,U,h||0,p||Math.PI*2))}),l=yield L.go(),!l))return;if(!h){if(!i)return;L.setBasePt(i),L.setMessage(te._ML_String("MxAiDrawCircleArc_StartAngle","指定圆弧开始角")),L.setKeyWords(""),L.setUserDraw((O,U)=>{i&&l&&(h=sd(i.x,i.y,O.x,O.y)-Math.PI,U.drawMcDbEntity(ld(i,l,h||0,p||Math.PI*2)))});const B=yield L.go();if(!B)return;L.getDetailedResult()===tt.DetailedResult.kCoordIn&&(h=B*(Math.PI/180))}if(!p){if(!i)return;L.setBasePt(i),L.setMessage(te._ML_String("MxAiDrawCircleArc_EndAngle","指定圆弧结束角")),L.setKeyWords(""),L.setUserDraw((O,U)=>{i&&l&&(p=sd(i.x,i.y,O.x,O.y)-Math.PI,U.drawMcDbEntity(ld(i,l,h||0,p||Math.PI*2)))});const B=yield L.go();if(!B)return;L.getDetailedResult()===tt.DetailedResult.kCoordIn&&(p=B*(Math.PI/180))}const I=ld(i,l,h,p);_s(I,n),C.drawEntity(I),C.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},...gs]}}}const A3=()=>{wa.regist(S3)};function F1(e=new te.McGePoint3d,n=new te.McGePoint3d,i=3){const l=n.x,h=n.y,p=e.x,_=e.y,s=Math.max(3,i),T=Math.sqrt(Qv(l-p,2)+Qv(h-_,2))/Math.cos(Math.PI/s),C=Math.atan2(h-_,l-p)-Math.PI/s,E=[];for(let L=0;L"),T.setKeyWords(""),T.clearLastInputPoint(),l=(yield T.go())||5}if(i){if(s)s=ur(s);else{const L=new te.MxCADUiPrPoint;if(L.setMessage(` 指定正多变形的中心点`),L.setKeyWords(""),L.clearLastInputPoint(),s=yield L.go(),!s)return}let T=te.McGeVector3d.kXAxis,C;if(!_){const L=new te.MxCADUiPrDist;L.setMessage(te._ML_String("MxAiDrawPolygon_radius","指定圆的半径")),L.setKeyWords(""),L.setBasePt(s),L.setUserDraw((B,O)=>{if(M){const U=B.distanceTo(s);T=B.sub(s);const q=s.clone().addvec(B.sub(s).normalize().mult(U)),ee=F1(s,q,l),he=new te.McDbPolyline;ee.forEach(Ce=>{he.addVertexAt(Ce)}),he.isClosed=!0,O.drawMcDbEntity(he)}else{C=B;const U=new te.McDbPolyline;O1(s,B,l).forEach(q=>{U.addVertexAt(q)}),U.isClosed=!0,O.drawMcDbEntity(U)}});const I=yield L.go();if(!I)return;_=I}const E=new te.McDbPolyline;if(E.isClosed=!0,M){const L=s.clone().addvec(T.normalize().mult(_));F1(s,L,l).forEach(B=>{E.addVertexAt(B)})}else{if(!C){const L=te.McGeVector3d.kXAxis.clone().rotateBy(Math.PI/l).mult(_);C=s.clone().addvec(L)}O1(s,C,l).forEach(L=>{E.addVertexAt(L)})}te.MxCpp.getCurrentMxCAD().drawEntity(E)}else{const T=E=>{const L=new te.McDbPolyline;return C3(h,E,l||5).forEach(B=>{L.addVertexAt(B)}),L.isClosed=!0,L};if(h)h=ur(h);else{const E=new te.MxCADUiPrPoint;if(E.clearLastInputPoint(),E.setMessage(` 指定边的第一个端点`),E.setKeyWords(""),h=yield E.go(),!h)return;E.setUserDraw((L,I)=>{I.drawMcDbEntity(T(L))})}if(p)p=ur(p);else{const E=new te.MxCADUiPrPoint;E.setBasePt(h),E.setMessage(` 指定边的第二个端点`),p=yield E.go()}if(!p)return;const C=T(p);te.MxCpp.getCurrentMxCAD().drawEntity(C)}})}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 L3=()=>{wa.regist(P3)},N1=(e,n,i)=>{const l=Math.cos(i),h=Math.sin(i),p=n.x-e.x,_=n.y-e.y,s=p*l-_*h+e.x,M=p*h+_*l+e.y,T=n.z;return new te.McGePoint3d(s,M,T)},Py=(e,n,i=0)=>{const l=new te.McGePoint3d((e.x+n.x)/2,(e.y+n.y)/2,(e.z+n.z)/2),h=new te.McGePoint3d(e.x,n.y,e.z),p=new te.McGePoint3d(n.x,e.y,n.z),_=N1(l,h,i),s=N1(l,p,i);return[e,_,n,s]},U1=(e,n)=>[n.x>=e.x&&n.y>=e.y,n.x=e.y,n.x=e.x&&n.yB.angleTo1(i)&&(O=L),te.MxCADUtility.calcBulge(e,O,n).val}class I3{call(n){return wn(this,null,function*(){console.log(n),te.MxCpp.getCurrentMxCAD().newFile();let{pt1:i,pt2:l,chamfer1Length:h,chamfer2Length:p,filletRadius:_,lineWidth:s,area:M,rectLength:T,rectWidth:C,rotationAngle:E}=n;const L=(O,U)=>{const[q,ee,he,Ce]=Py(O,U,E),K=new te.McDbPolyline;return K.addVertexAt(q,0,s,s),K.addVertexAt(ee,0,s,s),K.addVertexAt(he,0,s,s),K.addVertexAt(Ce,0,s,s),K.isClosed=!0,s&&(K.constantWidth=s),K},I=(O,U)=>{let q;if(_){const ee=V1(Py(O,U,E),_,_),[he,Ce,K,ie]=U1(O,U);if(ee.length===8){q||(q=new te.McDbPolyline);const ue=(se,Ue,Oe)=>{let We=new te.McGeVector3d(Oe);const st=D3(se,Ue,We);q.addVertexAt(se,st,s,s),q.addVertexAt(Ue,0,s,s)},ae=new te.McGeVector3d(-1,0),le=new te.McGeVector3d(0,1),De=new te.McGeVector3d(1,0),ye=new te.McGeVector3d(0,-1);ie&&(le.y=-1,De.x=1,ye.y=1),Ce&&(ae.x=1,le.y=1,De.x=-1,ye.y=-1),K&&(ae.x=1,le.y=-1,De.x=-1,ye.y=1),ue(ee[0],ee[1],ae),ue(ee[2],ee[3],le),ue(ee[4],ee[5],De),ue(ee[6],ee[7],ye),q.isClosed=!0}}else(h||p)&&(q||(q=new te.McDbPolyline),V1(Py(O,U,E),h||p,p||h).forEach(he=>{q.addVertexAt(he)}),q.isClosed=!0);return q||(q=L(O,U)),s&&(q.constantWidth=s),q};if(i)i=ur(i);else{const O=new te.MxCADUiPrPoint;if(O.setMessage("指定第一个角点"),O.setKeyWords(""),i=yield O.go(),!i)return}if(M&&(T&&(C=M/T),C&&(T=M/C)),T&&C&&(l=new te.McGePoint3d(i.x+C,i.y+T,0)),l)l=ur(l);else{const O=new te.MxCADUiPrPoint;if(O.setMessage("指定第二个角点"),O.setKeyWords(""),O.setUserDraw((U,q)=>{q.drawMcDbEntity(I(i,U))}),l=yield O.go(),!l)return}const B=I(i,l);_s(B,n),te.MxCpp.getCurrentMxCAD().drawEntity(B)})}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},...gs]}}}function R3(){wa.regist(I3)}const no=(e,n,i,l,h)=>{const p=new te.McDbEllipse,_=new te.McGePoint3d((e.x+n.x)/2,(n.y+n.y)/2),s=e.sub(n),M=s,T=e.distanceTo(n)/2,E=i/2/T;return p.center=_,p.majorAxis=s,p.minorAxis=M,p.radiusRatio=E,p.startAngle=l,p.endAngle=h,p};class z3{call(n){return wn(this,null,function*(){let{endPoint1:i,endPoint2:l,halfAxisLength:h}=n;const p=te.MxCpp.getCurrentMxCAD();p.newFile();const _=new te.MxCADUiPrPoint,s=new te.MxCADUiPrDist;if(i&&(i=ur(i)),l&&(l=ur(l)),!i&&(_.setMessage("指定椭圆的轴端点1"),_.setKeyWords(""),_.setUserDraw((T,C)=>{l&&h&&C.drawMcDbEntity(no(T,l,h,0,Math.PI*2))}),i=yield _.go(),!i)||!l&&(_.setMessage("指定椭圆的轴端点2"),_.setKeyWords(""),_.setUserDraw((T,C)=>{i&&h&&C.drawMcDbEntity(no(i,T,h,0,Math.PI*2))}),l=yield _.go(),!l))return;if(!h){s.setMessage("指定半轴长度"),s.setKeyWords("");const T=new te.McGePoint3d((i.x+l.x)/2,(l.y+l.y)/2);if(s.setBasePt(T),s.setUserDraw((C,E)=>{i&&E.drawMcDbEntity(no(i,l,T.distanceTo(C),0,Math.PI*2))}),h=yield s.go(),!h)return}const M=no(i,l,h,0,Math.PI*2);_s(M,n),p.drawEntity(M)})}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},...gs]}}}class k3{call(n){return wn(this,null,function*(){let{endPoint1:i,endPoint2:l,halfAxisLength:h,startAngle:p,endAngle:_}=n;const s=te.MxCpp.getCurrentMxCAD();s.newFile();const M=new te.MxCADUiPrPoint,T=new te.MxCADUiPrDist;if(i&&(i=ur(i)),l&&(l=ur(l)),p&&(p=p*(Math.PI/180)),_&&(_=_*(Math.PI/180)),!i&&(M.setMessage("指定椭圆的轴端点1"),M.setKeyWords(""),M.setUserDraw((I,B)=>{l&&h&&B.drawMcDbEntity(no(I,l,h,0,Math.PI*2))}),i=yield M.go(),!i)||!l&&(M.setMessage("指定椭圆的轴端点2"),M.setKeyWords(""),M.setUserDraw((I,B)=>{i&&h&&B.drawMcDbEntity(no(i,I,h,0,Math.PI*2))}),l=yield M.go(),!l))return;const C=new te.McGePoint3d((i.x+l.x)/2,(l.y+l.y)/2);if(!h&&(T.setMessage("指定半轴长度"),T.setKeyWords(""),T.setBasePt(C),T.setUserDraw((I,B)=>{i&&B.drawMcDbEntity(no(i,l,C.distanceTo(I),0,Math.PI*2))}),h=yield T.go(),!h))return;const E=sd(C.x,C.y,i.x,i.y);if(!p){T.setMessage(te._ML_String("EllipticalArc_startAngle","指定起点角度")),T.setKeyWords(""),T.setUserDraw((B,O)=>{p=sd(C.x,C.y,B.x,B.y)-E-Math.PI,O.drawMcDbEntity(no(i,l,h,p,Math.PI*2))});const I=yield T.go();if(!I)return;T.getDetailedResult()==tt.DetailedResult.kCoordIn&&(p=I*(180/Math.PI))}if(!_){T.setLastInputPoint(C),T.setMessage(te._ML_String("EllipticalArc_endAngle","指定端点角度")),T.setKeyWords(""),T.setUserDraw((B,O)=>{_=sd(C.x,C.y,B.x,B.y)-E-Math.PI,O.drawMcDbEntity(no(i,l,h,p,_))});const I=yield T.go();if(!I)return;T.getDetailedResult()===tt.DetailedResult.kCoordIn&&(_=I*(180/Math.PI))}const L=no(i,l,h,p,_);_s(L,n),s.drawEntity(L)})}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},...gs]}}}const B3=()=>{wa.regist(z3),wa.regist(k3)},ha=class ha{constructor(n,i,l=50){this.width=50,this.isDraw=!1,this.update(n,i,l)}update(n,i,l=this.width){let h=n.clone().sub(i).normalize();h=new te.McGeVector3d(-h.y,h.x,0).mult(l/2);const p=h.clone().negate();this.outsidePoints=[n.clone().addvec(h),i.clone().addvec(h)],this.insidePoints=[n.clone().addvec(p),i.clone().addvec(p)],this.width=l,this.startPoint=n.clone(),this.endPoint=i.clone(),this.outsideLine?(this.outsideLine.startPoint=this.outsidePoints[0],this.outsideLine.endPoint=this.outsidePoints[1]):this.outsideLine=new te.McDbLine(this.outsidePoints[0],this.outsidePoints[1]),this.insideLine?(this.insideLine.startPoint=this.insidePoints[0],this.insideLine.endPoint=this.insidePoints[1]):this.insideLine=new te.McDbLine(this.insidePoints[0],this.insidePoints[1]),this.startClosedLine?(this.startClosedLine.startPoint=this.outsidePoints[0],this.startClosedLine.endPoint=this.insidePoints[0]):this.startClosedLine=new te.McDbLine(this.outsidePoints[0],this.insidePoints[0]),this.endClosedLine?(this.endClosedLine.startPoint=this.outsidePoints[1],this.endClosedLine.endPoint=this.insidePoints[1]):this.endClosedLine=new te.McDbLine(this.outsidePoints[1],this.insidePoints[1])}clone(){const n=new ha(this.startPoint,this.endPoint,this.width);return n.insideLine=this.insideLine.clone(),n.outsideLine=this.outsideLine.clone(),n}hiddenStartClosedLine(){this.startClosedLine.visible=!1}hiddenEndClosedLine(){this.endClosedLine.visible=!1}getClosedStartLineToDiffWallInsideLineIntersectionPoint(n,i=!1){return this.startClosedLine.visible?Gr(n.insideLine.startPoint,n.insideLine.endPoint,this.startClosedLine.startPoint,this.startClosedLine.endPoint,i):null}getClosedStartLineToDiffWallOutsideLineIntersectionPoint(n,i=!1){return this.startClosedLine.visible?Gr(n.outsideLine.startPoint,n.outsideLine.endPoint,this.startClosedLine.startPoint,this.startClosedLine.endPoint,i):null}getClosedEndLineToDiffWallInsideLineIntersectionPoint(n,i=!1){return this.endClosedLine.visible?Gr(n.insideLine.startPoint,n.insideLine.endPoint,this.endClosedLine.startPoint,this.endClosedLine.endPoint,i):null}getClosedEndLineToDiffWallOutsideLineIntersectionPoint(n,i=!1){return this.endClosedLine.visible?Gr(n.outsideLine.startPoint,n.outsideLine.endPoint,this.endClosedLine.startPoint,this.endClosedLine.endPoint,i):null}getInsideToDiffInsideIntersectionPoint(n,i=!1){return Gr(n.insideLine.startPoint,n.insideLine.endPoint,this.insideLine.startPoint,this.insideLine.endPoint,i)}getOutsideToDiffOutsideIntersectionPoint(n,i=!1){return Gr(n.outsideLine.startPoint,n.outsideLine.endPoint,this.outsideLine.startPoint,this.outsideLine.endPoint,i)}getInsideToDiffOutsideIntersectionPoint(n,i=!1){return Gr(n.outsideLine.startPoint,n.outsideLine.endPoint,this.insideLine.startPoint,this.insideLine.endPoint,i)}getOutsideToDiffInsideIntersectionPoint(n,i=!1){return Gr(n.insideLine.startPoint,n.insideLine.endPoint,this.outsideLine.startPoint,this.outsideLine.endPoint,i)}getClosedStartLineToDiffLineClosedStartLineIntersectionPoint(n,i=!1){return this.startClosedLine.visible?Gr(n.startClosedLine.startPoint,n.startClosedLine.endPoint,this.startClosedLine.startPoint,this.startClosedLine.endPoint,i):null}getClosedStartLineToDiffLineClosedEndLineIntersectionPoint(n,i=!1){return this.startClosedLine.visible?Gr(n.endClosedLine.startPoint,n.endClosedLine.endPoint,this.startClosedLine.startPoint,this.startClosedLine.endPoint,i):null}getClosedEndLineToDiffLineClosedStartLineIntersectionPoint(n,i=!1){return this.endClosedLine.visible?Gr(n.startClosedLine.startPoint,n.startClosedLine.endPoint,this.endClosedLine.startPoint,this.endClosedLine.endPoint,i):null}getClosedEndLineToDiffLineClosedEndLineIntersectionPoint(n,i=!1){return this.endClosedLine.visible?Gr(n.endClosedLine.startPoint,n.endClosedLine.endPoint,this.endClosedLine.startPoint,this.endClosedLine.endPoint,i):null}isCorner(n){const i=n.startPoint.sub(n.endPoint).normalize(),l=i.clone().mult(n.width),h=i.clone().mult(-n.width),p=n.insideLine.startPoint.clone().addvec(l),_=n.insideLine.startPoint.clone().addvec(h),s=n.outsideLine.startPoint.clone().addvec(h),M=n.outsideLine.startPoint.clone().addvec(l),T=n.insideLine.endPoint.clone().addvec(l),C=n.insideLine.endPoint.clone().addvec(h),E=n.outsideLine.endPoint.clone().addvec(h),L=n.outsideLine.endPoint.clone().addvec(l),I=eu([p,_,s,M],this.startPoint),B=eu([p,_,s,M],this.endPoint),O=eu([T,C,E,L],this.startPoint),U=eu([T,C,E,L],this.endPoint);return[{start:I,end:B},{start:O,end:U}]}handlingCorners(n){const[i,l]=this.isCorner(n);if(l.start){this.outsideLine.startPoint=n.outsideLine.endPoint=this.getOutsideToDiffOutsideIntersectionPoint(n,!0),this.insideLine.startPoint=n.insideLine.endPoint=this.getInsideToDiffInsideIntersectionPoint(n,!0),this.hiddenStartClosedLine(),n.hiddenEndClosedLine();return}else if(l.end){this.outsideLine.endPoint=n.insideLine.endPoint=this.getOutsideToDiffInsideIntersectionPoint(n,!0),this.insideLine.endPoint=n.outsideLine.endPoint=this.getInsideToDiffOutsideIntersectionPoint(n,!0),this.hiddenEndClosedLine(),n.hiddenEndClosedLine();return}else if(i.start){this.insideLine.startPoint=n.outsideLine.startPoint=this.getInsideToDiffOutsideIntersectionPoint(n,!0),this.outsideLine.startPoint=n.insideLine.startPoint=this.getOutsideToDiffInsideIntersectionPoint(n,!0),this.hiddenStartClosedLine(),n.hiddenStartClosedLine();return}else if(i.end){this.outsideLine.endPoint=n.outsideLine.startPoint=this.getOutsideToDiffOutsideIntersectionPoint(n,!0),this.insideLine.endPoint=n.insideLine.startPoint=this.getInsideToDiffInsideIntersectionPoint(n,!0),this.hiddenEndClosedLine(),n.hiddenStartClosedLine();return}}processingIntersection(){const n=[];ha.lines.forEach(i=>{const l=this.getInsideToDiffInsideIntersectionPoint(i),h=this.getInsideToDiffOutsideIntersectionPoint(i),p=this.getOutsideToDiffOutsideIntersectionPoint(i),_=this.getOutsideToDiffInsideIntersectionPoint(i);(l||h||p||_)&&n.push({diffLine:i,intersectionPoints:[l,h,p,_]})}),n.forEach(({diffLine:i,intersectionPoints:l})=>{const[h,p]=this.isCorner(i);h.end||h.start||p.start||p.start;const[_,s,M,T]=l,C=[i.insideLine.startPoint,i.insideLine.endPoint,i.outsideLine.endPoint,i.outsideLine.startPoint];if(eu(C,this.startPoint),eu(C,this.endPoint),_&&s&&M&&T){const E=Gr(this.startPoint,this.endPoint,i.startPoint,i.endPoint),L=new ha(this.startPoint,E,this.width),I=new ha(E,this.endPoint,this.width),B=new ha(i.startPoint,E,i.width),O=new ha(E,i.endPoint,i.width);L.insideLine.startPoint=this.insideLine.startPoint,L.outsideLine.startPoint=this.outsideLine.startPoint,I.insideLine.endPoint=this.insideLine.endPoint,I.outsideLine.endPoint=this.outsideLine.endPoint,i.remove(),this.remove(),L.draw(),I.draw(),B.draw(),O.draw()}else if(M&&s||_&&T){const E=Gr(this.startPoint,this.endPoint,i.startPoint,i.endPoint,!0),L=new ha(i.startPoint,E,i.width);L.hiddenEndClosedLine();const I=new ha(E,i.endPoint,i.width);I.hiddenStartClosedLine(),i.remove(),L.draw(),I.draw()}else{if(n.length===1)return this.handlingCorners(i);p.start?(console.log("endCorner.start"),M&&(i.outsideLine.endPoint=this.outsideLine.startPoint=M),_&&(i.insideLine.endPoint=this.insideLine.startPoint=_),this.hiddenStartClosedLine(),i.hiddenEndClosedLine()):p.end?(console.log("endCorner.end"),T&&(i.insideLine.endPoint=this.outsideLine.endPoint=T),s&&(i.outsideLine.endPoint=this.insideLine.endPoint=s),this.hiddenEndClosedLine(),i.hiddenEndClosedLine()):h.start?(console.log("startCorner.start"),s&&(i.outsideLine.startPoint=this.insideLine.startPoint=s),T&&(i.insideLine.startPoint=this.outsideLine.startPoint=T),i.hiddenStartClosedLine(),this.hiddenStartClosedLine()):h.end&&(console.log("startCorner.end"),M&&(i.outsideLine.startPoint=this.outsideLine.endPoint=M),_&&(i.insideLine.startPoint=this.insideLine.endPoint=_),i.hiddenStartClosedLine(),this.hiddenEndClosedLine())}})}draw(n=!0){if(this.isDraw)return;const i=te.MxCpp.getCurrentMxCAD();if(this.outsideLine&&this.outsideLine.erase(),this.insideLine&&this.insideLine.erase(),!i)return;this.outsideLine.trueColor=new te.McCmColor(255,0,0),this.outsideId=i.drawEntity(this.outsideLine),this.insideLine.trueColor=new te.McCmColor(0,255,255),this.insideId=i.drawEntity(this.insideLine);const l=this.outsideId.getMcDbEntity();l&&(this.outsideLine=l);const h=this.insideId.getMcDbEntity();h&&(this.insideLine=h),this.startClosedId=i.drawEntity(this.startClosedLine),this.endClosedId=i.drawEntity(this.endClosedLine);const p=this.startClosedId.getMcDbEntity();p&&(this.startClosedLine=p);const _=this.endClosedId.getMcDbEntity();_&&(this.endClosedLine=_),i.updateDisplay(),ha.lines.add(this),this.isDraw=!0,n&&this.processingIntersection()}remove(){this.endClosedId&&this.endClosedId.erase(),this.startClosedId&&this.startClosedId.erase(),this.insideId&&this.insideId.erase(),this.outsideId&&this.outsideId.erase(),ha.lines.delete(this)}};ha.lines=new Set;let Ly=ha;class F3{call(n){if(n&&n.points){let i=te.MxCpp.getCurrentMxCAD();const l=b3(n.points);if(l.length<2)return;l.forEach((h,p)=>{const _=l[p+1];if(!_)return;new Ly(h,_,n.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},...gs]}}}setTimeout(()=>{te.MxCpp.App.getCurrentMxCAD().insertBlock(new URL("data:application/octet-stream;base64,TXhXZWIxMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3LjAuMy4zLjIwMjMwOTA2LjEAAAAAAAAAAAAAAAAAAAMCAxEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAPAAAAe3R5cGU6MH10eHQuc2h4FgAAAHt0eXBlOjB9e2JpZ31oenR4dC5zaHgAUACVogAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABdAEAAAJ++AAAAAAAAACaeBuZm8GkzZhpilRyOJBAn4tc//5R2bFAe3kyw6fWWTAWwe1PchVprNnl8tMN/pIaWS/hZsrTh7OpqqM6DRLbNLHLv444qfqMJUFd6pQqzE/GB36X84thmjIVMBlKvqvpMFCFQBOiWYZAI4QbTgIDKHKXlbSonTHsTBcWU+YgeAjST3E5p17PW/6vaFQrxuESiD6lUcUJb3tsNa7Xyu9Z9AvP6MaOXJMHWCDPMIiVvDMqBWlZ38zKJKgqyEnUJbRr3pTur3EfRKqhJuCSOHFG1YPFoGYKLGeSeStBcHpaCU2gQJiF0HdudLQPz9VcK0wePfr5JLL390wEmhRuzwgk90fTnBUNkA1c3A+QLGL2GsZSdyZrin7sleYrIImkwmnf8eYYi4XiH8bu8GHQgOcBP3XHnsn8UsZ6YuTRmqdwbfCJS2QK/9fWC9dq6RfjZu2y/yh9/WJ860OBLFs6bcYr3gsQJRJ9sH9SUEpC2DbXL5zJalvMwYS8ZiUWMHkm2JgLvHQDQthvTtBO8cNk085/KHm+GPvpkJYI2uWgM5G67Dd89R1mJA36ajdRZoAbCi9DWaHIabFTB8uUe6EjjIw/Lih1jrDWxJwaxUWTnPpv+NzVSef2xLC1pb5UGbsYUrox9pf1zDTZGCI62UD+WqRhWtTsaT/gM0gc2BadKMORGy7AQ5gDFSedSMCezVrfEG3Jq2GX5BO8bLOJ9LtLHQ9tIYkWXb4EdGrtjEcOBrEiBIAAcSqyk8k/f59G7XTxLgGyjGe4WUiIqh4Aof8tYOzH0gBAaY3ZcK2PNePhDCcUWfgh8nf5BdDSxHab0LQyABIKJITRuzOycyh4ZWuQPNuALUTOJ3PnE5xLFJ8rBy2RmWiDhiO5JAky0TiH/mgJcgwXUB3heK8XCBBh2+hHJ9xoCh3xPIl3ltaBaDvqrZgyO+uBzPvdLOeljgbNPqlKnYykEDV+/Uc/2lgqQf5FlCyPhYaV7GSbZIROrYeGI2IBu1hxBVZhPUpFFmamGLpVo9+T7fbvuHLe1wjEBz/AysTUBsMLLcQHfTqS6uDI6EPsapoSyC9Ja+RRHiKQzJyoj3JJokdefntZ23+2/Wy6aZAGBJseTI93qtZnMxVEBuzasJeI1JtPPOs9hbTtZV5pEA7taTycqBjVZK4WjZdPfPcB22Aapi91ngktqafjIXaVWQs4VxjXjFoV9nc+pmC8dITVbJnnpNEZF+u+O3Z3olp9xgcqgdgauoHpoz4MYWzNRv7CQ6PenT0xfwOpGnNn8p/Z0SVh1np5Dj87O4BquzWCY/h+CBc+hbpFx7/ljvhyxDhOWydYPVEEQ8Z2I4RXD14VpIsjJdKXArxFs/Ml9kGun32aU7SbQQpNFdQJbFkLN3zhQYqPkPFB330qg5p4FJjNHufIDX6XeJaxU/t/oOTclmdsnnj3t82+KK2rpyRkAPgjQxl4LSzZKpIKRiLJX8x6ZLygrdGjkP5qq8VW/aFVCDhTqju/8+8aYTgPjFK7dlmiyYCYszy/QxSF2spXChXZN/qtLmfi+4h/7PcvOOxz1KYe44E1YdYi0Urmf2d2Mc2d1bQ9hHwJpEntuFsSlIII9dOtPBoZTLszMdVSfq/K2pD/amOa0MeNKdEXDKJ/6vXkBhftUfbOwxAT29dzxWZdPuXAQM2JieVzJD4TJN2jssnPocwGTnExPu+SJq2YxE0/GVm5erg67LtOxhyfw9ddqt87oceqksrppzLCMbEKOsYuDulMJ4EARLtzJmzF4Aq2cqnD6Swgy3W1Qhvk6c8WujhW+9Bg1J1ju4a5FV/aaPsp0qKtQb5JcLkmqYAJkdp3QRPzoQiRdeVLBW+rr5vclybWUY7qy2S1XJAxifQ573cvciggQ8zMH0Y4Ra2wSPrhL+ClLyMR9OlcPbtlFlt6vrvAtlPio0pFedXSPmvu8BxngBKWkux2dk7rQMlyTswH924BSaQk86y1TXQD3FlRrY3sHDSYi8zr5LcTXh9C9Fz1sgXMDU2ieYg+jAi5iXKA47VuTQp3uiKxxEdnWBiA3PK7rDQL2NCGnBAeDhpbCue6qfJeGnqHKTUzpriuxMlCLB64NV92xTls2p+COV/KNgKO5bkDu8lpGYAavW1YMgi1+zz4G0fqQYalAkNM7dKU1oXG+Ir1EumBRSqwDkhPD+NY2ZP976WZN+VBEHZSsSoYMCYjRvysX7QkAfosVzAdWAVlDgB1bZB+LNGxBrKsIK8jxp+A2sek6+rVTZSm0igaWZ5ycIzCyU/JhYiSsJlS5YvG+MV5C5DdQo0JO32YknSThUX80LuWtTohFUVPc3b+2kXzv8hsWwk09rZvYW2X6SyWWjtuciRAgVVh0zqGszaWIjwEngnkUNm45n60wRoHYyygQ2o4qWiAFnqJffiWfVkPQpAsLhgzI42rhNjwmQtGbGBuH4+SxrIkPr8oZfvmHDFTdZOrDv/80tB8jRaf+RvYrQw2reClkO8orYaXmC2R9RV2vR9CvFRoDizVVmAYfEtx7vHAblwnCJFLzb1UdxGVwOhVPILp9jLBLXFkOT6bips7we7o+6eu3DcUfBhCJ0xqfte6AFzxpbP7ucb2lAIWieKGaw/I6YI93xISXIbmA5wfOqPP+rPHSHbEVUE3LCG6BQGoO06K/onrjDToxNSHkIiKvPdg1GnFGkcGyOHXXfUiCzF6zs24ahYQzDW7WRJ3HmWhxUbD6AvbBZ2X4nPACTNgysK5/k4y6NiUUe9Pdq/KYJnHiZuRgzm512BxTtKRA/2eoOW7Hpi9sCYumYvBRFZisTYZJ0X2TnCe7QWlrTcED8q929lKCWJ8nF770jTmHWpWDPXTLjM5zL5v+BHdmT5JPVOQFLDpXSKzuj7AJ2JqJRT0u1BIV+Fw/UukTWORcPsQDC1QLNkkzI5W/jRL4rRaDZ8e+wS6LQGH9Ztt2EFB3m1ryfvak+i7FXrguXoz09Fokm+oXVLY07GtmwYqlV4BGyzPbFrKYF1BTKDDN1wzQOYtMzNDIk1+aoSnB4sxPoxqr6/lydxHdYLjr0uetm7daDcmKHEBJs3c999DxB4z1hmFDZ/zIH+qtqEonDy0BCJ0FvTTljEfCCABs9m0Fy4/3qCo7/mCXXu8Gdd69EAGt++5qZ88b43rB/Dq9rKT+VbmF1Rg6lnvwFyBGlYsW+lHw/ddv9K2UQ0eGLnrzD9ycvNfNmSX3ko0l6YioJfFl2X98yevvHV2pE70IJ3OUFND18Acq8hraEc3Wp4D1+uGFrDjtf0QPwrNfLDhFx1m+6DrcwoPvlnG5G6cNbdS6GUMyflVy4lGl/5GZPXTq5qI+aYbHWaGW2t3C7NoG0Lk2TQY2zSJIoFx/+1zPKXcI93j6VqHoEiXoFNx1TThmtw0bSs1McyWUjkPcnDLwJAxfMdB6NqVNqxU82m1wYEEyCL4ZbolEs7epDtiEAHc3zkNLtI02uIOCejTc+1agdjaZ4hufthr/q8HLo+qwAeWwiuWTC5GJO1xykhgpLCZFddHRfhR515UavDgFm35/AWydtVu/d+N78pAmRmiqrwSivcqxZ9JmnxgbJYFwqjpFPL46jPl3vpilqn+BP1cCe0NbyhCYQsMJdi/2VTudgAerpf0xE+kx7a6Ug9JiAvnx0a5ud6b4C+cuhOYRmaAPU7VEUZ3CZj3/OK04xEBNTRhHnGS2j4RWPPgcJep16Bvyxqpf0QLGv7PcP2X8XUCeE0T0OZpx450yHRy52mb9LQeCDvExkAKfXV75XakgWB520i9QP/DvmLIbkOnfZvznBPn6RZrup60uGG2vcFXVVBS2jumF/e79HXkarU1k5RV+A4AGU6nm3ksNOtOGVAetMibgBjt2Fcp8FK18NtK5BBKdbNKyaBv0M/XZGgoEiHKxRX2C0TFggUXtfIfU/WNmReSTwjHvegUIsEhZlZHxnSxX6zd8hGZEZZi5sxyKMGh/PSmK3ZbO22g3KCvnWMeKrPGLBpH/MuwsHRUHLCf7G/VTqQjZ+WkAWKbZotF/C6XyOJ1Rn1Os2kAtfTIAnDjftfkvQYv0wi4t6HSO/9kPFskSiuBO0rK/b1kLk2jkdkeh7vcH86sKleI9UMPFCec7ZcAJiwvA3VjTzilcLYFqTLfVM9kcZGCUAfx3F+1w6gzLNXMvWYibVE/RFYRqxDLSS44z6r+o0Nuhzk6FglhbjPbZw9LXLyIqix5Vxc5maYzECAVIzpyNp8vQ5PO3Jvl62swcecBlE2tiF5ziz1mPygGBTlJbThtakFwLgtK2Zdevg1W2RIEMLFaOEleRtfYLI5eO9Sz7VovMhMKJnaeqJaidqzcVlA4EmwXQczWoWxXUPNUgJPAVB4GNWrI8Y+DH0DzR9E/g8W0gmzUPvT2m0UirF1dlbo1+6lky6pmZWC0LTEWMLBJZ/1vWJzRLp+LrSn+IP++to6ilv3pjuVI/9o81Xuupu3xSWmLrdJv57t4FHYLmiH9goEkdVcA5PkUysKC0nl9gxPeubVZqz2Hu0xcf+xyg3p6R1r6FrnLm+0XYSRSuFmfTYCRfySmYSjHe2yNemVzl02Ue4a5+8WGjHwyvbiEDoOVeHQGIDei4i03ADUoUQ1fn5Lax8wa7mWb/w44r+dwSAG0irQLMlOjbU6lRicXWjHFRAyOobb7UHPEx8BuO7wD8ViHbsnk36Q1qXwj0rVhpxFZkfJnRGUikhA1g5if3f5UktkvGGCwtOXM9oYC+jzG65yAUhFBPoRCyPSuM/JXGr+ZdaMmpo9B2HJ1b4uf8FyZ3LHG8gOCi3F7FK/pj49e7iX8++pxXgNpclhZca7NMBEfSWH3Hw8oYDcqbTHwhsTTRX1aseRlexsxOP5HjixpG1rzoIU0p2E9Od8O667bD3OzJ+3cIcRN7aq2D9FSTPQ87BIVeFdvQ29BYAfwJJajubtYkD2FtBAOiGgssNXoJiXVdzPv01Y/HKIPfewjGaaXtP4i/MBrf0DwiP96bnL71BuMyALItvwsMiuugG2wlcXHwN09g8CzSv95CSiKDSMSgFbKSKJTAtPad0gMnHXXD8OwN6I1FPMj7ER+CtDBsXldfQcotwL1OD0WLgSaXqu8Kyvg+1cQV6ZNf6bSs2NKwZGMdmtCRrz2mjKzhNHA/T2f9XBIQ9P0qSBsSuujZGykUoGvvEKclDp90wsNbPRgiwLWI5CEylzqveQ6dV6f7nQO2lc7x/ZLfAj0NIiYlnH7Uaixx8lOVGvUhOY6snnyaMTj2YTzuMqSjb9qmeWpzNJcF2jLKOwT59KXtHAvh2ai7fVGyM80jtCyBGbpQk8JHF8V6dVFmum8IjE+8s8p6DJBI7u8YWqSIAnxFzR95D/AiLnmjmyEVHVXO0PPZYv31KXTIohDwlVP3sWOJK1/LsSAx0R4VlUJ9AloAABsj3EaApiVDecz4LxaWYiBbKNIGZHKe8ZaMo06uJ8SCJy6uygjJRxUkKW07oRmshiEft22HKrmUe/9j9zqvwIdUp8hoh+mNFJP2TJq01C/R7TiSi0Bd4RHCl1s354OK9LYkWbbT7p8bIk4YVTsi9NVuN9WENcFpoKW77nIwJZFFa21w7OtX9+u5C2GolXjA20N0S9yvKlq94iTlDgXpo+IMYMzkiDajti9woG6bPUqRQqWLAkxy99v3/eaYYv+XlKSwSnGuv8F64juJ3bEBXNgi092/TNJa8yJ41OCwr9AXbB/CHN+dcY3Et0Q2KTOdJDvwJ2PZpHYj9Yg4xJYHdD9nbwHdr/NACB0+Gybc6J46foWrXfWrVfcbc8eyRPcGJgUDSXWik385WpyLsJtPqNYdQyucXBZA6IB0HEiI6q3Chet7cWRSBLValAhkkJya2+bvDoJaD9ytsQuO7LoVQ6UBd66+qvFFgNsNe56pCCIlrnYGerwId5ED0FpDcjFwv/iUI4Mm5UXeFzIowmtNhh7uPUEIFd+Kzh6geuwSdMdTq8REhb3Kfuooe/mkleRjlCGQo3USyGFhrMbn9iK8VVKHEEBXRjnVfpqz08P0UlJPEk8RQAN8v/A7B7U0Wt9ICYhPu6/3bmRTQ/GsjYLCi4zqB2EdPT8U2DY3gLPRuKtHsQRXm7GhW3g+c/2w7aKUYgZUJlwrNk7KaDhLV0KZs4hjApf0EjmqrPupHj52pykMlNMFvQeZYBf3fFgV0qTfR6BBb3DmE25aN7CeKvTQ7v9zi644EttTpwZITTRJ0UonrGL/BiXwK3UPHyPNJKUoDPv68OYgUQlEI0+GBHLO8FEIeOB2vwpJ61/gEYOPJ/kce7e0z/wkfy5b22SospLW9KGtWCcpV8NzngHH/3Ef8/D8H/hXaOTGvXmnpB1xVHyEuwlvr2vp233KIfqCxezaSo970i9f+JQF1hN7P6z6pxrgLxyHtQx9OzRJAIsdP606nQ5SdYYYWtJlnnSxNKHC06u+loAVdpRi8sLMugfvTRJFM3zN9p5my6sALEwq5VtWCtC2fCH6ralFt2PNZaRpKsyxSmAr04VPloS8P6+D7IPaYFUEhmMM6sIglpFezTbl9IPeL6gZL6IR2Td+x3jc4Q50eadapDCSlvp3vQWpMOcjVaqNacgnH1wH8r97tbEabgK80B3XwRMwS2BOw7+24mNTdK3lkSrBST0N71h7dxTAP+Nz73ytaXCvj8VFr5LJrL6ld0mW4bVsVptcyNnL1Y2L+WKY+SGlS5Yxsj5fLvfy9hXZM9LpFHOz6KQqHUlRK0a+oBIGQKPiGNwBqa4pnKdWZ4xzHav6T7WwLamMSYztyu2CZJh8CKQPZcHJsNk20Nav7ZuInrhTOZLKb3dDUnEP9FN7L2TpwY67hErFUiWh19otAITOSKdRziJ/tNFvZ1ldgzXJMUiiUpLZryAxII9QeKp5QZxRzInBX2sCOZoLKo7XuvF3F2oqTI2g31zPtDGoXKmXTXvlDGhh/otKi/NCFGsuRSGGj4sHBEsNydgk2RTg1XjX8oOViRK6pHgQ1PBGpzEOB8Wm97U93opxT9wBddzDo0yqaCuEEH0jyJ8Cwj1Wx5OTab3oLk1yQCn45L9QfSZpL+QPdJrwSh+fV0EKXGcTg1dpO7GUIP8lU7HMtCrWXqf5CNKvaOEWiR8Mi1FZ9IfqBMvSJj7JBdybXI6oK1QDSqOyP5YcJs/OQU+WrnaG2ARBdIz53uUUHdxz5h595wk/peFR2+FZXY2CppCWnVyeso5UMSi/FqFEFPf3wd1Ur0gM24utARGB9SG/TrBE/TGdAd2RgDdvbGig50ujLPoJftREuVkR2puYGa4LfjlEFHu42WHukcwRHwPHv2pKy5mmq24NLiHnLCizydGoeO5qtvt47/6Sx2uxrgolbfOIXpJcjPSRPxKOrcZGBwyVzmOJ+/AuzOizW+la0VPIl0iUoZsoORG9gRyAunh4D2FTizYRjblV28ClaEyOs1P898dVFHW1PWQRic6o2zU9PgR1XnDkhI8GyaXZMgShngs7u+yrKfrd+dylJw5lFYindJ/dj4i9WxZjzDBFbl+Jnh6hFxgSr+rw8L4bZencNVULNOpzy4LUKT/7Is0HkJbdMZYyxbUXs1w2SV/N8c0zrZ/WmDxKwrfMK8uJPhzbuwFEyPSdvwi+BGhI2GjcTWzN5X27ZbJoFhdlxf5+xrVwJJLJAeKyu0Z279YHkojxES9YIwkluFc07iGigbCBh8cmwvS5ITWrOi1DWfqQhwbrqh8UxhX1MZTB330U9ZkjJbul0nM2QfgqZPfeanDcWKMjzbRZkAgFFuSY/JFjfIPFF/CpOd42RSKQ5eH0K39XFOMkK/eS8qVgrGYN6b+JZx3T5zrUa4Tc8NzUSdkDX8nRaIvlrBeI1Fq+RqnkuCD+THVGyynCX/ZS3HJUT6/YeI41CweBotCuts9nO/t1PotKejClV/7tfq1O8sSH8toKQGuLLWE5YVl5fXoYOWS9nZ+e870fqfT5VeAa8iTidjja0RqV5EtN0wz2g0ebueipXqJG/ZbGCkXyWLfxgR37SK4cM3bhOg6GsaGo3cnOmuBarZwDg3/irukg9SQzdjJhQXLVvt9MV2PmuqwUsJzNFGaDoXe+llGRiVoLgpZvUyEmwyRjyzn0XZyjl1/LM+ny4UvPy4XX6cHCFtq19WZQhDPcfJqW2dqdoybITJYT1XnO6co6o4PKdW7VztlyuMWBaTIOdyS+vzJTKyiKDbrijATvDoxjCqSEAaVM3JnGoPrIyc/jrqBFk6Z/uLoJbVwhvKk3eUM7M1hIqKhuGgXeEwW3gtzbVXrKw4cVvKq3EYnKPgqVOBGqAm2c86n6+yMO5VOidFRSJopPAhglOy5RTBhCo2Q2p1+H/px03wPXJlxEnQ0yUzjOvUX0DzvXHmTrcaY+oY4Qfv09IxBAy+3kYxpvjJV/4lqQh34FHgDXy7srIA1G3wxnNAWdxKCUtiYgJq86ONevJOQqzx8B/kK5UzUG+ijg/LcFTzbDAkZJsiVaT368jKLxvQNiMMefQWEtZs3E5DL5o2Ij/0uHHXn9Pbh+6DbgcnYKYBNuHuHNAgR/qMcjazcsxxq/bXsRmhpa8a7ZcIt03V01iEWk6Sgh93hvfuexe5W81+/Ac6ewQJ7aaVL64bs8dlgr2OetUHWe2rJGV54jzNpw0KdM9xN2B1fBDQLrA+2IIYHuPcSd5SLAwMcD8L5PDkTUtqzAgkVn1zJ8lLNGeO2PWDBd3F1fLnbZFpC0WCdnN9Z3j/yA63Xv0NhkR1rDPA7JDyFz0837HPU2bhPYYjejiKEllEilnOMVor7npXwkbpDNNWXkVsrsK+JbQRrhjeZyToTebg8OidZ87NtGIW3VCCW3DVlvdTM2Sqnb8xj6jiiDfDUZQ270tyjgPXlD+LVC77jNmmsun1tXiwbskddbjFKPoh6tFFUBT2TUqSwrb+BqxUornpz522hDg6BhagK3x3jBwzi4rl3T7Mw4dQcAt1tmIOUU18A9PIU6W4P0Quct6RKhjpmpF1OwoHoZENcau2GdpPc3501ATcirpck9qoCOK8EqI9UMLtekHn0k6LFIE+ax1NX96tOaBW57U5+a4iCki+U9d8qeAxVq3JwkEdHiEZDQ3zhQ9E+Oqa74riIG88Nci2mbwlhMBuzg6bjgqlkTn3JW/+dCWuoeuHVNQRY8HstQZz2BdU9OKTwMDoV6O1dPYMdMaxeFNussu3DueOMsMzuN4jMon2goUj6kIFnjNRw0FFn8hsAxBk9sOlZI+pdovDBdEcr77kAELEiwoxn0reM/cNumRTd1OZiRhuKmEO4Pc6NNInW87+1Y4P2kzB+hqLhkGQjYzSUMPkyTuOhqr3KphZNCJC9dPsOOpKCkPEQPjn6Bsd6vLn4RgAAPq8c0fk3h1aN2SPjkP7aGlYIEqLYh6EHSCdo13b7qKmltbSuqJdsjTEil7CvOfPXdLSCsuv3Ru+6rSslHMmdncuVG3JwJwCf3mrPWoOP70ZAqR1ZimlmryUf0DnbQb+2zFiGE15Er75uCLlsh7ErhCEgBzGrFlwFe2j8I0+KK9hAhiIL3PxlFR8GxvpCM6KGxxYSeS7j5yqKCch9He3NA1Tu05Tu/4spzP4QElyDmQa2s6pqk2nio/2Avh3hTHkekNKKp1JOZqzL04jOKr7aaaPlVxhP8qVr/vLir1CGdyBDswaKTSsTB9vOIRDIH7ixN+PKCOL6UcctaI8gAZErs2EWvrU/d83cMdbJmI3hpPOajiHrVVMPIJ6/ox0UeW7zsg7rpuot6tuBYCB5F6HhC5KR+hcILALlgckpCtVG3vet4rME6gGTpOI/sobiGU65yxOMPwofkgyuGOmcbhixrVdHMfGTm819VjaDuWJBdKvZhl9bt3WMKN756Ip8wM3F2w39y97FigtexAye+1xLj863ld1DZXc6xopv1I9WanoOnHmAnffpjiSycAaeTGoeTujt54Kpf8GNxN6ZjE9QAaO/z86W5Mdv0PgOK5i9NRgTymoo2Z0TtrGsVdr1qDu2/C72sWmWR2BwH+mM1uGsY0nmwhigax9RCAkaMPxCFJ5sOKyYl1FShS6EWV5Bv5FyZi7Q5M7DQantsY4MeKHihsLvNmxE54l5pnxee76TIdAKuLA4nj5bApUIcDfdYXauV9SjxU63mn52niGX4Ye6Ea/bvCR3reS8dPb9pG/xNczQUe9XGd8iXnBZ8T4rSa5BVqbbfT2zzLV+8fu8+NMn4HpCYElUnWK6ORxdS9pvpyF6DkgJMvBwSJ33raNFTwLebpT1PjNVleCiKAa2YIWOrQ+9hHrNPVE6GAv/eIibecP+cLyr1TnghyU4n0d+lpWMe7JYDnz1uXkhr1pXNh06Kaqnw7aV4gfXa9E5wJ0vVByoQ1+RyaEm8GQYTPbCVE+kHZFCunENKDKTomH6IAXduotzNSGEGC0dBofc6v5Z3goWdW8rSiYI04eW7ciXeOdduBCq9VlRkdhbeeBLH0JhjgL/D8pc1ffl0lH8TrNzHTFbZyCZ6Jw+/SdnGKZi/lVdRZXYx6GWmnUcyx7vHFYDLwqL7HOdl7dF/c+8juZFsBFRcUTT+Hmi5pWgjcEG+B5/Y7HZ3h5R+/8BZgPCA3mNyXhNjnkb6iaAhuXqkFH8ElRSiCPzf30+Lu5xAecppULz5XDfk+p13q383+lwzlQglDOpG4rD2e0iz7fiWCJF9SQeVe8g6DWJ0d3LNUAT7CLb0/WG9/Qj3EMj3YaOnLguZe2vRCLGzpknS6RcW+tYK2hxFmUwMQkkEv6rMN2S5XyqfrOlWNumuwo1iqaSG7FPdp5kGwI4BrbS6QYCeY7gLo7lFFgoNhTPD0jM8tIEBvrt6bI8tv0PARaIivEjXTP/Zss7IkLI6iWUwgjZplaafcTC58cairqZxZKsg/R+UxtlPp1lNj8EHcWMM8wukDGoAdt6PqBIEC3P7A/tYv9oFhztSornbHBO9ESE8SqWUbGYa08MwqhBSrBDdeXNMxkr+XAIa+Clxrik1sLA/6exK06IIYmrZ5GwbuvuqiFvkW1/SWGoIYh21tKJNA+k3oVnozIa0JOX37bFbk4wCKLTpBkRZtnMh1eKhd22nHeiYCpN0IRS2fFSvbHfXoiLzvvSDr5spr1zQ88jYgXREW8vvGaqcMPNYMP57+dWQhdmvnh6e6TBxrI7GRiCzo8hffp3Lq0EwMeh/aufKN0RDbRBZk2veSHvd3ipUQAerYWz6I4jkENDRzPwxeCRsCVbpX+1dg8eeTeRnA6mX3RsupLGEctSZE9uB2mbosDJ7sTrmUWuqwatjpjGJ23n6Ob8xA+SAh0WUOyuTeIVHHSY+XwmRdNq7nc6h3PRL0DWbOeKtklre9smuYcjwX9KIH5G7FgiIDX/za/aB4C9EvaAcjtLWbAwRKWjtavjo6UO3bKWY5+zkhiotVE+S30Trcliz/u/JwuDYBNZS55OrIc2RTqi14ZbBLslgagWU9KWHBYEWWLNOgwEJ486hTBMV3VkCGrltEZwW6Mn5Ugqj3WhASWC5o9iw5vIzICvp9wkn6BWs8lKCLLHPrT9edR2LZivH6y3U1612I//oj9npjfw42cqIhAoc/5U2uQdTbTMhuGdxrp+iguEJGKMyH3OU0wv+Ldso0n97yX8BQ/f/x/7hm7gspZTn8EeaaEiuJio1P0NnZ5iN9TlK4VKPmL1WchDnZBrZwTApGhjN0+2lb/J3q1uf+GTMbznOOTaUPAB9RF0a9yar1W2Xy2xTbINFa0j6HiiBOymouQVb4K17w+sgTNekoP+Kr0rgf8Z8g0syWHFTosOrI7zZMScjbHDjVYZoUPCh+hwlWTTtGBp6y0wdn9g6rT3auvrBnlzv1MPaiJM74tVFne9gt6nyxnHQbURJhy7Gb9ZVInm1HH7ABAqLnqUnNhZypt7AVXGg83k+coX8JfNcZ9lYQeJ8OAn7tVDD5MDZAGJp0z5V2R5wVL7D8DXxt51/0VYdVy06V+j7v5k3RK3BdoDypofI/F/Q+YPF6EIYWcdjwwUUJtOOwNQPJSHJFs6LDXSs1UcA4s72hOF9zmnmcOiii3msv8TKbm1wRafVQXb9I38YGA0uKAiU0PxboFEt0OohFeNaRCI2GRNpoevLOkbi39Nt8WoIKitTzpn4+1lbCd8ItZ1I3nuLDjmz9TjZ+pJRqF01rIeTHYC5wHf69uxhsoOL8gwnvx/N9G1YsYQnXAYgAUU0OprA3GVZRrevPltF6mg27yxgviItjf7aMejtlHXxaEqjAoK0DSBdd90/I3wjKl0A/3JVjpTBbLdo75pUGH+VfiK6R1gKBGcrkI1ZmRt5iRf156mRT6FU5Ymw3xXcT2q6ql8M3Wyo8Qk9hT9EfMFgD4/Ea22xDpiq0ZVmifUjrjncbEYpnR0Rc7Kiy8WJ5t4jFeOO+f1n73jGSe3E4BDp0h84oNjyvSs4v2vAhqMM3T1br5G59bcu8GruOXnIGYG/ArNJkBPS637kxoWSkuGvtBMG77GCttiyJWxU6R6N9Z5O2j5cmDn/OI5qSblPbniIydAkFO/fvLRVohM6AYiuR5R9dUgoG0WAjQASM8rasCsER0S1Y+fOkGYzFRjVULtKoaGTu0YOq/oPi8D3Llc8c/vZraQNtkhgWbPDE/tY4DKVWibtlcYbWjFqAaLOqs1zY7FKOBqYWNmqBDTBIBGMM1jInGGGwQpJTWhl3L4rv7chAZnsxQoDRouwkiKttbsafQ2NiNP8h/9np+Vmd3FDU9CS5+lcxB+79OKSmvieSXrV6hZyEwmChtHbu9qC2Ab4cDlRgi44lVv2wrQmCVZH+ZW8eXnJFwWF96PBrVnwaiK+lfJlhsFys7DYg1SCX3C4kzqcFZiYBDgyvHDkUiy6d+Ltf4xtMkda/3EKAmPqAPV3005NM84tj+TkB06yD4/xudp61p6q1sjb1sb5CeHxN7ZurceRufbqJiGV8R5+nl55cO4hl2JFi693lZzvDyjN6L+G6Nr4utMN57KblNKxo2tpCFpofRAe/UQI4xY9m+xNJDkMVb8zBHBPcrFEPmPsrVeJ+XYcYhG5SVJ2VUognvfKyQOsE+RUpEJHibiuh+2bUvvBHYOWErJKVZmGZvsz/6x+cg3Kz7+5KeYLNG+MFoHYYaeJzPHJHLyyneTJwz6vIcaukhbQ4JrwzmNq9bi27mdyQ8pngtUb0TsNMmHUSSHgiysNZMVZFU4BcfXaeR4xD0Da6pGBLitBCE1Yusn6IMtRNBqzkUh2QE4y+Ze6PnSyh2MUhkZZGmT7Maev8wLz7VQl3igK/afybrK1C3YMIBnDBDqlt6fM5dLMICs48qX2S7geOocHyVW12gkAUJeTlkoQcx7kFxCaaBhqx0v53t4xHS1xjzITb4ZrWtMSHtGFkks/kKPehYUKfvksas+rS/Qp3D8zTdaGPa2Ma6WOmhhoB/U1Sjfq+7+Pf94zNrRHUPmBR81w7melzqD4YX8CASyPzZWHrie3xccS8Fz9ip9wtuC94CLFw++AiB7D0dOZMSD4eQnXe5O84b2hr2ZIyv40mJA0zkQngSNMNCo3TpPvnvBCF9oHppF06j0mXKi5267F6IlSpgTeJveFVDzrAGehk//YJmCTG7bwD29N48827k8tDp+5sa+cThOAzCjPD3khHdUDaUavEhOKv/rlaF82HijIlSBrK912AAYD0+TBq0KYYAYjIazw3wl5g64X/O4WIcM7vWLbHB8Rvd8dy9riWaf3wzCni5zLZD+Xrsumvh65s4mDSfMJkiHx2Z8HXYYIBM0y7npGP/yijqsnPch+5OFzr/tvIIwKz33hMj56TRG10BZ2b7jBSnnpanRupVJOwaMEg9zHP3V9SMquX/TXMEadJAOcAQ14PEM5nKkiuG1IuTWi0JtbgYZkpQf5WDpbCRUxJCApc5I1cDnrDuMybFW4dFNV6iemp47fEG/tUtjs/TyCo6qNz74BizTO1Ew64D/58RdgZWrH18whitpPZmIKSkjBhufcGshIoDgRxczIqwQ/obz4bUu9E41iVkODe0zLaXtlKRGVKpsl658yG83+PQ6R82zRGXx9TGHAarJ9jifFabmn6sTTjfjwpg0n++aaYNFJb3qU4w0stq/NRYsAg+43/lzAhbP3QaVQWTS6MgW94bQKN6klz9OrekuKOUsL38JSuED611yCKeZQTnvYp8REtxQkgci+9txu6VmeDCdBiAk3GIYSmL1eVqDimtDgMO9SoZ0O5TRyVWZ3xJF/emOmkd2aCV6Ikphv9Qpq4udajboGrEBH4FJWU9s1RelvnYzQMCP8LT1iYsZhORIjUXFH1X8oRXRkbNm2Cx1mmsOsTF2BQVD4WWnuHaAWlj46XchlSyWPSm0UJpZjWVzxpAHy9Z0u+U/qNsbaHpFHRm4A41F/Jp22jdzlGen9VbHO019GPMl2hp09R8uINCcTwWRYFaG+zq8tB7jePGWIGVay0dANmezdy4E5ENIbE4SaxoFWpbvVsdf3buTEUXr9QMD1aTL9i1zAmQmvAm0rlAeMq2x00/gYzeOvmkHOsXoTl0p9yzmxD02JcubC0hzgHKG57JnyEDFKUgVtnLhyIin4Ab6veMO9xA+0pj3fz/MsYCaT3mYs74PHMmyWdiJCu3iUENkUK7C8cSlZRQwJvYCkc/WUZcfQ3/ApOlbYsJPhCwenjB+ovEeqe7qyXDnmO5e1lrGtgo/v4NC6DOpM1fmBTxVoAUbjwuRTg+JAj6xguq4UWmG13zzrsUui1s0NLiVu5pSU+cj3Is3orm441Rij+kjZF8/Le6lj2HbrMX4aRVMthQCFWvGvhj6lVD4riQ64S7OR8m2FvFstqFXy/sVM+WTHiSxZx8rbzgTTYTD2T4ErzM8N9C7qGwVlFgidHw6OsNvhTXVLSpQR6gAsnr9gEQ9W1n9pvi+URYXzSVvJ6+sbNDKHbgvLeNL8jrIhXTjdNFmoRfdGcnlDcWBzAz9xxXdv4RAEm3aYV4sGUTO7fax2rzHs9ClBKiRatGH+6VeThI2wENTxMy0lqD8MnCeSp9gI7k19c29AuhFkIzPo37qGStnBDDlMrmafvM3e64TZn23gD8I/aIM6g1lI+N/U7ZSG1DpMlQN8DY4N5DPesyu30oodAli3a8MO/0daIpcbX+9zf1i/8+P7u6SzWPYuc6MXx2xDtvrPPwqYgCYM8z/dJH4iC65Y20xjaj8qvfIEENT/ndu7EjBptJ3G2AlQqOilw2JW688ULIjiLy7AwMXk02hotLwyJyKDW5tEPLTd5s9aN6yJiLEVRJAmKNKDvpVfcnbho1T7KKiXVfBlvt8Ss2Rl8g/J9xCt2mIWi7iAF8LHvoFJa7qZymEhUOe6yl8n1dpBCx7Lww/Ovm8l/3WBczVSX1dUIAr4QLZWEtv+SARivcnKC/Tval+clzknKhUtfIdk02I0w9XvDsv8TLZ8luF0XjBoyfM/gm5x2w7LetEiMkSyq/WvS/8h3fC3ReWRavLNm/rk5ZKxPItZlm/QnoP+OttYxa+yczjlZ7xynew+wM1v8t45etYP4Qa9fnET2bzEZ8e6Dth8KwFIGqR3WNO4W71Ktfql244gsYUdRYV5vzZ4wlXcKdWKMW14leuMXXBOtCCemD7UCLhNa5KSK6GA5YZ+blWYH/pm9aJDI3dhe5ZY5MMqNrrBo2mSLWiNvLA0+QPQlLx4qiaYuzbj+eITttkPHzc6P7tVJiD99DK6bPjuDxARK2VHgqhZ4rxL9o9+5SqyzlSJcQ1iKtkArtKAnlrHY/Z2KwNNSVZHcg4lo3HWYwovVAVMoLHPcbA2LZal63jv+WtAXLfYbdFeqa5k1vcLBs1KeuL/FYNyoM3AKIBLuZJ023uQs5+He2AW0oGSqcO52Epca8Ovu7Y4Cxekvyifq8a9qV43DH9R3fkLSJ8NEWGg5cFtSKWHJCd0IEP9MsigTa5kEH+wLJ/J42b2jEvu0NDeUallmUA1JdJ4Xo4Dmgg8Zgs2V/Ad9b0AXrgr9A2BVOsptxxZsvDr0IIWDBRAtSpw40cfwwr82WzEQyDHmC0Q4oorrSnSTX8tNiSG/meF7CUbMwbPUAL/f30hZ+cIH3A3d51b3DWA+QxKg+thSrMFvEYDDvq1IPbXXXAxudvvDQIUsrLepPggVylgtWpiJq8PAkuBGm/0f9RxRxK3iEbsRthUFWpQPyRL6cREOXHz3ODSq4npQIU7ysU38BrxQJ71KvtMRArZE+BiQKOkRMI7vlXP+oI94q4qfEjFYlKtJKVLZp4pzbUTQq+EzqiXqSgzSKq8JXgxd2MM8/duT9Fzh9G+gyipdSO1KUEQEU6NWenYoAsLaIOwRZ8CcQi/YNGiZa/5nNoGyKdp3KLR09Bac4g/GFJ7CD0aytUax2N77nALI+J0dZU4hp0jICzGM1LQFUemP1rKDVD0r1FnPobHOkKthYf6weNnbabqYfDrXxF5vqHQ3IFNw5jTK5KCbanDRfZf9nwmTPLSWTjVSJt+NgUUKucfkLvXid6HAsON3z97CE5qxSw2+u4TsAyAWdHbrbnTCJm8jb18zTly0Ro1vgl3lfKBJL9MPj/TOlQnV31yl8sve2QF435GxLt6ny9cr56PDI5RGh6jeIPwhlaY1Sqbgf6Di42lK6wQ3lnCEqObQ6pH66mcrCrIGYtMklwQzBBAO3f1f9SUG2EKRL6GcIfN+BaGKuw6HMPnEcpZ9IY8L+g3ObnNoZgCIVfQDvpyr+vntLtPID7WoQIEVv5okUB3rbXPWBY7HNDOcTO4+/IoqXiEXrTcNxNTA4BkYt9wqkLXEjVoXo0p8hYIXbieE7lmeX544Mp25+TKy/kbn4K5lZRiXfucQjZO5uoUOcEsVDymPAneUTD3GAgZex61eIKxZD3BQXFies0jkoxQqdBx/cVrFRGK3VfHXtiMxGs70lFhER6MJ3FLizCaq6U+2BEw+/JxuFXS9ekHTKsFG3253FkyWk4/3JP+PPeALVyWj0X7kG3wjzLKD/CMqg6NCYS2eRUtelOeogop+HhG0J0e43nh2Nuf8HC5nl9Lhqf/zBF1q0zx9s4r43h9kvlOIPEutCfOHJJJ+Ude49Hv/m5xYZDNNv4//PQzeHWM5mntZ6fiDJ2P2uJy9ZNO+NC8xBZLkH/hu0kCU8P1c319MYBAENggCqAQ++N5Uam9HW7v7aWPvJ70CO/YXoW56w2gJgz30C4fCUolgPrgWa5qlBSLsuMT2wp/zwhVNniiwJx60ElHIHfax5KggtWpNK0rLIdTctJZqhj2nWKHQTquEZ7UY+K1cKTNA+bcwsKVmuUPCaLjS1PVwAky0sRQt+3fSuvHrfURpeg23kZtyLv7jHhcg5FkvT1Kr7pSvyIhl4F5Ngw4R5VED6e+B5zNcv8x69GpbLZbdk9Fb+JK450xOpO+Dqgh1zEhW1ZElJWuGq6sodYCIq7vEUid91t2r88zBoC8ocHflQoWKrbvDjvvSvq9ua+bgRZLMdCvTjyo8eoBs2iC5qJN8aZk4YzgV1fUkmtWhji2GwcN4q070Yy1/ccR4I8cuek8d7zMJBFb9K9/euZm1Em9mlSe4ak92tSarqoDhlYLsQNTuWggfbeM+jWzos4L48yuWJQ979v2zevjy48mExpg3W1zU5SXhQNVandDIEltav9+zHfcXAOIHAVQ4gMrL/F8LKw66rnpvWxnBCA1LuQ9FKngXOXr2UAQp9zKGiULYGQPrBCxqwBISr15px2fsTZb7T824dZjiM3PwLm+12SI2EXcoSuB5QrYMeAj8NIaX4MH1qdDsdLZV5s2cVI+QlraHy1/Rxv1rXx1a7jGi9FhpOhUzFu+ke8W4280QSPI8vShGbPcTJzxCA8AbzP7xNl+OgEFZDQFsNRY5bqsY7kR1VoRI09lxskqvWQ5z7S2CrobQyc7O2HlqZ1rt7iIQwR9CrgEaCZPqDGcVq6v0PJrUN14WpzoI1YY+v3idvJcn0scs39iIp2MHMiHumejg04iZiCc0MTTCJCABisj3rRFSQTT+kDBoIKDoFMIuublQ2Zgp9jc/dK39D2kHXX+fVoNe5DHUqNLN/Dzccz61QBWj8+q/Ynsq17o6k+uLMAB9/r5k2QQw+Zhi3lusF3Qnw+Hi54Anzq6vlx9KN4brFR93WNnc+pv0dyvfr287xW/bQZBFNGoUdvX3R6Eo+t9hxacaBTsBpSWYpfvOHzvYsfiCtZhMNahZWZuv/Jslt6vUhEuI0QdRlJMkGtEvtHMG9n3PmWb5g30OR1r2daf4Qx13gopDhRAh/uFVGLJLRJwBCFZQrOUsSOi1uS9gc3sldGGyjeuLwlOFiuzbFpA9twDO4gEcJ9mA4YdegbHhrZwPVL+MtCFYuCmkZk8LNJEgUIWuUEhU9wFdHOk1DXvomBtNgD19EQIng2wdTBH1XFgFiFlpnC2E6AjwAwDvHpAjAV0EWvH+4bWfeZwrUbPoywwJMGRrcfmHxqRdvwobnwSyNMLuSejapA7lr2gas1Gd4VfoLqp2ER2hWobMRRYCRSvfkxqZHn1QHw8Hf3GvfXlB512OXso8Az9JeVcoKwJgGyUDDB4wERZhr3VJSKjiRmy+o+xLAibQz2yEphmY+aKoyGoR9z6zLyYcKUm5zNqfjVALDmmZKU08cThtTtJseCIkX3FtI7TeTiZBvsGPLrCBT7TE3K567SMl+92JZYqjPySAVpnoHyjlRLm9C4i9sDUJpS/D5yYWTG2cdQjuhvh9YTWJ+TQ65OAlWDa7ReJmZ4TSAUH3JKmdiLoQ613p4W7o9ph2ufSLwsrkwrfeTLIg/TuStMYXhW1nbHmOnyGx4ES3iCXWlYv4ebYBlY8/ISEgC8C2CC/5+hZEr93nr3C4quj8jBUb03G8Fk+M4GP486WW57W5qhEF/ZpO9n5bQYbdkkWPG41s4ohRCpl5n2CoEjeIjqnhUgbq4JlsnYNzpOlgJ0GXMBr6lLUgpg8QzOp2lDYb4KTwww2KG0FRkP15j4+gmiEAgu8Yl0dQe3S5r8w55JORasg2GQ58sPUc2GYc98npui7vJ7h9dbEUI7cKjlpH3j10RddaTZgWG6rGxDrv8/XZweOrl56Ct2qGkJzOFzXm7yQ1J/IR1/2RfY59tKLvPblt/3C8fKqjIj4cCTGLnIf8vzTW0r5f3F/bEljwfcWotKp2z2p+g5/iR/po7siWv5xWetaNETqsv3c5AsBYbiKqgqh8xSl+l1dmjMlju8Gx4kkxz2sSNWotmoOvo3f5JiwjCtFusmLEgQmsqKW0hXS3yLL6E8J5yxy3wU1mSG7bDPVBFbRfAC7CF8X3AkcYEruySDP8KUEqs9XXlCRfnHKZep4oPz9hPFDWZYbHbrznLgNnw6eB7xTzytigCUNGRZuklePmG8hF74QOVkA9l2H6unT/qkwC/iZ7DkDZ6zwX5h87p52nAx4+bk2H/ZNgflSPXC7YTWCo66H78XFn0EYiP680r4TxB2ANav1dqB5EHM0k4fkn3moKsl1Y4+EKrGu2kK7x7y8cU6p99juNoG4nd2b8Tz6surtRaKMhWtptAaP2fIB/WCPhgjeEXmSsr3KucVj+xft5I5SiI8G9a+l23IbrPXUI2DKcPEu0DW8xuDOPyl8rWKW8Ek+Pmd3M9Z1fNK6z5ZTBLBVFuL4gEkVHw5BcJVOJd8EuWU5Gl52V/mJKLF0Yg7YQX+I9qZ5CAeJZxk49twwwVsG49mGSFJU+ZtmxSlTa4DoM7Gwg5tiM3KxZBYWecnpmnRpdbf/+U/+k1umJNQCwBznBTI0Cb2gJy6yDDmBgZ1AIUCzP/xVUYaG0XMkdou3k/T4EMKC0uF/LdFhGTlG0KoIw4GRO2BQwM7VKiZwGLLbgBYk8TpgTP/MPibIMF04yB8XfZ8930gLv1qrgTMHUNLwOkaS+eViSp8pb61PQzCj+S8BlE3iX0SDQRTxcaLxfDBLHN+jyh0vSG2nqlnYOzJ8wY9kz4n8MqSkOs8ksuUybe6+/kxw5jsljkZtpLKz3lI5cHwtB26cAkaLN5Cu9STICwZArrseQJixvect5mlOTOVhw/yTBqgl2jFe1tOQFTKkCyqVtCk6sJ+hjn7DTwx7C2qOucNw2Az6i04BKc0Twd1CfnXIBiUU3hUSxl8MFs0jjY9M4v2aSxU8m9Jtbgo5TIyvybbyafcOrk5/OVVwCfCyaEW4UCFobIU5USRMWVA5NPkLuVsVVw9ZxTxWQAY0BReVxV11reOPKQFMlReqlZdfpNYEEWz6hVyzNs+nqaccbhnAWy5L2844SislOnlx9TqnuJlZ4TJM6JwqFi9ht94uNOpZXGQPMpwKCYVmW/7XrlZrUUBxegsgbzhBYmRFsB3XbOu6nEDwe0TMDrw2vBJujgdti+OOh2z6gzjhCr3XRen0k9BYN0sU7BjwsmaDitBOmw4qgHWN6BhB4tf1ZL+4iephYBwG6Sw3Oh8j2ZemQDMEyCsQ7WFbKRz/BT9Lm7EFipljAsq3XhwBH65KMiVtCN3g3QHXsTwWTeeZ0IeJpCxg9z0B05nsgb50wpQQUE1eOKSyaHi7ODOJJeJOYtCS0XAvuTtRaByw2R0mLISrkg+3eBzPFk9OsPLRvq9FkNUGl4vz+VRkFxfFrdkZ12BWcnwqFMydXdTCqFfjRodw3TAM0LFGTXR0VjqEqsQfM523wOW6I/+KO3cOFWWH8dSh0aLjex8VgbBW99hgpsoQUQ5PkLmu26A125ZK1lM0okl5d0bpf3rb26oHAAR2MIScOlgo+k6zOJR3XkvERnMHs6c3kfCSg0qBAuSv3g3f3Kc4C8pUarjybSwlt1EbEsQuWVZqYLkPpMRF3DJN7Zq+OG5bZgzpYgV7nAvPbIAN5Fp+uCrtaVnWNYG/aEf3SChLPve77PbT88RB3UMapnIdHZCljAtr1TdUdzvBpguD0J1Sr3Is/RwXo2ACh+C1ZxpiHgU4zINgJ0XXX1+fmrPNmbxW+g9BBquaV3kgYv6+9jvyPsyWImkK81+75/FmCtfMjJBvKqOtEyfMOVuxVqC5jCzD88Wcjj3QypriAYNQNvvVFMQQpAzxIvcD4OAhl0rFtUBYsNHCHQISBnezxx0ZQJ/Cp25AfEwLtBpYgbTRpbJVBQXsGRwre1XC+K5DVo+pOJr9/6lfEr0bJdOWV+m4r7HTQzU4GafymiY8lFJ1wjo3H5k10nErzc2zjCMJTJ78XM+HtXnPD9rI7/EIS+3xv2t25BqTb6VzwqCbbfp1iGBl7yW7OjMtYVPrTUKcWCSYZzID7TddkY4ZpzXSEAdsFWmlWFT3FI9J3izLnFrqbdHiDRRXyQceEc4DVsYPrKaeZ+f11psAG15C7d25gAcnZlvCtFpIxUGnZLp+aPtF/xWkrXiwPICw6y4MBDv0qvcpMsiEfvjxy4nx0FkWnU6+56sIftFzL4iXFzhi9Z5xIYS+Ch1XZa5AYN/4ig6qicdqAM5q8IgZ9mvxULIIppBDGSZ0tpVBL4sVZVkZs0I562M4SEi5I1lxQOkWUJktBWc6crroswJU25Yl7jRKqfrm0u/bD3awGkNkNc4ezQmcaMdxqhUMZX+kqaaePped/5/JN2zabhUI5Xr6IcoT9xPtTjx+QnRYsWKBTlhUDQ5jf2ZHugJ/jyWa/I4URFxOPpIbV7pRitp2c5aOyAsW6aGuTzy+MSVrl/TCHlGlhJI2a56kJSmvZ8eFw8F6+1tbFS25CQC4J85uph4iYlvmvloVWnBoPV4xz+bqzIUUwE/E0Hr7ehc87Hovgh768k/gtN1uJc8lOjeyiYRdD53Pn4S2SFB8KQtnisYOnW9bWYoW8x9A4bR+59YmolCOFz0GF3K2SJYnmVt2iCTK1pqMgw3c+zWekn4OFJ+TvSHNTN4B3uh1PZGYM4ZWMaeRQK8rVY0wjGxh1YYk8jQBaWLaYErn51Acu7eAu2iiGeQmkebKpFaNuc9f0SS2TxPdzD/2ZXhLSPO6hs2TCVHT2ke/isclYcQe4wjoChaZLFwrBTkYvHvaZdC7JiV5/wGsCKHVkhnv8mOqGlyJ5cifYUp8q9agvUdFhxy8L8/ybg8F5czuiM8Oos17CRdSsOE9DQUAXkGVKRKdEOl5AcicBXkCO5lmZ4BymA3QHXN4/w8WckLgRds7c9v8uHQXPAdJqDJxqeTsz3iBoMU99hDBM7W7hGmZX6jEzjTroG4hGnhaYt2RR1JnMSSF2Yk3z0wJ0ZWab4Q=",self.location).href,"树")},2e3);class O3{call(n){return wn(this,null,function*(){let i=te.MxCpp.App.getCurrentMxCAD();if(n.name){const h=i.getDatabase().getBlockTable().get(n.name);if(!h||!h.isValid())return;let p=new te.McDbBlockReference;p.blockTableRecordId=h;let _=p.getBoundingBox(),s=0;if(_.ret){let M=_.maxPt.distanceTo(_.minPt);M>1e-5&&(s=i.getMxDrawObject().screenCoordLong2Doc(100)/M,p.setScale(s))}p.position=new te.McGePoint3d(n.pos[0],n.pos[1]),i.drawEntity(p),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 N3(){wa.regist(F3),wa.regist(O3)}class U3{call(n){return wn(this,null,function*(){let i=te.MxCpp.getCurrentMxCAD();console.log(n),i.newFile();let l;const h=typeof n.isMText=="undefined"?!1:n.isMText,p=()=>{const s=new te.McDbMText;return s.textHeight=n.textSize||100,s.location=n.textPos||new te.McGePoint3d,s.contents=n.textString||"",s},_=()=>{const s=new te.McDbText;return s.height=n.textSize||100,s.textString=n.textString||"",s.position=n.textPos||new te.McGePoint3d,s};if(!n.textString){const s=new te.MxCADUiPrString;s.setMessage("请输入文字");const M=yield s.go();if(!M)return;n.textString=M}if(n.textPos)n.textPos=ur(n.textPos);else{const s=new te.MxCADUiPrPoint;s.clearLastInputPoint(),s.setMessage("请指定文字位置");const M=yield s.go();if(s.setUserDraw((T,C)=>{if(n.textPos=T,h){const E=p();C.drawMcDbEntity(E)}else{const E=_();C.drawMcDbEntity(E)}}),!M)return;n.textPos=M}if(!n.textSize){const s=new te.MxCADUiPrPoint;s.clearLastInputPoint(),s.setMessage("通过线段长度确定文字高度");const M=yield s.go();if(M){s.setUserDraw((C,E)=>{if(n.textSize=M.distanceTo(C),h){const L=p();E.drawMcDbEntity(L)}else{const L=_();E.drawMcDbEntity(L)}});const T=yield s.go();T&&(n.textSize=T.distanceTo(M))}}if(h){const s=p();l=i.drawEntity(s)}else{const s=_();l=i.drawEntity(s)}_s(l.getMcDbEntity(),n),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},...gs]}}}function V3(){wa.regist(U3)}class G3{call(n){if(console.log(n),n.isWithdraw){typeof n.withdrawNum!="number"&&(n.withdrawNum=1);for(let i=0;i{i.operation_code=n,te.MxCpp.Ai.registTool(i)}),te.MxCpp.Ai.reloadTools({operation_code:n})}}let wa=new W3;function j3(){return wn(this,null,function*(){let e=new te.MxCADUiPrString;e.setMessage(` human:`);let n=yield e.go();n&&te.MxCpp.Ai.chat_tool(n)})}function q3(){return wn(this,null,function*(){let e=new te.MxCADUiPrString;e.setMessage(` 输入 server_operate_code:`);let n=yield e.go();n&&wa.regist_server(n)})}function Z3(){tt.MxFun.addCommand("Mx_Ai",j3),tt.MxFun.addCommand("Mx_AiRegistServer",q3),M3(),E3(),A3(),L3(),B3(),N3(),V3(),H3(),R3()}function X3(e,n){let i=40,l=new te.MxCADResbuf;l.AddString("电杆层",0),l.AddString("INSERT",5020);let h=new te.MxCADSelectionSet;h.crossingSelect(e.x-i,e.y-i,e.x+i,e.y+i,l);let p=[];if(h.forEach(_=>{let s=_.getMcDbEntity();if(s){let M=s;n[M.getObjectID().id]&&p.push({dist:M.position.distanceTo(e),blk:n[M.getObjectID().id]})}}),p.length!=0)return p.sort((_,s)=>_.dist-s.dist),p[0].dist{let T=M.getMcDbEntity();if(T){let C=T,E=C.endPoint,L=C.startPoint.distanceTo(h.position);if(L>C.endPoint.distanceTo(h.position)&&(L=C.endPoint.distanceTo(h.position),E=C.startPoint),L{let p=h.getMcDbEntity();if(p){let _=p,s=_.getAllAttribute(),M={};s.forEach(T=>{let C=T.getMcDbEntity();C.tag=="杆号"&&(M.tag=C.textString)}),M.tag&&(M.handle=_.getHandle(),i[h.id]={ref:_,tag:M.tag},console.log(M))}});let l={};Object.keys(i).forEach(h=>{Y3(h,i,l)}),Object.keys(l).forEach(h=>{console.log(l[h])})})}function J3(){tt.MxFun.addCommand("MxTest_UserGetData",$3)}function K3(){J3()}class cd extends te.McDbCustomEntity{create(n){throw new Error("Method not implemented.")}getTypeName(){throw new Error("Method not implemented.")}dwgInFields(n){throw new Error("Method not implemented.")}dwgOutFields(n){throw new Error("Method not implemented.")}worldDraw(n){throw new Error("Method not implemented.")}}class ud extends cd{constructor(n){super(n),this.pt=new te.McGePoint3d}create(n){return new ud(n)}getTypeName(){return"McDbGisPoint"}dwgInFields(n){return this.pt=n.readPoint("pt").val,!0}dwgOutFields(n){return n.writePoint("pt",this.pt),!0}moveGripPointsAt(n,i,l,h){this.assertWrite(),n==0&&(this.pt.x+=i,this.pt.y+=l,this.pt.z+=h)}getGripPoints(){let n=new te.McGePoint3dArray;return n.append(this.pt),n}worldDraw(n){n.drawEntity(new te.McDbPoint(this.pt))}setPoint(n){this.assertWrite(),this.pt=n.clone()}getPoint(){return this.pt}}class hd extends cd{constructor(n){super(n),this.pts=[]}create(n){return new hd(n)}getTypeName(){return"McDbGisMultiPoint"}dwgInFields(n){return this.pts=n.readPoints("pts").val,!0}dwgOutFields(n){return n.writePoints("pts",this.pts),!0}moveGripPointsAt(n,i,l,h){this.assertWrite(),n>=0&&n{n.append(i)}),n}worldDraw(n){this.pts.forEach(i=>{n.drawEntity(new te.McDbPoint(i))})}setPoint(n,i){this.assertWrite(),n>=0&&n=0&&n=0&&n{n.append(i)}),n}worldDraw(n){let i=new te.McDbPolyline;this.pts.forEach(l=>{i.addVertexAt(l)}),n.drawEntity(i)}setPoint(n,i){this.assertWrite(),n>=0&&n=0&&n{n.writePoints("ptss_"+l,i)}),!0}moveGripPointsAt(n,i,l,h){this.assertWrite();let p=0;for(let _=0;_{i.forEach(l=>{n.append(l)})}),n}worldDraw(n){for(let i=0;i{h.addVertexAt(p)}),n.drawEntity(h)}}addPoints(n){this.ptss.push(n)}removeAllPoint(){this.ptss=[]}getPointsCount(){return this.ptss.length}getPoints(n){return n>=0&&n{n.writePoints("ptss_"+l,i)}),!0}moveGripPointsAt(n,i,l,h){this.assertWrite();let p=0;for(let _=0;_{i.forEach(l=>{n.append(l)})}),n}worldDraw(n){let i=new te.McDbHatch;for(let l=0;l2&&i.appendLoop(new te.McGePoint3dArray(h))}i.numLoops>0&&n.drawEntity(i)}addPoints(n){this.ptss.push(n)}removeAllPoint(){this.ptss=[]}getPointsCount(){return this.ptss.length}getPoints(n){return n>=0&&n0&&e.drawEntity(i),l.forEach(h=>{h.erase()})})}function tL(){return wn(this,null,function*(){let e=te.MxCpp.getCurrentMxCAD(),n=new te.MxCADUiPrPoint;n.setMessage("点取一个点坐标");let i=new dd,l=[],h;for(;;){h&&(n.setBasePt(h),n.setUseBasePt(!0)),n.setDynamicInputType(tt.DynamicInputType.kXYCoordInput);let p=yield n.go();if(p){if(i.addPoint(p),h){let _=new te.McDbLine;_.startPoint=h,_.endPoint=p,l.push(e.drawEntity(_))}h=p}else break}i.getPointCount()>1&&e.drawEntity(i),l.forEach(p=>{p.erase()})})}function nL(){return wn(this,null,function*(){let e=te.MxCpp.getCurrentMxCAD(),n=new te.MxCADUiPrPoint;n.setMessage("点取一个点坐标"),n.setKeyWords("[下一段线(N)]");let i=new pd,l=[],h=[],p;for(;;){p?n.setBasePt(p):n.setUseBasePt(!1),n.setDynamicInputType(tt.DynamicInputType.kXYCoordInput);let _=yield n.go();if(n.isKeyWordPicked("N"))l.length>1&&i.addPoints(l),l=[],p=void 0;else if(_){if(l.push(_),p){let s=new te.McDbLine;s.startPoint=p,s.endPoint=_,h.push(e.drawEntity(s))}p=_}else break}l.length>1&&i.addPoints(l),i.getPointsCount()>0&&e.drawEntity(i),h.forEach(_=>{_.erase()})})}function iL(){return wn(this,null,function*(){let e=te.MxCpp.getCurrentMxCAD(),n=new te.MxCADUiPrPoint;n.setMessage("点取一个点坐标");let i=new fd,l=[],h=[],p;for(;;){p?n.setBasePt(p):n.setUseBasePt(!1),l.length>2&&n.setKeyWords("[闭合(C)/退出(E)]"),n.setDynamicInputType(tt.DynamicInputType.kXYCoordInput);let _=yield n.go();if(n.isKeyWordPicked("C")){let s=new te.McDbLine;s.startPoint=l[0],s.endPoint=l[l.length-1],h.push(e.drawEntity(s)),l.length>2&&i.addPoints(l),l=[],p=void 0}else{if(n.isKeyWordPicked("E"))break;if(_){if(l.push(_),p){let s=new te.McDbLine;s.startPoint=p,s.endPoint=_,h.push(e.drawEntity(s))}p=_}else break}}l.length>2&&i.addPoints(l),i.getPointsCount()>0&&e.drawEntity(i),h.forEach(_=>{_.erase()})})}function rL(){let e=new te.MxCADSelectionSet,n=new te.MxCADResbuf;n.AddMcDbEntityTypes("McDbCustomEntity"),e.allSelect(n);let i={type:"FeatureCollection",features:[]};e.forEach(l=>{let h=l.getMcDbEntity();if(h){if(h instanceof ud){let _=h.getPoint(),s={type:"Feature",properties:{},geometry:{type:"Point",coordinates:[_.x,_.y,_.z]}};i.features.push(s)}else if(h instanceof hd){let p=h,_=[],s=p.getPointCount();for(let T=0;T(c=1))return c;for(;om?o=d:c=d,d=.5*(c-o)+o}return d},C.prototype.solve=function(a,t){return this.sampleCurveY(this.solveCurveX(a,t))};var E=L;function L(a,t){this.x=a,this.y=t}L.prototype={clone:function(){return new L(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,t){return this.clone()._rotateAround(a,t)},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 t=a.x-this.x,o=a.y-this.y;return t*t+o*o},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,t){return Math.atan2(this.x*t-this.y*a,this.x*a+this.y*t)},_matMult:function(a){var t=a[2]*this.x+a[3]*this.y;return this.x=a[0]*this.x+a[1]*this.y,this.y=t,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 t=Math.cos(a),o=Math.sin(a),c=o*this.x+t*this.y;return this.x=t*this.x-o*this.y,this.y=c,this},_rotateAround:function(a,t){var o=Math.cos(a),c=Math.sin(a),d=t.y+c*(this.x-t.x)+o*(this.y-t.y);return this.x=t.x+o*(this.x-t.x)-c*(this.y-t.y),this.y=d,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},L.convert=function(a){return a instanceof L?a:Array.isArray(a)?new L(a[0],a[1]):a};var I=typeof self!="undefined"?self:{};const B=Math.PI/180,O=180/Math.PI;function U(a){return a*B}function q(a){return a*O}const ee=[[0,0],[1,0],[1,1],[0,1]];function he(a){if(a<=0)return 0;if(a>=1)return 1;const t=a*a,o=t*a;return 4*(a<.5?o:3*(a-t)+o-.75)}function Ce(a,t,o,c){const d=new T(a,t,o,c);return function(m){return d.solve(m)}}const K=Ce(.25,.1,.25,1);function ie(a,t,o){return Math.min(o,Math.max(t,a))}function ue(a,t,o){return(o=ie((o-a)/(t-a),0,1))*o*(3-2*o)}function ae(a,t,o){const c=o-t,d=((a-t)%c+c)%c+t;return d===t?o:d}function le(a,t,o){if(!a.length)return o(null,[]);let c=a.length;const d=new Array(a.length);let m=null;a.forEach((y,v)=>{t(y,(w,A)=>{w&&(m=w),d[v]=A,--c==0&&o(m,d)})})}function De(a){const t=[];for(const o in a)t.push(a[o]);return t}function ye(a,...t){for(const o of t)for(const c in o)a[c]=o[c];return a}let se=1;function Ue(){return se++}function Oe(){return function a(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,a)}()}function We(a){return a<=1?1:Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function st(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 St(a,t){a.forEach(o=>{t[o]&&(t[o]=t[o].bind(t))})}function gt(a,t){return a.indexOf(t,a.length-t.length)!==-1}function At(a,t,o){const c={};for(const d in a)c[d]=t.call(o||this,a[d],d,a);return c}function Dt(a,t,o){const c={};for(const d in a)t.call(o||this,a[d],d,a)&&(c[d]=a[d]);return c}function Ot(a){return Array.isArray(a)?a.map(Ot):typeof a=="object"&&a?At(a,Ot):a}const Pe={};function ge(a){Pe[a]||(typeof console!="undefined"&&console.warn(a),Pe[a]=!0)}function Ve(a,t,o){return(o.y-a.y)*(t.x-a.x)>(t.y-a.y)*(o.x-a.x)}function Ne(a){let t=0;for(let o,c,d=0,m=a.length,y=m-1;d@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(o,c,d,m)=>{const y=d||m;return t[c]=!y||y.toLowerCase(),""}),t["max-age"]){const o=parseInt(t["max-age"],10);isNaN(o)?delete t["max-age"]:t["max-age"]=o}return t}let ce,we,Me,pe,Be=null;function $e(a){if(Be==null){const t=a.navigator?a.navigator.userAgent:null;Be=!!a.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Be}function ot(a){try{const t=I[a];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(t){return!1}}const bt={now:()=>Me!==void 0?Me:I.performance.now(),setNow(a){Me=a},restoreNow(){Me=void 0},frame(a){const t=I.requestAnimationFrame(a);return{cancel:()=>I.cancelAnimationFrame(t)}},getImageData(a,t=0){const{width:o,height:c}=a;pe||(pe=I.document.createElement("canvas"));const d=pe.getContext("2d");if(!d)throw new Error("failed to create canvas 2d context");return(o>pe.width||c>pe.height)&&(pe.width=o,pe.height=c),d.clearRect(-t,-t,o+2*t,c+2*t),d.drawImage(a,0,0,o,c),d.getImageData(-t,-t,o+2*t,c+2*t)},resolveURL:a=>(ce||(ce=I.document.createElement("a")),ce.href=a,ce.href),get devicePixelRatio(){return I.devicePixelRatio},get prefersReducedMotion(){return!!I.matchMedia&&(we==null&&(we=I.matchMedia("(prefers-reduced-motion: reduce)")),we.matches)}};let Vt;const oe={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(Vt==null){const a=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{Vt=process.env.API_URL_REGEX!=null?new RegExp(process.env.API_URL_REGEX):a}catch(t){Vt=a}}return Vt},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},ve={supported:!1,testSupport:function(a){!xn&&mt&&(un?tn(a):xt=a)}};let xt,mt,xn=!1,un=!1;function tn(a){const t=a.createTexture();a.bindTexture(a.TEXTURE_2D,t);try{if(a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,mt),a.isContextLost())return;ve.supported=!0}catch(o){}a.deleteTexture(t),xn=!0}I.document&&(mt=I.document.createElement("img"),mt.onload=function(){xt&&tn(xt),xt=null,un=!0},mt.onerror=function(){xn=!0,xt=null},mt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const dn="01",bn="NO_ACCESS_TOKEN";function ln(a){return a.indexOf("mapbox:")===0}function Gt(a){return oe.API_URL_REGEX.test(a)}const on=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Zt(a){const t=a.match(on);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function qe(a){const t=a.params.length?`?${a.params.join("&")}`:"";return`${a.protocol}://${a.authority}${a.path}${t}`}function Nt(a){if(!a)return null;const t=a.split(".");if(!t||t.length!==3)return null;try{return JSON.parse(decodeURIComponent(I.atob(t[1]).split("").map(o=>"%"+("00"+o.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(o){return null}}class Qt{constructor(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const o=Nt(oe.ACCESS_TOKEN);let c="";return c=o&&o.u?I.btoa(encodeURIComponent(o.u).replace(/%([0-9A-F]{2})/g,(d,m)=>String.fromCharCode(+("0x"+m)))):oe.ACCESS_TOKEN||"",t?`mapbox.eventData.${t}:${c}`:`mapbox.eventData:${c}`}fetchEventData(){const t=ot("localStorage"),o=this.getStorageKey(),c=this.getStorageKey("uuid");if(t)try{const d=I.localStorage.getItem(o);d&&(this.eventData=JSON.parse(d));const m=I.localStorage.getItem(c);m&&(this.anonId=m)}catch(d){ge("Unable to read from LocalStorage")}}saveEventData(){const t=ot("localStorage"),o=this.getStorageKey(),c=this.getStorageKey("uuid");if(t)try{I.localStorage.setItem(c,this.anonId),Object.keys(this.eventData).length>=1&&I.localStorage.setItem(o,JSON.stringify(this.eventData))}catch(d){ge("Unable to write to LocalStorage")}}processRequests(t){}postEvent(t,o,c,d){if(!oe.EVENTS_URL)return;const m=Zt(oe.EVENTS_URL);m.params.push(`access_token=${d||oe.ACCESS_TOKEN||""}`);const y={event:this.type,created:new Date(t).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:M,skuId:dn,userId:this.anonId},v=o?ye(y,o):y,w={url:qe(m),headers:{"Content-Type":"text/plain"},body:JSON.stringify([v])};this.pendingRequest=Ge(w,A=>{this.pendingRequest=null,c(A),this.saveEventData(),this.processRequests(d)})}queueRequest(t,o){this.queue.push(t),this.processRequests(o)}}const Pn=new class extends Qt{constructor(a){super("appUserTurnstile"),this._customAccessToken=a}postTurnstileEvent(a,t){oe.EVENTS_URL&&oe.ACCESS_TOKEN&&Array.isArray(a)&&a.some(o=>ln(o)||Gt(o))&&this.queueRequest(Date.now(),t)}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=Nt(oe.ACCESS_TOKEN),o=t?t.u:oe.ACCESS_TOKEN;let c=o!==this.eventData.tokenU;st(this.anonId)||(this.anonId=Oe(),c=!0);const d=this.queue.shift();if(this.eventData.lastSuccess){const m=new Date(this.eventData.lastSuccess),y=new Date(d),v=(d-this.eventData.lastSuccess)/864e5;c=c||v>=1||v<-1||m.getDate()!==y.getDate()}else c=!0;c?this.postEvent(d,{"enabled.telemetry":!1},m=>{m||(this.eventData.lastSuccess=d,this.eventData.tokenU=o)},a):this.processRequests()}},pn=Pn.postTurnstileEvent.bind(Pn),On=new class extends Qt{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(a,t,o,c){this.skuToken=t,this.errorCb=c,oe.EVENTS_URL&&(o||oe.ACCESS_TOKEN?this.queueRequest({id:a,timestamp:Date.now()},o):this.errorCb(new Error(bn)))}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;const{id:t,timestamp:o}=this.queue.shift();t&&this.success[t]||(this.anonId||this.fetchEventData(),st(this.anonId)||(this.anonId=Oe()),this.postEvent(o,{skuToken:this.skuToken},c=>{c?this.errorCb(c):t&&(this.success[t]=!0)},a))}},Gn=On.postMapLoadEvent.bind(On),Zn=new class extends Qt{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(a,t,o,c){if(!oe.API_URL||!oe.SESSION_PATH)return;const d=Zt(oe.API_URL+oe.SESSION_PATH);d.params.push(`sku=${t||""}`),d.params.push(`access_token=${c||oe.ACCESS_TOKEN||""}`);const m={url:qe(d),headers:{"Content-Type":"text/plain"}};this.pendingRequest=Je(m,y=>{this.pendingRequest=null,o(y),this.saveEventData(),this.processRequests(c)})}getSessionAPI(a,t,o,c){this.skuToken=t,this.errorCb=c,oe.SESSION_PATH&&oe.API_URL&&(o||oe.ACCESS_TOKEN?this.queueRequest({id:a,timestamp:Date.now()},o):this.errorCb(new Error(bn)))}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;const{id:t,timestamp:o}=this.queue.shift();t&&this.success[t]||this.getSession(o,this.skuToken,c=>{c?this.errorCb(c):t&&(this.success[t]=!0)},a)}},Wi=Zn.getSessionAPI.bind(Zn),Nn=new Set,Ci="mapbox-tiles";let ei,Ki,yi=500,Hr=50;function ki(){I.caches&&!ei&&(ei=I.caches.open(Ci))}function Wr(a){const t=a.indexOf("?");return t<0?a:a.slice(0,t)}let Sr=1/0;const _e={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};typeof Object.freeze=="function"&&Object.freeze(_e);class G extends Error{constructor(t,o,c){o===401&&Gt(c)&&(t+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(t),this.status=o,this.url=c}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Z=Ie()?()=>self.worker&&self.worker.referrer:()=>(I.location.protocol==="blob:"?I.parent:I).location.href,de=function(a,t){if(!(/^file:/.test(o=a.url)||/^file:/.test(Z())&&!/^\w+:/.test(o))){if(I.fetch&&I.Request&&I.AbortController&&I.Request.prototype.hasOwnProperty("signal"))return function(c,d){const m=new I.AbortController,y=new I.Request(c.url,{method:c.method||"GET",body:c.body,credentials:c.credentials,headers:c.headers,referrer:Z(),signal:m.signal});let v=!1,w=!1;const A=(D=y.url).indexOf("sku=")>0&&Gt(D);var D;c.type==="json"&&y.headers.set("Accept","application/json");const R=(V,j,$)=>{if(w)return;if(V&&V.message!=="SecurityError"&&ge(V),j&&$)return k(j);const ne=Date.now();I.fetch(y).then(me=>{if(me.ok){const ke=A?me.clone():null;return k(me,ke,ne)}return d(new G(me.statusText,me.status,c.url))}).catch(me=>{me.code!==20&&d(new Error(me.message))})},k=(V,j,$)=>{(c.type==="arrayBuffer"?V.arrayBuffer():c.type==="json"?V.json():V.text()).then(ne=>{w||(j&&$&&function(me,ke,He){if(ki(),!ei)return;const Ze={status:ke.status,statusText:ke.statusText,headers:new I.Headers};ke.headers.forEach((lt,ht)=>Ze.headers.set(ht,lt));const Xe=it(ke.headers.get("Cache-Control")||"");if(Xe["no-store"])return;Xe["max-age"]&&Ze.headers.set("Expires",new Date(He+1e3*Xe["max-age"]).toUTCString());const Ye=Ze.headers.get("Expires");Ye&&(new Date(Ye).getTime()-He<42e4||function(lt,ht){if(Ki===void 0)try{new Response(new ReadableStream),Ki=!0}catch(vt){Ki=!1}Ki?ht(lt.body):lt.blob().then(ht)}(ke,lt=>{const ht=new I.Response(lt,Ze);ki(),ei&&ei.then(vt=>vt.put(Wr(me.url),ht)).catch(vt=>ge(vt.message))}))}(y,j,$),v=!0,d(null,ne,V.headers.get("Cache-Control"),V.headers.get("Expires")))}).catch(ne=>{w||d(new Error(ne.message))})};return A?function(V,j){if(ki(),!ei)return j(null);const $=Wr(V.url);ei.then(ne=>{ne.match($).then(me=>{const ke=function(He){if(!He)return!1;const Ze=new Date(He.headers.get("Expires")||0),Xe=it(He.headers.get("Cache-Control")||"");return Ze>Date.now()&&!Xe["no-cache"]}(me);ne.delete($),ke&&ne.put($,me.clone()),j(null,me,ke)}).catch(j)}).catch(j)}(y,R):R(null,null),{cancel:()=>{w=!0,v||m.abort()}}}(a,t);if(Ie()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",a,t,void 0,!0)}var o;return function(c,d){const m=new I.XMLHttpRequest;m.open(c.method||"GET",c.url,!0),c.type==="arrayBuffer"&&(m.responseType="arraybuffer");for(const y in c.headers)m.setRequestHeader(y,c.headers[y]);return c.type==="json"&&(m.responseType="text",m.setRequestHeader("Accept","application/json")),m.withCredentials=c.credentials==="include",m.onerror=()=>{d(new Error(m.statusText))},m.onload=()=>{if((m.status>=200&&m.status<300||m.status===0)&&m.response!==null){let y=m.response;if(c.type==="json")try{y=JSON.parse(m.response)}catch(v){return d(v)}d(null,y,m.getResponseHeader("Cache-Control"),m.getResponseHeader("Expires"))}else d(new G(m.statusText,m.status,c.url))},m.send(c.body),{cancel:()=>m.abort()}}(a,t)},Le=function(a,t){return de(ye(a,{type:"arrayBuffer"}),t)},Ge=function(a,t){return de(ye(a,{method:"POST"}),t)},Je=function(a,t){return de(ye(a,{method:"GET"}),t)};function Ke(a){const t=I.document.createElement("a");return t.href=a,t.protocol===I.document.location.protocol&&t.host===I.document.location.host}const je="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let nt,yt;nt=[],yt=0;const Ut=function(a,t){if(ve.supported&&(a.headers||(a.headers={}),a.headers.accept="image/webp,*/*"),yt>=oe.MAX_PARALLEL_IMAGE_REQUESTS){const m={requestParameters:a,callback:t,cancelled:!1,cancel(){this.cancelled=!0}};return nt.push(m),m}yt++;let o=!1;const c=()=>{if(!o)for(o=!0,yt--;nt.length&&yt{c(),m?t(m):y&&(I.createImageBitmap?function(A,D){const R=new I.Blob([new Uint8Array(A)],{type:"image/png"});I.createImageBitmap(R).then(k=>{D(null,k)}).catch(k=>{D(new Error(`Could not load image because of ${k.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(y,(A,D)=>t(A,D,v,w)):function(A,D){const R=new I.Image,k=I.URL;R.onload=()=>{D(null,R),k.revokeObjectURL(R.src),R.onload=null,I.requestAnimationFrame(()=>{R.src=je})},R.onerror=()=>D(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 V=new I.Blob([new Uint8Array(A)],{type:"image/png"});R.src=A.byteLength?k.createObjectURL(V):je}(y,(A,D)=>t(A,D,v,w)))});return{cancel:()=>{d.cancel(),c()}}};function Et(a,t,o){o[a]&&o[a].indexOf(t)!==-1||(o[a]=o[a]||[],o[a].push(t))}function _n(a,t,o){if(o&&o[a]){const c=o[a].indexOf(t);c!==-1&&o[a].splice(c,1)}}class W{constructor(t,o={}){ye(this,o),this.type=t}}class Y extends W{constructor(t,o={}){super("error",ye({error:t},o))}}class ze{on(t,o){return this._listeners=this._listeners||{},Et(t,o,this._listeners),this}off(t,o){return _n(t,o,this._listeners),_n(t,o,this._oneTimeListeners),this}once(t,o){return o?(this._oneTimeListeners=this._oneTimeListeners||{},Et(t,o,this._oneTimeListeners),this):new Promise(c=>this.once(t,c))}fire(t,o){typeof t=="string"&&(t=new W(t,o||{}));const c=t.type;if(this.listens(c)){t.target=this;const d=this._listeners&&this._listeners[c]?this._listeners[c].slice():[];for(const v of d)v.call(this,t);const m=this._oneTimeListeners&&this._oneTimeListeners[c]?this._oneTimeListeners[c].slice():[];for(const v of m)_n(c,v,this._oneTimeListeners),v.call(this,t);const y=this._eventedParent;y&&(ye(t,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),y.fire(t))}else t instanceof Y&&console.error(t.error);return this}listens(t){return!!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,o){return this._eventedParent=t,this._eventedParentData=o,this}}var xe=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 Mt(a,...t){for(const o of t)for(const c in o)a[c]=o[c];return a}function _t(a){return a instanceof Number||a instanceof String||a instanceof Boolean?a.valueOf():a}function Ft(a){if(Array.isArray(a))return a.map(Ft);if(a instanceof Object&&!(a instanceof Number||a instanceof String||a instanceof Boolean)){const t={};for(const o in a)t[o]=Ft(a[o]);return t}return _t(a)}class nn extends Error{constructor(t,o){super(o),this.message=o,this.key=t}}class Ln{constructor(t,o=[]){this.parent=t,this.bindings={};for(const[c,d]of o)this.bindings[c]=d}concat(t){return new Ln(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const Dn={kind:"null"},wt={kind:"number"},cn={kind:"string"},$t={kind:"boolean"},fn={kind:"color"},Tn={kind:"object"},Sn={kind:"value"},di={kind:"collator"},Ar={kind:"formatted"},ai={kind:"resolvedImage"};function li(a,t){return{kind:"array",itemType:a,N:t}}function oi(a){if(a.kind==="array"){const t=oi(a.itemType);return typeof a.N=="number"?`array<${t}, ${a.N}>`:a.itemType.kind==="value"?"array":`array<${t}>`}return a.kind}const ys=[Dn,wt,cn,$t,fn,Ar,Tn,li(Sn),ai];function za(a,t){if(t.kind==="error")return null;if(a.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!za(a.itemType,t.itemType))&&(typeof a.N!="number"||a.N===t.N))return null}else{if(a.kind===t.kind)return null;if(a.kind==="value"){for(const o of ys)if(!za(o,t))return null}}return`Expected ${oi(a)} but found ${oi(t)} instead.`}function iu(a,t){return t.some(o=>o.kind===a.kind)}function vs(a,t){return t.some(o=>o==="null"?a===null:o==="array"?Array.isArray(a):o==="object"?a&&!Array.isArray(a)&&typeof a=="object":o===typeof a)}function ru(a){var t={exports:{}};return a(t,t.exports),t.exports}var xd=ru(function(a,t){var o={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 c(v){return(v=Math.round(v))<0?0:v>255?255:v}function d(v){return c(v[v.length-1]==="%"?parseFloat(v)/100*255:parseInt(v))}function m(v){return(w=v[v.length-1]==="%"?parseFloat(v)/100:parseFloat(v))<0?0:w>1?1:w;var w}function y(v,w,A){return A<0?A+=1:A>1&&(A-=1),6*A<1?v+(w-v)*A*6:2*A<1?w:3*A<2?v+(w-v)*(2/3-A)*6:v}try{t.parseCSSColor=function(v){var w,A=v.replace(/ /g,"").toLowerCase();if(A in o)return o[A].slice();if(A[0]==="#")return A.length===4?(w=parseInt(A.substr(1),16))>=0&&w<=4095?[(3840&w)>>4|(3840&w)>>8,240&w|(240&w)>>4,15&w|(15&w)<<4,1]:null:A.length===7&&(w=parseInt(A.substr(1),16))>=0&&w<=16777215?[(16711680&w)>>16,(65280&w)>>8,255&w,1]:null;var D=A.indexOf("("),R=A.indexOf(")");if(D!==-1&&R+1===A.length){var k=A.substr(0,D),V=A.substr(D+1,R-(D+1)).split(","),j=1;switch(k){case"rgba":if(V.length!==4)return null;j=m(V.pop());case"rgb":return V.length!==3?null:[d(V[0]),d(V[1]),d(V[2]),j];case"hsla":if(V.length!==4)return null;j=m(V.pop());case"hsl":if(V.length!==3)return null;var $=(parseFloat(V[0])%360+360)%360/360,ne=m(V[1]),me=m(V[2]),ke=me<=.5?me*(ne+1):me+ne-me*ne,He=2*me-ke;return[c(255*y(He,ke,$+1/3)),c(255*y(He,ke,$)),c(255*y(He,ke,$-1/3)),j];default:return null}}return null}}catch(v){}});class Xn{constructor(t,o,c,d=1){this.r=t,this.g=o,this.b=c,this.a=d}static parse(t){if(!t)return;if(t instanceof Xn)return t;if(typeof t!="string")return;const o=xd.parseCSSColor(t);return o?new Xn(o[0]/255*o[3],o[1]/255*o[3],o[2]/255*o[3],o[3]):void 0}toString(){const[t,o,c,d]=this.toArray();return`rgba(${Math.round(t)},${Math.round(o)},${Math.round(c)},${d})`}toArray(){const{r:t,g:o,b:c,a:d}=this;return d===0?[0,0,0,0]:[255*t/d,255*o/d,255*c/d,d]}}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 xs{constructor(t,o,c){this.sensitivity=t?o?"variant":"case":o?"accent":"base",this.locale=c,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,o){return this.collator.compare(t,o)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class bd{constructor(t,o,c,d,m){this.text=t.normalize?t.normalize():t,this.image=o,this.scale=c,this.fontStack=d,this.textColor=m}}class Bi{constructor(t){this.sections=t}static fromString(t){return new Bi([new bd(t,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(t=>t.text.length!==0||t.image&&t.image.name.length!==0)}static factory(t){return t instanceof Bi?t:Bi.fromString(t)}toString(){return this.sections.length===0?"":this.sections.map(t=>t.text).join("")}serialize(){const t=["format"];for(const o of this.sections){if(o.image){t.push(["image",o.image.name]);continue}t.push(o.text);const c={};o.fontStack&&(c["text-font"]=["literal",o.fontStack.split(",")]),o.scale&&(c["font-scale"]=o.scale),o.textColor&&(c["text-color"]=["rgba"].concat(o.textColor.toArray())),t.push(c)}return t}}class Cr{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Cr({name:t,available:!1}):null}serialize(){return["image",this.name]}}function da(a,t,o,c){return typeof a=="number"&&a>=0&&a<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof o=="number"&&o>=0&&o<=255?c===void 0||typeof c=="number"&&c>=0&&c<=1?null:`Invalid rgba value [${[a,t,o,c].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof c=="number"?[a,t,o,c]:[a,t,o]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function au(a){if(a===null||typeof a=="string"||typeof a=="boolean"||typeof a=="number"||a instanceof Xn||a instanceof xs||a instanceof Bi||a instanceof Cr)return!0;if(Array.isArray(a)){for(const t of a)if(!au(t))return!1;return!0}if(typeof a=="object"){for(const t in a)if(!au(a[t]))return!1;return!0}return!1}function Pi(a){if(a===null)return Dn;if(typeof a=="string")return cn;if(typeof a=="boolean")return $t;if(typeof a=="number")return wt;if(a instanceof Xn)return fn;if(a instanceof xs)return di;if(a instanceof Bi)return Ar;if(a instanceof Cr)return ai;if(Array.isArray(a)){const t=a.length;let o;for(const c of a){const d=Pi(c);if(o){if(o===d)continue;o=Sn;break}o=d}return li(o||Sn,t)}return Tn}function ka(a){const t=typeof a;return a===null?"":t==="string"||t==="number"||t==="boolean"?String(a):a instanceof Xn||a instanceof Bi||a instanceof Cr?a.toString():JSON.stringify(a)}class Ba{constructor(t,o){this.type=t,this.value=o}static parse(t,o){if(t.length!==2)return o.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!au(t[1]))return o.error("invalid value");const c=t[1];let d=Pi(c);const m=o.expectedType;return d.kind!=="array"||d.N!==0||!m||m.kind!=="array"||typeof m.N=="number"&&m.N!==0||(d=m),new Ba(d,c)}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 Bi?this.value.serialize():this.value}}class Qi{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const wd={string:cn,number:wt,boolean:$t,object:Tn};class pa{constructor(t,o){this.type=t,this.args=o}static parse(t,o){if(t.length<2)return o.error("Expected at least one argument.");let c,d=1;const m=t[0];if(m==="array"){let v,w;if(t.length>2){const A=t[1];if(typeof A!="string"||!(A in wd)||A==="object")return o.error('The item type argument of "array" must be one of string, number, boolean',1);v=wd[A],d++}else v=Sn;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return o.error('The length argument to "array" must be a positive integer literal',2);w=t[2],d++}c=li(v,w)}else c=wd[m];const y=[];for(;dt.outputDefined())}serialize(){const t=this.type,o=[t.kind];if(t.kind==="array"){const c=t.itemType;if(c.kind==="string"||c.kind==="number"||c.kind==="boolean"){o.push(c.kind);const d=t.N;(typeof d=="number"||this.args.length>1)&&o.push(d)}}return o.concat(this.args.map(c=>c.serialize()))}}class bs{constructor(t){this.type=Ar,this.sections=t}static parse(t,o){if(t.length<2)return o.error("Expected at least one argument.");const c=t[1];if(!Array.isArray(c)&&typeof c=="object")return o.error("First argument must be an image or text section.");const d=[];let m=!1;for(let y=1;y<=t.length-1;++y){const v=t[y];if(m&&typeof v=="object"&&!Array.isArray(v)){m=!1;let w=null;if(v["font-scale"]&&(w=o.parse(v["font-scale"],1,wt),!w))return null;let A=null;if(v["text-font"]&&(A=o.parse(v["text-font"],1,li(cn)),!A))return null;let D=null;if(v["text-color"]&&(D=o.parse(v["text-color"],1,fn),!D))return null;const R=d[d.length-1];R.scale=w,R.font=A,R.textColor=D}else{const w=o.parse(t[y],1,Sn);if(!w)return null;const A=w.type.kind;if(A!=="string"&&A!=="value"&&A!=="null"&&A!=="resolvedImage")return o.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");m=!0,d.push({content:w,scale:null,font:null,textColor:null})}}return new bs(d)}evaluate(t){return new Bi(this.sections.map(o=>{const c=o.content.evaluate(t);return Pi(c)===ai?new bd("",c,null,null,null):new bd(ka(c),null,o.scale?o.scale.evaluate(t):null,o.font?o.font.evaluate(t).join(","):null,o.textColor?o.textColor.evaluate(t):null)}))}eachChild(t){for(const o of this.sections)t(o.content),o.scale&&t(o.scale),o.font&&t(o.font),o.textColor&&t(o.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const o of this.sections){t.push(o.content.serialize());const c={};o.scale&&(c["font-scale"]=o.scale.serialize()),o.font&&(c["text-font"]=o.font.serialize()),o.textColor&&(c["text-color"]=o.textColor.serialize()),t.push(c)}return t}}class ws{constructor(t){this.type=ai,this.input=t}static parse(t,o){if(t.length!==2)return o.error("Expected two arguments.");const c=o.parse(t[1],1,cn);return c?new ws(c):o.error("No image name provided.")}evaluate(t){const o=this.input.evaluate(t),c=Cr.fromString(o);return c&&t.availableImages&&(c.available=t.availableImages.indexOf(o)>-1),c}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Dy={"to-boolean":$t,"to-color":fn,"to-number":wt,"to-string":cn};class fa{constructor(t,o){this.type=t,this.args=o}static parse(t,o){if(t.length<2)return o.error("Expected at least one argument.");const c=t[0];if((c==="to-boolean"||c==="to-string")&&t.length!==2)return o.error("Expected one argument.");const d=Dy[c],m=[];for(let y=1;y4?`Invalid rbga value ${JSON.stringify(o)}: expected an array containing either three or four numeric values.`:da(o[0],o[1],o[2],o[3]),!c))return new Xn(o[0]/255,o[1]/255,o[2]/255,o[3])}throw new Qi(c||`Could not parse color from value '${typeof o=="string"?o:String(JSON.stringify(o))}'`)}if(this.type.kind==="number"){let o=null;for(const c of this.args){if(o=c.evaluate(t),o===null)return 0;const d=Number(o);if(!isNaN(d))return d}throw new Qi(`Could not convert ${JSON.stringify(o)} to number.`)}return this.type.kind==="formatted"?Bi.fromString(ka(this.args[0].evaluate(t))):this.type.kind==="resolvedImage"?Cr.fromString(ka(this.args[0].evaluate(t))):ka(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}serialize(){if(this.type.kind==="formatted")return new bs([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new ws(this.args[0]).serialize();const t=[`to-${this.type.kind}`];return this.eachChild(o=>{t.push(o.serialize())}),t}}const Iy=["Unknown","Point","LineString","Polygon"];class gm{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"?Iy[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 t=this.featureDistanceData.center,o=this.featureDistanceData.scale,{x:c,y:d}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(c*o-t[0])+this.featureDistanceData.bearing[1]*(d*o-t[1])}return 0}parseColor(t){let o=this._parseColorCache[t];return o||(o=this._parseColorCache[t]=Xn.parse(t)),o}}class Pr{constructor(t,o,c,d){this.name=t,this.type=o,this._evaluate=c,this.args=d}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(t=>t.serialize()))}static parse(t,o){const c=t[0],d=Pr.definitions[c];if(!d)return o.error(`Unknown expression "${c}". If you wanted a literal array, use ["literal", [...]].`,0);const m=Array.isArray(d)?d[0]:d.type,y=Array.isArray(d)?[[d[1],d[2]]]:d.overloads,v=y.filter(([A])=>!Array.isArray(A)||A.length===t.length-1);let w=null;for(const[A,D]of v){w=new ro(o.registry,o.path,null,o.scope);const R=[];let k=!1;for(let V=1;V{return k=R,Array.isArray(k)?`(${k.map(oi).join(", ")})`:`(${oi(k.type)}...)`;var k}).join(" | "),D=[];for(let R=1;R=t[2]||a[1]<=t[1]||a[3]>=t[3])}function _m(a,t){const o=(180+a[0])/360,c=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a[1]*Math.PI/360)))/360,d=Math.pow(2,t.z);return[Math.round(o*d*io),Math.round(c*d*io)]}function lu(a,t,o){const c=a[0]-t[0],d=a[1]-t[1],m=a[0]-o[0],y=a[1]-o[1];return c*y-m*d==0&&c*m<=0&&d*y<=0}function Td(a,t){let o=!1;for(let y=0,v=t.length;y(c=a)[1]!=(m=w[A+1])[1]>c[1]&&c[0]<(m[0]-d[0])*(c[1]-d[1])/(m[1]-d[1])+d[0]&&(o=!o)}}var c,d,m;return o}function Ry(a,t){for(let o=0;o0&&v<0||y<0&&v>0}function zy(a,t,o){for(const A of o)for(let D=0;Do[2]){const d=.5*c;let m=a[0]-o[0]>d?-c:o[0]-a[0]>d?c:0;m===0&&(m=a[0]-o[2]>d?-c:o[2]-a[0]>d?c:0),a[0]+=m}Md(t,a)}function bm(a,t,o,c){const d=Math.pow(2,c.z)*io,m=[c.x*io,c.y*io],y=[];if(!a)return y;for(const v of a)for(const w of v){const A=[w.x+m[0],w.y+m[1]];xm(A,t,o,d),y.push(A)}return y}function wm(a,t,o,c){const d=Math.pow(2,c.z)*io,m=[c.x*io,c.y*io],y=[];if(!a)return y;for(const w of a){const A=[];for(const D of w){const R=[D.x+m[0],D.y+m[1]];Md(t,R),A.push(R)}y.push(A)}if(t[2]-t[0]<=d/2){(v=t)[0]=v[1]=1/0,v[2]=v[3]=-1/0;for(const w of y)for(const A of w)xm(A,t,o,d)}var v;return y}class No{constructor(t,o){this.type=$t,this.geojson=t,this.geometries=o}static parse(t,o){if(t.length!==2)return o.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(au(t[1])){const c=t[1];if(c.type==="FeatureCollection")for(let d=0;d{t&&!gr(o)&&(t=!1)}),t}function yl(a){if(a instanceof Pr&&a.name==="feature-state")return!1;let t=!0;return a.eachChild(o=>{t&&!yl(o)&&(t=!1)}),t}function vl(a,t){if(a instanceof Pr&&t.indexOf(a.name)>=0)return!1;let o=!0;return a.eachChild(c=>{o&&!vl(c,t)&&(o=!1)}),o}class Uo{constructor(t,o){this.type=o.type,this.name=t,this.boundExpression=o}static parse(t,o){if(t.length!==2||typeof t[1]!="string")return o.error("'var' expression requires exactly one string literal argument.");const c=t[1];return o.scope.has(c)?new Uo(c,o.scope.get(c)):o.error(`Unknown variable "${c}". Make sure "${c}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class ro{constructor(t,o=[],c,d=new Ln,m=[]){this.registry=t,this.path=o,this.key=o.map(y=>`[${y}]`).join(""),this.scope=d,this.errors=m,this.expectedType=c}parse(t,o,c,d,m={}){return o?this.concat(o,c,d)._parse(t,m):this._parse(t,m)}_parse(t,o){function c(d,m,y){return y==="assert"?new pa(m,[d]):y==="coerce"?new fa(m,[d]):d}if(t!==null&&typeof t!="string"&&typeof t!="boolean"&&typeof t!="number"||(t=["literal",t]),Array.isArray(t)){if(t.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const d=t[0];if(typeof d!="string")return this.error(`Expression name must be a string, but found ${typeof d} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const m=this.registry[d];if(m){let y=m.parse(t,this);if(!y)return null;if(this.expectedType){const v=this.expectedType,w=y.type;if(v.kind!=="string"&&v.kind!=="number"&&v.kind!=="boolean"&&v.kind!=="object"&&v.kind!=="array"||w.kind!=="value")if(v.kind!=="color"&&v.kind!=="formatted"&&v.kind!=="resolvedImage"||w.kind!=="value"&&w.kind!=="string"){if(this.checkSubtype(v,w))return null}else y=c(y,v,o.typeAnnotation||"coerce");else y=c(y,v,o.typeAnnotation||"assert")}if(!(y instanceof Ba)&&y.type.kind!=="resolvedImage"&&uu(y)){const v=new gm;try{y=new Ba(y.type,y.evaluate(v))}catch(w){return this.error(w.message),null}}return y}return this.error(`Unknown expression "${d}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(t===void 0?"'undefined' value invalid. Use null instead.":typeof t=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,o,c){const d=typeof t=="number"?this.path.concat(t):this.path,m=c?this.scope.concat(c):this.scope;return new ro(this.registry,d,o||null,m,this.errors)}error(t,...o){const c=`${this.key}${o.map(d=>`[${d}]`).join("")}`;this.errors.push(new nn(c,t))}checkSubtype(t,o){const c=za(t,o);return c&&this.error(c),c}}function uu(a){if(a instanceof Uo)return uu(a.boundExpression);if(a instanceof Pr&&a.name==="error"||a instanceof ou||a instanceof No)return!1;const t=a instanceof fa||a instanceof pa;let o=!0;return a.eachChild(c=>{o=t?o&&uu(c):o&&c instanceof Ba}),!!o&&gr(a)&&vl(a,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function xl(a,t){const o=a.length-1;let c,d,m=0,y=o,v=0;for(;m<=y;)if(v=Math.floor((m+y)/2),c=a[v],d=a[v+1],c<=t){if(v===o||tt))throw new Qi("Input is not a number.");y=v-1}return 0}class bl{constructor(t,o,c){this.type=t,this.input=o,this.labels=[],this.outputs=[];for(const[d,m]of c)this.labels.push(d),this.outputs.push(m)}static parse(t,o){if(t.length-1<4)return o.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return o.error("Expected an even number of arguments.");const c=o.parse(t[1],1,wt);if(!c)return null;const d=[];let m=null;o.expectedType&&o.expectedType.kind!=="value"&&(m=o.expectedType);for(let y=1;y=v)return o.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',A);const R=o.parse(w,D,m);if(!R)return null;m=m||R.type,d.push([v,R])}return new bl(m,c,d)}evaluate(t){const o=this.labels,c=this.outputs;if(o.length===1)return c[0].evaluate(t);const d=this.input.evaluate(t);if(d<=o[0])return c[0].evaluate(t);const m=o.length;return d>=o[m-1]?c[m-1].evaluate(t):c[xl(o,d)].evaluate(t)}eachChild(t){t(this.input);for(const o of this.outputs)t(o)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}serialize(){const t=["step",this.input.serialize()];for(let o=0;o0&&t.push(this.labels[o]),t.push(this.outputs[o].serialize());return t}}function gn(a,t,o){return a*(1-o)+t*o}var hu=Object.freeze({__proto__:null,number:gn,color:function(a,t,o){return new Xn(gn(a.r,t.r,o),gn(a.g,t.g,o),gn(a.b,t.b,o),gn(a.a,t.a,o))},array:function(a,t,o){return a.map((c,d)=>gn(c,t[d],o))}});const Mm=.95047,Tm=1.08883,Ed=4/29,Sd=6/29,Ad=3*Sd*Sd,Em=Math.PI/180,Sm=180/Math.PI;function du(a){return a>.008856451679035631?Math.pow(a,.3333333333333333):a/Ad+Ed}function ao(a){return a>Sd?a*a*a:Ad*(a-Ed)}function Ms(a){return 255*(a<=.0031308?12.92*a:1.055*Math.pow(a,.4166666666666667)-.055)}function Cd(a){return(a/=255)<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}function pu(a){const t=Cd(a.r),o=Cd(a.g),c=Cd(a.b),d=du((.4124564*t+.3575761*o+.1804375*c)/Mm),m=du((.2126729*t+.7151522*o+.072175*c)/1);return{l:116*m-16,a:500*(d-m),b:200*(m-du((.0193339*t+.119192*o+.9503041*c)/Tm)),alpha:a.a}}function Pd(a){let t=(a.l+16)/116,o=isNaN(a.a)?t:t+a.a/500,c=isNaN(a.b)?t:t-a.b/200;return t=1*ao(t),o=Mm*ao(o),c=Tm*ao(c),new Xn(Ms(3.2404542*o-1.5371385*t-.4985314*c),Ms(-.969266*o+1.8760108*t+.041556*c),Ms(.0556434*o-.2040259*t+1.0572252*c),a.alpha)}function By(a,t,o){const c=t-a;return a+o*(c>180||c<-180?c-360*Math.round(c/360):c)}const wl={forward:pu,reverse:Pd,interpolate:function(a,t,o){return{l:gn(a.l,t.l,o),a:gn(a.a,t.a,o),b:gn(a.b,t.b,o),alpha:gn(a.alpha,t.alpha,o)}}},Ml={forward:function(a){const{l:t,a:o,b:c}=pu(a),d=Math.atan2(c,o)*Sm;return{h:d<0?d+360:d,c:Math.sqrt(o*o+c*c),l:t,alpha:a.a}},reverse:function(a){const t=a.h*Em,o=a.c;return Pd({l:a.l,a:Math.cos(t)*o,b:Math.sin(t)*o,alpha:a.alpha})},interpolate:function(a,t,o){return{h:By(a.h,t.h,o),c:gn(a.c,t.c,o),l:gn(a.l,t.l,o),alpha:gn(a.alpha,t.alpha,o)}}};var Ld=Object.freeze({__proto__:null,lab:wl,hcl:Ml});class Lr{constructor(t,o,c,d,m){this.type=t,this.operator=o,this.interpolation=c,this.input=d,this.labels=[],this.outputs=[];for(const[y,v]of m)this.labels.push(y),this.outputs.push(v)}static interpolationFactor(t,o,c,d){let m=0;if(t.name==="exponential")m=fu(o,t.base,c,d);else if(t.name==="linear")m=fu(o,1,c,d);else if(t.name==="cubic-bezier"){const y=t.controlPoints;m=new T(y[0],y[1],y[2],y[3]).solve(fu(o,1,c,d))}return m}static parse(t,o){let[c,d,m,...y]=t;if(!Array.isArray(d)||d.length===0)return o.error("Expected an interpolation type expression.",1);if(d[0]==="linear")d={name:"linear"};else if(d[0]==="exponential"){const A=d[1];if(typeof A!="number")return o.error("Exponential interpolation requires a numeric base.",1,1);d={name:"exponential",base:A}}else{if(d[0]!=="cubic-bezier")return o.error(`Unknown interpolation type ${String(d[0])}`,1,0);{const A=d.slice(1);if(A.length!==4||A.some(D=>typeof D!="number"||D<0||D>1))return o.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);d={name:"cubic-bezier",controlPoints:A}}}if(t.length-1<4)return o.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return o.error("Expected an even number of arguments.");if(m=o.parse(m,2,wt),!m)return null;const v=[];let w=null;c==="interpolate-hcl"||c==="interpolate-lab"?w=fn:o.expectedType&&o.expectedType.kind!=="value"&&(w=o.expectedType);for(let A=0;A=D)return o.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',k);const j=o.parse(R,V,w);if(!j)return null;w=w||j.type,v.push([D,j])}return w.kind==="number"||w.kind==="color"||w.kind==="array"&&w.itemType.kind==="number"&&typeof w.N=="number"?new Lr(w,c,d,m,v):o.error(`Type ${oi(w)} is not interpolatable.`)}evaluate(t){const o=this.labels,c=this.outputs;if(o.length===1)return c[0].evaluate(t);const d=this.input.evaluate(t);if(d<=o[0])return c[0].evaluate(t);const m=o.length;if(d>=o[m-1])return c[m-1].evaluate(t);const y=xl(o,d),v=Lr.interpolationFactor(this.interpolation,d,o[y],o[y+1]),w=c[y].evaluate(t),A=c[y+1].evaluate(t);return this.operator==="interpolate"?hu[this.type.kind.toLowerCase()](w,A,v):this.operator==="interpolate-hcl"?Ml.reverse(Ml.interpolate(Ml.forward(w),Ml.forward(A),v)):wl.reverse(wl.interpolate(wl.forward(w),wl.forward(A),v))}eachChild(t){t(this.input);for(const o of this.outputs)t(o)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}serialize(){let t;t=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 o=[this.operator,t,this.input.serialize()];for(let c=0;cza(d,v.type));return new Tl(y?Sn:c,m)}evaluate(t){let o,c=null,d=0;for(const m of this.args){if(d++,c=m.evaluate(t),c&&c instanceof Cr&&!c.available&&(o||(o=c),c=null,d===this.args.length))return o;if(c!==null)break}return c}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}serialize(){const t=["coalesce"];return this.eachChild(o=>{t.push(o.serialize())}),t}}class El{constructor(t,o){this.type=o.type,this.bindings=[].concat(t),this.result=o}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const o of this.bindings)t(o[1]);t(this.result)}static parse(t,o){if(t.length<4)return o.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const c=[];for(let m=1;m=c.length)throw new Qi(`Array index out of bounds: ${o} > ${c.length-1}.`);if(o!==Math.floor(o))throw new Qi(`Array index must be an integer, but found ${o} instead.`);return c[o]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class mu{constructor(t,o){this.type=$t,this.needle=t,this.haystack=o}static parse(t,o){if(t.length!==3)return o.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const c=o.parse(t[1],1,Sn),d=o.parse(t[2],2,Sn);return c&&d?iu(c.type,[$t,cn,wt,Dn,Sn])?new mu(c,d):o.error(`Expected first argument to be of type boolean, string, number or null, but found ${oi(c.type)} instead`):null}evaluate(t){const o=this.needle.evaluate(t),c=this.haystack.evaluate(t);if(c==null)return!1;if(!vs(o,["boolean","string","number","null"]))throw new Qi(`Expected first argument to be of type boolean, string, number or null, but found ${oi(Pi(o))} instead.`);if(!vs(c,["string","array"]))throw new Qi(`Expected second argument to be of type array or string, but found ${oi(Pi(c))} instead.`);return c.indexOf(o)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class gu{constructor(t,o,c){this.type=wt,this.needle=t,this.haystack=o,this.fromIndex=c}static parse(t,o){if(t.length<=2||t.length>=5)return o.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const c=o.parse(t[1],1,Sn),d=o.parse(t[2],2,Sn);if(!c||!d)return null;if(!iu(c.type,[$t,cn,wt,Dn,Sn]))return o.error(`Expected first argument to be of type boolean, string, number or null, but found ${oi(c.type)} instead`);if(t.length===4){const m=o.parse(t[3],3,wt);return m?new gu(c,d,m):null}return new gu(c,d)}evaluate(t){const o=this.needle.evaluate(t),c=this.haystack.evaluate(t);if(!vs(o,["boolean","string","number","null"]))throw new Qi(`Expected first argument to be of type boolean, string, number or null, but found ${oi(Pi(o))} instead.`);if(!vs(c,["string","array"]))throw new Qi(`Expected second argument to be of type array or string, but found ${oi(Pi(c))} instead.`);if(this.fromIndex){const d=this.fromIndex.evaluate(t);return c.indexOf(o,d)}return c.indexOf(o)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class _u{constructor(t,o,c,d,m,y){this.inputType=t,this.type=o,this.input=c,this.cases=d,this.outputs=m,this.otherwise=y}static parse(t,o){if(t.length<5)return o.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return o.error("Expected an even number of arguments.");let c,d;o.expectedType&&o.expectedType.kind!=="value"&&(d=o.expectedType);const m={},y=[];for(let A=2;ANumber.MAX_SAFE_INTEGER)return k.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof j=="number"&&Math.floor(j)!==j)return k.error("Numeric branch labels must be integer values.");if(c){if(k.checkSubtype(c,Pi(j)))return null}else c=Pi(j);if(m[String(j)]!==void 0)return k.error("Branch labels must be unique.");m[String(j)]=y.length}const V=o.parse(R,A,d);if(!V)return null;d=d||V.type,y.push(V)}const v=o.parse(t[1],1,Sn);if(!v)return null;const w=o.parse(t[t.length-1],t.length-1,d);return w?v.type.kind!=="value"&&o.concat(1).checkSubtype(c,v.type)?null:new _u(c,d,v,m,y,w):null}evaluate(t){const o=this.input.evaluate(t);return(Pi(o)===this.inputType&&this.outputs[this.cases[o]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every(t=>t.outputDefined())&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],o=Object.keys(this.cases).sort(),c=[],d={};for(const y of o){const v=d[this.cases[y]];v===void 0?(d[this.cases[y]]=c.length,c.push([this.cases[y],[y]])):c[v][1].push(y)}const m=y=>this.inputType.kind==="number"?Number(y):y;for(const[y,v]of c)t.push(v.length===1?m(v[0]):v.map(m)),t.push(this.outputs[y].serialize());return t.push(this.otherwise.serialize()),t}}class yu{constructor(t,o,c){this.type=t,this.branches=o,this.otherwise=c}static parse(t,o){if(t.length<4)return o.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return o.error("Expected an odd number of arguments.");let c;o.expectedType&&o.expectedType.kind!=="value"&&(c=o.expectedType);const d=[];for(let y=1;yo.outputDefined())&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild(o=>{t.push(o.serialize())}),t}}class vu{constructor(t,o,c,d){this.type=t,this.input=o,this.beginIndex=c,this.endIndex=d}static parse(t,o){if(t.length<=2||t.length>=5)return o.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const c=o.parse(t[1],1,Sn),d=o.parse(t[2],2,wt);if(!c||!d)return null;if(!iu(c.type,[li(Sn),cn,Sn]))return o.error(`Expected first argument to be of type array or string, but found ${oi(c.type)} instead`);if(t.length===4){const m=o.parse(t[3],3,wt);return m?new vu(c.type,c,d,m):null}return new vu(c.type,c,d)}evaluate(t){const o=this.input.evaluate(t),c=this.beginIndex.evaluate(t);if(!vs(o,["string","array"]))throw new Qi(`Expected first argument to be of type array or string, but found ${oi(Pi(o))} instead.`);if(this.endIndex){const d=this.endIndex.evaluate(t);return o.slice(c,d)}return o.slice(c)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function Am(a,t){return a==="=="||a==="!="?t.kind==="boolean"||t.kind==="string"||t.kind==="number"||t.kind==="null"||t.kind==="value":t.kind==="string"||t.kind==="number"||t.kind==="value"}function Cm(a,t,o,c){return c.compare(t,o)===0}function Ts(a,t,o){const c=a!=="=="&&a!=="!=";return class eM{constructor(m,y,v){this.type=$t,this.lhs=m,this.rhs=y,this.collator=v,this.hasUntypedArgument=m.type.kind==="value"||y.type.kind==="value"}static parse(m,y){if(m.length!==3&&m.length!==4)return y.error("Expected two or three arguments.");const v=m[0];let w=y.parse(m[1],1,Sn);if(!w)return null;if(!Am(v,w.type))return y.concat(1).error(`"${v}" comparisons are not supported for type '${oi(w.type)}'.`);let A=y.parse(m[2],2,Sn);if(!A)return null;if(!Am(v,A.type))return y.concat(2).error(`"${v}" comparisons are not supported for type '${oi(A.type)}'.`);if(w.type.kind!==A.type.kind&&w.type.kind!=="value"&&A.type.kind!=="value")return y.error(`Cannot compare types '${oi(w.type)}' and '${oi(A.type)}'.`);c&&(w.type.kind==="value"&&A.type.kind!=="value"?w=new pa(A.type,[w]):w.type.kind!=="value"&&A.type.kind==="value"&&(A=new pa(w.type,[A])));let D=null;if(m.length===4){if(w.type.kind!=="string"&&A.type.kind!=="string"&&w.type.kind!=="value"&&A.type.kind!=="value")return y.error("Cannot use collator to compare non-string types.");if(D=y.parse(m[3],3,di),!D)return null}return new eM(w,A,D)}evaluate(m){const y=this.lhs.evaluate(m),v=this.rhs.evaluate(m);if(c&&this.hasUntypedArgument){const w=Pi(y),A=Pi(v);if(w.kind!==A.kind||w.kind!=="string"&&w.kind!=="number")throw new Qi(`Expected arguments for "${a}" to be (string, string) or (number, number), but found (${w.kind}, ${A.kind}) instead.`)}if(this.collator&&!c&&this.hasUntypedArgument){const w=Pi(y),A=Pi(v);if(w.kind!=="string"||A.kind!=="string")return t(m,y,v)}return this.collator?o(m,y,v,this.collator.evaluate(m)):t(m,y,v)}eachChild(m){m(this.lhs),m(this.rhs),this.collator&&m(this.collator)}outputDefined(){return!0}serialize(){const m=[a];return this.eachChild(y=>{m.push(y.serialize())}),m}}}const Fy=Ts("==",function(a,t,o){return t===o},Cm),Oy=Ts("!=",function(a,t,o){return t!==o},function(a,t,o,c){return!Cm(0,t,o,c)}),Pm=Ts("<",function(a,t,o){return t",function(a,t,o){return t>o},function(a,t,o,c){return c.compare(t,o)>0}),Uy=Ts("<=",function(a,t,o){return t<=o},function(a,t,o,c){return c.compare(t,o)<=0}),Vy=Ts(">=",function(a,t,o){return t>=o},function(a,t,o,c){return c.compare(t,o)>=0});class Id{constructor(t,o,c,d,m){this.type=cn,this.number=t,this.locale=o,this.currency=c,this.minFractionDigits=d,this.maxFractionDigits=m}static parse(t,o){if(t.length!==3)return o.error("Expected two arguments.");const c=o.parse(t[1],1,wt);if(!c)return null;const d=t[2];if(typeof d!="object"||Array.isArray(d))return o.error("NumberFormat options argument must be an object.");let m=null;if(d.locale&&(m=o.parse(d.locale,1,cn),!m))return null;let y=null;if(d.currency&&(y=o.parse(d.currency,1,cn),!y))return null;let v=null;if(d["min-fraction-digits"]&&(v=o.parse(d["min-fraction-digits"],1,wt),!v))return null;let w=null;return d["max-fraction-digits"]&&(w=o.parse(d["max-fraction-digits"],1,wt),!w)?null:new Id(c,m,y,v,w)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class xu{constructor(t){this.type=wt,this.input=t}static parse(t,o){if(t.length!==2)return o.error(`Expected 1 argument, but found ${t.length-1} instead.`);const c=o.parse(t[1],1);return c?c.type.kind!=="array"&&c.type.kind!=="string"&&c.type.kind!=="value"?o.error(`Expected argument of type string or array, but found ${oi(c.type)} instead.`):new xu(c):null}evaluate(t){const o=this.input.evaluate(t);if(typeof o=="string"||Array.isArray(o))return o.length;throw new Qi(`Expected value to be of type string or array, but found ${oi(Pi(o))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild(o=>{t.push(o.serialize())}),t}}const Vo={"==":Fy,"!=":Oy,">":Ny,"<":Pm,">=":Vy,"<=":Uy,array:pa,at:Dd,boolean:pa,case:yu,coalesce:Tl,collator:ou,format:bs,image:ws,in:mu,"index-of":gu,interpolate:Lr,"interpolate-hcl":Lr,"interpolate-lab":Lr,length:xu,let:El,literal:Ba,match:_u,number:pa,"number-format":Id,object:pa,slice:vu,step:bl,string:pa,"to-boolean":fa,"to-color":fa,"to-number":fa,"to-string":fa,var:Uo,within:No};function Rd(a,[t,o,c,d]){t=t.evaluate(a),o=o.evaluate(a),c=c.evaluate(a);const m=d?d.evaluate(a):1,y=da(t,o,c,m);if(y)throw new Qi(y);return new Xn(t/255*m,o/255*m,c/255*m,m)}function Lm(a,t){return a in t}function zd(a,t){const o=t[a];return o===void 0?null:o}function oo(a){return{type:a}}function kd(a){return{result:"success",value:a}}function Go(a){return{result:"error",value:a}}function Es(a){return a["property-type"]==="data-driven"||a["property-type"]==="cross-faded-data-driven"}function Dm(a){return!!a.expression&&a.expression.parameters.indexOf("zoom")>-1}function Bd(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 Ho(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}function Im(a){return a}function Fd(a,t){const o=t.type==="color",c=a.stops&&typeof a.stops[0][0]=="object",d=c||!(c||a.property!==void 0),m=a.type||(Bd(t)?"exponential":"interval");if(o&&((a=Mt({},a)).stops&&(a.stops=a.stops.map(A=>[A[0],Xn.parse(A[1])])),a.default=Xn.parse(a.default?a.default:t.default)),a.colorSpace&&a.colorSpace!=="rgb"&&!Ld[a.colorSpace])throw new Error(`Unknown color space: ${a.colorSpace}`);let y,v,w;if(m==="exponential")y=Od;else if(m==="interval")y=Hy;else if(m==="categorical"){y=Gy,v=Object.create(null);for(const A of a.stops)v[A[0]]=A[1];w=typeof a.stops[0][0]}else{if(m!=="identity")throw new Error(`Unknown function type "${m}"`);y=Rm}if(c){const A={},D=[];for(let V=0;VV[0]),evaluate:({zoom:V},j)=>Od({stops:R,base:a.base},t,V).evaluate(V,j)}}if(d){const A=m==="exponential"?{name:"exponential",base:a.base!==void 0?a.base:1}:null;return{kind:"camera",interpolationType:A,interpolationFactor:Lr.interpolationFactor.bind(void 0,A),zoomStops:a.stops.map(D=>D[0]),evaluate:({zoom:D})=>y(a,t,D,v,w)}}return{kind:"source",evaluate(A,D){const R=D&&D.properties?D.properties[a.property]:void 0;return R===void 0?Sl(a.default,t.default):y(a,t,R,v,w)}}}function Sl(a,t,o){return a!==void 0?a:t!==void 0?t:o!==void 0?o:void 0}function Gy(a,t,o,c,d){return Sl(typeof o===d?c[o]:void 0,a.default,t.default)}function Hy(a,t,o){if(Qn(o)!=="number")return Sl(a.default,t.default);const c=a.stops.length;if(c===1||o<=a.stops[0][0])return a.stops[0][1];if(o>=a.stops[c-1][0])return a.stops[c-1][1];const d=xl(a.stops.map(m=>m[0]),o);return a.stops[d][1]}function Od(a,t,o){const c=a.base!==void 0?a.base:1;if(Qn(o)!=="number")return Sl(a.default,t.default);const d=a.stops.length;if(d===1||o<=a.stops[0][0])return a.stops[0][1];if(o>=a.stops[d-1][0])return a.stops[d-1][1];const m=xl(a.stops.map(D=>D[0]),o),y=function(D,R,k,V){const j=V-k,$=D-k;return j===0?0:R===1?$/j:(Math.pow(R,$)-1)/(Math.pow(R,j)-1)}(o,c,a.stops[m][0],a.stops[m+1][0]),v=a.stops[m][1],w=a.stops[m+1][1];let A=hu[t.type]||Im;if(a.colorSpace&&a.colorSpace!=="rgb"){const D=Ld[a.colorSpace];A=(R,k)=>D.reverse(D.interpolate(D.forward(R),D.forward(k),y))}return typeof v.evaluate=="function"?{evaluate(...D){const R=v.evaluate.apply(void 0,D),k=w.evaluate.apply(void 0,D);if(R!==void 0&&k!==void 0)return A(R,k,y)}}:A(v,w,y)}function Rm(a,t,o){return t.type==="color"?o=Xn.parse(o):t.type==="formatted"?o=Bi.fromString(o.toString()):t.type==="resolvedImage"?o=Cr.fromString(o.toString()):Qn(o)===t.type||t.type==="enum"&&t.values[o]||(o=void 0),Sl(o,a.default,t.default)}Pr.register(Vo,{error:[{kind:"error"},[cn],(a,[t])=>{throw new Qi(t.evaluate(a))}],typeof:[cn,[Sn],(a,[t])=>oi(Pi(t.evaluate(a)))],"to-rgba":[li(wt,4),[fn],(a,[t])=>t.evaluate(a).toArray()],rgb:[fn,[wt,wt,wt],Rd],rgba:[fn,[wt,wt,wt,wt],Rd],has:{type:$t,overloads:[[[cn],(a,[t])=>Lm(t.evaluate(a),a.properties())],[[cn,Tn],(a,[t,o])=>Lm(t.evaluate(a),o.evaluate(a))]]},get:{type:Sn,overloads:[[[cn],(a,[t])=>zd(t.evaluate(a),a.properties())],[[cn,Tn],(a,[t,o])=>zd(t.evaluate(a),o.evaluate(a))]]},"feature-state":[Sn,[cn],(a,[t])=>zd(t.evaluate(a),a.featureState||{})],properties:[Tn,[],a=>a.properties()],"geometry-type":[cn,[],a=>a.geometryType()],id:[Sn,[],a=>a.id()],zoom:[wt,[],a=>a.globals.zoom],pitch:[wt,[],a=>a.globals.pitch||0],"distance-from-center":[wt,[],a=>a.distanceFromCenter()],"heatmap-density":[wt,[],a=>a.globals.heatmapDensity||0],"line-progress":[wt,[],a=>a.globals.lineProgress||0],"sky-radial-progress":[wt,[],a=>a.globals.skyRadialProgress||0],accumulated:[Sn,[],a=>a.globals.accumulated===void 0?null:a.globals.accumulated],"+":[wt,oo(wt),(a,t)=>{let o=0;for(const c of t)o+=c.evaluate(a);return o}],"*":[wt,oo(wt),(a,t)=>{let o=1;for(const c of t)o*=c.evaluate(a);return o}],"-":{type:wt,overloads:[[[wt,wt],(a,[t,o])=>t.evaluate(a)-o.evaluate(a)],[[wt],(a,[t])=>-t.evaluate(a)]]},"/":[wt,[wt,wt],(a,[t,o])=>t.evaluate(a)/o.evaluate(a)],"%":[wt,[wt,wt],(a,[t,o])=>t.evaluate(a)%o.evaluate(a)],ln2:[wt,[],()=>Math.LN2],pi:[wt,[],()=>Math.PI],e:[wt,[],()=>Math.E],"^":[wt,[wt,wt],(a,[t,o])=>Math.pow(t.evaluate(a),o.evaluate(a))],sqrt:[wt,[wt],(a,[t])=>Math.sqrt(t.evaluate(a))],log10:[wt,[wt],(a,[t])=>Math.log(t.evaluate(a))/Math.LN10],ln:[wt,[wt],(a,[t])=>Math.log(t.evaluate(a))],log2:[wt,[wt],(a,[t])=>Math.log(t.evaluate(a))/Math.LN2],sin:[wt,[wt],(a,[t])=>Math.sin(t.evaluate(a))],cos:[wt,[wt],(a,[t])=>Math.cos(t.evaluate(a))],tan:[wt,[wt],(a,[t])=>Math.tan(t.evaluate(a))],asin:[wt,[wt],(a,[t])=>Math.asin(t.evaluate(a))],acos:[wt,[wt],(a,[t])=>Math.acos(t.evaluate(a))],atan:[wt,[wt],(a,[t])=>Math.atan(t.evaluate(a))],min:[wt,oo(wt),(a,t)=>Math.min(...t.map(o=>o.evaluate(a)))],max:[wt,oo(wt),(a,t)=>Math.max(...t.map(o=>o.evaluate(a)))],abs:[wt,[wt],(a,[t])=>Math.abs(t.evaluate(a))],round:[wt,[wt],(a,[t])=>{const o=t.evaluate(a);return o<0?-Math.round(-o):Math.round(o)}],floor:[wt,[wt],(a,[t])=>Math.floor(t.evaluate(a))],ceil:[wt,[wt],(a,[t])=>Math.ceil(t.evaluate(a))],"filter-==":[$t,[cn,Sn],(a,[t,o])=>a.properties()[t.value]===o.value],"filter-id-==":[$t,[Sn],(a,[t])=>a.id()===t.value],"filter-type-==":[$t,[cn],(a,[t])=>a.geometryType()===t.value],"filter-<":[$t,[cn,Sn],(a,[t,o])=>{const c=a.properties()[t.value],d=o.value;return typeof c==typeof d&&c{const o=a.id(),c=t.value;return typeof o==typeof c&&o":[$t,[cn,Sn],(a,[t,o])=>{const c=a.properties()[t.value],d=o.value;return typeof c==typeof d&&c>d}],"filter-id->":[$t,[Sn],(a,[t])=>{const o=a.id(),c=t.value;return typeof o==typeof c&&o>c}],"filter-<=":[$t,[cn,Sn],(a,[t,o])=>{const c=a.properties()[t.value],d=o.value;return typeof c==typeof d&&c<=d}],"filter-id-<=":[$t,[Sn],(a,[t])=>{const o=a.id(),c=t.value;return typeof o==typeof c&&o<=c}],"filter->=":[$t,[cn,Sn],(a,[t,o])=>{const c=a.properties()[t.value],d=o.value;return typeof c==typeof d&&c>=d}],"filter-id->=":[$t,[Sn],(a,[t])=>{const o=a.id(),c=t.value;return typeof o==typeof c&&o>=c}],"filter-has":[$t,[Sn],(a,[t])=>t.value in a.properties()],"filter-has-id":[$t,[],a=>a.id()!==null&&a.id()!==void 0],"filter-type-in":[$t,[li(cn)],(a,[t])=>t.value.indexOf(a.geometryType())>=0],"filter-id-in":[$t,[li(Sn)],(a,[t])=>t.value.indexOf(a.id())>=0],"filter-in-small":[$t,[cn,li(Sn)],(a,[t,o])=>o.value.indexOf(a.properties()[t.value])>=0],"filter-in-large":[$t,[cn,li(Sn)],(a,[t,o])=>function(c,d,m,y){for(;m<=y;){const v=m+y>>1;if(d[v]===c)return!0;d[v]>c?y=v-1:m=v+1}return!1}(a.properties()[t.value],o.value,0,o.value.length-1)],all:{type:$t,overloads:[[[$t,$t],(a,[t,o])=>t.evaluate(a)&&o.evaluate(a)],[oo($t),(a,t)=>{for(const o of t)if(!o.evaluate(a))return!1;return!0}]]},any:{type:$t,overloads:[[[$t,$t],(a,[t,o])=>t.evaluate(a)||o.evaluate(a)],[oo($t),(a,t)=>{for(const o of t)if(o.evaluate(a))return!0;return!1}]]},"!":[$t,[$t],(a,[t])=>!t.evaluate(a)],"is-supported-script":[$t,[cn],(a,[t])=>{const o=a.globals&&a.globals.isSupportedScript;return!o||o(t.evaluate(a))}],upcase:[cn,[cn],(a,[t])=>t.evaluate(a).toUpperCase()],downcase:[cn,[cn],(a,[t])=>t.evaluate(a).toLowerCase()],concat:[cn,oo(Sn),(a,t)=>t.map(o=>ka(o.evaluate(a))).join("")],"resolved-locale":[cn,[di],(a,[t])=>t.evaluate(a).resolvedLocale()]});class bu{constructor(t,o){this.expression=t,this._warningHistory={},this._evaluator=new gm,this._defaultValue=o?function(c){return c.type==="color"&&Ho(c.default)?new Xn(0,0,0,0):c.type==="color"?Xn.parse(c.default)||null:c.default===void 0?null:c.default}(o):null,this._enumValues=o&&o.type==="enum"?o.values:null}evaluateWithoutErrorHandling(t,o,c,d,m,y,v,w){return this._evaluator.globals=t,this._evaluator.feature=o,this._evaluator.featureState=c,this._evaluator.canonical=d||null,this._evaluator.availableImages=m||null,this._evaluator.formattedSection=y,this._evaluator.featureTileCoord=v||null,this._evaluator.featureDistanceData=w||null,this.expression.evaluate(this._evaluator)}evaluate(t,o,c,d,m,y,v,w){this._evaluator.globals=t,this._evaluator.feature=o||null,this._evaluator.featureState=c||null,this._evaluator.canonical=d||null,this._evaluator.availableImages=m||null,this._evaluator.formattedSection=y||null,this._evaluator.featureTileCoord=v||null,this._evaluator.featureDistanceData=w||null;try{const A=this.expression.evaluate(this._evaluator);if(A==null||typeof A=="number"&&A!=A)return this._defaultValue;if(this._enumValues&&!(A in this._enumValues))throw new Qi(`Expected value to be one of ${Object.keys(this._enumValues).map(D=>JSON.stringify(D)).join(", ")}, but found ${JSON.stringify(A)} instead.`);return A}catch(A){return this._warningHistory[A.message]||(this._warningHistory[A.message]=!0,typeof console!="undefined"&&console.warn(A.message)),this._defaultValue}}}function Ss(a){return Array.isArray(a)&&a.length>0&&typeof a[0]=="string"&&a[0]in Vo}function Al(a,t){const o=new ro(Vo,[],t?function(d){const m={color:fn,string:cn,number:wt,enum:cn,boolean:$t,formatted:Ar,resolvedImage:ai};return d.type==="array"?li(m[d.value]||Sn,d.length):m[d.type]}(t):void 0),c=o.parse(a,void 0,void 0,void 0,t&&t.type==="string"?{typeAnnotation:"coerce"}:void 0);return c?kd(new bu(c,t)):Go(o.errors)}class Nd{constructor(t,o){this.kind=t,this._styleExpression=o,this.isStateDependent=t!=="constant"&&!yl(o.expression)}evaluateWithoutErrorHandling(t,o,c,d,m,y){return this._styleExpression.evaluateWithoutErrorHandling(t,o,c,d,m,y)}evaluate(t,o,c,d,m,y){return this._styleExpression.evaluate(t,o,c,d,m,y)}}class Ud{constructor(t,o,c,d){this.kind=t,this.zoomStops=c,this._styleExpression=o,this.isStateDependent=t!=="camera"&&!yl(o.expression),this.interpolationType=d}evaluateWithoutErrorHandling(t,o,c,d,m,y){return this._styleExpression.evaluateWithoutErrorHandling(t,o,c,d,m,y)}evaluate(t,o,c,d,m,y){return this._styleExpression.evaluate(t,o,c,d,m,y)}interpolationFactor(t,o,c){return this.interpolationType?Lr.interpolationFactor(this.interpolationType,t,o,c):0}}function zm(a,t){if((a=Al(a,t)).result==="error")return a;const o=a.value.expression,c=gr(o);if(!c&&!Es(t))return Go([new nn("","data expressions not supported")]);const d=vl(o,["zoom","pitch","distance-from-center"]);if(!d&&!Dm(t))return Go([new nn("","zoom expressions not supported")]);const m=Mu(o);return m||d?m instanceof nn?Go([m]):m instanceof Lr&&!Bd(t)?Go([new nn("",'"interpolate" expressions cannot be used with this property')]):kd(m?new Ud(c?"camera":"composite",a.value,m.labels,m instanceof Lr?m.interpolation:void 0):new Nd(c?"constant":"source",a.value)):Go([new nn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class wu{constructor(t,o){this._parameters=t,this._specification=o,Mt(this,Fd(this._parameters,this._specification))}static deserialize(t){return new wu(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Mu(a){let t=null;if(a instanceof El)t=Mu(a.result);else if(a instanceof Tl){for(const o of a.args)if(t=Mu(o),t)break}else(a instanceof bl||a instanceof Lr)&&a.input instanceof Pr&&a.input.name==="zoom"&&(t=a);return t instanceof nn||a.eachChild(o=>{const c=Mu(o);c instanceof nn?t=c:!t&&c?t=new nn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&c&&t!==c&&(t=new nn("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}class Ht{constructor(t,o,c,d){this.message=(t?`${t}: `:"")+c,d&&(this.identifier=d),o!=null&&o.__line__&&(this.line=o.__line__)}}function jr(a){const t=a.key,o=a.value,c=a.valueSpec||{},d=a.objectElementValidators||{},m=a.style,y=a.styleSpec;let v=[];const w=Qn(o);if(w!=="object")return[new Ht(t,o,`object expected, ${w} found`)];for(const A in o){const D=A.split(".")[0],R=c[D]||c["*"];let k;d[D]?k=d[D]:c[D]?k=ji:d["*"]?k=d["*"]:c["*"]&&(k=ji),k?v=v.concat(k({key:(t&&`${t}.`)+A,value:o[A],valueSpec:R,style:m,styleSpec:y,object:o,objectKey:A},o)):v.push(new Ht(t,o[A],`unknown property "${A}"`))}for(const A in c)d[A]||c[A].required&&c[A].default===void 0&&o[A]===void 0&&v.push(new Ht(t,o,`missing required property "${A}"`));return v}function Cl(a){const t=a.value,o=a.valueSpec,c=a.style,d=a.styleSpec,m=a.key,y=a.arrayElementValidator||ji;if(Qn(t)!=="array")return[new Ht(m,t,`array expected, ${Qn(t)} found`)];if(o.length&&t.length!==o.length)return[new Ht(m,t,`array length ${o.length} expected, length ${t.length} found`)];if(o["min-length"]&&t.lengthm)return[new Ht(t,o,`${o} is greater than the maximum value ${m}`)]}return[]}function Bm(a){const t=a.valueSpec,o=_t(a.value.type);let c,d,m,y={};const v=o!=="categorical"&&a.value.property===void 0,w=!v,A=Qn(a.value.stops)==="array"&&Qn(a.value.stops[0])==="array"&&Qn(a.value.stops[0][0])==="object",D=jr({key:a.key,value:a.value,valueSpec:a.styleSpec.function,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{stops:function(V){if(o==="identity")return[new Ht(V.key,V.value,'identity function may not have a "stops" property')];let j=[];const $=V.value;return j=j.concat(Cl({key:V.key,value:$,valueSpec:V.valueSpec,style:V.style,styleSpec:V.styleSpec,arrayElementValidator:R})),Qn($)==="array"&&$.length===0&&j.push(new Ht(V.key,$,"array must have at least one stop")),j},default:function(V){return ji({key:V.key,value:V.value,valueSpec:t,style:V.style,styleSpec:V.styleSpec})}}});return o==="identity"&&v&&D.push(new Ht(a.key,a.value,'missing required property "property"')),o==="identity"||a.value.stops||D.push(new Ht(a.key,a.value,'missing required property "stops"')),o==="exponential"&&a.valueSpec.expression&&!Bd(a.valueSpec)&&D.push(new Ht(a.key,a.value,"exponential functions not supported")),a.styleSpec.$version>=8&&(w&&!Es(a.valueSpec)?D.push(new Ht(a.key,a.value,"property functions not supported")):v&&!Dm(a.valueSpec)&&D.push(new Ht(a.key,a.value,"zoom functions not supported"))),o!=="categorical"&&!A||a.value.property!==void 0||D.push(new Ht(a.key,a.value,'"property" property is required')),D;function R(V){let j=[];const $=V.value,ne=V.key;if(Qn($)!=="array")return[new Ht(ne,$,`array expected, ${Qn($)} found`)];if($.length!==2)return[new Ht(ne,$,`array length 2 expected, length ${$.length} found`)];if(A){if(Qn($[0])!=="object")return[new Ht(ne,$,`object expected, ${Qn($[0])} found`)];if($[0].zoom===void 0)return[new Ht(ne,$,"object stop key must have zoom")];if($[0].value===void 0)return[new Ht(ne,$,"object stop key must have value")];const me=_t($[0].zoom);if(typeof me!="number")return[new Ht(ne,$[0].zoom,"stop zoom values must be numbers")];if(m&&m>me)return[new Ht(ne,$[0].zoom,"stop zoom values must appear in ascending order")];me!==m&&(m=me,d=void 0,y={}),j=j.concat(jr({key:`${ne}[0]`,value:$[0],valueSpec:{zoom:{}},style:V.style,styleSpec:V.styleSpec,objectElementValidators:{zoom:km,value:k}}))}else j=j.concat(k({key:`${ne}[0]`,value:$[0],valueSpec:{},style:V.style,styleSpec:V.styleSpec},$));return Ss(Ft($[1]))?j.concat([new Ht(`${ne}[1]`,$[1],"expressions are not allowed in function stops.")]):j.concat(ji({key:`${ne}[1]`,value:$[1],valueSpec:t,style:V.style,styleSpec:V.styleSpec}))}function k(V,j){const $=Qn(V.value),ne=_t(V.value),me=V.value!==null?V.value:j;if(c){if($!==c)return[new Ht(V.key,me,`${$} stop domain type must match previous stop domain type ${c}`)]}else c=$;if($!=="number"&&$!=="string"&&$!=="boolean"&&typeof ne!="number"&&typeof ne!="string"&&typeof ne!="boolean")return[new Ht(V.key,me,"stop domain value must be a number, string, or boolean")];if($!=="number"&&o!=="categorical"){let ke=`number expected, ${$} found`;return Es(t)&&o===void 0&&(ke+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ht(V.key,me,ke)]}return o!=="categorical"||$!=="number"||typeof ne=="number"&&isFinite(ne)&&Math.floor(ne)===ne?o!=="categorical"&&$==="number"&&typeof ne=="number"&&typeof d=="number"&&d!==void 0&&nenew Ht(`${a.key}${c.key}`,a.value,c.message));const o=t.value.expression||t.value._styleExpression.expression;if(a.expressionContext==="property"&&a.propertyKey==="text-font"&&!o.outputDefined())return[new Ht(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"&&!yl(o))return[new Ht(a.key,a.value,'"feature-state" data expressions are not supported with layout properties.')];if(a.expressionContext==="filter")return Fa(o,a);if(a.expressionContext&&a.expressionContext.indexOf("cluster")===0){if(!vl(o,["zoom","feature-state"]))return[new Ht(a.key,a.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(a.expressionContext==="cluster-initial"&&!gr(o))return[new Ht(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Fa(a,t){const o=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(t.valueSpec&&t.valueSpec.expression)for(const d of t.valueSpec.expression.parameters)o.delete(d);if(o.size===0)return[];const c=[];return a instanceof Pr&&o.has(a.name)?[new Ht(t.key,t.value,`["${a.name}"] expression is not supported in a filter for a ${t.object.type} layer with id: ${t.object.id}`)]:(a.eachChild(d=>{c.push(...Fa(d,t))}),c)}function Pl(a){const t=a.key,o=a.value,c=a.valueSpec,d=[];return Array.isArray(c.values)?c.values.indexOf(_t(o))===-1&&d.push(new Ht(t,o,`expected one of [${c.values.join(", ")}], ${JSON.stringify(o)} found`)):Object.keys(c.values).indexOf(_t(o))===-1&&d.push(new Ht(t,o,`expected one of [${Object.keys(c.values).join(", ")}], ${JSON.stringify(o)} found`)),d}function so(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 t of a.slice(1))if(!so(t)&&typeof t!="boolean")return!1;return!0;default:return!0}}function lo(a,t="fill"){if(a==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};so(a)||(a=Ll(a));const o=a;let c=!0;try{c=function(A){if(!co(A))return A;let D=Ft(A);return Fm(D),D=Vd(D),D}(o)}catch(A){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(o,null,2)} `)}const d=xe[`filter_${t}`],m=Al(c,d);let y=null;if(m.result==="error")throw new Error(m.value.map(A=>`${A.key}: ${A.message}`).join(", "));y=(A,D,R)=>m.value.evaluate(A,D,{},R);let v=null,w=null;if(c!==o){const A=Al(o,d);if(A.result==="error")throw new Error(A.value.map(D=>`${D.key}: ${D.message}`).join(", "));v=(D,R,k,V,j)=>A.value.evaluate(D,R,{},k,void 0,void 0,V,j),w=!gr(A.value.expression)}return y=y,{filter:y,dynamicFilter:v||void 0,needGeometry:Tu(c),needFeature:!!w}}function Vd(a){if(!Array.isArray(a))return a;const t=function(o){if(Om.has(o[0])){for(let c=1;cVd(o))}function Fm(a){let t=!1;const o=[];if(a[0]==="case"){for(let c=1;c",">=","<","<=","to-boolean"]);function Gd(a,t){return at?1:0}function Tu(a){if(!Array.isArray(a))return!1;if(a[0]==="within")return!0;for(let t=1;t"||t==="<="||t===">="?Dl(a[1],a[2],t):t==="any"?(o=a.slice(1),["any"].concat(o.map(Ll))):t==="all"?["all"].concat(a.slice(1).map(Ll)):t==="none"?["all"].concat(a.slice(1).map(Ll).map(Il)):t==="in"?Hd(a[1],a.slice(2)):t==="!in"?Il(Hd(a[1],a.slice(2))):t==="has"?Wd(a[1]):t==="!has"?Il(Wd(a[1])):t!=="within"||a;var o}function Dl(a,t,o){switch(a){case"$type":return[`filter-type-${o}`,t];case"$id":return[`filter-id-${o}`,t];default:return[`filter-${o}`,a,t]}}function Hd(a,t){if(t.length===0)return!1;switch(a){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(o=>typeof o!=typeof t[0])?["filter-in-large",a,["literal",t.sort(Gd)]]:["filter-in-small",a,["literal",t]]}}function Wd(a){switch(a){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",a]}}function Il(a){return["!",a]}function uo(a){return so(Ft(a.value))?As(Mt({},a,{expressionContext:"filter",valueSpec:a.styleSpec[`filter_${a.layerType||"fill"}`]})):jd(a)}function jd(a){const t=a.value,o=a.key;if(Qn(t)!=="array")return[new Ht(o,t,`array expected, ${Qn(t)} found`)];const c=a.styleSpec;let d,m=[];if(t.length<1)return[new Ht(o,t,"filter array must have at least 1 element")];switch(m=m.concat(Pl({key:`${o}[0]`,value:t[0],valueSpec:c.filter_operator,style:a.style,styleSpec:a.styleSpec})),_t(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&_t(t[1])==="$type"&&m.push(new Ht(o,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&m.push(new Ht(o,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(d=Qn(t[1]),d!=="string"&&m.push(new Ht(`${o}[1]`,t[1],`string expected, ${d} found`)));for(let y=2;y{A in o&&t.push(new Ht(c,o[A],`"${A}" is prohibited for ref layers`))}),d.layers.forEach(A=>{_t(A.id)===v&&(w=A)}),w?w.ref?t.push(new Ht(c,o.ref,"ref cannot reference another ref layer")):y=_t(w.type):typeof v=="string"&&t.push(new Ht(c,o.ref,`ref layer "${v}" not found`))}else if(y!=="background"&&y!=="sky")if(o.source){const w=d.sources&&d.sources[o.source],A=w&&_t(w.type);w?A==="vector"&&y==="raster"?t.push(new Ht(c,o.source,`layer "${o.id}" requires a raster source`)):A==="raster"&&y!=="raster"?t.push(new Ht(c,o.source,`layer "${o.id}" requires a vector source`)):A!=="vector"||o["source-layer"]?A==="raster-dem"&&y!=="hillshade"?t.push(new Ht(c,o.source,"raster-dem source can only be used with layer type 'hillshade'.")):y!=="line"||!o.paint||!o.paint["line-gradient"]||A==="geojson"&&w.lineMetrics||t.push(new Ht(c,o,`layer "${o.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new Ht(c,o,`layer "${o.id}" must specify a "source-layer"`)):t.push(new Ht(c,o.source,`source "${o.source}" not found`))}else t.push(new Ht(c,o,'missing required property "source"'));return t=t.concat(jr({key:c,value:o,valueSpec:m.layer,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{"*":()=>[],type:()=>ji({key:`${c}.type`,value:o.type,valueSpec:m.layer.type,style:a.style,styleSpec:a.styleSpec,object:o,objectKey:"type"}),filter:w=>uo(Mt({layerType:y},w)),layout:w=>jr({layer:o,key:w.key,value:w.value,valueSpec:{},style:w.style,styleSpec:w.styleSpec,objectElementValidators:{"*":A=>Zd(Mt({layerType:y},A))}}),paint:w=>jr({layer:o,key:w.key,value:w.value,valueSpec:{},style:w.style,styleSpec:w.styleSpec,objectElementValidators:{"*":A=>Eu(Mt({layerType:y},A))}})}})),t}function Oa(a){const t=a.value,o=a.key,c=Qn(t);return c!=="string"?[new Ht(o,t,`string expected, ${c} found`)]:[]}const Um={promoteId:function({key:a,value:t}){if(Qn(t)==="string")return Oa({key:a,value:t});{const o=[];for(const c in t)o.push(...Oa({key:`${a}.${c}`,value:t[c]}));return o}}};function Vm(a){const t=a.value,o=a.key,c=a.styleSpec,d=a.style;if(!t.type)return[new Ht(o,t,'"type" is required')];const m=_t(t.type);let y;switch(m){case"vector":case"raster":case"raster-dem":return y=jr({key:o,value:t,valueSpec:c[`source_${m.replace("-","_")}`],style:a.style,styleSpec:c,objectElementValidators:Um}),y;case"geojson":if(y=jr({key:o,value:t,valueSpec:c.source_geojson,style:d,styleSpec:c,objectElementValidators:Um}),t.cluster)for(const v in t.clusterProperties){const[w,A]=t.clusterProperties[v],D=typeof w=="string"?[w,["accumulated"],["get",v]]:w;y.push(...As({key:`${o}.${v}.map`,value:A,expressionContext:"cluster-map"})),y.push(...As({key:`${o}.${v}.reduce`,value:D,expressionContext:"cluster-reduce"}))}return y;case"video":return jr({key:o,value:t,valueSpec:c.source_video,style:d,styleSpec:c});case"image":return jr({key:o,value:t,valueSpec:c.source_image,style:d,styleSpec:c});case"canvas":return[new Ht(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Pl({key:`${o}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:d,styleSpec:c})}}function Gm(a){const t=a.value,o=a.styleSpec,c=o.light,d=a.style;let m=[];const y=Qn(t);if(t===void 0)return m;if(y!=="object")return m=m.concat([new Ht("light",t,`object expected, ${y} found`)]),m;for(const v in t){const w=v.match(/^(.*)-transition$/);m=m.concat(w&&c[w[1]]&&c[w[1]].transition?ji({key:v,value:t[v],valueSpec:o.transition,style:d,styleSpec:o}):c[v]?ji({key:v,value:t[v],valueSpec:c[v],style:d,styleSpec:o}):[new Ht(v,t[v],`unknown property "${v}"`)])}return m}function Hm(a){const t=a.value,o=a.key,c=a.style,d=a.styleSpec,m=d.terrain;let y=[];const v=Qn(t);if(t===void 0)return y;if(v!=="object")return y=y.concat([new Ht("terrain",t,`object expected, ${v} found`)]),y;for(const w in t){const A=w.match(/^(.*)-transition$/);y=y.concat(A&&m[A[1]]&&m[A[1]].transition?ji({key:w,value:t[w],valueSpec:d.transition,style:c,styleSpec:d}):m[w]?ji({key:w,value:t[w],valueSpec:m[w],style:c,styleSpec:d}):[new Ht(w,t[w],`unknown property "${w}"`)])}if(t.source){const w=c.sources&&c.sources[t.source],A=w&&_t(w.type);w?A!=="raster-dem"&&y.push(new Ht(o,t.source,`terrain cannot be used with a source of type ${String(A)}, it only be used with a "raster-dem" source type`)):y.push(new Ht(o,t.source,`source "${t.source}" not found`))}else y.push(new Ht(o,t,'terrain is missing required property "source"'));return y}function Wm(a){const t=a.value,o=a.style,c=a.styleSpec,d=c.fog;let m=[];const y=Qn(t);if(t===void 0)return m;if(y!=="object")return m=m.concat([new Ht("fog",t,`object expected, ${y} found`)]),m;for(const v in t){const w=v.match(/^(.*)-transition$/);m=m.concat(w&&d[w[1]]&&d[w[1]].transition?ji({key:v,value:t[v],valueSpec:c.transition,style:o,styleSpec:c}):d[v]?ji({key:v,value:t[v],valueSpec:d[v],style:o,styleSpec:c}):[new Ht(v,t[v],`unknown property "${v}"`)])}return m}const Rl={"*":()=>[],array:Cl,boolean:function(a){const t=a.value,o=a.key,c=Qn(t);return c!=="boolean"?[new Ht(o,t,`boolean expected, ${c} found`)]:[]},number:km,color:function(a){const t=a.key,o=a.value,c=Qn(o);return c!=="string"?[new Ht(t,o,`color expected, ${c} found`)]:xd.parseCSSColor(o)===null?[new Ht(t,o,`color expected, "${o}" found`)]:[]},enum:Pl,filter:uo,function:Bm,layer:Nm,object:jr,source:Vm,light:Gm,terrain:Hm,fog:Wm,string:Oa,formatted:function(a){return Oa(a).length===0?[]:As(a)},resolvedImage:function(a){return Oa(a).length===0?[]:As(a)},projection:function(a){const t=a.value,o=a.styleSpec,c=o.projection,d=a.style;let m=[];const y=Qn(t);if(y==="object")for(const v in t)m=m.concat(ji({key:v,value:t[v],valueSpec:c[v],style:d,styleSpec:o}));else y!=="string"&&(m=m.concat([new Ht("projection",t,`object or string expected, ${y} found`)]));return m}};function ji(a){const t=a.value,o=a.valueSpec,c=a.styleSpec;return o.expression&&Ho(_t(t))?Bm(a):o.expression&&Ss(Ft(t))?As(a):o.type&&Rl[o.type]?Rl[o.type](a):jr(Mt({},a,{valueSpec:o.type?c[o.type]:o}))}function Dr(a){const t=a.value,o=a.key,c=Oa(a);return c.length||(t.indexOf("{fontstack}")===-1&&c.push(new Ht(o,t,'"glyphs" url must include a "{fontstack}" token')),t.indexOf("{range}")===-1&&c.push(new Ht(o,t,'"glyphs" url must include a "{range}" token'))),c}function zl(a,t=xe){return Na(ji({key:"",value:a,valueSpec:t.$root,styleSpec:t,style:a,objectElementValidators:{glyphs:Dr,"*":()=>[]}}))}const Wy=a=>Na(Eu(a)),jy=a=>Na(Zd(a));function Na(a){return a.slice().sort((t,o)=>t.line&&o.line?t.line-o.line:0)}function jm(a,t){let o=!1;if(t&&t.length)for(const c of t)a.fire(new Y(new Error(c.message))),o=!0;return o}var ho=Ma;function Ma(a,t,o){var c=this.cells=[];if(a instanceof ArrayBuffer){this.arrayBuffer=a;var d=new Int32Array(this.arrayBuffer);a=d[0],this.d=(t=d[1])+2*(o=d[2]);for(var m=0;m=D[V+0]&&c>=D[V+1])?(y[k]=!0,m.push(A[k])):y[k]=!1}}},Ma.prototype._forEachCell=function(a,t,o,c,d,m,y,v){for(var w=this._convertToCellCoord(a),A=this._convertToCellCoord(t),D=this._convertToCellCoord(o),R=this._convertToCellCoord(c),k=w;k<=D;k++)for(var V=A;V<=R;V++){var j=this.d*V+k;if((!v||v(this._convertFromCellCoord(k),this._convertFromCellCoord(V),this._convertFromCellCoord(k+1),this._convertFromCellCoord(V+1)))&&d.call(this,a,t,o,c,j,m,y,v))return}},Ma.prototype._convertFromCellCoord=function(a){return(a-this.padding)/this.scale},Ma.prototype._convertToCellCoord=function(a){return Math.max(0,Math.min(this.d-1,Math.floor(a*this.scale)+this.padding))},Ma.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var a=this.cells,t=3+this.cells.length+1+1,o=0,c=0;c=0||(d[m]=kl(a[m],t)));a instanceof Error&&(d.message=a.message)}if(d.$name)throw new Error("$name property is reserved for worker serialization logic.");return c!=="Object"&&(d.$name=c),d}throw new Error("can't serialize object of type "+typeof a)}function Ps(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||qm(a)||Su(a)||ArrayBuffer.isView(a)||a instanceof I.ImageData)return a;if(Array.isArray(a))return a.map(Ps);if(typeof a=="object"){const t=a.$name||"Object",{klass:o}=Cs[t];if(!o)throw new Error(`can't deserialize unregistered class ${t}`);if(o.deserialize)return o.deserialize(a);const c=Object.create(o.prototype);for(const d of Object.keys(a))d!=="$name"&&(c[d]=Ps(a[d]));return c}throw new Error("can't deserialize object of type "+typeof a)}class Xd{constructor(){this.first=!0}update(t,o){const c=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=c,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=c,!0):(this.lastFloorZoom>c?(this.lastIntegerZoom=c+1,this.lastIntegerZoomTime=o):this.lastFloorZooma>=1536&&a<=1791,Au=a=>a>=1872&&a<=1919,Bl=a=>a>=2208&&a<=2303,Yd=a=>a>=11904&&a<=12031,Xm=a=>a>=12032&&a<=12255,$d=a=>a>=12272&&a<=12287,Cu=a=>a>=12288&&a<=12351,Fl=a=>a>=12352&&a<=12447,Pu=a=>a>=12448&&a<=12543,Ym=a=>a>=12544&&a<=12591,$m=a=>a>=12704&&a<=12735,Jm=a=>a>=12736&&a<=12783,Jd=a=>a>=12784&&a<=12799,Km=a=>a>=12800&&a<=13055,Qm=a=>a>=13056&&a<=13311,eg=a=>a>=13312&&a<=19903,Kd=a=>a>=19968&&a<=40959,tg=a=>a>=40960&&a<=42127,ng=a=>a>=42128&&a<=42191,ig=a=>a>=44032&&a<=55215,Ol=a=>a>=63744&&a<=64255,Qd=a=>a>=64336&&a<=65023,rg=a=>a>=65040&&a<=65055,Ls=a=>a>=65072&&a<=65103,ag=a=>a>=65104&&a<=65135,Lu=a=>a>=65136&&a<=65279,ep=a=>a>=65280&&a<=65519;function Du(a){for(const t of a)if(Iu(t.charCodeAt(0)))return!0;return!1}function og(a){for(const t of a)if(!sg(t.charCodeAt(0)))return!1;return!0}function sg(a){return!(Zm(a)||Au(a)||Bl(a)||Qd(a)||Lu(a))}function Iu(a){return!(a!==746&&a!==747&&(a<4352||!($m(a)||Ym(a)||Ls(a)&&!(a>=65097&&a<=65103)||Ol(a)||Qm(a)||Yd(a)||Jm(a)||!(!Cu(a)||a>=12296&&a<=12305||a>=12308&&a<=12319||a===12336)||eg(a)||Kd(a)||Km(a)||(t=>t>=12592&&t<=12687)(a)||(t=>t>=43360&&t<=43391)(a)||(t=>t>=55216&&t<=55295)(a)||(t=>t>=4352&&t<=4607)(a)||ig(a)||Fl(a)||$d(a)||(t=>t>=12688&&t<=12703)(a)||Xm(a)||Jd(a)||Pu(a)&&a!==12540||!(!ep(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)||!(!ag(a)||a>=65112&&a<=65118||a>=65123&&a<=65126)||(t=>t>=5120&&t<=5759)(a)||(t=>t>=6320&&t<=6399)(a)||rg(a)||(t=>t>=19904&&t<=19967)(a)||tg(a)||ng(a))))}function Ru(a){return!(Iu(a)||function(t){return!!((o=>o>=128&&o<=255)(t)&&(t===167||t===169||t===174||t===177||t===188||t===189||t===190||t===215||t===247)||(o=>o>=8192&&o<=8303)(t)&&(t===8214||t===8224||t===8225||t===8240||t===8241||t===8251||t===8252||t===8258||t===8263||t===8264||t===8265||t===8273)||(o=>o>=8448&&o<=8527)(t)||(o=>o>=8528&&o<=8591)(t)||(o=>o>=8960&&o<=9215)(t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||t===9003||t>=9085&&t<=9114||t>=9150&&t<=9165||t===9167||t>=9169&&t<=9179||t>=9186&&t<=9215)||(o=>o>=9216&&o<=9279)(t)&&t!==9251||(o=>o>=9280&&o<=9311)(t)||(o=>o>=9312&&o<=9471)(t)||(o=>o>=9632&&o<=9727)(t)||(o=>o>=9728&&o<=9983)(t)&&!(t>=9754&&t<=9759)||(o=>o>=11008&&o<=11263)(t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||Cu(t)||Pu(t)||(o=>o>=57344&&o<=63743)(t)||Ls(t)||ag(t)||ep(t)||t===8734||t===8756||t===8757||t>=9984&&t<=10087||t>=10102&&t<=10131||t===65532||t===65533)}(a))}function zu(a){return a>=1424&&a<=2303||Qd(a)||Lu(a)}function qy(a,t){return!(!t&&zu(a)||a>=2304&&a<=3583||a>=3840&&a<=4255||(o=>o>=6016&&o<=6143)(a))}function Zy(a){for(const t of a)if(zu(t.charCodeAt(0)))return!0;return!1}const tp="deferred",Nl="loading",np="loaded";let ip=null,_r="unavailable",Ir=null;const Ul=function(a){a&&typeof a=="string"&&a.indexOf("NetworkError")>-1&&(_r="error"),ip&&ip(a)};function Wo(){rp.fire(new W("pluginStateChange",{pluginStatus:_r,pluginURL:Ir}))}const rp=new ze,ku=function(){return _r},Ds=function(){if(_r!==tp||!Ir)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");_r=Nl,Wo(),Ir&&Le({url:Ir},a=>{a?Ul(a):(_r=np,Wo())})},qr={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>_r===np||qr.applyArabicShaping!=null,isLoading:()=>_r===Nl,setState(a){_r=a.pluginStatus,Ir=a.pluginURL},isParsed:()=>qr.applyArabicShaping!=null&&qr.processBidirectionalText!=null&&qr.processStyledBidirectionalText!=null,getPluginURL:()=>Ir};class ci{constructor(t,o){this.zoom=t,o?(this.now=o.now,this.fadeDuration=o.fadeDuration,this.zoomHistory=o.zoomHistory,this.transition=o.transition,this.pitch=o.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Xd,this.transition={},this.pitch=0)}isSupportedScript(t){return function(o,c){for(const d of o)if(!qy(d.charCodeAt(0),c))return!1;return!0}(t,qr.isLoaded())}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,o=t-Math.floor(t),c=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:o+(1-o)*c}:{fromScale:.5,toScale:1,t:1-(1-c)*o}}}class Vl{constructor(t,o){this.property=t,this.value=o,this.expression=function(c,d){if(Ho(c))return new wu(c,d);if(Ss(c)){const m=zm(c,d);if(m.result==="error")throw new Error(m.value.map(y=>`${y.key}: ${y.message}`).join(", "));return m.value}{let m=c;return typeof c=="string"&&d.type==="color"&&(m=Xn.parse(c)),{kind:"constant",evaluate:()=>m}}}(o===void 0?t.specification.default:o,t.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(t,o,c){return this.property.possiblyEvaluate(this,t,o,c)}}class Is{constructor(t){this.property=t,this.value=new Vl(t,void 0)}transitioned(t,o){return new r(this.property,this.value,o,ye({},t.transition,this.transition),t.now)}untransitioned(){return new r(this.property,this.value,null,{},0)}}class f{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return Ot(this._values[t].value.value)}setValue(t,o){this._values.hasOwnProperty(t)||(this._values[t]=new Is(this._values[t].property)),this._values[t].value=new Vl(this._values[t].property,o===null?void 0:Ot(o))}getTransition(t){return Ot(this._values[t].transition)}setTransition(t,o){this._values.hasOwnProperty(t)||(this._values[t]=new Is(this._values[t].property)),this._values[t].transition=Ot(o)||void 0}serialize(){const t={};for(const o of Object.keys(this._values)){const c=this.getValue(o);c!==void 0&&(t[o]=c);const d=this.getTransition(o);d!==void 0&&(t[`${o}-transition`]=d)}return t}transitioned(t,o){const c=new u(this._properties);for(const d of Object.keys(this._values))c._values[d]=this._values[d].transitioned(t,o._values[d]);return c}untransitioned(){const t=new u(this._properties);for(const o of Object.keys(this._values))t._values[o]=this._values[o].untransitioned();return t}}class r{constructor(t,o,c,d,m){const y=d.delay||0,v=d.duration||0;m=m||0,this.property=t,this.value=o,this.begin=m+y,this.end=this.begin+v,t.specification.transition&&(d.delay||d.duration)&&(this.prior=c)}possiblyEvaluate(t,o,c){const d=t.now||0,m=this.value.possiblyEvaluate(t,o,c),y=this.prior;if(y){if(d>this.end)return this.prior=null,m;if(this.value.isDataDriven())return this.prior=null,m;if(dd.zoomHistory.lastIntegerZoom?{from:t,to:o,other:c}:{from:c,to:o,other:t}}interpolate(t){return t}}class F{constructor(t){this.specification=t}possiblyEvaluate(t,o,c,d){if(t.value!==void 0){if(t.expression.kind==="constant"){const m=t.expression.evaluate(o,null,{},c,d);return this._calculate(m,m,m,o)}return this._calculate(t.expression.evaluate(new ci(Math.floor(o.zoom-1),o)),t.expression.evaluate(new ci(Math.floor(o.zoom),o)),t.expression.evaluate(new ci(Math.floor(o.zoom+1),o)),o)}}_calculate(t,o,c,d){return d.zoom>d.zoomHistory.lastIntegerZoom?{from:t,to:o}:{from:c,to:o}}interpolate(t){return t}}class N{constructor(t){this.specification=t}possiblyEvaluate(t,o,c,d){return!!t.expression.evaluate(o,null,{},c,d)}interpolate(){return!1}}class H{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const o in t){const c=t[o];c.specification.overridable&&this.overridableProperties.push(o);const d=this.defaultPropertyValues[o]=new Vl(c,void 0),m=this.defaultTransitionablePropertyValues[o]=new Is(c);this.defaultTransitioningPropertyValues[o]=m.untransitioned(),this.defaultPossiblyEvaluatedValues[o]=d.possiblyEvaluate({})}}}function J(a,t){return 256*(a=ie(Math.floor(a),0,255))+ie(Math.floor(t),0,255)}jt(P,"DataDrivenProperty"),jt(S,"DataConstantProperty"),jt(z,"CrossFadedDataDrivenProperty"),jt(F,"CrossFadedProperty"),jt(N,"ColorRampProperty");const re={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Q{constructor(t,o){this._structArray=t,this._pos1=o*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class X{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,o){return t._trim(),o&&(t.isTransferred=!0,o.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const o=Object.create(this.prototype);return o.arrayBuffer=t.arrayBuffer,o.length=t.length,o.capacity=t.arrayBuffer.byteLength/o.bytesPerElement,o._refreshViews(),o}_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(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const o=this.uint8;this._refreshViews(),o&&this.uint8.set(o)}}_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 Ae(a,t=1){let o=0,c=0;return{members:a.map(d=>{const m=re[d.type].BYTES_PER_ELEMENT,y=o=fe(o,Math.max(t,m)),v=d.components||1;return c=Math.max(c,m),o+=m*v,{name:d.name,type:d.type,components:v,offset:y}}),size:fe(o,Math.max(c,t)),alignment:t}}function fe(a,t){return Math.ceil(a/t)*t}class Te extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,o){const c=this.length;return this.resize(c+1),this.emplace(c,t,o)}emplace(t,o,c){const d=2*t;return this.int16[d+0]=o,this.int16[d+1]=c,t}}Te.prototype.bytesPerElement=4,jt(Te,"StructArrayLayout2i4");class Se extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,o,c){const d=this.length;return this.resize(d+1),this.emplace(d,t,o,c)}emplace(t,o,c,d){const m=3*t;return this.int16[m+0]=o,this.int16[m+1]=c,this.int16[m+2]=d,t}}Se.prototype.bytesPerElement=6,jt(Se,"StructArrayLayout3i6");class Re extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,o,c,d){const m=this.length;return this.resize(m+1),this.emplace(m,t,o,c,d)}emplace(t,o,c,d,m){const y=4*t;return this.int16[y+0]=o,this.int16[y+1]=c,this.int16[y+2]=d,this.int16[y+3]=m,t}}Re.prototype.bytesPerElement=8,jt(Re,"StructArrayLayout4i8");class be extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y,v){const w=this.length;return this.resize(w+1),this.emplace(w,t,o,c,d,m,y,v)}emplace(t,o,c,d,m,y,v,w){const A=6*t,D=12*t,R=3*t;return this.int16[A+0]=o,this.int16[A+1]=c,this.uint8[D+4]=d,this.uint8[D+5]=m,this.uint8[D+6]=y,this.uint8[D+7]=v,this.float32[R+2]=w,t}}be.prototype.bytesPerElement=12,jt(be,"StructArrayLayout2i4ub1f12");class Fe extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,o,c,d){const m=this.length;return this.resize(m+1),this.emplace(m,t,o,c,d)}emplace(t,o,c,d,m){const y=4*t;return this.float32[y+0]=o,this.float32[y+1]=c,this.float32[y+2]=d,this.float32[y+3]=m,t}}Fe.prototype.bytesPerElement=16,jt(Fe,"StructArrayLayout4f16");class Qe extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y,v,w,A,D){const R=this.length;return this.resize(R+1),this.emplace(R,t,o,c,d,m,y,v,w,A,D)}emplace(t,o,c,d,m,y,v,w,A,D,R){const k=10*t;return this.uint16[k+0]=o,this.uint16[k+1]=c,this.uint16[k+2]=d,this.uint16[k+3]=m,this.uint16[k+4]=y,this.uint16[k+5]=v,this.uint16[k+6]=w,this.uint16[k+7]=A,this.uint16[k+8]=D,this.uint16[k+9]=R,t}}Qe.prototype.bytesPerElement=20,jt(Qe,"StructArrayLayout10ui20");class at extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y,v,w){const A=this.length;return this.resize(A+1),this.emplace(A,t,o,c,d,m,y,v,w)}emplace(t,o,c,d,m,y,v,w,A){const D=8*t;return this.uint16[D+0]=o,this.uint16[D+1]=c,this.uint16[D+2]=d,this.uint16[D+3]=m,this.uint16[D+4]=y,this.uint16[D+5]=v,this.uint16[D+6]=w,this.uint16[D+7]=A,t}}at.prototype.bytesPerElement=16,jt(at,"StructArrayLayout8ui16");class dt extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y){const v=this.length;return this.resize(v+1),this.emplace(v,t,o,c,d,m,y)}emplace(t,o,c,d,m,y,v){const w=6*t;return this.int16[w+0]=o,this.int16[w+1]=c,this.int16[w+2]=d,this.int16[w+3]=m,this.int16[w+4]=y,this.int16[w+5]=v,t}}dt.prototype.bytesPerElement=12,jt(dt,"StructArrayLayout6i12");class ut extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne){const me=this.length;return this.resize(me+1),this.emplace(me,t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne)}emplace(t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne,me){const ke=16*t;return this.int16[ke+0]=o,this.int16[ke+1]=c,this.int16[ke+2]=d,this.int16[ke+3]=m,this.uint16[ke+4]=y,this.uint16[ke+5]=v,this.uint16[ke+6]=w,this.uint16[ke+7]=A,this.int16[ke+8]=D,this.int16[ke+9]=R,this.int16[ke+10]=k,this.int16[ke+11]=V,this.int16[ke+12]=j,this.int16[ke+13]=$,this.int16[ke+14]=ne,this.int16[ke+15]=me,t}}ut.prototype.bytesPerElement=32,jt(ut,"StructArrayLayout4i4ui4i4i32");class Rt extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,o,c){const d=this.length;return this.resize(d+1),this.emplace(d,t,o,c)}emplace(t,o,c,d){const m=3*t;return this.float32[m+0]=o,this.float32[m+1]=c,this.float32[m+2]=d,t}}Rt.prototype.bytesPerElement=12,jt(Rt,"StructArrayLayout3f12");class et extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const o=this.length;return this.resize(o+1),this.emplace(o,t)}emplace(t,o){return this.uint32[1*t+0]=o,t}}et.prototype.bytesPerElement=4,jt(et,"StructArrayLayout1ul4");class zt extends X{_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(t,o,c,d,m,y,v,w,A,D,R,k,V){const j=this.length;return this.resize(j+1),this.emplace(j,t,o,c,d,m,y,v,w,A,D,R,k,V)}emplace(t,o,c,d,m,y,v,w,A,D,R,k,V,j){const $=20*t,ne=10*t;return this.int16[$+0]=o,this.int16[$+1]=c,this.int16[$+2]=d,this.int16[$+3]=m,this.int16[$+4]=y,this.float32[ne+3]=v,this.float32[ne+4]=w,this.float32[ne+5]=A,this.float32[ne+6]=D,this.int16[$+14]=R,this.uint32[ne+8]=k,this.uint16[$+18]=V,this.uint16[$+19]=j,t}}zt.prototype.bytesPerElement=40,jt(zt,"StructArrayLayout5i4f1i1ul2ui40");class Pt extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y,v){const w=this.length;return this.resize(w+1),this.emplace(w,t,o,c,d,m,y,v)}emplace(t,o,c,d,m,y,v,w){const A=8*t;return this.int16[A+0]=o,this.int16[A+1]=c,this.int16[A+2]=d,this.int16[A+4]=m,this.int16[A+5]=y,this.int16[A+6]=v,this.int16[A+7]=w,t}}Pt.prototype.bytesPerElement=16,jt(Pt,"StructArrayLayout3i2i2i16");class Jt extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m){const y=this.length;return this.resize(y+1),this.emplace(y,t,o,c,d,m)}emplace(t,o,c,d,m,y){const v=4*t,w=8*t;return this.float32[v+0]=o,this.float32[v+1]=c,this.float32[v+2]=d,this.int16[w+6]=m,this.int16[w+7]=y,t}}Jt.prototype.bytesPerElement=16,jt(Jt,"StructArrayLayout2f1f2i16");class pt extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,o,c,d){const m=this.length;return this.resize(m+1),this.emplace(m,t,o,c,d)}emplace(t,o,c,d,m){const y=12*t,v=3*t;return this.uint8[y+0]=o,this.uint8[y+1]=c,this.float32[v+1]=d,this.float32[v+2]=m,t}}pt.prototype.bytesPerElement=12,jt(pt,"StructArrayLayout2ub2f12");class qt extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,o,c){const d=this.length;return this.resize(d+1),this.emplace(d,t,o,c)}emplace(t,o,c,d){const m=3*t;return this.uint16[m+0]=o,this.uint16[m+1]=c,this.uint16[m+2]=d,t}}qt.prototype.bytesPerElement=6,jt(qt,"StructArrayLayout3ui6");class mn extends X{_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(t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne,me,ke,He,Ze,Xe){const Ye=this.length;return this.resize(Ye+1),this.emplace(Ye,t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne,me,ke,He,Ze,Xe)}emplace(t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne,me,ke,He,Ze,Xe,Ye){const lt=30*t,ht=15*t,vt=60*t;return this.int16[lt+0]=o,this.int16[lt+1]=c,this.int16[lt+2]=d,this.float32[ht+2]=m,this.float32[ht+3]=y,this.uint16[lt+8]=v,this.uint16[lt+9]=w,this.uint32[ht+5]=A,this.uint32[ht+6]=D,this.uint32[ht+7]=R,this.uint16[lt+16]=k,this.uint16[lt+17]=V,this.uint16[lt+18]=j,this.float32[ht+10]=$,this.float32[ht+11]=ne,this.uint8[vt+48]=me,this.uint8[vt+49]=ke,this.uint8[vt+50]=He,this.uint32[ht+13]=Ze,this.int16[lt+28]=Xe,this.uint8[vt+58]=Ye,t}}mn.prototype.bytesPerElement=60,jt(mn,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Xt extends X{_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(t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne,me,ke,He,Ze,Xe,Ye,lt,ht,vt,Tt,rt,ft,Ct,Bt){const It=this.length;return this.resize(It+1),this.emplace(It,t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne,me,ke,He,Ze,Xe,Ye,lt,ht,vt,Tt,rt,ft,Ct,Bt)}emplace(t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne,me,ke,He,Ze,Xe,Ye,lt,ht,vt,Tt,rt,ft,Ct,Bt,It){const kt=38*t,En=19*t;return this.int16[kt+0]=o,this.int16[kt+1]=c,this.int16[kt+2]=d,this.float32[En+2]=m,this.float32[En+3]=y,this.int16[kt+8]=v,this.int16[kt+9]=w,this.int16[kt+10]=A,this.int16[kt+11]=D,this.int16[kt+12]=R,this.int16[kt+13]=k,this.uint16[kt+14]=V,this.uint16[kt+15]=j,this.uint16[kt+16]=$,this.uint16[kt+17]=ne,this.uint16[kt+18]=me,this.uint16[kt+19]=ke,this.uint16[kt+20]=He,this.uint16[kt+21]=Ze,this.uint16[kt+22]=Xe,this.uint16[kt+23]=Ye,this.uint16[kt+24]=lt,this.uint16[kt+25]=ht,this.uint16[kt+26]=vt,this.uint16[kt+27]=Tt,this.uint16[kt+28]=rt,this.uint32[En+15]=ft,this.float32[En+16]=Ct,this.float32[En+17]=Bt,this.float32[En+18]=It,t}}Xt.prototype.bytesPerElement=76,jt(Xt,"StructArrayLayout3i2f6i15ui1ul3f76");class Yt extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const o=this.length;return this.resize(o+1),this.emplace(o,t)}emplace(t,o){return this.float32[1*t+0]=o,t}}Yt.prototype.bytesPerElement=4,jt(Yt,"StructArrayLayout1f4");class vn extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y,v){const w=this.length;return this.resize(w+1),this.emplace(w,t,o,c,d,m,y,v)}emplace(t,o,c,d,m,y,v,w){const A=7*t;return this.float32[A+0]=o,this.float32[A+1]=c,this.float32[A+2]=d,this.float32[A+3]=m,this.float32[A+4]=y,this.float32[A+5]=v,this.float32[A+6]=w,t}}vn.prototype.bytesPerElement=28,jt(vn,"StructArrayLayout7f28");class kn extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m){const y=this.length;return this.resize(y+1),this.emplace(y,t,o,c,d,m)}emplace(t,o,c,d,m,y){const v=5*t;return this.float32[v+0]=o,this.float32[v+1]=c,this.float32[v+2]=d,this.float32[v+3]=m,this.float32[v+4]=y,t}}kn.prototype.bytesPerElement=20,jt(kn,"StructArrayLayout5f20");class hn extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,o,c,d){const m=this.length;return this.resize(m+1),this.emplace(m,t,o,c,d)}emplace(t,o,c,d,m){const y=6*t;return this.uint32[3*t+0]=o,this.uint16[y+2]=c,this.uint16[y+3]=d,this.uint16[y+4]=m,t}}hn.prototype.bytesPerElement=12,jt(hn,"StructArrayLayout1ul3ui12");class Mn extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,o){const c=this.length;return this.resize(c+1),this.emplace(c,t,o)}emplace(t,o,c){const d=2*t;return this.uint16[d+0]=o,this.uint16[d+1]=c,t}}Mn.prototype.bytesPerElement=4,jt(Mn,"StructArrayLayout2ui4");class qn extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const o=this.length;return this.resize(o+1),this.emplace(o,t)}emplace(t,o){return this.uint16[1*t+0]=o,t}}qn.prototype.bytesPerElement=2,jt(qn,"StructArrayLayout1ui2");class vi extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,o){const c=this.length;return this.resize(c+1),this.emplace(c,t,o)}emplace(t,o,c){const d=2*t;return this.float32[d+0]=o,this.float32[d+1]=c,t}}vi.prototype.bytesPerElement=8,jt(vi,"StructArrayLayout2f8");class nr extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y,v){const w=this.length;return this.resize(w+1),this.emplace(w,t,o,c,d,m,y,v)}emplace(t,o,c,d,m,y,v,w){const A=8*t,D=4*t;return this.int16[A+0]=o,this.int16[A+1]=c,this.int16[A+2]=d,this.int16[A+3]=m,this.int16[A+4]=y,this.int16[A+5]=v,this.float32[D+3]=w,t}}nr.prototype.bytesPerElement=16,jt(nr,"StructArrayLayout6i1f16");class ir extends Q{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 Rr extends dt{get(t){return new ir(this,t)}}jt(Rr,"FillExtrusionExtArray");class ma extends Q{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]}}ma.prototype.size=40;class Ua extends zt{get(t){return new ma(this,t)}}jt(Ua,"CollisionBoxArray");class po extends Q{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(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}po.prototype.size=60;class Va extends mn{get(t){return new po(this,t)}}jt(Va,"PlacedSymbolArray");class bi extends Q{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(t){this._structArray.uint32[this._pos4+15]=t}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 Xt{get(t){return new bi(this,t)}}jt(Ti,"SymbolInstanceArray");class $n extends Yt{getoffsetX(t){return this.float32[1*t+0]}}jt($n,"GlyphOffsetArray");class Li extends Se{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}jt(Li,"SymbolLineVertexArray");class zr extends Q{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 hn{get(t){return new zr(this,t)}}jt(xi,"FeatureIndexArray");class Zr extends Q{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}Zr.prototype.size=4;class Gl extends Mn{get(t){return new Zr(this,t)}}jt(Gl,"FillExtrusionCentroidArray");class kr extends Q{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]}}kr.prototype.size=16;class jo extends nr{get(t){return new kr(this,t)}}jt(jo,"CircleGlobeExtArray");const lg=Ae([{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"}]),ap=Ae([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var Rs=ru(function(a){a.exports=function(t,o){var c,d,m,y,v,w,A,D;for(d=t.length-(c=3&t.length),m=o,v=3432918353,w=461845907,D=0;D>>16)*v&65535)<<16)&4294967295)<<15|A>>>17))*w+(((A>>>16)*w&65535)<<16)&4294967295)<<13|m>>>19))+((5*(m>>>16)&65535)<<16)&4294967295))+((58964+(y>>>16)&65535)<<16);switch(A=0,c){case 3:A^=(255&t.charCodeAt(D+2))<<16;case 2:A^=(255&t.charCodeAt(D+1))<<8;case 1:m^=A=(65535&(A=(A=(65535&(A^=255&t.charCodeAt(D)))*v+(((A>>>16)*v&65535)<<16)&4294967295)<<15|A>>>17))*w+(((A>>>16)*w&65535)<<16)&4294967295}return m^=t.length,m=2246822507*(65535&(m^=m>>>16))+((2246822507*(m>>>16)&65535)<<16)&4294967295,m=3266489909*(65535&(m^=m>>>13))+((3266489909*(m>>>16)&65535)<<16)&4294967295,(m^=m>>>16)>>>0}}),Xy=ru(function(a){a.exports=function(t,o){for(var c,d=t.length,m=o^d,y=0;d>=4;)c=1540483477*(65535&(c=255&t.charCodeAt(y)|(255&t.charCodeAt(++y))<<8|(255&t.charCodeAt(++y))<<16|(255&t.charCodeAt(++y))<<24))+((1540483477*(c>>>16)&65535)<<16),m=1540483477*(65535&m)+((1540483477*(m>>>16)&65535)<<16)^(c=1540483477*(65535&(c^=c>>>24))+((1540483477*(c>>>16)&65535)<<16)),d-=4,++y;switch(d){case 3:m^=(255&t.charCodeAt(y+2))<<16;case 2:m^=(255&t.charCodeAt(y+1))<<8;case 1:m=1540483477*(65535&(m^=255&t.charCodeAt(y)))+((1540483477*(m>>>16)&65535)<<16)}return m=1540483477*(65535&(m^=m>>>13))+((1540483477*(m>>>16)&65535)<<16),(m^=m>>>15)>>>0}}),fo=Rs,op=Xy;fo.murmur3=Rs,fo.murmur2=op;class cg{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,o,c,d){this.ids.push(Y1(t)),this.positions.push(o,c,d)}getPositions(t){const o=Y1(t);let c=0,d=this.ids.length-1;for(;c>1;this.ids[y]>=o?d=y:c=y+1}const m=[];for(;this.ids[c]===o;)m.push({index:this.positions[3*c],start:this.positions[3*c+1],end:this.positions[3*c+2]}),c++;return m}static serialize(t,o){const c=new Float64Array(t.ids),d=new Uint32Array(t.positions);return Yy(c,d,0,c.length-1),o&&o.push(c.buffer,d.buffer),{ids:c,positions:d}}static deserialize(t){const o=new cg;return o.ids=t.ids,o.positions=t.positions,o.indexed=!0,o}}function Y1(a){const t=+a;return!isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:fo(String(a))}function Yy(a,t,o,c){for(;o>1];let m=o-1,y=c+1;for(;;){do m++;while(a[m]d);if(m>=y)break;ug(a,m,y),ug(t,3*m,3*y),ug(t,3*m+1,3*y+1),ug(t,3*m+2,3*y+2)}y-o`u_${d}`),this.type=c}setUniform(t,o,c){t.set(c.constantOr(this.value))}getBinding(t,o,c){return this.type==="color"?new J1(t,o):new hg(t,o)}}class Bu{constructor(t,o){this.uniformNames=o.map(c=>`u_${c}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,o){this.pixelRatioFrom=o.pixelRatio||1,this.pixelRatioTo=t.pixelRatio||1,this.patternFrom=o.tl.concat(o.br),this.patternTo=t.tl.concat(t.br)}setUniform(t,o,c,d){const m=d==="u_pattern_to"||d==="u_dash_to"?this.patternTo:d==="u_pattern_from"||d==="u_dash_from"?this.patternFrom:d==="u_pixel_ratio_to"?this.pixelRatioTo:d==="u_pixel_ratio_from"?this.pixelRatioFrom:null;m&&t.set(m)}getBinding(t,o,c){return c==="u_pattern_from"||c==="u_pattern_to"||c==="u_dash_from"||c==="u_dash_to"?new $1(t,o):new hg(t,o)}}class Zo{constructor(t,o,c,d){this.expression=t,this.type=c,this.maxValue=0,this.paintVertexAttributes=o.map(m=>({name:`a_${m}`,type:"Float32",components:c==="color"?2:1,offset:0})),this.paintVertexArray=new d}populatePaintArray(t,o,c,d,m,y){const v=this.paintVertexArray.length,w=this.expression.evaluate(new ci(0),o,{},m,d,y);this.paintVertexArray.resize(t),this._setPaintValue(v,t,w)}updatePaintArray(t,o,c,d,m){const y=this.expression.evaluate({zoom:0},c,d,void 0,m);this._setPaintValue(t,o,y)}_setPaintValue(t,o,c){if(this.type==="color"){const d=$y(c);for(let m=t;m`u_${v}_t`),this.type=c,this.useIntegerZoom=d,this.zoom=m,this.maxValue=0,this.paintVertexAttributes=o.map(v=>({name:`a_${v}`,type:"Float32",components:c==="color"?4:2,offset:0})),this.paintVertexArray=new y}populatePaintArray(t,o,c,d,m,y){const v=this.expression.evaluate(new ci(this.zoom),o,{},m,d,y),w=this.expression.evaluate(new ci(this.zoom+1),o,{},m,d,y),A=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(A,t,v,w)}updatePaintArray(t,o,c,d,m){const y=this.expression.evaluate({zoom:this.zoom},c,d,void 0,m),v=this.expression.evaluate({zoom:this.zoom+1},c,d,void 0,m);this._setPaintValue(t,o,y,v)}_setPaintValue(t,o,c,d){if(this.type==="color"){const m=$y(c),y=$y(d);for(let v=t;v!0){this.binders={},this._buffers=[];const d=[];for(const m in t.paint._values){if(!c(m))continue;const y=t.paint.get(m);if(!(y instanceof x&&Es(y.property.specification)))continue;const v=OL(m,t.type),w=y.value,A=y.property.specification.type,D=y.property.useIntegerZoom,R=y.property.specification["property-type"],k=R==="cross-faded"||R==="cross-faded-data-driven",V=String(m)==="line-dasharray"&&t.layout.get("line-cap").value.kind!=="constant";if(w.kind!=="constant"||V)if(w.kind==="source"||V||k){const j=K1(m,A,"source");this.binders[m]=k?new zs(w,v,A,D,o,j,t.id):new Zo(w,v,A,j),d.push(`/a_${m}`)}else{const j=K1(m,A,"composite");this.binders[m]=new Ga(w,v,A,D,o,j),d.push(`/z_${m}`)}else this.binders[m]=k?new Bu(w.value,v):new sp(w.value,v,A),d.push(`/u_${m}`)}this.cacheKey=d.sort().join("")}getMaxValue(t){const o=this.binders[t];return o instanceof Zo||o instanceof Ga?o.maxValue:0}populatePaintArrays(t,o,c,d,m,y){for(const v in this.binders){const w=this.binders[v];(w instanceof Zo||w instanceof Ga||w instanceof zs)&&w.populatePaintArray(t,o,c,d,m,y)}}setConstantPatternPositions(t,o){for(const c in this.binders){const d=this.binders[c];d instanceof Bu&&d.setConstantPatternPositions(t,o)}}updatePaintArrays(t,o,c,d,m,y){let v=!1;for(const w in t){const A=o.getPositions(w);for(const D of A){const R=c.feature(D.index);for(const k in this.binders){const V=this.binders[k];if((V instanceof Zo||V instanceof Ga||V instanceof zs)&&V.expression.isStateDependent===!0){const j=d.paint.get(k);V.expression=j.value,V.updatePaintArray(D.start,D.end,R,t[w],m,y),v=!0}}}}return v}defines(){const t=[];for(const o in this.binders){const c=this.binders[o];(c instanceof sp||c instanceof Bu)&&t.push(...c.uniformNames.map(d=>`#define HAS_UNIFORM_${d}`))}return t}getBinderAttributes(){const t=[];for(const o in this.binders){const c=this.binders[o];if(c instanceof Zo||c instanceof Ga||c instanceof zs)for(let d=0;d!0){this.programConfigurations={};for(const d of t)this.programConfigurations[d.id]=new ks(d,o,c);this.needsUpload=!1,this._featureMap=new cg,this._bufferOffset=0}populatePaintArrays(t,o,c,d,m,y,v){for(const w in this.programConfigurations)this.programConfigurations[w].populatePaintArrays(t,o,d,m,y,v);o.id!==void 0&&this._featureMap.add(o.id,c,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,o,c,d,m){for(const y of c)this.needsUpload=this.programConfigurations[y.id].updatePaintArrays(t,this._featureMap,o,y,d,m)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const o in this.programConfigurations)this.programConfigurations[o].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const FL={"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 OL(a,t){return FL[a]||[a.replace(`${t}-`,"").replace(/-/g,"_")]}const NL={"line-pattern":{source:Qe,composite:Qe},"fill-pattern":{source:Qe,composite:Qe},"fill-extrusion-pattern":{source:Qe,composite:Qe},"line-dasharray":{source:at,composite:at}},UL={color:{source:vi,composite:Fe},number:{source:Yt,composite:vi}};function K1(a,t,o){const c=NL[a];return c&&c[o]||UL[t][o]}jt(sp,"ConstantBinder"),jt(Bu,"CrossFadedConstantBinder"),jt(Zo,"SourceExpressionBinder"),jt(zs,"CrossFadedCompositeBinder"),jt(Ga,"CompositeExpressionBinder"),jt(ks,"ProgramConfiguration",{omit:["_buffers"]}),jt(Hl,"ProgramConfigurationSet");const dg="-transition";class Ha extends ze{constructor(t,o){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,t.type!=="custom"&&(this.metadata=(t=t).metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,t.type!=="background"&&t.type!=="sky"&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),o.layout&&(this._unevaluatedLayout=new g(o.layout)),o.paint)){this._transitionablePaint=new f(o.paint);for(const c in t.paint)this.setPaintProperty(c,t.paint[c],{validate:!1});for(const c in t.layout)this.setLayoutProperty(c,t.layout[c],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new b(o.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return t==="visibility"?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,o,c={}){o!=null&&this._validate(jy,`layers.${this.id}.layout.${t}`,t,o,c)||(t!=="visibility"?this._unevaluatedLayout.setValue(t,o):this.visibility=o)}getPaintProperty(t){return gt(t,dg)?this._transitionablePaint.getTransition(t.slice(0,-dg.length)):this._transitionablePaint.getValue(t)}setPaintProperty(t,o,c={}){if(o!=null&&this._validate(Wy,`layers.${this.id}.paint.${t}`,t,o,c))return!1;if(gt(t,dg))return this._transitionablePaint.setTransition(t.slice(0,-dg.length),o||void 0),!1;{const d=this._transitionablePaint._values[t],m=d.property.specification["property-type"]==="cross-faded-data-driven",y=d.value.isDataDriven(),v=d.value;this._transitionablePaint.setValue(t,o),this._handleSpecialPaintPropertyUpdate(t);const w=this._transitionablePaint._values[t].value;return w.isDataDriven()||y||m||this._handleOverridablePaintPropertyUpdate(t,v,w)}}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getProgramConfiguration(t){return null}_handleOverridablePaintPropertyUpdate(t,o,c){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||this.visibility==="none"}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,o){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,o)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,o)}serialize(){const t={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&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),Dt(t,(o,c)=>!(o===void 0||c==="layout"&&!Object.keys(o).length||c==="paint"&&!Object.keys(o).length))}_validate(t,o,c,d,m={}){return(!m||m.validate!==!1)&&jm(this,t.call(zl,{key:o,layerType:this.type,objectKey:c,value:d,styleSpec:xe,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const o=this.paint.get(t);if(o instanceof x&&Es(o.property.specification)&&(o.value.kind==="source"||o.value.kind==="composite")&&o.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=lo(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const VL=Ae([{name:"a_pos",components:2,type:"Int16"}],4),GL=Ae([{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(t=[]){this.segments=t}prepareSegment(t,o,c,d){let m=this.segments[this.segments.length-1];return t>Ei.MAX_VERTEX_ARRAY_LENGTH&&ge(`Max vertices per segment is ${Ei.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!m||m.vertexLength+t>Ei.MAX_VERTEX_ARRAY_LENGTH||m.sortKey!==d)&&(m={vertexOffset:o.length,primitiveOffset:c.length,vertexLength:0,primitiveLength:0},d!==void 0&&(m.sortKey=d),this.segments.push(m)),m}get(){return this.segments}destroy(){for(const t of this.segments)for(const o in t.vaos)t.vaos[o].destroy()}static simpleSegment(t,o,c,d){return new Ei([{vertexOffset:t,primitiveOffset:o,vertexLength:c,primitiveLength:d,vaos:{},sortKey:0}])}}Ei.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,jt(Ei,"SegmentVector");var In=8192;class Bs{constructor(t,o){t&&(o?this.setSouthWest(t).setNorthEast(o):t.length===4?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))}setNorthEast(t){return this._ne=t instanceof ti?new ti(t.lng,t.lat):ti.convert(t),this}setSouthWest(t){return this._sw=t instanceof ti?new ti(t.lng,t.lat):ti.convert(t),this}extend(t){const o=this._sw,c=this._ne;let d,m;if(t instanceof ti)d=t,m=t;else{if(!(t instanceof Bs))return Array.isArray(t)?t.length===4||t.every(Array.isArray)?this.extend(Bs.convert(t)):this.extend(ti.convert(t)):this;if(d=t._sw,m=t._ne,!d||!m)return this}return o||c?(o.lng=Math.min(d.lng,o.lng),o.lat=Math.min(d.lat,o.lat),c.lng=Math.max(m.lng,c.lng),c.lat=Math.max(m.lat,c.lat)):(this._sw=new ti(d.lng,d.lat),this._ne=new ti(m.lng,m.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(t){const{lng:o,lat:c}=ti.convert(t);let d=this._sw.lng<=o&&o<=this._ne.lng;return this._sw.lng>this._ne.lng&&(d=this._sw.lng>=o&&o>=this._ne.lng),this._sw.lat<=c&&c<=this._ne.lat&&d}static convert(t){return!t||t instanceof Bs?t:new Bs(t)}}const Jy=63710088e-1;class ti{constructor(t,o){if(isNaN(t)||isNaN(o))throw new Error(`Invalid LngLat object: (${t}, ${o})`);if(this.lng=+t,this.lat=+o,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new ti(ae(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const o=Math.PI/180,c=this.lat*o,d=t.lat*o,m=Math.sin(c)*Math.sin(d)+Math.cos(c)*Math.cos(d)*Math.cos((t.lng-this.lng)*o);return Jy*Math.acos(Math.min(m,1))}toBounds(t=0){const o=360*t/40075017,c=o/Math.cos(Math.PI/180*this.lat);return new Bs(new ti(this.lng-c,this.lat-o),new ti(this.lng+c,this.lat+o))}static convert(t){if(t instanceof ti)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new ti(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t!==null)return new ti(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const Q1=2*Math.PI*Jy;function Ky(a){return Q1*Math.cos(a*Math.PI/180)}function lp(a){return(180+a)/360}function Fu(a){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a*Math.PI/360)))/360}function Ou(a,t){return a/Ky(t)}function Ta(a){return 360*a-180}function rr(a){return 360/Math.PI*Math.atan(Math.exp((180-360*a)*Math.PI/180))-90}function eb(a,t){return a*Ky(rr(t))}const mo=85.051129;class pg{constructor(t,o,c=0){this.x=+t,this.y=+o,this.z=+c}static fromLngLat(t,o=0){const c=ti.convert(t);return new pg(lp(c.lng),Fu(c.lat),Ou(o,c.lat))}toLngLat(){return new ti(Ta(this.x),rr(this.y))}toAltitude(){return eb(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Q1*(t=rr(this.y),1/Math.cos(t*Math.PI/180));var t}}function Qy(a,t,o,c,d,m,y,v,w){const A=(t+c)/2,D=(o+d)/2,R=new E(A,D);v(R),function(k,V,j,$,ne,me){const ke=j-ne,He=$-me;return Math.abs(($-V)*ke-(j-k)*He)/Math.hypot(ke,He)}(R.x,R.y,m.x,m.y,y.x,y.y)>=w?(Qy(a,t,o,A,D,m,R,v,w),Qy(a,A,D,c,d,R,y,v,w)):a.push(y)}function HL(a,t,o){let c=a[0],d=c.x,m=c.y;t(c);const y=[c];for(let v=1;va.x+1||ca.y+1)&&ge("Geometry exceeds allowed extent, reduce your vector tile buffer size"),a}function Xo(a,t,o){const c=a.loadGeometry(),d=a.extent,m=In/d;if(t&&o&&o.projection.isReprojectedInTileSpace){const y=1<{const V=Ta((t.x+k.x/d)/y),j=rr((t.y+k.y/d)/y),$=D.project(V,j);k.x=($.x*v-w)*d,k.y=($.y*v-A)*d};for(let k=0;k=d||j.y<0||j.y>=d||(R(j),V.push(j));c[k]=V}}for(const y of c)for(const v of y)WL(v,m);return c}function Wl(a,t){return{type:a.type,id:a.id,properties:a.properties,geometry:t?Xo(a):[]}}function fg(a,t,o,c,d){a.emplaceBack(2*t+(c+1)/2,2*o+(d+1)/2)}function mg(a,t,o,c){a.emplaceBack(t.x,t.y,t.z,o[0]*16384,o[1]*16384,o[2]*16384,c)}class tv{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(o=>o.id),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new Te,this.indexArray=new qt,this.segments=new Ei,this.programConfigurations=new Hl(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id)}populate(t,o,c,d){const m=this.layers[0],y=[];let v=null;m.type==="circle"&&(v=m.layout.get("circle-sort-key"));for(const{feature:A,id:D,index:R,sourceLayerIndex:k}of t){const V=this.layers[0]._featureFilter.needGeometry,j=Wl(A,V);if(!this.layers[0]._featureFilter.filter(new ci(this.zoom),j,c))continue;const $=v?v.evaluate(j,{},c):void 0,ne={id:D,properties:A.properties,type:A.type,sourceLayerIndex:k,index:R,geometry:V?j.geometry:Xo(A,c,d),patterns:{},sortKey:$};y.push(ne)}v&&y.sort((A,D)=>A.sortKey-D.sortKey);let w=null;d.projection.name==="globe"&&(this.globeExtVertexArray=new jo,w=d.projection);for(const A of y){const{geometry:D,index:R,sourceLayerIndex:k}=A,V=t[R].feature;this.addFeature(A,D,R,o.availableImages,c,w),o.featureIndex.insert(V,D,R,k,this.index)}}update(t,o,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,o,this.stateDependentLayers,c,d)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,VL.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,GL.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,o,c,d,m,y){for(const v of o)for(const w of v){const A=w.x,D=w.y;if(A<0||A>=In||D<0||D>=In)continue;if(y){const V=y.projectTilePoint(A,D,m),j=y.upVector(m,A,D),$=rr((D/In+m.y)/(1<1){if(nv(a,t))return!0;for(let c=0;c1?o:o.sub(t)._mult(d)._add(t))}function ab(a,t){let o,c,d,m=!1;for(let y=0;yt.y!=d.y>t.y&&t.x<(d.x-c.x)*(t.y-c.y)/(d.y-c.y)+c.x&&(m=!m)}return m}function Nu(a,t){let o=!1;for(let c=0,d=a.length-1;ct.y!=y.y>t.y&&t.x<(y.x-m.x)*(t.y-m.y)/(y.y-m.y)+m.x&&(o=!o)}return o}function ob(a,t,o,c,d){for(const y of a)if(t<=y.x&&o<=y.y&&c>=y.x&&d>=y.y)return!0;const m=[new E(t,o),new E(t,d),new E(c,d),new E(c,o)];if(a.length>2){for(const y of m)if(Nu(a,y))return!0}for(let y=0;yd.x&&t.x>d.x||a.yd.y&&t.y>d.y)return!1;const m=Ve(a,t,o[0]);return m!==Ve(a,t,o[1])||m!==Ve(a,t,o[2])||m!==Ve(a,t,o[3])}function Uu(a,t,o){const c=t.paint.get(a).value;return c.kind==="constant"?c.value:o.programConfigurations.get(t.id).getMaxValue(a)}function gg(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1])}function sb(a,t,o,c,d){if(!t[0]&&!t[1])return a;const m=E.convert(t)._mult(d);o==="viewport"&&m._rotate(-c);const y=[];for(let v=0;v0&&(m=1/Math.sqrt(m)),a[0]=t[0]*m,a[1]=t[1]*m,a[2]=t[2]*m,a}function dp(a,t){return a[0]*t[0]+a[1]*t[1]+a[2]*t[2]}function mb(a,t,o){var c=t[0],d=t[1],m=t[2],y=o[0],v=o[1],w=o[2];return a[0]=d*w-m*v,a[1]=m*y-c*w,a[2]=c*v-d*y,a}function ql(a,t,o){var c=t[0],d=t[1],m=t[2],y=o[3]*c+o[7]*d+o[11]*m+o[15];return a[0]=(o[0]*c+o[4]*d+o[8]*m+o[12])/(y=y||1),a[1]=(o[1]*c+o[5]*d+o[9]*m+o[13])/y,a[2]=(o[2]*c+o[6]*d+o[10]*m+o[14])/y,a}function gb(a,t,o){var c=o[0],d=o[1],m=o[2],y=t[0],v=t[1],w=t[2],A=d*w-m*v,D=m*y-c*w,R=c*v-d*y,k=d*R-m*D,V=m*A-c*R,j=c*D-d*A,$=2*o[3];return D*=$,R*=$,V*=2,j*=2,a[0]=y+(A*=$)+(k*=2),a[1]=v+D+V,a[2]=w+R+j,a}var pp,Vu=pb,KL=fb,QL=hb;function Gu(a,t,o){var c=t[0],d=t[1],m=t[2],y=t[3];return a[0]=o[0]*c+o[4]*d+o[8]*m+o[12]*y,a[1]=o[1]*c+o[5]*d+o[9]*m+o[13]*y,a[2]=o[2]*c+o[6]*d+o[10]*m+o[14]*y,a[3]=o[3]*c+o[7]*d+o[11]*m+o[15]*y,a}function _b(){var a=new Xr(4);return Xr!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a[3]=1,a}function yb(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a}function vb(a,t,o){o*=.5;var c=t[0],d=t[1],m=t[2],y=t[3],v=Math.sin(o),w=Math.cos(o);return a[0]=c*w+y*v,a[1]=d*w+m*v,a[2]=m*w-d*v,a[3]=y*w-c*v,a}lv(),pp=new Xr(4),Xr!=Float32Array&&(pp[0]=0,pp[1]=0,pp[2]=0,pp[3]=0),lv(),cp(1,0,0),cp(0,1,0),_b(),_b(),cb();class dv{constructor(t,o){this.points=t,this.planes=o}static fromInvProjectionMatrix(t,o,c,d){const m=Math.pow(2,c),y=[[-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(w=>{const A=Gu([],w,t),D=1/A[3]/o*m;return function(R,k,V){return R[0]=k[0]*V[0],R[1]=k[1]*V[1],R[2]=k[2]*V[2],R[3]=k[3]*V[3],R}(A,A,[D,D,d?1/A[3]:D,D])}),v=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(w=>{const A=hp([],mb([],Vu([],y[w[0]],y[w[1]]),Vu([],y[w[2]],y[w[1]]))),D=-dp(A,y[w[1]]);return A.concat(D)});return new dv(y,v)}}class ga{constructor(t,o){this.min=t,this.max=o,this.center=up([],db([],this.min,this.max),.5)}quadrant(t){const o=[t%2==0,t<2],c=ub(this.min),d=ub(this.max);for(let m=0;m=0;if(y===0)return 0;y!==o.length&&(c=!1)}if(c)return 2;for(let d=0;d<3;d++){let m=Number.MAX_VALUE,y=-Number.MAX_VALUE;for(let v=0;vthis.max[d]-this.min[d])return 0}return 1}}function xb(a,t,o,c,d,m,y,v,w){if(m&&a.queryGeometry.isAboveHorizon)return!1;m&&(w*=a.pixelToTileUnitsFactor);for(const A of t)for(const D of A){const R=D.add(v),k=d&&o.elevation?o.elevation.exaggeration()*d.getElevationAt(R.x,R.y,!0):0,V=m?R:eD(R,k,c),j=m?a.tilespaceRays.map(ne=>nD(ne,k)):a.queryGeometry.screenGeometry,$=Gu([],[D.x,D.y,k,1],c);if(!y&&m?w*=$[3]/o.cameraToCenterDistance:y&&!m&&(w*=o.cameraToCenterDistance/$[3]),jL(j,V,w))return!0}return!1}function eD(a,t,o){const c=Gu([],[a.x,a.y,t,1],o);return new E(c[0]/c[3],c[1]/c[3])}const bb=cp(0,0,0),tD=cp(0,0,1);function nD(a,t){const o=lv();return bb[2]=t,a.intersectsPlane(bb,tD,o),new E(o[0],o[1])}class wb extends tv{}function Mb(a,{width:t,height:o},c,d){if(d){if(d instanceof Uint8ClampedArray)d=new Uint8Array(d.buffer);else if(d.length!==t*o*c)throw new RangeError("mismatched image size")}else d=new Uint8Array(t*o*c);return a.width=t,a.height=o,a.data=d,a}function Tb(a,t,o){const{width:c,height:d}=t;c===a.width&&d===a.height||(pv(a,t,{x:0,y:0},{x:0,y:0},{width:Math.min(a.width,c),height:Math.min(a.height,d)},o),a.width=c,a.height=d,a.data=t.data)}function pv(a,t,o,c,d,m){if(d.width===0||d.height===0)return t;if(d.width>a.width||d.height>a.height||o.x>a.width-d.width||o.y>a.height-d.height)throw new RangeError("out of range source coordinates for image copy");if(d.width>t.width||d.height>t.height||c.x>t.width-d.width||c.y>t.height-d.height)throw new RangeError("out of range destination coordinates for image copy");const y=a.data,v=t.data;for(let w=0;w{t[a.evaluationKey]=w;const A=a.expression.evaluate(t);d.data[y+v+0]=Math.floor(255*A.r/A.a),d.data[y+v+1]=Math.floor(255*A.g/A.a),d.data[y+v+2]=Math.floor(255*A.b/A.a),d.data[y+v+3]=Math.floor(255*A.a)};if(a.clips)for(let y=0,v=0;y80*o){c=m=a[0],d=y=a[1];for(var j=o;jm&&(m=v),w>y&&(y=w);A=(A=Math.max(m-c,y-d))!==0?1/A:0}return fp(k,V,o,c,d,A),V}function Eb(a,t,o,c,d){var m,y;if(d===_v(a,t,o,c)>0)for(m=t;m=t;m-=c)y=Cb(m,a[m],a[m+1],y);return y&&vg(y,y.next)&&(gp(y),y=y.next),y}function Os(a,t){if(!a)return a;t||(t=a);var o,c=a;do if(o=!1,c.steiner||!vg(c,c.next)&&Di(c.prev,c,c.next)!==0)c=c.next;else{if(gp(c),(c=t=c.prev)===c.next)break;o=!0}while(o||c!==t);return t}function fp(a,t,o,c,d,m,y){if(a){!y&&m&&function(D,R,k,V){var j=D;do j.z===null&&(j.z=mv(j.x,j.y,R,k,V)),j.prevZ=j.prev,j.nextZ=j.next,j=j.next;while(j!==D);j.prevZ.nextZ=null,j.prevZ=null,function($){var ne,me,ke,He,Ze,Xe,Ye,lt,ht=1;do{for(me=$,$=null,Ze=null,Xe=0;me;){for(Xe++,ke=me,Ye=0,ne=0;ne0||lt>0&&ke;)Ye!==0&&(lt===0||!ke||me.z<=ke.z)?(He=me,me=me.nextZ,Ye--):(He=ke,ke=ke.nextZ,lt--),Ze?Ze.nextZ=He:$=He,He.prevZ=Ze,Ze=He;me=ke}Ze.nextZ=null,ht*=2}while(Xe>1)}(j)}(a,c,d,m);for(var v,w,A=a;a.prev!==a.next;)if(v=a.prev,w=a.next,m?cD(a,c,d,m):lD(a))t.push(v.i/o),t.push(a.i/o),t.push(w.i/o),gp(a),a=w.next,A=w.next;else if((a=w)===A){y?y===1?fp(a=uD(Os(a),t,o),t,o,c,d,m,2):y===2&&hD(a,t,o,c,d,m):fp(Os(a),t,o,c,d,m,1);break}}}function lD(a){var t=a.prev,o=a,c=a.next;if(Di(t,o,c)>=0)return!1;for(var d=a.next.next;d!==a.prev;){if(Hu(t.x,t.y,o.x,o.y,c.x,c.y,d.x,d.y)&&Di(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function cD(a,t,o,c){var d=a.prev,m=a,y=a.next;if(Di(d,m,y)>=0)return!1;for(var v=d.x>m.x?d.x>y.x?d.x:y.x:m.x>y.x?m.x:y.x,w=d.y>m.y?d.y>y.y?d.y:y.y:m.y>y.y?m.y:y.y,A=mv(d.x=A&&k&&k.z<=D;){if(R!==a.prev&&R!==a.next&&Hu(d.x,d.y,m.x,m.y,y.x,y.y,R.x,R.y)&&Di(R.prev,R,R.next)>=0||(R=R.prevZ,k!==a.prev&&k!==a.next&&Hu(d.x,d.y,m.x,m.y,y.x,y.y,k.x,k.y)&&Di(k.prev,k,k.next)>=0))return!1;k=k.nextZ}for(;R&&R.z>=A;){if(R!==a.prev&&R!==a.next&&Hu(d.x,d.y,m.x,m.y,y.x,y.y,R.x,R.y)&&Di(R.prev,R,R.next)>=0)return!1;R=R.prevZ}for(;k&&k.z<=D;){if(k!==a.prev&&k!==a.next&&Hu(d.x,d.y,m.x,m.y,y.x,y.y,k.x,k.y)&&Di(k.prev,k,k.next)>=0)return!1;k=k.nextZ}return!0}function uD(a,t,o){var c=a;do{var d=c.prev,m=c.next.next;!vg(d,m)&&Sb(d,c,c.next,m)&&mp(d,m)&&mp(m,d)&&(t.push(d.i/o),t.push(c.i/o),t.push(m.i/o),gp(c),gp(c.next),c=a=m),c=c.next}while(c!==a);return Os(c)}function hD(a,t,o,c,d,m){var y=a;do{for(var v=y.next.next;v!==y.prev;){if(y.i!==v.i&&gD(y,v)){var w=Ab(y,v);return y=Os(y,y.next),w=Os(w,w.next),fp(y,t,o,c,d,m),void fp(w,t,o,c,d,m)}v=v.next}y=y.next}while(y!==a)}function dD(a,t){return a.x-t.x}function pD(a,t){var o=function(m,y){var v,w=y,A=m.x,D=m.y,R=-1/0;do{if(D<=w.y&&D>=w.next.y&&w.next.y!==w.y){var k=w.x+(D-w.y)*(w.next.x-w.x)/(w.next.y-w.y);if(k<=A&&k>R){if(R=k,k===A){if(D===w.y)return w;if(D===w.next.y)return w.next}v=w.x=w.x&&w.x>=$&&A!==w.x&&Hu(Dv.x||w.x===v.x&&fD(v,w)))&&(v=w,me=V)),w=w.next;while(w!==j);return v}(a,t);if(!o)return t;var c=Ab(o,a),d=Os(o,o.next);return Os(c,c.next),t===o?d:t}function fD(a,t){return Di(a.prev,a,t.prev)<0&&Di(t.next,a,a.next)<0}function mv(a,t,o,c,d){return(a=1431655765&((a=858993459&((a=252645135&((a=16711935&((a=32767*(a-o)*d)|a<<8))|a<<4))|a<<2))|a<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-c)*d)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function mD(a){var t=a,o=a;do(t.x=0&&(a-y)*(c-v)-(o-y)*(t-v)>=0&&(o-y)*(m-v)-(d-y)*(c-v)>=0}function gD(a,t){return a.next.i!==t.i&&a.prev.i!==t.i&&!function(o,c){var d=o;do{if(d.i!==o.i&&d.next.i!==o.i&&d.i!==c.i&&d.next.i!==c.i&&Sb(d,d.next,o,c))return!0;d=d.next}while(d!==o);return!1}(a,t)&&(mp(a,t)&&mp(t,a)&&function(o,c){var d=o,m=!1,y=(o.x+c.x)/2,v=(o.y+c.y)/2;do d.y>v!=d.next.y>v&&d.next.y!==d.y&&y<(d.next.x-d.x)*(v-d.y)/(d.next.y-d.y)+d.x&&(m=!m),d=d.next;while(d!==o);return m}(a,t)&&(Di(a.prev,a,t.prev)||Di(a,t.prev,t))||vg(a,t)&&Di(a.prev,a,a.next)>0&&Di(t.prev,t,t.next)>0)}function Di(a,t,o){return(t.y-a.y)*(o.x-t.x)-(t.x-a.x)*(o.y-t.y)}function vg(a,t){return a.x===t.x&&a.y===t.y}function Sb(a,t,o,c){var d=bg(Di(a,t,o)),m=bg(Di(a,t,c)),y=bg(Di(o,c,a)),v=bg(Di(o,c,t));return d!==m&&y!==v||!(d!==0||!xg(a,o,t))||!(m!==0||!xg(a,c,t))||!(y!==0||!xg(o,a,c))||!(v!==0||!xg(o,t,c))}function xg(a,t,o){return t.x<=Math.max(a.x,o.x)&&t.x>=Math.min(a.x,o.x)&&t.y<=Math.max(a.y,o.y)&&t.y>=Math.min(a.y,o.y)}function bg(a){return a>0?1:a<0?-1:0}function mp(a,t){return Di(a.prev,a,a.next)<0?Di(a,t,a.next)>=0&&Di(a,a.prev,t)>=0:Di(a,t,a.prev)<0||Di(a,a.next,t)<0}function Ab(a,t){var o=new gv(a.i,a.x,a.y),c=new gv(t.i,t.x,t.y),d=a.next,m=t.prev;return a.next=t,t.prev=a,o.next=d,d.prev=o,c.next=o,o.prev=c,m.next=c,c.prev=m,c}function Cb(a,t,o,c){var d=new gv(a,t,o);return c?(d.next=c.next,d.prev=c,c.next.prev=d,c.next=d):(d.prev=d,d.next=d),d}function gp(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 gv(a,t,o){this.i=a,this.x=t,this.y=o,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function _v(a,t,o,c){for(var d=0,m=t,y=o-c;mo;){if(c-o>600){var m=c-o+1,y=t-o+1,v=Math.log(m),w=.5*Math.exp(2*v/3),A=.5*Math.sqrt(v*w*(m-w)/m)*(y-m/2<0?-1:1);Pb(a,t,Math.max(o,Math.floor(t-y*w/m+A)),Math.min(c,Math.floor(t+(m-y)*w/m+A)),d)}var D=a[t],R=o,k=c;for(_p(a,o,t),d(a[c],D)>0&&_p(a,o,c);R0;)k--}d(a[o],D)===0?_p(a,o,k):_p(a,++k,c),k<=t&&(o=k+1),t<=k&&(c=k-1)}}function _p(a,t,o){var c=a[t];a[t]=a[o],a[o]=c}function yD(a,t){return at?1:0}function yv(a,t){const o=a.length;if(o<=1)return[a];const c=[];let d,m;for(let y=0;y1)for(let y=0;y0&&o.holes.push(c+=a[d-1].length)}return o},_g.default=sD;class wg{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(o=>o.id),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Te,this.indexArray=new qt,this.indexArray2=new Mn,this.programConfigurations=new Hl(t.layers,t.zoom),this.segments=new Ei,this.segments2=new Ei,this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id),this.projection=t.projection}populate(t,o,c,d){this.hasPattern=vv("fill",this.layers,o);const m=this.layers[0].layout.get("fill-sort-key"),y=[];for(const{feature:v,id:w,index:A,sourceLayerIndex:D}of t){const R=this.layers[0]._featureFilter.needGeometry,k=Wl(v,R);if(!this.layers[0]._featureFilter.filter(new ci(this.zoom),k,c))continue;const V=m?m.evaluate(k,{},c,o.availableImages):void 0,j={id:w,properties:v.properties,type:v.type,sourceLayerIndex:D,index:A,geometry:R?k.geometry:Xo(v,c,d),patterns:{},sortKey:V};y.push(j)}m&&y.sort((v,w)=>v.sortKey-w.sortKey);for(const v of y){const{geometry:w,index:A,sourceLayerIndex:D}=v;if(this.hasPattern){const R=xv("fill",this.layers,v,this.zoom,o);this.patternFeatures.push(R)}else this.addFeature(v,w,A,c,{},o.availableImages);o.featureIndex.insert(t[A].feature,w,A,D,this.index)}}update(t,o,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,o,this.stateDependentLayers,c,d)}addFeatures(t,o,c,d,m){for(const y of this.patternFeatures)this.addFeature(y,y.geometry,y.index,o,c,d)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,oD),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),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(t,o,c,d,m,y=[]){for(const v of yv(o,500)){let w=0;for(const j of v)w+=j.length;const A=this.segments.prepareSegment(w,this.layoutVertexArray,this.indexArray),D=A.vertexLength,R=[],k=[];for(const j of v){if(j.length===0)continue;j!==v[0]&&k.push(R.length/2);const $=this.segments2.prepareSegment(j.length,this.layoutVertexArray,this.indexArray2),ne=$.vertexLength;this.layoutVertexArray.emplaceBack(j[0].x,j[0].y),this.indexArray2.emplaceBack(ne+j.length-1,ne),R.push(j[0].x),R.push(j[0].y);for(let me=1;me>3}if(d--,c===1||c===2)m+=a.readSVarint(),y+=a.readSVarint(),c===1&&(t&&v.push(t),t=[]),t.push(new E(m,y));else{if(c!==7)throw new Error("unknown command "+c);t&&t.push(t[0].clone())}}return t&&v.push(t),v},Wu.prototype.bbox=function(){var a=this._pbf;a.pos=this._geometry;for(var t=a.readVarint()+a.pos,o=1,c=0,d=0,m=0,y=1/0,v=-1/0,w=1/0,A=-1/0;a.pos>3}if(c--,o===1||o===2)(d+=a.readSVarint())v&&(v=d),(m+=a.readSVarint())A&&(A=m);else if(o!==7)throw new Error("unknown command "+o)}return[y,w,v,A]},Wu.prototype.toGeoJSON=function(a,t,o){var c,d,m=this.extent*Math.pow(2,o),y=this.extent*a,v=this.extent*t,w=this.loadGeometry(),A=Wu.types[this.type];function D(V){for(var j=0;j>3;d=y===1?c.readString():y===2?c.readFloat():y===3?c.readDouble():y===4?c.readVarint64():y===5?c.readVarint():y===6?c.readSVarint():y===7?c.readBoolean():null}return d}(o))}function PD(a,t,o){if(a===3){var c=new Db(o,o.readVarint()+o.pos);c.length&&(t[c.name]=c)}}Ib.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 t=this._pbf.readVarint()+this._pbf.pos;return new Lb(this._pbf,t,this.extent,this._keys,this._values)};var Zl={VectorTile:function(a,t){this.layers=a.readFields(PD,{},t)},VectorTileFeature:Lb,VectorTileLayer:Db};function Mg(a,t,o,c){const d=[],m=c===0?(y,v,w,A,D,R)=>{y.push(new E(R,w+(R-v)/(A-v)*(D-w)))}:(y,v,w,A,D,R)=>{y.push(new E(v+(R-w)/(D-w)*(A-v),R))};for(const y of a){const v=[];for(const w of y){if(w.length<=2)continue;const A=[];for(let k=0;kt&&m(A,V,j,$,ne,t):me>o?ke=t&&m(A,V,j,$,ne,t),ke>o&&me<=o&&m(A,V,j,$,ne,o)}let D=w[w.length-1];const R=c===0?D.x:D.y;R>=t&&R<=o&&A.push(D),A.length&&(D=A[A.length-1],A[0].x===D.x&&A[0].y===D.y||A.push(A[0]),v.push(A))}v.length&&d.push(v)}return d}const LD=Zl.VectorTileFeature.types,DD=Math.pow(2,13);function yp(a,t,o,c,d,m,y,v){a.emplaceBack((t<<1)+y,(o<<1)+m,(Math.floor(c*DD)<<1)+d,Math.round(v))}function vp(a,t,o){a.emplaceBack(t.x,t.y,t.z,o[0]*16384,o[1]*16384,o[2]*16384)}class Rb{constructor(){this.acc=new E(0,0),this.polyCount=[]}startRing(t){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new E(t.x,t.y),this.max=new E(t.x,t.y))}append(t,o){this.currentPolyCount.edges++,this.acc._add(t);const c=this.min,d=this.max;t.xd.x&&(d.x=t.x),t.yd.y&&(d.y=t.y),((t.x===0||t.x===In)&&t.x===o.x)!=((t.y===0||t.y===In)&&t.y===o.y)&&this.processBorderOverlap(t,o),o.x<0!=t.x<0&&this.addBorderIntersection(0,gn(o.y,t.y,(0-o.x)/(t.x-o.x))),o.x>In!=t.x>In&&this.addBorderIntersection(1,gn(o.y,t.y,(In-o.x)/(t.x-o.x))),o.y<0!=t.y<0&&this.addBorderIntersection(2,gn(o.x,t.x,(0-o.y)/(t.y-o.y))),o.y>In!=t.y>In&&this.addBorderIntersection(3,gn(o.x,t.x,(In-o.y)/(t.y-o.y)))}addBorderIntersection(t,o){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 c=this.borders[t];oc[1]&&(c[1]=o)}processBorderOverlap(t,o){if(t.x===o.x){if(t.y===o.y)return;const c=t.x===0?0:1;this.addBorderIntersection(c,o.y),this.addBorderIntersection(c,t.y)}else{const c=t.y===0?2:3;this.addBorderIntersection(c,o.x),this.addBorderIntersection(c,t.x)}}centroid(){const t=this.polyCount.reduce((o,c)=>o+c.edges,0);return t!==0?this.acc.div(t)._round():new E(0,0)}span(){return new E(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((t,o)=>t+ +(o[0]!==Number.MAX_VALUE),0)}}class xp{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(o=>o.id),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new Re,this.centroidVertexArray=new Gl,this.indexArray=new qt,this.programConfigurations=new Hl(t.layers,t.zoom),this.segments=new Ei,this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id),this.enableTerrain=t.enableTerrain}populate(t,o,c,d){this.features=[],this.hasPattern=vv("fill-extrusion",this.layers,o),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(m){const y=Math.exp(Math.PI*(1-m.y/(1<=0;$--){const ne=k[$];(ne.length===0||(V=ne[0]).every(me=>me.x<=0)||V.every(me=>me.x>=In)||V.every(me=>me.y<=0)||V.every(me=>me.y>=In))&&k.splice($,1)}var V;let j;if(D){const ne=1<{for(const Kt of An)rt.push({polygon:Kt,bounds:Bn})},Ct=Math.ceil(Math.log2(lt)),Bt=Math.ceil(Math.log2(ht)),It=Ct-Bt,kt=[];for(let An=0;An0?0:1);for(let An=0;AnBn+1?Un.push({polygons:Oi,bounds:Hn,depth:Bn+1}):ft(Oi,Hn)}if(Kn.length){const Hn=[new E(Kt===0?ui:Wt.x,Kt===1?ui:Wt.y),Vn];kt.length>Bn+1?Un.push({polygons:Kn,bounds:Hn,depth:Bn+1}):ft(Kn,Hn)}}return rt}(k,w,Math.ceil((ke-me)/11.25),Math.ceil((He-Ze)/11.25),1,(Xe,Ye,lt)=>{if(Xe===0)return .5*(Ye+lt);{const ht=rr((d.y+Ye/In)/ne);return(Fu(.5*(rr((d.y+lt/In)/ne)+ht))*ne-d.y)*In}})}else{j=[];for(const $ of k)j.push({polygon:$,bounds:w})}for(const $ of j){const ne=$.polygon;let me=0,ke=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let lt=0;lt=1){const ft=ht[Tt-1];if(!ID(rt,ft,$.bounds)){R&&R.append(rt,ft),ke.vertexLength+4>Ei.MAX_VERTEX_ARRAY_LENGTH&&(ke=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const Ct=rt.sub(ft)._perp(),Bt=Ct.x/(Math.abs(Ct.x)+Math.abs(Ct.y)),It=Ct.y>0?1:0,kt=ft.dist(rt);vt+kt>32768&&(vt=0),yp(this.layoutVertexArray,rt.x,rt.y,Bt,It,0,0,vt),yp(this.layoutVertexArray,rt.x,rt.y,Bt,It,0,1,vt),vt+=kt,yp(this.layoutVertexArray,ft.x,ft.y,Bt,It,0,0,vt),yp(this.layoutVertexArray,ft.x,ft.y,Bt,It,0,1,vt);const En=ke.vertexLength;if(this.indexArray.emplaceBack(En,En+2,En+1),this.indexArray.emplaceBack(En+1,En+2,En+3),ke.vertexLength+=4,ke.primitiveLength+=2,D){const Un=this.layoutVertexExtArray,An=A.projectTilePoint(rt.x,rt.y,d),Bn=A.projectTilePoint(ft.x,ft.y,d),Kt=A.upVector(d,rt.x,rt.y),Wt=A.upVector(d,ft.x,ft.y);vp(Un,An,Kt),vp(Un,An,Kt),vp(Un,Bn,Wt),vp(Un,Bn,Wt)}}}}}if(ke.vertexLength+me>Ei.MAX_VERTEX_ARRAY_LENGTH&&(ke=this.segments.prepareSegment(me,this.layoutVertexArray,this.indexArray)),LD[t.type]!=="Polygon")continue;const He=[],Ze=[],Xe=ke.vertexLength;for(let lt=0;lt0){if(R.borders){R.vertexArrayOffset=this.centroidVertexArray.length;const $=R.borders,ne=this.featuresOnBorder.push(R)-1;for(let me=0;me<4;me++)$[me][0]!==Number.MAX_VALUE&&this.borders[me].push(ne)}this.encodeCentroid(R.borders?void 0:R.centroid(),R)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,c,m,y,d)}sortBorders(){for(let t=0;t<4;t++)this.borders[t].sort((o,c)=>this.featuresOnBorder[o].borders[t][0]-this.featuresOnBorder[c].borders[t][0])}encodeCentroid(t,o,c=!0){let d,m;if(t)if(t.y!==0){const v=o.span()._mult(this.tileToMeter);d=(Math.max(t.x,1)<<3)+Math.min(7,Math.round(v.x/10)),m=(Math.max(t.y,1)<<3)+Math.min(7,Math.round(v.y/10))}else d=Math.ceil(7*(t.x+450)),m=0;else d=0,m=+c;let y=c?this.centroidVertexArray.length:o.vertexArrayOffset;for(const v of o.polyCount){c&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*v.edges+v.top);for(let w=0;w<2*v.edges;w++)this.centroidVertexArray.emplace(y++,0,m),this.centroidVertexArray.emplace(y++,d,m);for(let w=0;wo[1].x)||a.y===t.y&&(a.yo[1].y)}jt(xp,"FillExtrusionBucket",{omit:["layers","features"]}),jt(Rb,"PartMetadata");var RD={paint:new H({"fill-extrusion-opacity":new S(xe["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new P(xe["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new S(xe["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new S(xe["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new z(xe["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new P(xe["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new P(xe["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new S(xe["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function bp(a,t){return a.x*t.x+a.y*t.y}function zb(a,t){if(a.length===1){let o=0;const c=t[o++];let d;for(;!d||c.equals(d);)if(d=t[o++],!d)return 1/0;for(;oo.id),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(o=>{this.gradients[o.id]={}}),this.layoutVertexArray=new be,this.layoutVertexArray2=new Rt,this.indexArray=new qt,this.programConfigurations=new Hl(t.layers,t.zoom),this.segments=new Ei,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id)}populate(t,o,c,d){this.hasPattern=vv("line",this.layers,o);const m=this.layers[0].layout.get("line-sort-key"),y=[];for(const{feature:D,id:R,index:k,sourceLayerIndex:V}of t){const j=this.layers[0]._featureFilter.needGeometry,$=Wl(D,j);if(!this.layers[0]._featureFilter.filter(new ci(this.zoom),$,c))continue;const ne=m?m.evaluate($,{},c):void 0,me={id:R,properties:D.properties,type:D.type,sourceLayerIndex:V,index:k,geometry:j?$.geometry:Xo(D,c,d),patterns:{},sortKey:ne};y.push(me)}m&&y.sort((D,R)=>D.sortKey-R.sortKey);const{lineAtlas:v,featureIndex:w}=o,A=this.addConstantDashes(v);for(const D of y){const{geometry:R,index:k,sourceLayerIndex:V}=D;if(A&&this.addFeatureDashes(D,v),this.hasPattern){const j=xv("line",this.layers,D,this.zoom,o);this.patternFeatures.push(j)}else this.addFeature(D,R,k,c,v.positions,o.availableImages);w.insert(t[k].feature,R,k,V,this.index)}}addConstantDashes(t){let o=!1;for(const c of this.layers){const d=c.paint.get("line-dasharray").value,m=c.layout.get("line-cap").value;if(d.kind!=="constant"||m.kind!=="constant")o=!0;else{const y=m.value,v=d.value;if(!v)continue;t.addDash(v.from,y),t.addDash(v.to,y),v.other&&t.addDash(v.other,y)}}return o}addFeatureDashes(t,o){const c=this.zoom;for(const d of this.layers){const m=d.paint.get("line-dasharray").value,y=d.layout.get("line-cap").value;if(m.kind==="constant"&&y.kind==="constant")continue;let v,w,A,D,R,k;if(m.kind==="constant"){const ne=m.value;if(!ne)continue;v=ne.other||ne.to,w=ne.to,A=ne.from}else v=m.evaluate({zoom:c-1},t),w=m.evaluate({zoom:c},t),A=m.evaluate({zoom:c+1},t);y.kind==="constant"?D=R=k=y.value:(D=y.evaluate({zoom:c-1},t),R=y.evaluate({zoom:c},t),k=y.evaluate({zoom:c+1},t)),o.addDash(v,D),o.addDash(w,R),o.addDash(A,k);const V=o.getKey(v,D),j=o.getKey(w,R),$=o.getKey(A,k);t.patterns[d.id]={min:V,mid:j,max:$}}}update(t,o,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,o,this.stateDependentLayers,c,d)}addFeatures(t,o,c,d,m){for(const y of this.patternFeatures)this.addFeature(y,y.geometry,y.index,o,c,d)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,OD)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,BD),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,o,c,d,m,y){const v=this.layers[0].layout,w=v.get("line-join").evaluate(t,{}),A=v.get("line-cap").evaluate(t,{}),D=v.get("line-miter-limit"),R=v.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const k of o)this.addLine(k,t,w,A,D,R);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,c,m,y,d)}addLine(t,o,c,d,m,y){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let me=0;me=2&&t[w-1].equals(t[w-2]);)w--;let A=0;for(;A0;if(lt&&me>A){const rt=k.dist(V);if(rt>2*D){const ft=k.sub(k.sub(V)._mult(D/rt)._round());this.updateDistance(V,ft),this.addCurrentVertex(ft,$,0,0,R),V=ft}}const vt=V&&j;let Tt=vt?c:v?"butt":d;if(vt&&Tt==="round"&&(Xem&&(Tt="bevel"),Tt==="bevel"&&(Xe>2&&(Tt="flipbevel"),Xe100)ke=ne.mult(-1);else{const rt=Xe*$.add(ne).mag()/$.sub(ne).mag();ke._perp()._mult(rt*(ht?-1:1))}this.addCurrentVertex(k,ke,0,0,R),this.addCurrentVertex(k,ke.mult(-1),0,0,R)}else if(Tt==="bevel"||Tt==="fakeround"){const rt=-Math.sqrt(Xe*Xe-1),ft=ht?rt:0,Ct=ht?0:rt;if(V&&this.addCurrentVertex(k,$,ft,Ct,R),Tt==="fakeround"){const Bt=Math.round(180*Ye/Math.PI/20);for(let It=1;It2*D){const ft=k.add(j.sub(k)._mult(D/rt)._round());this.updateDistance(k,ft),this.addCurrentVertex(ft,ne,0,0,R),k=ft}}}}addCurrentVertex(t,o,c,d,m,y=!1){const v=o.y*d-o.x,w=-o.y-o.x*d;this.addHalfVertex(t,o.x+o.y*c,o.y-o.x*c,y,!1,c,m),this.addHalfVertex(t,v,w,y,!0,-d,m)}addHalfVertex({x:t,y:o},c,d,m,y,v,w){this.layoutVertexArray.emplaceBack((t<<1)+(m?1:0),(o<<1)+(y?1:0),Math.round(63*c)+128,Math.round(63*d)+128,1+(v===0?0:v<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const A=w.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,A),w.primitiveLength++),y?this.e2=A:this.e1=A}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,o){this.distance+=t.dist(o),this.updateScaledDistance()}}jt(Tg,"LineBucket",{omit:["layers","patternFeatures"]});const VD=new H({"line-cap":new P(xe.layout_line["line-cap"]),"line-join":new P(xe.layout_line["line-join"]),"line-miter-limit":new S(xe.layout_line["line-miter-limit"]),"line-round-limit":new S(xe.layout_line["line-round-limit"]),"line-sort-key":new P(xe.layout_line["line-sort-key"])});var Bb={paint:new H({"line-opacity":new P(xe.paint_line["line-opacity"]),"line-color":new P(xe.paint_line["line-color"]),"line-translate":new S(xe.paint_line["line-translate"]),"line-translate-anchor":new S(xe.paint_line["line-translate-anchor"]),"line-width":new P(xe.paint_line["line-width"]),"line-gap-width":new P(xe.paint_line["line-gap-width"]),"line-offset":new P(xe.paint_line["line-offset"]),"line-blur":new P(xe.paint_line["line-blur"]),"line-dasharray":new z(xe.paint_line["line-dasharray"]),"line-pattern":new z(xe.paint_line["line-pattern"]),"line-gradient":new N(xe.paint_line["line-gradient"])}),layout:VD};const Fb=new class extends P{possiblyEvaluate(a,t){return t=new ci(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(a,t)}evaluate(a,t,o,c){return t=ye({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(a,t,o,c)}}(Bb.paint.properties["line-width"].specification);function Ob(a,t){return t>0?t+2*a:a}Fb.useIntegerZoom=!0;const GD=Ae([{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),HD=Ae([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ae([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const WD=Ae([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),jD=Ae([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Ae([{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 Nb=Ae([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),qD=Ae([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Ae([{name:"triangle",components:3,type:"Uint16"}]),Ae([{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"}]),Ae([{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"}]),Ae([{type:"Float32",name:"offsetX"}]),Ae([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var ar=24;const _o=128;function bv(a,t){const{expression:o}=t;if(o.kind==="constant")return{kind:"constant",layoutSize:o.evaluate(new ci(a+1))};if(o.kind==="source")return{kind:"source"};{const{zoomStops:c,interpolationType:d}=o;let m=0;for(;m{c.text=function(d,m,y){const v=m.layout.get("text-transform").evaluate(y,{});return v==="uppercase"?d=d.toLocaleUpperCase():v==="lowercase"&&(d=d.toLocaleLowerCase()),qr.applyArabicShaping&&(d=qr.applyArabicShaping(d)),d}(c.text,t,o)}),a}const wp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function YD(a){return a==="︶"||a==="﹈"||a==="︸"||a==="﹄"||a==="﹂"||a==="︾"||a==="︼"||a==="︺"||a==="︘"||a==="﹀"||a==="︐"||a==="︓"||a==="︔"||a==="`"||a===" ̄"||a==="︑"||a==="︒"}function $D(a){return a==="︵"||a==="﹇"||a==="︷"||a==="﹃"||a==="﹁"||a==="︽"||a==="︻"||a==="︹"||a==="︗"||a==="︿"}var Ub=function(a,t,o,c,d){var m,y,v=8*d-c-1,w=(1<>1,D=-7,R=o?d-1:0,k=o?-1:1,V=a[t+R];for(R+=k,m=V&(1<<-D)-1,V>>=-D,D+=v;D>0;m=256*m+a[t+R],R+=k,D-=8);for(y=m&(1<<-D)-1,m>>=-D,D+=c;D>0;y=256*y+a[t+R],R+=k,D-=8);if(m===0)m=1-A;else{if(m===w)return y?NaN:1/0*(V?-1:1);y+=Math.pow(2,c),m-=A}return(V?-1:1)*y*Math.pow(2,m-c)},Vb=function(a,t,o,c,d,m){var y,v,w,A=8*m-d-1,D=(1<>1,k=d===23?Math.pow(2,-24)-Math.pow(2,-77):0,V=c?0:m-1,j=c?1:-1,$=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(v=isNaN(t)?1:0,y=D):(y=Math.floor(Math.log(t)/Math.LN2),t*(w=Math.pow(2,-y))<1&&(y--,w*=2),(t+=y+R>=1?k/w:k*Math.pow(2,1-R))*w>=2&&(y++,w/=2),y+R>=D?(v=0,y=D):y+R>=1?(v=(t*w-1)*Math.pow(2,d),y+=R):(v=t*Math.pow(2,R-1)*Math.pow(2,d),y=0));d>=8;a[o+V]=255&v,V+=j,v/=256,d-=8);for(y=y<0;a[o+V]=255&y,V+=j,y/=256,A-=8);a[o+V-j]|=128*$},Mp=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 wv=4294967296,Gb=1/wv,Hb=typeof TextDecoder=="undefined"?null:new TextDecoder("utf8");function $o(a){return a.type===si.Bytes?a.readVarint()+a.pos:a.pos+1}function qu(a,t,o){return o?4294967296*t+(a>>>0):4294967296*(t>>>0)+(a>>>0)}function Wb(a,t,o){var c=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));o.realloc(c);for(var d=o.pos-1;d>=a;d--)o.buf[d+c]=o.buf[d]}function JD(a,t){for(var o=0;o>>8,a[o+2]=t>>>16,a[o+3]=t>>>24}function jb(a,t){return(a[t]|a[t+1]<<8|a[t+2]<<16)+(a[t+3]<<24)}function oI(a,t,o){t.glyphs=[],a===1&&o.readMessage(sI,t)}function sI(a,t,o){if(a===3){const{id:c,bitmap:d,width:m,height:y,left:v,top:w,advance:A}=o.readMessage(lI,{});t.glyphs.push({id:c,bitmap:new Yo({width:m+6,height:y+6},d),metrics:{width:m,height:y,left:v,top:w,advance:A}})}else a===4?t.ascender=o.readSVarint():a===5&&(t.descender=o.readSVarint())}function lI(a,t,o){a===1?t.id=o.readVarint():a===2?t.bitmap=o.readBytes():a===3?t.width=o.readVarint():a===4?t.height=o.readVarint():a===5?t.left=o.readSVarint():a===6?t.top=o.readSVarint():a===7&&(t.advance=o.readVarint())}function Mv(a){let t=0,o=0;for(const y of a)t+=y.w*y.h,o=Math.max(o,y.w);a.sort((y,v)=>v.h-y.h);const c=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),o),h:1/0}];let d=0,m=0;for(const y of a)for(let v=c.length-1;v>=0;v--){const w=c[v];if(!(y.w>w.w||y.h>w.h)){if(y.x=w.x,y.y=w.y,m=Math.max(m,y.y+y.h),d=Math.max(d,y.x+y.w),y.w===w.w&&y.h===w.h){const A=c.pop();v>3,m=this.pos;this.type=7&c,a(d,t,this),this.pos===m&&this.skip(c)}return t},readMessage:function(a,t){return this.readFields(a,t,this.readVarint()+this.pos)},readFixed32:function(){var a=Sg(this.buf,this.pos);return this.pos+=4,a},readSFixed32:function(){var a=jb(this.buf,this.pos);return this.pos+=4,a},readFixed64:function(){var a=Sg(this.buf,this.pos)+Sg(this.buf,this.pos+4)*wv;return this.pos+=8,a},readSFixed64:function(){var a=Sg(this.buf,this.pos)+jb(this.buf,this.pos+4)*wv;return this.pos+=8,a},readFloat:function(){var a=Ub(this.buf,this.pos,!0,23,4);return this.pos+=4,a},readDouble:function(){var a=Ub(this.buf,this.pos,!0,52,8);return this.pos+=8,a},readVarint:function(a){var t,o,c=this.buf;return t=127&(o=c[this.pos++]),o<128?t:(t|=(127&(o=c[this.pos++]))<<7,o<128?t:(t|=(127&(o=c[this.pos++]))<<14,o<128?t:(t|=(127&(o=c[this.pos++]))<<21,o<128?t:function(d,m,y){var v,w,A=y.buf;if(v=(112&(w=A[y.pos++]))>>4,w<128||(v|=(127&(w=A[y.pos++]))<<3,w<128)||(v|=(127&(w=A[y.pos++]))<<10,w<128)||(v|=(127&(w=A[y.pos++]))<<17,w<128)||(v|=(127&(w=A[y.pos++]))<<24,w<128)||(v|=(1&(w=A[y.pos++]))<<31,w<128))return qu(d,v,m);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(o=c[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,t=this.pos;return this.pos=a,a-t>=12&&Hb?function(o,c,d){return Hb.decode(o.subarray(c,d))}(this.buf,t,a):function(o,c,d){for(var m="",y=c;y239?4:D>223?3:D>191?2:1;if(y+k>d)break;k===1?D<128&&(R=D):k===2?(192&(v=o[y+1]))==128&&(R=(31&D)<<6|63&v)<=127&&(R=null):k===3?(w=o[y+2],(192&(v=o[y+1]))==128&&(192&w)==128&&((R=(15&D)<<12|(63&v)<<6|63&w)<=2047||R>=55296&&R<=57343)&&(R=null)):k===4&&(w=o[y+2],A=o[y+3],(192&(v=o[y+1]))==128&&(192&w)==128&&(192&A)==128&&((R=(15&D)<<18|(63&v)<<12|(63&w)<<6|63&A)<=65535||R>=1114112)&&(R=null)),R===null?(R=65533,k=1):R>65535&&(R-=65536,m+=String.fromCharCode(R>>>10&1023|55296),R=56320|1023&R),m+=String.fromCharCode(R),y+=k}return m}(this.buf,t,a)},readBytes:function(){var a=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,a);return this.pos=a,t},readPackedVarint:function(a,t){if(this.type!==si.Bytes)return a.push(this.readVarint(t));var o=$o(this);for(a=a||[];this.pos127;);else if(t===si.Bytes)this.pos=this.readVarint()+this.pos;else if(t===si.Fixed32)this.pos+=4;else{if(t!==si.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(a,t){this.writeVarint(a<<3|t)},realloc:function(a){for(var t=this.length||16;t268435455||a<0?function(t,o){var c,d;if(t>=0?(c=t%4294967296|0,d=t/4294967296|0):(d=~(-t/4294967296),4294967295^(c=~(-t%4294967296))?c=c+1|0:(c=0,d=d+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");o.realloc(10),function(m,y,v){v.buf[v.pos++]=127&m|128,m>>>=7,v.buf[v.pos++]=127&m|128,m>>>=7,v.buf[v.pos++]=127&m|128,m>>>=7,v.buf[v.pos++]=127&m|128,v.buf[v.pos]=127&(m>>>=7)}(c,0,o),function(m,y){var v=(7&m)<<4;y.buf[y.pos++]|=v|((m>>>=3)?128:0),m&&(y.buf[y.pos++]=127&m|((m>>>=7)?128:0),m&&(y.buf[y.pos++]=127&m|((m>>>=7)?128:0),m&&(y.buf[y.pos++]=127&m|((m>>>=7)?128:0),m&&(y.buf[y.pos++]=127&m|((m>>>=7)?128:0),m&&(y.buf[y.pos++]=127&m)))))}(d,o)}(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 t=this.pos;this.pos=function(c,d,m){for(var y,v,w=0;w55295&&y<57344){if(!v){y>56319||w+1===d.length?(c[m++]=239,c[m++]=191,c[m++]=189):v=y;continue}if(y<56320){c[m++]=239,c[m++]=191,c[m++]=189,v=y;continue}y=v-55296<<10|y-56320|65536,v=null}else v&&(c[m++]=239,c[m++]=191,c[m++]=189,v=null);y<128?c[m++]=y:(y<2048?c[m++]=y>>6|192:(y<65536?c[m++]=y>>12|224:(c[m++]=y>>18|240,c[m++]=y>>12&63|128),c[m++]=y>>6&63|128),c[m++]=63&y|128)}return m}(this.buf,a,this.pos);var o=this.pos-t;o>=128&&Wb(t,o,this),this.pos=t-1,this.writeVarint(o),this.pos+=o},writeFloat:function(a){this.realloc(4),Vb(this.buf,a,this.pos,!0,23,4),this.pos+=4},writeDouble:function(a){this.realloc(8),Vb(this.buf,a,this.pos,!0,52,8),this.pos+=8},writeBytes:function(a){var t=a.length;this.writeVarint(t),this.realloc(t);for(var o=0;o=128&&Wb(o,c,this),this.pos=o-1,this.writeVarint(c),this.pos+=c},writeMessage:function(a,t,o){this.writeTag(a,si.Bytes),this.writeRawMessage(t,o)},writePackedVarint:function(a,t){t.length&&this.writeMessage(a,JD,t)},writePackedSVarint:function(a,t){t.length&&this.writeMessage(a,KD,t)},writePackedBoolean:function(a,t){t.length&&this.writeMessage(a,tI,t)},writePackedFloat:function(a,t){t.length&&this.writeMessage(a,QD,t)},writePackedDouble:function(a,t){t.length&&this.writeMessage(a,eI,t)},writePackedFixed32:function(a,t){t.length&&this.writeMessage(a,nI,t)},writePackedSFixed32:function(a,t){t.length&&this.writeMessage(a,iI,t)},writePackedFixed64:function(a,t){t.length&&this.writeMessage(a,rI,t)},writePackedSFixed64:function(a,t){t.length&&this.writeMessage(a,aI,t)},writeBytesField:function(a,t){this.writeTag(a,si.Bytes),this.writeBytes(t)},writeFixed32Field:function(a,t){this.writeTag(a,si.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(a,t){this.writeTag(a,si.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(a,t){this.writeTag(a,si.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(a,t){this.writeTag(a,si.Fixed64),this.writeSFixed64(t)},writeVarintField:function(a,t){this.writeTag(a,si.Varint),this.writeVarint(t)},writeSVarintField:function(a,t){this.writeTag(a,si.Varint),this.writeSVarint(t)},writeStringField:function(a,t){this.writeTag(a,si.Bytes),this.writeString(t)},writeFloatField:function(a,t){this.writeTag(a,si.Fixed32),this.writeFloat(t)},writeDoubleField:function(a,t){this.writeTag(a,si.Fixed64),this.writeDouble(t)},writeBooleanField:function(a,t){this.writeVarintField(a,!!t)}};class Tv{constructor(t,{pixelRatio:o,version:c,stretchX:d,stretchY:m,content:y}){this.paddedRect=t,this.pixelRatio=o,this.stretchX=d,this.stretchY=m,this.content=y,this.version=c}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 qb{constructor(t,o){const c={},d={};this.haveRenderCallbacks=[];const m=[];this.addImages(t,c,m),this.addImages(o,d,m);const{w:y,h:v}=Mv(m),w=new Yr({width:y||1,height:v||1});for(const A in t){const D=t[A],R=c[A].paddedRect;Yr.copy(D.data,w,{x:0,y:0},{x:R.x+1,y:R.y+1},D.data)}for(const A in o){const D=o[A],R=d[A].paddedRect,k=R.x+1,V=R.y+1,j=D.data.width,$=D.data.height;Yr.copy(D.data,w,{x:0,y:0},{x:k,y:V},D.data),Yr.copy(D.data,w,{x:0,y:$-1},{x:k,y:V-1},{width:j,height:1}),Yr.copy(D.data,w,{x:0,y:0},{x:k,y:V+$},{width:j,height:1}),Yr.copy(D.data,w,{x:j-1,y:0},{x:k-1,y:V},{width:1,height:$}),Yr.copy(D.data,w,{x:0,y:0},{x:k+j,y:V},{width:1,height:$})}this.image=w,this.iconPositions=c,this.patternPositions=d}addImages(t,o,c){for(const d in t){const m=t[d],y={x:0,y:0,w:m.data.width+2,h:m.data.height+2};c.push(y),o[d]=new Tv(y,m),m.hasRenderCallback&&this.haveRenderCallbacks.push(d)}}patchUpdatedImages(t,o){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(c=>t.hasImage(c)),t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const c in t.updatedImages)this.patchUpdatedImage(this.iconPositions[c],t.getImage(c),o),this.patchUpdatedImage(this.patternPositions[c],t.getImage(c),o)}patchUpdatedImage(t,o,c){if(!t||!o||t.version===o.version)return;t.version=o.version;const[d,m]=t.tl;c.update(o.data,void 0,{x:d,y:m})}}jt(Tv,"ImagePosition"),jt(qb,"ImageAtlas");const _a={horizontal:1,vertical:2,horizontalOnly:3};class Tp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,o){const c=new Tp;return c.scale=t||1,c.fontStack=o,c}static forImage(t){const o=new Tp;return o.imageName=t,o}}class Xu{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,o){const c=new Xu;for(let d=0;d=0&&c>=t&&Ag[this.text.charCodeAt(c)];c--)o--;this.text=this.text.substring(t,o),this.sectionIndex=this.sectionIndex.slice(t,o)}substring(t,o){const c=new Xu;return c.text=this.text.substring(t,o),c.sectionIndex=this.sectionIndex.slice(t,o),c.sections=this.sections,c}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((t,o)=>Math.max(t,this.sections[o].scale),0)}addTextSection(t,o){this.text+=t.text,this.sections.push(Tp.forText(t.scale,t.fontStack||o));const c=this.sections.length-1;for(let d=0;d=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Ev(a,t,o,c,d,m,y,v,w,A,D,R,k,V,j,$){const ne=Xu.fromFeature(a,d);let me;R===_a.vertical&&ne.verticalizePunctuation(k);const{processBidirectionalText:ke,processStyledBidirectionalText:He}=qr;if(ke&&ne.sections.length===1){me=[];const Ye=ke(ne.toString(),Sv(ne,A,m,t,c,V,j));for(const lt of Ye){const ht=new Xu;ht.text=lt,ht.sections=ne.sections;for(let vt=0;vt0&&Sa>Ni&&(Ni=Sa)}else{const hr=ht[vr.fontStack];if(!hr)continue;hr[er]&&(hi=hr[er]);const Ji=lt[vr.fontStack];if(!Ji)continue;const Sa=Ji.glyphs[er];if(!Sa)continue;if(fi=Sa.metrics,xr=er!==8203?ar:0,Wt){const js=Ji.ascender!==void 0?Math.abs(Ji.ascender):0,zp=Ji.descender!==void 0?Math.abs(Ji.descender):0,kp=(js+zp)*$i;Yi=0;let D=0;for(let k=0;k-o/2;){if(y--,y<0)return!1;v-=a[y].dist(m),m=a[y]}v+=a[y].dist(a[y+1]),y++;const w=[];let A=0;for(;vc;)A-=w.shift().angleDelta;if(A>d)return!1;y++,v+=D.dist(R)}return!0}function ew(a){let t=0;for(let o=0;oA){const j=(A-w)/V,$=gn(R.x,k.x,j),ne=gn(R.y,k.y,j),me=new Jo($,ne,0,k.angleTo(R),D);return!y||Qb(a,me,v,y,t)?me:void 0}w+=V}}function pI(a,t,o,c,d,m,y,v,w){const A=tw(c,m,y),D=nw(c,d),R=D*y,k=a[0].x===0||a[0].x===w||a[0].y===0||a[0].y===w;return t-R=0&&Ze=0&&Xe=0&&k+A<=D){const Ye=new Jo(Ze,Xe,0,ke,j);Ye._round(),c&&!Qb(a,Ye,m,c,d)||V.push(Ye)}}R+=me}return v||V.length||y||(V=iw(a,R/2,o,c,d,m,y,!0,w)),V}function rw(a,t,o,c,d){const m=[];for(let y=0;y=c&&R.x>=c||(D.x>=c?D=new E(c,D.y+(c-D.x)/(R.x-D.x)*(R.y-D.y))._round():R.x>=c&&(R=new E(c,D.y+(c-D.x)/(R.x-D.x)*(R.y-D.y))._round()),D.y>=d&&R.y>=d||(D.y>=d?D=new E(D.x+(d-D.y)/(R.y-D.y)*(R.x-D.x),d)._round():R.y>=d&&(R=new E(D.x+(d-D.y)/(R.y-D.y)*(R.x-D.x),d)._round()),w&&D.equals(w[w.length-1])||(w=[D],m.push(w)),w.push(R)))))}}return m}jt(Jo,"Anchor");const Ep=1e20;function aw(a,t,o,c,d,m,y,v,w){for(let A=t;A-1);w++,m[w]=v,y[w]=A,y[w+1]=Ep}for(let v=0,w=0;v{let v=this.entries[d];v||(v=this.entries[d]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let w=v.glyphs[m];if(w!==void 0)return void y(null,{stack:d,id:m,glyph:w});if(w=this._tinySDF(v,d,m),w)return v.glyphs[m]=w,void y(null,{stack:d,id:m,glyph:w});const A=Math.floor(m/256);if(256*A>65535)return void y(new Error("glyphs > 65535 not supported"));if(v.ranges[A])return void y(null,{stack:d,id:m,glyph:w});let D=v.requests[A];D||(D=v.requests[A]=[],Yu.loadGlyphRange(d,A,this.url,this.requestManager,(R,k)=>{if(k){v.ascender=k.ascender,v.descender=k.descender;for(const V in k.glyphs)this._doesCharSupportLocalGlyph(+V)||(v.glyphs[+V]=k.glyphs[+V]);v.ranges[A]=!0}for(const V of D)V(R,k);delete v.requests[A]})),D.push((R,k)=>{R?y(R):k&&y(null,{stack:d,id:m,glyph:k.glyphs[m]||null})})},(d,m)=>{if(d)o(d);else if(m){const y={};for(const{stack:v,id:w,glyph:A}of m)y[v]===void 0&&(y[v]={}),y[v].glyphs===void 0&&(y[v].glyphs={}),y[v].glyphs[w]=A&&{id:A.id,bitmap:A.bitmap.clone(),metrics:A.metrics},y[v].ascender=this.entries[v].ascender,y[v].descender=this.entries[v].descender;o(null,y)}})}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Cv.none&&(this.localGlyphMode===Cv.all?!!this.localFontFamily:!!this.localFontFamily&&(Kd(t)||ig(t)||Fl(t)||Pu(t)||Cu(t)))}_tinySDF(t,o,c){const d=this.localFontFamily;if(!d||!this._doesCharSupportLocalGlyph(c))return;let m=t.tinySDF;if(!m){let $="400";/bold/i.test(o)?$="900":/medium/i.test(o)?$="500":/light/i.test(o)&&($="200"),m=t.tinySDF=new Yu.TinySDF({fontFamily:d,fontWeight:$,fontSize:48,buffer:6,radius:16}),m.fontWeight=$}if(this.localGlyphs[m.fontWeight][c])return this.localGlyphs[m.fontWeight][c];const y=String.fromCharCode(c),{data:v,width:w,height:A,glyphWidth:D,glyphHeight:R,glyphLeft:k,glyphTop:V,glyphAdvance:j}=m.draw(y);return this.localGlyphs[m.fontWeight][c]={id:c,bitmap:new Yo({width:w,height:A},v),metrics:{width:D/2,height:R/2,left:k/2,top:V/2-27,advance:j/2,localGlyph:!0}}}}function sw(a,t,o,c){const d=[],m=a.image,y=m.pixelRatio,v=m.paddedRect.w-2,w=m.paddedRect.h-2,A=a.right-a.left,D=a.bottom-a.top,R=m.stretchX||[[0,v]],k=m.stretchY||[[0,w]],V=(rt,ft)=>rt+ft[1]-ft[0],j=R.reduce(V,0),$=k.reduce(V,0),ne=v-j,me=w-$;let ke=0,He=j,Ze=0,Xe=$,Ye=0,lt=ne,ht=0,vt=me;if(m.content&&c){const rt=m.content;ke=Cg(R,0,rt[0]),Ze=Cg(k,0,rt[1]),He=Cg(R,rt[0],rt[2]),Xe=Cg(k,rt[1],rt[3]),Ye=rt[0]-ke,ht=rt[1]-Ze,lt=rt[2]-rt[0]-He,vt=rt[3]-rt[1]-Xe}const Tt=(rt,ft,Ct,Bt)=>{const It=Pg(rt.stretch-ke,He,A,a.left),kt=Lg(rt.fixed-Ye,lt,rt.stretch,j),En=Pg(ft.stretch-Ze,Xe,D,a.top),Un=Lg(ft.fixed-ht,vt,ft.stretch,$),An=Pg(Ct.stretch-ke,He,A,a.left),Bn=Lg(Ct.fixed-Ye,lt,Ct.stretch,j),Kt=Pg(Bt.stretch-Ze,Xe,D,a.top),Wt=Lg(Bt.fixed-ht,vt,Bt.stretch,$),Vn=new E(It,En),Jn=new E(An,En),Fi=new E(An,Kt),ui=new E(It,Kt),Oi=new E(kt/y,Un/y),Kn=new E(Bn/y,Wt/y),Hn=t*Math.PI/180;if(Hn){const Si=Math.sin(Hn),Ni=Math.cos(Hn),Yi=[Ni,-Si,Si,Ni];Vn._matMult(Yi),Jn._matMult(Yi),ui._matMult(Yi),Fi._matMult(Yi)}const ni=rt.stretch+rt.fixed,wi=ft.stretch+ft.fixed;return{tl:Vn,tr:Jn,bl:ui,br:Fi,tex:{x:m.paddedRect.x+1+ni,y:m.paddedRect.y+1+wi,w:Ct.stretch+Ct.fixed-ni,h:Bt.stretch+Bt.fixed-wi},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Oi,pixelOffsetBR:Kn,minFontScaleX:lt/y/A,minFontScaleY:vt/y/D,isSDF:o}};if(c&&(m.stretchX||m.stretchY)){const rt=lw(R,ne,j),ft=lw(k,me,$);for(let Ct=0;Ct{if(w)d(w);else if(A){const D={},R=function(k){return new Mp(k).readFields(oI,{})}(A);for(const k of R.glyphs)D[k.id]=k;d(null,{glyphs:D,ascender:R.ascender,descender:R.descender})}})},Yu.TinySDF=class{constructor({fontSize:a=24,buffer:t=3,radius:o=8,cutoff:c=.25,fontFamily:d="sans-serif",fontWeight:m="normal",fontStyle:y="normal"}){this.buffer=t,this.cutoff=c,this.radius=o;const v=this.size=a+4*t,w=this._createCanvas(v),A=this.ctx=w.getContext("2d",{willReadFrequently:!0});A.font=`${y} ${m} ${a}px ${d}`,A.textBaseline="alphabetic",A.textAlign="left",A.fillStyle="black",this.gridOuter=new Float64Array(v*v),this.gridInner=new Float64Array(v*v),this.f=new Float64Array(v),this.z=new Float64Array(v+1),this.v=new Uint16Array(v)}_createCanvas(a){const t=document.createElement("canvas");return t.width=t.height=a,t}draw(a){const{width:t,actualBoundingBoxAscent:o,actualBoundingBoxDescent:c,actualBoundingBoxLeft:d,actualBoundingBoxRight:m}=this.ctx.measureText(a),y=Math.floor(o),v=Math.min(this.size-this.buffer,Math.ceil(m-d)),w=Math.min(this.size-this.buffer,Math.ceil(o)+Math.ceil(c)),A=v+2*this.buffer,D=w+2*this.buffer,R=A*D,k=new Uint8ClampedArray(R),V={data:k,width:A,height:D,glyphWidth:v,glyphHeight:w,glyphTop:y,glyphLeft:0,glyphAdvance:t};if(v===0||w===0)return V;const{ctx:j,buffer:$,gridInner:ne,gridOuter:me}=this;j.clearRect($,$,v,w),j.fillText(a,$,$+y+1);const ke=j.getImageData($,$,v,w);me.fill(Ep,0,R),ne.fill(0,0,R);for(let He=0;He0?lt*lt:0,ne[Ye]=lt<0?lt*lt:0}}aw(me,0,0,A,D,A,this.f,this.v,this.z),aw(ne,$,$,v,w,A,this.f,this.v,this.z);for(let He=0;He0)for(let c=(this.length>>1)-1;c>=0;c--)this._down(c)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],o=this.data.pop();return this.length--,this.length>0&&(this.data[0]=o,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:o,compare:c}=this,d=o[t];for(;t>0;){const m=t-1>>1,y=o[m];if(c(d,y)>=0)break;o[t]=y,t=m}o[t]=d}_down(t){const{data:o,compare:c}=this,d=this.length>>1,m=o[t];for(;t=0)break;o[t]=v,t=y}o[t]=m}}function gI(a,t){return at?1:0}function _I(a,t=1,o=!1){let c=1/0,d=1/0,m=-1/0,y=-1/0;const v=a[0];for(let V=0;Vm)&&(m=j.x),(!V||j.y>y)&&(y=j.y)}const w=Math.min(m-c,y-d);let A=w/2;const D=new mI([],yI);if(w===0)return new E(c,d);for(let V=c;VR.d||!R.d)&&(R=V,o&&console.log("found best %d after %d probes",Math.round(1e4*V.d)/1e4,k)),V.max-R.d<=t||(A=V.h/2,D.push(new $u(V.p.x-A,V.p.y-A,A,a)),D.push(new $u(V.p.x+A,V.p.y-A,A,a)),D.push(new $u(V.p.x-A,V.p.y+A,A,a)),D.push(new $u(V.p.x+A,V.p.y+A,A,a)),k+=4)}return o&&(console.log(`num probes: ${k}`),console.log(`best distance: ${R.d}`)),R.p}function yI(a,t){return t.max-a.max}function $u(a,t,o,c){this.p=new E(a,t),this.h=o,this.d=function(d,m){let y=!1,v=1/0;for(let w=0;wd.y!=j.y>d.y&&d.x<(j.x-V.x)*(d.y-V.y)/(j.y-V.y)+V.x&&(y=!y),v=Math.min(v,rb(d,V,j))}}return(y?1:-1)*Math.sqrt(v)}(this.p,c),this.max=this.d+this.h*Math.SQRT2}const Pv=Number.POSITIVE_INFINITY,vI=Math.sqrt(2);function cw(a,t){return t[1]!==Pv?function(o,c,d){let m=0,y=0;switch(c=Math.abs(c),d=Math.abs(d),o){case"top-right":case"top-left":case"top":y=d-7;break;case"bottom-right":case"bottom-left":case"bottom":y=7-d}switch(o){case"top-right":case"bottom-right":case"right":m=-c;break;case"top-left":case"bottom-left":case"left":m=c}return[m,y]}(a,t[0],t[1]):function(o,c){let d=0,m=0;c<0&&(c=0);const y=c/vI;switch(o){case"top-right":case"top-left":m=y-7;break;case"bottom-right":case"bottom-left":m=7-y;break;case"bottom":m=7-c;break;case"top":m=c-7}switch(o){case"top-right":case"bottom-right":d=-y;break;case"top-left":case"bottom-left":d=y;break;case"left":d=c;break;case"right":d=-c}return[d,m]}(a,t[0])}function xI(a,t,o,c,d,m,y,v,w,A){a.createArrays(),a.tilePixelRatio=In/(512*a.overscaling),a.compareText={},a.iconsNeedLinear=!1;const D=a.layers[0].layout,R=a.layers[0]._unevaluatedLayout._values,k={};if(a.textSizeData.kind==="composite"){const{minZoom:$,maxZoom:ne}=a.textSizeData;k.compositeTextSizes=[R["text-size"].possiblyEvaluate(new ci($),v),R["text-size"].possiblyEvaluate(new ci(ne),v)]}if(a.iconSizeData.kind==="composite"){const{minZoom:$,maxZoom:ne}=a.iconSizeData;k.compositeIconSizes=[R["icon-size"].possiblyEvaluate(new ci($),v),R["icon-size"].possiblyEvaluate(new ci(ne),v)]}k.layoutTextSize=R["text-size"].possiblyEvaluate(new ci(w+1),v),k.layoutIconSize=R["icon-size"].possiblyEvaluate(new ci(w+1),v),k.textMaxSize=R["text-size"].possiblyEvaluate(new ci(18),v);const V=D.get("text-rotation-alignment")==="map"&&D.get("symbol-placement")!=="point",j=D.get("text-size");for(const $ of a.features){const ne=D.get("text-font").evaluate($,{},v).join(","),me=j.evaluate($,{},v),ke=k.layoutTextSize.evaluate($,{},v),He=(k.layoutIconSize.evaluate($,{},v),{horizontal:{},vertical:void 0}),Ze=$.text;let Xe,Ye=[0,0];if(Ze){const vt=Ze.toString(),Tt=D.get("text-letter-spacing").evaluate($,{},v)*ar,rt=D.get("text-line-height").evaluate($,{},v)*ar,ft=og(vt)?Tt:0,Ct=D.get("text-anchor").evaluate($,{},v),Bt=D.get("text-variable-anchor");if(!Bt){const Bn=D.get("text-radial-offset").evaluate($,{},v);Ye=Bn?cw(Ct,[Bn*ar,Pv]):D.get("text-offset").evaluate($,{},v).map(Kt=>Kt*ar)}let It=V?"center":D.get("text-justify").evaluate($,{},v);const kt=D.get("symbol-placement"),En=kt==="point",Un=kt==="point"?D.get("text-max-width").evaluate($,{},v)*ar:0,An=Bn=>{a.allowVerticalPlacement&&Du(vt)&&(He.vertical=Ev(Ze,t,o,d,ne,Un,rt,Ct,Bn,ft,Ye,_a.vertical,!0,kt,ke,me))};if(!V&&Bt){const Bn=It==="auto"?Bt.map(Wt=>Lv(Wt)):[It];let Kt=!1;for(let Wt=0;Wt=0||!Du(vt)){const Bn=Ev(Ze,t,o,d,ne,Un,rt,Ct,It,ft,Ye,_a.horizontal,!1,kt,ke,me);Bn&&(He.horizontal[It]=Bn)}An(kt==="point"?"left":It)}}let lt=!1;if($.icon&&$.icon.name){const vt=c[$.icon.name];vt&&(Xe=hI(d[$.icon.name],D.get("icon-offset").evaluate($,{},v),D.get("icon-anchor").evaluate($,{},v)),lt=vt.sdf,a.sdfIcons===void 0?a.sdfIcons=vt.sdf:a.sdfIcons!==vt.sdf&&ge("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(vt.pixelRatio!==a.pixelRatio||D.get("icon-rotate").constantOr(1)!==0)&&(a.iconsNeedLinear=!0))}const ht=hw(He.horizontal)||He.vertical;a.iconsInText||(a.iconsInText=!!ht&&ht.iconsInText),(ht||Xe)&&bI(a,$,He,Xe,c,k,ke,0,Ye,lt,y,v,A)}m&&a.generateCollisionDebugBuffers(w,a.collisionBoxArray)}function Lv(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 bI(a,t,o,c,d,m,y,v,w,A,D,R,k){let V=m.textMaxSize.evaluate(t,{},R);V===void 0&&(V=y);const j=a.layers[0].layout,$=j.get("icon-offset").evaluate(t,{},R),ne=hw(o.horizontal)||o.vertical,me=y/24,ke=a.tilePixelRatio*V/24,He=(rt=a.overscaling,a.zoom>18&&rt>2&&(rt>>=1),Math.max(In/(512*rt),1)*j.get("symbol-spacing")),Ze=j.get("text-padding")*a.tilePixelRatio,Xe=j.get("icon-padding")*a.tilePixelRatio,Ye=U(j.get("text-max-angle")),lt=j.get("text-rotation-alignment")==="map"&&j.get("symbol-placement")!=="point",ht=j.get("icon-rotation-alignment")==="map"&&j.get("symbol-placement")!=="point",vt=j.get("symbol-placement"),Tt=He/2;var rt;const ft=j.get("icon-text-fit");let Ct;c&&ft!=="none"&&(a.allowVerticalPlacement&&o.vertical&&(Ct=Kb(c,o.vertical,ft,j.get("icon-text-fit-padding"),$,me)),ne&&(c=Kb(c,ne,ft,j.get("icon-text-fit-padding"),$,me)));const Bt=(It,kt,En)=>{if(kt.x<0||kt.x>=In||kt.y<0||kt.y>=In)return;const{x:Un,y:An,z:Bn}=k.projectTilePoint(kt.x,kt.y,En),Kt=new Jo(Un,An,Bn,0,void 0);(function(Wt,Vn,Jn,Fi,ui,Oi,Kn,Hn,ni,wi,Si,Ni,Yi,Kr,Br,ii,vr,Qr,er,$i,fi,hi,Fr,xr,Ii){const br=Wt.addToLineVertexArray(Vn,Fi);let hr,Ji,Sa,js,zp,kp,Zw,Xw=0,Yw=0,$w=0,Jw=0,Zv=-1,Xv=-1;const bo={};let Kw=fo(""),Yv=0,$v=0;if(ni._unevaluatedLayout.getValue("text-radial-offset")===void 0?[Yv,$v]=ni.layout.get("text-offset").evaluate(fi,{},Ii).map(ea=>ea*ar):(Yv=ni.layout.get("text-radial-offset").evaluate(fi,{},Ii)*ar,$v=Pv),Wt.allowVerticalPlacement&&ui.vertical){const ea=ui.vertical;if(Br)kp=Dv(ea),Hn&&(Zw=Dv(Hn));else{const ta=ni.layout.get("text-rotate").evaluate(fi,{},Ii)+90;Sa=Dg(wi,Jn,Vn,Si,Ni,Yi,ea,Kr,ta,ii),Hn&&(js=Dg(wi,Jn,Vn,Si,Ni,Yi,Hn,Qr,ta))}}if(Oi){const ea=ni.layout.get("icon-rotate").evaluate(fi,{},Ii),ta=ni.layout.get("icon-text-fit")!=="none",Bp=sw(Oi,ea,Fr,ta),Kv=Hn?sw(Hn,ea,Fr,ta):void 0;Ji=Dg(wi,Jn,Vn,Si,Ni,Yi,Oi,Qr,ea),Xw=4*Bp.length;const Qw=Wt.iconSizeData;let $l=null;Qw.kind==="source"?($l=[_o*ni.layout.get("icon-size").evaluate(fi,{},Ii)],$l[0]>Ns&&ge(`${Wt.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):Qw.kind==="composite"&&($l=[_o*hi.compositeIconSizes[0].evaluate(fi,{},Ii),_o*hi.compositeIconSizes[1].evaluate(fi,{},Ii)],($l[0]>Ns||$l[1]>Ns)&&ge(`${Wt.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),Wt.addSymbols(Wt.icon,Bp,$l,$i,er,fi,!1,Jn,Vn,br.lineStartIndex,br.lineLength,-1,xr,Ii),Zv=Wt.icon.placedSymbolArray.length-1,Kv&&(Yw=4*Kv.length,Wt.addSymbols(Wt.icon,Kv,$l,$i,er,fi,_a.vertical,Jn,Vn,br.lineStartIndex,br.lineLength,-1,xr,Ii),Xv=Wt.icon.placedSymbolArray.length-1)}for(const ea in ui.horizontal){const ta=ui.horizontal[ea];hr||(Kw=fo(ta.text),Br?zp=Dv(ta):hr=Dg(wi,Jn,Vn,Si,Ni,Yi,ta,Kr,ni.layout.get("text-rotate").evaluate(fi,{},Ii),ii));const Bp=ta.positionedLines.length===1;if($w+=uw(Wt,Jn,Vn,ta,Kn,ni,Br,fi,ii,br,ui.vertical?_a.horizontal:_a.horizontalOnly,Bp?Object.keys(ui.horizontal):[ea],bo,Zv,hi,xr,Ii),Bp)break}ui.vertical&&(Jw+=uw(Wt,Jn,Vn,ui.vertical,Kn,ni,Br,fi,ii,br,_a.vertical,["vertical"],bo,Xv,hi,xr,Ii));let qs=-1;const Jv=(ea,ta)=>ea?Math.max(ea,ta):ta;qs=Jv(zp,qs),qs=Jv(kp,qs),qs=Jv(Zw,qs);const tR=qs>-1?1:0;Wt.glyphOffsetArray.length>=Us.MAX_GLYPHS&&ge("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),fi.sortKey!==void 0&&Wt.addToSortKeyRanges(Wt.symbolInstances.length,fi.sortKey),Wt.symbolInstances.emplaceBack(Jn.x,Jn.y,Jn.z,Vn.x,Vn.y,bo.right>=0?bo.right:-1,bo.center>=0?bo.center:-1,bo.left>=0?bo.left:-1,bo.vertical>=0?bo.vertical:-1,Zv,Xv,Kw,hr!==void 0?hr:Wt.collisionBoxArray.length,hr!==void 0?hr+1:Wt.collisionBoxArray.length,Sa!==void 0?Sa:Wt.collisionBoxArray.length,Sa!==void 0?Sa+1:Wt.collisionBoxArray.length,Ji!==void 0?Ji:Wt.collisionBoxArray.length,Ji!==void 0?Ji+1:Wt.collisionBoxArray.length,js||Wt.collisionBoxArray.length,js?js+1:Wt.collisionBoxArray.length,Si,$w,Jw,Xw,Yw,tR,0,Yv,$v,qs)})(a,kt,Kt,It,o,c,d,Ct,a.layers[0],a.collisionBoxArray,t.index,t.sourceLayerIndex,a.index,Ze,lt,w,0,Xe,ht,$,t,m,A,D,R)};if(vt==="line")for(const It of rw(t.geometry,0,0,In,In)){const kt=pI(It,He,Ye,o.vertical||ne,c,24,ke,a.overscaling,In);for(const En of kt){const Un=ne;Un&&wI(a,Un.text,Tt,En)||Bt(It,En,R)}}else if(vt==="line-center"){for(const It of t.geometry)if(It.length>1){const kt=dI(It,Ye,o.vertical||ne,c,24,ke);kt&&Bt(It,kt,R)}}else if(t.type==="Polygon")for(const It of yv(t.geometry,0)){const kt=_I(It,16);Bt(It[0],new Jo(kt.x,kt.y,0,0,void 0),R)}else if(t.type==="LineString")for(const It of t.geometry)Bt(It,new Jo(It[0].x,It[0].y,0,0,void 0),R);else if(t.type==="Point")for(const It of t.geometry)for(const kt of It)Bt([kt],new Jo(kt.x,kt.y,0,0,void 0),R)}const Ns=32640;function uw(a,t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne){const me=function(Ze,Xe,Ye,lt,ht,vt,Tt,rt){const ft=[];if(Xe.positionedLines.length===0)return ft;const Ct=lt.layout.get("text-rotate").evaluate(vt,{})*Math.PI/180,Bt=function(An){const Bn=An[0],Kt=An[1],Wt=Bn*Kt;return Wt>0?[Bn,-Kt]:Wt<0?[-Bn,Kt]:Bn===0?[Kt,Bn]:[Kt,-Bn]}(Ye);let It=Math.abs(Xe.top-Xe.bottom);for(const An of Xe.positionedLines)It-=An.lineOffset;const kt=Xe.positionedLines.length,En=It/kt;let Un=Xe.top-Ye[1];for(let An=0;AnNs&&ge(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):ke.kind==="composite"&&(He=[_o*j.compositeTextSizes[0].evaluate(v,{},ne),_o*j.compositeTextSizes[1].evaluate(v,{},ne)],(He[0]>Ns||He[1]>Ns)&&ge(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),a.addSymbols(a.text,me,He,w,y,v,D,t,o,A.lineStartIndex,A.lineLength,V,$,ne);for(const Ze of R)k[Ze]=a.text.placedSymbolArray.length-1;return 4*me.length}function hw(a){for(const t in a)return a[t];return null}function Dg(a,t,o,c,d,m,y,v,w,A){let D=y.top,R=y.bottom,k=y.left,V=y.right;const j=y.collisionPadding;if(j&&(k-=j[0],D-=j[1],V+=j[2],R+=j[3]),w){const $=new E(k,D),ne=new E(V,D),me=new E(k,R),ke=new E(V,R),He=U(w);let Ze=new E(0,0);A&&(Ze=new E(A[0],A[1])),$._rotateAround(He,Ze),ne._rotateAround(He,Ze),me._rotateAround(He,Ze),ke._rotateAround(He,Ze),k=Math.min($.x,ne.x,me.x,ke.x),V=Math.max($.x,ne.x,me.x,ke.x),D=Math.min($.y,ne.y,me.y,ke.y),R=Math.max($.y,ne.y,me.y,ke.y)}return a.emplaceBack(t.x,t.y,t.z,o.x,o.y,k,D,V,R,v,c,d,m),a.length-1}function Dv(a){a.collisionPadding&&(a.top-=a.collisionPadding[1],a.bottom+=a.collisionPadding[3]);const t=a.bottom-a.top;return t>0?Math.max(10,t):null}function wI(a,t,o,c){const d=a.compareText;if(t in d){const m=d[t];for(let y=m.length-1;y>=0;y--)if(c.dist(m[y])y.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=go([]),this.placementViewportMatrix=go([]);const o=this.layers[0]._unevaluatedLayout._values;this.textSizeData=bv(this.zoom,o["text-size"]),this.iconSizeData=bv(this.zoom,o["icon-size"]);const c=this.layers[0].layout,d=c.get("symbol-sort-key"),m=c.get("symbol-z-order");this.canOverlap=c.get("text-allow-overlap")||c.get("icon-allow-overlap")||c.get("text-ignore-placement")||c.get("icon-ignore-placement"),this.sortFeaturesByKey=m!=="viewport-y"&&d.constantOr(1)!==void 0,this.sortFeaturesByY=(m==="viewport-y"||m==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=c.get("text-writing-mode").map(y=>_a[y]),this.stateDependentLayerIds=this.layers.filter(y=>y.isStateDependent()).map(y=>y.id),this.sourceID=t.sourceID,this.projection=t.projection}createArrays(){this.text=new Rv(new Hl(this.layers,this.zoom,t=>/^text/.test(t))),this.icon=new Rv(new Hl(this.layers,this.zoom,t=>/^icon/.test(t))),this.glyphOffsetArray=new $n,this.lineVertexArray=new Li,this.symbolInstances=new Ti}calculateGlyphDependencies(t,o,c,d,m){for(let y=0;y0)&&(v.value.kind!=="constant"||v.value.value.length>0),R=A.value.kind!=="constant"||!!A.value.value||Object.keys(A.parameters).length>0,k=y.get("symbol-sort-key");if(this.features=[],!D&&!R)return;const V=o.iconDependencies,j=o.glyphDependencies,$=o.availableImages,ne=new ci(this.zoom);for(const{feature:me,id:ke,index:He,sourceLayerIndex:Ze}of t){const Xe=m._featureFilter.needGeometry,Ye=Wl(me,Xe);if(!m._featureFilter.filter(ne,Ye,c))continue;let lt,ht;if(Xe||(Ye.geometry=Xo(me,c,d)),D){const Tt=m.getValueAndResolveTokens("text-field",Ye,c,$),rt=Bi.factory(Tt);EI(rt)&&(this.hasRTLText=!0),(!this.hasRTLText||ku()==="unavailable"||this.hasRTLText&&qr.isParsed())&&(lt=XD(rt,m,Ye))}if(R){const Tt=m.getValueAndResolveTokens("icon-image",Ye,c,$);ht=Tt instanceof Cr?Tt:Cr.fromString(Tt)}if(!lt&&!ht)continue;const vt=this.sortFeaturesByKey?k.evaluate(Ye,{},c):void 0;if(this.features.push({id:ke,text:lt,icon:ht,index:He,sourceLayerIndex:Ze,geometry:Ye.geometry,properties:me.properties,type:MI[me.type],sortKey:vt}),ht&&(V[ht.name]=!0),lt){const Tt=v.evaluate(Ye,{},c).join(","),rt=y.get("text-rotation-alignment")==="map"&&y.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(_a.vertical)>=0;for(const ft of lt.sections)if(ft.image)V[ft.image.name]=!0;else{const Ct=Du(lt.toString()),Bt=ft.fontStack||Tt,It=j[Bt]=j[Bt]||{};this.calculateGlyphDependencies(ft.text,It,rt,this.allowVerticalPlacement,Ct)}}}y.get("symbol-placement")==="line"&&(this.features=function(me){const ke={},He={},Ze=[];let Xe=0;function Ye(Tt){Ze.push(me[Tt]),Xe++}function lt(Tt,rt,ft){const Ct=He[Tt];return delete He[Tt],He[rt]=Ct,Ze[Ct].geometry[0].pop(),Ze[Ct].geometry[0]=Ze[Ct].geometry[0].concat(ft[0]),Ct}function ht(Tt,rt,ft){const Ct=ke[rt];return delete ke[rt],ke[Tt]=Ct,Ze[Ct].geometry[0].shift(),Ze[Ct].geometry[0]=ft[0].concat(Ze[Ct].geometry[0]),Ct}function vt(Tt,rt,ft){const Ct=ft?rt[0][rt[0].length-1]:rt[0][0];return`${Tt}:${Ct.x}:${Ct.y}`}for(let Tt=0;TtTt.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((me,ke)=>me.sortKey-ke.sortKey)}update(t,o,c,d){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,o,this.layers,c,d),this.icon.programConfigurations.updatePaintArrays(t,o,this.layers,c,d))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,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(t,o){const c=this.lineVertexArray.length,d=t.segment;if(d!==void 0){let m=t.dist(o[d+1]),y=t.dist(o[d]);const v={};for(let w=d+1;w=0;w--)v[w]={x:o[w].x,y:o[w].y,tileUnitDistanceFromAnchor:y},w>0&&(y+=o[w-1].dist(o[w]));for(let w=0;w=0?o.rightJustifiedTextSymbolIndex:o.centerJustifiedTextSymbolIndex>=0?o.centerJustifiedTextSymbolIndex:o.leftJustifiedTextSymbolIndex>=0?o.leftJustifiedTextSymbolIndex:o.verticalPlacedTextSymbolIndex>=0?o.verticalPlacedTextSymbolIndex:d),y=Eg(this.textSizeData,t,m)/ar;return this.tilePixelRatio*y}getSymbolInstanceIconSize(t,o,c){const d=this.icon.placedSymbolArray.get(c),m=Eg(this.iconSizeData,t,d);return this.tilePixelRatio*m}_commitDebugCollisionVertexUpdate(t,o,c){t.emplaceBack(o,-c,-c),t.emplaceBack(o,c,-c),t.emplaceBack(o,c,c),t.emplaceBack(o,-c,c)}_updateTextDebugCollisionBoxes(t,o,c,d,m,y){for(let v=d;v0}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(t,o){const c=t.placedSymbolArray.get(o),d=c.vertexStartIndex+4*c.numGlyphs;for(let m=c.vertexStartIndex;md[v]-d[w]||m[w]-m[v]),y}addToSortKeyRanges(t,o){const c=this.sortKeyRanges[this.sortKeyRanges.length-1];c&&c.sortKey===o?c.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:o,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const o of this.symbolInstanceIndexes){const c=this.symbolInstances.get(o);this.featureSortOrder.push(c.featureIndex),[c.rightJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.leftJustifiedTextSymbolIndex].forEach((d,m,y)=>{d>=0&&y.indexOf(d)===m&&this.addIndicesForPlacedSymbol(this.text,d)}),c.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,c.verticalPlacedTextSymbolIndex),c.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,c.placedIconSymbolIndex),c.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,c.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}jt(Us,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Us.MAX_GLYPHS=65535,Us.addDynamicAttributes=Iv;const SI=new H({"symbol-placement":new S(xe.layout_symbol["symbol-placement"]),"symbol-spacing":new S(xe.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new S(xe.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new P(xe.layout_symbol["symbol-sort-key"]),"symbol-z-order":new S(xe.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new S(xe.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new S(xe.layout_symbol["icon-ignore-placement"]),"icon-optional":new S(xe.layout_symbol["icon-optional"]),"icon-rotation-alignment":new S(xe.layout_symbol["icon-rotation-alignment"]),"icon-size":new P(xe.layout_symbol["icon-size"]),"icon-text-fit":new S(xe.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new S(xe.layout_symbol["icon-text-fit-padding"]),"icon-image":new P(xe.layout_symbol["icon-image"]),"icon-rotate":new P(xe.layout_symbol["icon-rotate"]),"icon-padding":new S(xe.layout_symbol["icon-padding"]),"icon-keep-upright":new S(xe.layout_symbol["icon-keep-upright"]),"icon-offset":new P(xe.layout_symbol["icon-offset"]),"icon-anchor":new P(xe.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new S(xe.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new S(xe.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new S(xe.layout_symbol["text-rotation-alignment"]),"text-field":new P(xe.layout_symbol["text-field"]),"text-font":new P(xe.layout_symbol["text-font"]),"text-size":new P(xe.layout_symbol["text-size"]),"text-max-width":new P(xe.layout_symbol["text-max-width"]),"text-line-height":new P(xe.layout_symbol["text-line-height"]),"text-letter-spacing":new P(xe.layout_symbol["text-letter-spacing"]),"text-justify":new P(xe.layout_symbol["text-justify"]),"text-radial-offset":new P(xe.layout_symbol["text-radial-offset"]),"text-variable-anchor":new S(xe.layout_symbol["text-variable-anchor"]),"text-anchor":new P(xe.layout_symbol["text-anchor"]),"text-max-angle":new S(xe.layout_symbol["text-max-angle"]),"text-writing-mode":new S(xe.layout_symbol["text-writing-mode"]),"text-rotate":new P(xe.layout_symbol["text-rotate"]),"text-padding":new S(xe.layout_symbol["text-padding"]),"text-keep-upright":new S(xe.layout_symbol["text-keep-upright"]),"text-transform":new P(xe.layout_symbol["text-transform"]),"text-offset":new P(xe.layout_symbol["text-offset"]),"text-allow-overlap":new S(xe.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new S(xe.layout_symbol["text-ignore-placement"]),"text-optional":new S(xe.layout_symbol["text-optional"])});var kv={paint:new H({"icon-opacity":new P(xe.paint_symbol["icon-opacity"]),"icon-color":new P(xe.paint_symbol["icon-color"]),"icon-halo-color":new P(xe.paint_symbol["icon-halo-color"]),"icon-halo-width":new P(xe.paint_symbol["icon-halo-width"]),"icon-halo-blur":new P(xe.paint_symbol["icon-halo-blur"]),"icon-translate":new S(xe.paint_symbol["icon-translate"]),"icon-translate-anchor":new S(xe.paint_symbol["icon-translate-anchor"]),"text-opacity":new P(xe.paint_symbol["text-opacity"]),"text-color":new P(xe.paint_symbol["text-color"],{runtimeType:fn,getOverride:a=>a.textColor,hasOverride:a=>!!a.textColor}),"text-halo-color":new P(xe.paint_symbol["text-halo-color"]),"text-halo-width":new P(xe.paint_symbol["text-halo-width"]),"text-halo-blur":new P(xe.paint_symbol["text-halo-blur"]),"text-translate":new S(xe.paint_symbol["text-translate"]),"text-translate-anchor":new S(xe.paint_symbol["text-translate-anchor"])}),layout:SI};class dw{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Dn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const o=this.defaultValue.property.overrides;if(o&&o.hasOverride(t.formattedSection))return o.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}jt(dw,"FormatSectionOverride",{omit:["defaultValue"]});class Rg extends Ha{constructor(t){super(t,kv)}recalculate(t,o){super.recalculate(t,o),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 c=this.layout.get("text-writing-mode");if(c){const d=[];for(const m of c)d.indexOf(m)<0&&d.push(m);this.layout._values["text-writing-mode"]=d}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(t,o,c,d){const m=this.layout.get(t).evaluate(o,{},c,d),y=this._unevaluatedLayout._values[t];return y.isDataDriven()||Ss(y.value)||!m?m:function(v,w){return w.replace(/{([^{}]+)}/g,(A,D)=>D in v?String(v[D]):"")}(o.properties,m)}createBucket(t){return new Us(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of kv.paint.overridableProperties){if(!Rg.hasPaintOverride(this.layout,t))continue;const o=this.paint.get(t),c=new dw(o),d=new bu(c,o.property.specification);let m=null;m=o.value.kind==="constant"||o.value.kind==="source"?new Nd("source",d):new Ud("composite",d,o.value.zoomStops,o.value._interpolationType),this.paint._values[t]=new x(o.property,m,o.parameters)}}_handleOverridablePaintPropertyUpdate(t,o,c){return!(!this.layout||o.isDataDriven()||c.isDataDriven())&&Rg.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,o){const c=t.get("text-field"),d=kv.paint.properties[o];let m=!1;const y=v=>{for(const w of v)if(d.overrides&&d.overrides.hasOverride(w))return void(m=!0)};if(c.value.kind==="constant"&&c.value.value instanceof Bi)y(c.value.value.sections);else if(c.value.kind==="source"){const v=A=>{m||(A instanceof Ba&&Pi(A.value)===Ar?y(A.value.sections):A instanceof bs?y(A.sections):A.eachChild(v))},w=c.value;w._styleExpression&&v(w._styleExpression.expression)}return m}getProgramConfiguration(t){return new ks(this,t)}}var AI={paint:new H({"background-color":new S(xe.paint_background["background-color"]),"background-pattern":new F(xe.paint_background["background-pattern"]),"background-opacity":new S(xe.paint_background["background-opacity"])})},CI={paint:new H({"raster-opacity":new S(xe.paint_raster["raster-opacity"]),"raster-hue-rotate":new S(xe.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new S(xe.paint_raster["raster-brightness-min"]),"raster-brightness-max":new S(xe.paint_raster["raster-brightness-max"]),"raster-saturation":new S(xe.paint_raster["raster-saturation"]),"raster-contrast":new S(xe.paint_raster["raster-contrast"]),"raster-resampling":new S(xe.paint_raster["raster-resampling"]),"raster-fade-duration":new S(xe.paint_raster["raster-fade-duration"])})};class PI extends Ha{constructor(t){super(t,{}),this.implementation=t}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)}}var LI={paint:new H({"sky-type":new S(xe.paint_sky["sky-type"]),"sky-atmosphere-sun":new S(xe.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new S(xe.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new S(xe.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new S(xe.paint_sky["sky-gradient-radius"]),"sky-gradient":new N(xe.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new S(xe.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new S(xe.paint_sky["sky-atmosphere-color"]),"sky-opacity":new S(xe.paint_sky["sky-opacity"])})};function Bv(a,t,o){const c=[0,0,1],d=yb([]);return function(m,y,v){v*=.5;var w=y[0],A=y[1],D=y[2],R=y[3],k=Math.sin(v),V=Math.cos(v);m[0]=w*V-D*k,m[1]=A*V+R*k,m[2]=D*V+w*k,m[3]=R*V-A*k}(d,d,o?-U(a)+Math.PI:U(a)),vb(d,d,-U(t)),gb(c,c,d),hp(c,c)}const DI={circle:class extends Ha{constructor(a){super(a,$L)}createBucket(a){return new tv(a)}queryRadius(a){const t=a;return Uu("circle-radius",this,t)+Uu("circle-stroke-width",this,t)+gg(this.paint.get("circle-translate"))}queryIntersectsFeature(a,t,o,c,d,m,y,v){const w=lb(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),m.angle,a.pixelToTileUnitsFactor),A=this.paint.get("circle-radius").evaluate(t,o)+this.paint.get("circle-stroke-width").evaluate(t,o);return xb(a,c,m,y,v,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",w,A)}getProgramIds(){return["circle"]}getProgramConfiguration(a){return new ks(this,a)}},heatmap:class extends Ha{createBucket(a){return new wb(a)}constructor(a){super(a,iD),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(a){a==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=fv({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 Uu("heatmap-radius",this,a)}queryIntersectsFeature(a,t,o,c,d,m,y,v){const w=this.paint.get("heatmap-radius").evaluate(t,o);return xb(a,c,m,y,v,!0,!0,new E(0,0),w)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(a){return new ks(this,a)}},hillshade:class extends Ha{constructor(a){super(a,rD)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends Ha{constructor(a){super(a,bD)}getProgramIds(){const a=this.paint.get("fill-pattern"),t=a&&a.constantOr(1),o=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&o.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),o}getProgramConfiguration(a){return new ks(this,a)}recalculate(a,t){super.recalculate(a,t);const o=this.paint._values["fill-outline-color"];o.value.kind==="constant"&&o.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(a){return new wg(a)}queryRadius(){return gg(this.paint.get("fill-translate"))}queryIntersectsFeature(a,t,o,c,d,m){return!a.queryGeometry.isAboveHorizon&&ib(sb(a.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),m.angle,a.pixelToTileUnitsFactor),c)}isTileClipped(){return!0}},"fill-extrusion":class extends Ha{constructor(a){super(a,RD)}createBucket(a){return new xp(a)}queryRadius(){return gg(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 ks(this,a)}queryIntersectsFeature(a,t,o,c,d,m,y,v,w){const A=lb(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),m.angle,a.pixelToTileUnitsFactor),D=this.paint.get("fill-extrusion-height").evaluate(t,o),R=this.paint.get("fill-extrusion-base").evaluate(t,o),k=[0,0],V=v&&m.elevation,j=m.elevation?m.elevation.exaggeration():1,$=a.tile.getBucket(this);if(V&&$ instanceof xp){const ke=$.centroidVertexArray,He=w+1;if(He=3){for(let j=0;j1&&(w=t[++v]);const D=Math.abs(A-w.left),R=Math.abs(A-w.right),k=Math.min(D,R);let V;const j=m/c*(d+1);if(w.isDash){const $=d-Math.abs(j);V=Math.sqrt(k*k+$*$)}else V=d-Math.sqrt(k*k+j*j);this.image.data[y+A]=Math.max(0,Math.min(255,V+128))}}}addRegularDash(t,o){for(let w=t.length-1;w>=0;--w){const A=t[w],D=t[w+1];A.zeroLength?t.splice(w,1):D&&D.isDash===A.isDash&&(D.left=A.left,t.splice(w,1))}const c=t[0],d=t[t.length-1];c.isDash===d.isDash&&(c.left=d.left-this.width,d.right=c.right+this.width);const m=this.width*this.nextRow;let y=0,v=t[y];for(let w=0;w1&&(v=t[++y]);const A=Math.abs(w-v.left),D=Math.abs(w-v.right),R=Math.min(A,D);this.image.data[m+w]=Math.max(0,Math.min(255,(v.isDash?R:-R)+o+128))}}addDash(t,o){const c=this.getKey(t,o);if(this.positions[c])return this.positions[c];const d=o==="round",m=d?7:0,y=2*m+1;if(this.nextRow+y>this.height)return ge("LineAtlas out of space"),null;t.length===0&&t.push(1);let v=0;for(let D=0;D{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 RI=I.performance;function pw(a){const t=a?a.url.toString():void 0;return RI.getEntriesByName(t)}class zI{constructor(){this.tasks={},this.taskQueue=[],St(["process"],this),this.invoker=new II(this.process),this.nextId=0}add(t,o){const c=this.nextId++,d=function({type:m,isSymbolTile:y,zoom:v}){return v=v||0,m==="message"?0:m!=="maybePrepare"||y?m!=="parseTile"||y?m==="parseTile"&&y?300-v:m==="maybePrepare"&&y?400-v:500:200-v:100-v}(o);if(d===0){Ie();try{t()}finally{}return{cancel:()=>{}}}return this.tasks[c]={fn:t,metadata:o,priority:d,id:c},this.taskQueue.push(c),this.invoker.trigger(),{cancel:()=>{delete this.tasks[c]}}}process(){Ie();try{if(this.taskQueue=this.taskQueue.filter(c=>!!this.tasks[c]),!this.taskQueue.length)return;const t=this.pick();if(t===null)return;const o=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!o)return;o.fn()}finally{}}pick(){let t=null,o=1/0;for(let d=0;d1?null:function(c,d,m,y){const v=Math.sin(m);return c*(Math.sin((1-y)*m)/v)+d*(Math.sin(y*m)/v)}(a.a[t],a.b[t],a.angle,ie(o,0,1))+a.center[t]}function Cp(a){if(a.z<=1)return FI[a.z+2*a.y+a.x];const[t,o]=Nv(a),c=[Ko(t[0],t[1]),Ko(t[0],o[1]),Ko(o[0],t[1]),Ko(o[0],o[1])],d=[Jr,Jr,Jr],m=[$r,$r,$r];for(const y of c)d[0]=Math.min(d[0],y[0]),d[1]=Math.min(d[1],y[1]),d[2]=Math.min(d[2],y[2]),m[0]=Math.max(m[0],y[0]),m[1]=Math.max(m[1],y[1]),m[2]=Math.max(m[2],y[2]);return new ga(d,m)}function NI(a,t,o){const c=t/a.worldSize,d=(ft,Ct)=>{up(ft,ft,c),up(Ct,Ct,c)},m=Number.MAX_VALUE,y=[-m,-m,-m],v=[m,m,m],w=xw(a);if(o.z<=1){const ft=Cp(o).getCorners();for(let Ct=0;CtMath.abs(lt))Xe=Ye>=0?1:3,Ze=V;else{Xe=lt>=0?0:2;const ft=[w[4],w[5],w[6]];let Ct;Ct=lt>=0?-Math.sin(U(R.getSouth()))*Ju:-Math.sin(U(R.getNorth()))*Ju,Ze=hv(Ze,V,ft,Ct)}const ht=k[Xe],vt=k[(Xe+1)%4],Tt=new OI(ht,vt,Ze),rt=[Ov(Tt,0)||ht[0],Ov(Tt,1)||ht[1],Ov(Tt,2)||ht[2]];return v[2]=Math.min(ht[2],vt[2]),cv(v,v,rt),uv(y,y,rt),d(v,y),new ga(v,y)}function Nv(a){const t=1<0;D--)w=1<this.canonical.z?new yr(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new yr(t,this.wrap,t,this.canonical.x>>o,this.canonical.y>>o)}calculateScaledKey(t,o=!0){if(this.overscaledZ===t&&o)return this.key;if(t>this.canonical.z)return Pp(this.wrap*+o,t,this.canonical.z,this.canonical.x,this.canonical.y);{const c=this.canonical.z-t;return Pp(this.wrap*+o,t,t,this.canonical.x>>c,this.canonical.y>>c)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const o=this.canonical.z-t.canonical.z;return t.overscaledZ===0||t.overscaledZ>o&&t.canonical.y===this.canonical.y>>o}children(t){if(this.overscaledZ>=t)return[new yr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const o=this.canonical.z+1,c=2*this.canonical.x,d=2*this.canonical.y;return[new yr(o,this.wrap,o,c,d),new yr(o,this.wrap,o,c+1,d),new yr(o,this.wrap,o,c,d+1),new yr(o,this.wrap,o,c+1,d+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.yHe&&(Ze(Ye,Bt,ht,vt,ft,Ct),Ze(Bt,lt,ft,Ct,Tt,rt))}Ze(R,k,c,m,d,m),Ze(k,V,d,m,d,y),Ze(V,j,d,y,c,y),Ze(j,R,c,y,c,m),$-=He,ne-=He,me+=He,ke+=He;const Xe=1/Math.max(me-$,ke-ne);return{scale:Xe,x:$*Xe,y:ne*Xe,x2:me*Xe,y2:ke*Xe,projection:t}}jt(zg,"CanonicalTileID"),jt(yr,"OverscaledTileID",{omit:["projMatrix"]});class Tw{constructor(t){this._stringToNumber={},this._numberToString=[];for(let o=0;o>=1)>1;){const A=o+d>>1,D=c+m>>1;1&t?(d=o,m=c,o=y,c=v):(o=d,c=m,d=y,m=v),y=A,v=D}const w=4*a;Vs[w+0]=o,Vs[w+1]=c,Vs[w+2]=d,Vs[w+3]=m}const vo=new Uint16Array(2178),Gs=new Uint8Array(1089),kg=new Uint16Array(1089);function Sw(a){return a===0?-.03125:a===32?.03125:0}var Aw=Ae([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Cw={type:2,extent:In,loadGeometry:()=>[[new E(0,0),new E(8193,0),new E(8193,8193),new E(0,8193),new E(0,0)]]};class Vv{constructor(t,o,c,d,m){this.tileID=t,this.uid=Ue(),this.uses=0,this.tileSize=o,this.tileZoom=c,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=m,this.expiredRequestCount=0,this.state="loading",d&&d.transform&&(this.projection=d.transform.projection)}registerFadeDuration(t){const o=t+this.timeAdded;om.getLayer(A)).filter(Boolean);if(w.length!==0){v.layers=w,v.stateDependentLayerIds&&(v.stateDependentLayers=v.stateDependentLayerIds.map(A=>w.filter(D=>D.id===A)[0]));for(const A of w)y[A.id]=v}}return y}(t.buckets,o.style),this.hasSymbolBuckets=!1;for(const d in this.buckets){const m=this.buckets[d];if(m instanceof Us){if(this.hasSymbolBuckets=!0,!c)break;m.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const d in this.buckets){const m=this.buckets[d];if(m instanceof Us&&m.hasRTLText){this.hasRTLText=!0,qr.isLoading()||qr.isLoaded()||ku()!=="deferred"||Ds();break}}this.queryPadding=0;for(const d in this.buckets){const m=this.buckets[d];this.queryPadding=Math.max(this.queryPadding,o.style.getLayer(d).queryRadius(m))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas)}else this.collisionBoxArray=new Ua}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].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(t){return this.buckets[t.id]}upload(t){for(const c in this.buckets){const d=this.buckets[c];d.uploadPending()&&d.upload(t)}const o=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Sp(t,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Sp(t,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Sp(t,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,o,c,d,m,y,v,w){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:d,pixelPosMatrix:v,transform:y,params:m,tileTransform:this.tileTransform},t,o,c):{}}querySourceFeatures(t,o){const c=this.latestFeatureIndex;if(!c||!c.rawTileData)return;const d=c.loadVTLayers(),m=o?o.sourceLayer:"",y=d._geojsonTileLayer||d[m];if(!y)return;const v=lo(o&&o.filter),{z:w,x:A,y:D}=this.tileID.canonical,R={z:w,x:A,y:D};for(let k=0;kc)d=!1;else if(o)if(this.expirationTime=0;ne--){const me=4*ne,ke=Vs[me+0],He=Vs[me+1],Ze=Vs[me+2],Xe=Vs[me+3],Ye=ke+Ze>>1,lt=He+Xe>>1,ht=Ye+lt-He,vt=lt+ke-Ye,Tt=He*yo+ke,rt=Xe*yo+Ze,ft=lt*yo+Ye,Ct=Math.hypot((vo[2*Tt+0]+vo[2*rt+0])/2-vo[2*ft+0],(vo[2*Tt+1]+vo[2*rt+1])/2-vo[2*ft+1])>=16;if(Gs[ft]=Gs[ft]||(Ct?1:0),ne<1022){const Bt=(He+vt>>1)*yo+(ke+ht>>1),It=(Xe+vt>>1)*yo+(Ze+ht>>1);Gs[ft]=Gs[ft]||Gs[Bt]||Gs[It]}}const R=new Re,k=new qt;let V=0;function j(ne,me){const ke=me*yo+ne;return kg[ke]===0&&(R.emplaceBack(vo[2*ke+0],vo[2*ke+1],ne*In/Ea,me*In/Ea),kg[ke]=++V),kg[ke]-1}function $(ne,me,ke,He,Ze,Xe){const Ye=ne+ke>>1,lt=me+He>>1;if(Math.abs(ne-Ze)+Math.abs(me-Xe)>1&&Gs[lt*yo+Ye])$(Ze,Xe,ne,me,Ye,lt),$(ke,He,Ze,Xe,Ye,lt);else{const ht=j(ne,me),vt=j(ke,He),Tt=j(Ze,Xe);k.emplaceBack(ht,vt,Tt)}}return $(0,0,Ea,Ea,Ea,0),$(Ea,Ea,0,0,0,Ea),{vertices:R,indices:k}}(this.tileID.canonical,o);d=y.vertices,m=y.indices}else{d=new Re,m=new qt;for(const{x:v,y:w}of c)d.emplaceBack(v,w,0,0);const y=_g(d.int16,void 0,4);for(let v=0;v{const j=(R-A)/(V-1),$=(k-D)/(V-1),ne=d.length;for(let me=0;mev*A+D;for(let A=0;At[y])return null}else{const v=1/c[y];let w=(a[y]-o[y])*v,A=(t[y]-o[y])*v;if(w>A){const D=w;w=A,A=D}if(w>d&&(d=w),Am)return null}return d}function Dw(a,t,o,c,d,m,y,v,w,A,D){const R=c-a,k=d-t,V=m-o,j=y-a,$=v-t,ne=w-o,me=D[1]*ne-D[2]*$,ke=D[2]*j-D[0]*ne,He=D[0]*$-D[1]*j,Ze=R*me+k*ke+V*He;if(Math.abs(Ze)<1e-15)return null;const Xe=1/Ze,Ye=A[0]-a,lt=A[1]-t,ht=A[2]-o,vt=(Ye*me+lt*ke+ht*He)*Xe;if(vt<0||vt>1)return null;const Tt=lt*V-ht*k,rt=ht*R-Ye*V,ft=Ye*k-lt*R,Ct=(D[0]*Tt+D[1]*rt+D[2]*ft)*Xe;return Ct<0||vt+Ct>1?null:(j*Tt+$*rt+ne*ft)*Xe}function Iw(a,t,o){return(a-t)/(o-t)}function Rw(a,t,o,c,d,m,y,v,w){const A=1<{const ke=ne?1:0,He=(V+1)*$-ke,Ze=j*$,Xe=(j+1)*$-ke;me[0]=V*$,me[1]=Ze,me[2]=He,me[3]=Xe};let R=new Pw(w);const k=[];for(let V=0;V=1;w/=2){const V=v[v.length-1];R=new Pw(w);for(let j=0;j0;){const{idx:j,t:$,nodex:ne,nodey:me,depth:ke}=V.pop();if(this.leaves[j]){Rw(ne,me,ke,t,o,c,d,R,k);const Ze=1<=kt[2])return $}continue}let He=0;for(let Ze=0;Ze=A[D[ht]]&&(D.splice(ht,0,Ze),lt=!0);lt||(D[He]=Ze),He++}}for(let Ze=0;Ze=this.dim+1||o<-1||o>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(o+1)*this.stride+(t+1)}_unpackMapbox(t,o,c){return(256*t*256+256*o+c)/10-1e4}_unpackTerrarium(t,o,c){return 256*t+o+c/256-32768}static pack(t,o){const c=[0,0,0,0],d=Bg.getUnpackVector(o);let m=Math.floor((t+d[3])/d[2]);return c[2]=m%256,m=Math.floor(m/256),c[1]=m%256,m=Math.floor(m/256),c[0]=m,c}getPixels(){return new Yr({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,o,c){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let d=o*this.dim,m=o*this.dim+this.dim,y=c*this.dim,v=c*this.dim+this.dim;switch(o){case-1:d=m-1;break;case 1:m=d+1}switch(c){case-1:y=v-1;break;case 1:v=y+1}const w=-o*this.dim,A=-c*this.dim;for(let D=y;D{this.remove(t,m)},c)),this.data[d].push(m),this.order.push(d),this.order.length>this.max){const y=this._getAndRemoveByKey(this.order[0]);y&&this.onRemove(y)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const o=this.data[t].shift();return o.timeout&&clearTimeout(o.timeout),this.data[t].length===0&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),o.value}getByKey(t){const o=this.data[t];return o?o[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,o){if(!this.has(t))return this;const c=t.wrapped().key,d=o===void 0?0:this.data[c].indexOf(o),m=this.data[c][d];return this.data[c].splice(d,1),m.timeout&&clearTimeout(m.timeout),this.data[c].length===0&&delete this.data[c],this.onRemove(m.value),this.order.splice(this.order.indexOf(c),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const o=this._getAndRemoveByKey(this.order[0]);o&&this.onRemove(o)}return this}filter(t){const o=[];for(const c in this.data)for(const d of this.data[c])t(d.value)||o.push(d);for(const c of o)this.remove(c.value.tileID,c)}}class Ku{constructor(t,o,c){this.func=t,this.mask=o,this.range=c}}Ku.ReadOnly=!1,Ku.ReadWrite=!0,Ku.disabled=new Ku(519,Ku.ReadOnly,[0,1]);const Gv=7680;class Hv{constructor(t,o,c,d,m,y){this.test=t,this.ref=o,this.mask=c,this.fail=d,this.depthFail=m,this.pass=y}}Hv.disabled=new Hv({func:519,mask:0},0,0,Gv,Gv,Gv);class xo{constructor(t,o,c){this.blendFunction=t,this.blendColor=o,this.mask=c}}xo.Replace=[1,0],xo.disabled=new xo(xo.Replace,Xn.transparent,[!1,!1,!1,!1]),xo.unblended=new xo(xo.Replace,Xn.transparent,[!0,!0,!0,!0]),xo.alphaBlended=new xo([1,771],Xn.transparent,[!0,!0,!0,!0]);const Wv=1029,jv=2305;class Wa{constructor(t,o,c){this.enable=t,this.mode=o,this.frontFace=c}}Wa.disabled=new Wa(!1,Wv,jv),Wa.backCCW=new Wa(!0,Wv,jv),Wa.backCW=new Wa(!0,Wv,2304),Wa.frontCW=new Wa(!0,1028,2304),Wa.frontCCW=new Wa(!0,1028,jv);class Yl extends ze{constructor(t,o,c){super(),this.id=t,this._onlySymbols=c,o.on("data",d=>{d.dataType==="source"&&d.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&d.dataType==="source"&&d.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),o.on("error",()=>{this._sourceErrored=!0}),this._source=o,this._tiles={},this._cache=new WI(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=o.minTileCacheSize,this._maxTileCacheSize=o.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new HI,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="custom"&&this._source._dataType==="raster"}onAdd(t){this.map=t,this._minTileCacheSize=this._minTileCacheSize===void 0&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const t in this._tiles){const o=this._tiles[t];if(o.state!=="loaded"&&o.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,o){return t.isSymbolTile=this._onlySymbols,this._source.loadTile(t,o)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,()=>{})}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t,()=>{})}serialize(){return this._source.serialize()}prepare(t){if(this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._source.prepareTile)for(const o in this._tiles){const c=this._tiles[o];this._source.prepareTile(c)&&this.map.painter.terrain&&this.map.painter.terrain._clearRenderCacheForTile(this.id,c.tileID),c.upload(t),c.prepare(this.map.style.imageManager)}else for(const o in this._tiles){const c=this._tiles[o];c.upload(t),c.prepare(this.map.style.imageManager)}}getIds(){return De(this._tiles).map(t=>t.tileID).sort(Fw).map(t=>t.key)}getRenderableIds(t){const o=[];for(const c in this._tiles)this._isIdRenderable(+c,t)&&o.push(this._tiles[c]);return t?o.sort((c,d)=>{const m=c.tileID,y=d.tileID,v=new E(m.canonical.x,m.canonical.y)._rotate(this.transform.angle),w=new E(y.canonical.x,y.canonical.y)._rotate(this.transform.angle);return m.overscaledZ-y.overscaledZ||w.y-v.y||w.x-v.x}).map(c=>c.tileID.key):o.map(c=>c.tileID).sort(Fw).map(c=>c.key)}hasRenderableParent(t){const o=this.findLoadedParent(t,0);return!!o&&this._isIdRenderable(o.tileID.key)}_isIdRenderable(t,o){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(o||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)this._tiles[t].state!=="errored"&&this._reloadTile(+t,"reloading")}}_reloadTile(t,o){const c=this._tiles[t];c&&(c.state!=="loading"&&(c.state=o),this._loadTile(c,this._tileLoaded.bind(this,c,t,o)))}_tileLoaded(t,o,c,d){if(d)if(t.state="errored",d.status!==404)this._source.fire(new Y(d,{tile:t}));else if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const m=this.map.painter.terrain;this.update(this.transform,m.getScaledDemTileSize(),!0),m.resetTileLookupCache(this.id)}else this.update(this.transform);else t.timeAdded=bt.now(),c==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(o,t),this._source.type==="raster-dem"&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new W("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const o=this.getRenderableIds();for(let d=0;d1||(Math.abs(y)>1&&(Math.abs(y+w)===1?y+=w:Math.abs(y-w)===1&&(y-=w)),m.dem&&d.dem&&(d.dem.backfillBorder(m.dem,y,v),d.neighboringTiles&&d.neighboringTiles[A]&&(d.neighboringTiles[A].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,o,c,d){for(const m in this._tiles){let y=this._tiles[m];if(d[m]||!y.hasData()||y.tileID.overscaledZ<=o||y.tileID.overscaledZ>c)continue;let v=y.tileID;for(;y&&y.tileID.overscaledZ>o+1;){const A=y.tileID.scaledTo(y.tileID.overscaledZ-1);y=this._tiles[A.key],y&&y.hasData()&&(v=A)}let w=v;for(;w.overscaledZ>o;)if(w=w.scaledTo(w.overscaledZ-1),t[w.key]){d[v.key]=v;break}}}findLoadedParent(t,o){if(t.key in this._loadedParentTiles){const c=this._loadedParentTiles[t.key];return c&&c.tileID.overscaledZ>=o?c:null}for(let c=t.overscaledZ-1;c>=o;c--){const d=t.scaledTo(c),m=this._getLoadedTile(d);if(m)return m}}_getLoadedTile(t){const o=this._tiles[t.key];return o&&o.hasData()?o:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,o){o=o||this._source.tileSize;const c=Math.ceil(t.width/o)+1,d=Math.ceil(t.height/o)+1,m=Math.floor(c*d*5),y=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,m):m,v=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,y):y;this._cache.setMaxSize(v)}handleWrapJump(t){const o=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);if(this._prevLng=t,o){const c={};for(const d in this._tiles){const m=this._tiles[d];m.tileID=m.tileID.unwrapTo(m.tileID.wrap+o),c[m.tileID.key]=m}this._tiles=c;for(const d in this._timers)clearTimeout(this._timers[d]),delete this._timers[d];for(const d in this._tiles)this._setTileReloadTimer(+d,this._tiles[d])}}update(t,o,c){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!c)return;let d;this.updateCacheSize(t,o),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?d=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(v=>new yr(v.canonical.z,v.wrap,v.canonical.z,v.canonical.x,v.canonical.y)):(d=t.coveringTiles({tileSize:o||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!c,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(d=d.filter(v=>this._source.hasTile(v)))):d=[];const m=this._updateRetainedTiles(d);if(Ow(this._source.type)&&d.length!==0){const v={},w={},A=Object.keys(m);for(const R of A){const k=m[R],V=this._tiles[R];if(!V||V.fadeEndTime&&V.fadeEndTime<=bt.now())continue;const j=this.findLoadedParent(k,Math.max(k.overscaledZ-Yl.maxOverzooming,this._source.minzoom));j&&(this._addTile(j.tileID),v[j.tileID.key]=j.tileID),w[R]=k}const D=d[d.length-1].overscaledZ;for(const R in this._tiles){const k=this._tiles[R];if(m[R]||!k.hasData())continue;let V=k.tileID;for(;V.overscaledZ>D;){V=V.scaledTo(V.overscaledZ-1);const j=this._tiles[V.key];if(j&&j.hasData()&&w[V.key]){m[R]=k.tileID;break}}}for(const R in v)m[R]||(this._coveredTiles[R]=!0,m[R]=v[R])}for(const v in m)this._tiles[v].clearFadeHold();const y=function(v,w){const A=[];for(const D in v)D in w||A.push(D);return A}(this._tiles,m);for(const v of y){const w=this._tiles[v];w.hasSymbolBuckets&&!w.holdingForFade()?w.setHoldDuration(this.map._fadeDuration):w.hasSymbolBuckets&&!w.symbolFadeFinished()||this._removeTile(+v)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const o={};if(t.length===0)return o;const c={},d=t.reduce((A,D)=>Math.min(A,D.overscaledZ),1/0),m=t[0].overscaledZ,y=Math.max(m-Yl.maxOverzooming,this._source.minzoom),v=Math.max(m+Yl.maxUnderzooming,this._source.minzoom),w={};for(const A of t){const D=this._addTile(A);o[A.key]=A,D.hasData()||d=this._source.maxzoom){const k=A.children(this._source.maxzoom)[0],V=this.getTile(k);if(V&&V.hasData()){o[k.key]=k;continue}}else{const k=A.children(this._source.maxzoom);if(o[k[0].key]&&o[k[1].key]&&o[k[2].key]&&o[k[3].key])continue}let R=D.wasRequested();for(let k=A.overscaledZ-1;k>=y;--k){const V=A.scaledTo(k);if(c[V.key]||(c[V.key]=!0,D=this.getTile(V),!D&&R&&(D=this._addTile(V)),D&&(o[V.key]=V,R=D.wasRequested(),D.hasData())))break}}return o}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const o=[];let c,d=this._tiles[t].tileID;for(;d.overscaledZ>0;){if(d.key in this._loadedParentTiles){c=this._loadedParentTiles[d.key];break}o.push(d.key);const m=d.scaledTo(d.overscaledZ-1);if(c=this._getLoadedTile(m),c)break;d=m}for(const m of o)this._loadedParentTiles[m]=c}}_addTile(t){let o=this._tiles[t.key];if(o)return this._source.prepareTile&&this._source.prepareTile(o),o;o=this._cache.getAndRemove(t),o&&(this._setTileReloadTimer(t.key,o),o.tileID=t,this._state.initializeTileState(o,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,o)));const c=!!o;if(!c){const d=this.map?this.map.painter:null;o=new Vv(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,d,this._isRaster),this._source.prepareTile&&this._source.prepareTile(o)||this._loadTile(o,this._tileLoaded.bind(this,o,t.key,o.state))}return o?(o.uses++,this._tiles[t.key]=o,c||this._source.fire(new W("dataloading",{tile:o,coord:o.tileID,dataType:"source"})),o):null}_setTileReloadTimer(t,o){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const c=o.getExpiryTimeout();c&&(this._timers[t]=setTimeout(()=>{this._reloadTile(t,"expired"),delete this._timers[t]},c))}_removeTile(t){const o=this._tiles[t];o&&(o.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),o.uses>0||(o.hasData()&&o.state!=="reloading"?this._cache.add(o.tileID,o,o.getExpiryTimeout()):(o.aborted=!0,this._abortTile(o),this._unloadTile(o))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);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(t,o,c){const d=[],m=this.transform;if(!m)return d;for(const y in this._tiles){const v=this._tiles[y];if(c&&v.clearQueryDebugViz(),v.holdingForFade())continue;const w=t.containsTile(v,m,o);w&&d.push(w)}return d}getVisibleCoordinates(t){const o=this.getRenderableIds(t).map(c=>this._tiles[c].tileID);for(const c of o)c.projMatrix=this.transform.calculateProjMatrix(c.toUnwrapped());return o}hasTransition(){if(this._source.hasTransition())return!0;if(Ow(this._source.type))for(const t in this._tiles){const o=this._tiles[t];if(o.fadeEndTime!==void 0&&o.fadeEndTime>=bt.now())return!0}return!1}setFeatureState(t,o,c){this._state.updateState(t=t||"_geojsonTileLayer",o,c)}removeFeatureState(t,o,c){this._state.removeFeatureState(t=t||"_geojsonTileLayer",o,c)}getFeatureState(t,o){return this._state.getState(t=t||"_geojsonTileLayer",o)}setDependencies(t,o,c){const d=this._tiles[t];d&&d.setDependencies(o,c)}reloadTilesForDependencies(t,o){for(const c in this._tiles)this._tiles[c].hasDependency(t,o)&&this._reloadTile(+c,"reloading");this._cache.filter(c=>!c.hasDependency(t,o))}_preloadTiles(t,o){const c=new Map,d=Array.isArray(t)?t:[t],m=this.map.painter.terrain,y=this.usedForTerrain&&m?m.getScaledDemTileSize():this._source.tileSize;for(const v of d){const w=v.coveringTiles({tileSize:y,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const A of w)c.set(A.key,A);this.usedForTerrain&&v.updateElevation(!1)}le(Array.from(c.values()),(v,w)=>{const A=new Vv(v,this._source.tileSize*v.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(A,D=>{this._source.type==="raster-dem"&&A.dem&&this._backfillDEM(A),w(D,A)})},o)}}function Fw(a,t){const o=Math.abs(2*a.wrap)-+(a.wrap<0),c=Math.abs(2*t.wrap)-+(t.wrap<0);return a.overscaledZ-t.overscaledZ||c-o||t.canonical.y-a.canonical.y||t.canonical.x-a.canonical.x}function Ow(a){return a==="raster"||a==="image"||a==="video"}Yl.maxOverzooming=10,Yl.maxUnderzooming=3;class Fg{constructor(t,o,c){this._demTile=t,this._dem=this._demTile.dem,this._scale=o,this._offset=c}static create(t,o,c){const d=c||t.findDEMTileFor(o);if(!d||!d.dem)return;const m=d.dem,y=d.tileID,v=1<=0&&R[3]>=0&&w.insert(v,R[0],R[1],R[2],R[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Zl.VectorTile(new Mp(this.rawTileData)).layers,this.sourceLayerCoder=new Tw(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,o,c,d){this.loadVTLayers();const m=t.params||{},y=lo(m.filter),v=t.tileResult,w=t.transform,A=v.bufferedTilespaceBounds,D=this.grid.query(A.min.x,A.min.y,A.max.x,A.max.y,(j,$,ne,me)=>ob(v.bufferedTilespaceGeometry,j,$,ne,me));D.sort(jI);let R=null;w.elevation&&D.length>0&&(R=Fg.create(w.elevation,this.tileID));const k={};let V;for(let j=0;j(me||(me=Xo(ke,this.tileID.canonical,t.tileTransform)),He.queryIntersectsFeature(v,ke,Ze,me,this.z,t.transform,t.pixelPosMatrix,R,Xe)))}return k}loadMatchingFeature(t,o,c,d,m,y,v,w,A){const{featureIndex:D,bucketIndex:R,sourceLayerIndex:k,layoutVertexArrayOffset:V}=o,j=this.bucketLayerIDs[R];if(d&&!function(ke,He){for(let Ze=0;Ze=0)return!0;return!1}(d,j))return;const $=this.sourceLayerCoder.decode(k),ne=this.vtLayers[$].feature(D);if(c.needGeometry){const ke=Wl(ne,!0);if(!c.filter(new ci(this.tileID.overscaledZ),ke,this.tileID.canonical))return}else if(!c.filter(new ci(this.tileID.overscaledZ),ne))return;const me=this.getId(ne,$);for(let ke=0;ke{const v=t instanceof b?t.get(y):null;return v&&v.evaluate?v.evaluate(o,c,d):v})}function jI(a,t){return t-a}jt(Nw,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class Vw{constructor(t){const o={},c=[];for(const v in t){const w=t[v],A=o[v]={};for(const D in w.glyphs){const R=w.glyphs[+D];if(!R||R.bitmap.width===0||R.bitmap.height===0)continue;const k=R.metrics.localGlyph?2:1,V={x:0,y:0,w:R.bitmap.width+2*k,h:R.bitmap.height+2*k};c.push(V),A[D]=V}}const{w:d,h:m}=Mv(c),y=new Yo({width:d||1,height:m||1});for(const v in t){const w=t[v];for(const A in w.glyphs){const D=w.glyphs[+A];if(!D||D.bitmap.width===0||D.bitmap.height===0)continue;const R=o[v][A],k=D.metrics.localGlyph?2:1;Yo.copy(D.bitmap,y,{x:0,y:0},{x:R.x+k,y:R.y+k},D.bitmap)}}this.image=y,this.positions=o}}jt(Vw,"GlyphAtlas");class qI{constructor(t){this.tileID=new yr(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.enableTerrain=!!t.enableTerrain,this.isSymbolTile=t.isSymbolTile,this.tileTransform=Xl(t.tileID.canonical,t.projection),this.projection=t.projection}parse(t,o,c,d,m){this.status="parsing",this.data=t,this.collisionBoxArray=new Ua;const y=new Tw(Object.keys(t.layers).sort()),v=new Nw(this.tileID,this.promoteId);v.bucketLayerIDs=[];const w={},A=new Fv(256,256),D={featureIndex:v,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:A,availableImages:c},R=o.familiesBySource[this.source];for(const Xe in R){const Ye=t.layers[Xe];if(!Ye)continue;let lt=!1,ht=!1;for(const rt of R[Xe])rt[0].type==="symbol"?lt=!0:ht=!0;if(this.isSymbolTile===!0&&!lt||this.isSymbolTile===!1&&!ht)continue;Ye.version===1&&ge(`Vector tile source "${this.source}" layer "${Xe}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const vt=y.encode(Xe),Tt=[];for(let rt=0;rt=ft.maxzoom||ft.visibility!=="none"&&(qv(rt,this.zoom,c),(w[ft.id]=ft.createBucket({index:v.bucketLayerIDs.length,layers:rt,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:vt,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.name,availableImages:c})).populate(Tt,D,this.tileID.canonical,this.tileTransform),v.bucketLayerIDs.push(rt.map(Ct=>Ct.id)))}}let k,V,j,$;A.trim();const ne={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},me=At(D.glyphDependencies,Xe=>Object.keys(Xe).map(Number));Object.keys(me).length?d.send("getGlyphs",{uid:this.uid,stacks:me},(Xe,Ye)=>{k||(k=Xe,V=Ye,Ze.call(this))},void 0,!1,ne):V={};const ke=Object.keys(D.iconDependencies);ke.length?d.send("getImages",{icons:ke,source:this.source,tileID:this.tileID,type:"icons"},(Xe,Ye)=>{k||(k=Xe,j=Ye,Ze.call(this))},void 0,!1,ne):j={};const He=Object.keys(D.patternDependencies);function Ze(){if(k)return m(k);if(V&&j&&$){const Xe=new Vw(V),Ye=new qb(j,$);for(const lt in w){const ht=w[lt];ht instanceof Us?(qv(ht.layers,this.zoom,c),xI(ht,V,Xe.positions,j,Ye.iconPositions,this.showCollisionBoxes,c,this.tileID.canonical,this.tileZoom,this.projection)):ht.hasPattern&&(ht instanceof Tg||ht instanceof wg||ht instanceof xp)&&(qv(ht.layers,this.zoom,c),ht.addFeatures(D,this.tileID.canonical,Ye.patternPositions,c,this.tileTransform))}this.status="done",m(null,{buckets:De(w).filter(lt=>!lt.isEmpty()),featureIndex:v,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Xe.image,lineAtlas:A,imageAtlas:Ye,glyphMap:this.returnDependencies?V:null,iconMap:this.returnDependencies?j:null,glyphPositions:this.returnDependencies?Xe.positions:null})}}He.length?d.send("getImages",{icons:He,source:this.source,tileID:this.tileID,type:"patterns"},(Xe,Ye)=>{k||(k=Xe,$=Ye,Ze.call(this))},void 0,!1,ne):$={},Ze.call(this)}}function qv(a,t,o){const c=new ci(t);for(const d of a)d.recalculate(c,o)}class Gw{constructor(t){this.entries={},this.scheduler=t}request(t,o,c,d){const m=this.entries[t]=this.entries[t]||{callbacks:[]};if(m.result){const[y,v]=m.result;return this.scheduler?this.scheduler.add(()=>{d(y,v)},o):d(y,v),()=>{}}return m.callbacks.push(d),m.cancel||(m.cancel=c((y,v)=>{m.result=[y,v];for(const w of m.callbacks)this.scheduler?this.scheduler.add(()=>{w(y,v)},o):w(y,v);setTimeout(()=>delete this.entries[t],3e3)})),()=>{m.result||(m.callbacks=m.callbacks.filter(y=>y!==d),m.callbacks.length||(m.cancel(),delete this.entries[t]))}}}function Hw(a,t,o){const c=JSON.stringify(a.request);return a.data&&(this.deduped.entries[c]={result:[null,a.data]}),this.deduped.request(c,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom},d=>{const m=Le(a.request,(y,v,w,A)=>{y?d(y):v&&d(null,{vectorTile:o?void 0:new Zl.VectorTile(new Mp(v)),rawData:v,cacheControl:w,expires:A})});return()=>{m.cancel(),d()}},t)}const ZI=go(new Float32Array(16));class Ws{constructor(t){this.name=t.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(t,o){return{x:0,y:0,z:0}}unproject(t,o){return new ti(0,0)}projectTilePoint(t,o,c){return{x:t,y:o,z:0}}locationPoint(t,o){return t._coordinatePoint(t.locationCoordinate(o),!1)}pixelsPerMeter(t,o){return Ou(1,t)*o}farthestPixelDistance(t){return function(o,c){const d=o.fovAboveCenter,m=o.elevation?o.elevation.getMinElevationBelowMSL()*c:0,y=(o._camera.position[2]*o.worldSize-m)/Math.cos(o._pitch),v=Math.sin(d)*y/Math.sin(Math.max(Math.PI/2-o._pitch-d,.01)),w=Math.sin(o._pitch)*v+y;return Math.min(1.01*w,y*(1/o._horizonShift))}(t,t.pixelsPerMeter)}pointCoordinate(t,o,c,d){const m=t.horizonLineFromTop(!1),y=new E(o,Math.max(m,c));return t.rayIntersectionCoordinate(t.pointRayIntersection(y,d))}createInversionMatrix(t,o){return ZI}createTileMatrix(t,o,c){let d,m,y;const v=c.canonical,w=go(new Float64Array(16));if(this.isReprojectedInTileSpace){const A=Xl(v,this);d=1,m=A.x+c.wrap*A.scale,y=A.y,Fs(w,w,[d/A.scale,d/A.scale,t.pixelsPerMeter/o])}else d=o/t.zoomScale(v.z),m=(v.x+Math.pow(2,v.z)*c.wrap)*d,y=v.y*d;return jl(w,w,[m,y,0]),Fs(w,w,[d/In,d/In,1]),w}upVector(t,o,c){return[0,0,1]}upVectorScale(t,o,c){return{metersToTile:1,metersToLabelSpace:1}}}class XI extends Ws{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(t,o){return{x:lp(t),y:Fu(o),z:0}}unproject(t,o){const c=Ta(t),d=rr(o);return new ti(c,d)}}class YI extends Ws{constructor(t){super(t),this.range=[4,7],this.center=t.center||[-96,37.5];const[o,c]=this.parallels=t.parallels||[29.5,45.5],d=Math.sin(U(o));this.n=(d+Math.sin(U(c)))/2,this.c=1+d*(2*this.n-d),this.r0=Math.sqrt(this.c)/this.n}project(t,o){const{n:c,c:d,r0:m}=this,y=U(t-this.center[0]),v=U(o),w=Math.sqrt(d-2*c*Math.sin(v))/c;return{x:w*Math.sin(y*c),y:w*Math.cos(y*c)-m,z:0}}unproject(t,o){const{n:c,c:d,r0:m}=this,y=m+o;let v=Math.atan2(t,Math.abs(y))*Math.sign(y);y*c<0&&(v-=Math.PI*Math.sign(t)*Math.sign(y));const w=U(this.center[0])*c;v=ae(v,-Math.PI-w,Math.PI-w);const A=q(v/c)+this.center[0],D=Math.asin(ie((d-(t*t+y*y)*c*c)/(2*c),-1,1)),R=ie(q(D),-85.051129,mo);return new ti(A,R)}}const Lp=1.340264,Dp=-.081106,Ip=893e-6,Rp=.003796,Og=Math.sqrt(3)/2;class $I extends Ws{project(t,o){o=o/180*Math.PI,t=t/180*Math.PI;const c=Math.asin(Og*Math.sin(o)),d=c*c,m=d*d*d;return{x:.5*(t*Math.cos(c)/(Og*(Lp+3*Dp*d+m*(7*Ip+9*Rp*d)))/Math.PI+.5),y:1-.5*(c*(Lp+Dp*d+m*(Ip+Rp*d))/Math.PI+1),z:0}}unproject(t,o){t=(2*t-.5)*Math.PI;let c=o=(2*(1-o)-1)*Math.PI,d=c*c,m=d*d*d;for(let D,R,k,V=0;V<12&&(R=c*(Lp+Dp*d+m*(Ip+Rp*d))-o,k=Lp+3*Dp*d+m*(7*Ip+9*Rp*d),D=R/k,c=ie(c-D,-Math.PI/3,Math.PI/3),d=c*c,m=d*d*d,!(Math.abs(D)<1e-12));++V);const y=Og*t*(Lp+3*Dp*d+m*(7*Ip+9*Rp*d))/Math.cos(c),v=Math.asin(Math.sin(c)/Og),w=ie(180*y/Math.PI,-180,180),A=ie(180*v/Math.PI,-85.051129,mo);return new ti(w,A)}}class JI extends Ws{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0}project(t,o){return{x:.5+t/360,y:.5-o/360,z:0}}unproject(t,o){const c=360*(t-.5),d=ie(360*(.5-o),-85.051129,mo);return new ti(c,d)}}const Qu=Math.PI/2;function Ng(a){return Math.tan((Qu+a)/2)}class KI extends Ws{constructor(t){super(t),this.center=t.center||[0,30];const[o,c]=this.parallels=t.parallels||[30,30],d=U(o),m=U(c),y=Math.cos(d);this.n=d===m?Math.sin(d):Math.log(y/Math.cos(m))/Math.log(Ng(m)/Ng(d)),this.f=y*Math.pow(Ng(d),this.n)/this.n}project(t,o){o=U(o),t=U(t-this.center[0]);const c=1e-6,{n:d,f:m}=this;m>0?o<-Qu+c&&(o=-Qu+c):o>Qu-c&&(o=Qu-c);const y=m/Math.pow(Ng(o),d),v=y*Math.sin(d*t),w=m-y*Math.cos(d*t);return{x:.5*(v/Math.PI+.5),y:1-.5*(w/Math.PI+.5),z:0}}unproject(t,o){t=(2*t-.5)*Math.PI,o=(2*(1-o)-.5)*Math.PI;const{n:c,f:d}=this,m=d-o,y=Math.sign(m),v=Math.sign(c)*Math.sqrt(t*t+m*m);let w=Math.atan2(t,Math.abs(m))*y;m*c<0&&(w-=Math.PI*Math.sign(t)*y);const A=ie(q(w/c)+this.center[0],-180,180),D=ie(q(2*Math.atan(Math.pow(d/v,1/c))-Qu),-85.051129,mo);return new ti(A,D)}}const Ww=U(mo);class QI extends Ws{project(t,o){const c=(o=U(o))*o,d=c*c;return{x:.5*((t=U(t))*(.8707-.131979*c+d*(d*(.003971*c-.001529*d)-.013791))/Math.PI+.5),y:1-.5*(o*(1.007226+c*(.015085+d*(.028874*c-.044475-.005916*d)))/Math.PI+1),z:0}}unproject(t,o){t=(2*t-.5)*Math.PI;let c=o=(2*(1-o)-1)*Math.PI,d=25,m=0,y=c*c;do{y=c*c;const A=y*y;m=(c*(1.007226+y*(.015085+A*(.028874*y-.044475-.005916*A)))-o)/(1.007226+y*(.045255+A*(.259866*y-.311325-.06507600000000001*A))),c=ie(c-m,-Ww,Ww)}while(Math.abs(m)>1e-6&&--d>0);y=c*c;const v=ie(q(t/(.8707+y*(y*(y*y*y*(.003971-.001529*y)-.013791)-.131979))),-180,180),w=q(c);return new ti(v,w)}}const jw=U(mo);class eR extends Ws{project(t,o){o=U(o),t=U(t);const c=Math.cos(o),d=2/Math.PI,m=Math.acos(c*Math.cos(t/2)),y=Math.sin(m)/m,v=.5*(t*d+2*c*Math.sin(t/2)/y)||0,w=.5*(o+Math.sin(o)/y)||0;return{x:.5*(v/Math.PI+.5),y:1-.5*(w/Math.PI+1),z:0}}unproject(t,o){let c=t=(2*t-.5)*Math.PI,d=o=(2*(1-o)-1)*Math.PI,m=25;const y=1e-6;let v=0,w=0;do{const A=Math.cos(d),D=Math.sin(d),R=2*D*A,k=D*D,V=A*A,j=Math.cos(c/2),$=Math.sin(c/2),ne=2*j*$,me=$*$,ke=1-V*j*j,He=ke?1/ke:0,Ze=ke?Math.acos(A*j)*Math.sqrt(1/ke):0,Xe=.5*(2*Ze*A*$+2*c/Math.PI)-t,Ye=.5*(Ze*D+d)-o,lt=.5*He*(V*me+Ze*A*j*k)+1/Math.PI,ht=He*(ne*R/4-Ze*D*$),vt=.125*He*(R*$-Ze*D*V*ne),Tt=.5*He*(k*j+Ze*me*A)+.5,rt=ht*vt-Tt*lt;v=(Ye*ht-Xe*Tt)/rt,w=(Xe*vt-Ye*lt)/rt,c=ie(c-v,-Math.PI,Math.PI),d=ie(d-w,-jw,jw)}while((Math.abs(v)>y||Math.abs(w)>y)&&--m>0);return new ti(q(c),q(d))}}class qw extends Ws{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(U(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,o){const{scale:c,cosPhi:d}=this;return{x:U(t)*d*c+.5,y:-Math.sin(U(o))/d*c+.5,z:0}}unproject(t,o){const{scale:c,cosPhi:d}=this,m=-(o-.5)/c,y=ie(q((t-.5)/c)/d,-180,180),v=Math.asin(ie(m*d,-1,1)),w=ie(q(v),-85.051129,mo);return new ti(y,w)}}s.ARRAY_TYPE=Xr,s.AUTH_ERR_MSG=bn,s.Aabb=ga,s.Actor=class{constructor(a,t,o){this.target=a,this.parent=t,this.mapId=o,this.callbacks={},this.cancelCallbacks={},St(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=Ie()?a:I,this.scheduler=new zI}send(a,t,o,c,d=!1,m){const y=Math.round(1e18*Math.random()).toString(36).substring(0,10);o&&(o.metadata=m,this.callbacks[y]=o);const v=$e(this.globalScope)?void 0:[];return this.target.postMessage({id:y,type:a,hasCallback:!!o,targetMapId:c,mustQueue:d,sourceMapId:this.mapId,data:kl(t,v)},v),{cancel:()=>{o&&delete this.callbacks[y],this.target.postMessage({id:y,type:"",targetMapId:c,sourceMapId:this.mapId})}}}receive(a){const t=a.data,o=t.id;if(o&&(!t.targetMapId||this.mapId===t.targetMapId))if(t.type===""){const c=this.cancelCallbacks[o];delete this.cancelCallbacks[o],c&&c.cancel()}else if(t.mustQueue||Ie()){const c=this.callbacks[o];this.cancelCallbacks[o]=this.scheduler.add(()=>this.processTask(o,t),c&&c.metadata||{type:"message"})}else this.processTask(o,t)}processTask(a,t){if(t.type===""){const o=this.callbacks[a];delete this.callbacks[a],o&&(t.error?o(Ps(t.error)):o(null,Ps(t.data)))}else{const o=$e(this.globalScope)?void 0:[],c=t.hasCallback?(m,y)=>{delete this.cancelCallbacks[a],this.target.postMessage({id:a,type:"",sourceMapId:this.mapId,error:m?kl(m):null,data:kl(y,o)},o)}:m=>{},d=Ps(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,d,c);else if(this.parent.getWorkerSource){const m=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,m[0],d.source)[m[1]](d,c)}else c(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},s.CanonicalTileID=zg,s.Color=Xn,s.ColorMode=xo,s.CullFaceMode=Wa,s.DEMData=Bg,s.DataConstantProperty=S,s.DedupedRequest=Gw,s.DepthMode=Ku,s.EXTENT=In,s.Elevation=class{isDataAvailableAtPoint(a){const t=this._source();if(!t||a.y<0||a.y>1)return!1;const o=t.getSource().maxzoom,c=1<1)return t;const d=c.getSource().maxzoom,m=1<{const m=this.getAtTileOffset(a,d.x,d.y),y=c.upVector(a.canonical,d.x,d.y);return up(y,y,m*c.upVectorScale(a.canonical,t,o).metersToTile),y}}getForTilePoints(a,t,o,c){const d=Fg.create(this,a,c);return!!d&&(t.forEach(m=>{m[2]=this.exaggeration()*d.getElevationAt(m[0],m[1],o)}),!0)}getMinMaxForTile(a){const t=this.findDEMTileFor(a);if(!t||!t.dem)return null;const o=t.dem.tree,c=t.tileID,d=1<this._skuTokenExpiresAt}transformRequest(a,t){return this._transformRequestFn&&this._transformRequestFn(a,t)||{url:a}}normalizeStyleURL(a,t){if(!ln(a))return a;const o=Zt(a);return o.path=`/styles/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||t)}normalizeGlyphsURL(a,t){if(!ln(a))return a;const o=Zt(a);return o.path=`/fonts/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||t)}normalizeSourceURL(a,t){if(!ln(a))return a;const o=Zt(a);return o.path=`/v4/${o.authority}.json`,o.params.push("secure"),this._makeAPIURL(o,this._customAccessToken||t)}normalizeSpriteURL(a,t,o,c){const d=Zt(a);return ln(a)?(d.path=`/styles/v1${d.path}/sprite${t}${o}`,this._makeAPIURL(d,this._customAccessToken||c)):(d.path+=`${t}${o}`,qe(d))}normalizeTileURL(a,t,o){if(this._isSkuTokenExpired()&&this._createSkuToken(),a&&!ln(a))return a;const c=Zt(a);c.path=c.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||o&&c.authority!=="raster"&&o===512?"@2x":""}${ve.supported?".webp":"$1"}`),c.authority==="raster"?c.path=`/${oe.RASTER_URL_PREFIX}${c.path}`:(c.path=c.path.replace(/^.+\/v4\//,"/"),c.path=`/${oe.TILE_URL_VERSION}${c.path}`);const d=this._customAccessToken||function(m){for(const y of m){const v=y.match(/^access_token=(.*)$/);if(v)return v[1]}return null}(c.params)||oe.ACCESS_TOKEN;return oe.REQUIRE_ACCESS_TOKEN&&d&&this._skuToken&&c.params.push(`sku=${this._skuToken}`),this._makeAPIURL(c,d)}canonicalizeTileURL(a,t){const o=Zt(a);if(!o.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!o.path.match(/\.[\w]+$/))return a;let c="mapbox://";o.path.match(/^\/raster\/v1\//)?c+=`raster/${o.path.replace(`/${oe.RASTER_URL_PREFIX}/`,"")}`:c+=`tiles/${o.path.replace(`/${oe.TILE_URL_VERSION}/`,"")}`;let d=o.params;return t&&(d=d.filter(m=>!m.match(/^access_token=/))),d.length&&(c+=`?${d.join("&")}`),c}canonicalizeTileset(a,t){const o=!!t&&ln(t),c=[];for(const d of a.tiles||[])Gt(d)?c.push(this.canonicalizeTileURL(d,o)):c.push(d);return c}_makeAPIURL(a,t){const o="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",c=Zt(oe.API_URL);if(a.protocol=c.protocol,a.authority=c.authority,a.protocol==="http"){const d=a.params.indexOf("secure");d>=0&&a.params.splice(d,1)}if(c.path!=="/"&&(a.path=`${c.path}${a.path}`),!oe.REQUIRE_ACCESS_TOKEN)return qe(a);if(t=t||oe.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${o}`);if(t[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${o}`)}return a.params=a.params.filter(d=>d.indexOf("access_token")===-1),a.params.push(`access_token=${t||""}`),qe(a)}},s.ResourceType=_e,s.SegmentVector=Ei,s.SourceCache=Yl,s.StencilMode=Hv,s.StructArrayLayout1ui2=qn,s.StructArrayLayout2f1f2i16=Jt,s.StructArrayLayout2i4=Te,s.StructArrayLayout2ui4=Mn,s.StructArrayLayout3f12=Rt,s.StructArrayLayout3ui6=qt,s.StructArrayLayout4i8=Re,s.Texture=Sp,s.Tile=Vv,s.Transitionable=f,s.Uniform1f=hg,s.Uniform1i=class extends qo{constructor(a,t){super(a,t),this.current=0}set(a){this.current!==a&&(this.current=a,this.gl.uniform1i(this.location,a))}},s.Uniform2f=class extends qo{constructor(a,t){super(a,t),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]))}},s.Uniform3f=class extends qo{constructor(a,t){super(a,t),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]))}},s.Uniform4f=$1,s.UniformColor=J1,s.UniformMatrix2f=class extends qo{constructor(a,t){super(a,t),this.current=BL}set(a){for(let t=0;t<4;t++)if(a[t]!==this.current[t]){this.current=a,this.gl.uniformMatrix2fv(this.location,!1,a);break}}},s.UniformMatrix3f=class extends qo{constructor(a,t){super(a,t),this.current=kL}set(a){for(let t=0;t<9;t++)if(a[t]!==this.current[t]){this.current=a,this.gl.uniformMatrix3fv(this.location,!1,a);break}}},s.UniformMatrix4f=class extends qo{constructor(a,t){super(a,t),this.current=zL}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 t=1;t<16;t++)if(a[t]!==this.current[t]){this.current=a,this.gl.uniformMatrix4fv(this.location,!1,a);break}}},s.UnwrappedTileID=Mw,s.ValidationError=Ht,s.VectorTileWorkerSource=class extends ze{constructor(a,t,o,c,d){super(),this.actor=a,this.layerIndex=t,this.availableImages=o,this.loadVectorData=d||Hw,this.loading={},this.loaded={},this.deduped=new Gw(a.scheduler),this.isSpriteLoaded=c,this.scheduler=a.scheduler}loadTile(a,t){const o=a.uid,c=a&&a.request,d=c&&c.collectResourceTiming,m=this.loading[o]=new qI(a);m.abort=this.loadVectorData(a,(y,v)=>{const w=!this.loading[o];if(delete this.loading[o],w||y||!v)return m.status="done",w||(this.loaded[o]=m),t(y);const A=v.rawData,D={};v.expires&&(D.expires=v.expires),v.cacheControl&&(D.cacheControl=v.cacheControl),m.vectorTile=v.vectorTile||new Zl.VectorTile(new Mp(A));const R=()=>{m.parse(m.vectorTile,this.layerIndex,this.availableImages,this.actor,(k,V)=>{if(k||!V)return t(k);const j={};if(d){const $=pw(c);$.length>0&&(j.resourceTiming=JSON.parse(JSON.stringify($)))}t(null,ye({rawTileData:A.slice(0)},V,D,j))})};this.isSpriteLoaded?R():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(R,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom}):R()}),this.loaded=this.loaded||{},this.loaded[o]=m})}reloadTile(a,t){const o=this.loaded,c=a.uid,d=this;if(o&&o[c]){const m=o[c];m.showCollisionBoxes=a.showCollisionBoxes,m.enableTerrain=!!a.enableTerrain,m.projection=a.projection,m.tileTransform=Xl(a.tileID.canonical,a.projection);const y=(v,w)=>{const A=m.reloadCallback;A&&(delete m.reloadCallback,m.parse(m.vectorTile,d.layerIndex,this.availableImages,d.actor,A)),t(v,w)};m.status==="parsing"?m.reloadCallback=y:m.status==="done"&&(m.vectorTile?m.parse(m.vectorTile,this.layerIndex,this.availableImages,this.actor,y):y())}}abortTile(a,t){const o=a.uid,c=this.loading[o];c&&(c.abort&&c.abort(),delete this.loading[o]),t()}removeTile(a,t){const o=this.loaded,c=a.uid;o&&o[c]&&delete o[c],t()}},s.WritingMode=_a,s.ZoomHistory=Xd,s.add=db,s.addDynamicAttributes=Iv,s.adjoint=function(a,t){var o=t[0],c=t[1],d=t[2],m=t[3],y=t[4],v=t[5],w=t[6],A=t[7],D=t[8];return a[0]=y*D-v*A,a[1]=d*A-c*D,a[2]=c*v-d*y,a[3]=v*w-m*D,a[4]=o*D-d*w,a[5]=d*m-o*v,a[6]=m*A-y*w,a[7]=c*w-o*A,a[8]=o*y-c*m,a},s.asyncAll=le,s.bezier=Ce,s.bindAll=St,s.boundsAttributes=Aw,s.bufferConvexPolygon=function(a,t){const o=[];for(let c=0;cHr&&(a.getActor().send("enforceCacheSizeLimit",yi),Sr=0)},s.calculateGlobeLabelMatrix=function(a,t){const{lng:o,lat:c}=a._center,d=vw(0,0,a.worldSize/a._projectionScaler,o,c);return av(d,d,function(m){const y=go(new Float64Array(16)),v=1/Uv(m);return jl(y,y,m.min),Fs(y,y,[v,v,v]),y}(Cp(t)))},s.calculateGlobeMatrix=xw,s.calculateGlobeMercatorMatrix=function(a){const t=a.worldSize,o=a.point,c=Ou(1,a.center.lat)*t,d=a.pixelsPerMeter,m=t/(c/a.pixelsPerMeter),y=go(new Float64Array(16));return jl(y,y,[o.x,o.y,0]),Fs(y,y,[m,m,d]),Float32Array.from(y)},s.circumferenceAtLatitude=Ky,s.clamp=ie,s.clearTileCache=function(a){const t=I.caches.delete(Ci);a&&t.catch(a).then(()=>a())},s.clipLine=rw,s.clone=function(a){var t=new Xr(16);return t[0]=a[0],t[1]=a[1],t[2]=a[2],t[3]=a[3],t[4]=a[4],t[5]=a[5],t[6]=a[6],t[7]=a[7],t[8]=a[8],t[9]=a[9],t[10]=a[10],t[11]=a[11],t[12]=a[12],t[13]=a[13],t[14]=a[14],t[15]=a[15],t},s.clone$1=Ot,s.collisionCircleLayout=qD,s.config=oe,s.conjugate=function(a,t){return a[0]=-t[0],a[1]=-t[1],a[2]=-t[2],a[3]=t[3],a},s.create=function(){var a=new Xr(16);return Xr!=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},s.create$1=cb,s.createExpression=Al,s.createLayout=Ae,s.createStyleLayer=function(a){return a.type==="custom"?new PI(a):new DI[a.type](a)},s.cross=mb,s.degToRad=U,s.div=function(a,t,o){return a[0]=t[0]/o[0],a[1]=t[1]/o[1],a[2]=t[2]/o[2],a},s.dot=dp,s.earthRadius=Jy,s.ease=K,s.easeCubicInOut=he,s.emitValidationErrors=jm,s.endsWith=gt,s.enforceCacheSizeLimit=function(a){ki(),ei&&ei.then(t=>{t.keys().then(o=>{for(let c=0;cm&&(c+=(a[d]-m)*(a[d]-m)),t[d]{}}},s.globeECEFOrigin=function(a,t){const o=[0,0,0];return ql(o,o,yw(Cp(t.canonical))),ql(o,o,a),o},s.globePixelsToTileUnits=function(a,t){return In/(512*Math.pow(2,a))*Uv(Cp(t))},s.globePoleMatrixForTile=function(a,t,o){const c=go(new Float64Array(16)),d=1<0&&(y=1/Math.sqrt(y)),a[0]=o*y,a[1]=c*y,a[2]=d*y,a[3]=m*y,a},s.number=gn,s.ortho=function(a,t,o,c,d,m,y){var v=1/(t-o),w=1/(c-d),A=1/(m-y);return a[0]=-2*v,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=-2*w,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=2*A,a[11]=0,a[12]=(t+o)*v,a[13]=(d+c)*w,a[14]=(y+m)*A,a[15]=1,a},s.pbf=Mp,s.perspective=function(a,t,o,c,d){var m,y=1/Math.tan(t/2);return a[0]=y/o,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=y,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,d!=null&&d!==1/0?(a[10]=(d+c)*(m=1/(c-d)),a[14]=2*d*c*m):(a[10]=-1,a[14]=-2*c),a},s.pick=function(a,t){const o={};for(let c=0;cNa(uo(a)),s.validateFog=a=>Na(Wm(a)),s.validateLayer=a=>Na(Nm(a)),s.validateLight=a=>Na(Gm(a)),s.validateSource=a=>Na(Vm(a)),s.validateStyle=zl,s.validateTerrain=a=>Na(Hm(a)),s.values=De,s.vectorTile=Zl,s.version=M,s.warnOnce=ge,s.window=I,s.wrap=ae}),p(["./shared"],function(s){function M(_e){if(typeof _e=="number"||typeof _e=="boolean"||typeof _e=="string"||_e==null)return JSON.stringify(_e);if(Array.isArray(_e)){let Z="[";for(const de of _e)Z+=`${M(de)},`;return`${Z}]`}let G="{";for(const Z of Object.keys(_e).sort())G+=`${Z}:${M(_e[Z])},`;return`${G}}`}function T(_e){let G="";for(const Z of s.refProperties)G+=`/${M(_e[Z])}`;return G}class C{constructor(G){this.keyCache={},G&&this.replace(G)}replace(G){this._layerConfigs={},this._layers={},this.update(G,[])}update(G,Z){for(const Le of G)this._layerConfigs[Le.id]=Le,(this._layers[Le.id]=s.createStyleLayer(Le)).compileFilter(),this.keyCache[Le.id]&&delete this.keyCache[Le.id];for(const Le of Z)delete this.keyCache[Le],delete this._layerConfigs[Le],delete this._layers[Le];this.familiesBySource={};const de=function(Le,Ge){const Je={};for(let je=0;jethis._layers[Ut.id]),Je=Ge[0];if(Je.visibility==="none")continue;const Ke=Je.source||"";let je=this.familiesBySource[Ke];je||(je=this.familiesBySource[Ke]={});const nt=Je.sourceLayer||"_geojsonTileLayer";let yt=je[nt];yt||(yt=je[nt]=[]),yt.push(Ge)}}}class E{loadTile(G,Z){const{uid:de,encoding:Le,rawImageData:Ge,padding:Je,buildQuadTree:Ke}=G,je=s.window.ImageBitmap&&Ge instanceof s.window.ImageBitmap?this.getImageData(Ge,Je):Ge;Z(null,new s.DEMData(de,je,Le,Je<1,Ke))}getImageData(G,Z){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(G.width,G.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=G.width,this.offscreenCanvas.height=G.height,this.offscreenCanvasContext.drawImage(G,0,0,G.width,G.height);const de=this.offscreenCanvasContext.getImageData(-Z,-Z,G.width+2*Z,G.height+2*Z);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),de}}var L=function _e(G,Z){var de,Le=G&&G.type;if(Le==="FeatureCollection")for(de=0;de=Math.abs(Ke)?Z-je+Ke:Ke-je+Z,Z=je}Z+de>=0!=!!G&&_e.reverse()}const O=s.vectorTile.VectorTileFeature.prototype.toGeoJSON;class U{constructor(G){this._feature=G,this.extent=s.EXTENT,this.type=G.type,this.properties=G.tags,"id"in G&&!isNaN(G.id)&&(this.id=parseInt(G.id,10))}loadGeometry(){if(this._feature.type===1){const G=[];for(const Z of this._feature.geometry)G.push([new s.pointGeometry(Z[0],Z[1])]);return G}{const G=[];for(const Z of this._feature.geometry){const de=[];for(const Le of Z)de.push(new s.pointGeometry(Le[0],Le[1]));G.push(de)}return G}}toGeoJSON(G,Z,de){return O.call(this,G,Z,de)}}class q{constructor(G){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=s.EXTENT,this.length=G.length,this._features=G}feature(G){return new U(this._features[G])}}var ee=s.vectorTile.VectorTileFeature,he=Ce;function Ce(_e,G){this.options=G||{},this.features=_e,this.length=_e.length}function K(_e,G){this.id=typeof _e.id=="number"?_e.id:void 0,this.type=_e.type,this.rawGeometry=_e.type===1?[_e.geometry]:_e.geometry,this.properties=_e.tags,this.extent=G||4096}Ce.prototype.feature=function(_e){return new K(this.features[_e],this.options.extent)},K.prototype.loadGeometry=function(){var _e=this.rawGeometry;this.geometry=[];for(var G=0;G<_e.length;G++){for(var Z=_e[G],de=[],Le=0;Le>31}function Oe(_e,G){for(var Z=_e.loadGeometry(),de=_e.type,Le=0,Ge=0,Je=Z.length,Ke=0;Ke>1;St(_e,G,Je,de,Le,Ge%2),st(_e,G,Z,de,Je-1,Ge+1),st(_e,G,Z,Je+1,Le,Ge+1)}function St(_e,G,Z,de,Le,Ge){for(;Le>de;){if(Le-de>600){const nt=Le-de+1,yt=Z-de+1,Ut=Math.log(nt),Et=.5*Math.exp(2*Ut/3),_n=.5*Math.sqrt(Ut*Et*(nt-Et)/nt)*(yt-nt/2<0?-1:1);St(_e,G,Z,Math.max(de,Math.floor(Z-yt*Et/nt+_n)),Math.min(Le,Math.floor(Z+(nt-yt)*Et/nt+_n)),Ge)}const Je=G[2*Z+Ge];let Ke=de,je=Le;for(gt(_e,G,de,Z),G[2*Le+Ge]>Je&>(_e,G,de,Le);KeJe;)je--}G[2*de+Ge]===Je?gt(_e,G,de,je):(je++,gt(_e,G,je,Le)),je<=Z&&(de=je+1),Z<=je&&(Le=je-1)}}function gt(_e,G,Z,de){At(_e,Z,de),At(G,2*Z,2*de),At(G,2*Z+1,2*de+1)}function At(_e,G,Z){const de=_e[G];_e[G]=_e[Z],_e[Z]=de}function Dt(_e,G,Z,de){const Le=_e-Z,Ge=G-de;return Le*Le+Ge*Ge}ie.fromVectorTileJs=ae,ie.fromGeojsonVt=function(_e,G){G=G||{};var Z={};for(var de in _e)Z[de]=new he(_e[de].features,G),Z[de].name=de,Z[de].version=G.version,Z[de].extent=G.extent;return ae({layers:Z})},ie.GeoJSONWrapper=ue;const Ot=_e=>_e[0],Pe=_e=>_e[1];class ge{constructor(G,Z=Ot,de=Pe,Le=64,Ge=Float64Array){this.nodeSize=Le,this.points=G;const Je=G.length<65536?Uint16Array:Uint32Array,Ke=this.ids=new Je(G.length),je=this.coords=new Ge(2*G.length);for(let nt=0;nt=Ke&&W<=nt&&Y>=je&&Y<=yt&&_n.push(Ge[nn]);continue}const _t=Math.floor((Mt+xe)/2);W=Je[2*_t],Y=Je[2*_t+1],W>=Ke&&W<=nt&&Y>=je&&Y<=yt&&_n.push(Ge[_t]);const Ft=(ze+1)%2;(ze===0?Ke<=W:je<=Y)&&(Et.push(Mt),Et.push(_t-1),Et.push(Ft)),(ze===0?nt>=W:yt>=Y)&&(Et.push(_t+1),Et.push(xe),Et.push(Ft))}return _n}(this.ids,this.coords,G,Z,de,Le,this.nodeSize)}within(G,Z,de){return function(Le,Ge,Je,Ke,je,nt){const yt=[0,Le.length-1,0],Ut=[],Et=je*je;for(;yt.length;){const _n=yt.pop(),W=yt.pop(),Y=yt.pop();if(W-Y<=nt){for(let Ft=Y;Ft<=W;Ft++)Dt(Ge[2*Ft],Ge[2*Ft+1],Je,Ke)<=Et&&Ut.push(Le[Ft]);continue}const ze=Math.floor((Y+W)/2),xe=Ge[2*ze],Mt=Ge[2*ze+1];Dt(xe,Mt,Je,Ke)<=Et&&Ut.push(Le[ze]);const _t=(_n+1)%2;(_n===0?Je-je<=xe:Ke-je<=Mt)&&(yt.push(Y),yt.push(ze-1),yt.push(_t)),(_n===0?Je+je>=xe:Ke+je>=Mt)&&(yt.push(ze+1),yt.push(W),yt.push(_t))}return Ut}(this.ids,this.coords,G,Z,de,this.nodeSize)}}const Ve={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:_e=>_e},Ne=Math.fround||(Ie=new Float32Array(1),_e=>(Ie[0]=+_e,Ie[0]));var Ie;class it{constructor(G){this.options=bt(Object.create(Ve),G),this.trees=new Array(this.options.maxZoom+1)}load(G){const{log:Z,minZoom:de,maxZoom:Le,nodeSize:Ge}=this.options;Z&&console.time("total time");const Je=`prepare ${G.length} points`;Z&&console.time(Je),this.points=G;let Ke=[];for(let je=0;je=de;je--){const nt=+Date.now();Ke=this._cluster(Ke,je),this.trees[je]=new ge(Ke,Vt,oe,Ge,Float32Array),Z&&console.log("z%d: %d clusters in %dms",je,Ke.length,+Date.now()-nt)}return Z&&console.timeEnd("total time"),this}getClusters(G,Z){let de=((G[0]+180)%360+360)%360-180;const Le=Math.max(-90,Math.min(90,G[1]));let Ge=G[2]===180?180:((G[2]+180)%360+360)%360-180;const Je=Math.max(-90,Math.min(90,G[3]));if(G[2]-G[0]>=360)de=-180,Ge=180;else if(de>Ge){const yt=this.getClusters([de,Le,180,Je],Z),Ut=this.getClusters([-180,Le,Ge,Je],Z);return yt.concat(Ut)}const Ke=this.trees[this._limitZoom(Z)],je=Ke.range(Be(de),$e(Je),Be(Ge),$e(Le)),nt=[];for(const yt of je){const Ut=Ke.points[yt];nt.push(Ut.numPoints?Me(Ut):this.points[Ut.index])}return nt}getChildren(G){const Z=this._getOriginId(G),de=this._getOriginZoom(G),Le="No cluster with the specified id.",Ge=this.trees[de];if(!Ge)throw new Error(Le);const Je=Ge.points[Z];if(!Je)throw new Error(Le);const Ke=this.options.radius/(this.options.extent*Math.pow(2,de-1)),je=Ge.within(Je.x,Je.y,Ke),nt=[];for(const yt of je){const Ut=Ge.points[yt];Ut.parentId===G&&nt.push(Ut.numPoints?Me(Ut):this.points[Ut.index])}if(nt.length===0)throw new Error(Le);return nt}getLeaves(G,Z,de){const Le=[];return this._appendLeaves(Le,G,Z=Z||10,de=de||0,0),Le}getTile(G,Z,de){const Le=this.trees[this._limitZoom(G)],Ge=Math.pow(2,G),{extent:Je,radius:Ke}=this.options,je=Ke/Je,nt=(de-je)/Ge,yt=(de+1+je)/Ge,Ut={features:[]};return this._addTileFeatures(Le.range((Z-je)/Ge,nt,(Z+1+je)/Ge,yt),Le.points,Z,de,Ge,Ut),Z===0&&this._addTileFeatures(Le.range(1-je/Ge,nt,1,yt),Le.points,Ge,de,Ge,Ut),Z===Ge-1&&this._addTileFeatures(Le.range(0,nt,je/Ge,yt),Le.points,-1,de,Ge,Ut),Ut.features.length?Ut:null}getClusterExpansionZoom(G){let Z=this._getOriginZoom(G)-1;for(;Z<=this.options.maxZoom;){const de=this.getChildren(G);if(Z++,de.length!==1)break;G=de[0].properties.cluster_id}return Z}_appendLeaves(G,Z,de,Le,Ge){const Je=this.getChildren(Z);for(const Ke of Je){const je=Ke.properties;if(je&&je.cluster?Ge+je.point_count<=Le?Ge+=je.point_count:Ge=this._appendLeaves(G,je.cluster_id,de,Le,Ge):GeZ&&(W+=ze.numPoints||1)}if(W>_n&&W>=Ke){let Y=yt.x*_n,ze=yt.y*_n,xe=Je&&_n>1?this._map(yt,!0):null;const Mt=(nt<<5)+(Z+1)+this.points.length;for(const _t of Et){const Ft=Ut.points[_t];if(Ft.zoom<=Z)continue;Ft.zoom=Z;const nn=Ft.numPoints||1;Y+=Ft.x*nn,ze+=Ft.y*nn,Ft.parentId=Mt,Je&&(xe||(xe=this._map(yt,!0)),Je(xe,this._map(Ft)))}yt.parentId=Mt,de.push(ce(Y/W,ze/W,Mt,W,xe))}else if(de.push(yt),W>1)for(const Y of Et){const ze=Ut.points[Y];ze.zoom<=Z||(ze.zoom=Z,de.push(ze))}}return de}_getOriginId(G){return G-this.points.length>>5}_getOriginZoom(G){return(G-this.points.length)%32}_map(G,Z){if(G.numPoints)return Z?bt({},G.properties):G.properties;const de=this.points[G.index].properties,Le=this.options.map(de);return Z&&Le===de?bt({},Le):Le}}function ce(_e,G,Z,de,Le){return{x:Ne(_e),y:Ne(G),zoom:1/0,id:Z,parentId:-1,numPoints:de,properties:Le}}function we(_e,G){const[Z,de]=_e.geometry.coordinates;return{x:Ne(Be(Z)),y:Ne($e(de)),zoom:1/0,index:G,parentId:-1}}function Me(_e){return{type:"Feature",id:_e.id,properties:pe(_e),geometry:{type:"Point",coordinates:[(G=_e.x,360*(G-.5)),ot(_e.y)]}};var G}function pe(_e){const G=_e.numPoints,Z=G>=1e4?`${Math.round(G/1e3)}k`:G>=1e3?Math.round(G/100)/10+"k":G;return bt(bt({},_e.properties),{cluster:!0,cluster_id:_e.id,point_count:G,point_count_abbreviated:Z})}function Be(_e){return _e/360+.5}function $e(_e){const G=Math.sin(_e*Math.PI/180),Z=.5-.25*Math.log((1+G)/(1-G))/Math.PI;return Z<0?0:Z>1?1:Z}function ot(_e){const G=(180-360*_e)*Math.PI/180;return 360*Math.atan(Math.exp(G))/Math.PI-90}function bt(_e,G){for(const Z in G)_e[Z]=G[Z];return _e}function Vt(_e){return _e.x}function oe(_e){return _e.y}function ve(_e,G,Z,de){for(var Le,Ge=de,Je=Z-G>>1,Ke=Z-G,je=_e[G],nt=_e[G+1],yt=_e[Z],Ut=_e[Z+1],Et=G+3;EtGe)Le=Et,Ge=_n;else if(_n===Ge){var W=Math.abs(Et-Je);Wde&&(Le-G>3&&ve(_e,G,Le,de),_e[Le+2]=Ge,Z-Le>3&&ve(_e,Le,Z,de))}function xt(_e,G,Z,de,Le,Ge){var Je=Le-Z,Ke=Ge-de;if(Je!==0||Ke!==0){var je=((_e-Z)*Je+(G-de)*Ke)/(Je*Je+Ke*Ke);je>1?(Z=Le,de=Ge):je>0&&(Z+=Je*je,de+=Ke*je)}return(Je=_e-Z)*Je+(Ke=G-de)*Ke}function mt(_e,G,Z,de){var Le={id:_e===void 0?null:_e,type:G,geometry:Z,tags:de,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(Ge){var Je=Ge.geometry,Ke=Ge.type;if(Ke==="Point"||Ke==="MultiPoint"||Ke==="LineString")xn(Ge,Je);else if(Ke==="Polygon"||Ke==="MultiLineString")for(var je=0;je0&&(Je+=de?(Le*nt-je*Ge)/2:Math.sqrt(Math.pow(je-Le,2)+Math.pow(nt-Ge,2))),Le=je,Ge=nt}var yt=G.length-3;G[2]=1,ve(G,0,yt,Z),G[yt+2]=1,G.size=Math.abs(Je),G.start=0,G.end=G.size}function bn(_e,G,Z,de){for(var Le=0;Le<_e.length;Le++){var Ge=[];dn(_e[Le],Ge,Z,de),G.push(Ge)}}function ln(_e){return _e/360+.5}function Gt(_e){var G=Math.sin(_e*Math.PI/180),Z=.5-.25*Math.log((1+G)/(1-G))/Math.PI;return Z<0?0:Z>1?1:Z}function on(_e,G,Z,de,Le,Ge,Je,Ke){if(de/=G,Ge>=(Z/=G)&&Je=de)return null;for(var je=[],nt=0;nt<_e.length;nt++){var yt=_e[nt],Ut=yt.geometry,Et=yt.type,_n=Le===0?yt.minX:yt.minY,W=Le===0?yt.maxX:yt.maxY;if(_n>=Z&&W=de)){var Y=[];if(Et==="Point"||Et==="MultiPoint")Zt(Ut,Y,Z,de,Le);else if(Et==="LineString")qe(Ut,Y,Z,de,Le,!1,Ke.lineMetrics);else if(Et==="MultiLineString")Qt(Ut,Y,Z,de,Le,!1);else if(Et==="Polygon")Qt(Ut,Y,Z,de,Le,!0);else if(Et==="MultiPolygon")for(var ze=0;ze=Z&&Je<=de&&(G.push(_e[Ge]),G.push(_e[Ge+1]),G.push(_e[Ge+2]))}}function qe(_e,G,Z,de,Le,Ge,Je){for(var Ke,je,nt=Nt(_e),yt=Le===0?pn:On,Ut=_e.start,Et=0;Et<_e.length-3;Et+=3){var _n=_e[Et],W=_e[Et+1],Y=_e[Et+2],ze=_e[Et+3],xe=_e[Et+4],Mt=Le===0?_n:W,_t=Le===0?ze:xe,Ft=!1;Je&&(Ke=Math.sqrt(Math.pow(_n-ze,2)+Math.pow(W-xe,2))),MtZ&&(je=yt(nt,_n,W,ze,xe,Z),Je&&(nt.start=Ut+Ke*je)):Mt>de?_t=Z&&(je=yt(nt,_n,W,ze,xe,Z),Ft=!0),_t>de&&Mt<=de&&(je=yt(nt,_n,W,ze,xe,de),Ft=!0),!Ge&&Ft&&(Je&&(nt.end=Ut+Ke*je),G.push(nt),nt=Nt(_e)),Je&&(Ut+=Ke)}var nn=_e.length-3;_n=_e[nn],W=_e[nn+1],Y=_e[nn+2],(Mt=Le===0?_n:W)>=Z&&Mt<=de&&Pn(nt,_n,W,Y),nn=nt.length-3,Ge&&nn>=3&&(nt[nn]!==nt[0]||nt[nn+1]!==nt[1])&&Pn(nt,nt[0],nt[1],nt[2]),nt.length&&G.push(nt)}function Nt(_e){var G=[];return G.size=_e.size,G.start=_e.start,G.end=_e.end,G}function Qt(_e,G,Z,de,Le,Ge){for(var Je=0;Je<_e.length;Je++)qe(_e[Je],G,Z,de,Le,Ge,!1)}function Pn(_e,G,Z,de){_e.push(G),_e.push(Z),_e.push(de)}function pn(_e,G,Z,de,Le,Ge){var Je=(Ge-G)/(de-G);return _e.push(Ge),_e.push(Z+(Le-Z)*Je),_e.push(1),Je}function On(_e,G,Z,de,Le,Ge){var Je=(Ge-Z)/(Le-Z);return _e.push(G+(de-G)*Je),_e.push(Ge),_e.push(1),Je}function Gn(_e,G){for(var Z=[],de=0;de<_e.length;de++){var Le,Ge=_e[de],Je=Ge.type;if(Je==="Point"||Je==="MultiPoint"||Je==="LineString")Le=Zn(Ge.geometry,G);else if(Je==="MultiLineString"||Je==="Polygon"){Le=[];for(var Ke=0;KeJe.maxX&&(Je.maxX=yt),Ut>Je.maxY&&(Je.maxY=Ut)}return Je}function ei(_e,G,Z,de){var Le=G.geometry,Ge=G.type,Je=[];if(Ge==="Point"||Ge==="MultiPoint")for(var Ke=0;Ke0&&G.size<(Le?Je:de))Z.numPoints+=G.length/3;else{for(var Ke=[],je=0;jeJe)&&(Z.numSimplified++,Ke.push(G[je]),Ke.push(G[je+1])),Z.numPoints++;Le&&function(nt,yt){for(var Ut=0,Et=0,_n=nt.length,W=_n-2;Et<_n;W=Et,Et+=2)Ut+=(nt[Et]-nt[W])*(nt[Et+1]+nt[W+1]);if(Ut>0===yt)for(Et=0,_n=nt.length;Et<_n/2;Et+=2){var Y=nt[Et],ze=nt[Et+1];nt[Et]=nt[_n-2-Et],nt[Et+1]=nt[_n-1-Et],nt[_n-2-Et]=Y,nt[_n-1-Et]=ze}}(Ke,Ge),_e.push(Ke)}}function yi(_e,G){var Z=(G=this.options=function(Le,Ge){for(var Je in Ge)Le[Je]=Ge[Je];return Le}(Object.create(this.options),G)).debug;if(Z&&console.time("preprocess data"),G.maxZoom<0||G.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(G.promoteId&&G.generateId)throw new Error("promoteId and generateId cannot be used together.");var de=function(Le,Ge){var Je=[];if(Le.type==="FeatureCollection")for(var Ke=0;Ke1&&console.time("creation"),Et=this.tiles[Ut]=Ci(_e,G,Z,de,je),this.tileCoords.push({z:G,x:Z,y:de}),nt)){nt>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",G,Z,de,Et.numFeatures,Et.numPoints,Et.numSimplified),console.timeEnd("creation"));var _n="z"+G;this.stats[_n]=(this.stats[_n]||0)+1,this.total++}if(Et.source=_e,Le){if(G===je.maxZoom||G===Le)continue;var W=1<1&&console.time("clipping");var Y,ze,xe,Mt,_t,Ft,nn=.5*je.buffer/je.extent,Ln=.5-nn,Dn=.5+nn,wt=1+nn;Y=ze=xe=Mt=null,_t=on(_e,yt,Z-nn,Z+Dn,0,Et.minX,Et.maxX,je),Ft=on(_e,yt,Z+Ln,Z+wt,0,Et.minX,Et.maxX,je),_e=null,_t&&(Y=on(_t,yt,de-nn,de+Dn,1,Et.minY,Et.maxY,je),ze=on(_t,yt,de+Ln,de+wt,1,Et.minY,Et.maxY,je),_t=null),Ft&&(xe=on(Ft,yt,de-nn,de+Dn,1,Et.minY,Et.maxY,je),Mt=on(Ft,yt,de+Ln,de+wt,1,Et.minY,Et.maxY,je),Ft=null),nt>1&&console.timeEnd("clipping"),Ke.push(Y||[],G+1,2*Z,2*de),Ke.push(ze||[],G+1,2*Z,2*de+1),Ke.push(xe||[],G+1,2*Z+1,2*de),Ke.push(Mt||[],G+1,2*Z+1,2*de+1)}}},yi.prototype.getTile=function(_e,G,Z){var de=this.options,Le=de.extent,Ge=de.debug;if(_e<0||_e>24)return null;var Je=1<<_e,Ke=Hr(_e,G=(G%Je+Je)%Je,Z);if(this.tiles[Ke])return Wi(this.tiles[Ke],Le);Ge>1&&console.log("drilling down to z%d-%d-%d",_e,G,Z);for(var je,nt=_e,yt=G,Ut=Z;!je&&nt>0;)nt--,yt=Math.floor(yt/2),Ut=Math.floor(Ut/2),je=this.tiles[Hr(nt,yt,Ut)];return je&&je.source?(Ge>1&&console.log("found parent tile z%d-%d-%d",nt,yt,Ut),Ge>1&&console.time("drilling down"),this.splitTile(je.source,nt,yt,Ut,_e,G,Z),Ge>1&&console.timeEnd("drilling down"),this.tiles[Ke]?Wi(this.tiles[Ke],Le):null):null};class Wr extends s.VectorTileWorkerSource{constructor(G,Z,de,Le,Ge){super(G,Z,de,Le,ki),Ge&&(this.loadGeoJSON=Ge)}loadData(G,Z){const de=G&&G.request,Le=de&&de.collectResourceTiming;this.loadGeoJSON(G,(Ge,Je)=>{if(Ge||!Je)return Z(Ge);if(typeof Je!="object")return Z(new Error(`Input data given to '${G.source}' is not a valid GeoJSON object.`));{L(Je,!0);try{if(G.filter){const je=s.createExpression(G.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(je.result==="error")throw new Error(je.value.map(yt=>`${yt.key}: ${yt.message}`).join(", "));Je={type:"FeatureCollection",features:Je.features.filter(yt=>je.value.evaluate({zoom:0},yt))}}this._geoJSONIndex=G.cluster?new it(function({superclusterOptions:je,clusterProperties:nt}){if(!nt||!je)return je;const yt={},Ut={},Et={accumulated:null,zoom:0},_n={properties:null},W=Object.keys(nt);for(const Y of W){const[ze,xe]=nt[Y],Mt=s.createExpression(xe),_t=s.createExpression(typeof ze=="string"?[ze,["accumulated"],["get",Y]]:ze);yt[Y]=Mt.value,Ut[Y]=_t.value}return je.map=Y=>{_n.properties=Y;const ze={};for(const xe of W)ze[xe]=yt[xe].evaluate(Et,_n);return ze},je.reduce=(Y,ze)=>{_n.properties=ze;for(const xe of W)Et.accumulated=Y[xe],Y[xe]=Ut[xe].evaluate(Et,_n)},je}(G)).load(Je.features):function(je,nt){return new yi(je,nt)}(Je,G.geojsonVtOptions)}catch(je){return Z(je)}this.loaded={};const Ke={};if(Le){const je=s.getPerformanceMeasurement(de);je&&(Ke.resourceTiming={},Ke.resourceTiming[G.source]=JSON.parse(JSON.stringify(je)))}Z(null,Ke)}})}reloadTile(G,Z){const de=this.loaded;return de&&de[G.uid]?super.reloadTile(G,Z):this.loadTile(G,Z)}loadGeoJSON(G,Z){if(G.request)s.getJSON(G.request,Z);else{if(typeof G.data!="string")return Z(new Error(`Input data given to '${G.source}' is not a valid GeoJSON object.`));try{return Z(null,JSON.parse(G.data))}catch(de){return Z(new Error(`Input data given to '${G.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(G,Z){try{Z(null,this._geoJSONIndex.getClusterExpansionZoom(G.clusterId))}catch(de){Z(de)}}getClusterChildren(G,Z){try{Z(null,this._geoJSONIndex.getChildren(G.clusterId))}catch(de){Z(de)}}getClusterLeaves(G,Z){try{Z(null,this._geoJSONIndex.getLeaves(G.clusterId,G.limit,G.offset))}catch(de){Z(de)}}}class Sr{constructor(G){this.self=G,this.actor=new s.Actor(G,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=s.getProjection({name:"mercator"}),this.workerSourceTypes={vector:s.VectorTileWorkerSource,geojson:Wr},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(Z,de)=>{if(this.workerSourceTypes[Z])throw new Error(`Worker source with name "${Z}" already registered.`);this.workerSourceTypes[Z]=de},this.self.registerRTLTextPlugin=Z=>{if(s.plugin.isParsed())throw new Error("RTL text plugin already registered.");s.plugin.applyArabicShaping=Z.applyArabicShaping,s.plugin.processBidirectionalText=Z.processBidirectionalText,s.plugin.processStyledBidirectionalText=Z.processStyledBidirectionalText}}clearCaches(G,Z,de){delete this.layerIndexes[G],delete this.availableImages[G],delete this.workerSources[G],delete this.demWorkerSources[G],de()}checkIfReady(G,Z,de){de()}setReferrer(G,Z){this.referrer=Z}spriteLoaded(G,Z){this.isSpriteLoaded[G]=Z;for(const de in this.workerSources[G]){const Le=this.workerSources[G][de];for(const Ge in Le)Le[Ge]instanceof s.VectorTileWorkerSource&&(Le[Ge].isSpriteLoaded=Z,Le[Ge].fire(new s.Event("isSpriteLoaded")))}}setImages(G,Z,de){this.availableImages[G]=Z;for(const Le in this.workerSources[G]){const Ge=this.workerSources[G][Le];for(const Je in Ge)Ge[Je].availableImages=Z}de()}enableTerrain(G,Z,de){this.terrain=Z,de()}setProjection(G,Z){this.projections[G]=s.getProjection(Z)}setLayers(G,Z,de){this.getLayerIndex(G).replace(Z),de()}updateLayers(G,Z,de){this.getLayerIndex(G).update(Z.layers,Z.removedIds),de()}loadTile(G,Z,de){const Le=this.enableTerrain?s.extend({enableTerrain:this.terrain},Z):Z;Le.projection=this.projections[G]||this.defaultProjection,this.getWorkerSource(G,Z.type,Z.source).loadTile(Le,de)}loadDEMTile(G,Z,de){const Le=this.enableTerrain?s.extend({buildQuadTree:this.terrain},Z):Z;this.getDEMWorkerSource(G,Z.source).loadTile(Le,de)}reloadTile(G,Z,de){const Le=this.enableTerrain?s.extend({enableTerrain:this.terrain},Z):Z;Le.projection=this.projections[G]||this.defaultProjection,this.getWorkerSource(G,Z.type,Z.source).reloadTile(Le,de)}abortTile(G,Z,de){this.getWorkerSource(G,Z.type,Z.source).abortTile(Z,de)}removeTile(G,Z,de){this.getWorkerSource(G,Z.type,Z.source).removeTile(Z,de)}removeSource(G,Z,de){if(!this.workerSources[G]||!this.workerSources[G][Z.type]||!this.workerSources[G][Z.type][Z.source])return;const Le=this.workerSources[G][Z.type][Z.source];delete this.workerSources[G][Z.type][Z.source],Le.removeSource!==void 0?Le.removeSource(Z,de):de()}loadWorkerSource(G,Z,de){try{this.self.importScripts(Z.url),de()}catch(Le){de(Le.toString())}}syncRTLPluginState(G,Z,de){try{s.plugin.setState(Z);const Le=s.plugin.getPluginURL();if(s.plugin.isLoaded()&&!s.plugin.isParsed()&&Le!=null){this.self.importScripts(Le);const Ge=s.plugin.isParsed();de(Ge?void 0:new Error(`RTL Text Plugin failed to import scripts from ${Le}`),Ge)}}catch(Le){de(Le.toString())}}getAvailableImages(G){let Z=this.availableImages[G];return Z||(Z=[]),Z}getLayerIndex(G){let Z=this.layerIndexes[G];return Z||(Z=this.layerIndexes[G]=new C),Z}getWorkerSource(G,Z,de){return this.workerSources[G]||(this.workerSources[G]={}),this.workerSources[G][Z]||(this.workerSources[G][Z]={}),this.workerSources[G][Z][de]||(this.workerSources[G][Z][de]=new this.workerSourceTypes[Z]({send:(Le,Ge,Je,Ke,je,nt)=>{this.actor.send(Le,Ge,Je,G,je,nt)},scheduler:this.actor.scheduler},this.getLayerIndex(G),this.getAvailableImages(G),this.isSpriteLoaded[G])),this.workerSources[G][Z][de]}getDEMWorkerSource(G,Z){return this.demWorkerSources[G]||(this.demWorkerSources[G]={}),this.demWorkerSources[G][Z]||(this.demWorkerSources[G][Z]=new E),this.demWorkerSources[G][Z]}enforceCacheSizeLimit(G,Z){s.enforceCacheSizeLimit(Z)}getWorkerPerformanceMetrics(G,Z,de){de(void 0,void 0)}}return typeof WorkerGlobalScope!="undefined"&&typeof self!="undefined"&&self instanceof WorkerGlobalScope&&(self.worker=new Sr(self)),Sr}),p(["./shared"],function(s){var M=T;function T(f){return!function(r){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 g,x,b=new Blob([""],{type:"text/javascript"}),S=URL.createObjectURL(b);try{x=new Worker(S),g=!0}catch(P){g=!1}return x&&x.terminate(),URL.revokeObjectURL(S),g}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var g=document.createElement("canvas");g.width=g.height=1;var x=g.getContext("2d");if(!x)return!1;var b=x.getImageData(0,0,1,1);return b&&b.width===g.width}()?(C[u=r&&r.failIfMajorPerformanceCaveat]===void 0&&(C[u]=function(g){var x,b=function(S){var P=document.createElement("canvas"),z=Object.create(T.webGLContextAttributes);return z.failIfMajorPerformanceCaveat=S,P.getContext("webgl",z)||P.getContext("experimental-webgl",z)}(g);if(!b)return!1;try{x=b.createShader(b.VERTEX_SHADER)}catch(S){return!1}return!(!x||b.isContextLost())&&(b.shaderSource(x,"void main() {}"),b.compileShader(x),b.getShaderParameter(x,b.COMPILE_STATUS)===!0)}(u)),C[u]?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 u}(f)}var C={};function E(f,r){if(Array.isArray(f)){if(!Array.isArray(r)||f.length!==r.length)return!1;for(let u=0;u{s.window.removeEventListener("click",he,!0)},0)}function K(f,r){const u=f.getBoundingClientRect();return ae(f,u,r)}function ie(f,r){const u=f.getBoundingClientRect(),g=[];for(let x=0;x=0?0:f.button}function ae(f,r,u){const g=f.offsetWidth===r.width?1:f.offsetWidth/r.width;return new s.pointGeometry((u.clientX-r.left)*g,(u.clientY-r.top)*g)}function le(f,r){var u=r[0],g=r[1],x=r[2],b=r[3],S=u*b-x*g;return S?(f[0]=b*(S=1/S),f[1]=-g*S,f[2]=-x*S,f[3]=u*S,f):null}function De(f){const{userImage:r}=f;return!!(r&&r.render&&r.render())&&(f.data.replace(new Uint8Array(r.data.buffer)),!0)}class ye extends s.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new s.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(r){if(this.loaded!==r&&(this.loaded=r,r)){for(const{ids:u,callback:g}of this.requestors)this._notify(u,g);this.requestors=[]}}hasImage(r){return!!this.getImage(r)}getImage(r){return this.images[r]}addImage(r,u){this._validate(r,u)&&(this.images[r]=u)}_validate(r,u){let g=!0;return this._validateStretch(u.stretchX,u.data&&u.data.width)||(this.fire(new s.ErrorEvent(new Error(`Image "${r}" has invalid "stretchX" value`))),g=!1),this._validateStretch(u.stretchY,u.data&&u.data.height)||(this.fire(new s.ErrorEvent(new Error(`Image "${r}" has invalid "stretchY" value`))),g=!1),this._validateContent(u.content,u)||(this.fire(new s.ErrorEvent(new Error(`Image "${r}" has invalid "content" value`))),g=!1),g}_validateStretch(r,u){if(!r)return!0;let g=0;for(const x of r){if(x[0]{this.ready=!0})}broadcast(r,u,g){s.asyncAll(this.actors,(x,b)=>{x.send(r,u,b)},g=g||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(r=>{r.remove()}),this.actors=[],this.workerPool.release(this.id)}}function Ve(f,r,u){return r*(s.EXTENT/(f.tileSize*Math.pow(2,u-f.tileID.overscaledZ)))}ge.Actor=s.Actor;class Ne{constructor(r,u,g,x){this.screenBounds=r,this.cameraPoint=u,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=g,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this.screenGeometry.map(b=>x.pointCoordinate3D(b)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(r,u){let g,x;if(r instanceof s.pointGeometry||typeof r[0]=="number"){const b=s.pointGeometry.convert(r);g=[s.pointGeometry.convert(r)],x=u.isPointAboveHorizon(b)}else{const b=s.pointGeometry.convert(r[0]),S=s.pointGeometry.convert(r[1]);g=[b,S],x=s.polygonizeBounds(b,S).every(P=>u.isPointAboveHorizon(P))}return new Ne(g,u.getCameraPoint(),x,u)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(r){return s.polygonizeBounds(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const u=this.screenBounds[0],g=this.screenBounds.length===1?this.screenBounds[0].add(new s.pointGeometry(1,1)):this.screenBounds[1],x=s.polygonizeBounds(u,g,0,!1);return this.cameraPoint.y>g.y&&(this.cameraPoint.x>u.x&&this.cameraPoint.x=g.x?x[2]=this.cameraPoint:this.cameraPoint.x<=u.x&&(x[3]=this.cameraPoint)),s.bufferConvexPolygon(x,r)}containsTile(r,u,g){const x=r.queryPadding+1,b=r.tileID.wrap,S=g?this._bufferedCameraMercator(x,u).map(Q=>s.getTilePoint(r.tileTransform,Q,b)):this._bufferedScreenMercator(x,u).map(Q=>s.getTilePoint(r.tileTransform,Q,b)),P=this.screenGeometryMercator.map(Q=>s.getTileVec3(r.tileTransform,Q,b)),z=P.map(Q=>new s.pointGeometry(Q[0],Q[1])),F=u.getFreeCameraOptions().position||new s.MercatorCoordinate(0,0,0),N=s.getTileVec3(r.tileTransform,F,b),H=P.map(Q=>{const X=s.sub(Q,Q,N);return s.normalize(X,X),new s.Ray(N,X)}),J=Ve(r,1,u.zoom);if(s.polygonIntersectsBox(S,0,0,s.EXTENT,s.EXTENT))return{queryGeometry:this,tilespaceGeometry:z,tilespaceRays:H,bufferedTilespaceGeometry:S,bufferedTilespaceBounds:(re=s.getBounds(S),re.min.x=s.clamp(re.min.x,0,s.EXTENT),re.min.y=s.clamp(re.min.y,0,s.EXTENT),re.max.x=s.clamp(re.max.x,0,s.EXTENT),re.max.y=s.clamp(re.max.y,0,s.EXTENT),re),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:J};var re}_bufferedScreenMercator(r,u){const g=Ie(r);if(this._screenRaycastCache[g])return this._screenRaycastCache[g];{const x=this.bufferedScreenGeometry(r).map(b=>u.pointCoordinate3D(b));return this._screenRaycastCache[g]=x,x}}_bufferedCameraMercator(r,u){const g=Ie(r);if(this._cameraRaycastCache[g])return this._cameraRaycastCache[g];{const x=this.bufferedCameraGeometry(r).map(b=>u.pointCoordinate3D(b));return this._cameraRaycastCache[g]=x,x}}}function Ie(f){return 100*f|0}function it(f,r,u){const g=function(x,b){if(x)return u(x);if(b){const S=s.pick(s.extend(b,f),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);b.vector_layers&&(S.vectorLayers=b.vector_layers,S.vectorLayerIds=S.vectorLayers.map(P=>P.id)),S.tiles=r.canonicalizeTileset(S,f.url),u(null,S)}};return f.url?s.getJSON(r.transformRequest(r.normalizeSourceURL(f.url),s.ResourceType.Source),g):s.exported.frame(()=>g(null,f))}class ce{constructor(r,u,g){this.bounds=s.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=u||0,this.maxzoom=g||24}validateBounds(r){return Array.isArray(r)&&r.length===4?[Math.max(-180,r[0]),Math.max(-90,r[1]),Math.min(180,r[2]),Math.min(90,r[3])]:[-180,-90,180,90]}contains(r){const u=Math.pow(2,r.z),g=Math.floor(s.mercatorXfromLng(this.bounds.getWest())*u),x=Math.floor(s.mercatorYfromLat(this.bounds.getNorth())*u),b=Math.ceil(s.mercatorXfromLng(this.bounds.getEast())*u),S=Math.ceil(s.mercatorYfromLat(this.bounds.getSouth())*u);return r.x>=g&&r.x=x&&r.y{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new s.ErrorEvent(r)):u&&(s.extend(this,u),u.bounds&&(this.tileBounds=new ce(u.bounds,this.minzoom,this.maxzoom)),s.postTurnstileEvent(u.tiles),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(r){this.map=r,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return s.extend({},this._options)}hasTile(r){return!this.tileBounds||this.tileBounds.contains(r.canonical)}loadTile(r,u){const g=s.exported.devicePixelRatio>=2,x=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),g,this.tileSize);r.request=s.getImage(this.map._requestManager.transformRequest(x,s.ResourceType.Tile),(b,S,P,z)=>(delete r.request,r.aborted?(r.state="unloaded",u(null)):b?(r.state="errored",u(b)):S?(this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:P,expires:z}),r.setTexture(S,this.map.painter),r.state="loaded",s.cacheEntryPossiblyAdded(this.dispatcher),void u(null)):u(null)))}static loadTileData(r,u,g){r.setTexture(u,g)}static unloadTileData(r,u){r.texture&&u.saveTileTexture(r.texture)}abortTile(r,u){r.request&&(r.request.cancel(),delete r.request),u()}unloadTile(r,u){r.texture&&this.map.painter.saveTileTexture(r.texture),u()}hasTransition(){return!1}}let de;function Le(f,r,u,g,x,b,S,P){const z=[f,u,x,r,g,b,1,1,1],F=[S,P,1],N=s.adjoint([],z),[H,J,re]=s.transformMat3(F,F,s.transpose(N,N));return s.multiply(z,[H,0,0,0,J,0,0,0,re],z)}class Ge extends s.Evented{constructor(r,u,g,x){super(),this.id=r,this.dispatcher=g,this.coordinates=u.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(x),this.options=u}load(r){this._loaded=!1,this.fire(new s.Event("dataloading",{dataType:"source"})),this.url=this.options.url,s.getImage(this.map._requestManager.transformRequest(this.url,s.ResourceType.Image),(u,g)=>{if(this._loaded=!0,u)this.fire(new s.ErrorEvent(u));else if(g){const{HTMLImageElement:x}=s.window;this.image=g instanceof x?s.exported.getImageData(g):g,this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),this._finishLoading()}})}loaded(){return this._loaded}updateImage(r){return this.image&&r.url?(this.options.url=r.url,this.load(r.coordinates),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(r){this.map=r,this.load()}onRemove(){this.texture&&this.texture.destroy()}setCoordinates(r){this.coordinates=r,this._boundsArray=void 0;const u=r.map(s.MercatorCoordinate.fromLngLat);return this.tileID=function(g){let x=1/0,b=1/0,S=-1/0,P=-1/0;for(const H of g)x=Math.min(x,H.x),b=Math.min(b,H.y),S=Math.max(S,H.x),P=Math.max(P,H.y);const z=Math.max(S-x,P-b),F=Math.max(0,Math.floor(-Math.log(z)/Math.LN2)),N=Math.pow(2,F);return new s.CanonicalTileID(F,Math.floor((x+S)/2*N),Math.floor((b+P)/2*N))}(u),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(r){for(const z in this.tiles){const F=this.tiles[z];F.state!=="loaded"&&(F.state="loaded",F.texture=this.texture)}if(this._boundsArray)return;const u=s.tileTransform(this.tileID,this.map.transform.projection),[g,x,b,S]=this.coordinates.map(z=>{const F=u.projection.project(z[0],z[1]);return s.getTilePoint(u,F)._round()});this.perspectiveTransform=function(z,F,N,H,J,re,Q,X,Ae,fe){const Te=Le(0,0,z,0,0,F,z,F),Se=Le(N,H,J,re,Q,X,Ae,fe);return s.multiply(Se,s.adjoint(Te,Te),Se),[Se[6]/Se[8]*z/s.EXTENT,Se[7]/Se[8]*F/s.EXTENT]}(this.width,this.height,g.x,g.y,x.x,x.y,S.x,S.y,b.x,b.y);const P=this._boundsArray=new s.StructArrayLayout4i8;P.emplaceBack(g.x,g.y,0,0),P.emplaceBack(x.x,x.y,s.EXTENT,0),P.emplaceBack(S.x,S.y,0,s.EXTENT),P.emplaceBack(b.x,b.y,s.EXTENT,s.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=r.createVertexBuffer(P,s.boundsAttributes.members),this.boundsSegments=s.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const r=this.map.painter.context,u=r.gl;this.texture?this.texture.update(this.image):(this.texture=new s.Texture(r,this.image,u.RGBA),this.texture.bind(u.LINEAR,u.CLAMP_TO_EDGE)),this._prepareData(r)}loadTile(r,u){this.tileID&&this.tileID.equals(r.tileID.canonical)?(this.tiles[String(r.tileID.wrap)]=r,r.buckets={},u(null)):(r.state="errored",u(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const Je={vector:class extends s.Evented{constructor(f,r,u,g){if(super(),this.id=f,this.dispatcher=u,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,s.extend(this,s.pick(r,["url","scheme","tileSize","promoteId"])),this._options=s.extend({type:"vector"},r),this._collectResourceTiming=r.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(g),this._tileWorkers={},this._deduped=new s.DedupedRequest}load(){this._loaded=!1,this.fire(new s.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=it(this._options,this.map._requestManager,(f,r)=>{this._tileJSONRequest=null,this._loaded=!0,f?this.fire(new s.ErrorEvent(f)):r&&(s.extend(this,r),r.bounds&&(this.tileBounds=new ce(r.bounds,this.minzoom,this.maxzoom)),s.postTurnstileEvent(r.tiles,this.map._requestManager._customAccessToken),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(f){return!this.tileBounds||this.tileBounds.contains(f.canonical)}onAdd(f){this.map=f,this.load()}setSourceProperty(f){this._tileJSONRequest&&this._tileJSONRequest.cancel(),f();const r=this.map.style._getSourceCaches(this.id);for(const u of r)u.clearTiles();this.load()}setTiles(f){return this.setSourceProperty(()=>{this._options.tiles=f}),this}setUrl(f){return this.setSourceProperty(()=>{this.url=f,this._options.url=f}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return s.extend({},this._options)}loadTile(f,r){const u=this.map._requestManager.normalizeTileURL(f.tileID.canonical.url(this.tiles,this.scheme)),g={request:this.map._requestManager.transformRequest(u,s.ResourceType.Tile),data:void 0,uid:f.uid,tileID:f.tileID,tileZoom:f.tileZoom,zoom:f.tileID.overscaledZ,tileSize:this.tileSize*f.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:s.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:f.isSymbolTile};if(g.request.collectResourceTiming=this._collectResourceTiming,f.actor&&f.state!=="expired")f.state==="loading"?f.reloadCallback=r:f.request=f.actor.send("reloadTile",g,x.bind(this));else if(f.actor=this._tileWorkers[u]=this._tileWorkers[u]||this.dispatcher.getActor(),this.dispatcher.ready)f.request=f.actor.send("loadTile",g,x.bind(this),void 0,!0);else{const b=s.loadVectorTile.call({deduped:this._deduped},g,(S,P)=>{S||!P?x.call(this,S):(g.data={cacheControl:P.cacheControl,expires:P.expires,rawData:P.rawData.slice(0)},f.actor&&f.actor.send("loadTile",g,x.bind(this),void 0,!0))},!0);f.request={cancel:b}}function x(b,S){return delete f.request,f.aborted?r(null):b&&b.status!==404?r(b):(S&&S.resourceTiming&&(f.resourceTiming=S.resourceTiming),this.map._refreshExpiredTiles&&S&&f.setExpiryData(S),f.loadVectorData(S,this.map.painter),s.cacheEntryPossiblyAdded(this.dispatcher),r(null),void(f.reloadCallback&&(this.loadTile(f,f.reloadCallback),f.reloadCallback=null)))}}abortTile(f){f.request&&(f.request.cancel(),delete f.request),f.actor&&f.actor.send("abortTile",{uid:f.uid,type:this.type,source:this.id})}unloadTile(f){f.unloadVectorData(),f.actor&&f.actor.send("removeTile",{uid:f.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:Z,"raster-dem":class extends Z{constructor(f,r,u,g){super(f,r,u,g),this.type="raster-dem",this.maxzoom=22,this._options=s.extend({type:"raster-dem"},r),this.encoding=r.encoding||"mapbox"}loadTile(f,r){const u=this.map._requestManager.normalizeTileURL(f.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function g(x,b){x&&(f.state="errored",r(x)),b&&(f.dem=b,f.dem.onDeserialize(),f.needsHillshadePrepare=!0,f.needsDEMTextureUpload=!0,f.state="loaded",r(null))}f.request=s.getImage(this.map._requestManager.transformRequest(u,s.ResourceType.Tile),function(x,b,S,P){if(delete f.request,f.aborted)f.state="unloaded",r(null);else if(x)f.state="errored",r(x);else if(b){this.map._refreshExpiredTiles&&f.setExpiryData({cacheControl:S,expires:P});const z=s.window.ImageBitmap&&b instanceof s.window.ImageBitmap&&(de==null&&(de=s.window.OffscreenCanvas&&new s.window.OffscreenCanvas(1,1).getContext("2d")&&typeof s.window.createImageBitmap=="function"),de),F=1-(b.width-s.prevPowerOfTwo(b.width))/2;F<1||f.neighboringTiles||(f.neighboringTiles=this._getNeighboringTiles(f.tileID));const N=z?b:s.exported.getImageData(b,F),H={uid:f.uid,coord:f.tileID,source:this.id,rawImageData:N,encoding:this.encoding,padding:F};f.actor&&f.state!=="expired"||(f.actor=this.dispatcher.getActor(),f.actor.send("loadDEMTile",H,g.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(f){const r=f.canonical,u=Math.pow(2,r.z),g=(r.x-1+u)%u,x=r.x===0?f.wrap-1:f.wrap,b=(r.x+1+u)%u,S=r.x+1===u?f.wrap+1:f.wrap,P={};return P[new s.OverscaledTileID(f.overscaledZ,x,r.z,g,r.y).key]={backfilled:!1},P[new s.OverscaledTileID(f.overscaledZ,S,r.z,b,r.y).key]={backfilled:!1},r.y>0&&(P[new s.OverscaledTileID(f.overscaledZ,x,r.z,g,r.y-1).key]={backfilled:!1},P[new s.OverscaledTileID(f.overscaledZ,f.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},P[new s.OverscaledTileID(f.overscaledZ,S,r.z,b,r.y-1).key]={backfilled:!1}),r.y+1{if(this._loaded=!0,this._pendingLoad=null,u)this.fire(new s.ErrorEvent(u));else{const x={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&g&&g.resourceTiming&&g.resourceTiming[this.id]&&(x.resourceTiming=g.resourceTiming[this.id]),this.fire(new s.Event("data",x)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(f,r){const u=f.actor?"reloadTile":"loadTile";f.actor=this.actor,f.request=this.actor.send(u,{type:this.type,uid:f.uid,tileID:f.tileID,tileZoom:f.tileZoom,zoom:f.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:s.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(g,x)=>(delete f.request,f.unloadVectorData(),f.aborted?r(null):g?r(g):(f.loadVectorData(x,this.map.painter,u==="reloadTile"),r(null))),void 0,u==="loadTile")}abortTile(f){f.request&&(f.request.cancel(),delete f.request),f.aborted=!0}unloadTile(f){f.unloadVectorData(),this.actor.send("removeTile",{uid:f.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return s.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends Ge{constructor(f,r,u,g){super(f,r,u,g),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const f=this.options;this.urls=[];for(const r of f.urls)this.urls.push(this.map._requestManager.transformRequest(r,s.ResourceType.Source).url);s.getVideo(this.urls,(r,u)=>{this._loaded=!0,r?this.fire(new s.ErrorEvent(r)):u&&(this.video=u,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(f){if(this.video){const r=this.video.seekable;fr.end(0)?this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${r.start(0)} and ${r.end(0)}-second mark.`))):this.video.currentTime=f}}getVideo(){return this.video}onAdd(f){this.map||(this.map=f,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 f=this.map.painter.context,r=f.gl;this.texture?this.video.paused||(this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,this.video)):(this.texture=new s.Texture(f,this.video,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(f)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Ge,canvas:class extends Ge{constructor(f,r,u,g){super(f,r,u,g),r.coordinates?Array.isArray(r.coordinates)&&r.coordinates.length===4&&!r.coordinates.some(x=>!Array.isArray(x)||x.length!==2||x.some(b=>typeof b!="number"))||this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${f}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${f}`,null,'missing required property "coordinates"'))),r.animate&&typeof r.animate!="boolean"&&this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${f}`,null,'optional "animate" property must be a boolean value'))),r.canvas?typeof r.canvas=="string"||r.canvas instanceof s.window.HTMLCanvasElement||this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${f}`,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 s.ErrorEvent(new s.ValidationError(`sources.${f}`,null,'missing required property "canvas"'))),this.options=r,this.animate=r.animate===void 0||r.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof s.window.HTMLCanvasElement?this.options.canvas:s.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new s.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(f){this.map=f,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let f=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,f=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,f=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const r=this.map.painter.context;this.texture?(f||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new s.Texture(r,this.canvas,r.gl.RGBA,{premultiply:!0}),this._prepareData(r)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const f of[this.canvas.width,this.canvas.height])if(isNaN(f)||f<=0)return!0;return!1}},custom:class extends s.Evented{constructor(f,r,u,g){super(),this.id=f,this.type="custom",this._dataType="raster",this._dispatcher=u,this._implementation=r,this.setEventedParent(g),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new s.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new s.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new ce(this._implementation.bounds,this.minzoom,this.maxzoom)),r.update=this._update.bind(this),r.coveringTiles=this._coveringTiles.bind(this),s.extend(this,s.pick(r,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return s.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new s.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(f){this._map=f,this._loaded=!1,this.fire(new s.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(f),this.load()}onRemove(f){this._implementation.onRemove&&this._implementation.onRemove(f)}hasTile(f){if(this._implementation.hasTile){const{x:r,y:u,z:g}=f.canonical;return this._implementation.hasTile({x:r,y:u,z:g})}return!this.tileBounds||this.tileBounds.contains(f.canonical)}loadTile(f,r){const{x:u,y:g,z:x}=f.tileID.canonical,b=new s.window.AbortController,S=this._implementation.loadTile({x:u,y:g,z:x},{signal:b.signal});if(!S)return this.loadTileData(f,{width:this.tileSize,height:this.tileSize,data:null}),f.state="loaded",r(null);S.cancel=()=>b.abort(),f.request=S.then(function(P){return delete f.request,f.aborted?(f.state="unloaded",r(null)):P?function(z){return z instanceof s.window.ImageData||z instanceof s.window.ImageBitmap||z instanceof s.window.HTMLCanvasElement}(P)?(this.loadTileData(f,P),f.state="loaded",void r(null)):(f.state="errored",r(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`))):(this.loadTileData(f,{width:this.tileSize,height:this.tileSize,data:null}),f.state="loaded",r(null))}.bind(this)).catch(P=>{P.code!==20&&(f.state="errored",r(P))})}loadTileData(f,r){Z.loadTileData(f,r,this._map.painter)}unloadTileData(f){Z.unloadTileData(f,this._map.painter)}prepareTile(f){if(!this._implementation.prepareTile)return null;const{x:r,y:u,z:g}=f.tileID.canonical,x=this._implementation.prepareTile({x:r,y:u,z:g});return x?(this.loadTileData(f,x),f.state="loaded",x):null}unloadTile(f,r){if(this.unloadTileData(f),this._implementation.unloadTile){const{x:u,y:g,z:x}=f.tileID.canonical;this._implementation.unloadTile({x:u,y:g,z:x})}r()}abortTile(f,r){f.request&&f.request.cancel&&(f.request.cancel(),delete f.request),r()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(f=>({x:f.canonical.x,y:f.canonical.y,z:f.canonical.z}))}_update(){this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"}))}}},Ke=function(f,r,u,g){const x=new Je[r.type](f,r,u,g);if(x.id!==f)throw new Error(`Expected Source id to be ${f} instead of ${x.id}`);return s.bindAll(["load","abort","unload","serialize","prepare"],x),x};function je(f,r){const u=s.identity([]);return s.scale(u,u,[.5*f.width,.5*-f.height,1]),s.translate(u,u,[1,-1,0]),s.multiply$1(u,u,f.calculateProjMatrix(r.toUnwrapped())),Float32Array.from(u)}function nt(f,r,u,g,x,b,S,P=!1){const z=f.tilesIn(g,S,P);z.sort(Ut);const F=[];for(const H of z)F.push({wrappedTileID:H.tile.tileID.wrapped().key,queryResults:H.tile.queryRenderedFeatures(r,u,f._state,H,x,b,je(f.transform,H.tile.tileID),P)});const N=function(H){const J={},re={};for(const Q of H){const X=Q.queryResults,Ae=Q.wrappedTileID,fe=re[Ae]=re[Ae]||{};for(const Te in X){const Se=X[Te],Re=fe[Te]=fe[Te]||{},be=J[Te]=J[Te]||[];for(const Fe of Se)Re[Fe.featureIndex]||(Re[Fe.featureIndex]=!0,be.push(Fe))}}return J}(F);for(const H in N)N[H].forEach(J=>{const re=J.feature,Q=re.layer;Q&&Q.type!=="background"&&Q.type!=="sky"&&(re.source=Q.source,Q["source-layer"]&&(re.sourceLayer=Q["source-layer"]),re.state=re.id!==void 0?f.getFeatureState(Q["source-layer"],re.id):{})});return N}function yt(f,r){const u=f.getRenderableIds().map(b=>f.getTileByID(b)),g=[],x={};for(let b=0;b{u.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[_n]}numActive(){return Object.keys(this.active).length}}let Y;function ze(){return Y||(Y=new W),Y}function xe(f,r){const u={};for(const g in f)g!=="ref"&&(u[g]=f[g]);return s.refProperties.forEach(g=>{g in r&&(u[g]=r[g])}),u}function Mt(f){f=f.slice();const r=Object.create(null);for(let u=0;u0?(x-S)/P:0;return this.points[b].mult(1-z).add(this.points[u].mult(z))}}class Tn{constructor(r,u,g){const x=this.boxCells=[],b=this.circleCells=[];this.xCellCount=Math.ceil(r/g),this.yCellCount=Math.ceil(u/g);for(let S=0;Sthis.width||x<0||u>this.height)return!b&&[];const P=[];if(r<=0&&u<=0&&this.width<=g&&this.height<=x){if(b)return!0;for(let z=0;z0:P}_queryCircle(r,u,g,x,b){const S=r-g,P=r+g,z=u-g,F=u+g;if(P<0||S>this.width||F<0||z>this.height)return!x&&[];const N=[];return this._forEachCell(S,z,P,F,this._queryCellCircle,N,{hitTest:x,circle:{x:r,y:u,radius:g},seenUids:{box:{},circle:{}}},b),x?N.length>0:N}query(r,u,g,x,b){return this._query(r,u,g,x,!1,b)}hitTest(r,u,g,x,b){return this._query(r,u,g,x,!0,b)}hitTestCircle(r,u,g,x){return this._queryCircle(r,u,g,!0,x)}_queryCell(r,u,g,x,b,S,P,z){const F=P.seenUids,N=this.boxCells[b];if(N!==null){const J=this.bboxes;for(const re of N)if(!F.box[re]){F.box[re]=!0;const Q=4*re;if(r<=J[Q+2]&&u<=J[Q+3]&&g>=J[Q+0]&&x>=J[Q+1]&&(!z||z(this.boxKeys[re]))){if(P.hitTest)return S.push(!0),!0;S.push({key:this.boxKeys[re],x1:J[Q],y1:J[Q+1],x2:J[Q+2],y2:J[Q+3]})}}}const H=this.circleCells[b];if(H!==null){const J=this.circles;for(const re of H)if(!F.circle[re]){F.circle[re]=!0;const Q=3*re;if(this._circleAndRectCollide(J[Q],J[Q+1],J[Q+2],r,u,g,x)&&(!z||z(this.circleKeys[re]))){if(P.hitTest)return S.push(!0),!0;{const X=J[Q],Ae=J[Q+1],fe=J[Q+2];S.push({key:this.circleKeys[re],x1:X-fe,y1:Ae-fe,x2:X+fe,y2:Ae+fe})}}}}}_queryCellCircle(r,u,g,x,b,S,P,z){const F=P.circle,N=P.seenUids,H=this.boxCells[b];if(H!==null){const re=this.bboxes;for(const Q of H)if(!N.box[Q]){N.box[Q]=!0;const X=4*Q;if(this._circleAndRectCollide(F.x,F.y,F.radius,re[X+0],re[X+1],re[X+2],re[X+3])&&(!z||z(this.boxKeys[Q])))return S.push(!0),!0}}const J=this.circleCells[b];if(J!==null){const re=this.circles;for(const Q of J)if(!N.circle[Q]){N.circle[Q]=!0;const X=3*Q;if(this._circlesCollide(re[X],re[X+1],re[X+2],F.x,F.y,F.radius)&&(!z||z(this.circleKeys[Q])))return S.push(!0),!0}}}_forEachCell(r,u,g,x,b,S,P,z){const F=this._convertToXCellCoord(r),N=this._convertToYCellCoord(u),H=this._convertToXCellCoord(g),J=this._convertToYCellCoord(x);for(let re=F;re<=H;re++)for(let Q=N;Q<=J;Q++)if(b.call(this,r,u,g,x,this.xCellCount*Q+re,S,P,z))return}_convertToXCellCoord(r){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(r*this.xScale)))}_convertToYCellCoord(r){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(r*this.yScale)))}_circlesCollide(r,u,g,x,b,S){const P=x-r,z=b-u,F=g+S;return F*F>P*P+z*z}_circleAndRectCollide(r,u,g,x,b,S,P){const z=(S-x)/2,F=Math.abs(r-(x+z));if(F>z+g)return!1;const N=(P-b)/2,H=Math.abs(u-(b+N));if(H>N+g)return!1;if(F<=z||H<=N)return!0;const J=F-z,re=H-N;return J*J+re*re<=g*g}}const Sn=Math.tan(85*Math.PI/180);function di(f,r,u,g,x,b){const S=s.create();if(u){if(x.projection.name==="globe")s.multiply$1(S,S,s.calculateGlobeLabelMatrix(x,r));else{const P=le([],b);S[0]=P[0],S[1]=P[1],S[4]=P[2],S[5]=P[3]}g||s.rotateZ(S,S,x.angle)}else s.multiply$1(S,x.labelPlaneMatrix,f);return S}function Ar(f,r,u,g,x,b){if(u){if(x.projection.name==="globe"){const S=di(f,r,u,g,x,b);return s.invert(S,S),s.multiply$1(S,f,S),S}{const S=s.clone(f),P=s.identity([]);return P[0]=b[0],P[1]=b[1],P[4]=b[2],P[5]=b[3],s.multiply$1(S,S,P),g||s.rotateZ(S,S,-x.angle),S}}return x.glCoordMatrix}function ai(f,r,u=0){const g=[f.x,f.y,u,1];u?s.transformMat4$1(g,g,r):Cr(g,g,r);const x=g[3];return{point:new s.pointGeometry(g[0]/x,g[1]/x),signedDistanceFromCamera:x}}function li(f,r){const u=[f[0],f[1],f[2],1];s.transformMat4$1(u,u,r);const g=u[3];return{point:new s.pointGeometry(u[0]/g,u[1]/g),signedDistanceFromCamera:g}}function oi(f,r){return Math.min(.5+f/r*.5,1.5)}function ys(f,r){const u=f[0]/f[3],g=f[1]/f[3];return u>=-r[0]&&u<=r[0]&&g>=-r[1]&&g<=r[1]}function za(f,r,u,g,x,b,S,P,z,F){const N=u.transform,H=g?f.textSizeData:f.iconSizeData,J=s.evaluateSizeForZoom(H,u.transform.zoom),re=[256/u.width*2+1,256/u.height*2+1],Q=g?f.text.dynamicLayoutVertexArray:f.icon.dynamicLayoutVertexArray;Q.clear();const X=f.lineVertexArray,Ae=g?f.text.placedSymbolArray:f.icon.placedSymbolArray,fe=u.transform.width/u.transform.height;let Te=!1;for(let Se=0;SeMath.abs(u.x-r.x)*g?{useVertical:!0}:f.writingMode===s.WritingMode.vertical?r.ySn}(r,u,g)?f.flipState===1?{needsFlipping:!0}:null:r.x>u.x?{needsFlipping:!0}:null}function ru(f,r,u,g,x,b,S,P,z,F,N,H,J,re,Q,X,Ae){const fe=r/24,Te=f.lineOffsetX*fe,Se=f.lineOffsetY*fe;let Re;if(f.numGlyphs>1){const be=f.glyphStartIndex+f.numGlyphs,Fe=f.lineStartIndex,Qe=f.lineStartIndex+f.lineLength,at=iu(fe,P,Te,Se,u,N,H,f,z,b,J,Q,!1,X,Ae);if(!at)return{notEnoughRoom:!0};const dt=ai(at.first.point,S).point,ut=ai(at.last.point,S).point;if(g&&!u){const Rt=vs(f,dt,ut,re);if(f.flipState=Rt&&Rt.needsFlipping?1:2,Rt)return Rt}Re=[at.first];for(let Rt=f.glyphStartIndex+1;Rt0?dt.point:Xn(H,at,Fe,1,x,void 0,X,Ae.canonical),re);if(f.flipState=ut&&ut.needsFlipping?1:2,ut)return ut}const be=xs(fe*P.getoffsetX(f.glyphStartIndex),Te,Se,u,N,H,f.segment,f.lineStartIndex,f.lineStartIndex+f.lineLength,z,b,J,Q,!1,!1,X,Ae);if(!be)return{notEnoughRoom:!0};Re=[be]}for(const be of Re)s.addDynamicAttributes(F,be.point,be.angle);return{}}function xd(f,r,u,g,x){const b=g.projectTilePoint(f.x,f.y,r);if(!x)return ai(b,u,b.z);const S=x(f);return ai(new s.pointGeometry(b.x+S[0],b.y+S[1]),u,b.z+S[2])}function Xn(f,r,u,g,x,b,S,P){const z=xd(f.add(f.sub(r)._unit()),P,x,S,b).point,F=u.sub(z);return u.add(F._mult(g/F.mag()))}function xs(f,r,u,g,x,b,S,P,z,F,N,H,J,re,Q,X,Ae){const fe=g?f-r:f+r;let Te=fe>0?1:-1,Se=0;g&&(Te*=-1,Se=Math.PI),Te<0&&(Se+=Math.PI);let Re=Te>0?P+S:P+S+1,be=x,Fe=x,Qe=0,at=0;const dt=Math.abs(fe),ut=[],Rt=[];let et=b;const zt=()=>{const Xt=Re-Te;return Qe===0?b:new s.pointGeometry(F.getx(Xt),F.gety(Xt))},Pt=()=>Xn(zt(),et,Fe,dt-Qe+1,N,J,X,Ae.canonical);for(;Qe+at<=dt;){if(Re+=Te,Re=z)return null;if(Fe=be,ut.push(be),re&&Rt.push(et||zt()),be=H[Re],be===void 0){et=new s.pointGeometry(F.getx(Re),F.gety(Re));const Xt=xd(et,Ae.canonical,N,X,J);be=Xt.signedDistanceFromCamera>0?H[Re]=Xt.point:Pt()}else et=null;Qe+=at,at=Fe.dist(be)}Q&&J&&(et=et||new s.pointGeometry(F.getx(Re),F.gety(Re)),H[Re]=be=H[Re]===void 0?be:Pt(),at=Fe.dist(be));const Jt=(dt-Qe)/at,pt=be.sub(Fe),qt=pt.mult(Jt)._add(Fe);u&&qt._add(pt._unit()._perp()._mult(u*Te));const mn=Se+Math.atan2(be.y-Fe.y,be.x-Fe.x);return ut.push(qt),re&&(et=et||new s.pointGeometry(F.getx(Re),F.gety(Re)),Rt.push(function(Xt,Yt,vn){const kn=1-vn;return new s.pointGeometry(Xt.x*kn+Yt.x*vn,Xt.y*kn+Yt.y*vn)}(Rt.length>0?Rt[Rt.length-1]:et,et,Jt))),{point:qt,angle:mn,path:ut,tilePath:Rt}}const bd=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Bi(f,r){for(let u=0;u0),Q=b*re.perspectiveRatio,X=(u.x1*r+g.x-u.padding)*Q+re.point.x,Ae=(u.y1*r+g.y-u.padding)*Q+re.point.y,fe=(u.x2*r+g.x+u.padding)*Q+re.point.x,Te=(u.y2*r+g.y+u.padding)*Q+re.point.y,Se=re.perspectiveRatio<=.55||re.occluded;return!this.isInsideGrid(X,Ae,fe,Te)||!x&&this.grid.hitTest(X,Ae,fe,Te,P)||Se?{box:[],offscreen:!1,occluded:re.occluded}:{box:[X,Ae,fe,Te],offscreen:this.isOffscreen(X,Ae,fe,Te),occluded:!1}}placeCollisionCircles(r,u,g,x,b,S,P,z,F,N,H,J,re,Q){const X=[],Ae=this.transform.elevation,fe=Ae?Ae.getAtTileOffsetFunc(Q,this.transform.center.lat,this.transform.worldSize,this.transform.projection):Pt=>[0,0,0],Te=new s.pointGeometry(u.tileAnchorX,u.tileAnchorY),Se=this.transform.projection.projectTilePoint(u.tileAnchorX,u.tileAnchorY,Q.canonical),Re=fe(Te),be=[Se.x+Re[0],Se.y+Re[1],Se.z+Re[2]],Fe=this.projectAndGetPerspectiveRatio(S,[be[0],be[1],be[2]],Q,this.transform.projection.name==="globe"||!!Ae||this.transform.pitch>0),{perspectiveRatio:Qe}=Fe,at=(N?b/Qe:b*Qe)/s.ONE_EM,dt=ai(new s.pointGeometry(be[0],be[1]),P,be[2]).point,ut=Fe.signedDistanceFromCamera>0?iu(at,x,u.lineOffsetX*at,u.lineOffsetY*at,!1,dt,Te,u,g,P,{},Ae&&!N?fe:null,N&&!!Ae,this.transform.projection,Q):null;let Rt=!1,et=!1,zt=!0;if(ut&&!Fe.occluded){const Pt=.5*J*Qe+re,Jt=new s.pointGeometry(-100,-100),pt=new s.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),qt=new fn,mn=ut.first,Xt=ut.last;let Yt=[];for(let hn=mn.path.length-1;hn>=1;hn--)Yt.push(mn.path[hn]);for(let hn=1;hn{const vi=fe(qnai(Mn,z));Yt=hn.some(Mn=>Mn.signedDistanceFromCamera<=0)?[]:hn.map(Mn=>Mn.point)}let kn=[];if(Yt.length>0){const hn=Yt[0].clone(),Mn=Yt[0].clone();for(let qn=1;qn=Jt.x&&Mn.x<=pt.x&&hn.y>=Jt.y&&Mn.y<=pt.y?[Yt]:Mn.xpt.x||Mn.ypt.y?[]:s.clipLine([Yt],Jt.x,Jt.y,pt.x,pt.y)}for(const hn of kn){qt.reset(hn,.25*Pt);let Mn=0;Mn=qt.length<=.5*Pt?1:Math.ceil(qt.paddedLength/vn)+1;for(let qn=0;qn0?(s.transformMat4$1(b,b,r),this.fogState&&g&&(S=function(P,z,F,N,H,J){const re=J.calculateFogTileMatrix(H),Q=[z,F,N];return s.transformMat4(Q,Q,re),gt(P,Q,J.pitch,J._fov)}(this.fogState,u[0],u[1],u[2],g.toUnwrapped(),this.transform)>.9)):Cr(b,b,r),{point:new s.pointGeometry((b[0]/b[3]+1)/2*this.transform.width+da,(-b[1]/b[3]+1)/2*this.transform.height+da),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/b[3]*.5,1.5),signedDistanceFromCamera:b[3],occluded:x&&b[2]>b[3]||S}}isOffscreen(r,u,g,x){return g=this.screenRightBoundary||xthis.screenBottomBoundary}isInsideGrid(r,u,g,x){return g>=0&&r=0&&ug.collisionGroupID===u}}return this.collisionGroups[r]}}function bs(f,r,u,g,x){const{horizontalAlign:b,verticalAlign:S}=s.getAnchorAlignment(f),P=-(b-.5)*r,z=-(S-.5)*u,F=s.evaluateVariableOffset(f,g);return new s.pointGeometry(P+F[0]*x,z+F[1]*x)}function ws(f,r,u,g,x){const b=new s.pointGeometry(f,r);return u&&b._rotate(g?x:-x),b}class Dy{constructor(r,u,g,x,b){this.transform=r.clone(),this.collisionIndex=new au(this.transform,b),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=u,this.retainedQueryData={},this.collisionGroups=new pa(g),this.collisionCircleArrays={},this.prevPlacement=x,x&&(x.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,u,g,x){const b=g.getBucket(u),S=g.latestFeatureIndex;if(!b||!S||u.id!==b.layerIds[0])return;const P=b.layers[0].layout,z=g.collisionBoxArray,F=Math.pow(2,this.transform.zoom-g.tileID.overscaledZ),N=g.tileSize/s.EXTENT,H=g.tileID.toUnwrapped(),J=this.transform.calculateProjMatrix(H),re=P.get("text-pitch-alignment")==="map",Q=P.get("text-rotation-alignment")==="map";u.compileFilter();const X=u.dynamicFilter(),Ae=u.dynamicFilterNeedsFeature(),fe=this.transform.calculatePixelsToTileUnitsMatrix(g),Te=di(J,g.tileID.canonical,re,Q,this.transform,fe);let Se=null;if(re){const Fe=Ar(J,g.tileID.canonical,re,Q,this.transform,fe);Se=s.multiply$1([],this.transform.labelPlaneMatrix,Fe)}let Re=null;X&&g.latestFeatureIndex&&(Re={unwrappedTileID:H,dynamicFilter:X,dynamicFilterNeedsFeature:Ae,featureIndex:g.latestFeatureIndex}),this.retainedQueryData[b.bucketInstanceId]=new wd(b.bucketInstanceId,S,b.sourceLayerIndex,b.index,g.tileID);const be={bucket:b,layout:P,posMatrix:J,textLabelPlaneMatrix:Te,labelToScreenMatrix:Se,clippingData:Re,scale:F,textPixelRatio:N,holdingForFade:g.holdingForFade(),collisionBoxArray:z,partiallyEvaluatedTextSize:s.evaluateSizeForZoom(b.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:s.evaluateSizeForZoom(b.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(b.sourceID)};if(x)for(const Fe of b.sortKeyRanges){const{sortKey:Qe,symbolInstanceStart:at,symbolInstanceEnd:dt}=Fe;r.push({sortKey:Qe,symbolInstanceStart:at,symbolInstanceEnd:dt,parameters:be})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:b.symbolInstances.length,parameters:be})}attemptAnchorPlacement(r,u,g,x,b,S,P,z,F,N,H,J,re,Q,X,Ae,fe,Te){const Se=[J.textOffset0,J.textOffset1],Re=bs(r,g,x,Se,b),be=this.collisionIndex.placeCollisionBox(b,u,ws(Re.x,Re.y,S,P,this.transform.angle),H,z,F,N.predicate);if((!Ae||this.collisionIndex.placeCollisionBox(Q.getSymbolInstanceIconSize(Te,this.transform.zoom,re),Ae,ws(Re.x,Re.y,S,P,this.transform.angle),H,z,F,N.predicate).box.length!==0)&&be.box.length>0){let Fe;return this.prevPlacement&&this.prevPlacement.variableOffsets[J.crossTileID]&&this.prevPlacement.placements[J.crossTileID]&&this.prevPlacement.placements[J.crossTileID].text&&(Fe=this.prevPlacement.variableOffsets[J.crossTileID].anchor),this.variableOffsets[J.crossTileID]={textOffset:Se,width:g,height:x,anchor:r,textScale:b,prevAnchor:Fe},this.markUsedJustification(Q,r,J,X),Q.allowVerticalPlacement&&(this.markUsedOrientation(Q,X,J),this.placedOrientations[J.crossTileID]=X),{shift:Re,placedGlyphBoxes:be}}}placeLayerBucketPart(r,u,g,x){const{bucket:b,layout:S,posMatrix:P,textLabelPlaneMatrix:z,labelToScreenMatrix:F,clippingData:N,textPixelRatio:H,holdingForFade:J,collisionBoxArray:re,partiallyEvaluatedTextSize:Q,partiallyEvaluatedIconSize:X,collisionGroup:Ae}=r.parameters,fe=S.get("text-optional"),Te=S.get("icon-optional"),Se=S.get("text-allow-overlap"),Re=S.get("icon-allow-overlap"),be=S.get("text-rotation-alignment")==="map",Fe=S.get("text-pitch-alignment")==="map",Qe=S.get("icon-text-fit")!=="none",at=S.get("symbol-z-order")==="viewport-y";let dt=Se&&(Re||!b.hasIconData()||Te),ut=Re&&(Se||!b.hasTextData()||fe);!b.collisionArrays&&re&&b.deserializeCollisionBoxes(re),g&&x&&b.updateCollisionDebugBuffers(this.transform.zoom,re);const Rt=(et,zt,Pt)=>{if(N){const bi={zoom:this.transform.zoom,pitch:this.transform.pitch};let Ti=null;if(N.dynamicFilterNeedsFeature){const $n=this.retainedQueryData[b.bucketInstanceId];Ti=N.featureIndex.loadFeature({featureIndex:et.featureIndex,bucketIndex:$n.bucketIndex,sourceLayerIndex:$n.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,N.dynamicFilter)(bi,Ti,this.retainedQueryData[b.bucketInstanceId].tileID.canonical,new s.pointGeometry(et.tileAnchorX,et.tileAnchorY),this.transform.calculateDistanceTileData(N.unwrappedTileID)))return this.placements[et.crossTileID]=new Ba(!1,!1,!1,!0),void(u[et.crossTileID]=!0)}if(u[et.crossTileID])return;if(J)return void(this.placements[et.crossTileID]=new Ba(!1,!1,!1));let Jt=!1,pt=!1,qt=!0,mn=!1,Xt=!1,Yt=null,vn={box:null,offscreen:null,occluded:null},kn={box:null,offscreen:null,occluded:null},hn=null,Mn=null,qn=null,vi=0,nr=0,ir=0;Pt.textFeatureIndex?vi=Pt.textFeatureIndex:et.useRuntimeCollisionCircles&&(vi=et.featureIndex),Pt.verticalTextFeatureIndex&&(nr=Pt.verticalTextFeatureIndex);const Rr=bi=>{bi.tileID=this.retainedQueryData[b.bucketInstanceId].tileID,(this.transform.elevation||bi.elevation)&&(bi.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[b.bucketInstanceId].tileID,bi.tileAnchorX,bi.tileAnchorY):0)},ma=Pt.textBox;if(ma){Rr(ma);const bi=$n=>{let Li=s.WritingMode.horizontal;if(b.allowVerticalPlacement&&!$n&&this.prevPlacement){const zr=this.prevPlacement.placedOrientations[et.crossTileID];zr&&(this.placedOrientations[et.crossTileID]=zr,Li=zr,this.markUsedOrientation(b,Li,et))}return Li},Ti=($n,Li)=>{if(b.allowVerticalPlacement&&et.numVerticalGlyphVertices>0&&Pt.verticalTextBox){for(const zr of b.writingModes)if(zr===s.WritingMode.vertical?(vn=Li(),kn=vn):vn=$n(),vn&&vn.box&&vn.box.length)break}else vn=$n()};if(S.get("text-variable-anchor")){let $n=S.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[et.crossTileID]){const xi=this.prevPlacement.variableOffsets[et.crossTileID];$n.indexOf(xi.anchor)>0&&($n=$n.filter(Zr=>Zr!==xi.anchor),$n.unshift(xi.anchor))}const Li=(xi,Zr,Gl)=>{const kr=b.getSymbolInstanceTextSize(Q,et,this.transform.zoom,zt),jo=(xi.x2-xi.x1)*kr+2*xi.padding,lg=(xi.y2-xi.y1)*kr+2*xi.padding,ap=Qe&&!Re?Zr:null;ap&&Rr(ap);let Rs={box:[],offscreen:!1,occluded:!1};const Xy=Se?2*$n.length:$n.length;for(let fo=0;fo=$n.length,et,zt,b,Gl,ap,Q,X);if(op&&(Rs=op.placedGlyphBoxes,Rs&&Rs.box&&Rs.box.length)){Jt=!0,Yt=op.shift;break}}return Rs};Ti(()=>Li(ma,Pt.iconBox,s.WritingMode.horizontal),()=>{const xi=Pt.verticalTextBox;return xi&&Rr(xi),b.allowVerticalPlacement&&!(vn&&vn.box&&vn.box.length)&&et.numVerticalGlyphVertices>0&&xi?Li(xi,Pt.verticalIconBox,s.WritingMode.vertical):{box:null,offscreen:null,occluded:null}}),vn&&(Jt=vn.box,qt=vn.offscreen,mn=vn.occluded);const zr=bi(vn&&vn.box);if(!Jt&&this.prevPlacement){const xi=this.prevPlacement.variableOffsets[et.crossTileID];xi&&(this.variableOffsets[et.crossTileID]=xi,this.markUsedJustification(b,xi.anchor,et,zr))}}else{const $n=(Li,zr)=>{const xi=b.getSymbolInstanceTextSize(Q,et,this.transform.zoom,zt),Zr=this.collisionIndex.placeCollisionBox(xi,Li,new s.pointGeometry(0,0),Se,H,P,Ae.predicate);return Zr&&Zr.box&&Zr.box.length&&(this.markUsedOrientation(b,zr,et),this.placedOrientations[et.crossTileID]=zr),Zr};Ti(()=>$n(ma,s.WritingMode.horizontal),()=>{const Li=Pt.verticalTextBox;return b.allowVerticalPlacement&&et.numVerticalGlyphVertices>0&&Li?(Rr(Li),$n(Li,s.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}}),bi(vn&&vn.box&&vn.box.length)}}if(hn=vn,Jt=hn&&hn.box&&hn.box.length>0,qt=hn&&hn.offscreen,mn=hn&&hn.occluded,et.useRuntimeCollisionCircles){const bi=b.text.placedSymbolArray.get(et.centerJustifiedTextSymbolIndex>=0?et.centerJustifiedTextSymbolIndex:et.verticalPlacedTextSymbolIndex),Ti=s.evaluateSizeForFeature(b.textSizeData,Q,bi),$n=S.get("text-padding");Mn=this.collisionIndex.placeCollisionCircles(Se,bi,b.lineVertexArray,b.glyphOffsetArray,Ti,P,z,F,g,Fe,Ae.predicate,et.collisionCircleDiameter*Ti/s.ONE_EM,$n,this.retainedQueryData[b.bucketInstanceId].tileID),Jt=Se||Mn.circles.length>0&&!Mn.collisionDetected,qt=qt&&Mn.offscreen,mn=Mn.occluded}if(Pt.iconFeatureIndex&&(ir=Pt.iconFeatureIndex),Pt.iconBox){const bi=Ti=>{Rr(Ti);const $n=Qe&&Yt?ws(Yt.x,Yt.y,be,Fe,this.transform.angle):new s.pointGeometry(0,0),Li=b.getSymbolInstanceIconSize(X,this.transform.zoom,zt);return this.collisionIndex.placeCollisionBox(Li,Ti,$n,Re,H,P,Ae.predicate)};kn&&kn.box&&kn.box.length&&Pt.verticalIconBox?(qn=bi(Pt.verticalIconBox),pt=qn.box.length>0):(qn=bi(Pt.iconBox),pt=qn.box.length>0),qt=qt&&qn.offscreen,Xt=qn.occluded}const Ua=fe||et.numHorizontalGlyphVertices===0&&et.numVerticalGlyphVertices===0,po=Te||et.numIconVertices===0;if(Ua||po?po?Ua||(pt=pt&&Jt):Jt=pt&&Jt:pt=Jt=pt&&Jt,Jt&&hn&&hn.box&&this.collisionIndex.insertCollisionBox(hn.box,S.get("text-ignore-placement"),b.bucketInstanceId,kn&&kn.box&&nr?nr:vi,Ae.ID),pt&&qn&&this.collisionIndex.insertCollisionBox(qn.box,S.get("icon-ignore-placement"),b.bucketInstanceId,ir,Ae.ID),Mn&&(Jt&&this.collisionIndex.insertCollisionCircles(Mn.circles,S.get("text-ignore-placement"),b.bucketInstanceId,vi,Ae.ID),g)){const bi=b.bucketInstanceId;let Ti=this.collisionCircleArrays[bi];Ti===void 0&&(Ti=this.collisionCircleArrays[bi]=new Qi);for(let $n=0;$n=0;--zt){const Pt=et[zt];Rt(b.symbolInstances.get(Pt),Pt,b.collisionArrays[Pt])}}else for(let et=r.symbolInstanceStart;et=0&&(r.text.placedSymbolArray.get(P).crossTileID=b>=0&&P!==b?0:g.crossTileID)}markUsedOrientation(r,u,g){const x=u===s.WritingMode.horizontal||u===s.WritingMode.horizontalOnly?u:0,b=u===s.WritingMode.vertical?u:0,S=[g.leftJustifiedTextSymbolIndex,g.centerJustifiedTextSymbolIndex,g.rightJustifiedTextSymbolIndex];for(const P of S)r.text.placedSymbolArray.get(P).placedOrientation=x;g.verticalPlacedTextSymbolIndex&&(r.text.placedSymbolArray.get(g.verticalPlacedTextSymbolIndex).placedOrientation=b)}commit(r){this.commitTime=r,this.zoomAtLastRecencyCheck=this.transform.zoom;const u=this.prevPlacement;let g=!1;this.prevZoomAdjustment=u?u.zoomAdjustment(this.transform.zoom):0;const x=u?u.symbolFadeChange(r):1,b=u?u.opacities:{},S=u?u.variableOffsets:{},P=u?u.placedOrientations:{};for(const z in this.placements){const F=this.placements[z],N=b[z];N?(this.opacities[z]=new ka(N,x,F.text,F.icon,null,F.clipped),g=g||F.text!==N.text.placed||F.icon!==N.icon.placed):(this.opacities[z]=new ka(null,x,F.text,F.icon,F.skipFade,F.clipped),g=g||F.text||F.icon)}for(const z in b){const F=b[z];if(!this.opacities[z]){const N=new ka(F,x,!1,!1);N.isHidden()||(this.opacities[z]=N,g=g||F.text.placed||F.icon.placed)}}for(const z in S)this.variableOffsets[z]||!this.opacities[z]||this.opacities[z].isHidden()||(this.variableOffsets[z]=S[z]);for(const z in P)this.placedOrientations[z]||!this.opacities[z]||this.opacities[z].isHidden()||(this.placedOrientations[z]=P[z]);g?this.lastPlacementChangeTime=r:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=u?u.lastPlacementChangeTime:r)}updateLayerOpacities(r,u){const g={};for(const x of u){const b=x.getBucket(r);b&&x.latestFeatureIndex&&r.id===b.layerIds[0]&&this.updateBucketOpacities(b,g,x.collisionBoxArray)}}updateBucketOpacities(r,u,g){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const x=r.layers[0].layout,b=!!r.layers[0].dynamicFilter(),S=new ka(null,0,!1,!1,!0),P=x.get("text-allow-overlap"),z=x.get("icon-allow-overlap"),F=x.get("text-variable-anchor"),N=x.get("text-rotation-alignment")==="map",H=x.get("text-pitch-alignment")==="map",J=x.get("icon-text-fit")!=="none",re=new ka(null,0,P&&(z||!r.hasIconData()||x.get("icon-optional")),z&&(P||!r.hasTextData()||x.get("text-optional")),!0);!r.collisionArrays&&g&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(g);const Q=(Ae,fe,Te)=>{for(let Se=0;Se0||Se>0,Qe=fe.numIconVertices>0,at=this.placedOrientations[fe.crossTileID],dt=at===s.WritingMode.vertical,ut=at===s.WritingMode.horizontal||at===s.WritingMode.horizontalOnly;if(!Fe&&!Qe||be.isHidden()||X++,Fe){const Rt=_m(be.text);Q(r.text,Te,dt?lu:Rt),Q(r.text,Se,ut?lu:Rt);const et=be.text.isHidden();[fe.rightJustifiedTextSymbolIndex,fe.centerJustifiedTextSymbolIndex,fe.leftJustifiedTextSymbolIndex].forEach(Jt=>{Jt>=0&&(r.text.placedSymbolArray.get(Jt).hidden=et||dt?1:0)}),fe.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get(fe.verticalPlacedTextSymbolIndex).hidden=et||ut?1:0);const zt=this.variableOffsets[fe.crossTileID];zt&&this.markUsedJustification(r,zt.anchor,fe,at);const Pt=this.placedOrientations[fe.crossTileID];Pt&&(this.markUsedJustification(r,"left",fe,Pt),this.markUsedOrientation(r,Pt,fe))}if(Qe){const Rt=_m(be.icon);fe.placedIconSymbolIndex>=0&&(Q(r.icon,fe.numIconVertices,dt?lu:Rt),r.icon.placedSymbolArray.get(fe.placedIconSymbolIndex).hidden=be.icon.isHidden()),fe.verticalPlacedIconSymbolIndex>=0&&(Q(r.icon,fe.numVerticalIconVertices,ut?lu:Rt),r.icon.placedSymbolArray.get(fe.verticalPlacedIconSymbolIndex).hidden=be.icon.isHidden())}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const Rt=r.collisionArrays[Ae];if(Rt){let et=new s.pointGeometry(0,0),zt=!0;if(Rt.textBox||Rt.verticalTextBox){if(F){const Jt=this.variableOffsets[Re];Jt?(et=bs(Jt.anchor,Jt.width,Jt.height,Jt.textOffset,Jt.textScale),N&&et._rotate(H?this.transform.angle:-this.transform.angle)):zt=!1}b&&(zt=!be.clipped),Rt.textBox&&fa(r.textCollisionBox.collisionVertexArray,be.text.placed,!zt||dt,et.x,et.y),Rt.verticalTextBox&&fa(r.textCollisionBox.collisionVertexArray,be.text.placed,!zt||ut,et.x,et.y)}const Pt=zt&&!!(!ut&&Rt.verticalIconBox);Rt.iconBox&&fa(r.iconCollisionBox.collisionVertexArray,be.icon.placed,Pt,J?et.x:0,J?et.y:0),Rt.verticalIconBox&&fa(r.iconCollisionBox.collisionVertexArray,be.icon.placed,!Pt,J?et.x:0,J?et.y:0)}}}if(r.fullyClipped=X===0,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const Ae=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=Ae.invProjMatrix,r.placementViewportMatrix=Ae.viewportMatrix,r.collisionCircleArray=Ae.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(r){return this.fadeDuration===0?1:(r-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(r){return Math.max(0,(this.transform.zoom-r)/1.5)}hasTransitions(r){return this.stale||r-this.lastPlacementChangeTimer}setStale(){this.stale=!0}}function fa(f,r,u,g,x){f.emplaceBack(r?1:0,u?1:0,g||0,x||0),f.emplaceBack(r?1:0,u?1:0,g||0,x||0),f.emplaceBack(r?1:0,u?1:0,g||0,x||0),f.emplaceBack(r?1:0,u?1:0,g||0,x||0)}const Iy=Math.pow(2,25),gm=Math.pow(2,24),Pr=Math.pow(2,17),ou=Math.pow(2,16),io=Math.pow(2,9),Md=Math.pow(2,8),su=Math.pow(2,1);function _m(f){if(f.opacity===0&&!f.placed)return 0;if(f.opacity===1&&f.placed)return 4294967295;const r=f.placed?1:0,u=Math.floor(127*f.opacity);return u*Iy+r*gm+u*Pr+r*ou+u*io+r*Md+u*su+r}const lu=0;class Td{constructor(r){this._sortAcrossTiles=r.layout.get("symbol-z-order")!=="viewport-y"&&r.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(r,u,g,x,b){const S=this._bucketParts;for(;this._currentTileIndexP.sortKey-z.sortKey));this._currentPartIndex{const S=s.exported.now()-x;return!this._forceFullPlacement&&S>2};for(;this._currentPlacementIndex>=0;){const S=u[r[this._currentPlacementIndex]],P=this.placement.collisionIndex.transform.zoom;if(S.type==="symbol"&&(!S.minzoom||S.minzoom<=P)&&(!S.maxzoom||S.maxzoom>P)){if(this._inProgressLayer||(this._inProgressLayer=new Td(S)),this._inProgressLayer.continuePlacement(g[S.source],this.placement,this._showCollisionBoxes,S,b))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(r){return this.placement.commit(r),this.placement}}const ym=512/s.EXTENT/2;class zy{constructor(r,u,g){this.tileID=r,this.indexedSymbolInstances={},this.bucketInstanceId=g;for(let x=0;xr.overscaledZ)for(const P in S){const z=S[P];z.tileID.isChildOf(r)&&z.findMatches(u.symbolInstances,r,x)}else{const P=S[r.scaledTo(Number(b)).key];P&&P.findMatches(u.symbolInstances,r,x)}}for(let b=0;b{u[g]=!0});for(const g in this.layerIndexes)u[g]||delete this.layerIndexes[g]}}const _l=(f,r)=>s.emitValidationErrors(f,r&&r.filter(u=>u.identifier!=="source.canvas")),xm=s.pick(_t,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),bm=s.pick(_t,["setCenter","setZoom","setBearing","setPitch"]),wm={version:8,layers:[],sources:{}},No={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class gr extends s.Evented{constructor(r,u={}){super(),this.map=r,this.dispatcher=new ge(ze(),this),this.imageManager=new ye,this.imageManager.setEventedParent(this),this.glyphManager=new s.GlyphManager(r._requestManager,u.localFontFamily?s.LocalGlyphMode.all:u.localIdeographFontFamily?s.LocalGlyphMode.ideographs:s.LocalGlyphMode.none,u.localFontFamily||u.localIdeographFontFamily),this.lineAtlas=new s.LineAtlas(256,512),this.crossTileSymbolIndex=new cu,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new s.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",s.getReferrer());const g=this;this._rtlTextPluginCallback=gr.registerForPluginStateChange(x=>{g.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:x.pluginStatus,pluginURL:x.pluginURL},(b,S)=>{if(s.triggerPluginCompletionEvent(b),S&&S.every(P=>P))for(const P in g._sourceCaches){const z=g._sourceCaches[P],F=z.getSource().type;F!=="vector"&&F!=="geojson"||z.reload()}})}),this.on("data",x=>{if(x.dataType!=="source"||x.sourceDataType!=="metadata")return;const b=this.getSource(x.sourceId);if(b&&b.vectorLayerIds)for(const S in this._layers){const P=this._layers[S];P.source===b.id&&this._validateLayer(P)}})}loadURL(r,u={}){this.fire(new s.Event("dataloading",{dataType:"style"}));const g=typeof u.validate=="boolean"?u.validate:!s.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,u.accessToken);const x=this.map._requestManager.transformRequest(r,s.ResourceType.Style);this._request=s.getJSON(x,(b,S)=>{this._request=null,b?this.fire(new s.ErrorEvent(b)):S&&this._load(S,g)})}loadJSON(r,u={}){this.fire(new s.Event("dataloading",{dataType:"style"})),this._request=s.exported.frame(()=>{this._request=null,this._load(r,u.validate!==!1)})}loadEmpty(){this.fire(new s.Event("dataloading",{dataType:"style"})),this._load(wm,!1)}_updateLayerCount(r,u){const g=u?1:-1;r.is3D()&&(this._num3DLayers+=g),r.type==="circle"&&(this._numCircleLayers+=g),r.type==="symbol"&&(this._numSymbolLayers+=g)}_load(r,u){if(u&&_l(this,s.validateStyle(r)))return;this._loaded=!0,this.stylesheet=r,this._updateMapProjection();for(const x in r.sources)this.addSource(x,r.sources[x],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const g=Mt(this.stylesheet.layers);this._order=g.map(x=>x.id),this._layers={},this._serializedLayers={};for(let x of g)x=s.createStyleLayer(x),x.setEventedParent(this,{layer:{id:x.id}}),this._layers[x.id]=x,this._serializedLayers[x.id]=x.serialize(),this._updateLayerCount(x,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new Oe(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 s.Event("data",{dataType:"style"})),this.fire(new s.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}setProjection(r){r?this.stylesheet.projection=r: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(r){this._spriteRequest=function(u,g,x){let b,S,P;const z=s.exported.devicePixelRatio>1?"@2x":"";let F=s.getJSON(g.transformRequest(g.normalizeSpriteURL(u,z,".json"),s.ResourceType.SpriteJSON),(J,re)=>{F=null,P||(P=J,b=re,H())}),N=s.getImage(g.transformRequest(g.normalizeSpriteURL(u,z,".png"),s.ResourceType.SpriteImage),(J,re)=>{N=null,P||(P=J,S=re,H())});function H(){if(P)x(P);else if(b&&S){const J=s.exported.getImageData(S),re={};for(const Q in b){const{width:X,height:Ae,x:fe,y:Te,sdf:Se,pixelRatio:Re,stretchX:be,stretchY:Fe,content:Qe}=b[Q],at=new s.RGBAImage({width:X,height:Ae});s.RGBAImage.copy(J,at,{x:fe,y:Te},{x:0,y:0},{width:X,height:Ae}),re[Q]={data:at,pixelRatio:Re,sdf:Se,stretchX:be,stretchY:Fe,content:Qe}}x(null,re)}}return{cancel(){F&&(F.cancel(),F=null),N&&(N.cancel(),N=null)}}}(r,this.map._requestManager,(u,g)=>{if(this._spriteRequest=null,u)this.fire(new s.ErrorEvent(u));else if(g)for(const x in g)this.imageManager.addImage(x,g[x]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new s.Event("data",{dataType:"style"}))})}_validateLayer(r){const u=this.getSource(r.source);if(!u)return;const g=r.sourceLayer;g&&(u.type==="geojson"||u.vectorLayerIds&&u.vectorLayerIds.indexOf(g)===-1)&&this.fire(new s.ErrorEvent(new Error(`Source layer "${g}" does not exist on source "${u.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const r in this._sourceCaches)if(!this._sourceCaches[r].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(r){const u=[];for(const g of r){const x=this._layers[g];x.type!=="custom"&&u.push(x.serialize())}return u}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const r in this._sourceCaches)if(this._sourceCaches[r].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(r){return!!this.terrain&&No[r.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(r){if(!this._loaded)return;const u=this._changed;if(this._changed){const x=Object.keys(this._updatedLayers),b=Object.keys(this._removedLayers);(x.length||b.length)&&this._updateWorkerLayers(x,b);for(const S in this._updatedSources){const P=this._updatedSources[S];P==="reload"?this._reloadSource(S):P==="clear"&&this._clearSource(S)}this._updateTilesForChangedImages();for(const S in this._updatedPaintProps)this._layers[S].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const g={};for(const x in this._sourceCaches){const b=this._sourceCaches[x];g[x]=b.used,b.used=!1}for(const x of this._order){const b=this._layers[x];if(b.recalculate(r,this._availableImages),!b.isHidden(r.zoom)){const P=this._getLayerSourceCache(b);P&&(P.used=!0)}const S=this.map.painter;if(S){const P=b.getProgramIds();if(!P)continue;const z=b.getProgramConfiguration(r.zoom);for(const F of P)S.useProgram(F,z)}}for(const x in g){const b=this._sourceCaches[x];g[x]!==b.used&&b.getSource().fire(new s.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:b.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),u&&this.fire(new s.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const r=Object.keys(this._changedImages);if(r.length){for(const u in this._sourceCaches)this._sourceCaches[u].reloadTilesForDependencies(["icons","patterns"],r);this._changedImages={}}}_updateWorkerLayers(r,u){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(r),removedIds:u})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),_l(this,s.validateStyle(r)))return!1;(r=s.clone$1(r)).layers=Mt(r.layers);const u=function(x,b){if(!x)return[{command:_t.setStyle,args:[b]}];let S=[];try{if(!E(x.version,b.version))return[{command:_t.setStyle,args:[b]}];E(x.center,b.center)||S.push({command:_t.setCenter,args:[b.center]}),E(x.zoom,b.zoom)||S.push({command:_t.setZoom,args:[b.zoom]}),E(x.bearing,b.bearing)||S.push({command:_t.setBearing,args:[b.bearing]}),E(x.pitch,b.pitch)||S.push({command:_t.setPitch,args:[b.pitch]}),E(x.sprite,b.sprite)||S.push({command:_t.setSprite,args:[b.sprite]}),E(x.glyphs,b.glyphs)||S.push({command:_t.setGlyphs,args:[b.glyphs]}),E(x.transition,b.transition)||S.push({command:_t.setTransition,args:[b.transition]}),E(x.light,b.light)||S.push({command:_t.setLight,args:[b.light]}),E(x.fog,b.fog)||S.push({command:_t.setFog,args:[b.fog]}),E(x.projection,b.projection)||S.push({command:_t.setProjection,args:[b.projection]});const P={},z=[];(function(H,J,re,Q){let X;for(X in J=J||{},H=H||{})H.hasOwnProperty(X)&&(J.hasOwnProperty(X)||nn(X,re,Q));for(X in J)J.hasOwnProperty(X)&&(H.hasOwnProperty(X)?E(H[X],J[X])||(H[X].type==="geojson"&&J[X].type==="geojson"&&Dn(H,J,X)?re.push({command:_t.setGeoJSONSourceData,args:[X,J[X].data]}):Ln(X,J,re,Q)):Ft(X,J,re))})(x.sources,b.sources,z,P);const F=[];x.layers&&x.layers.forEach(H=>{H.source&&P[H.source]?S.push({command:_t.removeLayer,args:[H.id]}):F.push(H)});let N=x.terrain;N&&P[N.source]&&(S.push({command:_t.setTerrain,args:[void 0]}),N=void 0),S=S.concat(z),E(N,b.terrain)||S.push({command:_t.setTerrain,args:[b.terrain]}),function(H,J,re){J=J||[];const Q=(H=H||[]).map(cn),X=J.map(cn),Ae=H.reduce($t,{}),fe=J.reduce($t,{}),Te=Q.slice(),Se=Object.create(null);let Re,be,Fe,Qe,at,dt,ut;for(Re=0,be=0;Re!(x.command in bm));if(u.length===0)return!1;const g=u.filter(x=>!(x.command in xm));if(g.length>0)throw new Error(`Unimplemented: ${g.map(x=>x.command).join(", ")}.`);return u.forEach(x=>{x.command!=="setTransition"&&this[x.command].apply(this,x.args)}),this.stylesheet=r,this._updateMapProjection(),!0}addImage(r,u){return this.getImage(r)?this.fire(new s.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(r,u),this._afterImageUpdated(r),this)}updateImage(r,u){this.imageManager.updateImage(r,u)}getImage(r){return this.imageManager.getImage(r)}removeImage(r){return this.getImage(r)?(this.imageManager.removeImage(r),this._afterImageUpdated(r),this):this.fire(new s.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new s.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,u,g={}){if(this._checkLoaded(),this.getSource(r)!==void 0)throw new Error("There is already a source with this ID");if(!u.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(u).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(u.type)>=0&&this._validate(s.validateSource,`sources.${r}`,u,null,g))return;this.map&&this.map._collectResourceTiming&&(u.collectResourceTiming=!0);const x=Ke(r,u,this.dispatcher,this);x.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(r),source:x.serialize(),sourceId:r}));const b=S=>{const P=(S?"symbol:":"other:")+r,z=this._sourceCaches[P]=new s.SourceCache(P,x,S);(S?this._symbolSourceCaches:this._otherSourceCaches)[r]=z,z.style=this,z.onAdd(this.map)};b(!1),u.type!=="vector"&&u.type!=="geojson"||b(!0),x.onAdd&&x.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const u=this.getSource(r);if(!u)throw new Error("There is no source with this ID");for(const x in this._layers)if(this._layers[x].source===r)return this.fire(new s.ErrorEvent(new Error(`Source "${r}" cannot be removed while layer "${x}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new s.ErrorEvent(new Error(`Source "${r}" cannot be removed while terrain is using it.`)));const g=this._getSourceCaches(r);for(const x of g)delete this._sourceCaches[x.id],delete this._updatedSources[x.id],x.fire(new s.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:x.getSource().id})),x.setEventedParent(null),x.clearTiles();return delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],u.setEventedParent(null),u.onRemove&&u.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(r,u){this._checkLoaded(),this.getSource(r).setData(u),this._changed=!0}getSource(r){const u=this._getSourceCache(r);return u&&u.getSource()}addLayer(r,u,g={}){this._checkLoaded();const x=r.id;if(this.getLayer(x))return void this.fire(new s.ErrorEvent(new Error(`Layer with id "${x}" already exists on this map`)));let b;if(r.type==="custom"){if(_l(this,s.validateCustomStyleLayer(r)))return;b=s.createStyleLayer(r)}else{if(typeof r.source=="object"&&(this.addSource(x,r.source),r=s.clone$1(r),r=s.extend(r,{source:x})),this._validate(s.validateLayer,`layers.${x}`,r,{arrayIndex:-1},g))return;b=s.createStyleLayer(r),this._validateLayer(b),b.setEventedParent(this,{layer:{id:x}}),this._serializedLayers[b.id]=b.serialize(),this._updateLayerCount(b,!0)}const S=u?this._order.indexOf(u):this._order.length;if(u&&S===-1)return void this.fire(new s.ErrorEvent(new Error(`Layer with id "${u}" does not exist on this map.`)));this._order.splice(S,0,x),this._layerOrderChanged=!0,this._layers[x]=b;const P=this._getLayerSourceCache(b);if(this._removedLayers[x]&&b.source&&P&&b.type!=="custom"){const z=this._removedLayers[x];delete this._removedLayers[x],z.type!==b.type?this._updatedSources[b.source]="clear":(this._updatedSources[b.source]="reload",P.pause())}this._updateLayer(b),b.onAdd&&b.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,u){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===u)return;const g=this._order.indexOf(r);this._order.splice(g,1);const x=u?this._order.indexOf(u):this._order.length;u&&x===-1?this.fire(new s.ErrorEvent(new Error(`Layer with id "${u}" does not exist on this map.`))):(this._order.splice(x,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const u=this._layers[r];if(!u)return void this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));u.setEventedParent(null),this._updateLayerCount(u,!1);const g=this._order.indexOf(r);this._order.splice(g,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=u,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],u.onRemove&&u.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(r){return this._layers[r]}hasLayer(r){return r in this._layers}hasLayerType(r){for(const u in this._layers)if(this._layers[u].type===r)return!0;return!1}setLayerZoomRange(r,u,g){this._checkLoaded();const x=this.getLayer(r);x?x.minzoom===u&&x.maxzoom===g||(u!=null&&(x.minzoom=u),g!=null&&(x.maxzoom=g),this._updateLayer(x)):this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,u,g={}){this._checkLoaded();const x=this.getLayer(r);if(x){if(!E(x.filter,u))return u==null?(x.filter=void 0,void this._updateLayer(x)):void(this._validate(s.validateFilter,`layers.${x.id}.filter`,u,{layerType:x.type},g)||(x.filter=s.clone$1(u),this._updateLayer(x)))}else this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){const u=this.getLayer(r);return u&&s.clone$1(u.filter)}setLayoutProperty(r,u,g,x={}){this._checkLoaded();const b=this.getLayer(r);b?E(b.getLayoutProperty(u),g)||(b.setLayoutProperty(u,g,x),this._updateLayer(b)):this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,u){const g=this.getLayer(r);if(g)return g.getLayoutProperty(u);this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,u,g,x={}){this._checkLoaded();const b=this.getLayer(r);b?E(b.getPaintProperty(u),g)||(b.setPaintProperty(u,g,x)&&this._updateLayer(b),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(r,u){const g=this.getLayer(r);return g&&g.getPaintProperty(u)}setFeatureState(r,u){this._checkLoaded();const g=r.source,x=r.sourceLayer,b=this.getSource(g);if(!b)return void this.fire(new s.ErrorEvent(new Error(`The source '${g}' does not exist in the map's style.`)));const S=b.type;if(S==="geojson"&&x)return void this.fire(new s.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(S==="vector"&&!x)return void this.fire(new s.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));r.id===void 0&&this.fire(new s.ErrorEvent(new Error("The feature id parameter must be provided.")));const P=this._getSourceCaches(g);for(const z of P)z.setFeatureState(x,r.id,u)}removeFeatureState(r,u){this._checkLoaded();const g=r.source,x=this.getSource(g);if(!x)return void this.fire(new s.ErrorEvent(new Error(`The source '${g}' does not exist in the map's style.`)));const b=x.type,S=b==="vector"?r.sourceLayer:void 0;if(b==="vector"&&!S)return void this.fire(new s.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(u&&typeof r.id!="string"&&typeof r.id!="number")return void this.fire(new s.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const P=this._getSourceCaches(g);for(const z of P)z.removeFeatureState(S,r.id,u)}getFeatureState(r){this._checkLoaded();const u=r.source,g=r.sourceLayer,x=this.getSource(u);if(x){if(x.type!=="vector"||g)return r.id===void 0&&this.fire(new s.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(u)[0].getFeatureState(g,r.id);this.fire(new s.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new s.ErrorEvent(new Error(`The source '${u}' does not exist in the map's style.`)))}getTransition(){return s.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const u in this._sourceCaches){const g=this._sourceCaches[u].getSource();r[g.id]||(r[g.id]=g.serialize())}return s.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:r,layers:this._serializeLayers(this._order)},u=>u!==void 0)}_updateLayer(r){this._updatedLayers[r.id]=!0;const u=this._getLayerSourceCache(r);r.source&&!this._updatedSources[r.source]&&u&&u.getSource().type!=="raster"&&(this._updatedSources[r.source]="reload",u.pause()),this._changed=!0,r.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(r){const u=S=>this._layers[S].type==="fill-extrusion",g={},x=[];for(let S=this._order.length-1;S>=0;S--){const P=this._order[S];if(u(P)){g[P]=S;for(const z of r){const F=z[P];if(F)for(const N of F)x.push(N)}}}x.sort((S,P)=>P.intersectionZ-S.intersectionZ);const b=[];for(let S=this._order.length-1;S>=0;S--){const P=this._order[S];if(u(P))for(let z=x.length-1;z>=0;z--){const F=x[z].feature;if(g[F.layer.id]{const F=this.getLayer(z);return F&&F.is3D()}):this.has3DLayers(),P=Ne.createFromScreenPoints(r,g);for(const z in this._sourceCaches){const F=this._sourceCaches[z].getSource().id;u.layers&&!x[F]||b.push(nt(this._sourceCaches[z],this._layers,this._serializedLayers,P,u,g,S,!!this.map._showQueryGeometry))}return this.placement&&b.push(function(z,F,N,H,J,re,Q){const X={},Ae=re.queryRenderedSymbols(H),fe=[];for(const Te of Object.keys(Ae).map(Number))fe.push(Q[Te]);fe.sort(Ut);for(const Te of fe){const Se=Te.featureIndex.lookupSymbolFeatures(Ae[Te.bucketInstanceId],F,Te.bucketIndex,Te.sourceLayerIndex,J.filter,J.layers,J.availableImages,z);for(const Re in Se){const be=X[Re]=X[Re]||[],Fe=Se[Re];Fe.sort((Qe,at)=>{const dt=Te.featureSortOrder;if(dt){const ut=dt.indexOf(Qe.featureIndex);return dt.indexOf(at.featureIndex)-ut}return at.featureIndex-Qe.featureIndex});for(const Qe of Fe)be.push(Qe)}}for(const Te in X)X[Te].forEach(Se=>{const Re=Se.feature,be=N(z[Te]).getFeatureState(Re.layer["source-layer"],Re.id);Re.source=Re.layer.source,Re.layer["source-layer"]&&(Re.sourceLayer=Re.layer["source-layer"]),Re.state=be});return X}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),P.screenGeometry,u,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(b)}querySourceFeatures(r,u){u&&u.filter&&this._validate(s.validateFilter,"querySourceFeatures.filter",u.filter,null,u);const g=this._getSourceCaches(r);let x=[];for(const b of g)x=x.concat(yt(b,u));return x}addSourceType(r,u,g){return gr.getSourceType(r)?g(new Error(`A source type called "${r}" already exists.`)):(gr.setSourceType(r,u),u.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:r,url:u.workerSourceURL},g):g(null,null))}getLight(){return this.light.getLight()}setLight(r,u={}){this._checkLoaded();const g=this.light.getLight();let x=!1;for(const S in r)if(!E(r[S],g[S])){x=!0;break}if(!x)return;const b={now:s.exported.now(),transition:s.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(r,u),this.light.updateTransitions(b)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(r,u=1){if(this._checkLoaded(),!r)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(u===1){if(typeof r.source=="object"){const g="terrain-dem-src";this.addSource(g,r.source),r=s.clone$1(r),r=s.extend(r,{source:g})}if(this._validate(s.validateTerrain,"terrain",r))return}if(!this.terrain||this.terrain&&u!==this.terrain.drapeRenderMode)this._createTerrain(r,u);else{const g=this.terrain,x=g.get();for(const b in r)if(!E(r[b],x[b])){g.set(r),this.stylesheet.terrain=r;const S={now:s.exported.now(),transition:s.extend({duration:0},this.stylesheet.transition)};g.updateTransitions(S);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(r){const u=this.fog=new Pe(r,this.map.transform);this.stylesheet.fog=r;const g={now:s.exported.now(),transition:s.extend({duration:0},this.stylesheet.transition)};u.updateTransitions(g)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const r of this.map._markers)r._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const u=this.fog,g=u.get();for(const x in r)if(!E(r[x],g[x])){u.set(r),this.stylesheet.fog=r;const b={now:s.exported.now(),transition:s.extend({duration:0},this.stylesheet.transition)};u.updateTransitions(b);break}}else this._createFog(r);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const r=this._order.filter(g=>this.isLayerDraped(this._layers[g])),u=this._order.filter(g=>!this.isLayerDraped(this._layers[g]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...r),this._drapedFirstOrder.push(...u)}_createTerrain(r,u){const g=this.terrain=new St(r,u);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const x={now:s.exported.now(),transition:s.extend({duration:0},this.stylesheet.transition)};g.updateTransitions(x)}_force3DLayerUpdate(){for(const r in this._layers){const u=this._layers[r];u.type==="fill-extrusion"&&this._updateLayer(u)}}_forceSymbolLayerUpdate(){for(const r in this._layers){const u=this._layers[r];u.type==="symbol"&&this._updateLayer(u)}}_validate(r,u,g,x,b={}){return(!b||b.validate!==!1)&&_l(this,r.call(s.validateStyle,s.extend({key:u,style:this.serialize(),value:g,styleSpec:s.spec},x)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),s.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const r in this._layers)this._layers[r].setEventedParent(null);for(const r in this._sourceCaches)this._sourceCaches[r].clearTiles(),this._sourceCaches[r].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(r){const u=this._getSourceCaches(r);for(const g of u)g.clearTiles()}_reloadSource(r){const u=this._getSourceCaches(r);for(const g of u)g.resume(),g.reload()}_updateSources(r){for(const u in this._sourceCaches)this._sourceCaches[u].update(r)}_generateCollisionBoxes(){for(const r in this._sourceCaches){const u=this._sourceCaches[r];u.resume(),u.reload()}}_updatePlacement(r,u,g,x,b=!1){let S=!1,P=!1;const z={};for(const F of this._order){const N=this._layers[F];if(N.type!=="symbol")continue;if(!z[N.source]){const J=this._getLayerSourceCache(N);if(!J)continue;z[N.source]=J.getRenderableIds(!0).map(re=>J.getTileByID(re)).sort((re,Q)=>Q.tileID.overscaledZ-re.tileID.overscaledZ||(re.tileID.isLessThan(Q.tileID)?-1:1))}const H=this.crossTileSymbolIndex.addLayer(N,z[N.source],r.center.lng,r.projection);S=S||H}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),b=b||this._layerOrderChanged||g===0,this._layerOrderChanged&&this.fire(new s.Event("neworder")),(b||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(s.exported.now(),r.zoom))&&(this.pauseablePlacement=new Ry(r,this._order,b,u,g,x,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,z),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(s.exported.now()),P=!0),S&&this.pauseablePlacement.placement.setStale()),P||S)for(const F of this._order){const N=this._layers[F];N.type==="symbol"&&this.placement.updateLayerOpacities(N,z[N.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(s.exported.now())}_releaseSymbolFadeTiles(){for(const r in this._sourceCaches)this._sourceCaches[r].releaseSymbolFadeTiles()}getImages(r,u,g){this.imageManager.getImages(u.icons,g),this._updateTilesForChangedImages();const x=b=>{b&&b.setDependencies(u.tileID.key,u.type,u.icons)};x(this._otherSourceCaches[u.source]),x(this._symbolSourceCaches[u.source])}getGlyphs(r,u,g){this.glyphManager.getGlyphs(u.stacks,g)}getResource(r,u,g){return s.makeRequest(u,g)}_getSourceCache(r){return this._otherSourceCaches[r]}_getLayerSourceCache(r){return r.type==="symbol"?this._symbolSourceCaches[r.source]:this._otherSourceCaches[r.source]}_getSourceCaches(r){const u=[];return this._otherSourceCaches[r]&&u.push(this._otherSourceCaches[r]),this._symbolSourceCaches[r]&&u.push(this._symbolSourceCaches[r]),u}_isSourceCacheLoaded(r){const u=this._getSourceCaches(r);return u.length===0?(this.fire(new s.ErrorEvent(new Error(`There is no source with ID '${r}'`))),!1):u.every(g=>g.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)}}gr.getSourceType=function(f){return Je[f]},gr.setSourceType=function(f,r){Je[f]=r},gr.registerForPluginStateChange=s.registerForPluginStateChange;var yl=` #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`,vl="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 Uo={},ro={};Uo=gn("",` #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),ro=gn(`#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 uu=gn(` 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.`),xl=yl;var bl={background:gn(`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:gn(`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:gn(`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:gn("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:gn(`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:gn(`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:gn("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:gn("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:gn("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:gn(`#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:gn(`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:gn(`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:gn(`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:gn(`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:gn(`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:gn(`#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:gn(`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:gn(`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:gn(`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:gn(`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:gn(`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:gn(`#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:gn(`#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:gn(`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:gn(`#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:gn(` 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 }`,vl),skyboxGradient:gn(`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 }`,vl),skyboxCapture:gn(` 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:gn(`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:gn(`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 gn(f,r,u){const g=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,x=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,b=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),S=f.match(x),P=r.match(x),z=yl.match(x);let F=P?P.concat(S):S;u||(Uo.staticUniforms&&(F=Uo.staticUniforms.concat(F)),ro.staticUniforms&&(F=ro.staticUniforms.concat(F))),F&&(F=F.concat(z));const N={};return{fragmentSource:f=f.replace(g,(H,J,re,Q,X)=>(N[X]=!0,J==="define"?` #ifndef HAS_UNIFORM_u_${X} varying ${re} ${Q} ${X}; #else uniform ${re} ${Q} u_${X}; #endif `:` #ifdef HAS_UNIFORM_u_${X} ${re} ${Q} ${X} = u_${X}; #endif `)),vertexSource:r=r.replace(g,(H,J,re,Q,X)=>{const Ae=Q==="float"?"vec2":"vec4",fe=X.match(/color/)?"color":Ae;return N[X]?J==="define"?` #ifndef HAS_UNIFORM_u_${X} uniform lowp float u_${X}_t; attribute ${re} ${Ae} a_${X}; varying ${re} ${Q} ${X}; #else uniform ${re} ${Q} u_${X}; #endif `:fe==="vec4"?` #ifndef HAS_UNIFORM_u_${X} ${X} = a_${X}; #else ${re} ${Q} ${X} = u_${X}; #endif `:` #ifndef HAS_UNIFORM_u_${X} ${X} = unpack_mix_${fe}(a_${X}, u_${X}_t); #else ${re} ${Q} ${X} = u_${X}; #endif `:J==="define"?` #ifndef HAS_UNIFORM_u_${X} uniform lowp float u_${X}_t; attribute ${re} ${Ae} a_${X}; #else uniform ${re} ${Q} u_${X}; #endif `:fe==="vec4"?` #ifndef HAS_UNIFORM_u_${X} ${re} ${Q} ${X} = a_${X}; #else ${re} ${Q} ${X} = u_${X}; #endif `:` #ifndef HAS_UNIFORM_u_${X} ${re} ${Q} ${X} = unpack_mix_${fe}(a_${X}, u_${X}_t); #else ${re} ${Q} ${X} = u_${X}; #endif `}),staticAttributes:b,staticUniforms:F}}class hu{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(r,u,g,x,b,S,P,z){this.context=r;let F=this.boundPaintVertexBuffers.length!==x.length;for(let N=0;!F&&N{const Se=fe.paint.get("hillshade-shadow-color"),Re=fe.paint.get("hillshade-highlight-color"),be=fe.paint.get("hillshade-accent-color");let Fe=fe.paint.get("hillshade-illumination-direction")*(Math.PI/180);fe.paint.get("hillshade-illumination-anchor")==="viewport"&&(Fe-=X.transform.angle);const Qe=!X.options.moving;return{u_matrix:Te||X.transform.calculateProjMatrix(Ae.tileID.toUnwrapped(),Qe),u_image:0,u_latrange:Mm(0,Ae.tileID),u_light:[fe.paint.get("hillshade-exaggeration"),Fe],u_shadow:Se,u_highlight:Re,u_accent:be}})(f,u,g,f.terrain?r.projMatrix:null);f.prepareDrawProgram(P,N,r.toUnwrapped());const{tileBoundsBuffer:J,tileBoundsIndexBuffer:re,tileBoundsSegments:Q}=f.getTileBoundsBuffers(u);N.draw(P,z.TRIANGLES,x,b,S,s.CullFaceMode.disabled,H,g.id,J,re,Q)}function Ed(f,r,u){if(!r.needsDEMTextureUpload)return;const g=f.context,x=g.gl;g.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture=r.demTexture||f.getTileTexture(u.stride);const b=u.getPixels();r.demTexture?r.demTexture.update(b,{premultiply:!1}):r.demTexture=new s.Texture(g,b,x.RGBA,{premultiply:!1}),r.needsDEMTextureUpload=!1}function Sd(f,r,u,g,x,b){const S=f.context,P=S.gl;if(!r.dem)return;const z=r.dem;if(S.activeTexture.set(P.TEXTURE1),Ed(f,r,z),!r.demTexture)return;r.demTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE);const F=z.dim;S.activeTexture.set(P.TEXTURE0);let N=r.fbo;if(!N){const Q=new s.Texture(S,{width:F,height:F,data:null},P.RGBA);Q.bind(P.LINEAR,P.CLAMP_TO_EDGE),N=r.fbo=S.createFramebuffer(F,F,!0),N.colorAttachment.set(Q.texture)}S.bindFramebuffer.set(N.framebuffer),S.viewport.set([0,0,F,F]);const{tileBoundsBuffer:H,tileBoundsIndexBuffer:J,tileBoundsSegments:re}=f.getMercatorTileBoundsBuffers();f.useProgram("hillshadePrepare").draw(S,P.TRIANGLES,g,x,b,s.CullFaceMode.disabled,((Q,X)=>{const Ae=X.stride,fe=s.create();return s.ortho(fe,0,s.EXTENT,-s.EXTENT,0,0,1),s.translate(fe,fe,[0,-s.EXTENT,0]),{u_matrix:fe,u_image:1,u_dimension:[Ae,Ae],u_zoom:Q.overscaledZ,u_unpack:X.unpackVector}})(r.tileID,z),u.id,H,J,re),r.needsHillshadePrepare=!1}const Ad=(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_image0:new s.Uniform1i(f,r.u_image0),u_skirt_height:new s.Uniform1f(f,r.u_skirt_height)}),Em=(f,r)=>({u_matrix:f,u_image0:0,u_skirt_height:r}),Sm=(f,r,u,g,x,b)=>({u_proj_matrix:Float32Array.from(f),u_globe_matrix:r,u_merc_matrix:u,u_zoom_transition:g,u_merc_center:x,u_image0:0,u_grid_matrix:b?Float32Array.from(b):new Float32Array(9)});function du(f,r){return f!=null&&r!=null&&!(!f.hasData()||!r.hasData())&&f.demTexture!=null&&r.demTexture!=null&&f.tileID.key!==r.tileID.key}const ao=new class{constructor(){this.operations={}}newMorphing(f,r,u,g,x){if(f in this.operations){const b=this.operations[f];b.to.tileID.key!==u.tileID.key&&(b.queued=u)}else this.operations[f]={startTime:g,phase:0,duration:x,from:r,to:u,queued:null}}getMorphValuesForProxy(f){if(!(f in this.operations))return null;const r=this.operations[f];return{from:r.from,to:r.to,phase:r.phase}}update(f){for(const r in this.operations){const u=this.operations[r];for(u.phase=(f-u.startTime)/u.duration;u.phase>=1||!this._validOp(u);)if(!this._nextOp(u,f)){delete this.operations[r];break}}}_nextOp(f,r){return!!f.queued&&(f.from=f.to,f.to=f.queued,f.queued=null,f.phase=0,f.startTime=r,!0)}_validOp(f){return f.from.hasData()&&f.to.hasData()}},Ms={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function Cd(f,r){const u=1<({u_matrix:f});function Pd(f,r,u,g,x){if(x>0){const b=s.exported.now(),S=(b-f.timeAdded)/x,P=r?(b-r.timeAdded)/x:-1,z=u.getSource(),F=g.coveringZoomLevel({tileSize:z.tileSize,roundZoom:z.roundZoom}),N=!r||Math.abs(r.tileID.overscaledZ-F)>Math.abs(f.tileID.overscaledZ-F),H=N&&f.refreshedUponExpiration?1:s.clamp(N?S:1-P,0,1);return f.refreshedUponExpiration&&S>=1&&(f.refreshedUponExpiration=!1),r?{opacity:1,mix:1-H}:{opacity:H,mix:0}}return{opacity:1,mix:0}}const By=2*s.mercatorZfromAltitude(1,0)*s.GLOBE_RADIUS*Math.PI;class wl extends s.SourceCache{constructor(r){const u={type:"raster-dem",maxzoom:r.transform.maxZoom},g=new ge(ze(),null),x=Ke("mock-dem",u,g,r.style);super("mock-dem",x,!1),x.setEventedParent(this),this._sourceLoaded=!0}_loadTile(r,u){r.state="loaded",u(null)}}class Ml extends s.SourceCache{constructor(r){const u=Ke("proxy",{type:"geojson",maxzoom:r.transform.maxZoom},new ge(ze(),null),r.style);super("proxy",u,!1),u.setEventedParent(this),this.map=this.getSource().map=r,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(r,u,g){if(r.freezeTileCoverage)return;this.transform=r;const x=r.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((b,S)=>{if(b[S.key]="",!this._tiles[S.key]){const P=new s.Tile(S,this._source.tileSize*S.overscaleFactor(),r.tileZoom);P.state="loaded",this._tiles[S.key]=P}return b},{});for(const b in this._tiles)b in x||(this.freeFBO(b),this._tiles[b].unloadVectorData(),delete this._tiles[b])}freeFBO(r){const u=this.proxyCachedFBO[r];if(u!==void 0){const g=Object.values(u);this.renderCachePool.push(...g),delete this.proxyCachedFBO[r]}}deallocRenderCache(){this.renderCache.forEach(r=>r.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Ld extends s.OverscaledTileID{constructor(r,u,g){super(r.overscaledZ,r.wrap,r.canonical.z,r.canonical.x,r.canonical.y),this.proxyTileKey=u,this.projMatrix=g}}class Lr extends s.Elevation{constructor(r,u){super(),this.painter=r,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[g,x,b]=function(z){const F=new s.StructArrayLayout4i8,N=new s.StructArrayLayout3ui6,H=131;F.reserve(17161),N.reserve(33800);const J=s.EXTENT/128,re=s.EXTENT+J/2,Q=re+J;for(let Ae=-J;Aere||Ae<0||Ae>re?24575:0,Se=s.clamp(Math.round(fe),0,s.EXTENT),Re=s.clamp(Math.round(Ae),0,s.EXTENT);F.emplaceBack(Se+Te,Re,Se,Re)}const X=(Ae,fe)=>{const Te=fe*H+Ae;N.emplaceBack(Te+1,Te,Te+H),N.emplaceBack(Te+H,Te+H+1,Te+1)};for(let Ae=1;Ae<129;Ae++)for(let fe=1;fe<129;fe++)X(fe,Ae);return[0,129].forEach(Ae=>{for(let fe=0;fe<130;fe++)X(fe,Ae),X(Ae,fe)}),[F,N,32768]}(),S=r.context;this.gridBuffer=S.createVertexBuffer(g,s.boundsAttributes.members),this.gridIndexBuffer=S.createIndexBuffer(x),this.gridSegments=s.SegmentVector.simpleSegment(0,0,g.length,x.length),this.gridNoSkirtSegments=s.SegmentVector.simpleSegment(0,0,g.length,b),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Ml(u.map),this.orthoMatrix=s.create(),s.ortho(this.orthoMatrix,0,s.EXTENT,0,s.EXTENT,0,1);const P=S.gl;this._overlapStencilMode=new s.StencilMode({func:P.GEQUAL,mask:255},0,255,P.KEEP,P.KEEP,P.REPLACE),this._previousZoom=r.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=u,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new wl(u.map)}set style(r){r.on("data",this._onStyleDataEvent.bind(this)),r.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=r,this._checkRenderCacheEfficiency()}update(r,u,g){if(r&&r.terrain){this._style!==r&&(this.style=r),this.enabled=!0;const x=r.terrain.properties;this.sourceCache=r.terrain.drapeRenderMode===0?this._mockSourceCache:r._getSourceCache(x.get("source")),this._exaggeration=x.get("exaggeration");const b=()=>{this.sourceCache.used&&s.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(u,S,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,b(),this._initializing=!0),b(),u.updateElevation(!g),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(u),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(r){this._findCoveringTileCache[r]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const r=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||r.efficiency!==100&&s.warnOnce(`Terrain render cache efficiency is not optimal (${r.efficiency}%) and performance may be affected negatively, consider placing all background, fill and line layers before layer with id '${r.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(r){r.coord&&r.dataType==="source"?this._clearRenderCacheForTile(r.sourceCacheId,r.coord):r.dataType==="style"&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const r in this._style._sourceCaches)this._style._sourceCaches[r].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(r=>r.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 r=2*this.proxySourceCache.getSource().tileSize;return[r,r]}set useVertexMorphing(r){this._useVertexMorphing=r}updateTileBinding(r){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const u=this.proxySourceCache,g=this.painter.transform;this._initializing&&(this._initializing=g._centerAltitude===0&&this.getAtPointOrZero(s.MercatorCoordinate.fromLngLat(g.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const x=this.proxyCoords=u.getIds().map(z=>{const F=u.getTileByID(z).tileID;return F.projMatrix=g.calculateProjMatrix(F.toUnwrapped()),F});(function(z,F){const N=F.transform.pointCoordinate(F.transform.getCameraPoint()),H=new s.pointGeometry(N.x,N.y);z.sort((J,re)=>{if(re.overscaledZ-J.overscaledZ)return re.overscaledZ-J.overscaledZ;const Q=new s.pointGeometry(J.canonical.x+(1<{this.proxyToSource[z.key]={}}),this.terrainTileForTile={};const S=this._style._sourceCaches;for(const z in S){const F=S[z];if(!F.used||(F!==this.sourceCache&&this.resetTileLookupCache(F.id),this._setupProxiedCoordsForOrtho(F,r[z],b),F.usedForTerrain))continue;const N=r[z];F.getSource().reparseOverscaled&&this._assignTerrainTiles(N)}this.proxiedCoords[u.id]=x.map(z=>new Ld(z,z.key,this.orthoMatrix)),this._assignTerrainTiles(x),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(b),this.renderingToTexture=!1,this._updateTimestamp=s.exported.now();const P={};this._visibleDemTiles=[];for(const z of this.proxyCoords){const F=this.terrainTileForTile[z.key];if(!F)continue;const N=F.tileID.key;N in P||(this._visibleDemTiles.push(F),P[N]=N)}}_assignTerrainTiles(r){this._initializing||r.forEach(u=>{if(this.terrainTileForTile[u.key])return;const g=this._findTileCoveringTileID(u,this.sourceCache);g&&(this.terrainTileForTile[u.key]=g)})}_prepareDEMTextures(){const r=this.painter.context,u=r.gl;for(const g in this.terrainTileForTile){const x=this.terrainTileForTile[g],b=x.dem;!b||x.demTexture&&!x.needsDEMTextureUpload||(r.activeTexture.set(u.TEXTURE1),Ed(this.painter,x,b))}}_prepareDemTileUniforms(r,u,g,x){if(!u||u.demTexture==null)return!1;const b=r.tileID.canonical,S=Math.pow(2,u.tileID.canonical.z-b.z),P=x||"";return g[`u_dem_tl${P}`]=[b.x*S%1,b.y*S%1],g[`u_dem_scale${P}`]=S,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const r=this.painter.context,u=r.gl;if(!this._emptyDepthBufferTexture){const g=new s.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new s.Texture(r,g,u.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let r=0;const u=this._visibleDemTiles.reduce((g,x)=>{if(!x.dem)return g;const b=x.dem.tree.minimums[0];return b>0&&r++,g+b},0);return r?u/r:0}_updateEmptyDEMTexture(){const r=this.painter.context,u=r.gl;r.activeTexture.set(u.TEXTURE2);const g=this._getLoadedAreaMinimum(),x=new s.RGBAImage({width:1,height:1},new Uint8Array(s.DEMData.pack(g,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let b=this._emptyDEMTexture;return b?b.update(x,{premultiply:!1}):b=this._emptyDEMTexture=new s.Texture(r,x,u.RGBA,{premultiply:!1}),b}setupElevationDraw(r,u,g){const x=this.painter.context,b=x.gl,S=(P=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:s.DEMData.getUnpackVector(P),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 P;S.u_dem_size=this.sourceCache.getSource().tileSize,S.u_exaggeration=this.exaggeration();const z=this.painter.transform,F=z.projection,N=r.tileID.canonical;S.u_tile_tl_up=F.upVector(N,0,0),S.u_tile_tr_up=F.upVector(N,s.EXTENT,0),S.u_tile_br_up=F.upVector(N,s.EXTENT,s.EXTENT),S.u_tile_bl_up=F.upVector(N,0,s.EXTENT),S.u_tile_up_scale=g&&g.useDenormalizedUpVectorScale?By:F.upVectorScale(N,z.center.lat,z.worldSize).metersToTile;let H=null,J=null,re=1;if(g&&g.morphing&&this._useVertexMorphing){const Q=g.morphing.srcDemTile,X=g.morphing.dstDemTile;re=g.morphing.phase,Q&&X&&(this._prepareDemTileUniforms(r,Q,S,"_prev")&&(J=Q),this._prepareDemTileUniforms(r,X,S)&&(H=X))}if(J&&H?(x.activeTexture.set(b.TEXTURE2),H.demTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE,b.NEAREST),x.activeTexture.set(b.TEXTURE4),J.demTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE,b.NEAREST),S.u_dem_lerp=re):(H=this.terrainTileForTile[r.tileID.key],x.activeTexture.set(b.TEXTURE2),(this._prepareDemTileUniforms(r,H,S)?H.demTexture:this.emptyDEMTexture).bind(b.NEAREST,b.CLAMP_TO_EDGE)),x.activeTexture.set(b.TEXTURE3),g&&g.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE),this._depthFBO&&(S.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE),S.u_depth_size_inv=[1,1]),g&&g.useMeterToDem&&H){const Q=(1<{if(fe===ut)return;const et=[Ms[ut],"PROJECTION_GLOBE_VIEW"];Rt&&et.push(Ms[Te]),Ae=F.useProgram("globeRaster",null,et),fe=ut},Re=F.colorModeForRenderPass(),be=new s.DepthMode(X.LEQUAL,s.DepthMode.ReadWrite,F.depthRangeFor3D);ao.update(re);const Fe=F.transform,Qe=s.calculateGlobeMercatorMatrix(Fe),at=[s.mercatorXfromLng(Fe.center.lng),s.mercatorYfromLat(Fe.center.lat)],dt=F.globeSharedBuffers;if((Te?[!1,!0]:[!1]).forEach(ut=>{fe=-1;const Rt=ut?X.LINES:X.TRIANGLES;for(const et of J){const zt=H.getTile(et),Pt=s.StencilMode.disabled,Jt=N.prevTerrainTileForTile[et.key],pt=N.terrainTileForTile[et.key];du(Jt,pt)&&ao.newMorphing(et.key,Jt,pt,re,250),Q.activeTexture.set(X.TEXTURE0),zt.texture.bind(X.LINEAR,X.CLAMP_TO_EDGE);const qt=ao.getMorphValuesForProxy(et.key),mn=qt?1:0,Xt={useDenormalizedUpVectorScale:!0};qt&&s.extend$1(Xt,{morphing:{srcDemTile:qt.from,dstDemTile:qt.to,phase:s.easeCubicInOut(qt.phase)}});const Yt=Float32Array.from(Fe.globeMatrix),vn=s.globeTileLatLngCorners(et.canonical),kn=s.getGridMatrix(et.canonical,vn),hn=Sm(Fe.projMatrix,Yt,Qe,s.globeToMercatorTransition(Fe.zoom),at,kn);if(Se(mn,ut),N.setupElevationDraw(zt,Ae,Xt),F.prepareDrawProgram(Q,Ae,et.toUnwrapped()),dt){const[Mn,qn,vi]=ut?dt.getWirefameBuffers(F.context):dt.getGridBuffers();Ae.draw(Q,Rt,be,Pt,Re,s.CullFaceMode.backCCW,hn,"globe_raster",Mn,qn,vi)}}}),dt){Ae=F.useProgram("globeRaster",null,["GLOBE_POLES","PROJECTION_GLOBE_VIEW"]);for(const ut of J){const{x:Rt,y:et,z:zt}=ut.canonical,Pt=et===0,Jt=et===(1<hn.draw(Q,X.TRIANGLES,be,s.StencilMode.disabled,Re,s.CullFaceMode.disabled,Sm(Fe.projMatrix,vn,vn,0,at),"globe_pole_raster",Mn,mn,Xt);N.setupElevationDraw(Yt,Ae,{}),F.prepareDrawProgram(Q,Ae,ut.toUnwrapped()),Pt&&kn(Ae,pt),Jt&&(vn=s.scale(s.create(),vn,[1,-1,1]),kn(Ae,qt))}}}})(x,b,S,P,z);else{const F=x.context,N=F.gl;let H,J;const re=x.options.showTerrainWireframe?2:0,Q=(Se,Re)=>{if(J===Se)return;const be=[Ms[Se]];Re&&be.push(Ms[re]),H=x.useProgram("terrainRaster",null,be),J=Se},X=x.colorModeForRenderPass(),Ae=new s.DepthMode(N.LEQUAL,s.DepthMode.ReadWrite,x.depthRangeFor3D);ao.update(z);const fe=x.transform,Te=6*Math.pow(1.5,22-fe.zoom)*b.exaggeration();(re?[!1,!0]:[!1]).forEach(Se=>{J=-1;const Re=Se?N.LINES:N.TRIANGLES,[be,Fe]=Se?b.getWirefameBuffer():[b.gridIndexBuffer,b.gridSegments];for(const Qe of P){const at=S.getTile(Qe),dt=s.StencilMode.disabled,ut=b.prevTerrainTileForTile[Qe.key],Rt=b.terrainTileForTile[Qe.key];du(ut,Rt)&&ao.newMorphing(Qe.key,ut,Rt,z,250),F.activeTexture.set(N.TEXTURE0),at.texture.bind(N.LINEAR,N.CLAMP_TO_EDGE,N.LINEAR_MIPMAP_NEAREST);const et=ao.getMorphValuesForProxy(Qe.key),zt=et?1:0;let Pt;et&&(Pt={morphing:{srcDemTile:et.from,dstDemTile:et.to,phase:s.easeCubicInOut(et.phase)}});const Jt=Em(Qe.projMatrix,Cd(Qe.canonical,fe.renderWorldCopies)?Te/10:Te);Q(zt,Se),b.setupElevationDraw(at,H,Pt),x.prepareDrawProgram(F,H,Qe.toUnwrapped()),H.draw(F,Re,Ae,dt,X,s.CullFaceMode.backCCW,Jt,"terrain_raster",b.gridBuffer,be,Fe)}})}}(u,this,this.proxySourceCache,r,this._updateTimestamp),this.renderingToTexture=!0,r.splice(0,r.length))}renderBatch(r){if(this._drapedRenderBatches.length===0)return r+1;this.renderingToTexture=!0;const u=this.painter,g=this.painter.context,x=this.proxySourceCache,b=this.proxiedCoords[x.id],S=this._drapedRenderBatches.shift(),P=[],z=u.style.order;let F=0;for(const N of b){const H=x.getTileByID(N.proxyTileKey),J=x.proxyCachedFBO[N.key]?x.proxyCachedFBO[N.key][r]:void 0,re=J!==void 0?x.renderCache[J]:this.pool[F++],Q=J!==void 0;if(H.texture=re.tex,Q&&!re.dirty){P.push(H.tileID);continue}let X;g.bindFramebuffer.set(re.fb.framebuffer),this.renderedToTile=!1,re.dirty&&(g.clear({color:s.Color.transparent,stencil:0}),re.dirty=!1);for(let Ae=S.start;Ae<=S.end;++Ae){const fe=u.style._layers[z[Ae]];if(fe.isHidden(u.transform.zoom))continue;const Te=u.style._getLayerSourceCache(fe),Se=Te?this.proxyToSource[N.key][Te.id]:[N];if(!Se)continue;const Re=Se;g.viewport.set([0,0,re.fb.width,re.fb.height]),X!==(Te?Te.id:null)&&(this._setupStencil(re,Se,fe,Te),X=Te?Te.id:null),u.renderLayer(u,Te,fe,Re)}this.renderedToTile?(re.dirty=!0,P.push(H.tileID)):Q||--F,F===5&&(F=0,this.renderToBackBuffer(P))}return this.renderToBackBuffer(P),this.renderingToTexture=!1,g.bindFramebuffer.set(null),g.viewport.set([0,0,u.width,u.height]),S.end+1}postRender(){}renderCacheEfficiency(r){const u=r.order.length;if(u===0)return{efficiency:100};let g,x=0,b=0,S=!1;for(let P=0;Pu.dem).forEach(u=>{r=Math.min(r,u.dem.tree.minimums[0])}),r===0?r:(r-30)*this._exaggeration}raycast(r,u,g){if(!this._visibleDemTiles)return null;const x=this._visibleDemTiles.filter(b=>b.dem).map(b=>{const S=b.tileID,P=Math.pow(2,S.overscaledZ),{x:z,y:F}=S.canonical,N=z/P,H=(z+1)/P,J=F/P,re=(F+1)/P;return{minx:N,miny:J,maxx:H,maxy:re,t:b.dem.tree.raycastRoot(N,J,H,re,r,u,g),tile:b}});x.sort((b,S)=>(b.t!==null?b.t:Number.MAX_VALUE)-(S.t!==null?S.t:Number.MAX_VALUE));for(const b of x){if(b.t==null)return null;const S=b.tile.dem.tree.raycast(b.minx,b.miny,b.maxx,b.maxy,r,u,g);if(S!=null)return S}return null}_createFBO(){const r=this.painter.context,u=r.gl,g=this.drapeBufferSize;r.activeTexture.set(u.TEXTURE0);const x=new s.Texture(r,{width:g[0],height:g[1],data:null},u.RGBA);x.bind(u.LINEAR,u.CLAMP_TO_EDGE);const b=r.createFramebuffer(g[0],g[1],!1);return b.colorAttachment.set(x.texture),b.depthAttachment=new Sr(r,b.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=r.createRenderbuffer(r.gl.DEPTH_STENCIL,g[0],g[1]),this._stencilRef=0,b.depthAttachment.set(this._sharedDepthStencil),r.clear({stencil:0})):b.depthAttachment.set(this._sharedDepthStencil),r.extTextureFilterAnisotropic&&!r.extTextureFilterAnisotropicForceOff&&u.texParameterf(u.TEXTURE_2D,r.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,r.extTextureFilterAnisotropicMax),{fb:b,tex:x,dirty:!1}}_initFBOPool(){for(;this.pool.length{const u=this._style._layers[r],g=u.isHidden(this.painter.transform.zoom),x=u.getCrossfadeParameters(),b=!!x&&x.t!==1,S=u.hasTransition();return u.type!=="custom"&&!g&&(b||S)})}_clearRasterFadeFromRenderCache(){let r=!1;for(const u in this._style._sourceCaches)if(this._style._sourceCaches[u]._source instanceof Z){r=!0;break}if(r)for(let u=0;uu.renderCachePool.length){const S=Object.values(u.proxyCachedFBO);u.proxyCachedFBO={};for(let P=0;P=0;S--){const P=g[S];if(u.getTileByID(P.key),u.proxyCachedFBO[P.key]!==void 0){const z=r[P.key],F=this.proxyToSource[P.key];let N=0;for(const H in F){const J=F[H],re=z[H];if(!re||re.length!==J.length||J.some((Q,X)=>Q!==re[X]||x[H]&&x[H].hasOwnProperty(Q.key))){N=-1;break}++N}for(const H in u.proxyCachedFBO[P.key])u.renderCache[u.proxyCachedFBO[P.key][H]].dirty=N<0||N!==Object.values(z).length}}const b=[...this._drapedRenderBatches];b.sort((S,P)=>P.end-P.start-(S.end-S.start));for(const S of b)for(const P of g){if(u.proxyCachedFBO[P.key])continue;let z=u.renderCachePool.pop();z===void 0&&u.renderCache.length<50&&(z=u.renderCache.length,u.renderCache.push(this._createFBO())),z!==void 0&&(u.proxyCachedFBO[P.key]={},u.proxyCachedFBO[P.key][S.start]=z,u.renderCache[z].dirty=!0)}this._tilesDirty={}}_setupStencil(r,u,g,x){if(!x||!this._sourceTilesOverlap[x.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const b=this.painter.context,S=b.gl;if(u.length<=1)return void(this._overlapStencilType=!1);let P;if(g.isTileClipped())P=u.length,this._overlapStencilMode.test={func:S.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(u[0].overscaledZ>u[u.length-1].overscaledZ))return void(this._overlapStencilType=!1);P=1,this._overlapStencilMode.test={func:S.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+P>255&&(b.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=P,this._overlapStencilMode.ref=this._stencilRef,g.isTileClipped()&&this._renderTileClippingMasks(u,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(r){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs.get(r.key)||0),this._overlapStencilMode):s.StencilMode.disabled}_renderTileClippingMasks(r,u){const g=this.painter,x=this.painter.context,b=x.gl;g._tileClippingMaskIDs.clear(),x.setColorMode(s.ColorMode.disabled),x.setDepthMode(s.DepthMode.disabled);const S=g.useProgram("clippingMask");for(const P of r){const z=--u;g._tileClippingMaskIDs.set(P.key,z),S.draw(x,b.TRIANGLES,s.DepthMode.disabled,new s.StencilMode({func:b.ALWAYS,mask:0},z,255,b.KEEP,b.KEEP,b.REPLACE),s.ColorMode.disabled,s.CullFaceMode.disabled,pu(P.projMatrix),"$clipping",g.tileExtentBuffer,g.quadTriangleIndexBuffer,g.tileExtentSegments)}}pointCoordinate(r){const u=this.painter.transform;if(r.x<0||r.x>u.width||r.y<0||r.y>u.height)return null;const g=[r.x,r.y,1,1];s.transformMat4$1(g,g,u.pixelMatrixInverse),s.scale$1(g,g,1/g[3]),g[0]/=u.worldSize,g[1]/=u.worldSize;const x=u._camera.position,b=s.mercatorZfromAltitude(1,u.center.lat),S=[x[0],x[1],x[2]/b,0],P=s.subtract([],g.slice(0,3),S);s.normalize(P,P);const z=this.raycast(S,P,this._exaggeration);return z!==null&&z?(s.scaleAndAdd(S,S,P,z),S[3]=S[2],S[2]*=b,S):null}drawDepth(){const r=this.painter,u=r.context,g=this.proxySourceCache,x=Math.ceil(r.width),b=Math.ceil(r.height);if(!this._depthFBO||this._depthFBO.width===x&&this._depthFBO.height===b||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const S=u.gl,P=u.createFramebuffer(x,b,!0);u.activeTexture.set(S.TEXTURE0);const z=new s.Texture(u,{width:x,height:b,data:null},S.RGBA);z.bind(S.NEAREST,S.CLAMP_TO_EDGE),P.colorAttachment.set(z.texture);const F=u.createRenderbuffer(u.gl.DEPTH_COMPONENT16,x,b);P.depthAttachment.set(F),this._depthFBO=P,this._depthTexture=z}u.bindFramebuffer.set(this._depthFBO.framebuffer),u.viewport.set([0,0,x,b]),function(S,P,z,F){if(S.transform.projection.name==="globe")return;const N=S.context,H=N.gl;N.clear({depth:1});const J=S.useProgram("terrainDepth"),re=new s.DepthMode(H.LESS,s.DepthMode.ReadWrite,S.depthRangeFor3D);for(const Q of F){const X=z.getTile(Q),Ae=Em(Q.projMatrix,0);P.setupElevationDraw(X,J),J.draw(N,H.TRIANGLES,re,s.StencilMode.disabled,s.ColorMode.unblended,s.CullFaceMode.backCCW,Ae,"terrain_depth",P.gridBuffer,P.gridIndexBuffer,P.gridNoSkirtSegments)}}(r,this,g,this.proxyCoords)}_setupProxiedCoordsForOrtho(r,u,g){if(r.getSource()instanceof Ge)return this._setupProxiedCoordsForImageSource(r,u,g);this._findCoveringTileCache[r.id]=this._findCoveringTileCache[r.id]||{};const x=this.proxiedCoords[r.id]=[],b=this.proxyCoords;for(let P=0;P(N.min.x=Math.min(N.min.x,H.x-P.x),N.min.y=Math.min(N.min.y,H.y-P.y),N.max.x=Math.max(N.max.x,H.x-P.x),N.max.y=Math.max(N.max.y,H.y-P.y),N),{min:new s.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new s.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),F=(N,H)=>{const J=N.wrap+N.canonical.x/(1<X+z.max.x||re+QAe+z.max.y};for(let N=0;NS.key===u.tileID.key);if(b)return b}if(u.tileID.key!==r.key){const b=r.canonical.z-u.tileID.canonical.z;let S,P,z;x=s.create();const F=u.tileID.wrap-r.wrap<0?(S=s.EXTENT>>b,P=S*((u.tileID.canonical.x<=H){const J=r.canonical.z-H;u.getSource().reparseOverscaled?(P=Math.max(r.canonical.z+2,u.transform.tileZoom),S=new s.OverscaledTileID(P,r.wrap,H,r.canonical.x>>J,r.canonical.y>>J)):J!==0&&(P=H,S=new s.OverscaledTileID(P,r.wrap,H,r.canonical.x>>J,r.canonical.y>>J))}S.key!==r.key&&(F.push(S.key),g=u.getTile(S))}const N=H=>{F.forEach(J=>{x[J]=H}),F.length=0};for(P-=1;P>=z&&(!g||!g.hasData());P--){g&&N(g.tileID.key);const H=S.calculateScaledKey(P);if(g=u.getTileByID(H),g&&g.hasData())break;const J=x[H];if(J===null)break;J===void 0?F.push(H):g=u.getTileByID(J)}return N(g?g.tileID.key:null),g&&g.hasData()?g:null}findDEMTileFor(r){return this.enabled?this._findTileCoveringTileID(r,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(r,u){let g=this._tilesDirty[r];g||(g=this._tilesDirty[r]={}),g[u.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const r=function(u){let g=0;const x=new s.StructArrayLayout2ui4,b=131;for(let S=1;S<129;S++){for(let P=1;P<129;P++)g=S*b+P,x.emplaceBack(g,g+1),x.emplaceBack(g,g+b),x.emplaceBack(g+1,g+b),S===128&&x.emplaceBack(g+b,g+b+1);x.emplaceBack(g+1,g+1+b)}return x}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(r),this.wireframeSegments=s.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function fu(f){const r=[];for(let u=0;u`#define ${be}`));const Ae=X.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`,xl,uu.fragmentSource,ro.fragmentSource,g.fragmentSource).join(` `),fe=X.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`,xl,uu.vertexSource,ro.vertexSource,Uo.vertexSource,g.vertexSource).join(` `),Te=P.createShader(P.FRAGMENT_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);P.shaderSource(Te,Ae),P.compileShader(Te),P.attachShader(this.program,Te);const Se=P.createShader(P.VERTEX_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);P.shaderSource(Se,fe),P.compileShader(Se),P.attachShader(this.program,Se),this.attributes={};const Re={};this.numAttributes=N.length;for(let be=0;be({u_dem:new s.Uniform1i(be,Fe.u_dem),u_dem_prev:new s.Uniform1i(be,Fe.u_dem_prev),u_dem_unpack:new s.Uniform4f(be,Fe.u_dem_unpack),u_dem_tl:new s.Uniform2f(be,Fe.u_dem_tl),u_dem_scale:new s.Uniform1f(be,Fe.u_dem_scale),u_dem_tl_prev:new s.Uniform2f(be,Fe.u_dem_tl_prev),u_dem_scale_prev:new s.Uniform1f(be,Fe.u_dem_scale_prev),u_dem_size:new s.Uniform1f(be,Fe.u_dem_size),u_dem_lerp:new s.Uniform1f(be,Fe.u_dem_lerp),u_exaggeration:new s.Uniform1f(be,Fe.u_exaggeration),u_depth:new s.Uniform1i(be,Fe.u_depth),u_depth_size_inv:new s.Uniform2f(be,Fe.u_depth_size_inv),u_meter_to_dem:new s.Uniform1f(be,Fe.u_meter_to_dem),u_label_plane_matrix_inv:new s.UniformMatrix4f(be,Fe.u_label_plane_matrix_inv),u_tile_tl_up:new s.Uniform3f(be,Fe.u_tile_tl_up),u_tile_tr_up:new s.Uniform3f(be,Fe.u_tile_tr_up),u_tile_br_up:new s.Uniform3f(be,Fe.u_tile_br_up),u_tile_bl_up:new s.Uniform3f(be,Fe.u_tile_bl_up),u_tile_up_scale:new s.Uniform1f(be,Fe.u_tile_up_scale)}))(r,Re)),S.indexOf("FOG")!==-1&&(this.fogUniforms=((be,Fe)=>({u_fog_matrix:new s.UniformMatrix4f(be,Fe.u_fog_matrix),u_fog_range:new s.Uniform2f(be,Fe.u_fog_range),u_fog_color:new s.Uniform4f(be,Fe.u_fog_color),u_fog_horizon_blend:new s.Uniform1f(be,Fe.u_fog_horizon_blend),u_fog_temporal_offset:new s.Uniform1f(be,Fe.u_fog_temporal_offset)}))(r,Re))}setTerrainUniformValues(r,u){if(!this.terrainUniforms)return;const g=this.terrainUniforms;if(!this.failedToCreate){r.program.set(this.program);for(const x in u)g[x].set(u[x])}}setFogUniformValues(r,u){if(!this.fogUniforms)return;const g=this.fogUniforms;if(!this.failedToCreate){r.program.set(this.program);for(const x in u)g[x].location&&g[x].set(u[x])}}draw(r,u,g,x,b,S,P,z,F,N,H,J,re,Q,X,Ae){const fe=r.gl;if(this.failedToCreate)return;r.program.set(this.program),r.setDepthMode(g),r.setStencilMode(x),r.setColorMode(b),r.setCullFace(S);for(const Se of Object.keys(this.fixedUniforms))this.fixedUniforms[Se].set(P[Se]);Q&&Q.setUniforms(r,this.binderUniforms,J,{zoom:re});const Te={[fe.LINES]:2,[fe.TRIANGLES]:3,[fe.LINE_STRIP]:1}[u];for(const Se of H.get()){const Re=Se.vaos||(Se.vaos={});(Re[z]||(Re[z]=new hu)).bind(r,this,F,Q?Q.getPaintVertexBuffers():[],N,Se.vertexOffset,X,Ae),fe.drawElements(u,Se.primitiveLength*Te,fe.UNSIGNED_SHORT,Se.primitiveOffset*Te*2)}}}function El(f,r,u){const g=1/Ve(u,1,r.transform.tileZoom),x=Math.pow(2,u.tileID.overscaledZ),b=u.tileSize*Math.pow(2,r.transform.tileZoom)/x,S=b*(u.tileID.canonical.x+u.tileID.wrap*x),P=b*u.tileID.canonical.y;return{u_image:0,u_texsize:u.imageAtlasTexture.size,u_scale:[g,f.fromScale,f.toScale],u_fade:f.t,u_pixel_coord_upper:[S>>16,P>>16],u_pixel_coord_lower:[65535&S,65535&P]}}const Dd=s.create(),mu=(f,r,u,g,x,b,S,P,z)=>{const F=r.style.light,N=F.properties.get("position"),H=[N.x,N.y,N.z],J=s.create$1();F.properties.get("anchor")==="viewport"&&(s.fromRotation(J,-r.transform.angle),s.transformMat3(H,H,J));const re=F.properties.get("color"),Q=r.transform,X={u_matrix:f,u_lightpos:H,u_lightintensity:F.properties.get("intensity"),u_lightcolor:[re.r,re.g,re.b],u_vertical_gradient:+u,u_opacity:g,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Dd,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0};return Q.projection.name==="globe"&&(X.u_tile_id=[x.canonical.x,x.canonical.y,1<{const H=mu(f,r,u,g,x,P,z,F,N),J={u_height_factor:-Math.pow(2,x.overscaledZ)/S.tileSize/8};return s.extend(H,El(b,r,S),J)},_u=f=>({u_matrix:f}),yu=(f,r,u,g)=>s.extend(_u(f),El(u,r,g)),vu=(f,r)=>({u_matrix:f,u_world:r}),Am=(f,r,u,g,x)=>s.extend(yu(f,r,u,g),{u_world:x}),Cm=s.create(),Ts=(f,r,u,g,x,b)=>{const S=f.transform,P=S.projection.name==="globe";let z;if(b.paint.get("circle-pitch-alignment")==="map")if(P){const N=s.globePixelsToTileUnits(S.zoom,r.canonical);z=Float32Array.from([N,0,0,N])}else z=S.calculatePixelsToTileUnitsMatrix(u);else z=new Float32Array([S.pixelsToGLUnits[0],0,0,S.pixelsToGLUnits[1]]);const F={u_camera_to_center_distance:S.cameraToCenterDistance,u_matrix:f.translatePosMatrix(r.projMatrix,u,b.paint.get("circle-translate"),b.paint.get("circle-translate-anchor")),u_device_pixel_ratio:s.exported.devicePixelRatio,u_extrude_scale:z,u_inv_rot_matrix:Cm,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};return P&&(F.u_inv_rot_matrix=g,F.u_merc_center=x,F.u_tile_id=[r.canonical.x,r.canonical.y,1<{const r=[];return f.paint.get("circle-pitch-alignment")==="map"&&r.push("PITCH_WITH_MAP"),f.paint.get("circle-pitch-scale")==="map"&&r.push("SCALE_WITH_MAP"),r},Oy=(f,r,u)=>{const g=s.EXTENT/u.tileSize;return{u_matrix:f,u_camera_to_center_distance:r.cameraToCenterDistance,u_extrude_scale:[r.pixelsToGLUnits[0]/g,r.pixelsToGLUnits[1]/g]}},Pm=(f,r,u=1)=>({u_matrix:f,u_color:r,u_overlay:0,u_overlay_scale:u}),Ny=s.create(),Uy=(f,r,u,g,x,b,S)=>{const P=f.transform,z=P.projection.name==="globe",F=z?s.globePixelsToTileUnits(P.zoom,r.canonical):Ve(u,1,b),N={u_matrix:r.projMatrix,u_extrude_scale:F,u_intensity:S,u_inv_rot_matrix:Ny,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};return z&&(N.u_inv_rot_matrix=g,N.u_merc_center=x,N.u_tile_id=[r.canonical.x,r.canonical.y,1<{const P=f.transform,z=P.calculatePixelsToTileUnitsMatrix(r),F={u_matrix:Vo(f,r,u,x),u_pixels_to_tile_units:z,u_device_pixel_ratio:S,u_units_to_pixels:[1/P.pixelsToGLUnits[0],1/P.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:b,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0};if(Rd(u)){const N=xu(r,f.transform);F.u_texsize=r.lineAtlasTexture.size,F.u_scale=[N,g.fromScale,g.toScale],F.u_mix=g.t}return F},Id=(f,r,u,g,x,b)=>{const S=f.transform,P=xu(r,S);return{u_matrix:Vo(f,r,u,x),u_texsize:r.imageAtlasTexture.size,u_pixels_to_tile_units:S.calculatePixelsToTileUnitsMatrix(r),u_device_pixel_ratio:b,u_image:0,u_scale:[P,g.fromScale,g.toScale],u_fade:g.t,u_units_to_pixels:[1/S.pixelsToGLUnits[0],1/S.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function xu(f,r){return 1/Ve(f,1,r.tileZoom)}function Vo(f,r,u,g){return f.translatePosMatrix(g||r.tileID.projMatrix,r,u.paint.get("line-translate"),u.paint.get("line-translate-anchor"))}function Rd(f){const r=f.paint.get("line-dasharray").value;return r.value||r.kind!=="constant"}const Lm=(f,r,u,g,x,b)=>{return{u_matrix:f,u_tl_parent:r,u_scale_parent:u,u_fade_t:g.mix,u_opacity:g.opacity*x.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:x.paint.get("raster-brightness-min"),u_brightness_high:x.paint.get("raster-brightness-max"),u_saturation_factor:(P=x.paint.get("raster-saturation"),P>0?1-1/(1.001-P):-P),u_contrast_factor:(S=x.paint.get("raster-contrast"),S>0?1/(1-S):1+S),u_spin_weights:zd(x.paint.get("raster-hue-rotate")),u_perspective_transform:b};var S,P};function zd(f){f*=Math.PI/180;const r=Math.sin(f),u=Math.cos(f);return[(2*u+1)/3,(-Math.sqrt(3)*r-u+1)/3,(Math.sqrt(3)*r-u+1)/3]}const oo=s.create(),kd=(f,r,u,g,x,b,S,P,z,F,N,H,J,re)=>{const Q=x.transform,X={u_is_size_zoom_constant:+(f==="constant"||f==="source"),u_is_size_feature_constant:+(f==="constant"||f==="camera"),u_size_t:r?r.uSizeT:0,u_size:r?r.uSize:0,u_camera_to_center_distance:Q.cameraToCenterDistance,u_rotate_symbol:+u,u_aspect_ratio:Q.width/Q.height,u_fade_change:x.options.fadeDuration?x.symbolFadeChange:1,u_matrix:b,u_label_plane_matrix:S,u_coord_matrix:P,u_is_text:+z,u_pitch_with_map:+g,u_texsize:F,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:oo,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:oo};return Q.projection.name==="globe"&&(X.u_tile_id=[N.canonical.x,N.canonical.y,1<{const{cameraToCenterDistance:X,_pitch:Ae}=x.transform;return s.extend(kd(f,r,u,g,x,b,S,P,z,F,H,J,re,Q),{u_gamma_scale:g?X*Math.cos(x.terrain?0:Ae):1,u_device_pixel_ratio:s.exported.devicePixelRatio,u_is_halo:+N})},Es=(f,r,u,g,x,b,S,P,z,F,N,H,J,re)=>s.extend(Go(f,r,u,g,x,b,S,P,!0,z,!0,N,H,J,re),{u_texsize_icon:F,u_texture_icon:1}),Dm=(f,r,u)=>({u_matrix:f,u_opacity:r,u_color:u}),Bd=(f,r,u,g,x,b)=>s.extend(function(S,P,z,F){const N=z.imageManager.getPattern(S.from.toString()),H=z.imageManager.getPattern(S.to.toString()),{width:J,height:re}=z.imageManager.getPixelSize(),Q=Math.pow(2,F.tileID.overscaledZ),X=F.tileSize*Math.pow(2,z.transform.tileZoom)/Q,Ae=X*(F.tileID.canonical.x+F.tileID.wrap*Q),fe=X*F.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:N.tl,u_pattern_br_a:N.br,u_pattern_tl_b:H.tl,u_pattern_br_b:H.br,u_texsize:[J,re],u_mix:P.t,u_pattern_size_a:N.displaySize,u_pattern_size_b:H.displaySize,u_scale_a:P.fromScale,u_scale_b:P.toScale,u_tile_units_to_pixels:1/Ve(F,1,z.transform.tileZoom),u_pixel_coord_upper:[Ae>>16,fe>>16],u_pixel_coord_lower:[65535&Ae,65535&fe]}}(g,b,u,x),{u_matrix:f,u_opacity:r}),Qn={fillExtrusion:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_lightpos:new s.Uniform3f(f,r.u_lightpos),u_lightintensity:new s.Uniform1f(f,r.u_lightintensity),u_lightcolor:new s.Uniform3f(f,r.u_lightcolor),u_vertical_gradient:new s.Uniform1f(f,r.u_vertical_gradient),u_opacity:new s.Uniform1f(f,r.u_opacity),u_tile_id:new s.Uniform3f(f,r.u_tile_id),u_zoom_transition:new s.Uniform1f(f,r.u_zoom_transition),u_inv_rot_matrix:new s.UniformMatrix4f(f,r.u_inv_rot_matrix),u_merc_center:new s.Uniform2f(f,r.u_merc_center),u_up_dir:new s.Uniform3f(f,r.u_up_dir),u_height_lift:new s.Uniform1f(f,r.u_height_lift)}),fillExtrusionPattern:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_lightpos:new s.Uniform3f(f,r.u_lightpos),u_lightintensity:new s.Uniform1f(f,r.u_lightintensity),u_lightcolor:new s.Uniform3f(f,r.u_lightcolor),u_vertical_gradient:new s.Uniform1f(f,r.u_vertical_gradient),u_height_factor:new s.Uniform1f(f,r.u_height_factor),u_tile_id:new s.Uniform3f(f,r.u_tile_id),u_zoom_transition:new s.Uniform1f(f,r.u_zoom_transition),u_inv_rot_matrix:new s.UniformMatrix4f(f,r.u_inv_rot_matrix),u_merc_center:new s.Uniform2f(f,r.u_merc_center),u_up_dir:new s.Uniform3f(f,r.u_up_dir),u_height_lift:new s.Uniform1f(f,r.u_height_lift),u_image:new s.Uniform1i(f,r.u_image),u_texsize:new s.Uniform2f(f,r.u_texsize),u_pixel_coord_upper:new s.Uniform2f(f,r.u_pixel_coord_upper),u_pixel_coord_lower:new s.Uniform2f(f,r.u_pixel_coord_lower),u_scale:new s.Uniform3f(f,r.u_scale),u_fade:new s.Uniform1f(f,r.u_fade),u_opacity:new s.Uniform1f(f,r.u_opacity)}),fill:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix)}),fillPattern:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_image:new s.Uniform1i(f,r.u_image),u_texsize:new s.Uniform2f(f,r.u_texsize),u_pixel_coord_upper:new s.Uniform2f(f,r.u_pixel_coord_upper),u_pixel_coord_lower:new s.Uniform2f(f,r.u_pixel_coord_lower),u_scale:new s.Uniform3f(f,r.u_scale),u_fade:new s.Uniform1f(f,r.u_fade)}),fillOutline:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_world:new s.Uniform2f(f,r.u_world)}),fillOutlinePattern:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_world:new s.Uniform2f(f,r.u_world),u_image:new s.Uniform1i(f,r.u_image),u_texsize:new s.Uniform2f(f,r.u_texsize),u_pixel_coord_upper:new s.Uniform2f(f,r.u_pixel_coord_upper),u_pixel_coord_lower:new s.Uniform2f(f,r.u_pixel_coord_lower),u_scale:new s.Uniform3f(f,r.u_scale),u_fade:new s.Uniform1f(f,r.u_fade)}),circle:(f,r)=>({u_camera_to_center_distance:new s.Uniform1f(f,r.u_camera_to_center_distance),u_extrude_scale:new s.UniformMatrix2f(f,r.u_extrude_scale),u_device_pixel_ratio:new s.Uniform1f(f,r.u_device_pixel_ratio),u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_inv_rot_matrix:new s.UniformMatrix4f(f,r.u_inv_rot_matrix),u_merc_center:new s.Uniform2f(f,r.u_merc_center),u_tile_id:new s.Uniform3f(f,r.u_tile_id),u_zoom_transition:new s.Uniform1f(f,r.u_zoom_transition),u_up_dir:new s.Uniform3f(f,r.u_up_dir)}),collisionBox:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_camera_to_center_distance:new s.Uniform1f(f,r.u_camera_to_center_distance),u_extrude_scale:new s.Uniform2f(f,r.u_extrude_scale)}),collisionCircle:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_inv_matrix:new s.UniformMatrix4f(f,r.u_inv_matrix),u_camera_to_center_distance:new s.Uniform1f(f,r.u_camera_to_center_distance),u_viewport_size:new s.Uniform2f(f,r.u_viewport_size)}),debug:(f,r)=>({u_color:new s.UniformColor(f,r.u_color),u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_overlay:new s.Uniform1i(f,r.u_overlay),u_overlay_scale:new s.Uniform1f(f,r.u_overlay_scale)}),clippingMask:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix)}),heatmap:(f,r)=>({u_extrude_scale:new s.Uniform1f(f,r.u_extrude_scale),u_intensity:new s.Uniform1f(f,r.u_intensity),u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_inv_rot_matrix:new s.UniformMatrix4f(f,r.u_inv_rot_matrix),u_merc_center:new s.Uniform2f(f,r.u_merc_center),u_tile_id:new s.Uniform3f(f,r.u_tile_id),u_zoom_transition:new s.Uniform1f(f,r.u_zoom_transition),u_up_dir:new s.Uniform3f(f,r.u_up_dir)}),heatmapTexture:(f,r)=>({u_image:new s.Uniform1i(f,r.u_image),u_color_ramp:new s.Uniform1i(f,r.u_color_ramp),u_opacity:new s.Uniform1f(f,r.u_opacity)}),hillshade:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_image:new s.Uniform1i(f,r.u_image),u_latrange:new s.Uniform2f(f,r.u_latrange),u_light:new s.Uniform2f(f,r.u_light),u_shadow:new s.UniformColor(f,r.u_shadow),u_highlight:new s.UniformColor(f,r.u_highlight),u_accent:new s.UniformColor(f,r.u_accent)}),hillshadePrepare:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_image:new s.Uniform1i(f,r.u_image),u_dimension:new s.Uniform2f(f,r.u_dimension),u_zoom:new s.Uniform1f(f,r.u_zoom),u_unpack:new s.Uniform4f(f,r.u_unpack)}),line:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_pixels_to_tile_units:new s.UniformMatrix2f(f,r.u_pixels_to_tile_units),u_device_pixel_ratio:new s.Uniform1f(f,r.u_device_pixel_ratio),u_units_to_pixels:new s.Uniform2f(f,r.u_units_to_pixels),u_dash_image:new s.Uniform1i(f,r.u_dash_image),u_gradient_image:new s.Uniform1i(f,r.u_gradient_image),u_image_height:new s.Uniform1f(f,r.u_image_height),u_texsize:new s.Uniform2f(f,r.u_texsize),u_scale:new s.Uniform3f(f,r.u_scale),u_mix:new s.Uniform1f(f,r.u_mix),u_alpha_discard_threshold:new s.Uniform1f(f,r.u_alpha_discard_threshold)}),linePattern:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_texsize:new s.Uniform2f(f,r.u_texsize),u_pixels_to_tile_units:new s.UniformMatrix2f(f,r.u_pixels_to_tile_units),u_device_pixel_ratio:new s.Uniform1f(f,r.u_device_pixel_ratio),u_image:new s.Uniform1i(f,r.u_image),u_units_to_pixels:new s.Uniform2f(f,r.u_units_to_pixels),u_scale:new s.Uniform3f(f,r.u_scale),u_fade:new s.Uniform1f(f,r.u_fade),u_alpha_discard_threshold:new s.Uniform1f(f,r.u_alpha_discard_threshold)}),raster:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_tl_parent:new s.Uniform2f(f,r.u_tl_parent),u_scale_parent:new s.Uniform1f(f,r.u_scale_parent),u_fade_t:new s.Uniform1f(f,r.u_fade_t),u_opacity:new s.Uniform1f(f,r.u_opacity),u_image0:new s.Uniform1i(f,r.u_image0),u_image1:new s.Uniform1i(f,r.u_image1),u_brightness_low:new s.Uniform1f(f,r.u_brightness_low),u_brightness_high:new s.Uniform1f(f,r.u_brightness_high),u_saturation_factor:new s.Uniform1f(f,r.u_saturation_factor),u_contrast_factor:new s.Uniform1f(f,r.u_contrast_factor),u_spin_weights:new s.Uniform3f(f,r.u_spin_weights),u_perspective_transform:new s.Uniform2f(f,r.u_perspective_transform)}),symbolIcon:(f,r)=>({u_is_size_zoom_constant:new s.Uniform1i(f,r.u_is_size_zoom_constant),u_is_size_feature_constant:new s.Uniform1i(f,r.u_is_size_feature_constant),u_size_t:new s.Uniform1f(f,r.u_size_t),u_size:new s.Uniform1f(f,r.u_size),u_camera_to_center_distance:new s.Uniform1f(f,r.u_camera_to_center_distance),u_rotate_symbol:new s.Uniform1i(f,r.u_rotate_symbol),u_aspect_ratio:new s.Uniform1f(f,r.u_aspect_ratio),u_fade_change:new s.Uniform1f(f,r.u_fade_change),u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_label_plane_matrix:new s.UniformMatrix4f(f,r.u_label_plane_matrix),u_coord_matrix:new s.UniformMatrix4f(f,r.u_coord_matrix),u_is_text:new s.Uniform1i(f,r.u_is_text),u_pitch_with_map:new s.Uniform1i(f,r.u_pitch_with_map),u_texsize:new s.Uniform2f(f,r.u_texsize),u_tile_id:new s.Uniform3f(f,r.u_tile_id),u_zoom_transition:new s.Uniform1f(f,r.u_zoom_transition),u_inv_rot_matrix:new s.UniformMatrix4f(f,r.u_inv_rot_matrix),u_merc_center:new s.Uniform2f(f,r.u_merc_center),u_camera_forward:new s.Uniform3f(f,r.u_camera_forward),u_tile_matrix:new s.UniformMatrix4f(f,r.u_tile_matrix),u_ecef_origin:new s.Uniform3f(f,r.u_ecef_origin),u_texture:new s.Uniform1i(f,r.u_texture)}),symbolSDF:(f,r)=>({u_is_size_zoom_constant:new s.Uniform1i(f,r.u_is_size_zoom_constant),u_is_size_feature_constant:new s.Uniform1i(f,r.u_is_size_feature_constant),u_size_t:new s.Uniform1f(f,r.u_size_t),u_size:new s.Uniform1f(f,r.u_size),u_camera_to_center_distance:new s.Uniform1f(f,r.u_camera_to_center_distance),u_rotate_symbol:new s.Uniform1i(f,r.u_rotate_symbol),u_aspect_ratio:new s.Uniform1f(f,r.u_aspect_ratio),u_fade_change:new s.Uniform1f(f,r.u_fade_change),u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_label_plane_matrix:new s.UniformMatrix4f(f,r.u_label_plane_matrix),u_coord_matrix:new s.UniformMatrix4f(f,r.u_coord_matrix),u_is_text:new s.Uniform1i(f,r.u_is_text),u_pitch_with_map:new s.Uniform1i(f,r.u_pitch_with_map),u_texsize:new s.Uniform2f(f,r.u_texsize),u_texture:new s.Uniform1i(f,r.u_texture),u_gamma_scale:new s.Uniform1f(f,r.u_gamma_scale),u_device_pixel_ratio:new s.Uniform1f(f,r.u_device_pixel_ratio),u_tile_id:new s.Uniform3f(f,r.u_tile_id),u_zoom_transition:new s.Uniform1f(f,r.u_zoom_transition),u_inv_rot_matrix:new s.UniformMatrix4f(f,r.u_inv_rot_matrix),u_merc_center:new s.Uniform2f(f,r.u_merc_center),u_camera_forward:new s.Uniform3f(f,r.u_camera_forward),u_tile_matrix:new s.UniformMatrix4f(f,r.u_tile_matrix),u_ecef_origin:new s.Uniform3f(f,r.u_ecef_origin),u_is_halo:new s.Uniform1i(f,r.u_is_halo)}),symbolTextAndIcon:(f,r)=>({u_is_size_zoom_constant:new s.Uniform1i(f,r.u_is_size_zoom_constant),u_is_size_feature_constant:new s.Uniform1i(f,r.u_is_size_feature_constant),u_size_t:new s.Uniform1f(f,r.u_size_t),u_size:new s.Uniform1f(f,r.u_size),u_camera_to_center_distance:new s.Uniform1f(f,r.u_camera_to_center_distance),u_rotate_symbol:new s.Uniform1i(f,r.u_rotate_symbol),u_aspect_ratio:new s.Uniform1f(f,r.u_aspect_ratio),u_fade_change:new s.Uniform1f(f,r.u_fade_change),u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_label_plane_matrix:new s.UniformMatrix4f(f,r.u_label_plane_matrix),u_coord_matrix:new s.UniformMatrix4f(f,r.u_coord_matrix),u_is_text:new s.Uniform1i(f,r.u_is_text),u_pitch_with_map:new s.Uniform1i(f,r.u_pitch_with_map),u_texsize:new s.Uniform2f(f,r.u_texsize),u_texsize_icon:new s.Uniform2f(f,r.u_texsize_icon),u_texture:new s.Uniform1i(f,r.u_texture),u_texture_icon:new s.Uniform1i(f,r.u_texture_icon),u_gamma_scale:new s.Uniform1f(f,r.u_gamma_scale),u_device_pixel_ratio:new s.Uniform1f(f,r.u_device_pixel_ratio),u_is_halo:new s.Uniform1i(f,r.u_is_halo)}),background:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_opacity:new s.Uniform1f(f,r.u_opacity),u_color:new s.UniformColor(f,r.u_color)}),backgroundPattern:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_opacity:new s.Uniform1f(f,r.u_opacity),u_image:new s.Uniform1i(f,r.u_image),u_pattern_tl_a:new s.Uniform2f(f,r.u_pattern_tl_a),u_pattern_br_a:new s.Uniform2f(f,r.u_pattern_br_a),u_pattern_tl_b:new s.Uniform2f(f,r.u_pattern_tl_b),u_pattern_br_b:new s.Uniform2f(f,r.u_pattern_br_b),u_texsize:new s.Uniform2f(f,r.u_texsize),u_mix:new s.Uniform1f(f,r.u_mix),u_pattern_size_a:new s.Uniform2f(f,r.u_pattern_size_a),u_pattern_size_b:new s.Uniform2f(f,r.u_pattern_size_b),u_scale_a:new s.Uniform1f(f,r.u_scale_a),u_scale_b:new s.Uniform1f(f,r.u_scale_b),u_pixel_coord_upper:new s.Uniform2f(f,r.u_pixel_coord_upper),u_pixel_coord_lower:new s.Uniform2f(f,r.u_pixel_coord_lower),u_tile_units_to_pixels:new s.Uniform1f(f,r.u_tile_units_to_pixels)}),terrainRaster:Ad,terrainDepth:Ad,skybox:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_sun_direction:new s.Uniform3f(f,r.u_sun_direction),u_cubemap:new s.Uniform1i(f,r.u_cubemap),u_opacity:new s.Uniform1f(f,r.u_opacity),u_temporal_offset:new s.Uniform1f(f,r.u_temporal_offset)}),skyboxGradient:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_color_ramp:new s.Uniform1i(f,r.u_color_ramp),u_center_direction:new s.Uniform3f(f,r.u_center_direction),u_radius:new s.Uniform1f(f,r.u_radius),u_opacity:new s.Uniform1f(f,r.u_opacity),u_temporal_offset:new s.Uniform1f(f,r.u_temporal_offset)}),skyboxCapture:(f,r)=>({u_matrix_3f:new s.UniformMatrix3f(f,r.u_matrix_3f),u_sun_direction:new s.Uniform3f(f,r.u_sun_direction),u_sun_intensity:new s.Uniform1f(f,r.u_sun_intensity),u_color_tint_r:new s.Uniform4f(f,r.u_color_tint_r),u_color_tint_m:new s.Uniform4f(f,r.u_color_tint_m),u_luminance:new s.Uniform1f(f,r.u_luminance)}),globeRaster:(f,r)=>({u_proj_matrix:new s.UniformMatrix4f(f,r.u_proj_matrix),u_globe_matrix:new s.UniformMatrix4f(f,r.u_globe_matrix),u_merc_matrix:new s.UniformMatrix4f(f,r.u_merc_matrix),u_zoom_transition:new s.Uniform1f(f,r.u_zoom_transition),u_merc_center:new s.Uniform2f(f,r.u_merc_center),u_image0:new s.Uniform1i(f,r.u_image0),u_grid_matrix:new s.UniformMatrix3f(f,r.u_grid_matrix)}),globeAtmosphere:(f,r)=>({u_frustum_tl:new s.Uniform3f(f,r.u_frustum_tl),u_frustum_tr:new s.Uniform3f(f,r.u_frustum_tr),u_frustum_br:new s.Uniform3f(f,r.u_frustum_br),u_frustum_bl:new s.Uniform3f(f,r.u_frustum_bl),u_globe_pos:new s.Uniform3f(f,r.u_globe_pos),u_globe_radius:new s.Uniform1f(f,r.u_globe_radius),u_opacity:new s.Uniform1f(f,r.u_opacity),u_fadeout_range:new s.Uniform1f(f,r.u_fadeout_range),u_start_color:new s.Uniform3f(f,r.u_start_color),u_end_color:new s.Uniform3f(f,r.u_end_color)})};let Ho;function Im(f,r,u,g,x,b,S){const P=f.context,z=P.gl,F=f.useProgram("collisionBox"),N=[];let H=0,J=0;for(let Se=0;Se0){const ut=s.create(),Rt=Qe;s.mul(ut,Fe.placementInvProjMatrix,f.transform.glCoordMatrix),s.mul(ut,ut,Fe.placementViewportMatrix),N.push({circleArray:dt,circleOffset:J,transform:Rt,invTransform:ut}),H+=dt.length/4,J=H}at&&(f.terrain&&f.terrain.setupElevationDraw(be,F),F.draw(P,z.LINES,s.DepthMode.disabled,s.StencilMode.disabled,f.colorModeForRenderPass(),s.CullFaceMode.disabled,Oy(Qe,f.transform,be),u.id,at.layoutVertexBuffer,at.indexBuffer,at.segments,null,f.transform.zoom,null,at.collisionVertexBuffer,at.collisionVertexBufferExt))}if(!S||!N.length)return;const re=f.useProgram("collisionCircle"),Q=new s.StructArrayLayout2f1f2i16;Q.resize(4*H),Q._trim();let X=0;for(const Se of N)for(let Re=0;Re=0&&(X[Re.associatedIconIndex]={shiftedAnchor:Xt,angle:Yt})}else Bi(Re.numGlyphs,re)}if(N){Q.clear();const Se=f.icon.placedSymbolArray;for(let Re=0;Re[0,0,0];za(Pt,et.projMatrix,f,x,ir,ma,Ae,F,jo,et)}const Va=fe||x&&Qe||po,bi=f.translatePosMatrix(et.projMatrix,zt,b,S),Ti=Va?Fd:ir,$n=f.translatePosMatrix(ma,zt,b,S,!0),Li=Q.projection.createInversionMatrix(Q,et.canonical),zr=Va?Rt.concat(["PROJECTED_POS_ON_VIEWPORT"]):Rt,xi=qt&&u.paint.get(x?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Zr;Zr=qt?Pt.iconsInText?Es(mn.kind,Yt,Te,Ae,f,bi,Ti,$n,vn,qn,et,dt,Fe,Li):Go(mn.kind,Yt,Te,Ae,f,bi,Ti,$n,x,vn,!0,et,dt,Fe,Li):kd(mn.kind,Yt,Te,Ae,f,bi,Ti,$n,x,vn,et,dt,Fe,Li);const Gl={program:f.useProgram(Hy(qt,x,Pt),pt,zr),buffers:Jt,uniformValues:Zr,atlasTexture:kn,atlasTextureIcon:vi,atlasInterpolation:hn,atlasInterpolationIcon:Mn,isSDF:qt,hasHalo:xi,tile:zt,labelPlaneMatrixInv:Rr};if(Se&&Pt.canOverlap){Re=!0;const kr=Jt.segments.get();for(const jo of kr)ut.push({segments:new s.SegmentVector([jo]),sortKey:jo.sortKey,state:Gl})}else ut.push({segments:Jt.segments,sortKey:0,state:Gl})}Re&&ut.sort((et,zt)=>et.sortKey-zt.sortKey);for(const et of ut){const zt=et.state;if(f.terrain&&f.terrain.setupElevationDraw(zt.tile,zt.program,{useDepthForOcclusion:!at,labelPlaneMatrixInv:zt.labelPlaneMatrixInv}),J.activeTexture.set(re.TEXTURE0),zt.atlasTexture.bind(zt.atlasInterpolation,re.CLAMP_TO_EDGE),zt.atlasTextureIcon&&(J.activeTexture.set(re.TEXTURE1),zt.atlasTextureIcon&&zt.atlasTextureIcon.bind(zt.atlasInterpolationIcon,re.CLAMP_TO_EDGE)),zt.isSDF){const Pt=zt.uniformValues;zt.hasHalo&&(Pt.u_is_halo=1,Rm(zt.buffers,et.segments,u,f,zt.program,be,N,H,Pt)),Pt.u_is_halo=0}Rm(zt.buffers,et.segments,u,f,zt.program,be,N,H,zt.uniformValues)}}function Rm(f,r,u,g,x,b,S,P,z){const F=g.context;x.draw(F,F.gl.TRIANGLES,b,S,P,s.CullFaceMode.disabled,z,u.id,f.layoutVertexBuffer,f.indexBuffer,r,u.paint,g.transform.zoom,f.programConfigurations.get(u.id),f.dynamicLayoutVertexBuffer,f.opacityVertexBuffer)}function bu(f,r,u,g,x,b,S){const P=f.context.gl,z=u.paint.get("fill-pattern"),F=z&&z.constantOr(1),N=u.getCrossfadeParameters();let H,J,re,Q,X;S?(J=F&&!u.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",H=P.LINES):(J=F?"fillPattern":"fill",H=P.TRIANGLES);for(const Ae of g){const fe=r.getTile(Ae);if(F&&!fe.patternsLoaded())continue;const Te=fe.getBucket(u);if(!Te)continue;f.prepareDrawTile();const Se=Te.programConfigurations.get(u.id),Re=f.useProgram(J,Se);F&&(f.context.activeTexture.set(P.TEXTURE0),fe.imageAtlasTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),Se.updatePaintBuffers(N));const be=z.constantOr(null);if(be&&fe.imageAtlas){const Qe=fe.imageAtlas,at=Qe.patternPositions[be.to.toString()],dt=Qe.patternPositions[be.from.toString()];at&&dt&&Se.setConstantPatternPositions(at,dt)}const Fe=f.translatePosMatrix(Ae.projMatrix,fe,u.paint.get("fill-translate"),u.paint.get("fill-translate-anchor"));if(S){Q=Te.indexBuffer2,X=Te.segments2;const Qe=f.terrain&&f.terrain.renderingToTexture?f.terrain.drapeBufferSize:[P.drawingBufferWidth,P.drawingBufferHeight];re=J==="fillOutlinePattern"&&F?Am(Fe,f,N,fe,Qe):vu(Fe,Qe)}else Q=Te.indexBuffer,X=Te.segments,re=F?yu(Fe,f,N,fe):_u(Fe);f.prepareDrawProgram(f.context,Re,Ae.toUnwrapped()),Re.draw(f.context,H,x,f.stencilModeForClipping(Ae),b,s.CullFaceMode.disabled,re,u.id,Te.layoutVertexBuffer,Q,X,u.paint,f.transform.zoom,Se)}}function Ss(f,r,u,g,x,b,S){const P=f.context,z=P.gl,F=f.transform,N=u.paint.get("fill-extrusion-pattern"),H=N.constantOr(1),J=u.getCrossfadeParameters(),re=u.paint.get("fill-extrusion-opacity"),Q=function(Se){if(Se.projection.name!=="globe")return 0;const Re=Math.PI/32,be=Math.tan(Re),Fe=s.earthRadius;return Fe*Math.sqrt(1+2*be*be)-Fe}(F),X=F.projection.name==="globe",Ae=X?s.globeToMercatorTransition(F.zoom):0,fe=[s.mercatorXfromLng(F.center.lng),s.mercatorYfromLat(F.center.lat)],Te=[];X&&Te.push("PROJECTION_GLOBE_VIEW");for(const Se of g){const Re=r.getTile(Se),be=Re.getBucket(u);if(!be||be.projection!==F.projection.name)continue;const Fe=be.programConfigurations.get(u.id),Qe=f.useProgram(H?"fillExtrusionPattern":"fillExtrusion",Fe,Te);if(f.terrain){const zt=f.terrain;if(f.style.terrainSetForDrapingOnly())zt.setupElevationDraw(Re,Qe,{useMeterToDem:!0});else{if(!be.enableTerrain)continue;if(zt.setupElevationDraw(Re,Qe,{useMeterToDem:!0}),Al(P,r,Se,be,u,zt),!be.centroidVertexBuffer){const Pt=Qe.attributes.a_centroid_pos;Pt!==void 0&&z.vertexAttrib2f(Pt,0,0)}}}H&&(f.context.activeTexture.set(z.TEXTURE0),Re.imageAtlasTexture.bind(z.LINEAR,z.CLAMP_TO_EDGE),Fe.updatePaintBuffers(J));const at=N.constantOr(null);if(at&&Re.imageAtlas){const zt=Re.imageAtlas,Pt=zt.patternPositions[at.to.toString()],Jt=zt.patternPositions[at.from.toString()];Pt&&Jt&&Fe.setConstantPatternPositions(Pt,Jt)}const dt=f.translatePosMatrix(Se.projMatrix,Re,u.paint.get("fill-extrusion-translate"),u.paint.get("fill-extrusion-translate-anchor")),ut=F.projection.createInversionMatrix(F,Se.canonical),Rt=u.paint.get("fill-extrusion-vertical-gradient"),et=H?gu(dt,f,Rt,re,Se,J,Re,Q,Ae,fe,ut):mu(dt,f,Rt,re,Se,Q,Ae,fe,ut);f.prepareDrawProgram(P,Qe,Se.toUnwrapped()),Qe.draw(P,P.gl.TRIANGLES,x,b,S,s.CullFaceMode.backCCW,et,u.id,be.layoutVertexBuffer,be.indexBuffer,be.segments,u.paint,f.transform.zoom,Fe,f.terrain?be.centroidVertexBuffer:null,X?be.layoutVertexExtBuffer:null)}}function Al(f,r,u,g,x,b){const S=[fe=>{let Te=fe.canonical.x-1,Se=fe.wrap;return Te<0&&(Te=(1<{let Te=fe.canonical.x+1,Se=fe.wrap;return Te===1<new s.OverscaledTileID(fe.overscaledZ,fe.wrap,fe.canonical.z,fe.canonical.x,(fe.canonical.y===0?1<new s.OverscaledTileID(fe.overscaledZ,fe.wrap,fe.canonical.z,fe.canonical.x,fe.canonical.y===(1<{const Te=r.getSource().minzoom,Se=be=>{const Fe=r.getTileByID(be);if(Fe&&Fe.hasData())return Fe.getBucket(x)},Re=[0,-1,1];for(const be of Re){if(fe.overscaledZ+be(z[0]=Math.min(fe.min.y,Te.min.y),z[1]=Math.max(fe.max.y,Te.max.y),z[2]=s.EXTENT-Te.min.x>fe.max.x?Te.min.x-s.EXTENT:fe.max.x,z),N=(fe,Te)=>(z[0]=Math.min(fe.min.x,Te.min.x),z[1]=Math.max(fe.max.x,Te.max.x),z[2]=s.EXTENT-Te.min.y>fe.max.y?Te.min.y-s.EXTENT:fe.max.y,z),H=[(fe,Te)=>F(fe,Te),(fe,Te)=>F(Te,fe),(fe,Te)=>N(fe,Te),(fe,Te)=>N(Te,fe)],J=new s.pointGeometry(0,0);let re,Q,X;const Ae=(fe,Te,Se,Re,be)=>{const Fe=[[Re?Se:fe,Re?fe:Se,0],[Re?Se:Te,Re?Te:Se,0]],Qe=be<0?s.EXTENT+be:be,at=[Re?Qe:(fe+Te)/2,Re?(fe+Te)/2:Qe,0];return Se===0&&be<0||Se!==0&&be>0?b.getForTilePoints(X,[at],!0,Q):Fe.push(at),b.getForTilePoints(u,Fe,!0,re),Math.max(Fe[0][2],Fe[1][2],at[2])/b.exaggeration()};for(let fe=0;fe<4;fe++){const Te=(fe<2?1:5)-fe,Se=g.borders[fe];if(Se.length===0)continue;const Re=X=S[fe](u),be=P(Re);if(!(be&&be instanceof s.FillExtrusionBucket&&be.enableTerrain)||g.borderDoneWithNeighborZ[fe]===be.canonical.z&&be.borderDoneWithNeighborZ[Te]===g.canonical.z||(Q=b.findDEMTileFor(Re),!Q||!Q.dem))continue;if(!re){const dt=b.findDEMTileFor(u);if(!dt||!dt.dem)return;re=dt}const Fe=be.borders[Te];let Qe=0;const at=be.borderDoneWithNeighborZ[Te]!==g.canonical.z;if(g.canonical.z===be.canonical.z){for(let dt=0;dtRt[0]+3));)at&&be.encodeCentroid(void 0,et,!1),Qe++;if(et&&QeRt[1]-3)&&(Pt++,++Qe!==Fe.length);)et=be.featuresOnBorder[Fe[Qe]];if(et=be.featuresOnBorder[Fe[zt]],ut.intersectsCount()>1||et.intersectsCount()>1||Pt!==1){Pt!==1&&(Qe=zt),g.encodeCentroid(void 0,ut,!1),at&&be.encodeCentroid(void 0,et,!1);continue}const Jt=H[fe](ut,et),pt=fe%2?s.EXTENT-1:0;J.x=Ae(Jt[0],Math.min(s.EXTENT-1,Jt[1]),pt,fe<2,Jt[2]),J.y=0,g.encodeCentroid(J,ut,!1),at&&be.encodeCentroid(J,et,!1)}else g.encodeCentroid(void 0,ut,!1)}g.borderDoneWithNeighborZ[fe]=be.canonical.z,g.needsCentroidUpdate=!0,at&&(be.borderDoneWithNeighborZ[Te]=g.canonical.z,be.needsCentroidUpdate=!0)}else{for(const dt of Se)g.encodeCentroid(void 0,g.featuresOnBorder[dt],!1);if(at){for(const dt of Fe)be.encodeCentroid(void 0,be.featuresOnBorder[dt],!1);be.borderDoneWithNeighborZ[Te]=g.canonical.z,be.needsCentroidUpdate=!0}g.borderDoneWithNeighborZ[fe]=be.canonical.z,g.needsCentroidUpdate=!0}}(g.needsCentroidUpdate||!g.centroidVertexBuffer&&g.centroidVertexArray.length!==0)&&g.uploadCentroid(f)}const Nd=new s.Color(1,0,0,1),Ud=new s.Color(0,1,0,1),zm=new s.Color(0,0,1,1),wu=new s.Color(1,0,1,1),Mu=new s.Color(0,1,1,1);function Ht(f,r,u,g){Cl(f,0,r+u/2,f.transform.width,u,g)}function jr(f,r,u,g){Cl(f,r-u/2,0,u,f.transform.height,g)}function Cl(f,r,u,g,x,b){const S=f.context,P=S.gl;P.enable(P.SCISSOR_TEST),P.scissor(r*s.exported.devicePixelRatio,u*s.exported.devicePixelRatio,g*s.exported.devicePixelRatio,x*s.exported.devicePixelRatio),S.clear({color:b}),P.disable(P.SCISSOR_TEST)}function km(f,r,u){const g=f.context,x=g.gl,b=f.transform.projection.name==="globe",S=u.projMatrix,P=f.useProgram("debug",null,b?["PROJECTION_GLOBE_VIEW"]:null),z=r.getTileByID(u.key);f.terrain&&f.terrain.setupElevationDraw(z,P);const F=s.DepthMode.disabled,N=s.StencilMode.disabled,H=f.colorModeForRenderPass(),J="$debug";g.activeTexture.set(x.TEXTURE0),f.emptyTexture.bind(x.LINEAR,x.CLAMP_TO_EDGE),b?z._makeGlobeTileDebugBuffers(f.context,f.transform.projection):z._makeDebugTileBoundsBuffers(f.context,f.transform.projection);const re=z._tileDebugBuffer||f.debugBuffer,Q=z._tileDebugIndexBuffer||f.debugIndexBuffer,X=z._tileDebugSegments||f.debugSegments;P.draw(g,x.LINE_STRIP,F,N,H,s.CullFaceMode.disabled,Pm(S,s.Color.red),J,re,Q,X,null,null,null,z._globeTileDebugBorderBuffer);const Ae=z.latestRawTileData,fe=Math.floor((Ae&&Ae.byteLength||0)/1024),Te=r.getTile(u).tileSize,Se=512/Math.min(Te,512)*(u.overscaledZ/f.transform.zoom)*.5;let Re=u.canonical.toString();u.overscaledZ!==u.canonical.z&&(Re+=` => ${u.overscaledZ}`),function(at,dt){at.initDebugOverlayCanvas();const ut=at.debugOverlayCanvas,Rt=at.context.gl,et=at.debugOverlayCanvas.getContext("2d");et.clearRect(0,0,ut.width,ut.height),et.shadowColor="white",et.shadowBlur=2,et.lineWidth=1.5,et.strokeStyle="white",et.textBaseline="top",et.font="bold 36px Open Sans, sans-serif",et.fillText(dt,5,5),et.strokeText(dt,5,5),at.debugOverlayTexture.update(ut),at.debugOverlayTexture.bind(Rt.LINEAR,Rt.CLAMP_TO_EDGE)}(f,`${Re} ${fe}kb`);const be=z._tileDebugTextBuffer||f.debugBuffer,Fe=z._tileDebugTextIndexBuffer||f.quadTriangleIndexBuffer,Qe=z._tileDebugTextSegments||f.debugSegments;P.draw(g,x.TRIANGLES,F,N,s.ColorMode.alphaBlended,s.CullFaceMode.disabled,Pm(S,s.Color.transparent,Se),J,be,Fe,Qe,null,null,null,z._globeTileDebugTextBuffer)}const Bm=s.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:As}=Bm;function Fa(f,r,u,g){f.emplaceBack(r,u,g)}class Pl{constructor(r){this.vertexArray=new s.StructArrayLayout3f12,this.indices=new s.StructArrayLayout3ui6,Fa(this.vertexArray,-1,-1,1),Fa(this.vertexArray,1,-1,1),Fa(this.vertexArray,-1,1,1),Fa(this.vertexArray,1,1,1),Fa(this.vertexArray,-1,-1,-1),Fa(this.vertexArray,1,-1,-1),Fa(this.vertexArray,-1,1,-1),Fa(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=r.createVertexBuffer(this.vertexArray,As),this.indexBuffer=r.createIndexBuffer(this.indices),this.segment=s.SegmentVector.simpleSegment(0,0,36,12)}}function so(f,r,u,g,x,b){const S=f.gl,P=r.paint.get("sky-atmosphere-color"),z=r.paint.get("sky-atmosphere-halo-color"),F=r.paint.get("sky-atmosphere-sun-intensity"),N=((H,J,re,Q,X)=>({u_matrix_3f:H,u_sun_direction:J,u_sun_intensity:re,u_color_tint_r:[Q.r,Q.g,Q.b,Q.a],u_color_tint_m:[X.r,X.g,X.b,X.a],u_luminance:5e-5}))(s.fromMat4(s.create$1(),g),x,F,P,z);S.framebufferTexture2D(S.FRAMEBUFFER,S.COLOR_ATTACHMENT0,S.TEXTURE_CUBE_MAP_POSITIVE_X+b,r.skyboxTexture,0),u.draw(f,S.TRIANGLES,s.DepthMode.disabled,s.StencilMode.disabled,s.ColorMode.unblended,s.CullFaceMode.frontCW,N,"skyboxCapture",r.skyboxGeometry.vertexBuffer,r.skyboxGeometry.indexBuffer,r.skyboxGeometry.segment)}function lo(f,r){return s.transformMat4(f,f,r)}const Vd={symbol:function(f,r,u,g,x){if(f.renderPass!=="translucent")return;const b=s.StencilMode.disabled,S=f.colorModeForRenderPass();u.layout.get("text-variable-anchor")&&function(P,z,F,N,H,J,re){const Q=z.transform,X=H==="map",Ae=J==="map";for(const fe of P){const Te=N.getTile(fe),Se=Te.getBucket(F);if(!Se||Se.projection!==Q.projection.name||!Se.text||!Se.text.segments.get().length)continue;const Re=s.evaluateSizeForZoom(Se.textSizeData,Q.zoom),be=z.transform.calculatePixelsToTileUnitsMatrix(Te),Fe=di(fe.projMatrix,Te.tileID.canonical,Ae,X,z.transform,be),Qe=F.layout.get("icon-text-fit")!=="none"&&Se.hasIconData();if(Re){const at=Math.pow(2,Q.zoom-Te.tileID.overscaledZ);Gy(Se,X,Ae,re,s.symbolSize,Q,Fe,fe,at,Re,Qe,Q.projection)}}}(g,f,u,r,u.layout.get("text-rotation-alignment"),u.layout.get("text-pitch-alignment"),x),u.paint.get("icon-opacity").constantOr(1)!==0&&Od(f,r,u,g,!1,u.paint.get("icon-translate"),u.paint.get("icon-translate-anchor"),u.layout.get("icon-rotation-alignment"),u.layout.get("icon-pitch-alignment"),u.layout.get("icon-keep-upright"),b,S),u.paint.get("text-opacity").constantOr(1)!==0&&Od(f,r,u,g,!0,u.paint.get("text-translate"),u.paint.get("text-translate-anchor"),u.layout.get("text-rotation-alignment"),u.layout.get("text-pitch-alignment"),u.layout.get("text-keep-upright"),b,S),r.map.showCollisionBoxes&&(Im(f,r,u,g,u.paint.get("text-translate"),u.paint.get("text-translate-anchor"),!0),Im(f,r,u,g,u.paint.get("icon-translate"),u.paint.get("icon-translate-anchor"),!1))},circle:function(f,r,u,g){if(f.renderPass!=="translucent")return;const x=u.paint.get("circle-opacity"),b=u.paint.get("circle-stroke-width"),S=u.paint.get("circle-stroke-opacity"),P=u.layout.get("circle-sort-key").constantOr(1)!==void 0;if(x.constantOr(1)===0&&(b.constantOr(1)===0||S.constantOr(1)===0))return;const z=f.context,F=z.gl,N=f.transform,H=f.depthModeForSublayer(0,s.DepthMode.ReadOnly),J=s.StencilMode.disabled,re=f.colorModeForRenderPass(),Q=N.projection.name==="globe",X=[s.mercatorXfromLng(N.center.lng),s.mercatorYfromLat(N.center.lat)],Ae=[];for(let Te=0;TeTe.sortKey-Se.sortKey);const fe={useDepthForOcclusion:!Q};for(const Te of Ae){const{programConfiguration:Se,program:Re,layoutVertexBuffer:be,globeExtVertexBuffer:Fe,indexBuffer:Qe,uniformValues:at,tile:dt}=Te.state,ut=Te.segments;f.terrain&&f.terrain.setupElevationDraw(dt,Re,fe),f.prepareDrawProgram(z,Re,dt.tileID.toUnwrapped()),Re.draw(z,F.TRIANGLES,H,J,re,s.CullFaceMode.disabled,at,u.id,be,Qe,ut,u.paint,N.zoom,Se,Q?Fe:null)}},heatmap:function(f,r,u,g){if(u.paint.get("heatmap-opacity")!==0)if(f.renderPass==="offscreen"){const x=f.context,b=x.gl,S=s.StencilMode.disabled,P=new s.ColorMode([b.ONE,b.ONE],s.Color.transparent,[!0,!0,!0,!0]);(function(J,re,Q){const X=J.gl;J.activeTexture.set(X.TEXTURE1),J.viewport.set([0,0,re.width/4,re.height/4]);let Ae=Q.heatmapFbo;if(Ae)X.bindTexture(X.TEXTURE_2D,Ae.colorAttachment.get()),J.bindFramebuffer.set(Ae.framebuffer);else{const fe=X.createTexture();X.bindTexture(X.TEXTURE_2D,fe),X.texParameteri(X.TEXTURE_2D,X.TEXTURE_WRAP_S,X.CLAMP_TO_EDGE),X.texParameteri(X.TEXTURE_2D,X.TEXTURE_WRAP_T,X.CLAMP_TO_EDGE),X.texParameteri(X.TEXTURE_2D,X.TEXTURE_MIN_FILTER,X.LINEAR),X.texParameteri(X.TEXTURE_2D,X.TEXTURE_MAG_FILTER,X.LINEAR),Ae=Q.heatmapFbo=J.createFramebuffer(re.width/4,re.height/4,!1),function(Te,Se,Re,be){const Fe=Te.gl;Fe.texImage2D(Fe.TEXTURE_2D,0,Fe.RGBA,Se.width/4,Se.height/4,0,Fe.RGBA,Te.extRenderToTextureHalfFloat?Te.extTextureHalfFloat.HALF_FLOAT_OES:Fe.UNSIGNED_BYTE,null),be.colorAttachment.set(Re)}(J,re,fe,Ae)}})(x,f,u),x.clear({color:s.Color.transparent});const z=f.transform,F=z.projection.name==="globe",N=F?["PROJECTION_GLOBE_VIEW"]:null,H=[s.mercatorXfromLng(z.center.lng),s.mercatorYfromLat(z.center.lat)];for(let J=0;J({u_image:0,u_color_ramp:1,u_opacity:H.paint.get("heatmap-opacity")}))(0,b),b.id,x.viewportBuffer,x.quadTriangleIndexBuffer,x.viewportSegments,b.paint,x.transform.zoom)}(f,u))},line:function(f,r,u,g){if(f.renderPass!=="translucent")return;const x=u.paint.get("line-opacity"),b=u.paint.get("line-width");if(x.constantOr(1)===0||b.constantOr(1)===0)return;const S=f.depthModeForSublayer(0,s.DepthMode.ReadOnly),P=f.colorModeForRenderPass(),z=f.terrain&&f.terrain.renderingToTexture?1:s.exported.devicePixelRatio,F=u.paint.get("line-dasharray"),N=F.constantOr(1),H=u.layout.get("line-cap"),J=u.paint.get("line-pattern"),re=J.constantOr(1),Q=u.paint.get("line-gradient"),X=u.getCrossfadeParameters(),Ae=re?"linePattern":"line",fe=f.context,Te=fe.gl,Se=(be=>{const Fe=[];Rd(be)&&Fe.push("RENDER_LINE_DASH"),be.paint.get("line-gradient")&&Fe.push("RENDER_LINE_GRADIENT");const Qe=be.paint.get("line-pattern").constantOr(1),at=be.paint.get("line-opacity").constantOr(1)!==1;return!Qe&&at&&Fe.push("RENDER_LINE_ALPHA_DISCARD"),Fe})(u);let Re=Se.includes("RENDER_LINE_ALPHA_DISCARD");f.terrain&&f.terrain.clipOrMaskOverlapStencilType()&&(Re=!1);for(const be of g){const Fe=r.getTile(be);if(re&&!Fe.patternsLoaded())continue;const Qe=Fe.getBucket(u);if(!Qe)continue;f.prepareDrawTile();const at=Qe.programConfigurations.get(u.id),dt=f.useProgram(Ae,at,Se),ut=J.constantOr(null);if(ut&&Fe.imageAtlas){const pt=Fe.imageAtlas,qt=pt.patternPositions[ut.to.toString()],mn=pt.patternPositions[ut.from.toString()];qt&&mn&&at.setConstantPatternPositions(qt,mn)}const Rt=F.constantOr(null),et=H.constantOr(null);if(!re&&Rt&&et&&Fe.lineAtlas){const pt=Fe.lineAtlas,qt=pt.getDash(Rt.to,et),mn=pt.getDash(Rt.from,et);qt&&mn&&at.setConstantPatternPositions(qt,mn)}const zt=f.terrain?be.projMatrix:null,Pt=re?Id(f,Fe,u,X,zt,z):Vy(f,Fe,u,X,zt,Qe.lineClipsArray.length,z);if(Q){const pt=Qe.gradients[u.id];let qt=pt.texture;if(u.gradientVersion!==pt.version){let mn=256;if(u.stepInterpolant){const Xt=r.getSource().maxzoom,Yt=be.canonical.z===Xt?Math.ceil(1<{dt.draw(fe,Te.TRIANGLES,S,pt,P,s.CullFaceMode.disabled,Pt,u.id,Qe.layoutVertexBuffer,Qe.indexBuffer,Qe.segments,u.paint,f.transform.zoom,at,Qe.layoutVertexBuffer2)};if(Re){const pt=f.stencilModeForClipping(be).ref;pt===0&&f.terrain&&fe.clear({stencil:0});const qt={func:Te.EQUAL,mask:255};Pt.u_alpha_discard_threshold=.8,Jt(new s.StencilMode(qt,pt,255,Te.KEEP,Te.KEEP,Te.INVERT)),Pt.u_alpha_discard_threshold=0,Jt(new s.StencilMode(qt,pt,255,Te.KEEP,Te.KEEP,Te.KEEP))}else Jt(f.stencilModeForClipping(be))}Re&&(f.resetStencilClippingMasks(),f.terrain&&fe.clear({stencil:0}))},fill:function(f,r,u,g){const x=u.paint.get("fill-color"),b=u.paint.get("fill-opacity");if(b.constantOr(1)===0)return;const S=f.colorModeForRenderPass(),P=u.paint.get("fill-pattern"),z=f.opaquePassEnabledForLayer()&&!P.constantOr(1)&&x.constantOr(s.Color.transparent).a===1&&b.constantOr(0)===1?"opaque":"translucent";if(f.renderPass===z){const F=f.depthModeForSublayer(1,f.renderPass==="opaque"?s.DepthMode.ReadWrite:s.DepthMode.ReadOnly);bu(f,r,u,g,F,S,!1)}if(f.renderPass==="translucent"&&u.paint.get("fill-antialias")){const F=f.depthModeForSublayer(u.getPaintProperty("fill-outline-color")?2:0,s.DepthMode.ReadOnly);bu(f,r,u,g,F,S,!0)}},"fill-extrusion":function(f,r,u,g){const x=u.paint.get("fill-extrusion-opacity");if(x!==0&&f.renderPass==="translucent"){const b=new s.DepthMode(f.context.gl.LEQUAL,s.DepthMode.ReadWrite,f.depthRangeFor3D);if(x!==1||u.paint.get("fill-extrusion-pattern").constantOr(1))Ss(f,r,u,g,b,s.StencilMode.disabled,s.ColorMode.disabled),Ss(f,r,u,g,b,f.stencilModeFor3D(),f.colorModeForRenderPass()),f.resetStencilClippingMasks();else{const S=f.colorModeForRenderPass();Ss(f,r,u,g,b,s.StencilMode.disabled,S)}}},hillshade:function(f,r,u,g){if(f.renderPass!=="offscreen"&&f.renderPass!=="translucent")return;const x=f.context,b=f.depthModeForSublayer(0,s.DepthMode.ReadOnly),S=f.colorModeForRenderPass(),P=f.terrain&&f.terrain.renderingToTexture,[z,F]=f.renderPass!=="translucent"||P?[{},g]:f.stencilConfigForOverlap(g);for(const N of F){const H=r.getTile(N);if(H.needsHillshadePrepare&&f.renderPass==="offscreen")Sd(f,H,u,b,s.StencilMode.disabled,S);else if(f.renderPass==="translucent"){const J=P&&f.terrain?f.terrain.stencilModeForRTTOverlap(N):z[N.overscaledZ];Tm(f,N,H,u,b,J,S)}}x.viewport.set([0,0,f.width,f.height]),f.resetStencilClippingMasks()},raster:function(f,r,u,g,x,b){if(f.renderPass!=="translucent"||u.paint.get("raster-opacity")===0||!g.length)return;const S=f.context,P=S.gl,z=r.getSource(),F=f.useProgram("raster"),N=f.colorModeForRenderPass(),H=f.terrain&&f.terrain.renderingToTexture,[J,re]=z instanceof Ge||H?[{},g]:f.stencilConfigForOverlap(g),Q=re[re.length-1].overscaledZ,X=!f.options.moving;for(const Ae of re){const fe=H?s.DepthMode.disabled:f.depthModeForSublayer(Ae.overscaledZ-Q,u.paint.get("raster-opacity")===1?s.DepthMode.ReadWrite:s.DepthMode.ReadOnly,P.LESS),Te=Ae.toUnwrapped(),Se=r.getTile(Ae);if(H&&(!Se||!Se.hasData()))continue;const Re=H?Ae.projMatrix:f.transform.calculateProjMatrix(Te,X),be=f.terrain&&H?f.terrain.stencilModeForRTTOverlap(Ae):J[Ae.overscaledZ],Fe=b?0:u.paint.get("raster-fade-duration");Se.registerFadeDuration(Fe);const Qe=r.findLoadedParent(Ae,0),at=Pd(Se,Qe,r,f.transform,Fe);let dt,ut;f.terrain&&f.terrain.prepareDrawTile();const Rt=u.paint.get("raster-resampling")==="nearest"?P.NEAREST:P.LINEAR;S.activeTexture.set(P.TEXTURE0),Se.texture.bind(Rt,P.CLAMP_TO_EDGE),S.activeTexture.set(P.TEXTURE1),Qe?(Qe.texture.bind(Rt,P.CLAMP_TO_EDGE),dt=Math.pow(2,Qe.tileID.overscaledZ-Se.tileID.overscaledZ),ut=[Se.tileID.canonical.x*dt%1,Se.tileID.canonical.y*dt%1]):Se.texture.bind(Rt,P.CLAMP_TO_EDGE);const et=Lm(Re,ut||[0,0],dt||1,at,u,z instanceof Ge?z.perspectiveTransform:[0,0]);if(f.prepareDrawProgram(S,F,Te),z instanceof Ge)z.boundsBuffer&&z.boundsSegments&&F.draw(S,P.TRIANGLES,fe,s.StencilMode.disabled,N,s.CullFaceMode.disabled,et,u.id,z.boundsBuffer,f.quadTriangleIndexBuffer,z.boundsSegments);else{const{tileBoundsBuffer:zt,tileBoundsIndexBuffer:Pt,tileBoundsSegments:Jt}=f.getTileBoundsBuffers(Se);F.draw(S,P.TRIANGLES,fe,be,N,s.CullFaceMode.disabled,et,u.id,zt,Pt,Jt)}}f.resetStencilClippingMasks()},background:function(f,r,u,g){const x=u.paint.get("background-color"),b=u.paint.get("background-opacity");if(b===0)return;const S=f.context,P=S.gl,z=f.transform,F=z.tileSize,N=u.paint.get("background-pattern");if(f.isPatternMissing(N))return;const H=!N&&x.a===1&&b===1&&f.opaquePassEnabledForLayer()?"opaque":"translucent";if(f.renderPass!==H)return;const J=s.StencilMode.disabled,re=f.depthModeForSublayer(0,H==="opaque"?s.DepthMode.ReadWrite:s.DepthMode.ReadOnly),Q=f.colorModeForRenderPass(),X=f.useProgram(N?"backgroundPattern":"background");let Ae,fe=g;fe||(Ae=f.getBackgroundTiles(),fe=Object.values(Ae).map(Se=>Se.tileID)),N&&(S.activeTexture.set(P.TEXTURE0),f.imageManager.bind(f.context));const Te=u.getCrossfadeParameters();for(const Se of fe){const Re=Se.toUnwrapped(),be=g?Se.projMatrix:f.transform.calculateProjMatrix(Re);f.prepareDrawTile();const Fe=r?r.getTile(Se):Ae?Ae[Se.key]:new s.Tile(Se,F,z.zoom,f),Qe=N?Bd(be,b,f,N,{tileID:Se,tileSize:F},Te):Dm(be,b,x);f.prepareDrawProgram(S,X,Re);const{tileBoundsBuffer:at,tileBoundsIndexBuffer:dt,tileBoundsSegments:ut}=f.getTileBoundsBuffers(Fe);X.draw(S,P.TRIANGLES,re,J,Q,s.CullFaceMode.disabled,Qe,u.id,at,dt,ut)}},sky:function(f,r,u){const g=f.transform,x=g.projection.name==="mercator"||g.projection.name==="globe"?1:s.smoothstep(7,8,g.zoom),b=u.paint.get("sky-opacity")*x;if(b===0)return;const S=f.context,P=u.paint.get("sky-type"),z=new s.DepthMode(S.gl.LEQUAL,s.DepthMode.ReadOnly,[0,1]),F=f.frameCounter/1e3%1;P==="atmosphere"?f.renderPass==="offscreen"?u.needsSkyboxCapture(f)&&(function(N,H,J,re){const Q=N.context,X=Q.gl;let Ae=H.skyboxFbo;if(!Ae){Ae=H.skyboxFbo=Q.createFramebuffer(32,32,!1),H.skyboxGeometry=new Pl(Q),H.skyboxTexture=Q.gl.createTexture(),X.bindTexture(X.TEXTURE_CUBE_MAP,H.skyboxTexture),X.texParameteri(X.TEXTURE_CUBE_MAP,X.TEXTURE_WRAP_S,X.CLAMP_TO_EDGE),X.texParameteri(X.TEXTURE_CUBE_MAP,X.TEXTURE_WRAP_T,X.CLAMP_TO_EDGE),X.texParameteri(X.TEXTURE_CUBE_MAP,X.TEXTURE_MIN_FILTER,X.LINEAR),X.texParameteri(X.TEXTURE_CUBE_MAP,X.TEXTURE_MAG_FILTER,X.LINEAR);for(let Re=0;Re<6;++Re)X.texImage2D(X.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,X.RGBA,32,32,0,X.RGBA,X.UNSIGNED_BYTE,null)}Q.bindFramebuffer.set(Ae.framebuffer),Q.viewport.set([0,0,32,32]);const fe=H.getCenter(N,!0),Te=N.useProgram("skyboxCapture"),Se=new Float64Array(16);s.identity(Se),s.rotateY(Se,Se,.5*-Math.PI),so(Q,H,Te,Se,fe,0),s.identity(Se),s.rotateY(Se,Se,.5*Math.PI),so(Q,H,Te,Se,fe,1),s.identity(Se),s.rotateX(Se,Se,.5*-Math.PI),so(Q,H,Te,Se,fe,2),s.identity(Se),s.rotateX(Se,Se,.5*Math.PI),so(Q,H,Te,Se,fe,3),s.identity(Se),so(Q,H,Te,Se,fe,4),s.identity(Se),s.rotateY(Se,Se,Math.PI),so(Q,H,Te,Se,fe,5),Q.viewport.set([0,0,N.width,N.height])}(f,u),u.markSkyboxValid(f)):f.renderPass==="sky"&&function(N,H,J,re,Q){const X=N.context,Ae=X.gl,fe=N.transform,Te=N.useProgram("skybox");X.activeTexture.set(Ae.TEXTURE0),Ae.bindTexture(Ae.TEXTURE_CUBE_MAP,H.skyboxTexture);const Se=((Re,be,Fe,Qe,at)=>({u_matrix:Re,u_sun_direction:be,u_cubemap:0,u_opacity:Qe,u_temporal_offset:at}))(fe.skyboxMatrix,H.getCenter(N,!1),0,re,Q);N.prepareDrawProgram(X,Te),Te.draw(X,Ae.TRIANGLES,J,s.StencilMode.disabled,N.colorModeForRenderPass(),s.CullFaceMode.backCW,Se,"skybox",H.skyboxGeometry.vertexBuffer,H.skyboxGeometry.indexBuffer,H.skyboxGeometry.segment)}(f,u,z,b,F):P==="gradient"&&f.renderPass==="sky"&&function(N,H,J,re,Q){const X=N.context,Ae=X.gl,fe=N.transform,Te=N.useProgram("skyboxGradient");H.skyboxGeometry||(H.skyboxGeometry=new Pl(X)),X.activeTexture.set(Ae.TEXTURE0);let Se=H.colorRampTexture;Se||(Se=H.colorRampTexture=new s.Texture(X,H.colorRamp,Ae.RGBA)),Se.bind(Ae.LINEAR,Ae.CLAMP_TO_EDGE);const Re=((be,Fe,Qe,at,dt)=>({u_matrix:be,u_color_ramp:0,u_center_direction:Fe,u_radius:s.degToRad(Qe),u_opacity:at,u_temporal_offset:dt}))(fe.skyboxMatrix,H.getCenter(N,!1),H.paint.get("sky-gradient-radius"),re,Q);N.prepareDrawProgram(X,Te),Te.draw(X,Ae.TRIANGLES,J,s.StencilMode.disabled,N.colorModeForRenderPass(),s.CullFaceMode.backCW,Re,"skyboxGradient",H.skyboxGeometry.vertexBuffer,H.skyboxGeometry.indexBuffer,H.skyboxGeometry.segment)}(f,u,z,b,F)},debug:function(f,r,u){for(let g=0;gx)return void(this.transform.fogCullDistSq=null);const b=g+.78*(x-g);this.transform.fogCullDistSq=b*b}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(r,u){if(this.width=r*s.exported.devicePixelRatio,this.height=u*s.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const g of this.style.order)this.style._layers[g].resize()}setup(){const r=this.context,u=new s.StructArrayLayout2i4;u.emplaceBack(0,0),u.emplaceBack(s.EXTENT,0),u.emplaceBack(0,s.EXTENT),u.emplaceBack(s.EXTENT,s.EXTENT),this.tileExtentBuffer=r.createVertexBuffer(u,s.posAttributes.members),this.tileExtentSegments=s.SegmentVector.simpleSegment(0,0,4,2);const g=new s.StructArrayLayout2i4;g.emplaceBack(0,0),g.emplaceBack(s.EXTENT,0),g.emplaceBack(0,s.EXTENT),g.emplaceBack(s.EXTENT,s.EXTENT),this.debugBuffer=r.createVertexBuffer(g,s.posAttributes.members),this.debugSegments=s.SegmentVector.simpleSegment(0,0,4,5);const x=new s.StructArrayLayout2i4;x.emplaceBack(-1,-1),x.emplaceBack(1,-1),x.emplaceBack(-1,1),x.emplaceBack(1,1),this.viewportBuffer=r.createVertexBuffer(x,s.posAttributes.members),this.viewportSegments=s.SegmentVector.simpleSegment(0,0,4,2);const b=new s.StructArrayLayout4i8;b.emplaceBack(0,0,0,0),b.emplaceBack(s.EXTENT,0,s.EXTENT,0),b.emplaceBack(0,s.EXTENT,0,s.EXTENT),b.emplaceBack(s.EXTENT,s.EXTENT,s.EXTENT,s.EXTENT),this.mercatorBoundsBuffer=r.createVertexBuffer(b,s.boundsAttributes.members),this.mercatorBoundsSegments=s.SegmentVector.simpleSegment(0,0,4,2);const S=new s.StructArrayLayout3ui6;S.emplaceBack(0,1,2),S.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=r.createIndexBuffer(S);const P=new s.StructArrayLayout1ui2;for(const F of[0,1,3,2,0])P.emplaceBack(F);this.debugIndexBuffer=r.createIndexBuffer(P),this.emptyTexture=new s.Texture(r,new s.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),r.gl.RGBA),this.identityMat=s.create();const z=this.context.gl;this.stencilClearMode=new s.StencilMode({func:z.ALWAYS,mask:0},0,255,z.ZERO,z.ZERO,z.ZERO),this.loadTimeStamps.push(s.window.performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(r){return r._makeTileBoundsBuffers(this.context,this.transform.projection),r._tileBoundsBuffer?{tileBoundsBuffer:r._tileBoundsBuffer,tileBoundsIndexBuffer:r._tileBoundsIndexBuffer,tileBoundsSegments:r._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const r=this.context,u=r.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear(),this.useProgram("clippingMask").draw(r,u.TRIANGLES,s.DepthMode.disabled,this.stencilClearMode,s.ColorMode.disabled,s.CullFaceMode.disabled,pu(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear())}_renderTileClippingMasks(r,u,g){if(!u||this.currentStencilSource===u.id||!r.isTileClipped()||!g||g.length===0)return;const x=[];let b=!1;if(this._tileClippingMaskIDs&&!this.terrain){for(const N of g)if(this._tileClippingMaskIDs.has(N.key)||(b=!0),this._skippedStencilTileIDs.has(N.key)){if(!u.getTile(N).getBucket(r))continue;this._skippedStencilTileIDs.delete(N.key),x.push(N)}if(!b&&x.length===0)return}const S=this.context,P=S.gl;S.setColorMode(s.ColorMode.disabled),S.setDepthMode(s.DepthMode.disabled);const z=this.useProgram("clippingMask"),F=N=>{const H=u.getTile(N),{tileBoundsBuffer:J,tileBoundsIndexBuffer:re,tileBoundsSegments:Q}=this.getTileBoundsBuffers(H);z.draw(S,P.TRIANGLES,s.DepthMode.disabled,new s.StencilMode({func:P.GREATER,mask:255},this._tileClippingMaskIDs.get(N.key)||0,255,P.KEEP,P.KEEP,P.REPLACE),s.ColorMode.disabled,s.CullFaceMode.disabled,pu(N.projMatrix),"$clipping",J,re,Q)};if(!b&&x.length>0)for(const N of x)F(N);else{(this._tileClippingMaskIDs.size===0||this.nextStencilID+g.length>256)&&this.clearStencil(),this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear();for(const N of g)this._tileClippingMaskIDs.set(N.key,this.nextStencilID++),u.getTile(N).getBucket(r)?F(N):this._skippedStencilTileIDs.add(N.key)}this._skippedStencilTileIDs.size===0&&(this.currentStencilSource=u.id)}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const r=this.nextStencilID++,u=this.context.gl;return new s.StencilMode({func:u.NOTEQUAL,mask:255},r,255,u.KEEP,u.KEEP,u.REPLACE)}stencilModeForClipping(r){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(r);const u=this.context.gl;return new s.StencilMode({func:u.EQUAL,mask:255},this._tileClippingMaskIDs.get(r.key)||0,0,u.KEEP,u.KEEP,u.REPLACE)}stencilConfigForOverlap(r){const u=this.context.gl,g=r.sort((S,P)=>P.overscaledZ-S.overscaledZ),x=g[g.length-1].overscaledZ,b=g[0].overscaledZ-x+1;if(b>1){this.currentStencilSource=void 0,this.nextStencilID+b>256&&this.clearStencil();const S={};for(let P=0;P=0;this.currentLayer--){const F=this.style._layers[g[this.currentLayer]],N=r._getLayerSourceCache(F);if(F.isSky())continue;const H=N?S[N.id]:void 0;this._renderTileClippingMasks(F,N,H),this.renderLayer(this,N,F,H)}if(this.renderPass="sky",(s.globeToMercatorTransition(this.transform.zoom)>0||this.transform.projection.name!=="globe")&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const H=r._getLayerSourceCache(N);H&&!N.isHidden(this.transform.zoom)&&(!F||F.getSource().maxzoom0?u.pop():null}isPatternMissing(r){if(!r)return!1;if(!r.from||!r.to)return!0;const u=this.imageManager.getPattern(r.from.toString()),g=this.imageManager.getPattern(r.to.toString());return!u||!g}currentGlobalDefines(){const r=this.terrain&&this.terrain.renderingToTexture,u=this.style&&this.style.fog,g=[];return this.terrain&&!this.terrain.renderingToTexture&&g.push("TERRAIN"),u&&!r&&u.getOpacity(this.transform.pitch)!==0&&g.push("FOG"),r&&g.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&g.push("OVERDRAW_INSPECTOR"),g}useProgram(r,u,g){this.cache=this.cache||{};const x=g||[],b=this.currentGlobalDefines().concat(x),S=Tl.cacheKey(r,b,u);return this.cache[S]||(this.cache[S]=new Tl(this.context,r,bl[r],u,Qn[r],b)),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 r=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(r.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=s.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new s.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(r,u,g){if(this.terrain&&this.terrain.renderingToTexture)return;const x=this.style.fog;if(x){const b=x.getOpacity(this.transform.pitch);b!==0&&u.setFogUniformValues(r,((S,P,z,F)=>{const N=P.properties.get("color"),H=S.frameCounter/1e3%1,J=[N.r/N.a,N.g/N.a,N.b/N.a,F];return{u_fog_matrix:z?S.transform.calculateFogTileMatrix(z):S.identityMat,u_fog_range:P.getFovAdjustedRange(S.transform._fov),u_fog_color:J,u_fog_horizon_blend:P.properties.get("horizon-blend"),u_fog_temporal_offset:H}})(this,x,g,b))}}setTileLoadedFlag(r){this.tileLoaded=r}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const r=this.context.gl,u=r.createTexture();return r.bindTexture(r.TEXTURE_2D,u),r.copyTexImage2D(r.TEXTURE_2D,0,r.RGBA,0,0,r.drawingBufferWidth,r.drawingBufferHeight,0),u}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const r=this.style&&this.style.fog;return!!r&&r.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const r=this._backgroundTiles,u=this._backgroundTiles={},g=this.transform.coveringTiles({tileSize:512});for(const x of g)u[x.key]=r[x.key]||new s.Tile(x,512,this.transform.tileZoom,this);return u}clearBackgroundTiles(){this._backgroundTiles={}}}class co{constructor(r=0,u=0,g=0,x=0){if(isNaN(r)||r<0||isNaN(u)||u<0||isNaN(g)||g<0||isNaN(x)||x<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=r,this.bottom=u,this.left=g,this.right=x}interpolate(r,u,g){return u.top!=null&&r.top!=null&&(this.top=s.number(r.top,u.top,g)),u.bottom!=null&&r.bottom!=null&&(this.bottom=s.number(r.bottom,u.bottom,g)),u.left!=null&&r.left!=null&&(this.left=s.number(r.left,u.left,g)),u.right!=null&&r.right!=null&&(this.right=s.number(r.right,u.right,g)),this}getCenter(r,u){const g=s.clamp((this.left+r-this.right)/2,0,r),x=s.clamp((this.top+u-this.bottom)/2,0,u);return new s.pointGeometry(g,x)}equals(r){return this.top===r.top&&this.bottom===r.bottom&&this.left===r.left&&this.right===r.right}clone(){return new co(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Om(f,r){const u=s.getColumn(f,3);s.fromQuat(f,r),s.setColumn(f,3,u)}function Gd(f,r){const u=s.identity$1([]);return s.rotateZ$1(u,u,-r),s.rotateX$1(u,u,-f),u}function Tu(f,r){const u=[f[0],f[1],0],g=[r[0],r[1],0];if(s.length(u)>=1e-15){const S=s.normalize([],u);s.scale$2(g,S,s.dot(g,S)),r[0]=g[0],r[1]=g[1]}const x=s.cross([],r,f);if(s.len(x)<1e-15)return null;const b=Math.atan2(-x[1],x[0]);return Gd(Math.atan2(Math.sqrt(f[0]*f[0]+f[1]*f[1]),-f[2]),b)}class Ll{constructor(r,u){this.position=r,this.orientation=u}get position(){return this._position}set position(r){if(r){const u=r instanceof s.MercatorCoordinate?r:new s.MercatorCoordinate(r[0],r[1],r[2]);this._renderWorldCopies&&(u.x=s.wrap(u.x,0,1)),this._position=u}else this._position=null}lookAtPoint(r,u){if(this.orientation=null,!this.position)return;const g=this._elevation?this._elevation.getAtPointOrZero(s.MercatorCoordinate.fromLngLat(r)):0,x=this.position,b=s.MercatorCoordinate.fromLngLat(r,g),S=[b.x-x.x,b.y-x.y,b.z-x.z];u||(u=[0,0,1]),u[2]=Math.abs(u[2]),this.orientation=Tu(S,u)}setPitchBearing(r,u){this.orientation=Gd(s.degToRad(r),s.degToRad(-u))}}class Dl{constructor(r,u){this._transform=s.identity([]),this.orientation=u,this.position=r}get mercatorPosition(){const r=this.position;return new s.MercatorCoordinate(r[0],r[1],r[2])}get position(){const r=s.getColumn(this._transform,3);return[r[0],r[1],r[2]]}set position(r){var u;r&&s.setColumn(this._transform,3,[(u=r)[0],u[1],u[2],1])}get orientation(){return this._orientation}set orientation(r){this._orientation=r||s.identity$1([]),r&&Om(this._transform,this._orientation)}getPitchBearing(){const r=this.forward(),u=this.right();return{bearing:Math.atan2(-u[1],u[0]),pitch:Math.atan2(Math.sqrt(r[0]*r[0]+r[1]*r[1]),-r[2])}}setPitchBearing(r,u){this._orientation=Gd(r,u),Om(this._transform,this._orientation)}forward(){const r=s.getColumn(this._transform,2);return[-r[0],-r[1],-r[2]]}up(){const r=s.getColumn(this._transform,1);return[-r[0],-r[1],-r[2]]}right(){const r=s.getColumn(this._transform,0);return[r[0],r[1],r[2]]}getCameraToWorld(r,u){const g=new Float64Array(16);return s.invert(g,this.getWorldToCamera(r,u)),g}getWorldToCameraPosition(r,u,g){const x=this.position;s.scale$2(x,x,-r);const b=new Float64Array(16);return s.fromScaling(b,[g,g,g]),s.translate(b,b,x),b[10]*=u,b}getWorldToCamera(r,u){const g=new Float64Array(16),x=new Float64Array(4),b=this.position;return s.conjugate(x,this._orientation),s.scale$2(b,b,-r),s.fromQuat(g,x),s.translate(g,g,b),g[1]*=-1,g[5]*=-1,g[9]*=-1,g[13]*=-1,g[8]*=u,g[9]*=u,g[10]*=u,g[11]*=u,g}getCameraToClipPerspective(r,u,g,x){const b=new Float64Array(16);return s.perspective(b,r,u,g,x),b}getDistanceToElevation(r){const u=r===0?0:s.mercatorZfromAltitude(r,this.position[1]),g=this.forward();return(u-this.position[2])/g[2]}clone(){return new Dl([...this.position],[...this.orientation])}}function Hd(f,r){const u=Il(f),g=function(b,S,P,z,F){const N=new s.LngLat(P.lng-180*uo,P.lat),H=new s.LngLat(P.lng+180*uo,P.lat),J=b.project(N.lng,N.lat),re=b.project(H.lng,H.lat),Q=-Math.atan2(re.y-J.y,re.x-J.x),X=s.MercatorCoordinate.fromLngLat(P);X.y=s.clamp(X.y,-.999975,.999975);const Ae=X.toLngLat(),fe=b.project(Ae.lng,Ae.lat),Te=s.MercatorCoordinate.fromLngLat(Ae);Te.x+=uo;const Se=Te.toLngLat(),Re=b.project(Se.lng,Se.lat),be=qd(Re.x-fe.x,Re.y-fe.y,Q),Fe=s.MercatorCoordinate.fromLngLat(Ae);Fe.y+=uo;const Qe=Fe.toLngLat(),at=b.project(Qe.lng,Qe.lat),dt=qd(at.x-fe.x,at.y-fe.y,Q),ut=Math.abs(be.x)/Math.abs(dt.y),Rt=s.identity([]);s.rotateZ(Rt,Rt,-Q*(1-(F?0:z)));const et=s.identity([]);return s.scale(et,et,[1,1-(1-ut)*z,1]),et[4]=-dt.x/dt.y*z,s.rotateZ(et,et,Q),s.multiply$1(et,Rt,et),et}(f.projection,0,f.center,u,r),x=Wd(f);return s.scale(g,g,[x,x,1]),g}function Wd(f){const r=f.projection,u=Il(f),g=jd(r,f.center),x=jd(r,s.LngLat.convert(r.center));return Math.pow(2,g*u+(1-u)*x)}function Il(f){const r=f.projection.range;if(!r)return 0;const u=Math.max(f.width,f.height),g=Math.log(u/1024)/Math.LN2;return s.smoothstep(r[0]+g,r[1]+g,f.zoom)}const uo=1/4e4;function jd(f,r){const u=s.clamp(r.lat,-s.MAX_MERCATOR_LATITUDE,s.MAX_MERCATOR_LATITUDE),g=new s.LngLat(r.lng-180*uo,u),x=new s.LngLat(r.lng+180*uo,u),b=f.project(g.lng,u),S=f.project(x.lng,u),P=s.MercatorCoordinate.fromLngLat(g),z=s.MercatorCoordinate.fromLngLat(x),F=S.x-b.x,N=S.y-b.y,H=z.x-P.x,J=z.y-P.y,re=Math.sqrt((H*H+J*J)/(F*F+N*N));return Math.log(re)/Math.LN2}function qd(f,r,u){const g=Math.cos(u),x=Math.sin(u);return{x:f*g-r*x,y:f*x+r*g}}class Eu{constructor(r,u,g,x,b,S,P){this.tileSize=512,this._renderWorldCopies=b===void 0||b,this._minZoom=r||0,this._maxZoom=u||22,this._minPitch=g==null?0:g,this._maxPitch=x==null?60:x,this.setProjection(S),this.setMaxBounds(P),this.width=0,this.height=0,this._center=new s.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 co,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new Dl,this._centerAltitude=0,this._centerAltitudeValidForExaggeration=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this._horizonShift=.1}clone(){const r=new Eu(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return r._elevation=this._elevation,r._centerAltitude=this._centerAltitude,r._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,r.tileSize=this.tileSize,r.width=this.width,r.height=this.height,r.cameraElevationReference=this.cameraElevationReference,r._center=this._center,r._setZoom(this.zoom),r._seaLevelZoom=this._seaLevelZoom,r.angle=this.angle,r._fov=this._fov,r._pitch=this._pitch,r._nearZ=this._nearZ,r._farZ=this._farZ,r._averageElevation=this._averageElevation,r._unmodified=this._unmodified,r._edgeInsets=this._edgeInsets.clone(),r._camera=this._camera.clone(),r._calcMatrices(),r.freezeTileCoverage=this.freezeTileCoverage,r}get elevation(){return this._elevation}set elevation(r){this._elevation!==r&&(this._elevation=r,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(r){const u=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||u)&&this._updateCameraOnTerrain(),(r||u)&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return s.pick(this.projection,["name","center","parallels"])}setProjection(r){r==null&&(r={name:"mercator"}),this.projectionOptions=r;const u=this.projection?this.getProjection():void 0;this.projection=s.getProjection(r);const g=this.getProjection();return E(u,g)?null:(this._calcMatrices(),g)}get minZoom(){return this._minZoom}set minZoom(r){this._minZoom!==r&&(this._minZoom=r,this.zoom=Math.max(this.zoom,r))}get maxZoom(){return this._maxZoom}set maxZoom(r){this._maxZoom!==r&&(this._maxZoom=r,this.zoom=Math.min(this.zoom,r))}get minPitch(){return this._minPitch}set minPitch(r){this._minPitch!==r&&(this._minPitch=r,this.pitch=Math.max(this.pitch,r))}get maxPitch(){return this._maxPitch}set maxPitch(r){this._maxPitch!==r&&(this._maxPitch=r,this.pitch=Math.min(this.pitch,r))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(r){r===void 0?r=!0:r===null&&(r=!1),this._renderWorldCopies=r}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const r=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(r))}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 s.pointGeometry(this.width,this.height)}get bearing(){return s.wrap(this.rotation,-180,180)}set bearing(r){this.rotation=r}get rotation(){return-this.angle/Math.PI*180}set rotation(r){const u=-r*Math.PI/180;var g;this.angle!==u&&(this._unmodified=!1,this.angle=u,this._calcMatrices(),this.rotationMatrix=(g=new s.ARRAY_TYPE(4),s.ARRAY_TYPE!=Float32Array&&(g[1]=0,g[2]=0),g[0]=1,g[3]=1,g),function(x,b,S){var P=b[0],z=b[1],F=b[2],N=b[3],H=Math.sin(S),J=Math.cos(S);x[0]=P*J+F*H,x[1]=z*J+N*H,x[2]=P*-H+F*J,x[3]=z*-H+N*J}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(r){const u=s.clamp(r,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==u&&(this._unmodified=!1,this._pitch=u,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(r){r=Math.max(.01,Math.min(60,r)),this._fov!==r&&(this._unmodified=!1,this._fov=r/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(r){this._averageElevation=r,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(r){const u=Math.min(Math.max(r,this.minZoom),this.maxZoom);this._zoom!==u&&(this._unmodified=!1,this._setZoom(u),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(r){this._zoom=r,this.scale=this.zoomScale(r),this.tileZoom=Math.floor(r),this.zoomFraction=r-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 r=this._elevation;this._centerAltitude=r.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=r.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 r=this._elevation,u=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],g=this.horizonLineFromTop();let x=0,b=0;for(let S=0;Sr.maxzoom&&(u=r.maxzoom);const S=this.locationCoordinate(this.center),P=this.center.lat,z=1<{const mn=new s.MercatorCoordinate(pt.x+25e-6,pt.y,pt.z),Xt=new s.MercatorCoordinate(pt.x,pt.y+25e-6,pt.z),Yt=pt.toLngLat(),vn=mn.toLngLat(),kn=Xt.toLngLat(),hn=this.locationCoordinate(Yt),Mn=this.locationCoordinate(vn),qn=this.locationCoordinate(kn),vi=Math.hypot(Mn.x-hn.x,Mn.y-hn.y),nr=Math.hypot(qn.x-hn.x,qn.y-hn.y);return Math.sqrt(vi*nr)*be/25e-6},Qe=pt=>{const qt=Se,mn=Re;return{aabb:s.tileAABB(this,z,0,0,0,pt,mn,qt,this.projection),zoom:0,x:0,y:0,minZ:mn,maxZ:qt,wrap:pt,fullyVisible:!1}},at=[];let dt=[];const ut=u,Rt=r.reparseOverscaled?g:u,et=pt=>pt*pt,zt=et((X-this._centerAltitude)*Q),Pt=pt=>{if(!this._elevation||!pt.tileID||!b)return;const qt=this._elevation.getMinMaxForTile(pt.tileID),mn=pt.aabb;qt?(mn.min[2]=qt.min,mn.max[2]=qt.max,mn.center[2]=(mn.min[2]+mn.max[2])/2):(pt.shouldSplit=Jt(pt),pt.shouldSplit||(mn.min[2]=mn.max[2]=mn.center[2]=this._centerAltitude))},Jt=pt=>{if(pt.zoom.85?1:hn}const vn=qt*qt+mn*mn+Xt;return vn{if(hn*et(.707)0;){const pt=at.pop(),qt=pt.x,mn=pt.y;let Xt=pt.fullyVisible;if(!Xt){const Yt=pt.aabb.intersects(J);if(Yt===0)continue;Xt=Yt===2}if(pt.zoom!==ut&&Jt(pt))for(let Yt=0;Yt<4;Yt++){const vn=(qt<<1)+Yt%2,kn=(mn<<1)+(Yt>>1),hn={aabb:b?pt.aabb.quadrant(Yt):s.tileAABB(this,z,pt.zoom+1,vn,kn,pt.wrap,pt.minZ,pt.maxZ,this.projection),zoom:pt.zoom+1,x:vn,y:kn,wrap:pt.wrap,fullyVisible:Xt,tileID:void 0,shouldSplit:void 0,minZ:pt.minZ,maxZ:pt.maxZ};x&&!N&&(hn.tileID=new s.OverscaledTileID(pt.zoom+1===ut?Rt:pt.zoom+1,pt.wrap,pt.zoom+1,vn,kn),Pt(hn)),at.push(hn)}else{const Yt=pt.zoom===ut?Rt:pt.zoom;if(r.minzoom&&r.minzoom>Yt)continue;const vn=F[0]-(.5+qt+(pt.wrap<{const Xt=[0,0,0,1],Yt=[s.EXTENT,s.EXTENT,0,1],vn=this.calculateFogTileMatrix(mn.tileID.toUnwrapped());s.transformMat4$1(Xt,Xt,vn),s.transformMat4$1(Yt,Yt,vn);const kn=s.getAABBPointSquareDist(Xt,Yt);if(kn===0)return!0;let hn=!1;const Mn=this._elevation;if(Mn&&kn>pt&&qt!==0){const qn=this.calculateProjMatrix(mn.tileID.toUnwrapped());let vi;r.isTerrainDEM||(vi=Mn.getMinMaxForTile(mn.tileID)),vi||(vi={min:Re,max:Se});const nr=s.furthestTileCorner(this.rotation),ir=[nr[0]*s.EXTENT,nr[1]*s.EXTENT,vi.max];s.transformMat4(ir,ir,qn),hn=(1-ir[1])*this.height*.5pt.distanceSq-qt.distanceSq).map(pt=>pt.tileID)}resize(r,u){this.width=r,this.height=u,this.pixelsToGLUnits=[2/r,-2/u],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(r){return Math.pow(2,r)}scaleZoom(r){return Math.log(r)/Math.LN2}project(r){const u=s.clamp(r.lat,-s.MAX_MERCATOR_LATITUDE,s.MAX_MERCATOR_LATITUDE),g=this.projection.project(r.lng,u);return new s.pointGeometry(g.x*this.worldSize,g.y*this.worldSize)}unproject(r){return this.projection.unproject(r.x/this.worldSize,r.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(r,u){let g,x;const b=this.centerPoint;if(this.projection.name==="globe"){const P=this.worldSize;g=(u.x-b.x)/P,x=(u.y-b.y)/P}else{const P=this.pointCoordinate(u),z=this.pointCoordinate(b);g=P.x-z.x,x=P.y-z.y}const S=this.locationCoordinate(r);this.setLocation(new s.MercatorCoordinate(S.x-g,S.y-x))}setLocation(r){this.center=this.coordinateLocation(r),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(r){return this.projection.locationPoint(this,r)}locationPoint3D(r){return this._coordinatePoint(this.locationCoordinate(r),!0)}pointLocation(r){return this.coordinateLocation(this.pointCoordinate(r))}pointLocation3D(r){return this.coordinateLocation(this.pointCoordinate3D(r))}locationCoordinate(r,u){const g=u?s.mercatorZfromAltitude(u,r.lat):void 0,x=this.projection.project(r.lng,r.lat);return new s.MercatorCoordinate(x.x,x.y,g)}coordinateLocation(r){return this.projection.unproject(r.x,r.y)}pointRayIntersection(r,u){const g=u!=null?u:this._centerAltitude,x=[r.x,r.y,0,1],b=[r.x,r.y,1,1];s.transformMat4$1(x,x,this.pixelMatrixInverse),s.transformMat4$1(b,b,this.pixelMatrixInverse);const S=b[3];s.scale$1(x,x,1/x[3]),s.scale$1(b,b,1/S);const P=x[2],z=b[2];return{p0:x,p1:b,t:P===z?0:(g-P)/(z-P)}}screenPointToMercatorRay(r){const u=[r.x,r.y,0,1],g=[r.x,r.y,1,1];return s.transformMat4$1(u,u,this.pixelMatrixInverse),s.transformMat4$1(g,g,this.pixelMatrixInverse),s.scale$1(u,u,1/u[3]),s.scale$1(g,g,1/g[3]),u[2]=s.mercatorZfromAltitude(u[2],this._center.lat)*this.worldSize,g[2]=s.mercatorZfromAltitude(g[2],this._center.lat)*this.worldSize,s.scale$1(u,u,1/this.worldSize),s.scale$1(g,g,1/this.worldSize),new s.Ray([u[0],u[1],u[2]],s.normalize([],s.sub([],g,u)))}rayIntersectionCoordinate(r){const{p0:u,p1:g,t:x}=r,b=s.mercatorZfromAltitude(u[2],this._center.lat),S=s.mercatorZfromAltitude(g[2],this._center.lat);return new s.MercatorCoordinate(s.number(u[0],g[0],x)/this.worldSize,s.number(u[1],g[1],x)/this.worldSize,s.number(b,S,x))}pointCoordinate(r,u=this._centerAltitude){return this.projection.pointCoordinate(this,r.x,r.y,u)}pointCoordinate3D(r){if(!this.elevation)return this.pointCoordinate(r);const u=this.elevation;let g=this.elevation.pointCoordinate(r);if(g)return new s.MercatorCoordinate(g[0],g[1],g[2]);let x=0,b=this.horizonLineFromTop();if(r.y>b)return this.pointCoordinate(r);const S=.02*b,P=r.clone();for(let z=0;z<10&&b-x>S;z++){P.y=s.number(x,b,.66);const F=u.pointCoordinate(P);F?(b=P.y,g=F):x=P.y}return g?new s.MercatorCoordinate(g[0],g[1],g[2]):this.pointCoordinate(r)}isPointAboveHorizon(r){if(this.elevation)return!this.elevation.pointCoordinate(r);{const u=this.horizonLineFromTop();return r.y0?new s.pointGeometry(x[0]/x[3],x[1]/x[3]):new s.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(r,u){const g=new s.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),x=new s.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),b=new s.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),S=new s.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let P=this.pointCoordinate(g,r),z=this.pointCoordinate(x,r);const F=this.pointCoordinate(b,u),N=this.pointCoordinate(S,u),H=(J,re)=>(re.y-J.y)/(re.x-J.x);return P.y>1&&z.y>=0?P=new s.MercatorCoordinate((1-N.y)/H(N,P)+N.x,1):P.y<0&&z.y<=1&&(P=new s.MercatorCoordinate(-N.y/H(N,P)+N.x,0)),z.y>1&&P.y>=0?z=new s.MercatorCoordinate((1-F.y)/H(F,z)+F.x,1):z.y<0&&P.y<=1&&(z=new s.MercatorCoordinate(-F.y/H(F,z)+F.x,0)),new s.LngLatBounds().extend(this.coordinateLocation(P)).extend(this.coordinateLocation(z)).extend(this.coordinateLocation(N)).extend(this.coordinateLocation(F))}_getBounds3D(){const r=this.elevation;if(!r.visibleDemTiles.length)return this._getBounds(0,0);const u=r.visibleDemTiles.reduce((g,x)=>{if(x.dem){const b=x.dem.tree;g.min=Math.min(g.min,b.minimums[0]),g.max=Math.max(g.max,b.maximums[0])}return g},{min:Number.MAX_VALUE,max:0});return this._getBounds(u.min*r.exaggeration(),u.max*r.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(r=!0){const u=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,g=this.height/2-u*(1-this._horizonShift);return r?Math.max(0,g):g}getMaxBounds(){return this.maxBounds}setMaxBounds(r){this.maxBounds=r,this.minLat=-s.MAX_MERCATOR_LATITUDE,this.maxLat=s.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,r&&(this.minLat=r.getSouth(),this.maxLat=r.getNorth(),this.minLng=r.getWest(),this.maxLng=r.getEast(),this.maxLngN&&(S=N-z),N-FJ&&(b=J-P),J-H.5?fe-1:fe,Te>.5?Te-1:Te,0]),this.alignedProjMatrix=Se,S=s.create(),s.scale(S,S,[this.width/2,-this.height/2,1]),s.translate(S,S,[1,-1,0]),this.labelPlaneMatrix=S,S=s.create(),s.scale(S,S,[1,-1,1]),s.translate(S,S,[-1,-1,0]),s.scale(S,S,[2/this.width,2/this.height,1]),this.glCoordMatrix=S,this.pixelMatrix=s.multiply$1(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},S=s.invert(new Float64Array(16),this.pixelMatrix),!S)throw new Error("failed to invert matrix");this.pixelMatrixInverse=S,this.globeMatrix=this.projection.name==="globe"?s.calculateGlobeMatrix(this):S,this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const r=this.cameraWorldSize,u=this.cameraPixelsPerMeter,g=this._camera.position,x=1/this.height,b=[r,r,u];s.scale$2(b,b,x),s.scale$2(g,g,-1),s.multiply$2(g,g,b);const S=s.create();s.translate(S,S,g),s.scale(S,S,b),this.mercatorFogMatrix=S,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(r,u,x)}_computeCameraPosition(r){const u=(r=r||this.pixelsPerMeter)/this.pixelsPerMeter,g=this._camera.forward(),x=this.point,b=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*u-r/this.worldSize*this._centerAltitude;return[x.x/this.worldSize-g[0]*b,x.y/this.worldSize-g[1]*b,r/this.worldSize*this._centerAltitude-g[2]*b]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(r){const u=this._maxCameraBoundsDistance()*Math.cos(this._pitch),g=r[2];let x=1;g>0&&(x=Math.min((u-this._camera.position[2])/g,1)),this._camera.position=s.scaleAndAdd([],this._camera.position,r,x),this._updateStateFromCamera(),this.projection.wrap&&(this.center=this.center.wrap())}_updateStateFromCamera(){const r=this._camera.position,u=this._camera.forward(),{pitch:g,bearing:x}=this._camera.getPitchBearing(),b=s.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,S=this._mercatorZfromZoom(this._maxZoom)*Math.cos(s.degToRad(this._maxPitch)),P=Math.max((r[2]-b)/Math.cos(g),S),z=this._zoomFromMercatorZ(P);s.scaleAndAdd(r,r,u,P),this._pitch=s.clamp(g,s.degToRad(this.minPitch),s.degToRad(this.maxPitch)),this.angle=s.wrap(x,-Math.PI,Math.PI),this._setZoom(s.clamp(z,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new s.MercatorCoordinate(r[0],r[1],r[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(r){return Math.pow(2,r)*this.tileSize}_mercatorZfromZoom(r){return this.cameraToCenterDistance/this._worldSizeFromZoom(r)}_minimumHeightOverTerrain(){const r=Math.min((this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(r)}_zoomFromMercatorZ(r){return this.scaleZoom(this.cameraToCenterDistance/(r*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(s.warnOnce("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."),1))}anyCornerOffEdge(r,u){const g=Math.min(r.x,u.x),x=Math.max(r.x,u.x),b=Math.min(r.y,u.y),S=Math.max(r.y,u.y);if(bF||J.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+s.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new s.pointGeometry(0,0),new s.pointGeometry(this.width,this.height))}zoomDeltaToMovement(r,u){const g=s.length(s.sub([],this._camera.position,r)),x=this._zoomFromMercatorZ(g)+u;return g-this._mercatorZfromZoom(x)}getCameraPoint(){const r=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new s.pointGeometry(0,r))}}function Zd(f,r){let u=!1,g=null;const x=()=>{g=null,u&&(f(),g=setTimeout(x,r),u=!1)};return()=>(u=!0,g||x(),g)}class Nm{constructor(r){this._hashName=r&&encodeURIComponent(r),s.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Zd(this._updateHashUnthrottled.bind(this),300)}addTo(r){return this._map=r,s.window.addEventListener("hashchange",this._onHashChange,!1),r.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),s.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(r){const u=this._map;if(!u)return"";const g=u.getCenter(),x=Math.round(100*u.getZoom())/100,b=Math.ceil((x*Math.LN2+Math.log(512/360/.5))/Math.LN10),S=Math.pow(10,b),P=Math.round(g.lng*S)/S,z=Math.round(g.lat*S)/S,F=u.getBearing(),N=u.getPitch();let H="";if(H+=r?`/${P}/${z}/${x}`:`${x}/${z}/${P}`,(F||N)&&(H+="/"+Math.round(10*F)/10),N&&(H+=`/${Math.round(N)}`),this._hashName){const J=this._hashName;let re=!1;const Q=s.window.location.hash.slice(1).split("&").map(X=>{const Ae=X.split("=")[0];return Ae===J?(re=!0,`${Ae}=${H}`):X}).filter(X=>X);return re||Q.push(`${J}=${H}`),`#${Q.join("&")}`}return`#${H}`}_getCurrentHash(){const r=s.window.location.hash.replace("#","");if(this._hashName){let u;return r.split("&").map(g=>g.split("=")).forEach(g=>{g[0]===this._hashName&&(u=g)}),(u&&u[1]||"").split("/")}return r.split("/")}_onHashChange(){const r=this._map;if(!r)return!1;const u=this._getCurrentHash();if(u.length>=3&&!u.some(g=>isNaN(g))){const g=r.dragRotate.isEnabled()&&r.touchZoomRotate.isEnabled()?+(u[3]||0):r.getBearing();return r.jumpTo({center:[+u[2],+u[1]],zoom:+u[0],bearing:g,pitch:+(u[4]||0)}),!0}return!1}_updateHashUnthrottled(){const r=s.window.location.href.replace(/(#.+)?$/,this.getHashString());s.window.history.replaceState(s.window.history.state,null,r)}}const Oa={linearity:.3,easing:s.bezier(0,0,.3,1)},Um=s.extend({deceleration:2500,maxSpeed:1400},Oa),Vm=s.extend({deceleration:20,maxSpeed:1400},Oa),Gm=s.extend({deceleration:1e3,maxSpeed:360},Oa),Hm=s.extend({deceleration:1e3,maxSpeed:90},Oa);class Wm{constructor(r){this._map=r,this.clear()}clear(){this._inertiaBuffer=[]}record(r){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:s.exported.now(),settings:r})}_drainInertiaBuffer(){const r=this._inertiaBuffer,u=s.exported.now();for(;r.length>0&&u-r[0].time>160;)r.shift()}_onMoveEnd(r){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const u={zoom:0,bearing:0,pitch:0,pan:new s.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:b}of this._inertiaBuffer)u.zoom+=b.zoomDelta||0,u.bearing+=b.bearingDelta||0,u.pitch+=b.pitchDelta||0,b.panDelta&&u.pan._add(b.panDelta),b.around&&(u.around=b.around),b.pinchAround&&(u.pinchAround=b.pinchAround);const g=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,x={};if(u.pan.mag()){const b=ji(u.pan.mag(),g,s.extend({},Um,r||{}));x.offset=u.pan.mult(b.amount/u.pan.mag()),x.center=this._map.transform.center,Rl(x,b)}if(u.zoom){const b=ji(u.zoom,g,Vm);x.zoom=this._map.transform.zoom+b.amount,Rl(x,b)}if(u.bearing){const b=ji(u.bearing,g,Gm);x.bearing=this._map.transform.bearing+s.clamp(b.amount,-179,179),Rl(x,b)}if(u.pitch){const b=ji(u.pitch,g,Hm);x.pitch=this._map.transform.pitch+b.amount,Rl(x,b)}if(x.zoom||x.bearing){const b=u.pinchAround===void 0?u.around:u.pinchAround;x.around=b?this._map.unproject(b):this._map.getCenter()}return this.clear(),x.noMoveStart=!0,x}}function Rl(f,r){(!f.duration||f.durationu.unproject(z)),P=b.reduce((z,F,N,H)=>z.add(F.div(H.length)),new s.pointGeometry(0,0));super(r,{points:b,point:P,lngLats:S,lngLat:u.unproject(P),originalEvent:g}),this._defaultPrevented=!1}}class Wy extends s.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,u,g){super(r,{originalEvent:g}),this._defaultPrevented=!1}}class jy{constructor(r,u){this._map=r,this._clickTolerance=u.clickTolerance}reset(){this._mousedownPos=void 0}wheel(r){return this._firePreventable(new Wy(r.type,this._map,r))}mousedown(r,u){return this._mousedownPos=u,this._firePreventable(new Dr(r.type,this._map,r))}mouseup(r){this._map.fire(new Dr(r.type,this._map,r))}preclick(r){const u=s.extend({},r);u.type="preclick",this._map.fire(new Dr(u.type,this._map,u))}click(r,u){this._mousedownPos&&this._mousedownPos.dist(u)>=this._clickTolerance||(this.preclick(r),this._map.fire(new Dr(r.type,this._map,r)))}dblclick(r){return this._firePreventable(new Dr(r.type,this._map,r))}mouseover(r){this._map.fire(new Dr(r.type,this._map,r))}mouseout(r){this._map.fire(new Dr(r.type,this._map,r))}touchstart(r){return this._firePreventable(new zl(r.type,this._map,r))}touchmove(r){this._map.fire(new zl(r.type,this._map,r))}touchend(r){this._map.fire(new zl(r.type,this._map,r))}touchcancel(r){this._map.fire(new zl(r.type,this._map,r))}_firePreventable(r){if(this._map.fire(r),r.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Na{constructor(r){this._map=r}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(r){this._map.fire(new Dr(r.type,this._map,r))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Dr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(r){this._delayContextMenu?this._contextMenuEvent=r:this._map.fire(new Dr(r.type,this._map,r)),this._map.listens("contextmenu")&&r.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class jm{constructor(r,u){this._map=r,this._el=r.getCanvasContainer(),this._container=r.getContainer(),this._clickTolerance=u.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(r,u){this.isEnabled()&&r.shiftKey&&r.button===0&&(q(),this._startPos=this._lastPos=u,this._active=!0)}mousemoveWindow(r,u){if(!this._active)return;const g=u;if(this._lastPos.equals(g)||!this._box&&g.dist(this._startPos){this._box&&(this._box.style.transform=`translate(${b}px,${P}px)`,this._box.style.width=S-b+"px",this._box.style.height=z-P+"px")})}mouseupWindow(r,u){if(!this._active||r.button!==0)return;const g=this._startPos,x=u;if(this.reset(),Ce(),g.x!==x.x||g.y!==x.y)return this._map.fire(new s.Event("boxzoomend",{originalEvent:r})),{cameraAnimation:b=>b.fitScreenCoordinates(g,x,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",r)}keydown(r){this._active&&r.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",r))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),ee(),delete this._startPos,delete this._lastPos}_fireEvent(r,u){return this._map.fire(new s.Event(r,{originalEvent:u}))}}function ho(f,r){const u={};for(let g=0;gthis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=r.timeStamp),g.length===this.numTouches&&(this.centroid=function(x){const b=new s.pointGeometry(0,0);for(const S of x)b._add(S);return b.div(x.length)}(u),this.touches=ho(g,u)))}touchmove(r,u,g){if(this.aborted||!this.centroid)return;const x=ho(g,u);for(const b in this.touches){const S=this.touches[b],P=x[b];(!P||P.dist(S)>30)&&(this.aborted=!0)}}touchend(r,u,g){if((!this.centroid||r.timeStamp-this.startTime>500)&&(this.aborted=!0),g.length===0){const x=!this.aborted&&this.centroid;if(this.reset(),x)return x}}}class Cs{constructor(r){this.singleTap=new Ma(r),this.numTaps=r.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(r,u,g){this.singleTap.touchstart(r,u,g)}touchmove(r,u,g){this.singleTap.touchmove(r,u,g)}touchend(r,u,g){const x=this.singleTap.touchend(r,u,g);if(x){const b=r.timeStamp-this.lastTime<500,S=!this.lastTap||this.lastTap.dist(x)<30;if(b&&S||this.reset(),this.count++,this.lastTime=r.timeStamp,this.lastTap=x,this.count===this.numTaps)return this.reset(),x}}}class jt{constructor(){this._zoomIn=new Cs({numTouches:1,numTaps:2}),this._zoomOut=new Cs({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(r,u,g){this._zoomIn.touchstart(r,u,g),this._zoomOut.touchstart(r,u,g)}touchmove(r,u,g){this._zoomIn.touchmove(r,u,g),this._zoomOut.touchmove(r,u,g)}touchend(r,u,g){const x=this._zoomIn.touchend(r,u,g),b=this._zoomOut.touchend(r,u,g);return x?(this._active=!0,r.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:S=>S.easeTo({duration:300,zoom:S.getZoom()+1,around:S.unproject(x)},{originalEvent:r})}):b?(this._active=!0,r.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:S=>S.easeTo({duration:300,zoom:S.getZoom()-1,around:S.unproject(b)},{originalEvent:r})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const qm={0:1,2:2};class Su{constructor(r){this.reset(),this._clickTolerance=r.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(r,u){return!1}_move(r,u){return{}}mousedown(r,u){if(this._lastPoint)return;const g=ue(r);this._correctButton(r,g)&&(this._lastPoint=u,this._eventButton=g)}mousemoveWindow(r,u){const g=this._lastPoint;if(g){if(r.preventDefault(),this._eventButton!=null&&function(x,b){const S=qm[b];return x.buttons===void 0||(x.buttons&S)!==S}(r,this._eventButton))this.reset();else if(this._moved||!(u.dist(g)0&&(this._active=!0);const x=ho(g,u),b=new s.pointGeometry(0,0),S=new s.pointGeometry(0,0);let P=0;for(const F in x){const N=x[F],H=this._touches[F];H&&(b._add(N),S._add(N.sub(H)),P++,x[F]=N)}if(this._touches=x,P{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")},500)}}class Au{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(r){}_move(r,u,g){return{}}touchstart(r,u,g){this._firstTwoTouches||g.length<2||(this._firstTwoTouches=[g[0].identifier,g[1].identifier],this._start([u[0],u[1]]))}touchmove(r,u,g){const x=this._firstTwoTouches;if(!x)return;r.preventDefault();const[b,S]=x,P=Bl(g,u,b),z=Bl(g,u,S);if(!P||!z)return;const F=this._aroundCenter?null:P.add(z).div(2);return this._move([P,z],F,r)}touchend(r,u,g){if(!this._firstTwoTouches)return;const[x,b]=this._firstTwoTouches,S=Bl(g,u,x),P=Bl(g,u,b);S&&P||(this._active&&Ce(),this.reset())}touchcancel(){this.reset()}enable(r){this._enabled=!0,this._aroundCenter=!!r&&r.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Bl(f,r,u){for(let g=0;gMath.abs(f.x)}class Pu extends Au{constructor(r){super(),this._map=r}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(r){this._lastPoints=r,Fl(r[0].sub(r[1]))&&(this._valid=!1)}_move(r,u,g){const x=this._lastPoints;if(!x)return;const b=r[0].sub(x[0]),S=r[1].sub(x[1]);return this._map._cooperativeGestures&&g.touches.length<3||(this._valid=this.gestureBeginsVertically(b,S,g.timeStamp),!this._valid)?void 0:(this._lastPoints=r,this._active=!0,{pitchDelta:(b.y+S.y)/2*-.5})}gestureBeginsVertically(r,u,g){if(this._valid!==void 0)return this._valid;const x=r.mag()>=2,b=u.mag()>=2;if(!x&&!b)return;if(!x||!b)return this._firstMove==null&&(this._firstMove=g),g-this._firstMove<100&&void 0;const S=r.y>0==u.y>0;return Fl(r)&&Fl(u)&&S}}const Ym={panStep:100,bearingStep:15,pitchStep:10};class $m{constructor(){const r=Ym;this._panStep=r.panStep,this._bearingStep=r.bearingStep,this._pitchStep=r.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(r){if(r.altKey||r.ctrlKey||r.metaKey)return;let u=0,g=0,x=0,b=0,S=0;switch(r.keyCode){case 61:case 107:case 171:case 187:u=1;break;case 189:case 109:case 173:u=-1;break;case 37:r.shiftKey?g=-1:(r.preventDefault(),b=-1);break;case 39:r.shiftKey?g=1:(r.preventDefault(),b=1);break;case 38:r.shiftKey?x=1:(r.preventDefault(),S=-1);break;case 40:r.shiftKey?x=-1:(r.preventDefault(),S=1);break;default:return}return this._rotationDisabled&&(g=0,x=0),{cameraAnimation:P=>{const z=P.getZoom();P.easeTo({duration:300,easeId:"keyboardHandler",easing:Jm,zoom:u?Math.round(z)+u*(r.shiftKey?2:1):z,bearing:P.getBearing()+g*this._bearingStep,pitch:P.getPitch()+x*this._pitchStep,offset:[-b*this._panStep,-S*this._panStep],center:P.getCenter()},{originalEvent:r})}}}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 Jm(f){return f*(2-f)}const Jd=4.000244140625;class Km{constructor(r,u){this._map=r,this._el=r.getCanvasContainer(),this._handler=u,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,s.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen"],this)}setZoomRate(r){this._defaultZoomRate=r}setWheelZoomRate(r){this._wheelZoomRate=r}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(r){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!r&&r.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(r){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(r.ctrlKey||r.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let u=r.deltaMode===s.window.WheelEvent.DOM_DELTA_LINE?40*r.deltaY:r.deltaY;const g=s.exported.now(),x=g-(this._lastWheelEventTime||0);this._lastWheelEventTime=g,u!==0&&u%Jd==0?this._type="wheel":u!==0&&Math.abs(u)<4?this._type="trackpad":x>400?(this._type=null,this._lastValue=u,this._timeout=setTimeout(this._onTimeout,40,r)):this._type||(this._type=Math.abs(x*u)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,u+=this._lastValue)),r.shiftKey&&u&&(u/=4),this._type&&(this._lastWheelEvent=r,this._delta-=u,this._active||this._start(r)),r.preventDefault()}_onTimeout(r){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(r)}_start(r){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 u=K(this._el,r);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:u,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 r=this._map.transform,u=()=>r._terrainEnabled()&&this._aroundCoord?r.computeZoomRelativeTo(this._aroundCoord):r.zoom;if(this._delta!==0){const z=this._type==="wheel"&&Math.abs(this._delta)>Jd?this._wheelZoomRate:this._defaultZoomRate;let F=2/(1+Math.exp(-Math.abs(this._delta*z)));this._delta<0&&F!==0&&(F=1/F);const N=u(),H=Math.pow(2,N),J=typeof this._targetZoom=="number"?r.zoomScale(this._targetZoom):H;this._targetZoom=Math.min(r.maxZoom,Math.max(r.minZoom,r.scaleZoom(J*F))),this._type==="wheel"&&(this._startZoom=u(),this._easing=this._smoothOutEasing(200)),this._delta=0}const g=typeof this._targetZoom=="number"?this._targetZoom:u(),x=this._startZoom,b=this._easing;let S,P=!1;if(this._type==="wheel"&&x&&b){const z=Math.min((s.exported.now()-this._lastWheelEventTime)/200,1),F=b(z);S=s.number(x,g,F),z<1?this._frameId||(this._frameId=!0):P=!0}else S=g,P=!0;return this._active=!0,P&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!P,zoomDelta:S-u(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(r){let u=s.ease;if(this._prevEase){const g=this._prevEase,x=(s.exported.now()-g.start)/g.duration,b=g.easing(x+.01)-g.easing(x),S=.27/Math.sqrt(b*b+1e-4)*.01,P=Math.sqrt(.0729-S*S);u=s.bezier(S,P,.25,1)}return this._prevEase={start:s.exported.now(),duration:r,easing:u},u}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=L("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(s.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!!s.window.document.fullscreenElement||!!s.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 Qm{constructor(r,u){this._clickZoom=r,this._tapZoom=u}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 eg{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(r,u){return r.preventDefault(),{cameraAnimation:g=>{g.easeTo({duration:300,zoom:g.getZoom()+(r.shiftKey?-1:1),around:g.unproject(u)},{originalEvent:r})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Kd{constructor(){this._tap=new Cs({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(r,u,g){this._swipePoint||(this._tapTime&&r.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?g.length>0&&(this._swipePoint=u[0],this._swipeTouch=g[0].identifier):this._tap.touchstart(r,u,g))}touchmove(r,u,g){if(this._tapTime){if(this._swipePoint){if(g[0].identifier!==this._swipeTouch)return;const x=u[0],b=x.y-this._swipePoint.y;return this._swipePoint=x,r.preventDefault(),this._active=!0,{zoomDelta:b/128}}}else this._tap.touchmove(r,u,g)}touchend(r,u,g){this._tapTime?this._swipePoint&&g.length===0&&this.reset():this._tap.touchend(r,u,g)&&(this._tapTime=r.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class tg{constructor(r,u,g){this._el=r,this._mousePan=u,this._touchPan=g}enable(r){this._inertiaOptions=r||{},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 ng{constructor(r,u,g){this._pitchWithRotate=r.pitchWithRotate,this._mouseRotate=u,this._mousePitch=g}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 ig{constructor(r,u,g,x){this._el=r,this._touchZoom=u,this._touchRotate=g,this._tapDragZoom=x,this._rotationDisabled=!1,this._enabled=!0}enable(r){this._touchZoom.enable(r),this._rotationDisabled||this._touchRotate.enable(r),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 Ol=f=>f.zoom||f.drag||f.pitch||f.rotate;class Qd extends s.Event{}class rg{constructor(){this.constants=[1,1,.01],this.radius=0}setup(r,u){const g=s.sub([],u,r);this.radius=s.length(g[2]<0?s.div([],g,this.constants):[g[0],g[1],0])}projectRay(r){s.div(r,r,this.constants),s.normalize(r,r),s.mul$1(r,r,this.constants);const u=s.scale$2([],r,this.radius);if(u[2]>0){const g=s.scale$2([],[0,0,1],s.dot(u,[0,0,1])),x=s.scale$2([],s.normalize([],[u[0],u[1],0]),this.radius),b=s.add([],u,s.scale$2([],s.sub([],s.add([],x,g),u),2));u[0]=b[0],u[1]=b[1]}return u}}function Ls(f){return f.panDelta&&f.panDelta.mag()||f.zoomDelta||f.bearingDelta||f.pitchDelta}class ag{constructor(r,u){this._map=r,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Wm(r),this._bearingSnap=u.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new rg,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(u),s.bindAll(["handleEvent","handleWindowEvent"],this);const g=this._el;this._listeners=[[g,"touchstart",{passive:!0}],[g,"touchmove",{passive:!1}],[g,"touchend",void 0],[g,"touchcancel",void 0],[g,"mousedown",void 0],[g,"mousemove",void 0],[g,"mouseup",void 0],[s.window.document,"mousemove",{capture:!0}],[s.window.document,"mouseup",void 0],[g,"mouseover",void 0],[g,"mouseout",void 0],[g,"dblclick",void 0],[g,"click",void 0],[g,"keydown",{capture:!1}],[g,"keyup",void 0],[g,"wheel",{passive:!1}],[g,"contextmenu",void 0],[s.window,"blur",void 0]];for(const[x,b,S]of this._listeners)x.addEventListener(b,x===s.window.document?this.handleWindowEvent:this.handleEvent,S)}destroy(){for(const[r,u,g]of this._listeners)r.removeEventListener(u,r===s.window.document?this.handleWindowEvent:this.handleEvent,g)}_addDefaultHandlers(r){const u=this._map,g=u.getCanvasContainer();this._add("mapEvent",new jy(u,r));const x=u.boxZoom=new jm(u,r);this._add("boxZoom",x);const b=new jt,S=new eg;u.doubleClickZoom=new Qm(S,b),this._add("tapZoom",b),this._add("clickZoom",S);const P=new Kd;this._add("tapDragZoom",P);const z=u.touchPitch=new Pu(u);this._add("touchPitch",z);const F=new Ps(r),N=new Xd(r);u.dragRotate=new ng(r,F,N),this._add("mouseRotate",F,["mousePitch"]),this._add("mousePitch",N,["mouseRotate"]);const H=new kl(r),J=new Zm(u,r);u.dragPan=new tg(g,H,J),this._add("mousePan",H),this._add("touchPan",J,["touchZoom","touchRotate"]);const re=new Cu,Q=new Xm;u.touchZoomRotate=new ig(g,Q,re,P),this._add("touchRotate",re,["touchPan","touchZoom"]),this._add("touchZoom",Q,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Na(u));const X=u.scrollZoom=new Km(u,this);this._add("scrollZoom",X,["mousePan"]);const Ae=u.keyboard=new $m;this._add("keyboard",Ae);for(const fe of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])r.interactive&&r[fe]&&u[fe].enable(r[fe])}_add(r,u,g){this._handlers.push({handlerName:r,handler:u,allowed:g}),this._handlersById[r]=u}stop(r){if(!this._updatingCamera){for(const{handler:u}of this._handlers)u.reset();this._inertia.clear(),this._fireEvents({},{},r),this._changes=[]}}isActive(){for(const{handler:r}of this._handlers)if(r.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Ol(this._eventsInProgress)||this.isZooming()}_blockedByActive(r,u,g){for(const x in r)if(x!==g&&(!u||u.indexOf(x)<0))return!0;return!1}handleWindowEvent(r){this.handleEvent(r,`${r.type}Window`)}_getMapTouches(r){const u=[];for(const g of r)this._el.contains(g.target)&&u.push(g);return u}handleEvent(r,u){this._updatingCamera=!0;const g=r.type==="renderFrame",x=g?void 0:r,b={needsRenderFrame:!1},S={},P={},z=r.touches?this._getMapTouches(r.touches):void 0,F=z?ie(this._el,z):g?void 0:K(this._el,r);for(const{handlerName:J,handler:re,allowed:Q}of this._handlers){if(!re.isEnabled())continue;let X;this._blockedByActive(P,Q,J)?re.reset():re[u||r.type]&&(X=re[u||r.type](r,F,z),this.mergeHandlerResult(b,S,X,J,x),X&&X.needsRenderFrame&&this._triggerRenderFrame()),(X||re.isActive())&&(P[J]=re)}const N={};for(const J in this._previousActiveHandlers)P[J]||(N[J]=x);this._previousActiveHandlers=P,(Object.keys(N).length||Ls(b))&&(this._changes.push([b,S,N]),this._triggerRenderFrame()),(Object.keys(P).length||Ls(b))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:H}=b;H&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],H(this._map))}mergeHandlerResult(r,u,g,x,b){if(!g)return;s.extend(r,g);const S={handlerName:x,originalEvent:g.originalEvent||b};g.zoomDelta!==void 0&&(u.zoom=S),g.panDelta!==void 0&&(u.drag=S),g.pitchDelta!==void 0&&(u.pitch=S),g.bearingDelta!==void 0&&(u.rotate=S)}_applyChanges(){const r={},u={},g={};for(const[x,b,S]of this._changes)x.panDelta&&(r.panDelta=(r.panDelta||new s.pointGeometry(0,0))._add(x.panDelta)),x.zoomDelta&&(r.zoomDelta=(r.zoomDelta||0)+x.zoomDelta),x.bearingDelta&&(r.bearingDelta=(r.bearingDelta||0)+x.bearingDelta),x.pitchDelta&&(r.pitchDelta=(r.pitchDelta||0)+x.pitchDelta),x.around!==void 0&&(r.around=x.around),x.aroundCoord!==void 0&&(r.aroundCoord=x.aroundCoord),x.pinchAround!==void 0&&(r.pinchAround=x.pinchAround),x.noInertia&&(r.noInertia=x.noInertia),s.extend(u,b),s.extend(g,S);this._updateMapTransform(r,u,g),this._changes=[]}_updateMapTransform(r,u,g){const x=this._map,b=x.transform,S=Te=>[Te.x,Te.y,Te.z];if((Te=>{const Se=this._eventsInProgress.drag;return Se&&!this._handlersById[Se.handlerName].isActive()})()&&!Ls(r)){const Te=b.zoom;b.cameraElevationReference="sea",b.recenterOnTerrain(),b.cameraElevationReference="ground",Te!==b.zoom&&this._map._update(!0)}if(!Ls(r))return void this._fireEvents(u,g,!0);let{panDelta:P,zoomDelta:z,bearingDelta:F,pitchDelta:N,around:H,aroundCoord:J,pinchAround:re}=r;re!==void 0&&(H=re),(Te=>u.drag&&!this._eventsInProgress.drag)()&&H&&(this._dragOrigin=S(b.pointCoordinate3D(H)),this._trackingEllipsoid.setup(b._camera.position,this._dragOrigin)),b.cameraElevationReference="sea",x._stop(!0),H=H||x.transform.centerPoint,F&&(b.bearing+=F),N&&(b.pitch+=N),b._updateCameraState();const Q=[0,0,0];if(P){const Te=b.pointCoordinate(H);if(b.projection.name==="globe"){const Se=s.latFromMercatorY(Te.y),Re=b.center.lat,be=Math.min(s.mercatorZfromAltitude(1,Se)/s.mercatorZfromAltitude(1,Re),2);P=P.rotate(-b.angle),Q[0]=-P.x/b.worldSize*be,Q[1]=-P.y/b.worldSize*be}else{const Se=b.pointCoordinate(H.sub(P));Te&&Se&&(Q[0]=Se.x-Te.x,Q[1]=Se.y-Te.y)}}const X=b.zoom,Ae=[0,0,0];if(z){const Te=S(J||b.pointCoordinate3D(H)),Se={dir:s.normalize([],s.sub([],Te,b._camera.position))};if(Se.dir[2]<0){const Re=b.zoomDeltaToMovement(Te,z);s.scale$2(Ae,Se.dir,Re)}}const fe=s.add(Q,Q,Ae);b._translateCameraConstrained(fe),z&&Math.abs(b.zoom-X)>1e-4&&b.recenterOnTerrain(),b.cameraElevationReference="ground",this._map._update(),r.noInertia||this._inertia.record(r),this._fireEvents(u,g,!0)}_fireEvents(r,u,g){const x=Ol(this._eventsInProgress),b=Ol(r),S={};for(const N in r){const{originalEvent:H}=r[N];this._eventsInProgress[N]||(S[`${N}start`]=H),this._eventsInProgress[N]=r[N]}!x&&b&&this._fireEvent("movestart",b.originalEvent);for(const N in S)this._fireEvent(N,S[N]);b&&this._fireEvent("move",b.originalEvent);for(const N in r){const{originalEvent:H}=r[N];this._fireEvent(N,H)}const P={};let z;for(const N in this._eventsInProgress){const{handlerName:H,originalEvent:J}=this._eventsInProgress[N];this._handlersById[H].isActive()||(delete this._eventsInProgress[N],z=u[H]||J,P[`${N}end`]=z)}for(const N in P)this._fireEvent(N,P[N]);const F=Ol(this._eventsInProgress);if(g&&(x||b)&&!F){this._updatingCamera=!0;const N=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),H=J=>J!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Qd("renderFrame",{timeStamp:r})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const Lu="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class ep extends s.Evented{constructor(r,u){super(),this._moving=!1,this._zooming=!1,this.transform=r,this._bearingSnap=u.bearingSnap,s.bindAll(["_renderFrameCallback"],this)}getCenter(){return new s.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(r,u){return this.jumpTo({center:r},u)}panBy(r,u,g){return r=s.pointGeometry.convert(r).mult(-1),this.panTo(this.transform.center,s.extend({offset:r},u),g)}panTo(r,u,g){return this.easeTo(s.extend({center:r},u),g)}getZoom(){return this.transform.zoom}setZoom(r,u){return this.jumpTo({zoom:r},u),this}zoomTo(r,u,g){return this.easeTo(s.extend({zoom:r},u),g)}zoomIn(r,u){return this.zoomTo(this.getZoom()+1,r,u),this}zoomOut(r,u){return this.zoomTo(this.getZoom()-1,r,u),this}getBearing(){return this.transform.bearing}setBearing(r,u){return this.jumpTo({bearing:r},u),this}getPadding(){return this.transform.padding}setPadding(r,u){return this.jumpTo({padding:r},u),this}rotateTo(r,u,g){return this.easeTo(s.extend({bearing:r},u),g)}resetNorth(r,u){return this.rotateTo(0,s.extend({duration:1e3},r),u),this}resetNorthPitch(r,u){return this.easeTo(s.extend({bearing:0,pitch:0,duration:1e3},r),u),this}snapToNorth(r,u){return Math.abs(this.getBearing())ut=>{if(Se&&(dt.zoom=s.number(x,z,ut)),Re&&(dt.bearing=s.number(b,F,ut)),be&&(dt.pitch=s.number(S,N,ut)),Fe&&(dt.interpolatePadding(P,H,ut),re=dt.centerPoint.add(J)),fe)dt.setLocationAtPoint(fe,Te);else{const Rt=dt.zoomScale(dt.zoom-x),et=z>x?Math.min(2,Ae):Math.max(.5,Ae),zt=Math.pow(et,1-ut),Pt=dt.unproject(Q.add(X.mult(ut*zt)).mult(Rt));dt.setLocationAtPoint(dt.renderWorldCopies?Pt.wrap():Pt,re)}return r.preloadOnly||this._fireMoveEvents(u),dt};if(r.preloadOnly){const dt=this._emulate(Qe,r.duration,g);return this._preloadTiles(dt),this}const at={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=Se,this._rotating=Re,this._pitching=be,this._padding=Fe,this._easeId=r.easeId,this._prepareEase(u,r.noMoveStart,at),this._ease(Qe(g),dt=>{g.recenterOnTerrain(),this._afterEase(u,dt)},r),this}_prepareEase(r,u,g={}){this._moving=!0,this.transform.cameraElevationReference="sea",u||g.moving||this.fire(new s.Event("movestart",r)),this._zooming&&!g.zooming&&this.fire(new s.Event("zoomstart",r)),this._rotating&&!g.rotating&&this.fire(new s.Event("rotatestart",r)),this._pitching&&!g.pitching&&this.fire(new s.Event("pitchstart",r))}_fireMoveEvents(r){this.fire(new s.Event("move",r)),this._zooming&&this.fire(new s.Event("zoom",r)),this._rotating&&this.fire(new s.Event("rotate",r)),this._pitching&&this.fire(new s.Event("pitch",r))}_afterEase(r,u){if(this._easeId&&u&&this._easeId===u)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const g=this._zooming,x=this._rotating,b=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,g&&this.fire(new s.Event("zoomend",r)),x&&this.fire(new s.Event("rotateend",r)),b&&this.fire(new s.Event("pitchend",r)),this.fire(new s.Event("moveend",r))}flyTo(r,u){if(!r.essential&&s.exported.prefersReducedMotion){const Xt=s.pick(r,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Xt,u)}this.stop(),r=s.extend({offset:[0,0],speed:1.2,curve:1.42,easing:s.ease},r);const g=this.transform,x=this.getZoom(),b=this.getBearing(),S=this.getPitch(),P=this.getPadding(),z="zoom"in r?s.clamp(+r.zoom,g.minZoom,g.maxZoom):x,F="bearing"in r?this._normalizeBearing(r.bearing,b):b,N="pitch"in r?+r.pitch:S,H="padding"in r?r.padding:g.padding,J=g.zoomScale(z-x),re=s.pointGeometry.convert(r.offset);let Q=g.centerPoint.add(re);const X=g.pointLocation(Q),Ae=s.LngLat.convert(r.center||X);this._normalizeCenter(Ae);const fe=g.project(X),Te=g.project(Ae).sub(fe);let Se=r.curve;const Re=Math.max(g.width,g.height),be=Re/J,Fe=Te.mag();if("minZoom"in r){const Xt=s.clamp(Math.min(r.minZoom,x,z),g.minZoom,g.maxZoom),Yt=Re/g.zoomScale(Xt-x);Se=Math.sqrt(Yt/Fe*2)}const Qe=Se*Se;function at(Xt){const Yt=(be*be-Re*Re+(Xt?-1:1)*Qe*Qe*Fe*Fe)/(2*(Xt?be:Re)*Qe*Fe);return Math.log(Math.sqrt(Yt*Yt+1)-Yt)}function dt(Xt){return(Math.exp(Xt)-Math.exp(-Xt))/2}function ut(Xt){return(Math.exp(Xt)+Math.exp(-Xt))/2}const Rt=at(0);let et=function(Xt){return ut(Rt)/ut(Rt+Se*Xt)},zt=function(Xt){return Re*((ut(Rt)*(dt(Yt=Rt+Se*Xt)/ut(Yt))-dt(Rt))/Qe)/Fe;var Yt},Pt=(at(1)-Rt)/Se;if(Math.abs(Fe)<1e-6||!isFinite(Pt)){if(Math.abs(Re-be)<1e-6)return this.easeTo(r,u);const Xt=ber.maxDuration&&(r.duration=0);const Jt=b!==F,pt=N!==S,qt=!g.isPaddingEqual(H),mn=Xt=>Yt=>{const vn=Yt*Pt,kn=1/et(vn);Xt.zoom=Yt===1?z:x+Xt.scaleZoom(kn),Jt&&(Xt.bearing=s.number(b,F,Yt)),pt&&(Xt.pitch=s.number(S,N,Yt)),qt&&(Xt.interpolatePadding(P,H,Yt),Q=Xt.centerPoint.add(re));const hn=Yt===1?Ae:Xt.unproject(fe.add(Te.mult(zt(vn))).mult(kn));return Xt.setLocationAtPoint(Xt.renderWorldCopies?hn.wrap():hn,Q),Xt._updateCameraOnTerrain(),r.preloadOnly||this._fireMoveEvents(u),Xt};if(r.preloadOnly){const Xt=this._emulate(mn,r.duration,g);return this._preloadTiles(Xt),this}return this._zooming=!0,this._rotating=Jt,this._pitching=pt,this._padding=qt,this._prepareEase(u,!1),this._ease(mn(g),()=>this._afterEase(u),r),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(r,u){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const g=this._onEaseEnd;this._onEaseEnd=void 0,g.call(this,u)}if(!r){const g=this.handlers;g&&g.stop(!1)}return this}_ease(r,u,g){g.animate===!1||g.duration===0?(r(1),u()):(this._easeStart=s.exported.now(),this._easeOptions=g,this._onEaseFrame=r,this._onEaseEnd=u,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const r=Math.min((s.exported.now()-this._easeStart)/this._easeOptions.duration,1),u=this._onEaseFrame;u&&u(this._easeOptions.easing(r)),r<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(r,u){r=s.wrap(r,-180,180);const g=Math.abs(r-u);return Math.abs(r-360-u)180?-360:g<-180?360:0}_emulate(r,u,g){const x=Math.ceil(15*u/1e3),b=[],S=r(g.clone());for(let P=0;P<=x;P++){const z=S(P/x);b.push(z.clone())}return b}}class Du{constructor(r={}){this.options=r,s.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(r){const u=this.options&&this.options.compact;return this._map=r,this._container=L("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=L("button","mapboxgl-ctrl-attrib-button",this._container),L("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=L("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),u&&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),u===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(r,u){const g=this._map._getUIString(`AttributionControl.${u}`);r.setAttribute("aria-label",g),r.removeAttribute("title"),r.firstElementChild&&r.firstElementChild.setAttribute("title",g)}_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 r=this._editLink;r||(r=this._editLink=this._container.querySelector(".mapbox-improve-map"));const u=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||s.config.ACCESS_TOKEN}];if(r){const g=u.reduce((x,b,S)=>(b.value&&(x+=`${b.key}=${b.value}${Sx.length-b.length),r=r.filter((x,b)=>{for(let S=b+1;S=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?r=[...this.options.customAttribution,...r]:r.unshift(this.options.customAttribution));const g=r.join(" | ");g!==this._attribHTML&&(this._attribHTML=g,r.length?(this._innerContainer.innerHTML=g,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 og{constructor(){s.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(r){this._map=r,this._container=L("div","mapboxgl-ctrl");const u=L("a","mapboxgl-ctrl-logo");return u.target="_blank",u.rel="noopener nofollow",u.href="https://www.mapbox.com/",u.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),u.setAttribute("rel","noopener nofollow"),this._container.appendChild(u),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(r){r&&r.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const r=this._map.style._sourceCaches;if(Object.entries(r).length===0)return!0;for(const u in r){const g=r[u].getSource();if(g.hasOwnProperty("mapbox_logo")&&!g.mapbox_logo)return!1}return!0}_updateCompact(){const r=this._container.children;if(r.length){const u=r[0];this._map.getCanvasContainer().offsetWidth<250?u.classList.add("mapboxgl-compact"):u.classList.remove("mapboxgl-compact")}}}class sg{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(r){const u=++this._id;return this._queue.push({callback:r,id:u,cancelled:!1}),u}remove(r){const u=this._currentlyRunning,g=u?this._queue.concat(u):this._queue;for(const x of g)if(x.id===r)return void(x.cancelled=!0)}run(r=0){const u=this._currentlyRunning=this._queue;this._queue=[];for(const g of u)if(!g.cancelled&&(g.callback(r),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Iu(f,r,u){if(f=new s.LngLat(f.lng,f.lat),r){const g=new s.LngLat(f.lng-360,f.lat),x=new s.LngLat(f.lng+360,f.lat),b=360*Math.ceil(Math.abs(f.lng-u.center.lng)/360),S=u.locationPoint(f).distSqr(r),P=r.x<0||r.y<0||r.x>u.width||r.y>u.height;u.locationPoint(g).distSqr(r)180;){const g=u.locationPoint(f);if(g.x>=0&&g.y>=0&&g.x<=u.width&&g.y<=u.height)break;f.lng>u.center.lng?f.lng-=360:f.lng+=360}return f}const Ru={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 zu extends s.Evented{constructor(r,u){if(super(),(r instanceof s.window.HTMLElement||u)&&(r=s.extend({element:r},u)),s.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=r&&r.anchor||"center",this._color=r&&r.color||"#3FB1CE",this._scale=r&&r.scale||1,this._draggable=r&&r.draggable||!1,this._clickTolerance=r&&r.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=r&&r.rotation||0,this._rotationAlignment=r&&r.rotationAlignment||"auto",this._pitchAlignment=r&&r.pitchAlignment&&r.pitchAlignment!=="auto"?r.pitchAlignment:this._rotationAlignment,this._updateMoving=()=>this._update(!0),r&&r.element)this._element=r.element,this._offset=s.pointGeometry.convert(r&&r.offset||[0,0]);else{this._defaultMarker=!0,this._element=L("div");const x=41,b=27,S=I("svg",{display:"block",height:x*this._scale+"px",width:b*this._scale+"px",viewBox:`0 0 ${b} ${x}`},this._element),P=I("radialGradient",{id:"shadowGradient"},I("defs",{},S));I("stop",{offset:"10%","stop-opacity":.4},P),I("stop",{offset:"100%","stop-opacity":.05},P),I("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},S),I("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),I("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),I("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},S),this._offset=s.pointGeometry.convert(r&&r.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",x=>{x.preventDefault()}),this._element.addEventListener("mousedown",x=>{x.preventDefault()});const g=this._element.classList;for(const x in Ru)g.remove(`mapboxgl-marker-anchor-${x}`);g.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(r){return r===this._map||(this.remove(),this._map=r,r.getCanvasContainer().appendChild(this._element),r.on("move",this._updateMoving),r.on("moveend",this._update),r.on("remove",this._clearFadeTimer),r._addMarker(this),this.setDraggable(this._draggable),this._update(),r.on("click",this._onMapClick)),this}remove(){const r=this._map;return r&&(r.off("click",this._onMapClick),r.off("move",this._updateMoving),r.off("moveend",this._update),r.off("mousedown",this._addDragHandler),r.off("touchstart",this._addDragHandler),r.off("mouseup",this._onUp),r.off("touchend",this._onUp),r.off("mousemove",this._onMove),r.off("touchmove",this._onMove),r.off("remove",this._clearFadeTimer),r._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(r){return this._lngLat=s.LngLat.convert(r),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(r){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")),r){if(!("offset"in r.options)){const x=Math.sqrt(Math.pow(13.5,2)/2);r.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[x,-1*(24.6+x)],"bottom-right":[-x,-1*(24.6+x)],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=r,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(r){const u=r.code,g=r.charCode||r.keyCode;u!=="Space"&&u!=="Enter"&&g!==32&&g!==13||this.togglePopup()}_onMapClick(r){const u=r.originalEvent.target,g=this._element;this._popup&&(u===g||g.contains(u))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const r=this._popup;return r?(r.isOpen()?(r.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(r.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_evaluateOpacity(){const r=this._map;if(!r)return;const u=this._pos;if(!u||u.x<0||u.x>r.transform.width||u.y<0||u.y>r.transform.height)return void this._clearFadeTimer();const g=r.unproject(u);let x=!1;if(r.transform._terrainEnabled()&&r.getTerrain()){const S=r.getFreeCameraOptions();if(S.position){const P=S.position.toLngLat();x=P.distanceTo(g)<.9*P.distanceTo(this._lngLat)}}const b=(1-r._queryFogOpacity(g))*(x?.2:1);this._element.style.opacity=`${b}`,this._popup&&this._popup._setOpacity(`${b}`),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const r=this._pos;if(!r)return;const u=this._offset.mult(this._scale),g=this._calculatePitch(),x=this._calculateRotation();this._element.style.transform=` translate(${r.x}px, ${r.y}px) ${Ru[this._anchor]} rotateX(${g}deg) rotateZ(${x}deg) translate(${u.x}px, ${u.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(r){s.window.cancelAnimationFrame(this._updateFrameId);const u=this._map;u&&(u.transform.renderWorldCopies&&(this._lngLat=Iu(this._lngLat,this._pos,u.transform)),this._pos=u.project(this._lngLat),r===!0?this._updateFrameId=s.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),u._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),!u.getTerrain()&&!u.getFog()||this._fadeTimer||(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(r){return this._offset=s.pointGeometry.convert(r),this._update(),this}_onMove(r){const u=this._map;if(u){if(!this._isDragging){const g=this._clickTolerance||u._clickTolerance;this._isDragging=r.point.dist(this._pointerdownPos)>=g}this._isDragging&&(this._pos=r.point.sub(this._positionDelta),this._lngLat=u.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new s.Event("dragstart"))),this.fire(new s.Event("drag")))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const r=this._map;r&&(r.off("mousemove",this._onMove),r.off("touchmove",this._onMove)),this._state==="active"&&this.fire(new s.Event("dragend")),this._state="inactive"}_addDragHandler(r){const u=this._map;u&&this._element.contains(r.originalEvent.target)&&(r.preventDefault(),this._positionDelta=r.point.sub(this._pos),this._pointerdownPos=r.point,this._state="pending",u.on("mousemove",this._onMove),u.on("touchmove",this._onMove),u.once("mouseup",this._onUp),u.once("touchend",this._onUp))}setDraggable(r){this._draggable=!!r;const u=this._map;return u&&(r?(u.on("mousedown",this._addDragHandler),u.on("touchstart",this._addDragHandler)):(u.off("mousedown",this._addDragHandler),u.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(r){return this._rotation=r||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(r){return this._rotationAlignment=r||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(r){return this._pitchAlignment=r&&r!=="auto"?r:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}class qy{constructor(r){this.jumpTo(r)}getValue(r){if(r<=this._startTime)return this._start;if(r>=this._endTime)return this._end;const u=s.easeCubicInOut((r-this._startTime)/(this._endTime-this._startTime));return this._start*(1-u)+this._end*u}isEasing(r){return r>=this._startTime&&r<=this._endTime}jumpTo(r){this._startTime=-1/0,this._endTime=-1/0,this._start=r,this._end=r}easeTo(r,u,g){this._start=this.getValue(u),this._end=r,this._startTime=u,this._endTime=u+g}}const Zy={"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"},tp={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 Nl(f){f.parentNode&&f.parentNode.removeChild(f)}const np={showCompass:!0,showZoom:!0,visualizePitch:!1};class ip{constructor(r,u,g=!1){this._clickTolerance=10,this.element=u,this.mouseRotate=new Ps({clickTolerance:r.dragRotate._mouseRotate._clickTolerance}),this.map=r,g&&(this.mousePitch=new Xd({clickTolerance:r.dragRotate._mousePitch._clickTolerance})),s.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),u.addEventListener("mousedown",this.mousedown),u.addEventListener("touchstart",this.touchstart,{passive:!1}),u.addEventListener("touchmove",this.touchmove),u.addEventListener("touchend",this.touchend),u.addEventListener("touchcancel",this.reset)}down(r,u){this.mouseRotate.mousedown(r,u),this.mousePitch&&this.mousePitch.mousedown(r,u),q()}move(r,u){const g=this.map,x=this.mouseRotate.mousemoveWindow(r,u),b=x&&x.bearingDelta;if(b&&g.setBearing(g.getBearing()+b),this.mousePitch){const S=this.mousePitch.mousemoveWindow(r,u),P=S&&S.pitchDelta;P&&g.setPitch(g.getPitch()+P)}}off(){const r=this.element;r.removeEventListener("mousedown",this.mousedown),r.removeEventListener("touchstart",this.touchstart,{passive:!1}),r.removeEventListener("touchmove",this.touchmove),r.removeEventListener("touchend",this.touchend),r.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){ee(),s.window.removeEventListener("mousemove",this.mousemove),s.window.removeEventListener("mouseup",this.mouseup)}mousedown(r){this.down(s.extend({},r,{ctrlKey:!0,preventDefault:()=>r.preventDefault()}),K(this.element,r)),s.window.addEventListener("mousemove",this.mousemove),s.window.addEventListener("mouseup",this.mouseup)}mousemove(r){this.move(r,K(this.element,r))}mouseup(r){this.mouseRotate.mouseupWindow(r),this.mousePitch&&this.mousePitch.mouseupWindow(r),this.offTemp()}touchstart(r){r.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=ie(this.element,r.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>r.preventDefault()},this._startPos))}touchmove(r){r.targetTouches.length!==1?this.reset():(this._lastPos=ie(this.element,r.targetTouches)[0],this.move({preventDefault:()=>r.preventDefault()},this._lastPos))}touchend(r){r.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)5280?Ds(r,g,F/5280,f._getUIString("ScaleControl.Miles"),f):Ds(r,g,F,f._getUIString("ScaleControl.Feet"),f)}else u&&u.unit==="nautical"?Ds(r,g,z/1852,f._getUIString("ScaleControl.NauticalMiles"),f):z>=1e3?Ds(r,g,z/1e3,f._getUIString("ScaleControl.Kilometers"),f):Ds(r,g,z,f._getUIString("ScaleControl.Meters"),f)}function Ds(f,r,u,g,x){const b=function(P){const z=Math.pow(10,`${Math.floor(P)}`.length-1);let F=P/z;return F=F>=10?10:F>=5?5:F>=3?3:F>=2?2:F>=1?1:function(N){const H=Math.pow(10,Math.ceil(-Math.log(N)/Math.LN10));return Math.round(N*H)/H}(F),z*F}(u),S=b/u;x._requestDomTask(()=>{f.style.width=r*S+"px",f.innerHTML=`${b} ${g}`})}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 Vl(f=new s.pointGeometry(0,0),r="bottom"){if(typeof f=="number"){const u=Math.round(Math.sqrt(.5*Math.pow(f,2)));switch(r){case"top":return new s.pointGeometry(0,f);case"top-left":return new s.pointGeometry(u,u);case"top-right":return new s.pointGeometry(-u,u);case"bottom":return new s.pointGeometry(0,-f);case"bottom-left":return new s.pointGeometry(u,-u);case"bottom-right":return new s.pointGeometry(-u,-u);case"left":return new s.pointGeometry(f,0);case"right":return new s.pointGeometry(-f,0)}return new s.pointGeometry(0,0)}return f instanceof s.pointGeometry||Array.isArray(f)?s.pointGeometry.convert(f):s.pointGeometry.convert(f[r]||[0,0])}const Is={version:s.version,supported:M,setRTLTextPlugin:s.setRTLTextPlugin,getRTLTextPluginStatus:s.getRTLTextPluginStatus,Map:class extends ep{constructor(f){if((f=s.extend({},tp,f)).minZoom!=null&&f.maxZoom!=null&&f.minZoom>f.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(f.minPitch!=null&&f.maxPitch!=null&&f.minPitch>f.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(f.minPitch!=null&&f.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(f.maxPitch!=null&&f.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(f.antialias&&s.isSafariWithAntialiasingBug(s.window)&&(f.antialias=!1,s.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Eu(f.minZoom,f.maxZoom,f.minPitch,f.maxPitch,f.renderWorldCopies),f),this._interactive=f.interactive,this._minTileCacheSize=f.minTileCacheSize,this._maxTileCacheSize=f.maxTileCacheSize,this._failIfMajorPerformanceCaveat=f.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=f.preserveDrawingBuffer,this._antialias=f.antialias,this._trackResize=f.trackResize,this._bearingSnap=f.bearingSnap,this._refreshExpiredTiles=f.refreshExpiredTiles,this._fadeDuration=f.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=f.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=f.collectResourceTiming,this._optimizeForTerrain=f.optimizeForTerrain,this._renderTaskQueue=new sg,this._domRenderTaskQueue=new sg,this._controls=[],this._markers=[],this._mapId=s.uniqueId(),this._locale=s.extend({},Zy,f.locale),this._clickTolerance=f.clickTolerance,this._cooperativeGestures=f.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new qy(0),this._explicitProjection=null,this._requestManager=new s.RequestManager(f.transformRequest,f.accessToken,f.testMode),this._silenceAuthErrors=!!f.testMode,typeof f.container=="string"){if(this._container=s.window.document.getElementById(f.container),!this._container)throw new Error(`Container '${f.container}' not found.`)}else{if(!(f.container instanceof s.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=f.container}if(this._container.childNodes.length>0&&s.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."),f.maxBounds&&this.setMaxBounds(f.maxBounds),s.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)),s.window!==void 0&&(s.window.addEventListener("online",this._onWindowOnline,!1),s.window.addEventListener("resize",this._onWindowResize,!1),s.window.addEventListener("orientationchange",this._onWindowResize,!1),s.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new ag(this,f),this._localFontFamily=f.localFontFamily,this._localIdeographFontFamily=f.localIdeographFontFamily,f.style&&this.setStyle(f.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),f.projection&&this.setProjection(f.projection),this._hash=f.hash&&new Nm(typeof f.hash=="string"&&f.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:f.center,zoom:f.zoom,bearing:f.bearing,pitch:f.pitch}),f.bounds&&(this.resize(),this.fitBounds(f.bounds,s.extend({},f.fitBoundsOptions,{duration:0})))),this.resize(),f.attributionControl&&this.addControl(new Du({customAttribution:f.customAttribution})),this._logoControl=new og,this.addControl(this._logoControl,f.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",r=>{this._update(r.dataType==="style"),this.fire(new s.Event(`${r.dataType}data`,r))}),this.on("dataloading",r=>{this.fire(new s.Event(`${r.dataType}dataloading`,r))})}_getMapId(){return this._mapId}addControl(f,r){if(r===void 0&&(r=f.getDefaultPosition?f.getDefaultPosition():"top-right"),!f||!f.onAdd)return this.fire(new s.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const u=f.onAdd(this);this._controls.push(f);const g=this._controlPositions[r];return r.indexOf("bottom")!==-1?g.insertBefore(u,g.firstChild):g.appendChild(u),this}removeControl(f){if(!f||!f.onRemove)return this.fire(new s.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const r=this._controls.indexOf(f);return r>-1&&this._controls.splice(r,1),f.onRemove(this),this}hasControl(f){return this._controls.indexOf(f)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(f){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 r=!this._moving;return r&&this.fire(new s.Event("movestart",f)).fire(new s.Event("move",f)),this.fire(new s.Event("resize",f)),r&&this.fire(new s.Event("moveend",f)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(f){return this.transform.setMaxBounds(s.LngLatBounds.convert(f)),this._update()}setMinZoom(f){if((f=f==null?-2:f)>=-2&&f<=this.transform.maxZoom)return this.transform.minZoom=f,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=f,this._update(),this.getZoom()>f?this.setZoom(f):this.fire(new s.Event("zoomstart")).fire(new s.Event("zoom")).fire(new s.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(f){if((f=f==null?0:f)<0)throw new Error("minPitch must be greater than or equal to 0");if(f>=0&&f<=this.transform.maxPitch)return this.transform.minPitch=f,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(f>=this.transform.minPitch)return this.transform.maxPitch=f,this._update(),this.getPitch()>f?this.setPitch(f):this.fire(new s.Event("pitchstart")).fire(new s.Event("pitch")).fire(new s.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(f){return this.transform.renderWorldCopies=f,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(f){return this._lazyInitEmptyStyle(),f?typeof f=="string"&&(f={name:f}):f=null,this._updateProjection(f)}_updateProjection(f){f===null&&(this._explicitProjection=null);const r=f||this.getProjection(),u=this.transform.setProjection(r);if(f&&(this._explicitProjection=this.transform.getProjection()),u){this.painter.clearBackgroundTiles();for(const g in this.style._sourceCaches)this.style._sourceCaches[g].clearTiles();this.style.applyProjectionUpdate(),this._update(!0)}return this}project(f){return this.transform.locationPoint3D(s.LngLat.convert(f))}unproject(f){return this.transform.pointLocation3D(s.pointGeometry.convert(f))}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(f,r,u){if(f==="mouseenter"||f==="mouseover"){let g=!1;const x=S=>{const P=r.filter(F=>this.getLayer(F)),z=P.length?this.queryRenderedFeatures(S.point,{layers:P}):[];z.length?g||(g=!0,u.call(this,new Dr(f,this,S.originalEvent,{features:z}))):g=!1},b=()=>{g=!1};return{layers:new Set(r),listener:u,delegates:{mousemove:x,mouseout:b}}}if(f==="mouseleave"||f==="mouseout"){let g=!1;const x=S=>{const P=r.filter(z=>this.getLayer(z));(P.length?this.queryRenderedFeatures(S.point,{layers:P}):[]).length?g=!0:g&&(g=!1,u.call(this,new Dr(f,this,S.originalEvent)))},b=S=>{g&&(g=!1,u.call(this,new Dr(f,this,S.originalEvent)))};return{layers:new Set(r),listener:u,delegates:{mousemove:x,mouseout:b}}}{const g=x=>{const b=r.filter(P=>this.getLayer(P)),S=b.length?this.queryRenderedFeatures(x.point,{layers:b}):[];S.length&&(x.features=S,u.call(this,x),delete x.features)};return{layers:new Set(r),listener:u,delegates:{[f]:g}}}}on(f,r,u){if(u===void 0)return super.on(f,r);Array.isArray(r)||(r=[r]);const g=this._createDelegatedListener(f,r,u);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[f]=this._delegatedListeners[f]||[],this._delegatedListeners[f].push(g);for(const x in g.delegates)this.on(x,g.delegates[x]);return this}once(f,r,u){if(u===void 0)return super.once(f,r);Array.isArray(r)||(r=[r]);const g=this._createDelegatedListener(f,r,u);for(const x in g.delegates)this.once(x,g.delegates[x]);return this}off(f,r,u){if(u===void 0)return super.off(f,r);r=new Set(Array.isArray(r)?r:[r]);const g=(b,S)=>{if(b.size!==S.size)return!1;for(const P of b)if(!S.has(P))return!1;return!0},x=this._delegatedListeners?this._delegatedListeners[f]:void 0;return x&&(b=>{for(let S=0;S{x?this.fire(new s.ErrorEvent(x)):b&&this._updateDiff(b,r)})}else typeof f=="object"&&this._updateDiff(f,r)}_updateDiff(f,r){try{this.style.setState(f)&&this._update(!0)}catch(u){s.warnOnce(`Unable to perform style diff: ${u.message||u.error||u}. Rebuilding the style from scratch.`),this._updateStyle(f,r)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(s.warnOnce("There is no style added to the map."),!1)}addSource(f,r){return this._lazyInitEmptyStyle(),this.style.addSource(f,r),this._update(!0)}isSourceLoaded(f){return!!this.style&&this.style._isSourceCacheLoaded(f)}areTilesLoaded(){const f=this.style&&this.style._sourceCaches;for(const r in f){const u=f[r]._tiles;for(const g in u){const x=u[g];if(x.state!=="loaded"&&x.state!=="errored")return!1}}return!0}addSourceType(f,r,u){this._lazyInitEmptyStyle(),this.style.addSourceType(f,r,u)}removeSource(f){return this.style.removeSource(f),this._updateTerrain(),this._update(!0)}getSource(f){return this.style.getSource(f)}addImage(f,r,{pixelRatio:u=1,sdf:g=!1,stretchX:x,stretchY:b,content:S}={}){if(this._lazyInitEmptyStyle(),r instanceof s.window.HTMLImageElement||s.window.ImageBitmap&&r instanceof s.window.ImageBitmap){const{width:P,height:z,data:F}=s.exported.getImageData(r);this.style.addImage(f,{data:new s.RGBAImage({width:P,height:z},F),pixelRatio:u,stretchX:x,stretchY:b,content:S,sdf:g,version:0})}else if(r.width===void 0||r.height===void 0)this.fire(new s.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:P,height:z}=r,F=r;this.style.addImage(f,{data:new s.RGBAImage({width:P,height:z},new Uint8Array(F.data)),pixelRatio:u,stretchX:x,stretchY:b,content:S,sdf:g,version:0,userImage:F}),F.onAdd&&F.onAdd(this,f)}}updateImage(f,r){const u=this.style.getImage(f);if(!u)return void this.fire(new s.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const g=r instanceof s.window.HTMLImageElement||s.window.ImageBitmap&&r instanceof s.window.ImageBitmap?s.exported.getImageData(r):r,{width:x,height:b}=g;x!==void 0&&b!==void 0?x===u.data.width&&b===u.data.height?(u.data.replace(g.data,!(r instanceof s.window.HTMLImageElement||s.window.ImageBitmap&&r instanceof s.window.ImageBitmap)),this.style.updateImage(f,u)):this.fire(new s.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 s.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(f){return f?!!this.style.getImage(f):(this.fire(new s.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(f){this.style.removeImage(f)}loadImage(f,r){s.getImage(this._requestManager.transformRequest(f,s.ResourceType.Image),(u,g)=>{r(u,g instanceof s.window.HTMLImageElement?s.exported.getImageData(g):g)})}listImages(){return this.style.listImages()}addLayer(f,r){return this._lazyInitEmptyStyle(),this.style.addLayer(f,r),this._update(!0)}moveLayer(f,r){return this.style.moveLayer(f,r),this._update(!0)}removeLayer(f){return this.style.removeLayer(f),this._update(!0)}getLayer(f){return this.style.getLayer(f)}setLayerZoomRange(f,r,u){return this.style.setLayerZoomRange(f,r,u),this._update(!0)}setFilter(f,r,u={}){return this.style.setFilter(f,r,u),this._update(!0)}getFilter(f){return this.style.getFilter(f)}setPaintProperty(f,r,u,g={}){return this.style.setPaintProperty(f,r,u,g),this._update(!0)}getPaintProperty(f,r){return this.style.getPaintProperty(f,r)}setLayoutProperty(f,r,u,g={}){return this.style.setLayoutProperty(f,r,u,g),this._update(!0)}getLayoutProperty(f,r){return this.style.getLayoutProperty(f,r)}setLight(f,r={}){return this._lazyInitEmptyStyle(),this.style.setLight(f,r),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(f){return this._lazyInitEmptyStyle(),!f&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(f),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(f){return this._lazyInitEmptyStyle(),this.style.setFog(f),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(f){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(s.LngLat.convert(f),this.transform):0}setFeatureState(f,r){return this.style.setFeatureState(f,r),this._update()}removeFeatureState(f,r){return this.style.removeFeatureState(f,r),this._update()}getFeatureState(f){return this.style.getFeatureState(f)}_updateContainerDimensions(){if(!this._container)return;const f=this._container.getBoundingClientRect().width||400,r=this._container.getBoundingClientRect().height||300;let u,g,x,b=this._container;for(;b&&(!g||!x);){const S=s.window.getComputedStyle(b).transform;S&&S!=="none"&&(u=S.match(/matrix.*\((.+)\)/)[1].split(", "),u[0]&&u[0]!=="0"&&u[0]!=="1"&&(g=u[0]),u[3]&&u[3]!=="0"&&u[3]!=="1"&&(x=u[3])),b=b.parentElement}this._containerWidth=g?Math.abs(f/g):f,this._containerHeight=x?Math.abs(r/x):r}_detectMissingCSS(){s.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&s.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 f=this._container;f.classList.add("mapboxgl-map"),(this._missingCSSCanary=L("div","mapboxgl-canary",f)).style.visibility="hidden",this._detectMissingCSS();const r=this._canvasContainer=L("div","mapboxgl-canvas-container",f);this._interactive&&r.classList.add("mapboxgl-interactive"),this._canvas=L("canvas","mapboxgl-canvas",r),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 u=this._controlContainer=L("div","mapboxgl-control-container",f),g=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(x=>{g[x]=L("div",`mapboxgl-ctrl-${x}`,u)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(f,r){const u=s.exported.devicePixelRatio||1;this._canvas.width=u*Math.ceil(f),this._canvas.height=u*Math.ceil(r),this._canvas.style.width=`${f}px`,this._canvas.style.height=`${r}px`}_addMarker(f){this._markers.push(f)}_removeMarker(f){const r=this._markers.indexOf(f);r!==-1&&this._markers.splice(r,1)}_setupPainter(){const f=s.extend({},M.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._canvas.getContext("webgl",f)||this._canvas.getContext("experimental-webgl",f);r?(s.storeAuthState(r,!0),this.painter=new Fm(r,this.transform),this.on("data",u=>{u.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),s.exported$1.testSupport(r)):this.fire(new s.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(f){f.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new s.Event("webglcontextlost",{originalEvent:f}))}_contextRestored(f){this._setupPainter(),this.resize(),this._update(),this.fire(new s.Event("webglcontextrestored",{originalEvent:f}))}_onMapScroll(f){if(f.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(f){return this.style?(this._styleDirty=this._styleDirty||f,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(f){return this._update(),this._renderTaskQueue.add(f)}_cancelRenderFrame(f){this._renderTaskQueue.remove(f)}_requestDomTask(f){!this.loaded()||this.loaded()&&!this.isMoving()?f():this._domRenderTaskQueue.add(f)}_render(f){let r;const u=this.painter.context.extTimerQuery,g=s.exported.now();if(this.listens("gpu-timing-frame")&&(r=u.createQueryEXT(),u.beginQueryEXT(u.TIME_ELAPSED_EXT,r)),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(f),this._domRenderTaskQueue.run(f),this._removed)return;let x=!1;const b=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const z=this.transform.zoom,F=this.transform.pitch,N=s.exported.now();this.style.zoomHistory.update(z,N);const H=new s.EvaluationParameters(z,{now:N,fadeDuration:b,pitch:F,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),J=H.crossFadingFactor();J===1&&J===this._crossFadingFactor||(x=!0,this._crossFadingFactor=J),this.style.update(H)}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(g),this.style._updateSources(this.transform),this._forceMarkerUpdate()):S=this._updateAverageElevation(g),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,b,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:b,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),speedIndexTiming:this.speedIndexTiming}),this.fire(new s.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new s.Event("load"))),this.style&&(this.style.hasTransitions()||x)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const z=s.exported.now()-g;u.endQueryEXT(u.TIME_ELAPSED_EXT,r),setTimeout(()=>{const F=u.getQueryObjectEXT(r,u.QUERY_RESULT_EXT)/1e6;u.deleteQueryEXT(r),this.fire(new s.Event("gpu-timing-frame",{cpuTime:z,gpuTime:F}))},50)}if(this.listens("gpu-timing-layer")){const z=this.painter.collectGpuTimers();setTimeout(()=>{const F=this.painter.queryGpuTimers(z);this.fire(new s.Event("gpu-timing-layer",{layerTimes:F}))},50)}const P=this._sourcesDirty||this._styleDirty||this._placementDirty||S;if(P||this._repaint)this.triggerRepaint();else{const z=!this.isMoving()&&this.loaded();if(z&&(S=this._updateAverageElevation(g,!0)),S)this.triggerRepaint();else if(this._triggerFrame(!1),z&&(this.fire(new s.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const F=this._calculateSpeedIndex();this.fire(new s.Event("speedindexcompleted",{speedIndex:F})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||P||(this._fullyLoaded=!0,this._authenticate())}_forceMarkerUpdate(){for(const f of this._markers)f._update()}_updateAverageElevation(f,r=!1){const u=g=>(this.transform.averageElevation=g,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&u(0);if((r||f-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(f)){const g=this.transform.averageElevation;let x=this.transform.sampleAverageElevation(),b=!1;this.transform.elevation&&(b=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(x)?x=0:this._averageElevationLastSampledAt=f;const S=Math.abs(g-x);if(S>1){if(this._isInitialLoad||b)return this._averageElevation.jumpTo(x),u(x);this._averageElevation.easeTo(x,f,300)}else if(S>1e-4)return this._averageElevation.jumpTo(x),u(x)}return!!this._averageElevation.isEasing(f)&&u(this._averageElevation.getValue(f))}_authenticate(){s.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,f=>{if(f&&(f.message===s.AUTH_ERR_MSG||f.status===401)){const r=this.painter.context.gl;s.storeAuthState(r,!1),this._logoControl instanceof og&&this._logoControl._updateLogo(),r&&r.clear(r.DEPTH_BUFFER_BIT|r.COLOR_BUFFER_BIT|r.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new s.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/")))}}),s.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const f=this.painter.canvasCopy(),r=this.painter.getCanvasCopiesAndTimestamps();r.timeStamps.push(performance.now());const u=this.painter.context.gl,g=u.createFramebuffer();function x(b){u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,b,0);const S=new Uint8Array(u.drawingBufferWidth*u.drawingBufferHeight*4);return u.readPixels(0,0,u.drawingBufferWidth,u.drawingBufferHeight,u.RGBA,u.UNSIGNED_BYTE,S),S}return u.bindFramebuffer(u.FRAMEBUFFER,g),this._canvasPixelComparison(x(f),r.canvasCopies.map(x),r.timeStamps)}_canvasPixelComparison(f,r,u){let g=u[1]-u[0];const x=f.length/4;for(let b=0;b{const u=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,u&&this._render(r)}))}_preloadTiles(f){const r=this.style?Object.values(this.style._sourceCaches):[];return s.asyncAll(r,(u,g)=>u._preloadTiles(f,g),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(f){this._trackResize&&this.resize({originalEvent:f})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(f){this._showTileBoundaries!==f&&(this._showTileBoundaries=f,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(f){this._showTerrainWireframe!==f&&(this._showTerrainWireframe=f,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(f){this._speedIndexTiming!==f&&(this._speedIndexTiming=f,this._update())}get showPadding(){return!!this._showPadding}set showPadding(f){this._showPadding!==f&&(this._showPadding=f,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(f){this._showCollisionBoxes!==f&&(this._showCollisionBoxes=f,f?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(f){this._showOverdrawInspector!==f&&(this._showOverdrawInspector=f,this._update())}get repaint(){return!!this._repaint}set repaint(f){this._repaint!==f&&(this._repaint=f,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(f){this._vertices=f,this._update()}_setCacheLimits(f,r){s.setCacheLimits(f,r)}get version(){return s.version}},NavigationControl:class{constructor(f){this.options=s.extend({},np,f),this._container=L("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",r=>r.preventDefault()),this.options.showZoom&&(s.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",r=>{this._map&&this._map.zoomIn({},{originalEvent:r})}),L("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",r=>{this._map&&this._map.zoomOut({},{originalEvent:r})}),L("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(s.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",r=>{const u=this._map;u&&(this.options.visualizePitch?u.resetNorthPitch({},{originalEvent:r}):u.resetNorth({},{originalEvent:r}))}),this._compassIcon=L("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const f=this._map;if(!f)return;const r=f.getZoom(),u=r===f.getMaxZoom(),g=r===f.getMinZoom();this._zoomInButton.disabled=u,this._zoomOutButton.disabled=g,this._zoomInButton.setAttribute("aria-disabled",u.toString()),this._zoomOutButton.setAttribute("aria-disabled",g.toString())}_rotateCompassArrow(){const f=this._map;if(!f)return;const r=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(f.transform.pitch*(Math.PI/180)),.5)}) rotateX(${f.transform.pitch}deg) rotateZ(${f.transform.angle*(180/Math.PI)}deg)`:`rotate(${f.transform.angle*(180/Math.PI)}deg)`;f._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=r)})}onAdd(f){return this._map=f,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),f.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&f.on("pitch",this._rotateCompassArrow),f.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ip(f,this._compass,this.options.visualizePitch)),this._container}onRemove(){const f=this._map;f&&(this._container.remove(),this.options.showZoom&&f.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&f.off("pitch",this._rotateCompassArrow),f.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(f,r){const u=L("button",f,this._container);return u.type="button",u.addEventListener("click",r),u}_setButtonTitle(f,r){if(!this._map)return;const u=this._map._getUIString(`NavigationControl.${r}`);f.setAttribute("aria-label",u),f.firstElementChild&&f.firstElementChild.setAttribute("title",u)}},GeolocateControl:class extends s.Evented{constructor(f){super(),this.options=s.extend({},_r,f),s.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Zd(this._updateMarkerRotation,20)}onAdd(f){var r;return this._map=f,this._container=L("div","mapboxgl-ctrl mapboxgl-ctrl-group"),r=this._setupUI,Ir!==void 0?r(Ir):s.window.navigator.permissions!==void 0?s.window.navigator.permissions.query({name:"geolocation"}).then(u=>{Ir=u.state!=="denied",r(Ir)}):(Ir=!!s.window.navigator.geolocation,r(Ir)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(s.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,Ul=0,Wo=!1}_isOutOfMapMaxBounds(f){const r=this._map.getMaxBounds(),u=f.coords;return!!r&&(u.longituder.getEast()||u.latituder.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(f){if(this._map){if(this._isOutOfMapMaxBounds(f))return this._setErrorState(),this.fire(new s.Event("outofmaxbounds",f)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=f,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(f),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(f),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new s.Event("geolocate",f)),this._finish()}}_updateCamera(f){const r=new s.LngLat(f.coords.longitude,f.coords.latitude),u=f.coords.accuracy,g=this._map.getBearing(),x=s.extend({bearing:g},this.options.fitBoundsOptions);this._map.fitBounds(r.toBounds(u),x,{geolocateSource:!0})}_updateMarker(f){if(f){const r=new s.LngLat(f.coords.longitude,f.coords.latitude);this._accuracyCircleMarker.setLngLat(r).addTo(this._map),this._userLocationDotMarker.setLngLat(r).addTo(this._map),this._accuracy=f.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const f=this._map._containerHeight/2,r=this._map.unproject([0,f]),u=this._map.unproject([100,f]),g=r.distanceTo(u)/100,x=Math.ceil(2*this._accuracy/g);this._circleElement.style.width=`${x}px`,this._circleElement.style.height=`${x}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(f){if(this._map){if(this.options.trackUserLocation)if(f.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 r=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(f.code===3&&Wo)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new s.Event("error",f)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(f){if(this._container.addEventListener("contextmenu",r=>r.preventDefault()),this._geolocateButton=L("button","mapboxgl-ctrl-geolocate",this._container),L("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",f===!1){s.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const r=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r)}else{const r=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=L("div","mapboxgl-user-location"),this._dotElement.appendChild(L("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(L("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new zu({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=L("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new zu({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",r=>{r.geolocateSource||this._watchState!=="ACTIVE_LOCK"||r.originalEvent&&r.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 s.Event("trackuserlocationend")))})}_onDeviceOrientation(f){this._userLocationDotMarker&&(f.webkitCompassHeading?this._heading=f.webkitCompassHeading:f.absolute===!0&&(this._heading=-1*f.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return s.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 s.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Ul--,Wo=!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 s.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 s.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 f;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Ul++,Ul>1?(f={maximumAge:6e5,timeout:0},Wo=!0):(f=this.options.positionOptions,Wo=!1),this._geolocationWatchID=s.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,f),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else s.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const f=()=>{s.window.addEventListener("ondeviceorientationabsolute"in s.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};s.window.DeviceMotionEvent!==void 0&&typeof s.window.DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(r=>{r==="granted"&&f()}).catch(console.error):f()}_clearWatch(){s.window.navigator.geolocation.clearWatch(this._geolocationWatchID),s.window.removeEventListener("deviceorientation",this._onDeviceOrientation),s.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:Du,ScaleControl:class{constructor(f){this.options=s.extend({},rp,f),s.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){ku(this._map,this._container,this.options)}onAdd(f){return this._map=f,this._container=L("div","mapboxgl-ctrl mapboxgl-ctrl-scale",f.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(f){this.options.unit=f,ku(this._map,this._container,this.options)}},FullscreenControl:class{constructor(f){this._fullscreen=!1,f&&f.container&&(f.container instanceof s.window.HTMLElement?this._container=f.container:s.warnOnce("Full screen control 'container' must be a DOM element.")),s.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in s.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in s.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(f){return this._map=f,this._container||(this._container=this._map.getContainer()),this._controlContainer=L("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",s.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,s.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!s.window.document.fullscreenEnabled&&!s.window.document.webkitFullscreenEnabled)}_setupUI(){const f=this._fullscreenButton=L("button","mapboxgl-ctrl-fullscreen",this._controlContainer);L("span","mapboxgl-ctrl-icon",f).setAttribute("aria-hidden","true"),f.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),s.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const f=this._getTitle();this._fullscreenButton.setAttribute("aria-label",f),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",f)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(s.window.document.fullscreenElement||s.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()?s.window.document.exitFullscreen?s.window.document.exitFullscreen():s.window.document.webkitCancelFullScreen&&s.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends s.Evented{constructor(f){super(),this.options=s.extend(Object.create(qr),f),s.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(f&&f.className?f.className.trim().split(/\s+/):[])}addTo(f){return this._map&&this.remove(),this._map=f,this.options.closeOnClick&&f.on("preclick",this._onClose),this.options.closeOnMove&&f.on("move",this._onClose),f.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(f.on("mousemove",this._onMouseEvent),f.on("mouseup",this._onMouseEvent),f._canvasContainer.classList.add("mapboxgl-track-pointer")):f.on("move",this._update),this.fire(new s.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const f=this._map;return f&&(f.off("move",this._update),f.off("move",this._onClose),f.off("preclick",this._onClose),f.off("click",this._onClose),f.off("remove",this.remove),f.off("mousemove",this._onMouseEvent),f.off("mouseup",this._onMouseEvent),f.off("drag",this._onMouseEvent),this._map=void 0),this.fire(new s.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(f){this._lngLat=s.LngLat.convert(f),this._pos=null,this._trackPointer=!1,this._update();const r=this._map;return r&&(r.on("move",this._update),r.off("mousemove",this._onMouseEvent),r._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const f=this._map;return f&&(f.off("move",this._update),f.on("mousemove",this._onMouseEvent),f.on("drag",this._onMouseEvent),f._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(f){return this.setDOMContent(s.window.document.createTextNode(f))}setHTML(f){const r=s.window.document.createDocumentFragment(),u=s.window.document.createElement("body");let g;for(u.innerHTML=f;g=u.firstChild,g;)r.appendChild(g);return this.setDOMContent(r)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(f){return this.options.maxWidth=f,this._update(),this}setDOMContent(f){let r=this._content;if(r)for(;r.hasChildNodes();)r.firstChild&&r.removeChild(r.firstChild);else r=this._content=L("div","mapboxgl-popup-content",this._container||void 0);if(r.appendChild(f),this.options.closeButton){const u=this._closeButton=L("button","mapboxgl-popup-close-button",r);u.type="button",u.setAttribute("aria-label","Close popup"),u.setAttribute("aria-hidden","true"),u.innerHTML="×",u.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(f){return this._classList.add(f),this._updateClassList(),this}removeClassName(f){return this._classList.delete(f),this._updateClassList(),this}setOffset(f){return this.options.offset=f,this._update(),this}toggleClassName(f){let r;return this._classList.delete(f)?r=!1:(this._classList.add(f),r=!0),this._updateClassList(),r}_onMouseEvent(f){this._update(f.point)}_getAnchor(f){if(this.options.anchor)return this.options.anchor;const r=this._map,u=this._container,g=this._pos;if(!r||!u||!g)return"bottom";const x=u.offsetWidth,b=u.offsetHeight,S=g.xr.transform.width-x/2;if(g.y+fr.transform.height-b){if(S)return"bottom-left";if(P)return"bottom-right"}return S?"left":P?"right":"bottom"}_updateClassList(){const f=this._container;if(!f)return;const r=[...this._classList];r.push("mapboxgl-popup"),this._anchor&&r.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&r.push("mapboxgl-popup-track-pointer"),f.className=r.join(" ")}_update(f){const r=this._map,u=this._content;if(!r||!this._lngLat&&!this._trackPointer||!u)return;let g=this._container;if(g||(g=this._container=L("div","mapboxgl-popup",r.getContainer()),this._tip=L("div","mapboxgl-popup-tip",g),g.appendChild(u)),this.options.maxWidth&&g.style.maxWidth!==this.options.maxWidth&&(g.style.maxWidth=this.options.maxWidth),r.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Iu(this._lngLat,this._pos,r.transform)),!this._trackPointer||f){const x=this._pos=this._trackPointer&&f?f:r.project(this._lngLat),b=Vl(this.options.offset),S=this._anchor=this._getAnchor(b.y),P=Vl(this.options.offset,S),z=x.add(P).round();r._requestDomTask(()=>{this._container&&S&&(this._container.style.transform=`${Ru[S]} translate(${z.x}px,${z.y}px)`)})}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const f=this._container.querySelector(ci);f&&f.focus()}_onClose(){this.remove()}_setOpacity(f){this._content&&(this._content.style.opacity=f),this._tip&&(this._tip.style.opacity=f)}},Marker:zu,Style:gr,LngLat:s.LngLat,LngLatBounds:s.LngLatBounds,Point:s.pointGeometry,MercatorCoordinate:s.MercatorCoordinate,FreeCameraOptions:Ll,Evented:s.Evented,config:s.config,prewarm:function(){ze().acquire(_n)},clearPrewarmedResources:function(){const f=Y;f&&(f.isPreloaded()&&f.numActive()===1?(f.release(_n),Y=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 s.config.ACCESS_TOKEN},set accessToken(f){s.config.ACCESS_TOKEN=f},get baseApiUrl(){return s.config.API_URL},set baseApiUrl(f){s.config.API_URL=f},get workerCount(){return W.workerCount},set workerCount(f){W.workerCount=f},get maxParallelImageRequests(){return s.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(f){s.config.MAX_PARALLEL_IMAGE_REQUESTS=f},clearStorage(f){s.clearTileCache(f)},workerUrl:"",workerClass:null,setNow:s.exported.setNow,restoreNow:s.exported.restoreNow};return Is});var _=h;return _})})(G1);var oL=G1.exports;const sL=z1(oL),tu={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 lL(e){const n="./gis/radar.tiff";console.log(n);let i=(114.06825863001939-104.18084906665138)*.005,l=(32.396413467808586-22.54283198132819)*.005,h=114.07867152431874,p=22.563727343812303;e.addSource("radar",{type:"image",url:n,coordinates:[[h-i*.5,p+l*.5],[h+i*.5,p+l*.5],[h+i*.5,p-l*.5],[h-i*.5,p-l*.5]]}),e.addLayer({id:"radar-layer",type:"raster",source:"radar",paint:{"raster-fade-duration":0}})}function cL(e){var n="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:[n],tileSize:256}),e.addLayer({id:"wmts-layer",type:"raster",source:"wmts-source",paint:{"raster-opacity":.95}})}let md,Ra;function uL(e){md.on("click",function(n){return wn(this,null,function*(){let{lng:i,lat:l}=n.lngLat;if(e){let _=te.mx_gcj02_To_gps84(i,l);i=_.lng,l=_.lat}console.log("经纬度坐标:",JSON.stringify([i,l]));let h=sL.MercatorCoordinate.fromLngLat([i,l],0);console.log("墨卡托坐标:",JSON.stringify(Ra.map_lnglat_to_meters(i,l)));let p=Ra.mercatorCoord2CAD(h.x,h.y);console.log("CAD坐标:",JSON.stringify(p))})})}let gd=!1,mm=!0;mm=!1,mm&&(gd=!1);function hL(){let e=new te.MxCADPluginMapDefaultData;e.cadOrigin=[116275.977014,19273.279085],e.mapOrigin=[114.06825863001939,22.54283198132819],e.meterInCADUnits=1,e.openFile="./demo/road.dwg.mxweb";let n=tt.MxFun.getQueryString("maptype");if(!mm)if(n=="google"){let i=te.mx_gps84_To_gcj02(e.mapOrigin[0],e.mapOrigin[1]);e.mapOrigin=[i.lng,i.lat],gd=!0,e.viewColor={red:0,green:0,blue:0}}else{let i=tu.gdslwzj();n=="gdslwzj"?i=tu.gdslwzj():n=="gdyx"?i=tu.gdyx():n=="tdtsl"?i=tu.tdtsl():n=="bdsl"?i=tu.bdsl():n=="geoq"&&(i=tu.geoq()),e.rasterTileLayerList=i.layers,i.key&&(e.rasterTileKey=i.key)}return e}function dL(e){Ra=e,md=e.getMapbox(),gd&&te.MxMapAddGoogleCnLayer(md,["Image","Lable"]),uL(gd),mm?cL(md):lL(md)}function pL(){return wn(this,null,function*(){let e=new te.MxCADUiPrPoint;e.setMessage(` 指定下载范围第一点:`);let n=yield e.go();if(!n)return;e.setMessage(` 指定下载范围第二点:`),e.setUserDraw((T,C)=>{C.setColor(16711680);let E=new te.McDbPolyline;E.addVertexAt(n),E.addVertexAt(new te.McGePoint3d(n.x,T.y)),E.addVertexAt(T),E.addVertexAt(new te.McGePoint3d(T.x,n.y)),E.constantWidth=tt.MxFun.screenCoordLong2Doc(2),E.isClosed=!0,C.drawMcDbEntity(E);let L=[];L.push(n.toVector3()),L.push(new THREE.Vector3(n.x,T.y)),L.push(T.toVector3()),L.push(new THREE.Vector3(T.x,n.y)),C.setColor(12868),C.drawSolid(L,.5)}),e.setDisableOsnap(!0),e.setDisableOrthoTrace(!0),e.setDynamicInputType(tt.DynamicInputType.kXYCoordInput);let i=yield e.go();if(!i)return;let l=Ra.cadTolnglat(n.toVector3()),h=Ra.cadTolnglat(i.toVector3()),p=Ra.map_lnglat_to_meters(l[0],l[1]),_=Ra.map_lnglat_to_meters(h[0],h[1]);if(gd&&!(Ra.outOfChina(l[0],l[1])&&Ra.outOfChina(h[0],h[1]))){let T=te.mx_gcj02_To_gps84(l[0],l[1]),C=te.mx_gcj02_To_gps84(h[0],h[1]);p=Ra.map_lnglat_to_meters(T.lng,T.lat),_=Ra.map_lnglat_to_meters(C.lng,C.lat)}let s={url:"https://gac-geo.googlecnapps.cn/maps/vt?lyrs=s&x={x}&y={y}&z={z}",polygon:[p[0],p[1],_[0],_[1]],zoom:18,auto_close:!1,no_repeated_download:!0,download_dir:"",thread_count:32};tt.MxFun.acutPrintf(` 使用教程:https://help.mxdraw.com/?pid=111`),tt.MxFun.acutPrintf(` 复制下面的范围,到下载器下载地图,下载范围:`);let M=` `+JSON.stringify([p[0],p[1],_[0],_[1]]);tt.MxFun.acutPrintf(M),tt.MxFun.acutPrintf(` `),Fp({method:"post",url:"http://localhost:1337/users/mxgis/download",data:s}).then(T=>{console.log(T.data),alert(JSON.stringify(T.data))}).catch(T=>{console.log("网络错误")})})}window._iconfont_svg_string_4337873='',function(e){var i=(i=document.getElementsByTagName("script"))[i.length-1],n=i.getAttribute("data-injectcss"),i=i.getAttribute("data-disable-injectsvg");if(!i){var l,h,p,_,s,M=function(E,L){L.parentNode.insertBefore(E,L)};if(n&&!e.__iconfont__svg__cssinject__){e.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(E){console&&console.log(E)}}l=function(){var E,L=document.createElement("div");L.innerHTML=e._iconfont_svg_string_4337873,(L=L.getElementsByTagName("svg")[0])&&(L.setAttribute("aria-hidden","true"),L.style.position="absolute",L.style.width=0,L.style.height=0,L.style.overflow="hidden",L=L,(E=document.body).firstChild?M(L,E.firstChild):E.appendChild(L))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(l,0):(h=function(){document.removeEventListener("DOMContentLoaded",h,!1),l()},document.addEventListener("DOMContentLoaded",h,!1)):document.attachEvent&&(p=l,_=e.document,s=!1,C(),_.onreadystatechange=function(){_.readyState=="complete"&&(_.onreadystatechange=null,T())})}function T(){s||(s=!0,p())}function C(){try{_.documentElement.doScroll("left")}catch(E){return void setTimeout(C,50)}T()}}(window);var fL=function(){function e(Pe){ri.call(this,Pe),this.dracoLoader=null,this.ddsLoader=null}e.prototype=Object.assign(Object.create(ri.prototype),{constructor:e,load:function(Pe,ge,Ve,Ne){var Ie=this,it;this.resourcePath!==""?it=this.resourcePath:this.path!==""?it=this.path:it=ul.extractUrlBase(Pe),Ie.manager.itemStart(Pe);var ce=function(Me){Ne?Ne(Me):console.error(Me),Ie.manager.itemError(Pe),Ie.manager.itemEnd(Pe)},we=new xa(Ie.manager);we.setPath(this.path),we.setResponseType("arraybuffer"),Ie.crossOrigin==="use-credentials"&&we.setWithCredentials(!0),we.load(Pe,function(Me){try{Ie.parse(Me,it,function(pe){ge(pe),Ie.manager.itemEnd(Pe)},ce)}catch(pe){ce(pe)}},Ve,ce)},setDRACOLoader:function(Pe){return this.dracoLoader=Pe,this},setDDSLoader:function(Pe){return this.ddsLoader=Pe,this},parse:function(Pe,ge,Ve,Ne){var Ie,it={};if(typeof Pe=="string")Ie=Pe;else{var ce=ul.decodeText(new Uint8Array(Pe,0,4));if(ce===_){try{it[i.KHR_BINARY_GLTF]=new T(Pe)}catch(ot){Ne&&Ne(ot);return}Ie=it[i.KHR_BINARY_GLTF].content}else Ie=ul.decodeText(new Uint8Array(Pe))}var we=JSON.parse(Ie);if(we.asset===void 0||we.asset.version[0]<2){Ne&&Ne(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}if(we.extensionsUsed)for(var Me=0;Me=0&&console.warn('THREE.GLTFLoader: Unknown extension "'+pe+'".')}}var $e=new gt(we,it,{path:ge||this.resourcePath||"",crossOrigin:this.crossOrigin,manager:this.manager});$e.parse(Ve,Ne)}});function n(){var Pe={};return{get:function(ge){return Pe[ge]},add:function(ge,Ve){Pe[ge]=Ve},remove:function(ge){delete Pe[ge]},removeAll:function(){Pe={}}}}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(Pe){if(!Pe)throw new Error("THREE.GLTFLoader: Attempting to load .dds texture without importing DDSLoader");this.name=i.MSFT_TEXTURE_DDS,this.ddsLoader=Pe}function h(Pe){this.name=i.KHR_LIGHTS_PUNCTUAL;var ge=Pe.extensions&&Pe.extensions[i.KHR_LIGHTS_PUNCTUAL]||{};this.lightDefs=ge.lights||[]}h.prototype.loadLight=function(Pe){var ge=this.lightDefs[Pe],Ve,Ne=new en(16777215);ge.color!==void 0&&Ne.fromArray(ge.color);var Ie=ge.range!==void 0?ge.range:0;switch(ge.type){case"directional":Ve=new Kf(Ne),Ve.target.position.set(0,0,-1),Ve.add(Ve.target);break;case"point":Ve=new Jf(Ne),Ve.distance=Ie;break;case"spot":Ve=new $f(Ne),Ve.distance=Ie,ge.spot=ge.spot||{},ge.spot.innerConeAngle=ge.spot.innerConeAngle!==void 0?ge.spot.innerConeAngle:0,ge.spot.outerConeAngle=ge.spot.outerConeAngle!==void 0?ge.spot.outerConeAngle:Math.PI/4,Ve.angle=ge.spot.outerConeAngle,Ve.penumbra=1-ge.spot.innerConeAngle/ge.spot.outerConeAngle,Ve.target.position.set(0,0,-1),Ve.add(Ve.target);break;default:throw new Error('THREE.GLTFLoader: Unexpected light type, "'+ge.type+'".')}return Ve.position.set(0,0,0),Ve.decay=2,ge.intensity!==void 0&&(Ve.intensity=ge.intensity),Ve.name=ge.name||"light_"+Pe,Promise.resolve(Ve)};function p(){this.name=i.KHR_MATERIALS_UNLIT}p.prototype.getMaterialType=function(){return lr},p.prototype.extendParams=function(Pe,ge,Ve){var Ne=[];Pe.color=new en(1,1,1),Pe.opacity=1;var Ie=ge.pbrMetallicRoughness;if(Ie){if(Array.isArray(Ie.baseColorFactor)){var it=Ie.baseColorFactor;Pe.color.fromArray(it),Pe.opacity=it[3]}Ie.baseColorTexture!==void 0&&Ne.push(Ve.assignTexture(Pe,"map",Ie.baseColorTexture))}return Promise.all(Ne)};var _="glTF",s=12,M={JSON:1313821514,BIN:5130562};function T(Pe){this.name=i.KHR_BINARY_GLTF,this.content=null,this.body=null;var ge=new DataView(Pe,0,s);if(this.header={magic:ul.decodeText(new Uint8Array(Pe.slice(0,4))),version:ge.getUint32(4,!0),length:ge.getUint32(8,!0)},this.header.magic!==_)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 Ve=new DataView(Pe,s),Ne=0;Ne",ge),we.fragmentShader=we.fragmentShader.replace("#include ",Ve),we.fragmentShader=we.fragmentShader.replace("#include ",Ne),we.fragmentShader=we.fragmentShader.replace("#include ",Ie),we.fragmentShader=we.fragmentShader.replace("#include ",it)},Object.defineProperties(this,{specular:{get:function(){return ce.specular.value},set:function(we){ce.specular.value=we}},specularMap:{get:function(){return ce.specularMap.value},set:function(we){ce.specularMap.value=we}},glossiness:{get:function(){return ce.glossiness.value},set:function(we){ce.glossiness.value=we}},glossinessMap:{get:function(){return ce.glossinessMap.value},set:function(we){ce.glossinessMap.value=we,we?(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(Pe)}L.prototype=Object.create(Ur.prototype),L.prototype.constructor=L,L.prototype.copy=function(Pe){return Ur.prototype.copy.call(this,Pe),this.specularMap=Pe.specularMap,this.specular.copy(Pe.specular),this.glossinessMap=Pe.glossinessMap,this.glossiness=Pe.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this};function I(){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 L},extendParams:function(Pe,ge,Ve){var Ne=ge.extensions[this.name];Pe.color=new en(1,1,1),Pe.opacity=1;var Ie=[];if(Array.isArray(Ne.diffuseFactor)){var it=Ne.diffuseFactor;Pe.color.fromArray(it),Pe.opacity=it[3]}if(Ne.diffuseTexture!==void 0&&Ie.push(Ve.assignTexture(Pe,"map",Ne.diffuseTexture)),Pe.emissive=new en(0,0,0),Pe.glossiness=Ne.glossinessFactor!==void 0?Ne.glossinessFactor:1,Pe.specular=new en(1,1,1),Array.isArray(Ne.specularFactor)&&Pe.specular.fromArray(Ne.specularFactor),Ne.specularGlossinessTexture!==void 0){var ce=Ne.specularGlossinessTexture;Ie.push(Ve.assignTexture(Pe,"glossinessMap",ce)),Ie.push(Ve.assignTexture(Pe,"specularMap",ce))}return Promise.all(Ie)},createMaterial:function(Pe){var ge=new L(Pe);return ge.fog=!0,ge.color=Pe.color,ge.map=Pe.map===void 0?null:Pe.map,ge.lightMap=null,ge.lightMapIntensity=1,ge.aoMap=Pe.aoMap===void 0?null:Pe.aoMap,ge.aoMapIntensity=1,ge.emissive=Pe.emissive,ge.emissiveIntensity=1,ge.emissiveMap=Pe.emissiveMap===void 0?null:Pe.emissiveMap,ge.bumpMap=Pe.bumpMap===void 0?null:Pe.bumpMap,ge.bumpScale=1,ge.normalMap=Pe.normalMap===void 0?null:Pe.normalMap,ge.normalMapType=Xs,Pe.normalScale&&(ge.normalScale=Pe.normalScale),ge.displacementMap=null,ge.displacementScale=1,ge.displacementBias=0,ge.specularMap=Pe.specularMap===void 0?null:Pe.specularMap,ge.specular=Pe.specular,ge.glossinessMap=Pe.glossinessMap===void 0?null:Pe.glossinessMap,ge.glossiness=Pe.glossiness,ge.alphaMap=null,ge.envMap=Pe.envMap===void 0?null:Pe.envMap,ge.envMapIntensity=1,ge.refractionRatio=.98,ge}}}function B(){this.name=i.KHR_MESH_QUANTIZATION}function O(Pe,ge,Ve,Ne){Vr.call(this,Pe,ge,Ve,Ne)}O.prototype=Object.create(Vr.prototype),O.prototype.constructor=O,O.prototype.copySampleValue_=function(Pe){for(var ge=this.resultBuffer,Ve=this.sampleValues,Ne=this.valueSize,Ie=Pe*Ne*3+Ne,it=0;it!==Ne;it++)ge[it]=Ve[Ie+it];return ge},O.prototype.beforeStart_=O.prototype.copySampleValue_,O.prototype.afterEnd_=O.prototype.copySampleValue_,O.prototype.interpolate_=function(Pe,ge,Ve,Ne){for(var Ie=this.resultBuffer,it=this.sampleValues,ce=this.valueSize,we=ce*2,Me=ce*3,pe=Ne-ge,Be=(Ve-ge)/pe,$e=Be*Be,ot=$e*Be,bt=Pe*Me,Vt=bt-Me,oe=-2*ot+3*$e,ve=ot-$e,xt=1-oe,mt=ve-$e+Be,xn=0;xn!==ce;xn++){var un=it[Vt+xn+ce],tn=it[Vt+xn+we]*pe,dn=it[bt+xn+ce],bn=it[bt+xn]*pe;Ie[xn]=xt*un+mt*tn+oe*dn+ve*bn}return Ie};var U={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},q={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ee={9728:Ui,9729:qi,9984:Gp,9985:Yg,9986:Hp,9987:ec},he={33071:wr,33648:sh,10497:Zs},Ce={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},K={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},ie={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ue={CUBICSPLINE:void 0,LINEAR:nc,STEP:uh},ae={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"},le={"image/png":Aa,"image/jpeg":Mo};function De(Pe,ge){return typeof Pe!="string"||Pe===""?"":(/^https?:\/\//i.test(ge)&&/^\//.test(Pe)&&(ge=ge.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(Pe)||/^data:.*,.*$/i.test(Pe)||/^blob:.*$/i.test(Pe)?Pe:ge+Pe)}function ye(Pe){return Pe.DefaultMaterial===void 0&&(Pe.DefaultMaterial=new Ur({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Jl})),Pe.DefaultMaterial}function se(Pe,ge,Ve){for(var Ne in Ve.extensions)Pe[Ne]===void 0&&(ge.userData.gltfExtensions=ge.userData.gltfExtensions||{},ge.userData.gltfExtensions[Ne]=Ve.extensions[Ne])}function Ue(Pe,ge){ge.extras!==void 0&&(typeof ge.extras=="object"?Object.assign(Pe.userData,ge.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+ge.extras))}function Oe(Pe,ge,Ve){for(var Ne=!1,Ie=!1,it=0,ce=ge.length;it=2&&oe.setY(Zt,ln[Gt*we+1]),we>=3&&oe.setZ(Zt,ln[Gt*we+2]),we>=4&&oe.setW(Zt,ln[Gt*we+3]),we>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return oe})},gt.prototype.loadTexture=function(Pe){var ge=this,Ve=this.json,Ne=this.options,Ie=this.textureLoader,it=window.URL||window.webkitURL,ce=Ve.textures[Pe],we=ce.extensions||{},Me;we[i.MSFT_TEXTURE_DDS]?Me=Ve.images[we[i.MSFT_TEXTURE_DDS].source]:Me=Ve.images[ce.source];var pe=Me.uri,Be=!1;return Me.bufferView!==void 0&&(pe=ge.getDependency("bufferView",Me.bufferView).then(function($e){Be=!0;var ot=new Blob([$e],{type:Me.mimeType});return pe=it.createObjectURL(ot),pe})),Promise.resolve(pe).then(function($e){var ot=Ne.manager.getHandler($e);return ot||(ot=we[i.MSFT_TEXTURE_DDS]?ge.extensions[i.MSFT_TEXTURE_DDS].ddsLoader:Ie),new Promise(function(bt,Vt){ot.load(De($e,Ne.path),bt,void 0,Vt)})}).then(function($e){Be===!0&&it.revokeObjectURL(pe),$e.flipY=!1,ce.name!==void 0&&($e.name=ce.name),Me.mimeType in le&&($e.format=le[Me.mimeType]);var ot=Ve.samplers||{},bt=ot[ce.sampler]||{};return $e.magFilter=ee[bt.magFilter]||qi,$e.minFilter=ee[bt.minFilter]||ec,$e.wrapS=he[bt.wrapS]||Zs,$e.wrapT=he[bt.wrapT]||Zs,$e})},gt.prototype.assignTexture=function(Pe,ge,Ve){var Ne=this;return this.getDependency("texture",Ve.index).then(function(Ie){if(!Ie.isCompressedTexture)switch(ge){case"aoMap":case"emissiveMap":case"metalnessMap":case"normalMap":case"roughnessMap":Ie.format=Mo;break}if(Ve.texCoord!==void 0&&Ve.texCoord!=0&&!(ge==="aoMap"&&Ve.texCoord==1)&&console.warn("THREE.GLTFLoader: Custom UV set "+Ve.texCoord+" for texture "+ge+" not yet supported."),Ne.extensions[i.KHR_TEXTURE_TRANSFORM]){var it=Ve.extensions!==void 0?Ve.extensions[i.KHR_TEXTURE_TRANSFORM]:void 0;it&&(Ie=Ne.extensions[i.KHR_TEXTURE_TRANSFORM].extendTexture(Ie,it))}Pe[ge]=Ie})},gt.prototype.assignFinalMaterial=function(Pe){var ge=Pe.geometry,Ve=Pe.material;this.extensions;var Ne=ge.attributes.tangent!==void 0,Ie=ge.attributes.color!==void 0,it=ge.attributes.normal===void 0,ce=Pe.isSkinnedMesh===!0,we=Object.keys(ge.morphAttributes).length>0,Me=we&&ge.morphAttributes.normal!==void 0;if(Pe.isPoints){var pe="PointsMaterial:"+Ve.uuid,Be=this.cache.get(pe);Be||(Be=new os,Rn.prototype.copy.call(Be,Ve),Be.color.copy(Ve.color),Be.map=Ve.map,Be.sizeAttenuation=!1,this.cache.add(pe,Be)),Ve=Be}else if(Pe.isLine){var pe="LineBasicMaterial:"+Ve.uuid,$e=this.cache.get(pe);$e||($e=new Ri,Rn.prototype.copy.call($e,Ve),$e.color.copy(Ve.color),this.cache.add(pe,$e)),Ve=$e}if(Ne||Ie||it||ce||we){var pe="ClonedMaterial:"+Ve.uuid+":";Ve.isGLTFSpecularGlossinessMaterial&&(pe+="specular-glossiness:"),ce&&(pe+="skinning:"),Ne&&(pe+="vertex-tangents:"),Ie&&(pe+="vertex-colors:"),it&&(pe+="flat-shading:"),we&&(pe+="morph-targets:"),Me&&(pe+="morph-normals:");var ot=this.cache.get(pe);ot||(ot=Ve.clone(),ce&&(ot.skinning=!0),Ne&&(ot.vertexTangents=!0),Ie&&(ot.vertexColors=Kl),it&&(ot.flatShading=!0),we&&(ot.morphTargets=!0),Me&&(ot.morphNormals=!0),this.cache.add(pe,ot)),Ve=ot}Ve.aoMap&&ge.attributes.uv2===void 0&&ge.attributes.uv!==void 0&&ge.setAttribute("uv2",new zn(ge.attributes.uv.array,2)),Ve.normalScale&&!Ne&&(Ve.normalScale.y=-Ve.normalScale.y),Pe.material=Ve},gt.prototype.loadMaterial=function(Pe){var ge=this,Ve=this.json,Ne=this.extensions,Ie=Ve.materials[Pe],it,ce={},we=Ie.extensions||{},Me=[];if(we[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var pe=Ne[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];it=pe.getMaterialType(),Me.push(pe.extendParams(ce,Ie,ge))}else if(we[i.KHR_MATERIALS_UNLIT]){var Be=Ne[i.KHR_MATERIALS_UNLIT];it=Be.getMaterialType(),Me.push(Be.extendParams(ce,Ie,ge))}else{it=Ur;var $e=Ie.pbrMetallicRoughness||{};if(ce.color=new en(1,1,1),ce.opacity=1,Array.isArray($e.baseColorFactor)){var ot=$e.baseColorFactor;ce.color.fromArray(ot),ce.opacity=ot[3]}$e.baseColorTexture!==void 0&&Me.push(ge.assignTexture(ce,"map",$e.baseColorTexture)),ce.metalness=$e.metallicFactor!==void 0?$e.metallicFactor:1,ce.roughness=$e.roughnessFactor!==void 0?$e.roughnessFactor:1,$e.metallicRoughnessTexture!==void 0&&(Me.push(ge.assignTexture(ce,"metalnessMap",$e.metallicRoughnessTexture)),Me.push(ge.assignTexture(ce,"roughnessMap",$e.metallicRoughnessTexture)))}Ie.doubleSided===!0&&(ce.side=rh);var bt=Ie.alphaMode||ae.OPAQUE;return bt===ae.BLEND?ce.transparent=!0:(ce.transparent=!1,bt===ae.MASK&&(ce.alphaTest=Ie.alphaCutoff!==void 0?Ie.alphaCutoff:.5)),Ie.normalTexture!==void 0&&it!==lr&&(Me.push(ge.assignTexture(ce,"normalMap",Ie.normalTexture)),ce.normalScale=new Lt(1,1),Ie.normalTexture.scale!==void 0&&ce.normalScale.set(Ie.normalTexture.scale,Ie.normalTexture.scale)),Ie.occlusionTexture!==void 0&&it!==lr&&(Me.push(ge.assignTexture(ce,"aoMap",Ie.occlusionTexture)),Ie.occlusionTexture.strength!==void 0&&(ce.aoMapIntensity=Ie.occlusionTexture.strength)),Ie.emissiveFactor!==void 0&&it!==lr&&(ce.emissive=new en().fromArray(Ie.emissiveFactor)),Ie.emissiveTexture!==void 0&&it!==lr&&Me.push(ge.assignTexture(ce,"emissiveMap",Ie.emissiveTexture)),Promise.all(Me).then(function(){var Vt;return it===L?Vt=Ne[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(ce):Vt=new it(ce),Ie.name!==void 0&&(Vt.name=Ie.name),Vt.map&&(Vt.map.encoding=hh),Vt.emissiveMap&&(Vt.emissiveMap.encoding=hh),Ue(Vt,Ie),Ie.extensions&&se(Ne,Vt,Ie),Vt})};function At(Pe,ge,Ve){var Ne=ge.attributes,Ie=new Pa;if(Ne.POSITION!==void 0){var it=Ve.json.accessors[Ne.POSITION],ce=it.min,we=it.max;if(ce!==void 0&&we!==void 0)Ie.set(new Ee(ce[0],ce[1],ce[2]),new Ee(we[0],we[1],we[2]));else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;var Me=ge.targets;if(Me!==void 0)for(var pe=new Ee,Be=0,$e=Me.length;Be<$e;Be++){var ot=Me[Be];if(ot.POSITION!==void 0){var it=Ve.json.accessors[ot.POSITION],ce=it.min,we=it.max;ce!==void 0&&we!==void 0?(pe.setX(Math.max(Math.abs(ce[0]),Math.abs(we[0]))),pe.setY(Math.max(Math.abs(ce[1]),Math.abs(we[1]))),pe.setZ(Math.max(Math.abs(ce[2]),Math.abs(we[2]))),Ie.expandByVector(pe)):console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}Pe.boundingBox=Ie;var bt=new Co;Ie.getCenter(bt.center),bt.radius=Ie.min.distanceTo(Ie.max)/2,Pe.boundingSphere=bt}function Dt(Pe,ge,Ve){var Ne=ge.attributes,Ie=[];function it(pe,Be){return Ve.getDependency("accessor",pe).then(function($e){Pe.setAttribute(Be,$e)})}for(var ce in Ne){var we=K[ce]||ce.toLowerCase();we in Pe.attributes||Ie.push(it(Ne[ce],we))}if(ge.indices!==void 0&&!Pe.index){var Me=Ve.getDependency("accessor",ge.indices).then(function(pe){Pe.setIndex(pe)});Ie.push(Me)}return Ue(Pe,ge),At(Pe,ge,Ve),Promise.all(Ie).then(function(){return ge.targets!==void 0?Oe(Pe,ge.targets,Ve):Pe})}function Ot(Pe,ge){var Ve=Pe.getIndex();if(Ve===null){var Ne=[],Ie=Pe.getAttribute("position");if(Ie!==void 0){for(var it=0;it0&&We(xt,Ne),xt.name=Ne.name||"mesh_"+Pe,$e.length>1&&(xt.name+="_"+bt),Ue(xt,Ne),ge.assignFinalMaterial(xt),ot.push(xt)}if(ot.length===1)return ot[0];for(var xn=new rl,bt=0,Vt=ot.length;bt1){var Be=it[ce.mesh]++;pe=Me.clone(),pe.name+="_instance_"+Be}else pe=Me;return ce.weights!==void 0&&pe.traverse(function($e){if($e.isMesh)for(var ot=0,bt=ce.weights.length;ot1?Me=new rl:we.length===1?Me=we[0]:Me=new rn,Me!==we[0])for(var pe=0,Be=we.length;pe{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)})}class gL extends te.MxCADPluginBase{constructor(){super(),this.map_default_data=hL()}}let _d;const{showModal:_L,hideModal:yd}=e0();function yL(){return wn(this,null,function*(){_L({title:"My Test Draw",text:"测试Modal",oncancel:()=>{yd()},onsubmit:()=>{yd()},ongetallentity:()=>{yd(),tt.MxFun.sendStringToExecute("TestGetAllEntity")},ondrawline:()=>{yd(),tt.MxFun.sendStringToExecute("Mx_Circle")},docommand:e=>{yd(),tt.MxFun.sendStringToExecute(e)}})})}const H1=document.createElement("div");document.body.appendChild(H1),ct.createApp(TM).mount(H1),SM(),tt.MxFun.on("mxcadApplicationStart",e=>{_d=e,_d.init(new gL)}),tt.MxFun.on("mxcadApplicationInitMap",()=>{dL(_d.mxmap)}),tt.MxFun.on("mxcadApplicationCreatedMxCADObject",e=>{e.mxcad.on("selectChange",i=>{if(i.length==0)return;let l=i[0],h=l.getMxDbEntity();if(h!==null){console.log(h.getTypeName()),h instanceof tt.MxDbRectBoxLeadComment&&console.log(h.text);return}let p=l.getMcDbEntity();p!==null&&(console.log(p.objectName),p instanceof te.McDbText?console.log(p.textString):p instanceof te.McDbBlockReference&&p.getAllAttribute().forEach(M=>{let T=M.getMcDbEntity();console.log(T.textString),console.log(T.tag)}))}),te.MxCpp.PropertiesWindow.onEvent_getProperties(i=>{let l=i.getMcDbEntity();if(!l)return[];let h=l.getxDataDouble("DN"),p=l.getxDataDouble("LEN"),_=[];return h.ret&&_.push({sVarName:"DN",iVarType:te.MxPropertiesWindowCustomValueType.kDouble,val:h.val,isOnlyRead:!1}),p.ret&&_.push({sVarName:"LEN",iVarType:te.MxPropertiesWindowCustomValueType.kDouble,val:p.val,isOnlyRead:!1}),_}),te.MxCpp.PropertiesWindow.onEvent_setProperties((i,l)=>{let h=i.getMcDbEntity();h&&(l.sVarName=="DN"?h.setxDataDouble("DN",l.val):l.sVarName=="LEN"&&h.setxDataDouble("LEN",l.val))})});function vd(){return _d}function Er(e){return"x="+e.x+",y="+e.y+",z="+e.z}function vL(){window.open("https://demo.mxdraw3d.com:3562/MxCADCode.7z")}function xL(){window.open("https://demo.mxdraw3d.com:3562/MxDrawCloudServer1.0TryVersion.7z")}function nu(e){var n=window.location.href;return n.indexOf("?")!=-1&&(n=n.replace(/(\?|#)[^'"]*/,"")),`${n}?map=true&maptype=${e}`}function bL(){window.open(nu("gdslwzj"))}function wL(){window.open(nu("google"))}function ML(){window.open(nu("gdyx"))}function TL(){window.open(nu("tdtsl"))}function EL(){window.open(nu("bdsl"))}function SL(){window.open(nu("geoq"))}function AL(){te.MxCpp.getCurrentMxCAD().setViewBackgroundColor(255,255,255),tt.MxFun.callEvent("updateBackgroundColor",new te.McCmColor(255,255,255))}function W1(){return wn(this,null,function*(){let e=new te.MxCADUiPrEntity;e.setMessage("选择要需要开启自定义属性的对象");let n=yield e.go();if(!n.isValid())return;let i=n.getMcDbEntity();te.MxCpp.PropertiesWindow.setEntitySupportCustom(n),i.setxDataDouble("DN",100),i.setxDataDouble("LEN",2e3)})}function CL(){te.MxCpp.getCurrentMxCAD().openWebFile("http://localhost:1337/mxcad/file/a9cbed3d3a351b79f24484e87bd78338.DWG.mxweb")}function PL(){return wn(this,null,function*(){})}function LL(){return wn(this,null,function*(){let e=new te.MxCADUiPrEntity;e.setMessage("选择要隐藏的对象");let n=yield e.go();if(!n.isValid())return;let i=n.getMcDbEntity(),l=te.MxCpp.getCurrentMxCAD(),_=l.getDatabase().getLayerTable().get(i.layer).getMcDbLayerTableRecord();_!==null&&(_.isOff=!0,l.updateLayerDisplayStatus(),l.updateDisplay())})}function DL(){return window.location.origin+window.location.pathname}function IL(){return wn(this,null,function*(){const e=new te.MxCADUiPrPoint;e.setMessage(` 指定插入点:`);let n=yield e.go();if(!n)return;let i=te.MxCpp.getCurrentMxCAD(),l=DL()+"mxcad.jpg";i.loadImage(l,h=>{if(!h){console.log("loadImage failed");return}let p=i.mxdraw.viewCoordLong2Cad(100),_=h.height/h.width*p;i.drawImage(n.x,n.y,p,_,0,l),i.updateDisplay()})})}function j1(){return wn(this,null,function*(){let e=te.MxCpp.getCurrentMxCAD(),n=new te.MxCADUiPrPoint,i=yield n.go();if(i==null)return;n.setBasePt(i);let l=yield n.go();if(l==null)return;let h=e.drawLine(i.x,i.y,l.x,l.y);e.addCurrentSelect(h)})}let q1=0;function Z1(){return wn(this,null,function*(){q1+=Math.PI*.5,te.MxCpp.getCurrentMxCAD().zoomAngle(q1)})}function X1(){te.MxCpp.getCurrentMxCAD().zoomCenter(900,900)}tt.MxFun.on("mxcadApplicationStartCreatingMxCADObject",e=>{let n=e.mxdraw;n.setViewMovementMethod(!0),n.on("openFileComplete",()=>{window.parent.postMessage({cmd:"MKY_Open_File_Complete"})}),n.addControlsEvent("mousedown",i=>{let l=i.offsetX,h=i.offsetY,p=n.viewCoord2Cad(l,h,0);return console.log("mousedown:",p),0})}),tt.MxFun.on("mxcadApplicationCreatedMxCADObject",e=>{e.mxcad.on("selectChange",i=>{if(i.length==0)return;let l=i[0],h=l.getMxDbEntity();if(h!==null){console.log(h.getTypeName()),h instanceof tt.MxDbRectBoxLeadComment&&console.log(h.text);return}let p=l.getMcDbEntity();p!==null&&(console.log(p.objectName),p instanceof te.McDbText?console.log(p.textString):p instanceof te.McDbBlockReference&&p.getAllAttribute().forEach(M=>{let T=M.getMcDbEntity();console.log(T.textString),console.log(T.tag)}))}),te.MxCpp.PropertiesWindow.onEvent_getProperties(i=>{let l=i.getMcDbEntity();if(!l)return[];let h=l.getxDataDouble("DN"),p=l.getxDataDouble("LEN"),_=[];return h.ret&&_.push({sVarName:"DN",iVarType:te.MxPropertiesWindowCustomValueType.kDouble,val:h.val,isOnlyRead:!1}),p.ret&&_.push({sVarName:"LEN",iVarType:te.MxPropertiesWindowCustomValueType.kDouble,val:p.val,isOnlyRead:!1}),_}),te.MxCpp.PropertiesWindow.onEvent_setProperties((i,l)=>{let h=i.getMcDbEntity();h&&(l.sVarName=="DN"?h.setxDataDouble("DN",l.val):l.sVarName=="LEN"&&h.setxDataDouble("LEN",l.val))}),RL()});function RL(){tt.MxFun.addCommand("My_PluginTest",yL),tt.MxFun.addCommand("Mx_Open_DemoCode",vL),tt.MxFun.addCommand("Mx_Open_DevInstall",xL),tt.MxFun.addCommand("Mx_Open_Map_gdslwzj",bL),tt.MxFun.addCommand("Mx_Open_Map_gdyx",ML),tt.MxFun.addCommand("Mx_Open_Map_tdtsl",TL),tt.MxFun.addCommand("Mx_Open_Map_bdsl",EL),tt.MxFun.addCommand("Mx_Open_Map_geoq",SL),tt.MxFun.addCommand("Mx_Open_Map_googlecn",wL),tt.MxFun.addCommand("Mx_ViewBackgroundColor",AL),tt.MxFun.addCommand("Mx_TestExProp",W1),tt.MxFun.addCommand("Mx_Test_OpenFile",CL),tt.MxFun.addCommand("Mx_Test_GetFile",PL),tt.MxFun.addCommand("Mx_TestExProp",W1),tt.MxFun.addCommand("Mx_SelectEntitHideLayer",LL),tt.MxFun.addCommand("MxTest_TestAddCurrentSelect",j1),tt.MxFun.addCommand("MxTest_TestSetViewAngle",Z1),tt.MxFun.addCommand("MxText_ZoomCenter",X1),tt.MxFun.addCommand("MxTest_Map_Download",pL),tt.MxFun.addCommand("Mx_Test_DrawImage",IL),kM(),$M(),MP(),EP(),n3(),u3(),d3(),g3(),y3(),Z3(),K3(),f3(),aL(),_d.mxmap&&mL(tt.MxFun.getCurrentDraw())}return wo.McGePoint3dToString=Er,wo.MxTest_TestAddCurrentSelect=j1,wo.MxTest_TestSetViewAngle=Z1,wo.MxText_ZoomCenter=X1,wo.getMxCADUi=vd,Object.defineProperty(wo,Symbol.toStringTag,{value:"Module"}),wo}({},Mx,mxcad,Vue,axios); //# sourceMappingURL=test.js.map