import{g as rt,bF as Li,b4 as Pi,t as V,a as E,bG as re,bH as ne,k as ae,A as x,bI as Ti,s as mt,V as je,bg as oe,bJ as zi,aX as Ii,bm as $i,z as bt,bk as St,B as le,b5 as Ct,aB as Wi,D as Ci,bK as Ei,l as he,bL as Ai,bM as Qe,bN as Je,bO as Ri,bP as ki,bQ as Fi,bR as Bi,bS as Se,bT as Le,bU as Pe,m as Vi,bV as Te,bW as Oi,al as ti,bq as Di}from"./index.6c049565.js";import{L as Ht,M as Gi,Q as st,h as Zi,j as ei,H as B,S as C,T as Ki,W as Ni,_ as Xi,$ as it,a0 as Ui,a1 as Hi,e as I,o as Lt,a2 as ii,a3 as Yi,a as ze,a4 as qi,a5 as si,a6 as Vt,a7 as ri}from"./enums.0295eb81.js";import{f as ji,p as Qi}from"./visualVariablesUtils.4b17aac7.js";import{b as P,G as Yt,x as k,e as M,f as Y,j as $,S as Ot,k as Ji,t as ts}from"./Utils.e8554a0e.js";import{l as es}from"./tileUtils.a1e62810.js";import{n as ni,r as is,c as ss,i as rs}from"./TileClipper.7297efa2.js";import{U as qt,s as ns,r as ai,n as oi,i as as,a as os,Z as ls,c as hs,o as cs,N as ce,C as Et,w as ft,O as At,b as li,P as us,f as ue}from"./MaterialKey.bbaab8f1.js";import{g as fs,f as _s,j as ds,h as Xt,n as Ie,m as ms,k as Pt,l as ps,T as ys,q as xs}from"./ExpandedCIM.64535143.js";import{M as jt}from"./GeometryUtils.51c4032a.js";import"./earcut.afc1d357.js";import{s as hi}from"./Geometry.d049a63c.js";import{c as gs,a as Ms}from"./devEnvironmentUtils.d8d0484c.js";function F(n,t){if(n&&"name"in n){const e=n;return t&&t.error(new rt(e.name,e.message,e.details)),!1}return!0}const vs=1.25;class Tt{constructor(t,e){this._pos=0;const i=e?this._roundToNearest(e,t.BYTES_PER_ELEMENT):40;this._array=new ArrayBuffer(i),this._buffer=new t(this._array),this._ctor=t,this._i16View=new Int16Array(this._array)}get length(){return this._pos}_roundToNearest(t,e){const i=Math.round(t);return i+(e-i%e)}_ensureSize(t){if(this._pos+t>=this._buffer.length){const e=this._roundToNearest((this._array.byteLength+t*this._buffer.BYTES_PER_ELEMENT)*vs,this._buffer.BYTES_PER_ELEMENT),i=new ArrayBuffer(e),s=new this._ctor(i);s.set(this._buffer,0),this._array=i,this._buffer=s,this._i16View=new Int16Array(this._array)}}ensureSize(t){this._ensureSize(t)}writeF32(t){this._ensureSize(1);const e=this._pos;return new Float32Array(this._array,4*this._pos,1)[0]=t,this._pos++,e}push(t){this._ensureSize(1);const e=this._pos;return this._buffer[this._pos++]=t,e}writeFixed(t){this._buffer[this._pos++]=t}setValue(t,e){this._buffer[t]=e}i1616Add(t,e,i){this._i16View[2*t]+=e,this._i16View[2*t+1]+=i}getValue(t){return this._buffer[t]}incr(t){if(this._buffer.length{const r=1<=st-i?Ee:Ae|Ee)|(e<0+s?ke:e>=st-s?Re:ke|Re));this._current.overlaps|=r}_getVertexWriter(t){if(!this._data.self.has(t)){const e=this._data.self,i=Yt(t,this._symbologyType).geometry;e.set(t,new $e(t,i,this.hint.records))}return this._data.self.get(t)}}const G=0,Z=100;function Fe(n,t,e){return n[0]=t[0]-e[0],n[1]=t[1]-e[1],n}function ci(n,t){return Math.sqrt(n*n+t*t)}function Be(n){const t=ci(n[0],n[1]);n[0]/=t,n[1]/=t}function bs(n,t){return ci(n[0]-t[0],n[1]-t[1])}function w(n){return typeof n=="function"}function Qt(n=2){return 1/Math.max(n,1)}function J(n,t){return[!!n.minScale&&t.scaleToZoom(n.minScale)||G,!!n.maxScale&&t.scaleToZoom(n.maxScale)||Z]}function Ss(n,t){return n[t+1]}function ui(n){return n.length-1}function Ls(n){let t=0;for(let e=0;et._index||this._index===t._index&&this._distance>=t._distance}get _segment(){return this._segments[this._index+1]}get angle(){const t=this.dy,e=(0*t+-1*-this.dx)/(1*this.length);let i=Math.acos(e);return t>0&&(i=2*Math.PI-i),i}get xStart(){return this._xStart}get yStart(){return this._yStart}get x(){return this.xStart+this.distance*this.dx}get y(){return this.yStart+this.distance*this.dy}get dx(){return this._segment[0]}get dy(){return this._segment[1]}get xMidpoint(){return this.xStart+.5*this.dx}get yMidpoint(){return this.yStart+.5*this.dy}get xEnd(){return this.xStart+this.dx}get yEnd(){return this.yStart+this.dy}get length(){const{dx:t,dy:e}=this;return Math.sqrt(t*t+e*e)}get remainingLength(){return this.length*(1-this._distance)}get backwardLength(){return this.length*this._distance}get distance(){return this._distance}get done(){return this._done}hasPrev(){return this._index-1>=0}hasNext(){return this._index+1t)return this._seekBackwards(t-s);s+=this.length}return this._distance=0,e?this:null}seek(t,e=!1){if(t<0)return this._seekBackwards(Math.abs(t),e);if(t<=this.remainingLength)return this._distance=(this.backwardLength+t)/this.length,this;let i=this.remainingLength;for(;this.next();){if(i+this.length>t)return this.seek(t-i,e);i+=this.length}return this._distance=1,e?this:null}}function Ts(n,t,e,i=!0){const s=Ls(n),r=Rt.create(n),a=s/2;if(!i)return r.seek(a),void e(r.clone(),0,a+0*t,s);const o=Math.max((s-t)/2,0),l=Math.floor(o/t),h=a-l*t;r.seek(h);for(let u=-l;u<=l;u++)r.x<512&&r.x>=0&&r.y<512&&r.y>=0&&e(r.clone(),u,a+u*t,s),r.seek(t)}function zs(n,t){const e=t;for(let i=0;i=0&&!(s[d+1]s[c]+u);d++){const y=u-s[d-1]+s[c],p=s[d]-s[d-1],g=s[d]-s[c]class extends n{constructor(...t){super(...t),this._isCIM=!1,this._vertexBoundsScale=1,this.geometryType=P.TEXT,this._aux=k(0,0,this._referenceSize,this._bitset)}bindTextInfo(t,e){t&&t.length?this._shapingInfo=Pi(t,i=>ds(i,e,{scale:this._scale,angle:this._angle,xOffset:this._xOffset,yOffset:this._yOffset,hAlign:this._xAlignD,vAlign:this._yAlignD,maxLineWidth:Math.max(32,Math.min(this._lineWidth,512)),lineHeight:Zi*Math.max(.25,Math.min(this._lineHeight,4)),decoration:this._decoration,isCIM:this._isCIM})):this._shapingInfo=null}_write(t,e,i,s){const r=e.getDisplayId();this._writeGeometry(t,e,r,i,s)}_writeGeometry(t,e,i,s,r){const a=this._shapingInfo;if(V(a))return;if(E(this._textPlacement)){const l=r!=null?r:e.readLegacyGeometryForDisplay();return this._writePlacedText(t,i,l,a,s)}const o=r?re(ne(r),2):e.geometryType==="esriGeometryPolygon"?e.readCentroid():e.readGeometryForDisplay();if(!V(o)){if(o.isPoint){const[l,h]=o.coords;return!t.hasAggregates&&t.hasPixelBufferEnabled&&(l<0||l>=512||h<0||h>=512)?void 0:this._writeGlyphs(t,i,{x:l,y:h},a)}o.forEachVertex((l,h)=>this._writeGlyphs(t,i,{x:l,y:h},a))}}_writePlacedText(t,e,i,s,r){const a=ae(this._textPlacement),o=fi.getPlacement(i,a,x(1),r.geometryEngine);if(!o)return;let l=o.next();for(;l!=null;){const h=-l.getAngle();s.setRotation(h);const u=l.tx,c=-l.ty;u<0||u>=512||c<0||c>=512||(this._writeGlyphs(t,e,{x:u,y:c},s),s.setRotation(-h)),l=o.next()}}_writeGlyphs(t,e,i,s){const r=qt.load(this._materialKey),a=M(Math.round(zt*i.x),Math.round(zt*i.y)),o=this._vertexBoundsScale,l=s.bounds,h=2*Math.max(l.width,l.height);for(const u of s.glyphs)r.textureBinding=u.textureBinding,t.recordStart(e,r.data,this.geometryType,!0),t.vertexBounds(i.x+l.x+this._xOffset,i.y+l.y-this._yOffset,h*o,h*o),this._writeVertices(t,e,a,u),t.recordEnd()}_writeGlyph(t,e,i,s,r){const a=qt.load(this._materialKey),o=M(Math.round(zt*i),Math.round(zt*s));a.textureBinding=r.textureBinding,t.recordStart(e,a.data,this.geometryType,!0);const l=r.bounds,h=this._vertexBoundsScale;t.vertexBounds(i+l.x*h,s+l.y*h,l.width*h,l.height*h),this._writeVertices(t,e,o,r),t.recordEnd()}_writeVertices(t,e,i,s){const r=t.vertexCount();this._writeVertexCommon(t,e,i,s),t.vertexWrite(s.offsets.upperLeft),t.vertexWrite(s.texcoords.upperLeft),t.vertexEnd(),this._writeVertexCommon(t,e,i,s),t.vertexWrite(s.offsets.upperRight),t.vertexWrite(s.texcoords.upperRight),t.vertexEnd(),this._writeVertexCommon(t,e,i,s),t.vertexWrite(s.offsets.lowerLeft),t.vertexWrite(s.texcoords.lowerLeft),t.vertexEnd(),this._writeVertexCommon(t,e,i,s),t.vertexWrite(s.offsets.lowerRight),t.vertexWrite(s.texcoords.lowerRight),t.vertexEnd(),t.indexWrite(r+0),t.indexWrite(r+1),t.indexWrite(r+2),t.indexWrite(r+1),t.indexWrite(r+3),t.indexWrite(r+2)}_writeVertexCommon(t,e,i,s){const r=this._color,a=this._haloColor,o=k(0,0,this._referenceSize,this._bitset),l=k(0,0,this._size,this._haloSize);t.vertexWrite(i),t.vertexWrite(e),t.vertexWrite(r),t.vertexWrite(a),t.vertexWrite(l),t.vertexWrite(o),t.vertexWrite(this._minMaxZoom)}};class wt{bindFeature(t,e,i){}write(t,e,i,s){var o;if(V(this._effects)||((o=this._effects)==null?void 0:o.length)===0)return this._write(t,e,s);const r=Xt.executeEffects(this._effects,e.readLegacyGeometryForDisplay(),s.geometryEngine);let a=Xt.next(r);for(;a;)this._write(t,e,s,a),a=Xt.next(r)}_write(t,e,i,s){}}const $s=5;class _t extends _i(wt){constructor(t,e,i,s,r,a,o,l,h,u,c,_,f,m,d,y,p,g,v=!1,b,L){super(),this._xOffset=x(f),this._yOffset=x(m),this._decoration=u||"none",this._color=r,this._haloColor=a,this._haloSize=Math.min(Math.floor($s*x(Ti(i))),127),this._size=Math.min(Math.round(x(e)),127);const S=Math.min(Math.round(x(s||e)),127);this._referenceSize=Math.round(Math.sqrt(256*S)),this._scale=this._size/ei,this._angle=_,this._justify=ns(o||"center"),this._xAlignD=ai(o||"center"),this._yAlignD=oi(l||"baseline"),this._baseline=(l||"baseline")==="baseline",this._bitset=(h===B.MAP?1:0)|(c?1:0)<<1;const T=qt.load(t);T.sdf=!0,this._materialKey=T.data,this._lineWidth=x(d)||512,this._lineHeight=y||1,this._textPlacement=p,this._effects=g,this._isCIM=v,this._minMaxZoom=M(Math.round(b*C),Math.round(L*C))}static fromText(t,e){const i=new _t(t.materialKey,t.font.size,t.haloSize||0,t.font.size,t.color&&Y(t.color)||0,t.haloColor&&Y(t.haloColor)||0,t.horizontalAlignment,t.verticalAlignment,B.SCREEN,t.font.decoration,!1,t.angle||0,t.xoffset,t.yoffset,t.lineWidth,t.lineHeight,null,null,!1,G,Z),[,s]=Ie(t.text);return i.bindTextInfo(e,s),i._vertexBoundsScale=t.maxVVSize?t.maxVVSize/t.font.size:1,i}static fromCIMText(t,e,i){const s=t.scaleFactor||1,r=t.size*t.sizeRatio*s,[a,o]=J(t.scaleInfo,i),l=new _t(t.materialKey,r,t.outlineSize*t.sizeRatio,t.referenceSize,$(t.color),$(t.outlineColor),t.horizontalAlignment,t.verticalAlignment,t.alignment,t.decoration,t.colorLocked,t.angle,t.offsetX*t.sizeRatio*s,t.offsetY*t.sizeRatio*s,512,1,t.markerPlacement,t.effects,!0,a,o),[,h]=Ie(t.text);return l.bindTextInfo(e,h),l._vertexBoundsScale=t.maxVVSize?t.maxVVSize/r:1,l}}const Ws=mt.getLogger("esri.views.2d.engine.webgl.WGLLabelTemplate"),Cs=(n,t="mapview-labeling")=>Ws.error(new rt(t,n)),It=1,ot=0,Es=4,Ve=25;function As(n,t){const e=!!n.minScale&&t.scaleToZoom(n.minScale)||0;return je(e,0,25.5)}function Rs(n,t){const e=!!n.maxScale&&t.scaleToZoom(n.maxScale)||255;return je(e,0,25.5)}function ks(n){const t=new Map;return e=>(t.has(e)||t.set(e,n(e)),t.get(e))}const Fs=ks(n=>{let t=0;if(n===0)return 1/0;for(;!(n%2);)t++,n/=2;return t}),$t=n=>Math.floor(127*n+127),pt=n=>Math.floor(10*n),lt=n=>Math.round(n*(254/360));class kt extends _t{constructor(t,e,i,s){var c,_,f;super(t,i.font.size,i.haloSize||0,i.font.size,i.color&&Y(i.color)||0,i.haloColor&&Y(i.haloColor)||0,i.horizontalAlignment,i.verticalAlignment,as(e.labelPlacement)?B.MAP:B.SCREEN,i.font.decoration,!1,i.angle||0,i.xoffset,i.yoffset,i.lineWidth,i.lineHeight,null,null,null,null,null),this._outLineLabelAngle=0,this._refPlacementPadding=0,this._refPlacementDirX=0,this._refPlacementDirY=0,this._refOffsetX=0,this._refOffsetY=0,this._zoomLevel=0,this.geometryType=P.LABEL,this._allowOverrun=(c=e.allowOverrun)!=null?c:!1,this._repeatLabel=(_=e.repeatLabel)!=null?_:!0,this._labelPosition=(f=e.labelPosition)!=null?f:"curved";const r=As(e,s),a=Rs(e,s),o=e.labelPlacement,[l,h]=os(o);this._xAlignD=l,this._yAlignD=h,this._minZoom=r,this._maxZoom=a,this._refPlacementPadding=x(i.haloSize)+Ki,this._repeatLabelDistance=e.repeatLabelDistance?x(e.repeatLabelDistance):128;const u=ls.load(t);u.sdf=!0,this._materialKey=u.data}static fromLabelClass(t,e){if(t.labelPlacement==="esriServerLinePlacementCenterAlong"){const i=t.symbol;i.xoffset=0,i.yoffset=0,i.angle=0,i.font.decoration="none"}return new kt(t.materialKey,t,t.symbol,e)}get _shapedBox(){return ae(this._shapingInfo).bounds}setZoomLevel(t){this._zoomLevel=t}bindReferenceTemplate(t){let e=hs(this._xAlignD),i=cs(this._yAlignD);if(this._refOffsetX=0,this._refOffsetY=0,V(t))return void(this._refSymbolAndPlacementOffset=k(0,0,$t(e),$t(i)));if(t.boundsType==="circle"&&(e||i)){const a=Math.sqrt(e*e+i*i);e/=a,i/=a}const s=Math.max(t.height,t.width),r=this._refPlacementPadding*Es;this._refSymbolAndPlacementOffset=k(r,s,$t(e),$t(i)),this._referenceSize=s,this._refPlacementDirX=e,this._refPlacementDirY=i,this._refOffsetX=t.xOffset,this._refOffsetY=t.yOffset}_write(t,e){if(V(this._shapingInfo))return;const i=this._shapingInfo,s=e.getDisplayId(),r=e.geometryType==="esriGeometryPolygon"?e.readLegacyCentroid():e.readLegacyGeometry();if(r)switch(this._current={out:t,inId:s,inShaping:i,zoomLevel:this._zoomLevel},e.geometryType){case"esriGeometryPolyline":this._placeLineLabels(r);break;case"esriGeometryPoint":case"esriGeometryPolygon":this._placePointLabels(r);break;default:Cs("mapview-labeling",`Geometry of type ${e.geometryType} is not supported`)}}_isVisible(t,e){const i=pt(this._current.zoomLevel);return pt(t)<=i&&i<=pt(e)}_placePointLabels(t){const{out:e,inId:i,inShaping:s}=this._current;this._writeGlyphs(e,i,t,s)}_placeLineLabels(t){const e=zs(t.paths,this._current.inShaping.bounds.width),i=this._placeSubdivGlyphs.bind(this),s=(this._shapedBox.width+this._repeatLabelDistance)/(1<=s);)this._placeOnSegment(a,e,o,i,-1,r),o+=a.length+ot}_placeForward(t,e,i,s,r){const a=t.clone();let o=t.remainingLength+ot;for(;a.next()&&!(o>=s);)this._placeOnSegment(a,e,o,i,1,r),o+=a.length+ot}_placeFirst(t,e,i,s=!1){const r=t,a=this._current.inShaping,o=a.glyphs,l=this._current.zoomLevel,{out:h,inId:u}=this._current;for(const c of o){const _=c.x>a.bounds.x?i:1-i,f=_*t.remainingLength+(1-_)*t.backwardLength,m=Math.abs(c.x+c.width/2-a.bounds.x),d=Math.max(0,l+Math.log2(m/(f+ot))),y=Math.max(e,s?0:d);if(c.maxZoom=Ve,c.angle=t.angle+(1-i)*Math.PI,c.minZoom=y,this._writeGlyph(h,u,r.x,r.y,c),i&&this._isVisible(c.minZoom,c.maxZoom)){const p=c.bounds;h.metricBoxWrite(p.center[0],p.center[1],p.width,p.height)}}}_placeOnSegment(t,e,i,s,r,a){const o=this._current.inShaping.glyphs,{out:l,inId:h}=this._current,u=this._current.inShaping,c=this._current.zoomLevel,_=t.dx/t.length,f=t.dy/t.length,m={x:t.x+i*-r*_,y:t.y+i*-r*f};for(const d of o){const y=d.x>u.bounds.x?a:1-a;if(!(y&&r===1||!y&&r===-1))continue;const p=Math.abs(d.x+d.width/2-u.bounds.x),g=Math.max(0,c+Math.log2(p/i)-.1),v=Math.max(s,c+Math.log2(p/(i+t.length+ot)));if(g!==0&&(d.angle=t.angle+(1-a)*Math.PI,d.minZoom=v,d.maxZoom=g,this._writeGlyph(l,h,m.x,m.y,d),a&&this._isVisible(d.minZoom,d.maxZoom))){const b=d.bounds,L=t.x-e.x,S=t.y-e.y;l.metricBoxWrite(b.center[0]+L,b.center[1]+S,b.width,b.height)}}}_writeGlyphs(t,e,i,s,r=this._minZoom){if(i.x<0||i.x>=512||i.y<0||i.y>=512)return;const a=i.x+this._refOffsetX,o=i.y-this._refOffsetY;for(const c of s.glyphs)c.minZoom=r,c.maxZoom=this._maxZoom,this._writeGlyph(t,e,a,o,c);const l=this._refPlacementDirX,h=this._refPlacementDirY,u=s.boundsT;t.metricStart(e,r,a,o,l,h,this._referenceSize,this._materialKey),t.metricBoxWrite(u.center[0],u.center[1],u.width,u.height),t.metricEnd()}_writeVertexCommon(t,e,i,s){const r=this._color,a=this._haloColor,o=k(0,0,this._size,this._haloSize),l=Math.max(s.minZoom,this._minZoom),h=Math.min(s.maxZoom,this._maxZoom),u=k(pt(l),pt(h),this._outLineLabelAngle,0);t.vertexWrite(i),t.vertexWrite(e),t.vertexWrite(r),t.vertexWrite(a),t.vertexWrite(o),t.vertexWrite(this._refSymbolAndPlacementOffset),t.vertexWrite(u)}}const Oe=3.14159265359/180,De=8,di=n=>class extends n{constructor(...t){super(...t),this.angle=0,this.xOffset=0,this.yOffset=0,this.width=0,this.height=0,this.boundsType="square",this._anchorX=0,this._anchorY=0,this._computedWidth=0,this._computedHeight=0,this._vertexBoundsScaleX=1,this._vertexBoundsScaleY=1,this._offsets={xUpperLeft:0,yUpperLeft:0,xUpperRight:0,yUpperRight:0,xBottomLeft:0,yBottomLeft:0,xBottomRight:0,yBottomRight:0},this.geometryType=P.MARKER}_write(t,e,i,s){const r=e.getDisplayId();t.recordStart(r,this._materialKey,this.geometryType,!0),this._writeGeometry(t,e,r,i,s),t.recordEnd()}_writeGeometry(t,e,i,s,r){if(E(this._markerPlacement))return this._writePlacedMarkers(t,e,s,r);if(!r&&e.geometryType==="esriGeometryPoint"){const o=e.getX(),l=e.getY();return!t.hasAggregates&&t.hasPixelBufferEnabled&&(o<0||o>=513||l<0||l>=513)?void 0:this._writeVertices(t,i,this._getPos(o,l),o,l)}const a=r?re(ne(r),2):e.geometryType==="esriGeometryPolygon"?e.readCentroid():e.readGeometryForDisplay();if(!V(a)){if(a.isPoint){const[o,l]=a.coords;return!t.hasAggregates&&t.hasPixelBufferEnabled&&(o<0||o>=512||l<0||l>=512)?void 0:this._writeVertices(t,i,this._getPos(o,l),o,l)}a.forEachVertex((o,l)=>{const h=2*st;o<-h||o>=h||l<-h||l>=h||this._writeVertices(t,i,this._getPos(o,l),o,l)})}}_writePlacedMarkers(t,e,i,s){const r=s!=null?s:e.readLegacyGeometryForDisplay(),a=fi.getPlacement(r,ae(this._markerPlacement),x(1),i.geometryEngine);if(!a)return;const o=e.getDisplayId(),l=le(),h=oe(),u=-128,c=640;let _=a.next();for(;_!=null;){const f=_.tx,m=-_.ty;f>=u&&f<=c&&m>=u&&m<=c&&(this._applyTransformation(h,l,-_.getAngle()/Oe),this._writeVertices(t,o,this._getPos(f,m),f,m)),_=a.next()}}_writeVertices(t,e,i,s,r){const a=ce.load(this._materialKey);return a.symbologyType===Ot.HEATMAP?this._writeHeatmapVertices(t,e,i):this._writeMarkerVertices(t,e,a,i,s,r)}_writeMarkerVertices(t,e,i,s,r,a){const o=i.vvRotation,l=t.vertexCount();let h=this._computedWidth*this._vertexBoundsScaleX,u=this._computedHeight*this._vertexBoundsScaleY;if(this.angle){const c=Math.max(h,u);h=c,u=c}if(o){const c=Math.max(this.xOffset,this.yOffset);h+=c,u+=c}t.vertexBounds(r+this.xOffset,a-this.yOffset,h,u),t.vertexWrite(s),t.vertexWrite(this._offsetUpperLeft),t.vertexWrite(this._texUpperLeft),t.vertexWrite(this._bitestAndDistRatio),t.vertexWrite(e),t.vertexWrite(this._fillColor),t.vertexWrite(this._outlineColor),t.vertexWrite(this._sizeOutlineWidth),t.vertexWrite(this._minMaxZoom),t.vertexEnd(),t.vertexWrite(s),t.vertexWrite(this._offsetUpperRight),t.vertexWrite(this._texUpperRight),t.vertexWrite(this._bitestAndDistRatio),t.vertexWrite(e),t.vertexWrite(this._fillColor),t.vertexWrite(this._outlineColor),t.vertexWrite(this._sizeOutlineWidth),t.vertexWrite(this._minMaxZoom),t.vertexEnd(),t.vertexWrite(s),t.vertexWrite(this._offsetBottomLeft),t.vertexWrite(this._texBottomLeft),t.vertexWrite(this._bitestAndDistRatio),t.vertexWrite(e),t.vertexWrite(this._fillColor),t.vertexWrite(this._outlineColor),t.vertexWrite(this._sizeOutlineWidth),t.vertexWrite(this._minMaxZoom),t.vertexEnd(),t.vertexWrite(s),t.vertexWrite(this._offsetBottomRight),t.vertexWrite(this._texBottomRight),t.vertexWrite(this._bitestAndDistRatio),t.vertexWrite(e),t.vertexWrite(this._fillColor),t.vertexWrite(this._outlineColor),t.vertexWrite(this._sizeOutlineWidth),t.vertexWrite(this._minMaxZoom),t.vertexEnd(),this._writeIndices(t,l)}_writeHeatmapVertices(t,e,i){const s=t.vertexCount();t.vertexWrite(i),t.vertexWrite(this._offsetUpperLeft),t.vertexWrite(e),t.vertexEnd(),t.vertexWrite(i),t.vertexWrite(this._offsetUpperRight),t.vertexWrite(e),t.vertexEnd(),t.vertexWrite(i),t.vertexWrite(this._offsetBottomLeft),t.vertexWrite(e),t.vertexEnd(),t.vertexWrite(i),t.vertexWrite(this._offsetBottomRight),t.vertexWrite(e),t.vertexEnd(),this._writeIndices(t,s)}_writeIndices(t,e){t.indexWrite(e+0),t.indexWrite(e+1),t.indexWrite(e+2),t.indexWrite(e+1),t.indexWrite(e+3),t.indexWrite(e+2)}_applyTransformation(t,e,i=0){zi(t,Ii(this.xOffset,-this.yOffset)),this.angle+i!==0&&$i(t,t,Oe*(this.angle+i));const s=this._computedWidth,r=this._computedHeight,a=-(.5+this._anchorX)*s,o=-(.5-this._anchorY)*r;bt(e,a,o),St(e,e,t),this._offsetUpperLeft=M(16*e[0],16*e[1]),this._offsets.xUpperLeft=e[0],this._offsets.yUpperLeft=e[1],bt(e,a+s,o),St(e,e,t),this._offsetUpperRight=M(16*e[0],16*e[1]),this._offsets.xUpperRight=e[0],this._offsets.yUpperRight=e[1],bt(e,a,o+r),St(e,e,t),this._offsetBottomLeft=M(16*e[0],16*e[1]),this._offsets.xBottomLeft=e[0],this._offsets.yBottomLeft=e[1],bt(e,a+s,o+r),St(e,e,t),this._offsetBottomRight=M(16*e[0],16*e[1]),this._offsets.xBottomRight=e[0],this._offsets.yBottomRight=e[1]}_getPos(t,e){return M(Math.round(De*t),Math.round(De*e))}};class D extends di(wt){constructor(t,e,i,s,r,a,o,l,h,u,c,_,f,m,d,y,p,g,v,b,L,S,T){super(),this.angle=s,this.height=o,this.width=a,this.xOffset=e*v,this.yOffset=i*v,this._markerPlacement=b,this._effects=L,this._anchorX=y,this._anchorY=p,this._minMaxZoom=M(Math.round(S*C),Math.round(T*C));const z=(m===B.MAP?Ni:Xi)|(c?it:0)|(f?Ui:0)|(_?Hi:0),N=d&&d.sdf,q=ce.load(t);q.sdf=N,q.pattern=!0,q.textureBinding=d.textureBinding,this._materialKey=q.data,this._fillColor=r,this._outlineColor=h,this._sizeOutlineWidth=k(Math.round(Math.min(Math.sqrt(128*a),255)),Math.round(Math.min(Math.sqrt(128*o),255)),Math.round(Math.min(Math.sqrt(128*u),255)),Math.round(Math.min(Math.sqrt(128*l),255)));const j=d.rect.x+I,O=d.rect.y+I,nt=j+d.width,at=O+d.height;this._offsets.xUpperLeft=j,this._offsets.yUpperLeft=O,this._offsets.xUpperRight=nt,this._offsets.yUpperRight=O,this._offsets.xBottomLeft=j,this._offsets.yBottomLeft=at,this._offsets.xBottomRight=nt,this._offsets.yBottomRight=at,q.symbologyType===Ot.PIE_CHART?(this._texUpperLeft=M(0,1),this._texUpperRight=M(1,1),this._texBottomLeft=M(0,0),this._texBottomRight=M(1,0)):(this._texUpperLeft=M(j,O),this._texUpperRight=M(nt,O),this._texBottomLeft=M(j,at),this._texBottomRight=M(nt,at)),a*=g,o*=g,a*=v,o*=v;const wi=Math.round(64*g);this._bitestAndDistRatio=M(z,wi),this._computedWidth=a,this._computedHeight=o;const bi=le(),Si=oe();this._applyTransformation(Si,bi)}static fromCIMMarker(t,e,i){const s=e&&e.width||1,r=e&&e.height||1,a=t.size,o=s/r*t.scaleX,l=t.scaleSymbolsProportionally&&t.frameHeight?a/t.frameHeight:1;let h=$(t.color);const u=$(t.outlineColor),c=x(a),_=c*o,f=x(t.offsetX||0),m=x(t.offsetY||0),d=x(t.outlineWidth||0)*l,y=t.alignment||B.SCREEN,p=x(t.referenceSize),[g,v]=J(t.scaleInfo,i);e.sdf||h!==0||(h=-1);let b=t.rotation||0;t.rotateClockwise||(b=-b);let L=0,S=0;const T=t.anchorPoint;T&&(t.isAbsoluteAnchorPoint?a&&(L=T.x/(a*o),S=T.y/a):(L=T.x,S=T.y));const z=new D(t.materialKey,f,m,b,h,_,c,p,u,d,t.colorLocked,t.scaleSymbolsProportionally,!1,y,e,L,S,t.sizeRatio,Ct(t.scaleFactor,1),t.markerPlacement,t.effects,g,v);return z._vertexBoundsScaleX=t.maxVVSize?t.maxVVSize/_:1,z._vertexBoundsScaleY=t.maxVVSize?t.maxVVSize/c:1,z}static fromPictureMarker(t,e){const i=Math.round(x(t.width)),s=Math.round(x(t.height)),r=ii,a=Math.round(x(t.xoffset||0)),o=Math.round(x(t.yoffset||0)),l=new D(t.materialKey,a,o,t.angle,r,i,s,s,0,0,!1,!1,!1,B.SCREEN,e,0,0,1,1,null,null,G,Z);return l._vertexBoundsScaleX=t.maxVVSize?t.maxVVSize/t.width:1,l._vertexBoundsScaleY=t.maxVVSize?t.maxVVSize/t.height:1,l}static fromSimpleMarker(t,e){const i=Y(t.color),s=Math.round(x(t.size)),r=s,a=Math.round(x(t.xoffset||0)),o=Math.round(x(t.yoffset||0)),l=t.style,h=t.outline,u=0|(h&&h.color&&Y(h.color)),c=0|(h&&h.width&&Math.round(x(h.width))),_=new D(t.materialKey,a,o,t.angle,i,s,r,r,u,c,!1,!1,l==="esriSMSCross"||l==="esriSMSX",B.SCREEN,e,0,0,126/64,1,null,null,G,Z);return _.boundsType=l==="esriSMSCircle"?"circle":"square",_._vertexBoundsScaleX=t.maxVVSize?t.maxVVSize/t.size:1,_._vertexBoundsScaleY=t.maxVVSize?t.maxVVSize/t.size:1,_}static fromLineSymbolMarker(t,e){const i=Y(t.color),s=6,r=Math.round(x(s*t.lineWidth)),a=r,o=t.style==="cross"||t.style==="x";let l;switch(t.placement){case"begin-end":l=Lt.Both;break;case"begin":l=Lt.JustBegin;break;case"end":l=Lt.JustEnd;break;default:l=Lt.None}const h={type:"CIMMarkerPlacementAtExtremities",angleToLine:!0,offset:0,extremityPlacement:l,offsetAlongLine:0},u=new D(t.materialKey,0,0,0,i,r,a,a/s,i,o?Math.round(x(t.lineWidth)):0,!1,!1,o,B.MAP,e,0,0,126/64,1,h,null,G,Z);return u.boundsType=t.style==="circle"?"circle":"square",u}}function Bs(n,t,e,i,s,r,a){ee=0;const o=(i-e)*r,l=s&&s.length,h=l?(s[0]-e)*r:o;let u,c,_,f,m,d=mi(t,e,i,0,h,r,!0);if(d&&d.next!==d.prev){if(l&&(d=Gs(t,e,i,s,d,r)),o>80*r){u=_=t[0+e*r],c=f=t[1+e*r];for(let y=r;y0)for(let l=i;l=i;l-=r)o=Ge(l+t*r,n[l+t*r],n[l+1+t*r],o);return o&&et(o,o.next)&&(Mt(o),o=o.next),o}function xt(n,t=n){if(!n)return n;let e,i=n;do if(e=!1,i.steiner||!et(i,i.next)&&W(i.prev,i,i.next)!==0)i=i.next;else{if(Mt(i),i=t=i.prev,i===i.next)break;e=!0}while(e||i!==t);return t}function gt(n,t,e,i,s,r,a,o){if(!n)return;!o&&r&&(n=pi(n,i,s,r));let l=n;for(;n.prev!==n.next;){const h=n.prev,u=n.next;if(r?Os(n,i,s,r):Vs(n))t.push(h.index/e+a),t.push(n.index/e+a),t.push(u.index/e+a),Mt(n),n=u.next,l=u.next;else if((n=u)===l){o?o===1?gt(n=Ys(n,t,e,a),t,e,i,s,r,a,2):o===2&&qs(n,t,e,i,s,r,a):gt(xt(n),t,e,i,s,r,a,1);break}}}function Vs(n){const t=n.prev,e=n,i=n.next;if(W(t,e,i)>=0)return!1;let s=n.next.next;const r=s;let a=0;for(;s!==n.prev&&(a===0||s!==r);){if(a++,ut(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y)&&W(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function Os(n,t,e,i){const s=n.prev,r=n,a=n.next;if(W(s,r,a)>=0)return!1;const o=s.xr.x?s.x>a.x?s.x:a.x:r.x>a.x?r.x:a.x,u=s.y>r.y?s.y>a.y?s.y:a.y:r.y>a.y?r.y:a.y,c=Jt(o,l,t,e,i),_=Jt(h,u,t,e,i);let f=n.prevZ,m=n.nextZ;for(;f&&f.z>=c&&m&&m.z<=_;){if(f!==n.prev&&f!==n.next&&ut(s.x,s.y,r.x,r.y,a.x,a.y,f.x,f.y)&&W(f.prev,f,f.next)>=0||(f=f.prevZ,m!==n.prev&&m!==n.next&&ut(s.x,s.y,r.x,r.y,a.x,a.y,m.x,m.y)&&W(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;f&&f.z>=c;){if(f!==n.prev&&f!==n.next&&ut(s.x,s.y,r.x,r.y,a.x,a.y,f.x,f.y)&&W(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;m&&m.z<=_;){if(m!==n.prev&&m!==n.next&&ut(s.x,s.y,r.x,r.y,a.x,a.y,m.x,m.y)&&W(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function Ge(n,t,e,i){const s=dt.create(n,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Mt(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Ds(n){let t=n,e=n;do(t.x=e.next.y&&e.next.y!==e.y){const _=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(_<=i&&_>a){if(a=_,_===i){if(s===e.y)return e;if(s===e.next.y)return e.next}r=e.x=e.x&&e.x>=l&&i!==e.x&&ut(sr.x)&&vt(e,n)&&(r=e,c=u)),e=e.next;return r}function pi(n,t,e,i){for(let s;s!==n;s=s.next){if(s=s||n,s.z===null&&(s.z=Jt(s.x,s.y,t,e,i)),s.prev.next!==s||s.next.prev!==s)return s.prev.next=s,s.next.prev=s,pi(n,t,e,i);s.prevZ=s.prev,s.nextZ=s.next}return n.prevZ.nextZ=null,n.prevZ=null,Ns(n)}function Ns(n){let t,e=1;for(;;){let i,s=n;n=null,t=null;let r=0;for(;s;){r++,i=s;let a=0;for(;a0||o>0&&i;){let l;a===0?(l=i,i=i.nextZ,o--):o!==0&&i?s.z<=i.z?(l=s,s=s.nextZ,a--):(l=i,i=i.nextZ,o--):(l=s,s=s.nextZ,a--),t?t.nextZ=l:n=l,l.prevZ=t,t=l}s=i}if(t.nextZ=null,e*=2,r<2)return n}}function W(n,t,e){return(t.y-n.y)*(e.x-t.x)-(t.x-n.x)*(e.y-t.y)}function yi(n,t,e,i){return!!(et(n,t)&&et(e,i)||et(n,i)&&et(e,t))||W(n,t,e)>0!=W(n,t,i)>0&&W(e,i,n)>0!=W(e,i,t)>0}function Xs(n,t){let e=n;do{if(e.index!==n.index&&e.next.index!==n.index&&e.index!==t.index&&e.next.index!==t.index&&yi(e,e.next,n,t))return!0;e=e.next}while(e!==n);return!1}function Us(n,t,e,i,s,r){let a=0;for(let o=i,l=s-r;o=0&&(n-a)*(i-o)-(e-a)*(t-o)>=0&&(e-a)*(r-o)-(s-a)*(i-o)>=0}function vt(n,t){return W(n.prev,n,n.next)<0?W(n,t,n.next)>=0&&W(n,n.prev,t)>=0:W(n,t,n.prev)<0||W(n,n.next,t)<0}function Jt(n,t,e,i,s){return(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=32767*(n-e)*s)|n<<8))|n<<4))|n<<2))|n<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*s)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function et(n,t){return n.x===t.x&&n.y===t.y}function Hs(n,t){return n.x-t.x}function Ys(n,t,e,i){let s=n;do{const r=s.prev,a=s.next.next;!et(r,a)&&yi(r,s,s.next,a)&&vt(r,a)&&vt(a,r)&&(t.push(r.index/e+i),t.push(s.index/e+i),t.push(a.index/e+i),Mt(s),Mt(s.next),s=n=a),s=s.next}while(s!==n);return s}function qs(n,t,e,i,s,r,a){let o=n;do{let l=o.next.next;for(;l!==o.prev;){if(o.index!==l.index&&js(o,l)){let h=xi(o,l);return o=xt(o,o.next),h=xt(h,h.next),gt(o,t,e,i,s,r,a,0),void gt(h,t,e,i,s,r,a,0)}l=l.next}o=o.next}while(o!==n)}function js(n,t){return n.next.index!==t.index&&n.prev.index!==t.index&&!Xs(n,t)&&vt(n,t)&&vt(t,n)&&Qs(n,t)}function Qs(n,t){let e=n,i=!1;const s=(n.x+t.x)/2,r=(n.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&s<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==n);return i}function xi(n,t){const e=dt.create(n.index,n.x,n.y),i=dt.create(t.index,t.x,t.y),s=n.next,r=t.prev;return n.next=t,t.prev=n,e.next=s,s.prev=e,i.next=e,e.prev=i,r.next=i,i.prev=r,i}class dt{constructor(){this.index=0,this.x=0,this.y=0,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}static create(t,e,i){const s=ee0))break;c+=p,_.push(o+u),u+=y}const f=a.length;Bs(a,e,o,o+u,_,2,r);const m=er(a,e,f,a.length,r),d=Math.abs(c);if(Math.abs((m-d)/Math.max(1e-7,d))>tr)return a.length=0,!1;l=h,o+=u}return!0}function sr(n){const{coords:t,lengths:e}=n,{buffer:i}=is(t,e);return i}function rr(n,t,e){let i=0;for(let s=0;se||le)return!0}i+=r}return!1}function nr(n,t){if(V(n))return null;if(!rr(n,-128,st+128))return n;tt.setPixelMargin(t),tt.reset(hi.Polygon);let e=0;for(let a=0;as||cs){a=!0;continue}l.push({x:u,y:c})}let _=!1;const f=h.length;for(let m=1;ms||cs){_=!0;break}l.push({x:u,y:c})}if(_)a=!0;else{if(a){const m=e.resultWithStarts();if(m)for(const d of m)r.push(d)}else r.push({line:l,start:0});o++,a=!1}}return r=r.filter(l=>l.line.length>1),r.length===0?null:r}tt.setExtent(st),ie.setExtent(st);const Ft=8,R=16,Ke=65535,gi=n=>class extends n{constructor(...t){super(...t),this.tessellationProperties={},this._tessellationOptions={halfWidth:0,pixelCoordRatio:1,offset:0},this.geometryType=P.LINE}writeGeometry(t,e,i,s){this._writeGeometry(t,e,i,s)}_initializeTessellator(t){const e=Et.load(this._materialKey),i=ft.load(this._materialKey),s=this._tessellationOptions,r=e.vvSizeFieldStops||e.vvSizeMinMaxValue||e.vvSizeScaleStops||e.vvSizeUnitValue,a=this.tessellationProperties._halfWidth(i,s,r,a,o,l,h,u,c,_,f)=>{const m=M(f,Math.ceil(R*n._halfWidth)),d=k(Math.round(R*h),Math.round(R*u),Math.round(R*c),Math.round(R*_)),y=k(R*o,R*l,0,n._bitset),p=n.out;return p.vertexBounds(i,s,t,e),p.vertexWrite(M(Ft*i,Ft*s)),p.vertexWrite(n.id),p.vertexWrite(n._fillColor),p.vertexWrite(d),p.vertexWrite(m),p.vertexWrite(n._tl),p.vertexWrite(n._br),p.vertexWrite(y),p.vertexWrite(M(Math.ceil(R*n._halfReferenceWidth),0)),p.vertexWrite(n.minMaxZoom),p.vertexEnd(),n.offset+n.vertexCount++},lr=(n,t,e)=>(i,s,r,a,o,l,h,u,c,_,f)=>{const m=M(R*n._halfWidth,R*n._halfReferenceWidth),d=k(R*h+128,R*u+128,R*c+128,R*_+128),y=n.out,p=n._bitset<<24|n.id;y.vertexBounds(i,s,t,e),y.vertexWrite(M(Ft*i,Ft*s)),y.vertexWrite(p),y.vertexWrite(n._fillColor);const g=li(n.key);return g||(y.vertexWrite(0),y.vertexWrite(0)),y.vertexWrite(0),y.vertexWrite(m),y.vertexWrite(d),g||y.vertexWrite(n.minMaxZoom),y.vertexEnd(),n.offset+n.vertexCount++},hr=n=>(t,e,i)=>{const s=n.out;s.indexWrite(t),s.indexWrite(e),s.indexWrite(i),n.indexCount+=3};class U extends gi(wt){constructor(t,e,i,s,r,a,o,l,h,u,c,_,f,m,d,y,p,g,v,b){super();const L=Et.load(t);e&&(L.sdf=e.sdf,L.pattern=!0,L.textureBinding=e.textureBinding),this._capType=s,this._joinType=r,this._miterLimitCosine=Qt(a),this.tessellationProperties._fillColor=o,this.tessellationProperties._tl=l,this.tessellationProperties._br=h,this._hasPattern=u,this._isDashed=c,this._zOrder=p,this._effects=g,this._minMaxZoom=M(Math.round(v*C),Math.round(b*C)),this._materialKey=L.data;const S=(f?it:0)|(m?qi:0)|(_?si:0)|(d?Vt:0);this.tessellationProperties._bitset=S,this.tessellationProperties._halfWidth=.5*i,this.tessellationProperties._halfReferenceWidth=.5*y,this.tessellationProperties.offset=0,this._initializeTessellator(!1)}static fromCIMLine(t,e,i){const s=t.color,r=t.scaleFactor||1,a=!!t.dashTemplate;let o=t.cap;a&&o===ze.ROUND&&(o=ze.SQUARE);const l=t.join,h=x(t.width)*r,u=x(t.referenceWidth),c=x(t.miterLimit),_=s&&$(s)||0,[f,m]=J(t.scaleInfo,i),d=!1;if(!e)return new U(t.materialKey,e,h,o,l,c,_,0,0,!1,a,t.scaleDash,t.colorLocked,d,t.sampleAlphaOnly,u,t.zOrder,t.effects,f,m);const{rect:y,width:p,height:g}=e,v=y.x+I,b=y.y+I,L=v+p,S=b+g,T=M(v,b),z=M(L,S),N=!1;return new U(t.materialKey,e,h,o,l,c,_,T,z,!0,a,t.scaleDash,t.colorLocked,N,t.sampleAlphaOnly,u,t.zOrder,t.effects,f,m)}static fromFillOutline(t){var i;const e=ft.load(t.materialKey);return At(e)&&t.outline&&((i=t.outline)==null?void 0:i.style)==="esriSLSSolid"?U.fromSimpleLine({hash:"",materialKey:t.materialKey,...t.outline},null,!0):null}static fromSimpleLine(t,e,i=!1){const{color:s}=t,r=t.style!=="esriSLSSolid"&&t.style!=="esriSLSNull",a=Ji(t.cap||"round"),o=ts(t.join||"round");let l=s&&t.style!=="esriSLSNull"&&Y(s)||0;t.style==="esriSLSNull"&&(l=0);const h=x(t.width),u=t.miterLimit;if(!e)return new U(t.materialKey,e,h,a,o,u,l,0,0,!1,r,!0,!1,i,!1,h,0,null,G,Z);const{rect:c,width:_,height:f}=e,m=c.x+I,d=c.y+I,y=m+_,p=d+f,g=M(m,d),v=M(y,p);return new U(t.materialKey,e,h,a,o,u,l,g,v,!0,r,!0,!1,i,!1,h,0,null,G,Z)}static fromPictureLineSymbol(t,e,i,s){return mt.getLogger("esri.views.2d.engine.webgl.WGLLineTemplate").error("PictureLineSymbol support does not exist!"),null}}const cr=100,Ne=1,Mi=n=>class extends n{constructor(...t){super(...t),this.forceLibtess=!1,this._bitset=0,this._lineTemplate=null,this.geometryType=P.FILL}_maybeAddLineTemplate(t){this._lineTemplate=U.fromFillOutline(t)}_write(t,e,i,s){const r=e.geometryType==="esriGeometryPoint",a=ft.load(this._materialKey);t.recordStart(e.getDisplayId(),this._materialKey,this.geometryType,r),this._writeGeometry(t,e,a,s,r),At(a)&&E(this._lineTemplate)&&this._lineTemplate.writeGeometry(t,e,s,r),t.recordEnd()}_writeGeometry(t,e,i,s,r){const a=this._getGeometry(e,s,r);if(V(a))return;const o=[];if(!(a.maxLength>cr)&&!this.forceLibtess&&ir(o,a))return void(o.length&&this._writeVertices(t,e,a.coords,a.lengths,i,o));const l=sr(a);this._writeVertices(t,e,l,[l.length/2],i)}_writeVertex(t,e,i,s,r,a){const o=M(Ne*s,Ne*r);if(t.vertexBounds(s,r,0,0),t.vertexWrite(o),t.vertexWrite(e),i.symbologyType===Ot.DOT_DENSITY)t.vertexWriteF32(1/Math.abs(a.readGeometryArea()));else{t.vertexWrite(this.fillColor);const l=li(i);l||(t.vertexWrite(this.tl),t.vertexWrite(this.br)),t.vertexWrite(this.aux21),t.vertexWrite(this.aux22),t.vertexWrite(this.aux3),l||t.vertexWrite(this._minMaxZoom)}}_writeVertices(t,e,i,s,r,a){const o=e.getDisplayId(),l=this._bitset<<24|o,h=s.reduce((f,m)=>f+m),u=Yt(r.geometryType,r.symbologyType).geometry/4,c=t.vertexCount();t.vertexEnsureSize(u*h);let _=0;if(a)for(const f of a){const m=i[2*f],d=i[2*f+1];this._writeVertex(t,l,r,m,d,e),_++}else for(let f=0;f0,o=e.readLegacyFeature(),l=e.getObjectId(),h=this._materialCache,u=this._cimLayer.materialHash;if(!u)return Xe.error("A Dynamic mesh template must have a material hash value or function!"),Promise.reject(null);const c=typeof u=="function"?u(o,i,s,l):u;if(h.has(c)){const v=h.get(c);return Promise.resolve(v)}const _=this._ongoingMaterialRequestMap.get(c);if(_)return _;const f=this._cimLayer,m=ms(f.cim,this._cimLayer.materialOverrides);m.mosaicHash=c;const{type:d,url:y}=f,p={cim:m,type:d,mosaicHash:c,url:y,size:null,dashTemplate:null,text:null,fontName:null,objectId:l,animatedSymbolProperties:null};switch(d){case"marker":p.size=Pt(f.size,o,i,s),p.animatedSymbolProperties=Pt(f.animatedSymbolProperties,o,i,s);break;case"line":p.dashTemplate=f.dashTemplate;break;case"text":p.text=Pt(f.text,o,i,s),p.fontName=Pt(f.fontName,o,i,s)}const g=t.getMosaicItem(p,r).then(v=>(a||(this._ongoingMaterialRequestMap.delete(c),h.set(c,v)),v)).catch(v=>(this._ongoingMaterialRequestMap.delete(c),Xe.error(".analyze()",v.message),null));return a||this._ongoingMaterialRequestMap.set(c,g),g}}const Ue=128;class pe extends Mi(Nt){constructor(t,e,i){var u;if(super(t),this._minMaxZoom=M(Math.round(e*C),Math.round(i*C)),w(t.color)){const c=(_,f,m)=>{const d=t.color(_,f,m);return d&&$(d)||0};this._dynamicPropertyMap.set("fillColor",c)}else{const c=t.color;this.fillColor=c&&$(c)||0}const s=((u=t.cim.placement)==null?void 0:u.type)==="CIMMarkerPlacementInsidePolygon"&&t.cim.placement.shiftOddRows?2:1,r=t.height;if(w(r)){const c=(_,f,m)=>r(_,f,m)*s;this._dynamicPropertyMap.set("_height",c)}else this._height=(r||0)*s;const a=t.offsetX;if(w(a)){const c=(_,f,m)=>x(a(_,f,m));this._dynamicPropertyMap.set("_offsetX",c)}else this._offsetX=x(a||0);const o=t.offsetY;if(w(o)){const c=(_,f,m)=>x(-o(_,f,m));this._dynamicPropertyMap.set("_offsetY",c)}else this._offsetY=x(-o||0);const l=t.scaleX;w(l)?this._dynamicPropertyMap.set("_scaleX",l):this._scaleX=l||1;const h=t.angle;if(w(h)){const c=(_,f,m)=>jt(h(_,f,m));this._dynamicPropertyMap.set("_angle",c)}else this._angle=jt(h)||0;if(E(t.effects)){const c=t.effects;w(c)?this._dynamicPropertyMap.set("_effects",c):this._effects=c}this._cimFillLayer=t,this._bitset=(t.colorLocked?it:0)|(t.applyRandomOffset?ri:0)|(t.sampleAlphaOnly?Vt:0),this._fillMaterialKey=t.materialKey}static fromCIMFill(t,e){const[i,s]=J(t.scaleInfo,e);return new pe(t,i,s)}bindFeature(t,e,i){const s=t.readLegacyFeature();this._dynamicPropertyMap.forEach((u,c)=>{this[c]=u(s,e,i)});const r=ft.load(this._fillMaterialKey),a=this._materialCache,o=(0,this._cimFillLayer.materialHash)(s,e,i),l=a.get(o);let h=null;if(l&&F(l.spriteMosaicItem)&&(h=l.spriteMosaicItem),h){const{rect:u,width:c,height:_}=h,f=u.x+I,m=u.y+I,d=f+c,y=m+_;let p=Math.round(x(this._height));p<=0&&(p=y-m);let g=Math.round(x(this._height/_*c||0));g<=0&&(g=d-f);const v=this._scaleX,b=1;this.tl=M(f,m),this.br=M(d,y),this.aux21=M(g,p),this.aux22=M(this._offsetX,this._offsetY),this.aux3=k(v*Ue,b*Ue,this._angle,0),r.sdf=h.sdf,r.pattern=!0,r.textureBinding=h.textureBinding}else this.tl=0,this.br=0,this.aux21=0,this.aux22=0,this.aux3=0,r.sdf=!1,r.pattern=!1,r.textureBinding=0;this._materialKey=r.data}}class ye extends gi(Nt){constructor(t,e,i){super(t),this._minMaxZoom=M(Math.round(e*C),Math.round(i*C)),this._cimLineLayer=t;let s=0;w(t.width)||(s=.5*x(t.width));const r=(c,_,f)=>w(t.width)?.5*x(t.width(c,_,f)):s;this._dynamicPropertyMap.set("_halfWidth",r),w(t.cap)?this._dynamicPropertyMap.set("_capType",t.cap):this._capType=t.cap,w(t.join)?this._dynamicPropertyMap.set("_joinType",t.join):this._joinType=t.join;const a=t.color;if(w(a)){const c=(_,f,m)=>$(a(_,f,m));this._dynamicPropertyMap.set("_fillColor",c)}else this._fillColor=a&&$(a)||0;const o=t.miterLimit;if(w(o)){const c=(_,f,m)=>Qt(o(_,f,m));this._dynamicPropertyMap.set("_miterLimitCosine",c)}else this._miterLimitCosine=Qt(o);if(E(t.effects)){const c=t.effects;w(c)?this._dynamicPropertyMap.set("_effects",c):this._effects=c}this._scaleFactor=t.scaleFactor||1,this._isDashed=t.dashTemplate!=null;const l=t.colorLocked?it:0,h=t.scaleDash?si:0,u=t.sampleAlphaOnly?Vt:0;this.tessellationProperties._bitset=l|h|u,this._materialKey=t.materialKey,this._initializeTessellator(!0)}static fromCIMLine(t,e){const[i,s]=J(t.scaleInfo,e);return new ye(t,i,s)}bindFeature(t,e,i){const s=t.readLegacyFeature();this._dynamicPropertyMap.forEach((u,c)=>{this[c]=u(s,e,i)}),this._halfWidth*=this._scaleFactor;const r=this._materialCache,a=(0,this._cimLineLayer.materialHash)(s,e,i),o=r.get(a);let l=null;if(o&&F(o.spriteMosaicItem)&&(l=o.spriteMosaicItem),l){this._hasPattern=!0;const{rect:u,width:c,height:_}=l,f=u.x+I,m=u.y+I,d=f+c,y=m+_;this.tessellationProperties._tl=M(f,m),this.tessellationProperties._br=M(d,y)}else this._hasPattern=!1,this.tessellationProperties._tl=0,this.tessellationProperties._br=0;this.tessellationProperties._fillColor=this._fillColor,this.tessellationProperties._halfWidth=this._halfWidth,this.tessellationProperties.offset=0,this.tessellationProperties._halfReferenceWidth=this.tessellationProperties._halfWidth;const h=Et.load(this._materialKey);l&&(h.sdf=l.sdf,h.pattern=!0,h.textureBinding=l.textureBinding),this._materialKey=h.data}}const ur=le(),fr=oe();class xe extends di(Nt){constructor(t,e,i){super(t),this._cimMarkerLayer=t,this._minMaxZoom=M(Math.round(e*C),Math.round(i*C));const s=t.color;if(w(s)){const _=(f,m,d)=>$(s(f,m,d));this._dynamicPropertyMap.set("_fillColor",_)}else this._fillColor=$(s);const r=t.outlineColor;if(w(r)){const _=(f,m,d)=>$(r(f,m,d));this._dynamicPropertyMap.set("_outlineColor",_)}else this._outlineColor=$(r);const a=t.size;if(w(a)){const _=(f,m,d)=>x(a(f,m,d));this._dynamicPropertyMap.set("_size",_)}else this._size=x(a)||0;const o=t.scaleX;w(o)?this._dynamicPropertyMap.set("_scaleX",o):this._scaleX=o;const l=t.offsetX;if(w(l)){const _=(f,m,d)=>x(l(f,m,d));this._dynamicPropertyMap.set("xOffset",_)}else this.xOffset=x(l)||0;const h=t.offsetY;if(w(h)){const _=(f,m,d)=>x(h(f,m,d));this._dynamicPropertyMap.set("yOffset",_)}else this.yOffset=x(h)||0;const u=t.outlineWidth;if(w(u)){const _=(f,m,d)=>x(u(f,m,d));this._dynamicPropertyMap.set("_outlineWidth",_)}else this._outlineWidth=x(u)||0;const c=t.rotation;if(w(c)?this._dynamicPropertyMap.set("_angle",c):this._angle=c||0,E(t.effects)){const _=t.effects;w(_)?this._dynamicPropertyMap.set("_effects",_):this._effects=_}if(E(t.markerPlacement)){const _=t.markerPlacement;w(_)?this._dynamicPropertyMap.set("_markerPlacement",_):this._markerPlacement=_}this._scaleFactor=Ct(t.scaleFactor,1),this._bitSet=(t.alignment===B.MAP?1:0)|(t.colorLocked?1:0)<<1|(t.scaleSymbolsProportionally?1:0)<<3,this._materialKey=t.materialKey}static fromCIMMarker(t,e){const[i,s]=J(t.scaleInfo,e);return new xe(t,i,s)}bindFeature(t,e,i){const s=t.readLegacyFeature(),r=t.getObjectId();this._dynamicPropertyMap.forEach((nt,at)=>{this[at]=nt(s,e,i)});const a=this._cimMarkerLayer.materialHash,o=typeof a=="function"?a(s,e,i,r):a,l=this._materialCache.get(o);if(!l||!F(l.spriteMosaicItem)||!l.spriteMosaicItem)return void mt.getLogger("esri.views.2d.engine.webgl.WGLDynamicMarkerTemplate").error(new rt("mapview-cim","Encountered an error when binding feature"));const h=l.spriteMosaicItem,u=this._cimMarkerLayer.sizeRatio,c=h.width/h.height*this._scaleX,_=this._cimMarkerLayer.rotateClockwise?this._angle:-this._angle;let f=this._size,m=f*c;const d=this.xOffset,y=this.yOffset;this.xOffset*=this._scaleFactor,this.yOffset*=this._scaleFactor;const p=this._cimMarkerLayer.scaleSymbolsProportionally&&this._cimMarkerLayer.frameHeight?this._size/x(this._cimMarkerLayer.frameHeight):1,g=this._outlineWidth*p,v=x(this._cimMarkerLayer.referenceSize);let b=0,L=0;const S=this._cimMarkerLayer.anchorPoint;S&&(this._cimMarkerLayer.isAbsoluteAnchorPoint?this._size&&(b=x(S.x)/(this._size*c),L=x(S.y)/this._size):(b=S.x,L=S.y)),this._anchorX=b,this._anchorY=L,this._sizeOutlineWidth=k(Math.round(Math.min(Math.sqrt(128*m),255)),Math.round(Math.min(Math.sqrt(128*f),255)),Math.round(Math.min(Math.sqrt(128*g),255)),Math.round(Math.min(Math.sqrt(128*v),255))),this.angle=_;const T=Math.round(64*u);this._bitestAndDistRatio=M(this._bitSet,T);const z=h.rect.x+I,N=h.rect.y+I,q=z+h.width,j=N+h.height;this._texUpperLeft=M(z,N),this._texUpperRight=M(q,N),this._texBottomLeft=M(z,j),this._texBottomRight=M(q,j);const O=ce.load(this._materialKey);O.sdf=h.sdf,O.pattern=!0,O.textureBinding=h.textureBinding,this._materialKey=O.data,m*=u,f*=u,m*=this._scaleFactor,f*=this._scaleFactor,m*=h.rect.width/h.width,f*=h.rect.height/h.height,this._computedWidth=m,this._computedHeight=f,this._applyTransformation(fr,ur),this.xOffset=d,this.yOffset=y}}function vi(n){const t=new Array(n.length);for(let e=0;e$(r(y,p,g));this._dynamicPropertyMap.set("_color",d)}else this._color=$(r);const a=t.outlineColor;if(w(a)){const d=(y,p,g)=>$(a(y,p,g));this._dynamicPropertyMap.set("_haloColor",d)}else this._haloColor=$(a);let o;w(t.size)||(o=Math.min(Math.round(x(t.size*t.sizeRatio)),127));const l=(d,y,p)=>w(t.size)?Math.min(Math.round(x(t.size(d,y,p)*t.sizeRatio)),127):o;if(this._dynamicPropertyMap.set("_size",l),w(t.outlineSize)){const d=(y,p,g)=>Math.min(Math.floor(He*x(t.outlineSize(y,p,g)*t.sizeRatio)),127);this._dynamicPropertyMap.set("_haloSize",d)}else this._haloSize=Math.min(Math.floor(He*x(t.outlineSize*t.sizeRatio)),127);let h;w(t.offsetX)||(h=Math.round(x(t.offsetX*t.sizeRatio)));const u=(d,y,p)=>w(t.offsetX)?Math.round(x(t.offsetX(d,y,p)*t.sizeRatio)):h;let c;this._dynamicPropertyMap.set("_xOffset",u),w(t.offsetY)||(c=Math.round(x(t.offsetY*t.sizeRatio)));const _=(d,y,p)=>w(t.offsetY)?Math.round(x(t.offsetY(d,y,p)*t.sizeRatio)):c;if(this._dynamicPropertyMap.set("_yOffset",_),w(t.angle)?this._dynamicPropertyMap.set("_angle",t.angle):this._angle=t.angle,w(t.horizontalAlignment)?this._dynamicPropertyMap.set("_horizontalAlignment",t.horizontalAlignment):this._horizontalAlignment=t.horizontalAlignment,w(t.verticalAlignment)?this._dynamicPropertyMap.set("_verticalAlignment",t.verticalAlignment):this._verticalAlignment=t.verticalAlignment,E(t.effects)){const d=t.effects;w(d)?this._dynamicPropertyMap.set("_effects",d):this._effects=d}if(E(t.markerPlacement)){const d=t.markerPlacement;w(d)?this._dynamicPropertyMap.set("_markerPlacement",d):this._textPlacement=d}w(t.text)?this._dynamicPropertyMap.set("_text",t.text):this._text=t.text,this._scaleFactor=s;const f=Math.min(Math.round(x(t.referenceSize*t.sizeRatio)),127);this._referenceSize=Math.round(Math.sqrt(256*f)),this._materialKey=t.materialKey;const m=us.load(this._materialKey);m.sdf=!0,this._bitset=(t.alignment===B.MAP?1:0)|(t.colorLocked?1:0)<<1,this._materialKey=m.data,this._decoration="none",this._lineHeight=1,this._lineWidth=512,this._isCIM=!0}static fromCIMText(t,e){const[i,s]=J(t.scaleInfo,e);return new ge(t,i,s)}async analyze(t,e,i,s){const r=e.readLegacyFeature(),a=_r(this._cimTextLayer,r,i,s),o=await super.analyze(t,e,i,s,vi(a));return o&&o.glyphMosaicItems&&this._textToGlyphs.set(a,o.glyphMosaicItems),o}bindFeature(t,e,i){const s=t.readLegacyFeature();if(this._dynamicPropertyMap.forEach((a,o)=>{this[o]=a(s,e,i)}),!this._text||this._text.length===0)return void(this._shapingInfo=null);this._size*=this._scaleFactor,this._scale=this._size/ei,this._xOffset*=this._scaleFactor,this._yOffset*=this._scaleFactor,this._xAlignD=ai(Ct(this._horizontalAlignment,"center")),this._yAlignD=oi(Ct(this._verticalAlignment,"baseline"));const r=this._textToGlyphs.get(this._text);this.bindTextInfo(r,!1)}}const ht=128;class H extends Mi(wt){constructor(t,e,i,s,r,a,o,l,h,u,c,_,f,m,d,y){super(),this._effects=m;const p=ft.load(t);e&&(p.sdf=e.sdf,p.pattern=!0,p.textureBinding=e.textureBinding),this.fillColor=i,this.tl=s,this.br=r,this.aux21=M(a,o),this.aux22=M(l,h),this.aux3=k(u,c,_,0),this._bitset=f,this._minMaxZoom=M(Math.round(d*C),Math.round(y*C)),this._materialKey=p.data}static fromCIMFill(t,e,i){const s=t.color,r=s&&$(s)||0,a=t.materialKey,[o,l]=J(t.scaleInfo,i),h=(t.colorLocked?it:0)|(t.applyRandomOffset?ri:0)|(t.sampleAlphaOnly?Vt:0);if(!e)return new H(a,null,r,0,0,0,0,0,0,0,0,0,h,t.effects,o,l);const{rect:u,width:c,height:_}=e,f=t.scaleX||1,m=u.x+I,d=u.y+I,y=m+c,p=d+_,g=x(t.height),v=f*g;let b=Math.round(g);b<=0&&(b=p-d);let L=Math.round(v);L<=0&&(L=y-m);const S=x(t.offsetX||0),T=x(-t.offsetY||0),z=M(m,d),N=M(y,p);return new H(a,e,r,z,N,L,b,S,T,ht,ht,jt(t.angle),h,t.effects,o,l)}static fromSimpleFill(t,e,i=!1){const{color:s}=t,r=s&&t.style!=="esriSFSNull"&&Y(s)||0,a=i?it:0,o=t.materialKey;let l;if(e){const{rect:h,width:u,height:c,pixelRatio:_}=e,f=h.x+I,m=h.y+I,d=f+u,y=m+c,p=M(f,m),g=M(d,y);l=new H(o,e,r,p,g,u/_,c/_,0,0,ht,ht,0,a,null,G,Z)}else l=new H(o,null,r,0,0,0,0,0,0,0,0,0,a,null,G,Z);return l._maybeAddLineTemplate(t),l}static fromPictureFill(t,e,i=!1){const s=ii,{rect:r,width:a,height:o}=e,l=r.x+I,h=r.y+I,u=l+a,c=h+o,_=M(l,h),f=M(u,c),m=Math.round(x(t.width)),d=Math.round(x(t.height)),y=x(t.xoffset),p=x(-t.yoffset),g=t.materialKey,v=i?it:0,b=new H(g,e,s,_,f,m,d,y,p,ht*t.xscale,ht*t.yscale,0,v,null,G,Z);return b._maybeAddLineTemplate(t),b}}class dr{constructor(){this._resolver=null}isHeld(){return!!this._resolver}async acquire(){this._resolver?(await this._resolver.promise,await this.acquire()):this._resolver=Ci()}release(){const t=this._resolver;this._resolver=null,t==null||t.resolve()}}async function mr(n,t,e){try{await n.acquire(),await t(e),n.release()}catch(i){throw n.release(),i}}async function pr(n,t,e){if(!n.name)throw new rt("style-symbol-reference-name-missing","Missing name in style symbol reference");if(n.styleName&&n.styleName==="Esri2DPointSymbolsStyle")return yr(n,e);try{return xr(await Ei(n,t,e),n.name,t,e)}catch(i){return he(i),null}}async function yr(n,t){const e=Ai.replace(/\{SymbolName\}/gi,n.name);try{const i=await Qe(e,t);return Je(i.data)}catch(i){return he(i),null}}async function xr(n,t,e,i){const s=n.data,r={portal:e&&E(e.portal)?e.portal:Ri.getDefault(),url:ki(n.baseUrl),origin:"portal-item"},a=s.items.find(l=>l.name===t);if(!a)throw new rt("symbolstyleutils:symbol-name-not-found",`The symbol name '${t}' could not be found`,{symbolName:t});let o=Fi(Bi(a,"cimRef"),r);gs()&&(o=Ms(o));try{const l=await Qe(o,i);return Je(l.data)}catch(l){return he(l),null}}const Ye=async(n,t,e)=>new ps(await ys(n.data,t,e),n.data,n.rendererKey,n.maxVVSize),K=async(n,t,e,i)=>{if(!n)return null;if(n.type==="cim")return Ye(n,t,e);if(n.type==="web-style"){const s={type:"cim",data:await pr(n,null,i),rendererKey:n.rendererKey,maxVVSize:n.maxVVSize};return Ye(s,t,e)}return n};function Wt(n){if(!n)return null;const{type:t,cim:e,url:i,materialHash:s}=n,r={cim:e,type:t,mosaicHash:s,url:i,size:null,dashTemplate:null,path:null,text:null,fontName:null,animatedSymbolProperties:null};switch(t){case"marker":r.size=n.size,r.path=n.path,r.animatedSymbolProperties=n.animatedSymbolProperties;break;case"line":r.dashTemplate=n.dashTemplate;break;case"text":r.text=n.text,r.fontName=n.fontName}return r}const A=mt.getLogger("esri.views.2d.engine.webgl.mesh.templates.WGLTemplateStore"),qe=new Array,Me={isOutline:!1,placement:null,symbologyType:Ot.DEFAULT,vvFlags:0},gr={...Se,hash:JSON.stringify(Se),materialKey:ue(P.MARKER,Me)},Mr={...Le,hash:JSON.stringify(Le),materialKey:ue(P.LINE,Me)},vr={...Pe,hash:JSON.stringify(Pe),materialKey:ue(P.FILL,Me)};function X(n,t){const e=n.length;return n.push(null),t.then(i=>n[e]=i),n}function yt(n){return!!(1&n)}function wr(n){return n.name==="worker:port-closed"}class Or{constructor(t,e){this._idCounter=1,this._templateIdCounter=1,this._idToTemplateGroup=new Map,this._symbolToTemplate=new Map,this._fetchQueue=[],this._idToResolver=new Map,this._cimTemplateCache=new Map,this._cimAnalyses=[],this._lock=new dr,this._fetchResource=t,this._tileInfo=e}get _markerError(){return this._errorTemplates.marker[0]}get _fillError(){return this._errorTemplates.fill[0]}get _lineError(){return this._errorTemplates.line[0]}get _textError(){return this._errorTemplates.line[0]}createTemplateGroup(t,e){this._initErrorTemplates();const i=t.hash;if(this._symbolToTemplate.has(i))return this._symbolToTemplate.get(i);const s=new Array;e&&this._createMeshTemplates(s,e,!0),this._createMeshTemplates(s,t,!1);const r=this._createGroupId(t.type==="expanded-cim"&&br(t));return this._idToTemplateGroup.set(r,s),this._symbolToTemplate.set(i,r),r}getTemplateGroup(t){return this._idToTemplateGroup.has(t)?this._idToTemplateGroup.get(t):qe}getDynamicTemplateGroup(t){return this._idToTemplateGroup.has(t)?(yt(t)||A.error("mapview-template-store",`Id ${t} does not refer to a dynamic template`),this._idToTemplateGroup.get(t)):qe}getMosaicItem(t,e){const i=this._createTemplateId(),s=new Promise(r=>this._idToResolver.set(i,r));return this._fetchQueue.push({symbol:t,id:i,glyphIds:e}),s}finalize(t){return this._fetchQueue.length||this._lock.isHeld()?mr(this._lock,this._fetchAllQueuedResources.bind(this),t):Promise.resolve()}_initErrorTemplates(){this._errorTemplates||(this._errorTemplates={fill:this._createMeshTemplates([],vr,!1),marker:this._createMeshTemplates([],gr,!1),line:this._createMeshTemplates([],Mr,!1)})}_fetchAllQueuedResources(t){if(!this._fetchQueue.length)return Promise.resolve();const e=this._fetchQueue,i=this._cimAnalyses;return this._fetchQueue=[],this._cimAnalyses=[],Promise.all(i).then(()=>this._fetchResource(e,t).then(s=>{for(const{id:r,mosaicItem:a}of s)this._idToResolver.get(r)(a),this._idToResolver.delete(r)})).catch(s=>{Vi(s)?this._fetchQueue=this._fetchQueue.concat(e):wr(s)||A.error(new rt("mapview-template-store","Unable to fetch requested texture resources",s))})}_createGroupId(t){return this._idCounter++<<1|(t?1:0)}_createTemplateId(){return this._templateIdCounter++}async _createSMS(t){const{spriteMosaicItem:e}=await this.getMosaicItem(t);return F(e,A)?D.fromSimpleMarker(t,e):this._markerError}async _createPMS(t){const{spriteMosaicItem:e}=await this.getMosaicItem(t);return F(e,A)?D.fromPictureMarker(t,e):this._markerError}async _createSFS(t,e){const{spriteMosaicItem:i}=await this.getMosaicItem(t);return F(i,A)?H.fromSimpleFill(t,i,e):this._fillError}async _createPFS(t,e){const{spriteMosaicItem:i}=await this.getMosaicItem(t);return F(i,A)?H.fromPictureFill(t,i,e):this._fillError}async _createSLS(t,e){const{spriteMosaicItem:i}=await this.getMosaicItem(t);return F(i,A)?U.fromSimpleLine(t,i):this._lineError}async _createLMS(t){const{spriteMosaicItem:e}=await this.getMosaicItem(t);return F(e,A)?D.fromLineSymbolMarker(t,e):this._markerError}async _createTS(t){const{glyphMosaicItems:e}=await this.getMosaicItem(t);return _t.fromText(t,e)}async _createCIMText(t){const{glyphMosaicItems:e}=await this.getMosaicItem(Wt(t),vi(t.text));return F(e,A)?_t.fromCIMText(t,e,this._tileInfo):this._textError}async _createCIMFill(t){const{spriteMosaicItem:e}=await this.getMosaicItem(Wt(t));return F(e,A)?H.fromCIMFill(t,e,this._tileInfo):this._fillError}async _createCIMLine(t){const{spriteMosaicItem:e}=await this.getMosaicItem(Wt(t));return F(e,A)?U.fromCIMLine(t,e,this._tileInfo):this._lineError}async _createCIMMarker(t){const{spriteMosaicItem:e}=await this.getMosaicItem(Wt(t));return F(e,A)?D.fromCIMMarker(t,e,this._tileInfo):this._markerError}async _createCIM(t){const e=t.templateHash;if(this._cimTemplateCache.has(e))return this._cimTemplateCache.get(e);let i;switch(t.type){case"marker":i=await this._createCIMMarker(t);break;case"line":i=await this._createCIMLine(t);break;case"fill":i=await this._createCIMFill(t);break;case"text":i=await this._createCIMText(t)}return this._cimTemplateCache.set(e,i),i}async _createDynamicCIM(t){const e=t.templateHash;if(this._cimTemplateCache.has(e))return this._cimTemplateCache.get(e);let i;switch(t.type){case"marker":i=xe.fromCIMMarker(t,this._tileInfo);break;case"line":i=ye.fromCIMLine(t,this._tileInfo);break;case"fill":i=pe.fromCIMFill(t,this._tileInfo);break;case"text":i=ge.fromCIMText(t,this._tileInfo)}return this._cimTemplateCache.set(e,i),i}_createPrimitiveMeshTemplates(t,e,i){switch(e.type){case"esriSMS":return X(t,this._createSMS(e));case"esriPMS":return X(t,this._createPMS(e));case"esriSFS":return X(t,this._createSFS(e,i));case"line-marker":return X(t,this._createLMS(e));case"esriPFS":return X(t,this._createPFS(e,i));case"esriSLS":return X(t,this._createSLS(e,!1));case"esriTS":return X(t,this._createTS(e));default:return A.error("Unable to create mesh template for unknown symbol type {: $ }{symbol.type}"),t}}_createMeshTemplates(t,e,i){if(e.type.includes("3d"))return A.error("3D symbols are not supported with MapView"),t;if(e.type==="expanded-cim"){for(const s of e.layers)typeof s.materialHash=="function"?X(t,this._createDynamicCIM(s)):X(t,this._createCIM(s));return t}if(e.type==="composite-symbol"){for(const s of e.layers)this._createPrimitiveMeshTemplates(t,s,i);return t}return e.type==="cim"||e.type==="label"||e.type==="web-style"?t:this._createPrimitiveMeshTemplates(t,e,i)}}const br=n=>{if(!n.layers)return!1;for(const t of n.layers)if(typeof t.materialHash=="function")return!0;return!1};class Dr{constructor(t,e,i){this._loadPromise=rs(),this._geometryType=t,this._idField=e,this._templateStore=i}update(t,e){E(t.mesh.labels)&&(this._labelTemplates=this._createLabelTemplates(t.mesh.labels,e)),this._schema=t}_createLabelTemplates(t,e){const i=new Map;if(t.type==="simple"){for(const s of t.classes){const r=kt.fromLabelClass(s,e);i.set(s.index,r)}return i}for(const s in t.classes){const r=t.classes[s];for(const a of r){const o=kt.fromLabelClass(a,e);i.set(a.index,o)}}return i}get templates(){return this._templateStore}async analyze(t,e,i,s,r,a,o){if(Te(o))return;let l;i.type==="dictionary"&&(l=await i.analyze(this._idField,t.copy(),e,r,a,o));let h=0;for(;t.next();){let u;if(u=l?l[h++]:E(s)&&Qi(t.getDisplayId())&&t.readAttribute("cluster_count")!==1?s.match(this._idField,t,this._geometryType,r,a):i.match(this._idField,t,this._geometryType,r,a),t.setGroupId(u),yt(u)){const c=this._templateStore.getDynamicTemplateGroup(u);for(const _ of c)_&&_.analyze&&_.analyze(this._templateStore,t,r,a)}}return await this._loadPromise,this._templateStore.finalize(o)}async analyzeGraphics(t,e,i,s,r,a){if(Te(a))return;const o=t.getCursor();for(i&&await i.analyze(this._idField,o.copy(),e,s,r,a);o.next();){let l=o.getGroupId();if(l!=null&&l!==-1||(l=i.match(this._idField,o,o.geometryType,s,r),o.setGroupId(l)),yt(l)){const h=this._templateStore.getDynamicTemplateGroup(l);for(const u of h)u&&u.analyze&&u.analyze(this._templateStore,o,s,r)}o.setGroupId(l)}return await this._loadPromise,this._templateStore.finalize(a)}writeGraphic(t,e,i,s){const r=e.getGroupId(),a=e.getDisplayId(),o=this._templateStore.getTemplateGroup(r);if(t.featureStart(e.insertAfter,0),a!=null){if(yt(r))for(const l of o)l&&l.bindFeature(e,null,null);if(o){for(const l of o)l&&l.write(t,e,i,s);t.featureEnd()}}}writeCursor(t,e,i,s,r,a,o){const l=e.getGroupId(),h=e.getDisplayId(),u=this._templateStore.getTemplateGroup(l),c=this._schema.mesh.sortKey;let _=0;if(E(c)&&(_=c.fieldIndex!=null?e.getComputedNumericAtIndex(c.fieldIndex):c.field!=null?e.readAttribute(c.field):e.readAttribute(this._idField),_*=c.order==="asc"?1:-1),t.featureStart(0,_==null||isNaN(_)?0:_),h!=null&&u){if(yt(l))for(const f of u)f.bindFeature(e,i,s);for(const f of u)f.write(t,e,r,o);if(E(a)&&t.hasRecords){const f=a&&this._findLabelRef(u);this._writeLabels(t,e,a,f,r,o)}t.featureEnd()}}_findLabelRef(t){for(const e of t)if(e instanceof D)return e;return null}_writeLabels(t,e,i,s,r,a){for(const o of i)if(E(o)&&o){const{glyphs:l,rtl:h,index:u}=o,c=this._labelTemplates.get(u);c.setZoomLevel(r),c.bindReferenceTemplate(s),c.bindTextInfo(l,h),c.write(t,e,null,a)}}}const se=mt.getLogger("esri/views/2d/engine/webgl/util/Matcher");async function Sr(n,t,e,i){switch(n.type){case"simple":case"heatmap":return Q.fromBasicRenderer(n,t,e,i);case"map":return we.fromUVRenderer(n,t,e,i);case"interval":return ve.fromCBRenderer(n,t,e,i);case"dictionary":return be.fromDictionaryRenderer(n,t,e,i);case"pie-chart":return Bt.fromPieChartRenderer(n,t,e,i);case"subtype":return Bt.fromSubtypes(n,t,e,i)}}class Q{constructor(){this.type="feature",this._defaultResult=null}static async fromBasicRenderer(t,e,i,s){const r=new Q;if(t.symbol){const a=await K(t.symbol,i,s),o=e.createTemplateGroup(a,null);r.setDefault(o)}return r}static async fromPieChartRenderer(t,e,i,s){const r=new Q;if(t.markerSymbol){const a=await K(t.markerSymbol,i,s);let o;t.fillSymbol&&(o=await K(t.fillSymbol,i,s));const l=e.createTemplateGroup(a,o);r.setDefault(l)}return r}size(){return 1}getDefault(){return this._defaultResult}setDefault(t){this._defaultResult=t}match(t,e,i,s,r){return this.getDefault()}async analyze(t,e,i,s,r,a){return null}}class Bt extends Q{constructor(t,e){super(),this._subMatchers=t,this._subtypeField=e}static async fromSubtypes(t,e,i,s){const r=new Map,a=[];for(const o in t.renderers){const l=parseInt(o,10),h=Sr(t.renderers[o],e,i,s).then(u=>r.set(l,u));a.push(h)}return await Promise.all(a),new Bt(r,t.subtypeField)}match(t,e,i,s,r){const a=e.readAttribute(this._subtypeField),o=this._subMatchers.get(a);return o?o.match(t,e,i,s,r):null}}class ve extends Q{constructor(t,e,i,s){super(),this.type="interval",this._intervals=[],this._isMaxInclusive=e,this._fieldIndex=s,this._field=t,this._normalizationInfo=i}static async fromCBRenderer(t,e,i,s){const{isMaxInclusive:r,normalizationField:a,normalizationTotal:o,normalizationType:l}=t,h=t.field,u=new ve(h,r,{normalizationField:a,normalizationTotal:o,normalizationType:l},t.fieldIndex),c=await K(t.backgroundFillSymbol,i,s);await Promise.all(t.intervals.map(async f=>{const m=await K(f.symbol,i,s),d=await e.createTemplateGroup(m,c),y={min:f.min,max:f.max};u.add(y,d)}));const _=await K(t.defaultSymbol,i,s);if(_){const f=await e.createTemplateGroup(_,c);u.setDefault(f)}return u}add(t,e){this._intervals.push({interval:t,result:e}),this._intervals.sort((i,s)=>i.interval.min-s.interval.min)}size(){return super.size()+this._intervals.length}match(t,e,i,s,r){if(this._fieldIndex==null&&!this._field)return this.getDefault();const a=this._fieldIndex!=null?e.getComputedNumericAtIndex(this._fieldIndex):this._getValueFromField(e);if(a==null||isNaN(a)||a===1/0||a===-1/0)return this.getDefault();for(let o=0;o=l.min,c=this._isMaxInclusive?a<=l.max:a{const c=await K(u.symbol,i,s),_=await e.createTemplateGroup(c,o);u.value===""?l.setNullResult(_):l.add(u.value,_)}));const h=await K(t.defaultSymbol,i,s);if(h){const u=await e.createTemplateGroup(h,o);l.setDefault(u)}return l}setNullResult(t){this._nullResult=t}add(t,e){this._resultsMap.set(t.toString(),e)}size(){return super.size()+this._resultsMap.size}match(t,e,i,s,r){if(this._fieldsIndex==null&&!this._fields)return this.getDefault();const a=this._fieldsIndex!=null?e.getComputedStringAtIndex(this._fieldsIndex):this._getValueFromFields(e);if(this._nullResult!==null&&(a==null||a===""||a===""))return this._nullResult;if(a==null)return this.getDefault();const o=a.toString();return this._resultsMap.has(o)?this._resultsMap.get(o):this.getDefault()}_getValueFromFields(t){const e=[];for(const i of this._fields){const s=t.readAttribute(i);s==null||s===""?e.push(""):e.push(s)}return e.join(this._seperator)}}async function Lr(n,t){const e=n||1;if(typeof e=="number")return(s,r,a)=>e;const i=await Di(e,t.spatialReference,t.fields);return(s,r,a)=>xs(i,s,{$view:a},t.geometryType,r)||1}let Ut;async function Pr(){return Ut||(Ut=ti(()=>import("./createSymbolSchema.30665f63.js"),["assets/createSymbolSchema.30665f63.js","assets/Utils.e8554a0e.js","assets/index.6c049565.js","assets/index.cf071e35.css","assets/enums.0295eb81.js","assets/enums.2d9e6f64.js","assets/Texture.8e8dfb11.js","assets/VertexElementDescriptor.1fdca6da.js","assets/MaterialKey.bbaab8f1.js"])),Ut}class be extends Q{constructor(t,e,i,s,r,a){super(),this.type="dictionary",this._groupIdCache=new Oi(100),this._loader=t,this._fieldMap=t.fieldMap,this._symbolFields=t.getSymbolFields(),this._templates=e,this._info=i,this._scaleFn=s,this._schemaUtilsModule=r,this._symbolOptions=a}static async fromDictionaryRenderer(t,e,i,s){const[{DictionaryLoader:r},a]=await Promise.all([ti(()=>import("./index.6c049565.js").then(function(h){return h.l3}),["assets/index.6c049565.js","assets/index.cf071e35.css"]),Pr()]),o=new r(t.url,t.config,t.fieldMap);await o.fetchResources({spatialReference:i.spatialReference,fields:i.fields});const l=await Lr(t.scaleExpression,i);return new be(o,e,i,l,a,t.symbolOptions)}async _analyzeFeature(t,e,i,s,r){const a=t.readLegacyFeature(),o=this._scaleFn(a,i,s),l=this._attributeHash(a)+"-"+o,h=this._groupIdCache.get(l);if(h)return h;const u={...s,spatialReference:this._info.spatialReference,abortOptions:r,fields:this._info.fields},c=await this._loader.getSymbolAsync(a,u),_=this._schemaUtilsModule.createSymbolSchema(c,this._symbolOptions),f=K(_,this._info,e,r).then(m=>{if(m.type!=="expanded-cim")return se.error(new rt("mapview-bad-type",`Found unexpected type ${m.type} in dictionary response`)),null;m.hash+="-"+o;for(const d of m.layers)d.scaleFactor=o,d.templateHash+="-"+o;return this._templates.createTemplateGroup(m,null)});return this._groupIdCache.put(l,f,1),f}async analyze(t,e,i,s,r,a){const o=e.getCursor(),l=[];for(;o.next();)l.push(this._analyzeFeature(o,i,s,r,a));return Promise.all(l)}match(t,e,i,s,r){return null}_attributeHash(t){let e="";for(const i of this._symbolFields){const s=this._fieldMap[i];s&&(e+=t.attributes[s]+"-")}return e}}export{Vr as E,Tt as a,Dr as b,F as e,Sr as l,K as n,vi as t,Or as x};