Files
ADHA_mobile_project/assets/Matcher-dd0694f8.js
T
2024-02-28 17:06:42 +05:00

2 lines
85 KiB
JavaScript

import{s as Mt,x as $r,eI as g,hT as kr,z as dt,lO as je,jK as Vt,au as Qe,lq as Er,lt as Ar,eE as Rr,ls as Br,gB as wt,lP as bt,lB as de,aj as Fr,_ as _e,lQ as Se,lR as Le,lS as ze,v as Vr,g$ as Pe,di as Or,L as Dr,hB as Gr}from"./index-b5c8f851.js";import{d as Qt,f as Kr,c as rt,w as Zr,e as Je,m as $,g as Nr,a as E,b as Xr,n as tr,l as er,p as q,h as Yr,x as rr,i as ir,$ as Hr,k as qr,j as sr,o as Ot,u as nr,v as ar,r as H,s as k,y as Ct,D as $t}from"./definitions-1467ba4a.js";import{f as Ur,a as Dt,p as jr}from"./visualVariablesUtils-f4ae79f2.js";import{E as P,R as Jt,b as I,w as M,c as F,g as W,S as Gt,k as Qr,G as Jr}from"./color-0916c686.js";import{o as ti}from"./tileUtils-c2f19f52.js";import{r as ei,c as ri,i as Te}from"./TurboLine-f7b8bf8b.js";import{i as O,o as St,e as We}from"./enums-f1a6a48a.js";import{U as te,s as ii,r as or,n as lr,i as si,a as ni,Z as Ht,c as ai,o as oi,N as fe,C as kt,w as ct,O as Et,b as hr,d as ee,P as li,f as me}from"./GeometryUtils-7a7937c3.js";import{j as hi,S as ci,k as ui,i as Ie,V as di,m as _i,p as fi,s as mi}from"./ExpandedCIM-0020ab0e.js";import{t as Lt,e as S}from"./utils-ebbcf3da.js";import"./earcut-d423749e.js";import{c as cr,t as ur}from"./GeometryUtils-984e8446.js";import{t as pi}from"./OptimizedGeometry-d94e541f.js";function B(a,t){if(a&&"name"in a){const e=a;return t&&t.error(new Mt(e.name,e.message,e.details)),!1}return!0}const xi=1.25;let zt=class{get length(){return this._pos}constructor(t,e){this._pos=0;const r=e?this._roundToNearest(e,t.BYTES_PER_ELEMENT):40;this._array=new ArrayBuffer(r),this._buffer=new t(this._array),this._ctor=t,this._i16View=new Int16Array(this._array)}_roundToNearest(t,e){const r=Math.round(t);return e===1?r:r+(e-r%e)}_ensureSize(t){if(this._pos+t>=this._buffer.length){const e=this._roundToNearest((this._array.byteLength+t*this._buffer.BYTES_PER_ELEMENT)*xi,this._buffer.BYTES_PER_ELEMENT),r=new ArrayBuffer(e),i=new this._ctor(r);i.set(this._buffer,0),this._array=r,this._buffer=i,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,r){this._i16View[2*t]+=e,this._i16View[2*t+1]+=r}getValue(t){return this._buffer[t]}incr(t){if(this._buffer.length<t)throw new Error("Increment index overflows the target buffer");this._buffer[t]++}decr(t){this._buffer[t]--}writeRegion(t){this._ensureSize(t.length);const e=this._pos;return this._buffer.set(t,this._pos),this._pos+=t.length,e}writeManyFrom(t,e,r){this._ensureSize(r-e);for(let i=e;i!==r;i++)this.writeFixed(t._buffer[i])}buffer(){const t=this._array.slice(0,4*this._pos);return this.destroy(),t}toArray(){return[...this._buffer]}seek(t){this._pos=t}destroy(){this._array=null,this._buffer=null}};const ot=new Map;function yi(a,t,e){const{indicesPerRecord:r,multiplier:i,verticesPerRecord:s}=ot.get(a);return{recordBytes:e*Qt*Uint32Array.BYTES_PER_ELEMENT,indexBytes:i*r*e*Uint32Array.BYTES_PER_ELEMENT,vertexBytes:i*s*e*t}}ot.set(P.MARKER,{multiplier:1,indicesPerRecord:6,verticesPerRecord:4}),ot.set(P.LINE,{multiplier:1,indicesPerRecord:24,verticesPerRecord:8}),ot.set(P.FILL,{multiplier:1,indicesPerRecord:10,verticesPerRecord:10}),ot.set(P.TEXT,{multiplier:8,indicesPerRecord:6,verticesPerRecord:4}),ot.set(P.LABEL,{multiplier:8,indicesPerRecord:6,verticesPerRecord:4});let Ce=class{constructor(t,e,r){this._start={index:0,vertex:0};const i=yi(t,e,r),s=e/4;this.geometryType=t,this._records=new zt(Int32Array,i.recordBytes),this._indices=new zt(Uint32Array,i.indexBytes),this._vertices=new zt(Uint32Array,i.vertexBytes),this._metrics=new zt(Float32Array,0),this._strideInt=s}serialize(t){const e=this._records.buffer(),r=this._indices.buffer(),i=this._vertices.buffer(),s=this._metrics.length?this._metrics.buffer():null,n=4*this._strideInt;return t.push(e,r,i),{stride:n,records:e,indices:r,vertices:i,metrics:s}}get strideInt(){return this._strideInt}get recordCount(){return this._records.length/Qt}get vertexCount(){return this._vertices.length/this._strideInt}get indexCount(){return this._indices.length}get indexWriter(){return this._indices}get vertexWriter(){return this._vertices}get metricWriter(){return this._metrics}vertexEnsureSize(t){this._vertices.ensureSize(t)}indexEnsureSize(t){this._indices.ensureSize(t)}recordStart(){this._start.index=this._indices.length,this._start.vertex=this._vertices.length}recordEnd(t,e,r,i,s,n,o,l){this._records.push(t),this._records.push(e??0),this._records.push(r),this._records.push(i),this._records.push(s),this._records.push(n),this._records.push(o),this._records.writeF32(l)}writeIndex(t){this._indices.push(t)}writeVertex(t){this._vertices.push(t)}writeVertexF32(t){this._vertices.writeF32(t)}copyLastFrom(t,e,r){const i=t._records.length-Qt,s=t._records.getValue(i),n=t._records.getValue(i+1),o=t._records.getValue(i+2),l=t._records.getValue(i+4),h=t._records.getValue(i+6),u=t._records.getValue(i+7),c=this._vertices.length,d=(t._start.vertex-this._vertices.length)/this._strideInt,_=this._indices.length,m=this.vertexCount;for(let f=t._start.index;f!==t._indices.length;f++){const p=t._indices.getValue(f);this._indices.push(p-d)}for(let f=t._start.vertex;f!==t._vertices.length;f++){const p=t._vertices.getValue(f);this._vertices.push(p)}for(let f=c;f<=this._vertices.length;f+=this._strideInt)this._vertices.i1616Add(f,e,r);this._records.push(s),this._records.push(n),this._records.push(o),this._records.push(_),this._records.push(l),this._records.push(m),this._records.push(h),this._records.push(u)}};const Kt=1,pe=2,Zt=4,xe=8,ye=16,Nt=32,ge=64,Xt=128;function $e(a){switch(a){case Kt:case xe:case Nt:return-1;case pe:case ge:return 0;case Zt:case ye:case Xt:return 1}}function ke(a){switch(a){case Kt:case pe:case Zt:return-1;case xe:case ye:return 0;case Nt:case ge:case Xt:return 1}}const Ee=Kt|xe|Nt,Ae=Zt|ye|Xt,Re=Kt|pe|Zt,Be=Nt|ge|Xt;let Ks=class{constructor(t,e,r,i,s,n=0){this._hasAggregate=!1,this.hasRecords=!1,this._data={self:new Map,neighbors:new Array},this._version=0,this._current={geometryType:0,writer:null,overlaps:0,start:0,insertAfter:0,sortKey:0,id:0,materialKey:0,indexStart:0,vertStart:0,isDotDensity:!1,bufferingEnabled:!1,metricBoxLenPointer:0},this.hint=e,this.tileKey=t,this._hasAggregate=i,this._pixelBufferEnabled=s,this._version=n,this._symbologyType=r}get hasAggregates(){return this._hasAggregate}get hasPixelBufferEnabled(){return this._pixelBufferEnabled}serialize(t){const e=[];return e.push(this._serializeTileVertexData(this.tileKey,this.tileKey,this._data.self)),this._data.neighbors.forEach((r,i)=>{const s=1<<i,n=$e(s),o=ke(s),l=ti(new $r(this.tileKey),n,o,t),h=this._serializeTileVertexData(this.tileKey,l.id,r.vertexData);h.message.bufferIds=r.displayIds,e.push(h)}),e}_serializeTileVertexData(t,e,r){var s,n,o,l,h;const i=new Array;return{message:{tileKeyOrigin:t,tileKey:e,data:{[P.MARKER]:(s=r.get(P.MARKER))==null?void 0:s.serialize(i),[P.FILL]:(n=r.get(P.FILL))==null?void 0:n.serialize(i),[P.LINE]:(o=r.get(P.LINE))==null?void 0:o.serialize(i),[P.TEXT]:(l=r.get(P.TEXT))==null?void 0:l.serialize(i),[P.LABEL]:(h=r.get(P.LABEL))==null?void 0:h.serialize(i)},version:this._version},transferList:i}}featureStart(t,e){this._current.insertAfter=t,this._current.sortKey=e}featureEnd(){}recordStart(t,e,r,i){this._current.writer=this._getVertexWriter(r),this._current.overlaps=0,this._current.indexStart=this._current.writer.indexCount,this._current.vertStart=this._current.writer.vertexCount,this._current.bufferingEnabled=i,this._current.id=t,this._current.materialKey=e,this._current.geometryType=r,this._current.isDotDensity=!1,this._current.writer.recordStart()}recordCount(){return this._current.writer.recordCount}vertexCount(){return this._current.writer.vertexCount}indexCount(){return this._current.writer.indexCount}vertexEnsureSize(t){this._current.writer.vertexEnsureSize(t)}indexEnsureSize(t){this._current.writer.indexEnsureSize(t)}vertexBounds(t,e,r,i){this._current.bufferingEnabled&&this._addOverlap(t,e,r,i)}vertexWrite(t){this._current.writer.writeVertex(t)}vertexWriteF32(t){this._current.writer.writeVertexF32(t)}vertexEnd(){}vertexWriter(){return this._current.writer.vertexWriter}indexWrite(t){this._current.writer.writeIndex(t)}indexWriter(){return this._current.writer.indexWriter}metricWriter(){return this._current.writer.metricWriter}metricStart(t,e,r,i,s,n,o,l){this._current.writer=this._getVertexWriter(P.LABEL);const h=this._current.writer.metricWriter;h.push(Ur(t)),h.push(e),h.push(r),h.push(i),h.push(s),h.push(n),h.push(o),h.push(l),h.push(255),this._current.metricBoxLenPointer=h.push(0)}metricEnd(){const t=this._current.writer.metricWriter;t.getValue(this._current.metricBoxLenPointer)===0&&t.seek(t.length-10)}metricBoxWrite(t,e,r,i){const s=this._current.writer.metricWriter;s.incr(this._current.metricBoxLenPointer),s.push(0),s.push(0),s.push(t),s.push(e),s.push(r),s.push(i)}recordEnd(){const t=this._current.vertStart,e=this._current.writer.vertexCount-t;if(!e)return!1;this.hasRecords=!0;const r=this._current.indexStart,i=this._current.writer.indexCount-r;if(this._current.writer.recordEnd(this._current.id,this._current.materialKey,this._current.insertAfter,r,i,t,e,this._current.sortKey),!this._pixelBufferEnabled||this._hasAggregate||this._current.overlaps===0||this._current.geometryType===P.LABEL)return!0;const s=this._current.writer;for(let n=0;n<8;n++){const o=1<<n;if(this._current.overlaps&o){this._data.neighbors[n]||(this._data.neighbors[n]={vertexData:new Map,displayIds:new Set});const l=this._data.neighbors[n],h=this._current.geometryType;if(!l.vertexData.has(h)){const m=Jt(h,this._symbologyType).geometry,f=new Ce(h,m,Kr);l.vertexData.set(h,f)}const u=l.vertexData.get(this._current.geometryType),c=8,d=512*-$e(o)*c,_=512*-ke(o)*c;u==null||u.copyLastFrom(s,d,_),l.displayIds.add(this._current.id)}}return!0}_addOverlap(t,e,r,i){const s=255^((t<0+r?Ae:t>=rt-r?Ee:Ae|Ee)|(e<0+i?Be:e>=rt-i?Re:Be|Re));this._current.overlaps|=s}_getVertexWriter(t){if(!this._data.self.has(t)){const e=this._data.self,r=Jt(t,this._symbologyType).geometry;e.set(t,new Ce(t,r,this.hint.records))}return this._data.self.get(t)}};const D=0,G=100;function Fe(a,t,e){return a[0]=t[0]-e[0],a[1]=t[1]-e[1],a}function dr(a,t){return Math.sqrt(a*a+t*t)}function Ve(a){const t=dr(a[0],a[1]);a[0]/=t,a[1]/=t}function gi(a,t){return dr(a[0]-t[0],a[1]-t[1])}function re(a=2){return 1/Math.max(a,1)}function Q(a,t){return[!!(a!=null&&a.minScale)&&t.scaleToZoom(a.minScale)||D,!!(a!=null&&a.maxScale)&&t.scaleToZoom(a.maxScale)||G]}function Mi(a,t){return a[t+1]}function _r(a){return a.length-1}function vi(a){let t=0;for(let e=0;e<_r(a);e++)t+=wi(a,e);return t}function wi(a,t,e=1){const[r,i]=Mi(a,t);return Math.sqrt(r*r+i*i)*e}let bi=class ie{constructor(t,e,r,i,s){this._segments=t,this._index=e,this._distance=r,this._xStart=i,this._yStart=s,this._done=!1}static create(t){return new ie(t,0,0,t[0][0],t[0][1])}clone(){return new ie(this._segments,this._index,this._distance,this.xStart,this.yStart)}equals(t){return this._index===t._index||t._index===this._index-1&&(this._distance===0||t._distance===1)||t._index===this._index+1&&(this._distance===1||t._distance===0)}leq(t){return this._index<t._index||this._index===t._index&&this._distance<=t._distance}geq(t){return this._index>t._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 r=Math.acos(e);return t>0&&(r=2*Math.PI-r),r}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+1<_r(this._segments)}next(){return this.hasNext()?(this._xStart+=this.dx,this._yStart+=this.dy,this._distance=0,this._index+=1,this):null}prev(){return this.hasPrev()?(this._index-=1,this._xStart-=this.dx,this._yStart-=this.dy,this._distance=1,this):(this._done=!0,null)}_seekBackwards(t,e){const r=this.backwardLength;if(t<=r)return this._distance=(r-t)/this.length,this;let i=this.backwardLength;for(;this.prev();){if(i+this.length>t)return this._seekBackwards(t-i);i+=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 r=this.remainingLength;for(;this.next();){if(r+this.length>t)return this.seek(t-r,e);r+=this.length}return this._distance=1,e?this:null}};function Si(a,t,e,r=!0){const i=vi(a),s=bi.create(a),n=i/2;if(!r)return s.seek(n),void e(s.clone(),0,n+0*t,i);const o=Math.max((i-t)/2,0),l=Math.floor(o/t),h=n-l*t;s.seek(h);for(let u=-l;u<=l;u++)s.x<512&&s.x>=0&&s.y<512&&s.y>=0&&e(s.clone(),u,n+u*t,i),s.seek(t)}function Li(a,t){const e=t;for(let r=0;r<a.length;r++){let i=a[r];zi(i,e);const s=[];s.push(i[0]);for(let n=1;n<i.length;n++){const[o,l]=i[n-1],[h,u]=i[n],c=Math.round(h-o),d=Math.round(u-l);s.push([c,d])}a[r]=s,i=s}return a}function zi(a,t){if(t<=0)return;const r=a.length;if(r<3)return;const i=[];let s=0;i.push(0);for(let c=1;c<r;c++)s+=gi(a[c],a[c-1]),i.push(s);t=Math.min(t,.2*s);const n=[];n.push(a[0][0]),n.push(a[0][1]);const o=a[r-1][0],l=a[r-1][1],h=Fe([0,0],a[0],a[1]);Ve(h),a[0][0]+=t*h[0],a[0][1]+=t*h[1],Fe(h,a[r-1],a[r-2]),Ve(h),a[r-1][0]+=t*h[0],a[r-1][1]+=t*h[1];for(let c=1;c<r;c++)i[c]+=t;i[r-1]+=t;const u=.5*t;for(let c=1;c<r-1;c++){let d=0,_=0,m=0;for(let f=c-1;f>=0&&!(i[f+1]<i[c]-u);f--){const p=u+i[f+1]-i[c],x=i[f+1]-i[f],y=i[c]-i[f]<u?1:p/x;if(Math.abs(y)<1e-6)break;const v=y*y,w=y*p-.5*v*x,b=y*x/t,L=a[f+1],z=a[f][0]-L[0],T=a[f][1]-L[1];d+=b/w*(L[0]*y*p+.5*v*(p*z-x*L[0])-v*y*x*z/3),_+=b/w*(L[1]*y*p+.5*v*(p*T-x*L[1])-v*y*x*T/3),m+=b}for(let f=c+1;f<r&&!(i[f-1]>i[c]+u);f++){const p=u-i[f-1]+i[c],x=i[f]-i[f-1],y=i[f]-i[c]<u?1:p/x;if(Math.abs(y)<1e-6)break;const v=y*y,w=y*p-.5*v*x,b=y*x/t,L=a[f-1],z=a[f][0]-L[0],T=a[f][1]-L[1];d+=b/w*(L[0]*y*p+.5*v*(p*z-x*L[0])-v*y*x*z/3),_+=b/w*(L[1]*y*p+.5*v*(p*T-x*L[1])-v*y*x*T/3),m+=b}n.push(d/m),n.push(_/m)}n.push(o),n.push(l);for(let c=0,d=0;c<r;c++)a[c][0]=n[d++],a[c][1]=n[d++]}let fr=class{static getPlacement(t,e,r,i,s,n){const o=hi(r);return o?(e===-1&&t.invertY(),o.execute(t,r,i,s,n)):null}};const nt=8,U=M(4,4),Pt=M(16,4),At=M(4,2),V=M(4,6),Oe=[At,At,V,V],De=[At,V,At,V],Pi=[V,V,U,U],Ti=[U,U,V,V],Wi=[V,U,V,U],Ii=[U,V,U,V],mr=a=>class extends a{constructor(...t){super(...t),this._isCIM=!1,this._vertexBoundsScale=1,this.geometryType=P.TEXT,this._aux=I(0,0,this._referenceSize,this._bitset)}bindTextInfo(t,e){this._shapingInfo=t!=null&&t.length?ci(t,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:Zr*Math.max(.25,Math.min(this._lineHeight,4)),decoration:this._decoration,isCIM:this._isCIM,hasBackground:!!this._backgroundColor,borderLineSize:this._borderLineSize}):null}_write(t,e,r,i){const s=e.getDisplayId();this._writeGeometry(t,e,s,r,i)}_writeGeometry(t,e,r,i,s){const n=this._shapingInfo;if(n==null)return;if(this._textPlacement)return this._writePlacedText(t,r,n,i,e,s);const o=s?s.asOptimized():e.geometryType==="esriGeometryPolygon"?e.readCentroid():e.readGeometryForDisplay();if(o!=null){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,r,{x:l,y:h},n)}o.forEachVertex((l,h)=>this._writeGlyphs(t,r,{x:l,y:h},n))}}_writePlacedText(t,e,r,i,s,n){const o=this._textPlacement,l=n||Dt.fromFeatureSetReaderCIM(s);if(!l)return;const h=-1,u=fr.getPlacement(l,h,o,g(1),t.tileKey,i.geometryEngine);if(!u)return;const c=r.bounds,d=Math.sqrt(c.height*c.height+c.width*c.width);let _,m,f;for(;_=u.next();)if(m=_.tx,f=-_.ty,m+d>=0&&m-d<512&&f+d>=0&&f-d<512){const p=-_.getAngle();r.setRotation(p),this._writeGlyphs(t,e,{x:m,y:f},r),r.setRotation(-p)}}_writeGlyphs(t,e,r,i){const s=te.load(this._materialKey),n=M(Math.round(nt*r.x),Math.round(nt*r.y)),o=this._vertexBoundsScale,{bounds:l,background:h,glyphs:u}=i;u.length>0&&(this._borderLineColor||this._backgroundColor)&&(s.textureBinding=u[0].textureBinding,t.recordStart(e,s.data,this.geometryType,!0),this._writeBackgroundGeometry(t,e,r,l,h),t.recordEnd());const c=2*Math.max(l.width,l.height);for(const d of i.glyphs)s.textureBinding=d.textureBinding,t.recordStart(e,s.data,this.geometryType,!0),t.vertexBounds(r.x+l.x+this._xOffset,r.y+l.y-this._yOffset,c*o,c*o),this._writeVertices(t,e,n,d),t.recordEnd()}_writeGlyph(t,e,r,i,s){const n=te.load(this._materialKey),o=M(Math.round(nt*r),Math.round(nt*i));n.textureBinding=s.textureBinding,t.recordStart(e,n.data,this.geometryType,!0);const l=s.bounds,h=this._vertexBoundsScale;t.vertexBounds(r+l.x*h,i+l.y*h,l.width*h,l.height*h),this._writeVertices(t,e,o,s),t.recordEnd()}_writeVertices(t,e,r,i){const s=t.vertexCount();this._writeVertexCommon(t,e,r,i),t.vertexWrite(i.offsets.upperLeft),t.vertexWrite(i.texcoords.upperLeft),t.vertexEnd(),this._writeVertexCommon(t,e,r,i),t.vertexWrite(i.offsets.upperRight),t.vertexWrite(i.texcoords.upperRight),t.vertexEnd(),this._writeVertexCommon(t,e,r,i),t.vertexWrite(i.offsets.lowerLeft),t.vertexWrite(i.texcoords.lowerLeft),t.vertexEnd(),this._writeVertexCommon(t,e,r,i),t.vertexWrite(i.offsets.lowerRight),t.vertexWrite(i.texcoords.lowerRight),t.vertexEnd(),t.indexWrite(s+0),t.indexWrite(s+1),t.indexWrite(s+2),t.indexWrite(s+1),t.indexWrite(s+3),t.indexWrite(s+2)}_writeVertexCommon(t,e,r,i){const s=this._color,n=this._haloColor,o=I(0,0,this._referenceSize,this._bitset),l=I(0,0,this._size,this._haloSize);t.vertexWrite(r),t.vertexWrite(e),t.vertexWrite(s),t.vertexWrite(n),t.vertexWrite(l),t.vertexWrite(o),t.vertexWrite(this._minMaxZoom)}_writeBackgroundVertex(t,e,r,i,s,n){const o=I(0,1,this._referenceSize,this._bitset),l=I(0,0,this._size,this._haloSize),h=I(0,0,0,0);t.vertexWrite(r),t.vertexWrite(e),t.vertexWrite(i),t.vertexWrite(h),t.vertexWrite(l),t.vertexWrite(o),t.vertexWrite(this._minMaxZoom),t.vertexWrite(s),t.vertexWrite(n),t.vertexEnd()}_writeBackgroundQuad(t,e,r,i,s,n){const o=t.vertexCount();this._writeBackgroundVertex(t,e,r,i,s.upperLeft,n[0]),this._writeBackgroundVertex(t,e,r,i,s.upperRight,n[1]),this._writeBackgroundVertex(t,e,r,i,s.lowerLeft,n[2]),this._writeBackgroundVertex(t,e,r,i,s.lowerRight,n[3]),t.indexWrite(o+0),t.indexWrite(o+1),t.indexWrite(o+2),t.indexWrite(o+1),t.indexWrite(o+3),t.indexWrite(o+2)}_writeBackgroundGeometry(t,e,r,i,s){const n=M(Math.round(nt*r.x),Math.round(nt*r.y)),{x:o,y:l,width:h,height:u}=i,c=2*Math.max(h,u);if(t.vertexBounds(r.x+o+this._xOffset,r.y+l-this._yOffset,c*this._vertexBoundsScale,c*this._vertexBoundsScale),this._backgroundColor){const d=[Pt,Pt,Pt,Pt];this._writeBackgroundQuad(t,e,n,this._backgroundColor,s.main,d)}if(this._borderLineColor||this._backgroundColor){const d=!!this._borderLineColor&&!!this._borderLineSize&&this._borderLineSize>0,[_,m,f,p,x]=d?[Oe,Oe,De,De,this._borderLineColor]:[Pi,Ti,Wi,Ii,this._backgroundColor];this._writeBackgroundQuad(t,e,n,x,s.top,_),this._writeBackgroundQuad(t,e,n,x,s.bot,m),this._writeBackgroundQuad(t,e,n,x,s.left,f),this._writeBackgroundQuad(t,e,n,x,s.right,p)}}};let vt=class{constructor(){this._materialKey=null}bindFeature(t,e,r){}write(t,e,r,i){if(this._effects&&this._effects.length>0){let s=Dt.fromFeatureSetReaderCIM(e);if(s){s.invertY();const n=ui.executeEffects(this._effects,s,t.tileKey,i.geometryEngine);for(;s=n.next();)s.invertY(),this._write(t,e,i,s)}}else this._write(t,e,i)}_write(t,e,r,i){}};const Ci=5;let se=class ne extends mr(vt){constructor(t,e,r,i,s,n,o,l,h,u,c,d,_,m,f,p,x,y,v,w,b,L,z,T){super(),this._xOffset=g(_),this._yOffset=g(m),this._decoration=u||"none",this._backgroundColor=L,this._borderLineColor=z,this._borderLineSize=T,this._color=s,this._haloColor=n,this._haloSize=Math.min(Math.floor(Ci*g(kr(r))),127),this._size=Math.min(Math.round(g(e)),127);const Z=Math.min(Math.round(g(i||e)),127);this._referenceSize=Math.round(Math.sqrt(256*Z)),this._scale=this._size/Je,this._angle=d,this._justify=ii(o||"center"),this._xAlignD=or(o||"center"),this._yAlignD=lr(l||"baseline"),this._baseline=(l||"baseline")==="baseline",this._bitset=(h===O.MAP?1:0)|(c?1:0)<<1;const it=te.load(t);it.sdf=!0,this._materialKey=it.data,this._lineWidth=g(f)||512,this._lineHeight=p||1,this._textPlacement=x,this._effects=y,this._isCIM=v??!1,this._minMaxZoom=M(Math.round(w*$),Math.round(b*$))}static fromText(t,e){var n,o;const r=(n=t.font)==null?void 0:n.size,i=new ne(t.materialKey,r,t.haloSize||0,r,t.color&&F(t.color)||0,t.haloColor&&F(t.haloColor)||0,t.horizontalAlignment,t.verticalAlignment,O.SCREEN,(o=t.font)==null?void 0:o.decoration,!1,t.angle||0,t.xoffset||0,t.yoffset||0,t.lineWidth||0,t.lineHeight||0,null,null,!1,D,G,t.backgroundColor&&F(t.backgroundColor),t.borderLineColor&&F(t.borderLineColor),t.borderLineSize),[,s]=Ie(t.text);return i.bindTextInfo(e??[],s),i._vertexBoundsScale=t.maxVVSize&&r?t.maxVVSize/r:1,i}static fromCIMText(t,e,r){const i=t.scaleFactor||1,s=t.size*t.sizeRatio*i,[n,o]=Q(t.scaleInfo,r),l=new ne(t.materialKey,s,t.outlineSize*t.sizeRatio,t.referenceSize,W(t.color),W(t.outlineColor),t.horizontalAlignment,t.verticalAlignment,t.alignment,t.decoration,t.colorLocked??!1,t.angle,t.offsetX*t.sizeRatio*i,t.offsetY*t.sizeRatio*i,t.lineWidth||512,1,t.markerPlacement,t.effects,!0,n,o,t.backgroundColor?W(t.backgroundColor):void 0,t.borderLineColor?W(t.borderLineColor):void 0,t.borderLineWidth),[,h]=Ie(t.text);return l.bindTextInfo(e,h),l._vertexBoundsScale=t.maxVVSize?t.maxVVSize/s:1,l}};const pr=dt.getLogger("esri.views.2d.engine.webgl.WGLLabelTemplate"),$i=(a,t="mapview-labeling")=>pr.error(new Mt(t,a)),Tt=1,at=0,ki=4,qt=25;function Ei(a,t){const e=!!a.minScale&&t.scaleToZoom(a.minScale)||0;return Qe(e,0,25.5)}function Ai(a,t){const e=!!a.maxScale&&t.scaleToZoom(a.maxScale)||255;return Qe(e,0,25.5)}function Ri(a){const t=new Map;return e=>(t.has(e)||t.set(e,a(e)),t.get(e))}const Bi=Ri(a=>{let t=0;if(a===0)return 1/0;for(;!(a%2);)t++,a/=2;return t}),Wt=a=>Math.floor(127*a+127),J=a=>Math.floor(a*$),Y=a=>Math.round(a*(254/360));class Rt extends se{constructor(t,e,r,i){var c,d,_;super(t,(c=r.font)==null?void 0:c.size,r.haloSize||0,(d=r.font)==null?void 0:d.size,r.color&&F(r.color)||0,r.haloColor&&F(r.haloColor)||0,r.horizontalAlignment,r.verticalAlignment,si(e.labelPlacement)?O.MAP:O.SCREEN,(_=r.font)==null?void 0:_.decoration,!1,r.angle||0,r.xoffset,r.yoffset,r.lineWidth,r.lineHeight,null,null,!1,null,null,r.backgroundColor&&F(r.backgroundColor),r.borderLineColor&&F(r.borderLineColor),r.borderLineSize),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=e.allowOverrun??!1,this._repeatLabel=e.repeatLabel??!0,this._labelPosition=e.labelPosition??"curved";const s=Ei(e,i),n=Ai(e,i),o=e.labelPlacement,[l,h]=ni(o);this._xAlignD=l,this._yAlignD=h,this._minZoom=s,this._maxZoom=n,this._minBackgroundZoom=s,this._maxBackgroundZoom=n,this._refPlacementPadding=g(r.haloSize)+Nr,this._repeatLabelDistance=e.repeatLabelDistance?g(e.repeatLabelDistance):128;const u=Ht.load(t);u.sdf=!0,this._materialKey=u.data}static fromLabelClass(t,e){if(t.labelPlacement==="esriServerLinePlacementCenterAlong"){const r=t.symbol;r.xoffset=0,r.yoffset=0,r.angle=0,r.font.decoration="none"}return new Rt(t.materialKey,t,t.symbol,e)}get _shapedBox(){return this._shapingInfo.bounds}setZoomLevel(t){this._zoomLevel=t}bindReferenceTemplate(t){let e=ai(this._xAlignD),r=oi(this._yAlignD);if(this._refOffsetX=0,this._refOffsetY=0,t==null)return void(this._refSymbolAndPlacementOffset=I(0,0,Wt(e),Wt(r)));if(t.boundsType==="circle"&&(e||r)){const n=Math.sqrt(e*e+r*r);e/=n,r/=n}const i=Math.max(t.height,t.width),s=this._refPlacementPadding*ki;this._refSymbolAndPlacementOffset=I(s,i,Wt(e),Wt(r)),this._referenceSize=i,this._refPlacementDirX=e,this._refPlacementDirY=r,this._refOffsetX=t.xOffset,this._refOffsetY=t.yOffset}_write(t,e){if(this._shapingInfo==null)return;const r=this._shapingInfo,i=e.getDisplayId(),s=e.geometryType==="esriGeometryPolygon"?e.readLegacyCentroid():e.readLegacyGeometry();if(s)switch(this._current={out:t,inId:i,inShaping:r,zoomLevel:this._zoomLevel},e.geometryType==="esriGeometryPolyline"&&this._labelPosition==="curved"&&(this._borderLineColor||this._backgroundColor)&&pr.warnOnce("TextSymbol properties 'borderLineColor', 'borderLineSize', and 'backgroundColor' are not supported in curved labels"),e.geometryType){case"esriGeometryPolyline":this._placeLineLabels(s);break;case"esriGeometryPoint":case"esriGeometryPolygon":this._placePointLabels(s);break;default:$i(`Geometry of type ${e.geometryType} is not supported`)}}_isVisible(t,e){const r=J(this._current.zoomLevel);return J(t)<=r&&r<=J(e)}_placePointLabels(t){const{out:e,inId:r,inShaping:i}=this._current;this._writeGlyphs(e,r,t,i)}_placeLineLabels(t){const e=Li(t.paths,this._current.inShaping.bounds.width),r=this._placeSubdivGlyphs.bind(this),i=(this._shapedBox.width+this._repeatLabelDistance)/(1<<Tt);for(const s of e)Si(s,i,r,this._repeatLabel)}_placeSubdivGlyphs(t,e,r,i){const s=Bi(e),n=this._shapedBox.width/(1<<Tt),o=Math.sqrt(this._repeatLabelDistance)/(1<<Tt),l=Math.min(r,i-r),h=this._current.inShaping.isMultiline?qt:Math.log2(l/(o+n/2)),u=e===0?h:Math.min(s,h),c=Math.max(this._minZoom,this._current.zoomLevel+Tt-u),d=this._current.zoomLevel-c,_=this._shapedBox.width/2*2**d;this._current.inShaping.isMultiline?e===0&&this._placeStraight(t,c):this._allowOverrun&&d<0?this._placeStraightAlong(t,this._minZoom):this._labelPosition==="parallel"?this._placeStraightAlong(t,c):this._labelPosition==="curved"&&this._placeCurved(t,c,_)}_placeStraight(t,e){const{out:r,inId:i,inShaping:s}=this._current,n=Math.ceil(t.angle*(180/Math.PI)%360),o=Math.ceil((t.angle*(180/Math.PI)+180)%360);this._outLineLabelAngle=Y(n),this._writeGlyphs(r,i,t,s,e),this._outLineLabelAngle=Y(o),this._writeGlyphs(r,i,t,s,e)}_placeCurved(t,e,r){const{out:i,inId:s}=this._current;i.metricStart(s,e,t.x,t.y,0,0,0,0);const n=t.clone(),o=t.angle*(180/Math.PI)%360,l=(t.angle*(180/Math.PI)+180)%360;this._outLineLabelAngle=Y(o),this._placeFirst(n,e,1),this._placeBack(t,n,e,r,1),this._placeForward(t,n,e,r,1),this._outLineLabelAngle=Y(l),this._placeFirst(n,e,0),this._placeBack(t,n,e,r,0),this._placeForward(t,n,e,r,0),i.metricEnd()}_placeStraightAlong(t,e){const{out:r,inId:i,inShaping:s}=this._current;r.metricStart(i,e,t.x,t.y,0,0,0,0);const n=t.clone(),o=t.angle*(180/Math.PI)%360,l=(t.angle*(180/Math.PI)+180)%360,h=s.glyphs.length>0&&(this._borderLineColor||this._backgroundColor);if(this._maxBackgroundZoom=qt,this._minBackgroundZoom=Math.max(e,0),h){const u=Ht.load(this._materialKey);u.textureBinding=s.glyphs[0].textureBinding;const c=je(Vt(),-t.angle),[d,_]=s.shapeBackground(c);this._outLineLabelAngle=Y(o),r.recordStart(i,u.data,this.geometryType,!0),this._writeBackgroundGeometry(r,i,t,d,_),r.recordEnd(),this._outLineLabelAngle=Y(l),r.recordStart(i,u.data,this.geometryType,!0),this._writeBackgroundGeometry(r,i,t,d,_),r.recordEnd()}this._outLineLabelAngle=Y(o),this._placeFirst(n,e,1,!0),this._outLineLabelAngle=Y(l),this._placeFirst(n,e,0,!0),r.metricEnd()}_placeBack(t,e,r,i,s){const n=t.clone();let o=t.backwardLength+at;for(;n.prev()&&!(o>=i);)this._placeOnSegment(n,e,o,r,-1,s),o+=n.length+at}_placeForward(t,e,r,i,s){const n=t.clone();let o=t.remainingLength+at;for(;n.next()&&!(o>=i);)this._placeOnSegment(n,e,o,r,1,s),o+=n.length+at}_placeFirst(t,e,r,i=!1){const s=t,n=this._current.inShaping,o=n.glyphs,l=this._current.zoomLevel,{out:h,inId:u}=this._current;for(const c of o){const d=c.x>n.bounds.x?r:1-r,_=d*t.remainingLength+(1-d)*t.backwardLength,m=Math.abs(c.x+c.width/2-n.bounds.x),f=Math.max(0,l+Math.log2(m/(_+at))),p=Math.max(e,i?0:f);if(c.maxZoom=qt,c.angle=t.angle+(1-r)*Math.PI,c.minZoom=p,this._writeGlyph(h,u,s.x,s.y,c),r&&this._isVisible(c.minZoom,c.maxZoom)){const x=c.bounds;h.metricBoxWrite(x.center[0],x.center[1],x.width,x.height)}}}_placeOnSegment(t,e,r,i,s,n){const o=this._current.inShaping.glyphs,{out:l,inId:h}=this._current,u=this._current.inShaping,c=this._current.zoomLevel,d=t.dx/t.length,_=t.dy/t.length,m={x:t.x+r*-s*d,y:t.y+r*-s*_};for(const f of o){const p=f.x>u.bounds.x?n:1-n;if(!(p&&s===1||!p&&s===-1))continue;const x=Math.abs(f.x+f.width/2-u.bounds.x),y=Math.max(0,c+Math.log2(x/r)-.1),v=Math.max(i,c+Math.log2(x/(r+t.length+at)));if(y!==0&&(f.angle=t.angle+(1-n)*Math.PI,f.minZoom=v,f.maxZoom=y,this._writeGlyph(l,h,m.x,m.y,f),n&&this._isVisible(f.minZoom,f.maxZoom))){const w=f.bounds,b=t.x-e.x,L=t.y-e.y;l.metricBoxWrite(w.center[0]+b,w.center[1]+L,w.width,w.height)}}}_writeGlyphs(t,e,r,i,s=this._minZoom){if(r.x<0||r.x>=512||r.y<0||r.y>=512)return;if(i.glyphs.length>0&&(this._borderLineColor||this._backgroundColor)){const c=Ht.load(this._materialKey);c.textureBinding=i.glyphs[0].textureBinding,t.recordStart(e,c.data,this.geometryType,!0),this._writeBackgroundGeometry(t,e,r,i.bounds,i.background),t.recordEnd()}const n=r.x+this._refOffsetX,o=r.y-this._refOffsetY;for(const c of i.glyphs)c.minZoom=s,c.maxZoom=this._maxZoom,this._writeGlyph(t,e,n,o,c);const l=this._refPlacementDirX,h=this._refPlacementDirY,u=i.boundsT;t.metricStart(e,s,n,o,l,h,this._referenceSize,this._materialKey),t.metricBoxWrite(u.center[0],u.center[1],u.width,u.height),t.metricEnd()}_writeVertexCommon(t,e,r,i){const s=this._color,n=this._haloColor,o=I(0,0,this._size,this._haloSize),l=Math.max(i.minZoom,this._minZoom),h=Math.min(i.maxZoom,this._maxZoom),u=I(J(l),J(h),this._outLineLabelAngle,0);t.vertexWrite(r),t.vertexWrite(e),t.vertexWrite(s),t.vertexWrite(n),t.vertexWrite(o),t.vertexWrite(this._refSymbolAndPlacementOffset),t.vertexWrite(u)}_writeBackgroundVertex(t,e,r,i,s,n){const o=I(0,0,this._size,this._haloSize),l=I(0,0,0,0),h=I(J(this._minBackgroundZoom),J(this._maxBackgroundZoom),this._outLineLabelAngle,1);t.vertexWrite(r),t.vertexWrite(e),t.vertexWrite(i),t.vertexWrite(l),t.vertexWrite(o),t.vertexWrite(this._refSymbolAndPlacementOffset),t.vertexWrite(h),t.vertexWrite(s),t.vertexWrite(n),t.vertexEnd()}}const Ut=3.14159265359/180,Ge=8,xr=a=>class extends a{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._allowBorrowing=!0,this._vertexBoundsScaleX=1,this._vertexBoundsScaleY=1,this.geometryType=P.MARKER}_write(t,e,r,i){const s=e.getDisplayId();t.recordStart(s,this._materialKey,this.geometryType,!0),this._writeGeometry(t,e,s,r,i),t.recordEnd()}_writeGeometry(t,e,r,i,s){if(this._markerPlacement!=null)return this._writePlacedMarkers(t,e,i,s);if(this._allowBorrowing=!0,!s&&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,r,this._getPos(o,l),o,l)}const n=s?s.asOptimized():e.geometryType==="esriGeometryPolygon"?e.readCentroid():e.readGeometryForDisplay();if(n!=null){if(n.isPoint){const[o,l]=n.coords;return!t.hasAggregates&&t.hasPixelBufferEnabled&&(o<0||o>=512||l<0||l>=512)?void 0:this._writeVertices(t,r,this._getPos(o,l),o,l)}n.forEachVertex((o,l)=>{const h=2*rt;o<-h||o>=h||l<-h||l>=h||this._writeVertices(t,r,this._getPos(o,l),o,l)})}}_writePlacedMarkers(t,e,r,i){const s=i||Dt.fromFeatureSetReaderCIM(e);if(!s)return;const n=-1,o=fr.getPlacement(s,n,this._markerPlacement,g(1),t.tileKey,r.geometryEngine);if(!o)return;this._allowBorrowing=e.geometryType!=="esriGeometryPolygon";const l=e.getDisplayId(),h=de(),u=Vt(),c=-128,d=640;let _=o.next();for(;_!=null;){const m=_.tx,f=-_.ty;m>=c&&m<=d&&f>=c&&f<=d&&(this._applyTransformation(u,h,-_.getAngle()/Ut),this._writeVertices(t,l,this._getPos(m,f),m,f)),_=o.next()}}_writeVertices(t,e,r,i,s){const n=fe.load(this._materialKey);return n.symbologyType===Gt.HEATMAP?this._writeHeatmapVertices(t,e,r):this._writeMarkerVertices(t,e,n,r,i,s)}_writeMarkerVertices(t,e,r,i,s,n){const o=r.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}this._allowBorrowing&&t.vertexBounds(s+this.xOffset,n-this.yOffset,h,u),t.vertexWrite(i),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(i),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(i),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(i),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,r){const i=t.vertexCount();t.vertexWrite(r),t.vertexWrite(this._offsetUpperLeft),t.vertexWrite(e),t.vertexEnd(),t.vertexWrite(r),t.vertexWrite(this._offsetUpperRight),t.vertexWrite(e),t.vertexEnd(),t.vertexWrite(r),t.vertexWrite(this._offsetBottomLeft),t.vertexWrite(e),t.vertexEnd(),t.vertexWrite(r),t.vertexWrite(this._offsetBottomRight),t.vertexWrite(e),t.vertexEnd(),this._writeIndices(t,i)}_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,r=0){r?je(t,Ut*r):Er(t),Ar(t,t,Rr(this.xOffset,-this.yOffset)),this.angle&&Br(t,t,Ut*this.angle);const i=this._computedWidth,s=this._computedHeight,n=-(.5+this._anchorX)*i,o=-(.5-this._anchorY)*s;wt(e,n,o),bt(e,e,t),this._offsetUpperLeft=M(16*e[0],16*e[1]),wt(e,n+i,o),bt(e,e,t),this._offsetUpperRight=M(16*e[0],16*e[1]),wt(e,n,o+s),bt(e,e,t),this._offsetBottomLeft=M(16*e[0],16*e[1]),wt(e,n+i,o+s),bt(e,e,t),this._offsetBottomRight=M(16*e[0],16*e[1])}_computeSize(t,e,r,i,s,n,o,l){const h=t*r,u=e*r;if(n.sdf&&!o){const L=l&&t>e?h:t,z=e,T=i+2*1;t=Math.min(L+T,h),e=Math.min(z+T,u)}else t=h,e=u;const c=Xr/Math.max(h,u),d=.5*(h-t)*c,_=.5*(u-e)*c,m=n.rect.x+E+d,f=n.rect.y+E+_,p=m+n.width-2*d,x=f+n.height-2*_,y=Math.floor(m),v=Math.floor(f),w=Math.ceil(p),b=Math.ceil(x);t*=(w-y)/(p-m),e*=(b-v)/(x-f),this._texUpperLeft=M(y,v),this._texUpperRight=M(w,v),this._texBottomLeft=M(y,b),this._texBottomRight=M(w,b),this._anchorX*=h/t,this._anchorY*=u/e,t*=s,e*=s,this._computedWidth=t,this._computedHeight=e}_getPos(t,e){return M(Math.round(Ge*t),Math.round(Ge*e))}};let _t=class ft extends xr(vt){constructor(t,e,r,i,s,n,o,l,h,u,c,d,_,m,f,p,x,y,v,w,b,L,z,T){super(),this.angle=i,this.height=o,this.width=n,this.xOffset=e*v,this.yOffset=r*v,this._markerPlacement=w||void 0,this._effects=b||void 0,this._anchorX=p,this._anchorY=x,this._minMaxZoom=M(Math.round(L*$),Math.round(z*$));const Z=(m===O.MAP?tr:er)|(c?q:0)|(_?Yr:0)|(d?rr:0),it=f&&f.sdf,st=fe.load(t);st.sdf=it,st.pattern=!0,st.textureBinding=f.textureBinding,this._materialKey=st.data,this._fillColor=s,this._outlineColor=h,this._sizeOutlineWidth=I(Math.round(Math.min(Math.sqrt(128*n),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))),st.symbologyType===Gt.PIE_CHART?(n*=y*v,o*=y*v,this._computedWidth=n,this._computedHeight=o,this._texUpperLeft=M(0,1),this._texUpperRight=M(1,1),this._texBottomLeft=M(0,0),this._texBottomRight=M(1,0)):this._computeSize(n,o,y,u,v,f,st.hasSizeVV(),T);const Wr=Math.round(64*y);this._bitestAndDistRatio=M(Z,Wr);const Ir=de(),Cr=Vt();this._applyTransformation(Cr,Ir)}static fromCIMMarker(t,e,r){const i=e&&e.width||1,s=e&&e.height||1,n=t.size,o=i/s*t.scaleX,l=t.scaleSymbolsProportionally&&t.frameHeight?n/t.frameHeight:1,h=W(t.color),u=W(t.outlineColor),c=g(n),d=c*o,_=g(t.offsetX||0),m=g(t.offsetY||0),f=g(t.outlineWidth||0)*l,p=t.alignment||O.SCREEN,x=g(t.referenceSize),[y,v]=Q(t.scaleInfo,r);let w=t.rotation||0;t.rotateClockwise||(w=-w);let b=0,L=0;const z=t.anchorPoint;z&&(t.isAbsoluteAnchorPoint?n&&(b=z.x/(n*o),L=z.y/n):(b=z.x,L=z.y));const T=new ft(t.materialKey,_,m,w,h,d,c,x,u,f,t.colorLocked,t.scaleSymbolsProportionally,!1,p,e,b,L,t.sizeRatio,t.scaleFactor??1,t.markerPlacement,t.effects,y,v,!0);return T._vertexBoundsScaleX=t.maxVVSize?t.maxVVSize/d:1,T._vertexBoundsScaleY=t.maxVVSize?t.maxVVSize/c:1,T}static fromPictureMarker(t,e){const r=Math.round(g(t.width)),i=Math.round(g(t.height)),s=ir,n=Math.round(g(t.xoffset||0)),o=Math.round(g(t.yoffset||0)),l=new ft(t.materialKey,n,o,t.angle,s,r,i,i,0,0,!1,!1,!1,O.SCREEN,e,0,0,1,1,null,null,D,G,!1);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 r=t.style,i=F(t.color),s=Math.round(g(t.size));let n=s;r==="esriSMSTriangle"&&(n*=e.height/e.width);const o=Math.round(g(t.xoffset||0)),l=Math.round(g(t.yoffset||0)),h=t.outline,u=0|((h==null?void 0:h.color)&&F(h.color)),c=0|((h==null?void 0:h.width)&&Math.round(g(h.width))),d=new ft(t.materialKey,o,l,t.angle??0,i,s,n,n,u,c,!1,!1,r==="esriSMSCross"||r==="esriSMSX",O.SCREEN,e,0,0,2,1,null,null,D,G,!1);return d.boundsType=r==="esriSMSCircle"?"circle":"square",d._vertexBoundsScaleX=t.maxVVSize?t.maxVVSize/t.size:1,d._vertexBoundsScaleY=t.maxVVSize?t.maxVVSize/t.size:1,d}static fromLineSymbolMarker(t,e){const r=F(t.color),i=6,s=Math.round(g(i*t.lineWidth)),n=s,o=t.style==="cross"||t.style==="x";let l;switch(t.placement){case"begin-end":l=St.Both;break;case"begin":l=St.JustBegin;break;case"end":l=St.JustEnd;break;default:l=St.None}const h={type:"CIMMarkerPlacementAtExtremities",angleToLine:!0,offset:0,extremityPlacement:l,offsetAlongLine:0},u=new ft(t.materialKey,0,0,0,r,s,n,n/i,r,o?Math.round(g(t.lineWidth)):0,!1,!1,o,O.MAP,e,0,0,2,1,h,null,D,G,!1);return u.boundsType=t.style==="circle"?"circle":"square",u}};function Fi(a,t,e,r,i,s,n){le=0;const o=(r-e)*s,l=i&&i.length,h=l?(i[0]-e)*s:o;let u,c,d,_,m,f=yr(t,e,r,0,h,s,!0);if(f&&f.next!==f.prev){if(l&&(f=Gi(t,e,r,i,f,s)),o>80*s){u=d=t[0+e*s],c=_=t[1+e*s];for(let p=s;p<h;p+=s){const x=t[p+e*s],y=t[p+1+e*s];u=Math.min(u,x),c=Math.min(c,y),d=Math.max(d,x),_=Math.max(_,y)}m=Math.max(d-u,_-c),m=m!==0?1/m:0}xt(f,a,s,u,c,m,n,0)}}function yr(a,t,e,r,i,s,n){let o;if(n===Yi(a,t,e,r,i,s)>0)for(let l=r;l<i;l+=s)o=Ke(l+t*s,a[l+t*s],a[l+1+t*s],o);else for(let l=i-s;l>=r;l-=s)o=Ke(l+t*s,a[l+t*s],a[l+1+t*s],o);return o&&et(o,o.next)&&(yt(o),o=o.next),o}function pt(a,t=a){if(!a)return a;let e,r=a;do if(e=!1,r.steiner||!et(r,r.next)&&C(r.prev,r,r.next)!==0)r=r.next;else{if(yt(r),r=t=r.prev,r===r.next)break;e=!0}while(e||r!==t);return t}function xt(a,t,e,r,i,s,n,o){if(!a)return;!o&&s&&(a=gr(a,r,i,s));let l=a;for(;a.prev!==a.next;){const h=a.prev,u=a.next;if(s?Oi(a,r,i,s):Vi(a))t.push(h.index/e+n),t.push(a.index/e+n),t.push(u.index/e+n),yt(a),a=u.next,l=u.next;else if((a=u)===l){o?o===1?xt(a=qi(a,t,e,n),t,e,r,i,s,n,2):o===2&&Ui(a,t,e,r,i,s,n):xt(pt(a),t,e,r,i,s,n,1);break}}}function Vi(a){const t=a.prev,e=a,r=a.next;if(C(t,e,r)>=0)return!1;let i=a.next.next;const s=i;let n=0;for(;i!==a.prev&&(n===0||i!==s);){if(n++,ht(t.x,t.y,e.x,e.y,r.x,r.y,i.x,i.y)&&C(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Oi(a,t,e,r){const i=a.prev,s=a,n=a.next;if(C(i,s,n)>=0)return!1;const o=i.x<s.x?i.x<n.x?i.x:n.x:s.x<n.x?s.x:n.x,l=i.y<s.y?i.y<n.y?i.y:n.y:s.y<n.y?s.y:n.y,h=i.x>s.x?i.x>n.x?i.x:n.x:s.x>n.x?s.x:n.x,u=i.y>s.y?i.y>n.y?i.y:n.y:s.y>n.y?s.y:n.y,c=ae(o,l,t,e,r),d=ae(h,u,t,e,r);let _=a.prevZ,m=a.nextZ;for(;_&&_.z>=c&&m&&m.z<=d;){if(_!==a.prev&&_!==a.next&&ht(i.x,i.y,s.x,s.y,n.x,n.y,_.x,_.y)&&C(_.prev,_,_.next)>=0||(_=_.prevZ,m!==a.prev&&m!==a.next&&ht(i.x,i.y,s.x,s.y,n.x,n.y,m.x,m.y)&&C(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;_&&_.z>=c;){if(_!==a.prev&&_!==a.next&&ht(i.x,i.y,s.x,s.y,n.x,n.y,_.x,_.y)&&C(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;m&&m.z<=d;){if(m!==a.prev&&m!==a.next&&ht(i.x,i.y,s.x,s.y,n.x,n.y,m.x,m.y)&&C(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function Ke(a,t,e,r){const i=ut.create(a,t,e);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function yt(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 Di(a){let t=a,e=a;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==a);return e}function Gi(a,t,e,r,i,s){const n=new Array;for(let o=0,l=r.length;o<l;o++){const h=yr(a,t,e,r[o]*s,o<l-1?r[o+1]*s:e*s,s,!1);h===h.next&&(h.steiner=!0),n.push(Di(h))}n.sort(Hi);for(const o of n)i=Ki(o,i);return i}function Ki(a,t){const e=Zi(a,t);if(!e)return t;const r=vr(e,a);return pt(r,r.next),pt(e,e.next)}function Zi(a,t){let e=t;const r=a.x,i=a.y;let s,n=-1/0;do{if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){const d=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=r&&d>n){if(n=d,d===r){if(i===e.y)return e;if(i===e.next.y)return e.next}s=e.x<e.next.x?e:e.next}}e=e.next}while(e!==t);if(!s)return null;if(r===n)return s.prev;const o=s,l=s.x,h=s.y;let u,c=1/0;for(e=s.next;e!==o;)r>=e.x&&e.x>=l&&r!==e.x&&ht(i<h?r:n,i,l,h,i<h?n:r,i,e.x,e.y)&&(u=Math.abs(i-e.y)/(r-e.x),(u<c||u===c&&e.x>s.x)&&gt(e,a)&&(s=e,c=u)),e=e.next;return s}function gr(a,t,e,r){let i;for(;i!==a;i=i.next){if(i=i||a,i.z===null&&(i.z=ae(i.x,i.y,t,e,r)),i.prev.next!==i||i.next.prev!==i)return i.prev.next=i,i.next.prev=i,gr(a,t,e,r);i.prevZ=i.prev,i.nextZ=i.next}return a.prevZ.nextZ=null,a.prevZ=null,Ni(a)}function Ni(a){let t,e=1;for(;;){let r,i=a;a=null,t=null;let s=0;for(;i;){s++,r=i;let n=0;for(;n<e&&r;n++)r=r.nextZ;let o=e;for(;n>0||o>0&&r;){let l;n===0?(l=r,r=r.nextZ,o--):o!==0&&r?i.z<=r.z?(l=i,i=i.nextZ,n--):(l=r,r=r.nextZ,o--):(l=i,i=i.nextZ,n--),t?t.nextZ=l:a=l,l.prevZ=t,t=l}i=r}if(t.nextZ=null,e*=2,s<2)return a}}function C(a,t,e){return(t.y-a.y)*(e.x-t.x)-(t.x-a.x)*(e.y-t.y)}function Mr(a,t,e,r){return!!(et(a,t)&&et(e,r)||et(a,r)&&et(e,t))||C(a,t,e)>0!=C(a,t,r)>0&&C(e,r,a)>0!=C(e,r,t)>0}function Xi(a,t){let e=a;do{if(e.index!==a.index&&e.next.index!==a.index&&e.index!==t.index&&e.next.index!==t.index&&Mr(e,e.next,a,t))return!0;e=e.next}while(e!==a);return!1}function Yi(a,t,e,r,i,s){let n=0;for(let o=r,l=i-s;o<i;o+=s)n+=(a[l+t*s]-a[o+t*s])*(a[o+1+t*s]+a[l+1+t*s]),l=o;return n}function ht(a,t,e,r,i,s,n,o){return(i-n)*(t-o)-(a-n)*(s-o)>=0&&(a-n)*(r-o)-(e-n)*(t-o)>=0&&(e-n)*(s-o)-(i-n)*(r-o)>=0}function gt(a,t){return C(a.prev,a,a.next)<0?C(a,t,a.next)>=0&&C(a,a.prev,t)>=0:C(a,t,a.prev)<0||C(a,a.next,t)<0}function ae(a,t,e,r,i){return(a=1431655765&((a=858993459&((a=252645135&((a=16711935&((a=32767*(a-e)*i)|a<<8))|a<<4))|a<<2))|a<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function et(a,t){return a.x===t.x&&a.y===t.y}function Hi(a,t){return a.x-t.x}function qi(a,t,e,r){let i=a;do{const s=i.prev,n=i.next.next;!et(s,n)&&Mr(s,i,i.next,n)&&gt(s,n)&&gt(n,s)&&(t.push(s.index/e+r),t.push(i.index/e+r),t.push(n.index/e+r),yt(i),yt(i.next),i=a=n),i=i.next}while(i!==a);return i}function Ui(a,t,e,r,i,s,n){let o=a;do{let l=o.next.next;for(;l!==o.prev;){if(o.index!==l.index&&ji(o,l)){let h=vr(o,l);return o=pt(o,o.next),h=pt(h,h.next),xt(o,t,e,r,i,s,n,0),void xt(h,t,e,r,i,s,n,0)}l=l.next}o=o.next}while(o!==a)}function ji(a,t){return a.next.index!==t.index&&a.prev.index!==t.index&&!Xi(a,t)&&gt(a,t)&&gt(t,a)&&Qi(a,t)}function Qi(a,t){let e=a,r=!1;const i=(a.x+t.x)/2,s=(a.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==a);return r}function vr(a,t){const e=ut.create(a.index,a.x,a.y),r=ut.create(t.index,t.x,t.y),i=a.next,s=t.prev;return a.next=t,t.prev=a,e.next=i,i.prev=e,r.next=e,e.prev=r,s.next=r,r.prev=s,r}class ut{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,r){const i=le<oe.length?oe[le++]:new ut;return i.index=t,i.x=e,i.y=r,i.prev=null,i.next=null,i.z=null,i.prevZ=null,i.nextZ=null,i.steiner=!1,i}}const oe=new Array,Ji=8096;let le=0;for(let a=0;a<Ji;a++)oe.push(new ut);const ts=1e-5,tt=new cr(0,0,0,1,0),he=new cr(0,0,0,1,0);function Ze(a,t,e){let r=0;for(let i=1;i<e;i++){const s=a[2*(t+i-1)],n=a[2*(t+i-1)+1];r+=(a[2*(t+i)]-s)*(a[2*(t+i)+1]+n)}return r}function es(a,t,e,r,i){let s=0;const n=2;for(let o=e;o<r;o+=3){const l=(a[o]-i)*n,h=(a[o+1]-i)*n,u=(a[o+2]-i)*n;s+=Math.abs((t[l]-t[u])*(t[h+1]-t[l+1])-(t[l]-t[h])*(t[u+1]-t[l+1]))}return s}function rs(a,t){const{coords:e,lengths:r,hasIndeterminateRingOrder:i}=t,s=0,n=a;if(i)return!1;let o=0;for(let l=0;l<r.length;){let h=l,u=r[l],c=Ze(e,o,u);const d=[];for(;++h<r.length;){const p=r[h],x=Ze(e,o+u,p);if(!(x>0))break;c+=x,d.push(o+u),u+=p}const _=n.length;Fi(n,e,o,o+u,d,2,s);const m=es(n,e,_,n.length,s),f=Math.abs(c);if(Math.abs((m-f)/Math.max(1e-7,f))>ts)return n.length=0,!1;l=h,o+=u}return!0}function is(a){const{coords:t,lengths:e}=a,{buffer:r}=ei(t,e);return r}function ss(a,t,e){let r=0;for(let i=0;i<a.lengths.length;i++){const s=a.lengths[i];for(let n=0;n<s;n++){const o=a.coords[2*(n+r)],l=a.coords[2*(n+r)+1];if(o<t||o>e||l<t||l>e)return!0}r+=s}return!1}function ns(a,t){if(a==null)return null;if(!ss(a,-128,rt+128))return a;tt.setPixelMargin(t),tt.reset(ur.Polygon);let e=0;for(let n=0;n<a.lengths.length;n++){const o=a.lengths[n];let l=a.coords[2*(0+e)],h=a.coords[2*(0+e)+1];tt.moveTo(l,h);for(let u=1;u<o;u++)l=a.coords[2*(u+e)],h=a.coords[2*(u+e)+1],tt.lineTo(l,h);tt.close(),e+=o}const r=tt.result(!1);if(!r)return null;const i=[],s=[];for(const n of r){let o=0;for(const l of n)s.push(l.x),s.push(l.y),o++;i.push(o)}return new pi(i,s)}function as(a,t){he.setPixelMargin(t);const e=he,r=-t,i=rt+t;let s=[],n=!1;if(!a.nextPath())return null;let o=!0;for(;o;){a.seekPathStart();const l=[];if(!a.pathSize)return null;e.reset(ur.LineString),a.nextPoint();let h=a.x,u=a.y;if(n)e.moveTo(h,u);else{if(h<r||h>i||u<r||u>i){n=!0;continue}l.push({x:h,y:u})}let c=!1;for(;a.nextPoint();)if(h=a.x,u=a.y,n)e.lineTo(h,u);else{if(h<r||h>i||u<r||u>i){c=!0;break}l.push({x:h,y:u})}if(c)n=!0;else{if(n){const d=e.resultWithStarts();if(d)for(const _ of d)s.push(_)}else s.push({line:l,start:0});o=a.nextPath(),n=!1}}return s=s.filter(l=>l.line.length>1),s.length===0?null:s}tt.setExtent(rt),he.setExtent(rt);const Bt=8,R=16,Ne=65535,wr=a=>class extends a{constructor(...t){super(...t),this.tessellationProperties={},this._tessellationOptions={halfWidth:0,pixelCoordRatio:1,offset:0},this.geometryType=P.LINE}writeGeometry(t,e,r,i){this._writeGeometry(t,e,r,i)}_initializeTessellator(t){const e=kt.load(this._materialKey),r=ct.load(this._materialKey),i=this._tessellationOptions,s=e.vvSizeFieldStops||e.vvSizeMinMaxValue||e.vvSizeScaleStops||e.vvSizeUnitValue,n=this.tessellationProperties._halfWidth<Hr&&!t&&!s;this.tessellationProperties.minMaxZoom=this._minMaxZoom,i.wrapDistance=Ne,i.textured=this._isDashed||this._hasPattern,i.offset=this.tessellationProperties.offset,i.halfWidth=this.tessellationProperties._halfWidth;const o=n?0:1,l=Et(r)?ls:os;this._lineTessellator=new ri(l(this.tessellationProperties,o,o),hs(this.tessellationProperties),n)}_write(t,e,r,i){const s=e.geometryType==="esriGeometryPoint";t.recordStart(e.getDisplayId(),this._materialKey,this.geometryType,s),this._writeGeometry(t,e,i,s),t.recordEnd()}_writeGeometry(t,e,r,i){const s=r||Dt.fromFeatureSetReaderCIM(e);if(!s)return;const n=this._getLines(s,i);n!=null&&this._writeVertices(t,e,n)}_getLines(t,e){return as(t,e?256:16)}_writeVertices(t,e,r){const i=e.getDisplayId(),s=t.vertexCount(),n=this.tessellationProperties,o=this._tessellationOptions;n.out=t,n.id=i,n.indexCount=0,n.vertexCount=0,n.offset=s,o.capType=this._capType,o.joinType=this._joinType;const l=ct.load(this._materialKey);this.tessellationProperties.key=Et(l)?l:kt.load(this._materialKey);for(const{line:h,start:u}of r)o.initialDistance=u%Ne,this._lineTessellator.tessellate(h,o)}},os=(a,t,e)=>(r,i,s,n,o,l,h,u,c,d,_)=>{const m=M(_,Math.ceil(R*a._halfWidth)),f=I(Math.round(R*h),Math.round(R*u),Math.round(R*c),Math.round(R*d)),p=I(R*o,R*l,0,a._bitset),x=a.out;return x.vertexBounds(r,i,t,e),x.vertexWrite(M(Bt*r,Bt*i)),x.vertexWrite(a.id),x.vertexWrite(a._fillColor),x.vertexWrite(f),x.vertexWrite(m),x.vertexWrite(a._tl),x.vertexWrite(a._br),x.vertexWrite(p),x.vertexWrite(M(Math.ceil(R*a._halfReferenceWidth),0)),x.vertexWrite(a.minMaxZoom),x.vertexEnd(),a.offset+a.vertexCount++},ls=(a,t,e)=>(r,i,s,n,o,l,h,u,c,d,_)=>{const m=M(R*a._halfWidth,R*a._halfReferenceWidth),f=I(R*h+128,R*u+128,R*c+128,R*d+128),p=a.out,x=a._bitset<<24|a.id;p.vertexBounds(r,i,t,e),p.vertexWrite(M(Bt*r,Bt*i)),p.vertexWrite(x),p.vertexWrite(a._fillColor);const y=hr(a.key);return y||(p.vertexWrite(0),p.vertexWrite(0)),p.vertexWrite(0),p.vertexWrite(m),p.vertexWrite(f),y||p.vertexWrite(a.minMaxZoom),p.vertexEnd(),a.offset+a.vertexCount++},hs=a=>(t,e,r)=>{const i=a.out;i.indexWrite(t),i.indexWrite(e),i.indexWrite(r),a.indexCount+=3};let ce=class lt extends wr(vt){constructor(t,e,r,i,s,n,o,l,h,u,c,d,_,m,f,p,x,y,v,w){super();const b=kt.load(t);e&&(b.sdf=e.sdf,b.pattern=!0,b.textureBinding=e.textureBinding),this._capType=i,this._joinType=s,this._miterLimitCosine=re(n),this.tessellationProperties._fillColor=o,this.tessellationProperties._tl=l,this.tessellationProperties._br=h,this._hasPattern=u,this._isDashed=c,this._zOrder=x,this._effects=y||null,this._minMaxZoom=M(Math.round(v*$),Math.round(w*$)),this._materialKey=b.data;const L=(_?q:0)|(m?qr:0)|(d?sr:0)|(f?Ot:0);this.tessellationProperties._bitset=L,this.tessellationProperties._halfWidth=.5*r,this.tessellationProperties._halfReferenceWidth=.5*p,this.tessellationProperties.offset=0,this._initializeTessellator(!1)}static fromCIMLine(t,e,r){const i=t.color,s=t.scaleFactor||1,n=!!t.dashTemplate;let o=t.cap;n&&o===We.ROUND&&(o=We.SQUARE);const l=t.join,h=g(t.width)*s,u=g(t.referenceWidth),c=g(t.miterLimit),d=i&&W(i)||0,[_,m]=Q(t.scaleInfo,r),f=!1;if(!e)return new lt(t.materialKey,e,h,o,l,c,d,0,0,!1,n,t.scaleDash??!1,t.colorLocked??!1,f,t.sampleAlphaOnly,u,t.zOrder,t.effects,_,m);const{rect:p,width:x,height:y}=e,v=p.x+E,w=p.y+E,b=v+x,L=w+y,z=M(v,w),T=M(b,L),Z=!1;return new lt(t.materialKey,e,h,o,l,c,d,z,T,!0,n,t.scaleDash??!1,t.colorLocked??!1,Z,t.sampleAlphaOnly,u,t.zOrder,t.effects,_,m)}static fromFillOutline(t){var r;const e=ct.load(t.materialKey);return Et(e)&&t.outline&&((r=t.outline)==null?void 0:r.style)==="esriSLSSolid"?lt.fromSimpleLine({hash:"",materialKey:t.materialKey,...t.outline},null,!0):null}static fromSimpleLine(t,e,r=!1){const{color:i}=t,s=t.style!=="esriSLSSolid"&&t.style!=="esriSLSNull",n=Qr(t.cap||"round"),o=Jr(t.join||"round");let l=i&&t.style!=="esriSLSNull"&&F(i)||0;t.style==="esriSLSNull"&&(l=0);const h=g(t.width),u=t.miterLimit;if(!e)return new lt(t.materialKey,e,h,n,o,u,l,0,0,!1,s,!0,!1,r,!1,h,0,null,D,G);const{rect:c,width:d,height:_}=e,m=c.x+E,f=c.y+E,p=m+d,x=f+_,y=M(m,f),v=M(p,x);return new lt(t.materialKey,e,h,n,o,u,l,y,v,!0,s,!0,!1,r,!1,h,0,null,D,G)}static fromPictureLineSymbol(t,e,r,i){return dt.getLogger("esri.views.2d.engine.webgl.WGLLineTemplate").error("PictureLineSymbol support does not exist!"),null}};const cs=100,Xe=1,br=a=>class extends a{constructor(...t){super(...t),this.forceLibtess=!1,this._bitset=0,this._lineTemplate=null,this.geometryType=P.FILL}_maybeAddLineTemplate(t){this._lineTemplate=ce.fromFillOutline(t)}_write(t,e,r,i){const s=e.geometryType==="esriGeometryPoint",n=ct.load(this._materialKey);t.recordStart(e.getDisplayId(),this._materialKey,this.geometryType,s),this._writeGeometry(t,e,n,i,s),Et(n)&&this._lineTemplate!=null&&this._lineTemplate.writeGeometry(t,e,i,s),t.recordEnd()}_writeGeometry(t,e,r,i,s){const n=this._getGeometry(e,i,s);if(n==null)return;const o=[];if(!(n.maxLength>cs)&&!this.forceLibtess&&rs(o,n))return void(o.length&&this._writeVertices(t,e,n.coords,n.lengths,r,o));const l=is(n);this._writeVertices(t,e,l,[l.length/2],r)}_writeVertex(t,e,r,i,s,n){const o=M(Xe*i,Xe*s);if(t.vertexBounds(i,s,0,0),t.vertexWrite(o),t.vertexWrite(e),r.symbologyType===Gt.DOT_DENSITY)t.vertexWriteF32(1/Math.abs(n.readGeometryArea()));else{t.vertexWrite(this.fillColor);const l=hr(r);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,r,i,s,n){const o=e.getDisplayId(),l=this._bitset<<24|o,h=i.reduce((_,m)=>_+m),u=Jt(s.geometryType,s.symbologyType).geometry/4,c=t.vertexCount();t.vertexEnsureSize(u*h);let d=0;if(n)for(const _ of n){const m=r[2*_],f=r[2*_+1];this._writeVertex(t,l,s,m,f,e),d++}else for(let _=0;_<r.length;_+=2){const m=Math.round(r[_]),f=Math.round(r[_+1]);this._writeVertex(t,l,s,m,f,e),d++}t.indexEnsureSize(d);for(let _=0;_<d;_++)t.indexWrite(_+c)}_getGeometry(t,e,r){const i=(e==null?void 0:e.asOptimized())||t.readGeometryForDisplay();return i?ns(i,r?256:8):null}},Ye=dt.getLogger("esri.views.2d.engine.webgl.WGLDynamicMeshTemplate");let Yt=class extends vt{constructor(t){super(),this._ongoingMaterialRequestMap=new Map,this._materialCache=new Map,this._dynamicPropertyMap=new Map,this._cimLayer=t}async analyze(t,e,r,i,s){if(s&&s.length===0)return null;const n=s&&s.length>0,o=e.readLegacyFeature(),l=e.getObjectId(),h=this._materialCache,u=this._cimLayer.materialHash;if(!u)return Ye.error("A Dynamic mesh template must have a material hash value or function!"),null;const c=typeof u=="function"?u(o,r,i,l):u,d=h.get(c);if(d!=null)return d;const _=this._ongoingMaterialRequestMap.get(c);if(_)return _;const m=this._cimLayer,f=di(m.cim,this._cimLayer.materialOverrides);f.mosaicHash=c;const{type:p,url:x}=m,y={cim:f,type:p,mosaicHash:c,url:x,size:null,dashTemplate:null,text:null,fontName:null,objectId:l,animatedSymbolProperties:null};switch(p){case"marker":y.size=Lt(m.size,o,r,i),y.animatedSymbolProperties=Lt(m.animatedSymbolProperties,o,r,i);break;case"line":y.dashTemplate=m.dashTemplate;break;case"text":y.text=Lt(m.text,o,r,i),y.fontName=Lt(m.fontName,o,r,i)}const v=t.getMosaicItem(y,s).then(w=>(n||(this._ongoingMaterialRequestMap.delete(c),h.set(c,w)),w)).catch(w=>(this._ongoingMaterialRequestMap.delete(c),Ye.error(".analyze()",w.message),null));return n||this._ongoingMaterialRequestMap.set(c,v),v}},us=class Sr extends br(Yt){constructor(t,e,r){var u;if(super(t),this._minMaxZoom=M(Math.round(e*$),Math.round(r*$)),S(t.color)){const c=(d,_,m)=>{const f=t.color(d,_,m);return f&&W(f)||0};this._dynamicPropertyMap.set("fillColor",c)}else{const c=t.color;this.fillColor=c&&W(c)||0}const i=((u=t.cim.placement)==null?void 0:u.type)==="CIMMarkerPlacementInsidePolygon"&&t.cim.placement.shiftOddRows?2:1,s=t.height;if(S(s)){const c=(d,_,m)=>s(d,_,m)*i;this._dynamicPropertyMap.set("_height",c)}else this._height=(s||0)*i;const n=t.offsetX;if(S(n)){const c=(d,_,m)=>g(n(d,_,m));this._dynamicPropertyMap.set("_offsetX",c)}else this._offsetX=g(n||0);const o=t.offsetY;if(S(o)){const c=(d,_,m)=>g(-o(d,_,m));this._dynamicPropertyMap.set("_offsetY",c)}else this._offsetY=g(-o||0);const l=t.scaleX;S(l)?this._dynamicPropertyMap.set("_scaleX",l):this._scaleX=l||1;const h=t.angle;if(S(h)){const c=(d,_,m)=>ee(h(d,_,m));this._dynamicPropertyMap.set("_angle",c)}else this._angle=ee(h)||0;if(t.effects!=null){const c=t.effects;S(c)?this._dynamicPropertyMap.set("_effects",c):this._effects=c}this._cimFillLayer=t,this._bitset=(t.colorLocked?q:0)|(t.applyRandomOffset?nr:0)|(t.sampleAlphaOnly?Ot:0)|(t.hasUnresolvedReplacementColor?ar:0),this._fillMaterialKey=t.materialKey}static fromCIMFill(t,e){const[r,i]=Q(t.scaleInfo,e);return new Sr(t,r,i)}bindFeature(t,e,r){const i=t.readLegacyFeature();this._dynamicPropertyMap.forEach((u,c)=>{this[c]=u(i,e,r)});const s=ct.load(this._fillMaterialKey),n=this._materialCache,o=(0,this._cimFillLayer.materialHash)(i,e,r),l=n.get(o);let h=null;if(l&&B(l.spriteMosaicItem)&&(h=l.spriteMosaicItem),h){const{rect:u,width:c,height:d}=h,_=u.x+E,m=u.y+E,f=_+c,p=m+d;let x=g(this._height);x<=0&&(x=p-m),x<H&&(x*=k,this._bitset|=Ct),x=Math.round(x);let y=g(this._height/d*c);y<=0&&(y=f-_),y<H&&(y*=k,this._bitset|=$t),y=Math.round(y);const v=this._scaleX,w=1;this.tl=M(_,m),this.br=M(f,p),this.aux21=M(y,x),this.aux22=M(this._offsetX,this._offsetY),this.aux3=I(v*k,w*k,this._angle,0),s.sdf=h.sdf,s.pattern=!0,s.textureBinding=h.textureBinding}else this.tl=0,this.br=0,this.aux21=0,this.aux22=0,this.aux3=0,s.sdf=!1,s.pattern=!1,s.textureBinding=0;this._materialKey=s.data}},ds=class Lr extends wr(Yt){constructor(t,e,r){super(t),this._minMaxZoom=M(Math.round(e*$),Math.round(r*$)),this._cimLineLayer=t;let i=0;S(t.width)||(i=.5*g(t.width));const s=(c,d,_)=>S(t.width)?.5*g(t.width(c,d,_)):i;this._dynamicPropertyMap.set("_halfWidth",s),S(t.cap)?this._dynamicPropertyMap.set("_capType",t.cap):this._capType=t.cap,S(t.join)?this._dynamicPropertyMap.set("_joinType",t.join):this._joinType=t.join;const n=t.color;if(S(n)){const c=(d,_,m)=>W(n(d,_,m));this._dynamicPropertyMap.set("_fillColor",c)}else this._fillColor=n&&W(n)||0;const o=t.miterLimit;if(S(o)){const c=(d,_,m)=>re(o(d,_,m));this._dynamicPropertyMap.set("_miterLimitCosine",c)}else this._miterLimitCosine=re(o);if(t.effects!=null){const c=t.effects;S(c)?this._dynamicPropertyMap.set("_effects",c):this._effects=c}this._scaleFactor=t.scaleFactor||1,this._isDashed=t.dashTemplate!=null;const l=t.colorLocked?q:0,h=t.scaleDash?sr:0,u=t.sampleAlphaOnly?Ot:0;this.tessellationProperties._bitset=l|h|u,this._materialKey=t.materialKey,this._initializeTessellator(!0)}static fromCIMLine(t,e){const[r,i]=Q(t.scaleInfo,e);return new Lr(t,r,i)}bindFeature(t,e,r){const i=t.readLegacyFeature();this._dynamicPropertyMap.forEach((u,c)=>{this[c]=u(i,e,r)}),this._halfWidth*=this._scaleFactor;const s=this._materialCache,n=(0,this._cimLineLayer.materialHash)(i,e,r),o=s.get(n);let l=null;if(o&&B(o.spriteMosaicItem)&&(l=o.spriteMosaicItem),l){this._hasPattern=!0;const{rect:u,width:c,height:d}=l,_=u.x+E,m=u.y+E,f=_+c,p=m+d;this.tessellationProperties._tl=M(_,m),this.tessellationProperties._br=M(f,p)}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=kt.load(this._materialKey);l&&(h.sdf=l.sdf,h.pattern=!0,h.textureBinding=l.textureBinding),this._materialKey=h.data}};const _s=de(),fs=Vt();let ms=class zr extends xr(Yt){constructor(t,e,r){super(t),this._cimMarkerLayer=t,this._minMaxZoom=M(Math.round(e*$),Math.round(r*$));const i=t.color;if(S(i)){const d=(_,m,f)=>W(i(_,m,f));this._dynamicPropertyMap.set("_fillColor",d)}else this._fillColor=W(i);const s=t.outlineColor;if(S(s)){const d=(_,m,f)=>W(s(_,m,f));this._dynamicPropertyMap.set("_outlineColor",d)}else this._outlineColor=W(s);const n=t.size;if(S(n)){const d=(_,m,f)=>g(n(_,m,f));this._dynamicPropertyMap.set("_size",d)}else this._size=g(n)||0;const o=t.scaleX;S(o)?this._dynamicPropertyMap.set("_scaleX",o):this._scaleX=o;const l=t.offsetX;if(S(l)){const d=(_,m,f)=>g(l(_,m,f));this._dynamicPropertyMap.set("xOffset",d)}else this.xOffset=g(l)||0;const h=t.offsetY;if(S(h)){const d=(_,m,f)=>g(h(_,m,f));this._dynamicPropertyMap.set("yOffset",d)}else this.yOffset=g(h)||0;const u=t.outlineWidth;if(S(u)){const d=(_,m,f)=>g(u(_,m,f));this._dynamicPropertyMap.set("_outlineWidth",d)}else this._outlineWidth=g(u)||0;const c=t.rotation;if(S(c)?this._dynamicPropertyMap.set("_angle",c):this._angle=c||0,t.effects!=null){const d=t.effects;S(d)?this._dynamicPropertyMap.set("_effects",d):this._effects=d}if(t.markerPlacement!=null){const d=t.markerPlacement;S(d)?this._dynamicPropertyMap.set("_markerPlacement",d):this._markerPlacement=d}this._scaleFactor=t.scaleFactor??1,this._bitSet=(t.alignment===O.MAP?tr:er)|(t.colorLocked?q:0)|(t.scaleSymbolsProportionally?rr:0),this._materialKey=t.materialKey}static fromCIMMarker(t,e){const[r,i]=Q(t.scaleInfo,e);return new zr(t,r,i)}bindFeature(t,e,r){const i=t.readLegacyFeature(),s=t.getObjectId();this._dynamicPropertyMap.forEach((Z,it)=>{this[it]=Z(i,e,r)});const n=this._cimMarkerLayer.materialHash,o=typeof n=="function"?n(i,e,r,s):n,l=this._materialCache.get(o);if(!l||!B(l.spriteMosaicItem)||!l.spriteMosaicItem)return void dt.getLogger("esri.views.2d.engine.webgl.WGLDynamicMarkerTemplate").error(new Mt("mapview-cim","Encountered an error when binding feature"));const h=l.spriteMosaicItem,u=this._cimMarkerLayer.sizeRatio,c=h.width/h.height*this._scaleX,d=fe.load(this._materialKey);d.sdf=h.sdf,d.pattern=!0,d.textureBinding=h.textureBinding,this._materialKey=d.data;const _=this._cimMarkerLayer.rotateClockwise?this._angle:-this._angle,m=this._size,f=m*c,p=this.xOffset,x=this.yOffset;this.xOffset*=this._scaleFactor,this.yOffset*=this._scaleFactor;const y=this._cimMarkerLayer.scaleSymbolsProportionally&&this._cimMarkerLayer.frameHeight?this._size/g(this._cimMarkerLayer.frameHeight):1,v=this._outlineWidth*y,w=g(this._cimMarkerLayer.referenceSize);let b=0,L=0;const z=this._cimMarkerLayer.anchorPoint;z&&(this._cimMarkerLayer.isAbsoluteAnchorPoint?this._size&&(b=g(z.x)/(this._size*c),L=g(z.y)/this._size):(b=z.x,L=z.y)),this._anchorX=b,this._anchorY=L,this._sizeOutlineWidth=I(Math.round(Math.min(Math.sqrt(128*f),255)),Math.round(Math.min(Math.sqrt(128*m),255)),Math.round(Math.min(Math.sqrt(128*v),255)),Math.round(Math.min(Math.sqrt(128*w),255))),this.angle=_;const T=Math.round(64*u);this._bitestAndDistRatio=M(this._bitSet,T),this._computeSize(f,m,u,v,this._scaleFactor,h,d.hasSizeVV(),!0),this._applyTransformation(fs,_s),this.xOffset=p,this.yOffset=x}};function Pr(a){if(a==null)return[];const t=new Array(a.length);for(let e=0;e<a.length;e++)t[e]=a.charCodeAt(e);return t}const He=5;function ps(a,t,e,r){return typeof a.text=="string"?a.text:typeof a.text=="function"?a.text(t,e,r)??"":""}let xs=class Tr extends mr(Yt){constructor(t,e,r){super(t),this._horizontalAlignment="center",this._verticalAlignment="middle",this._textToGlyphs=new Map,this._minMaxZoom=M(Math.round(e*$),Math.round(r*$));const i=t.scaleFactor||1;this._cimTextLayer=t;const s=t.color;if(S(s)){const f=(p,x,y)=>W(s(p,x,y));this._dynamicPropertyMap.set("_color",f)}else this._color=W(s);const n=t.outlineColor;if(S(n)){const f=(p,x,y)=>W(n(p,x,y));this._dynamicPropertyMap.set("_haloColor",f)}else this._haloColor=W(n);let o;S(t.size)||(o=Math.min(Math.round(g(t.size*t.sizeRatio)),127));const l=(f,p,x)=>S(t.size)?Math.min(Math.round(g(t.size(f,p,x)*t.sizeRatio)),127):o;if(this._dynamicPropertyMap.set("_size",l),S(t.outlineSize)){const f=(p,x,y)=>Math.min(Math.floor(He*g(t.outlineSize(p,x,y)*t.sizeRatio)),127);this._dynamicPropertyMap.set("_haloSize",f)}else this._haloSize=Math.min(Math.floor(He*g(t.outlineSize*t.sizeRatio)),127);let h;S(t.offsetX)||(h=Math.round(g(t.offsetX*t.sizeRatio)));const u=(f,p,x)=>S(t.offsetX)?Math.round(g(t.offsetX(f,p,x)*t.sizeRatio)):h;let c;this._dynamicPropertyMap.set("_xOffset",u),S(t.offsetY)||(c=Math.round(g(t.offsetY*t.sizeRatio)));const d=(f,p,x)=>S(t.offsetY)?Math.round(g(t.offsetY(f,p,x)*t.sizeRatio)):c;if(this._dynamicPropertyMap.set("_yOffset",d),S(t.angle)?this._dynamicPropertyMap.set("_angle",t.angle):this._angle=t.angle,S(t.horizontalAlignment)?this._dynamicPropertyMap.set("_horizontalAlignment",t.horizontalAlignment):this._horizontalAlignment=t.horizontalAlignment,S(t.verticalAlignment)?this._dynamicPropertyMap.set("_verticalAlignment",t.verticalAlignment):this._verticalAlignment=t.verticalAlignment,t.effects!=null){const f=t.effects;S(f)?this._dynamicPropertyMap.set("_effects",f):this._effects=f}if(t.markerPlacement!=null){const f=t.markerPlacement;S(f)?this._dynamicPropertyMap.set("_markerPlacement",f):this._textPlacement=f}S(t.text)?this._dynamicPropertyMap.set("_text",t.text):this._text=t.text,this._backgroundColor=t.backgroundColor&&W(t.backgroundColor),this._borderLineColor=t.borderLineColor&&W(t.borderLineColor),this._borderLineSize=t.borderLineWidth,this._scaleFactor=i;const _=Math.min(Math.round(g(t.referenceSize*t.sizeRatio)),127);this._referenceSize=Math.round(Math.sqrt(256*_)),this._materialKey=t.materialKey;const m=li.load(this._materialKey);m.sdf=!0,this._bitset=(t.alignment===O.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[r,i]=Q(t.scaleInfo,e);return new Tr(t,r,i)}async analyze(t,e,r,i){const s=e.readLegacyFeature(),n=ps(this._cimTextLayer,s,r,i),o=await super.analyze(t,e,r,i,Pr(n));return o!=null&&o.glyphMosaicItems&&this._textToGlyphs.set(n,o.glyphMosaicItems),o}bindFeature(t,e,r){const i=t.readLegacyFeature();if(this._dynamicPropertyMap.forEach((n,o)=>{this[o]=n(i,e,r)}),!this._text||this._text.length===0)return void(this._shapingInfo=null);this._size*=this._scaleFactor,this._scale=this._size/Je,this._xOffset*=this._scaleFactor,this._yOffset*=this._scaleFactor,this._xAlignD=or(this._horizontalAlignment??"center"),this._yAlignD=lr(this._verticalAlignment??"baseline");const s=this._textToGlyphs.get(this._text)??[];this.bindTextInfo(s,!1)}};class X extends br(vt){constructor(t,e,r,i,s,n,o,l,h,u,c,d,_,m,f,p){super(),this._effects=m||void 0;const x=ct.load(t);e&&(x.sdf=e.sdf,x.pattern=!0,x.textureBinding=e.textureBinding),this.fillColor=r,this.tl=i,this.br=s,this.aux21=M(n,o),this.aux22=M(l,h),this.aux3=I(u,c,d,0),this._bitset=_,this._minMaxZoom=M(Math.round(f*$),Math.round(p*$)),this._materialKey=x.data}static fromCIMFill(t,e,r){const i=t.color,s=i&&W(i)||0,n=t.materialKey,[o,l]=Q(t.scaleInfo,r);let h=(t.colorLocked?q:0)|(t.applyRandomOffset?nr:0)|(t.sampleAlphaOnly?Ot:0)|(t.hasUnresolvedReplacementColor?ar:0);if(!e)return new X(n,null,s,0,0,0,0,0,0,0,0,0,h,t.effects,o,l);const{rect:u,width:c,height:d}=e,_=t.scaleX||1,m=u.x+E,f=u.y+E,p=m+c,x=f+d,y=g(t.height);let v=_*y;t.cim.type==="CIMHatchFill"&&(v*=c/d);let w=y;w<=0&&(w=x-f),w<H&&(w*=k,h|=Ct),w=Math.round(w);let b=v;b<=0&&(b=p-m),b<H&&(b*=k,h|=$t),b=Math.round(b);const L=g(t.offsetX||0),z=g(-t.offsetY||0),T=M(m,f),Z=M(p,x);return new X(n,e,s,T,Z,b,w,L,z,k,k,ee(t.angle),h,t.effects,o,l)}static fromSimpleFill(t,e,r=!1){const{color:i}=t,s=i&&t.style!=="esriSFSNull"&&F(i)||0;let n=r?q:0;const o=t.materialKey;let l;if(e){const{rect:h,width:u,height:c,pixelRatio:d}=e,_=h.x+E,m=h.y+E,f=_+u,p=m+c,x=M(_,m),y=M(f,p);let v=u/d;v<H&&(v*=k,n|=$t),v=Math.round(v);let w=c/d;w<H&&(w*=k,n|=Ct),w=Math.round(w),l=new X(o,e,s,x,y,v,w,0,0,k,k,0,n,null,D,G)}else l=new X(o,null,s,0,0,0,0,0,0,0,0,0,n,null,D,G);return l._maybeAddLineTemplate(t),l}static fromPictureFill(t,e,r=!1){const i=ir,{rect:s,width:n,height:o}=e,l=s.x+E,h=s.y+E,u=l+n,c=h+o,d=M(l,h),_=M(u,c);let m=r?q:0,f=g(t.width);f<H&&(f*=k,m|=$t),f=Math.round(f);let p=g(t.height);p<H&&(p*=k,m|=Ct),p=Math.round(p);const x=g(t.xoffset),y=g(-t.yoffset),v=t.materialKey,w=new X(v,e,i,d,_,f,p,x,y,k*t.xscale,k*t.yscale,0,m,null,D,G);return w._maybeAddLineTemplate(t),w}}let ys=class{constructor(){this._resolver=null}isHeld(){return!!this._resolver}async acquire(){this._resolver?(await this._resolver.promise,await this.acquire()):this._resolver=Fr()}release(){const t=this._resolver;this._resolver=null,t==null||t.resolve()}};async function gs(a,t,e){try{await a.acquire(),await t(e),a.release()}catch(r){throw a.release(),r}}const qe=async(a,t,e)=>{const r=new fi(e,t);return new _i(await r.analyzeSymbolReference(a.data,!1),a.data,a.rendererKey,a.maxVVSize)};async function K(a,t,e,r){if(!a)return null;if(a.type==="cim")return qe(a,t,e);if(a.type==="web-style"){const{fetchCIMSymbolReference:i}=await _e(()=>import("./webStyleUtils-b7c16dd7.js"),["assets/webStyleUtils-b7c16dd7.js","assets/devEnvironmentUtils-4eab2a99.js","assets/index-b5c8f851.js","assets/index-86716609.css","assets/webStyleSymbolUtils-50c3c237.js"]),s={type:"cim",data:await i(a,null,r)??void 0,rendererKey:a.rendererKey,maxVVSize:a.maxVVSize};return qe(s,t,e)}return a}function It(a){if(!a)return null;const{avoidSDFRasterization:t,type:e,cim:r,url:i,materialHash:s,maxVVSize:n}=a,o={cim:r,type:e,mosaicHash:s,url:i,size:null,dashTemplate:null,path:null,text:null,fontName:null,animatedSymbolProperties:null,avoidSDFRasterization:t};switch(e){case"marker":n&&"size"in r&&(r.size=Math.max(n,r.size)),o.size=a.size,o.path=a.path,o.animatedSymbolProperties=a.animatedSymbolProperties;break;case"line":o.dashTemplate=a.dashTemplate;break;case"text":o.text=a.text,o.fontName=a.fontName}return o}const A=dt.getLogger("esri.views.2d.engine.webgl.mesh.templates.WGLTemplateStore"),Ue={sortKey:null,templates:new Array},Me={isOutline:!1,placement:null,symbologyType:Gt.DEFAULT,vvFlags:0},Ms={...Se,hash:JSON.stringify(Se),materialKey:me(P.MARKER,Me)},vs={...Le,hash:JSON.stringify(Le),materialKey:me(P.LINE,Me)},ws={...ze,hash:JSON.stringify(ze),materialKey:me(P.FILL,Me)};function N(a,t){const e=a.length;return a.push(null),t.then(r=>a[e]=r),a}function mt(a){return a!=null&&!!(1&a)}function bs(a){return a.name==="worker:port-closed"}class qs{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 ys,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,r=null){this._initErrorTemplates();const i=t.hash,s=this._symbolToTemplate.get(i);if(s!=null)return s;const n=new Array,o={sortKey:r,templates:n};e&&this._createMeshTemplates(n,e,!0),this._createMeshTemplates(n,t,!1);const l=this._createGroupId(t.type==="expanded-cim"&&Ss(t));return this._idToTemplateGroup.set(l,o),this._symbolToTemplate.set(i,l),l}getTemplateGroup(t){return this._idToTemplateGroup.get(t)??Ue}getDynamicTemplateGroup(t){return this._idToTemplateGroup.has(t)?(mt(t)||A.error("mapview-template-store",`Id ${t} does not refer to a dynamic template`),this._idToTemplateGroup.get(t)):Ue}getMosaicItem(t,e){const r=this._createTemplateId(),i=new Promise(s=>this._idToResolver.set(r,s));return this._fetchQueue.push({symbol:t,id:r,glyphIds:e}),i}finalize(t){return this._fetchQueue.length||this._lock.isHeld()?gs(this._lock,this._fetchAllQueuedResources.bind(this),t):Promise.resolve()}_initErrorTemplates(){this._errorTemplates||(this._errorTemplates={fill:this._createMeshTemplates([],ws,!1),marker:this._createMeshTemplates([],Ms,!1),line:this._createMeshTemplates([],vs,!1)})}_fetchAllQueuedResources(t){if(!this._fetchQueue.length)return Promise.resolve();const e=this._fetchQueue,r=this._cimAnalyses;return this._fetchQueue=[],this._cimAnalyses=[],Promise.all(r).then(()=>this._fetchResource(e,t).then(i=>{for(const{id:s,mosaicItem:n}of i)this._idToResolver.get(s)(n),this._idToResolver.delete(s)})).catch(i=>{Vr(i)?this._fetchQueue=this._fetchQueue.concat(e):bs(i)||A.error(new Mt("mapview-template-store","Unable to fetch requested texture resources",i))})}_createGroupId(t){return this._idCounter++<<1|(t?1:0)}_createTemplateId(){return this._templateIdCounter++}async _createSMS(t){const{spriteMosaicItem:e}=await this.getMosaicItem(t);return B(e,A)?_t.fromSimpleMarker(t,e):this._markerError}async _createPMS(t){const{spriteMosaicItem:e}=await this.getMosaicItem(t);return B(e,A)?_t.fromPictureMarker(t,e):this._markerError}async _createSFS(t,e){const{spriteMosaicItem:r}=await this.getMosaicItem(t);return B(r,A)?X.fromSimpleFill(t,r,e):this._fillError}async _createPFS(t,e){const{spriteMosaicItem:r}=await this.getMosaicItem(t);return B(r,A)?X.fromPictureFill(t,r,e):this._fillError}async _createSLS(t,e){const{spriteMosaicItem:r}=await this.getMosaicItem(t);return B(r,A)?ce.fromSimpleLine(t,r):this._lineError}async _createLMS(t){const{spriteMosaicItem:e}=await this.getMosaicItem(t);return B(e,A)?_t.fromLineSymbolMarker(t,e):this._markerError}async _createTS(t){const{glyphMosaicItems:e}=await this.getMosaicItem(t);return se.fromText(t,e??[])}async _createCIMText(t){const{glyphMosaicItems:e}=await this.getMosaicItem(It(t),Pr(t.text));return B(e,A)?se.fromCIMText(t,e,this._tileInfo):this._textError}async _createCIMFill(t){const{spriteMosaicItem:e}=await this.getMosaicItem(It(t));return B(e,A)?X.fromCIMFill(t,e,this._tileInfo):this._fillError}async _createCIMLine(t){const{spriteMosaicItem:e}=await this.getMosaicItem(It(t));return B(e,A)?ce.fromCIMLine(t,e,this._tileInfo):this._lineError}async _createCIMMarker(t){const{spriteMosaicItem:e}=await this.getMosaicItem(It(t));return B(e,A)?_t.fromCIMMarker(t,e,this._tileInfo):this._markerError}async _createCIM(t){const e=t.templateHash;let r=this._cimTemplateCache.get(e);if(r!=null)return r;switch(t.type){case"marker":r=await this._createCIMMarker(t);break;case"line":r=await this._createCIMLine(t);break;case"fill":r=await this._createCIMFill(t);break;case"text":r=await this._createCIMText(t)}return this._cimTemplateCache.set(e,r),r}async _createDynamicCIM(t){const e=t.templateHash;let r=this._cimTemplateCache.get(e);if(r!=null)return r;switch(t.type){case"marker":r=ms.fromCIMMarker(t,this._tileInfo);break;case"line":r=ds.fromCIMLine(t,this._tileInfo);break;case"fill":r=us.fromCIMFill(t,this._tileInfo);break;case"text":r=xs.fromCIMText(t,this._tileInfo)}return this._cimTemplateCache.set(e,r),r}_createPrimitiveMeshTemplates(t,e,r){switch(e.type){case"esriSMS":return N(t,this._createSMS(e));case"esriPMS":return N(t,this._createPMS(e));case"esriSFS":return N(t,this._createSFS(e,r));case"line-marker":return N(t,this._createLMS(e));case"esriPFS":return N(t,this._createPFS(e,r));case"esriSLS":return N(t,this._createSLS(e,!1));case"esriTS":return N(t,this._createTS(e));default:return A.error("Unable to create mesh template for unknown symbol type {: $ }{symbol.type}"),t}}_createMeshTemplates(t,e,r){if(e.type.includes("3d"))return A.error("3D symbols are not supported with MapView"),t;if(e.type==="expanded-cim"){for(const i of e.layers)typeof i.materialHash=="function"?N(t,this._createDynamicCIM(i)):N(t,this._createCIM(i));return t}if(e.type==="composite-symbol"){for(const i of e.layers)this._createPrimitiveMeshTemplates(t,i,r);return t}return e.type==="cim"||e.type==="label"||e.type==="web-style"?t:this._createPrimitiveMeshTemplates(t,e,r)}}const Ss=a=>{if(!a.layers)return!1;for(const t of a.layers)if(typeof t.materialHash=="function")return!0;return!1};class Us{constructor(t,e,r){this._geometryType=t,this._idField=e,this._templateStore=r}update(t,e){t.mesh.labels!=null&&(this._labelTemplates=this._createLabelTemplates(t.mesh.labels,e)),this._schema=t}_createLabelTemplates(t,e){const r=new Map;if(t.type==="simple"){for(const i of t.classes){const s=Rt.fromLabelClass(i,e);r.set(i.index,s)}return r}for(const i in t.classes){const s=t.classes[i];for(const n of s){const o=Rt.fromLabelClass(n,e);r.set(n.index,o)}}return r}get templates(){return this._templateStore}async analyze(t,e,r,i,s,n,o){if(Pe(o))return;let l;(r==null?void 0:r.type)==="dictionary"&&(l=await r.analyze(this._idField,t.copy(),e,s,n,o));let h=0;for(;t.next();){let u=null;if(u=l?l[h++]:i!=null&&jr(t.getDisplayId())&&t.readAttribute("cluster_count")!==1?i.match(this._idField,t,this._geometryType,s,n):r.match(this._idField,t,this._geometryType,s,n),t.setGroupId(u),mt(u)){const c=this._templateStore.getDynamicTemplateGroup(u).templates;for(const d of c)d&&d.analyze&&d.analyze(this._templateStore,t,s,n)}}return await Te(),this._templateStore.finalize(o)}async analyzeGraphics(t,e,r,i,s,n){if(Pe(n))return;const o=t.getCursor();for(r&&await r.analyze(this._idField,o.copy(),e,i,s,n);o.next();){let l=o.getGroupId();if(l!=null&&l!==-1||(l=r==null?void 0:r.match(this._idField,o,o.geometryType,i,s),o.setGroupId(l)),mt(l)){const h=this._templateStore.getDynamicTemplateGroup(l).templates;for(const u of h)u&&u.analyze&&u.analyze(this._templateStore,o,i,s)}o.setGroupId(l)}return await Te(),this._templateStore.finalize(n)}writeGraphic(t,e,r,i){const s=e.getGroupId(),n=e.getDisplayId(),o=this._templateStore.getTemplateGroup(s);if(t.featureStart(e.insertAfter,0),n!=null){if(mt(s))for(const l of o.templates)l&&l.bindFeature(e,null,null);if(o){for(const l of o.templates)l&&l.write(t,e,r,i);t.featureEnd()}}}writeCursor(t,e,r,i,s,n,o){const l=e.getGroupId(),h=e.getDisplayId(),u=this._templateStore.getTemplateGroup(l),c=u.templates,d=this._getSortKeyValue(e,u);if(t.featureStart(0,d),h!=null&&c){if(mt(l))for(const _ of c)_.bindFeature(e,r,i);for(const _ of c)_.write(t,e,s,o);if(c.length&&n!=null){const _=n&&this._findLabelRef(c);this._writeLabels(t,e,n,_,s,o)}t.featureEnd()}}_getSortKeyValue(t,e){const r=this._schema.mesh.sortKey;if(r==null)return 0;let i=0;return i=r.byRenderer===!0&&e.sortKey!=null?e.sortKey:r.fieldIndex!=null?t.getComputedNumericAtIndex(r.fieldIndex):r.field!=null?t.readAttribute(r.field):t.readAttribute(this._idField),i*=r.order==="asc"?1:-1,i==null||isNaN(i)?0:i}_findLabelRef(t){for(const e of t)if(e instanceof _t)return e;return null}_writeLabels(t,e,r,i,s,n){for(const o of r)if(o!=null&&o){const{glyphs:l,rtl:h,index:u}=o,c=this._labelTemplates.get(u);if(!c)continue;c.setZoomLevel(s),c.bindReferenceTemplate(i),c.bindTextInfo(l,h),c.write(t,e,null,n)}}}const ue=dt.getLogger("esri/views/2d/engine/webgl/util/Matcher");async function Ls(a,t,e,r){switch(a.type){case"simple":case"heatmap":return j.fromBasicRenderer(a,t,e,r);case"map":return we.fromUVRenderer(a,t,e,r);case"interval":return ve.fromCBRenderer(a,t,e,r);case"dictionary":return be.fromDictionaryRenderer(a,t,e,r);case"pie-chart":return Ft.fromPieChartRenderer(a,t,e,r);case"subtype":return Ft.fromSubtypes(a,t,e,r)}}class j{constructor(){this.type="feature",this._defaultResult=null}static async fromBasicRenderer(t,e,r,i){const s=new j;if(t.symbol){const n=await K(t.symbol,r,i),o=e.createTemplateGroup(n,null);s.setDefault(o)}return s}static async fromPieChartRenderer(t,e,r,i){const s=new j;if(t.markerSymbol){const n=await K(t.markerSymbol,r,i);let o;t.fillSymbol&&(o=await K(t.fillSymbol,r,i));const l=e.createTemplateGroup(n,o);s.setDefault(l)}return s}size(){return 1}getDefault(){return this._defaultResult}setDefault(t){this._defaultResult=t}match(t,e,r,i,s){return this.getDefault()}async analyze(t,e,r,i,s,n){return null}}class Ft extends j{constructor(t,e){super(),this._subMatchers=t,this._subtypeField=e}static async fromSubtypes(t,e,r,i){const s=new Map,n=[];for(const o in t.renderers){const l=parseInt(o,10),h=Ls(t.renderers[o],e,r,i).then(u=>s.set(l,u));n.push(h)}return await Promise.all(n),new Ft(s,t.subtypeField)}match(t,e,r,i,s){const n=e.readAttribute(this._subtypeField),o=this._subMatchers.get(n);return o?o.match(t,e,r,i,s):null}}class ve extends j{constructor(t,e,r,i){super(),this.type="interval",this._intervals=[],this._isMaxInclusive=e,this._fieldIndex=i,this._field=t,this._normalizationInfo=r}static async fromCBRenderer(t,e,r,i){const{isMaxInclusive:s,normalizationField:n,normalizationTotal:o,normalizationType:l}=t,h=t.field,u=new ve(h,s,{normalizationField:n,normalizationTotal:o,normalizationType:l},t.fieldIndex),c=await K(t.backgroundFillSymbol,r,i);await Promise.all(t.intervals.map(async _=>{const m=await K(_.symbol,r,i),f=e.createTemplateGroup(m,c),p={min:_.min,max:_.max};u.add(p,f)}));const d=await K(t.defaultSymbol,r,i);if(d){const _=e.createTemplateGroup(d,c);u.setDefault(_)}return u}add(t,e){this._intervals.push({interval:t,result:e}),this._intervals.sort((r,i)=>r.interval.min-i.interval.min)}size(){return super.size()+this._intervals.length}match(t,e,r,i,s){if(this._fieldIndex==null&&!this._field)return this.getDefault();const n=this._fieldIndex!=null?e.getComputedNumericAtIndex(this._fieldIndex):this._getValueFromField(e);if(n==null||isNaN(n)||n===1/0||n===-1/0)return this.getDefault();for(let o=0;o<this._intervals.length;o++){const{interval:l,result:h}=this._intervals[o],u=n>=l.min,c=this._isMaxInclusive?n<=l.max:n<l.max;if(u&&c)return h}return this.getDefault()}_needsNormalization(){const t=this._normalizationInfo;return t&&(t.normalizationField||t.normalizationTotal||t.normalizationType)}_getValueFromField(t){const e=t.readAttribute(this._field);if(!this._needsNormalization()||e==null)return e;const{normalizationField:r,normalizationTotal:i,normalizationType:s}=this._normalizationInfo,n=t.readAttribute(r)??1;if(s)switch(s){case"esriNormalizeByField":return n?e/n:void 0;case"esriNormalizeByLog":return Math.log(e)*Math.LOG10E;case"esriNormalizeByPercentOfTotal":return e/i*100;default:return void ue.error(`Found unknown normalization type: ${s}`)}else ue.error("Normalization is required, but no type was set!")}}class we extends j{constructor(t,e,r){super(),this.type="map",this._nullResult=null,this._resultsMap=new Map,this._fields=[],this._fieldsIndex=r,this._fields=t,this._seperator=e||""}static async fromUVRenderer(t,e,r,i){const s=t.fieldDelimiter,n=[t.field];t.field2&&n.push(t.field2),t.field3&&n.push(t.field3);const o=await K(t.backgroundFillSymbol,r,i),l=new we(n,s,t.fieldIndex);await Promise.all(t.map.map(async(u,c)=>{const d=await K(u.symbol,r,i),_=c+1,m=e.createTemplateGroup(d,o,_);u.value==="<Null>"?l.setNullResult(m):l.add(u.value,m)}));const h=await K(t.defaultSymbol,r,i);if(h){const u=Number.MAX_SAFE_INTEGER,c=e.createTemplateGroup(h,o,u);l.setDefault(c)}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,r,i,s){if(this._fieldsIndex==null&&!this._fields)return this.getDefault();const n=this._fieldsIndex!=null?e.getComputedStringAtIndex(this._fieldsIndex):this._getValueFromFields(e);if(this._nullResult!==null&&(n==null||n===""||n==="<Null>"))return this._nullResult;if(n==null)return this.getDefault();const o=n.toString();return this._resultsMap.has(o)?this._resultsMap.get(o):this.getDefault()}_getValueFromFields(t){const e=[];for(const r of this._fields){const i=t.readAttribute(r);i==null||i===""?e.push("<Null>"):e.push(i)}return e.join(this._seperator)}}async function zs(a,t){const e=a||1;if(typeof e=="number")return(i,s,n)=>e;const r=await Gr(e,t.spatialReference,t.fields);return(i,s,n)=>mi(r,i,{$view:n},t.geometryType,s)||1}let jt;async function Ps(){return jt||(jt=_e(()=>import("./AttributeStoreView-b12ba31a.js").then(a=>a.c),["assets/AttributeStoreView-b12ba31a.js","assets/index-b5c8f851.js","assets/index-86716609.css","assets/definitions-1467ba4a.js","assets/TiledDisplayObject-a2315f25.js","assets/Container-f991c035.js","assets/enums-bdecffa2.js","assets/Texture-507d5ea8.js","assets/color-0916c686.js","assets/enums-f1a6a48a.js","assets/VertexElementDescriptor-2925c6af.js","assets/WGLContainer-21aabd6b.js","assets/FramebufferObject-4be671ef.js","assets/ProgramTemplate-a9187eb2.js","assets/GeometryUtils-7a7937c3.js","assets/StyleDefinition-29c49b98.js","assets/config-1337d16e.js","assets/earcut-d423749e.js","assets/featureConversionUtils-6aca8295.js","assets/OptimizedGeometry-d94e541f.js","assets/OptimizedFeatureSet-1d1ac4b9.js","assets/visualVariablesUtils-f4ae79f2.js","assets/ExpandedCIM-0020ab0e.js","assets/BidiEngine-9a40f2f4.js","assets/GeometryUtils-984e8446.js","assets/utils-ebbcf3da.js","assets/Rect-ea14f53a.js","assets/quantizationUtils-50e37a76.js","assets/floatRGBA-ba8d5dad.js","assets/util-a6af6461.js"])),jt}class be extends j{constructor(t,e,r,i,s,n){super(),this.type="dictionary",this._groupIdCache=new Or(100),this._loader=t,this._fieldMap=t.fieldMap,this._symbolFields=t.getSymbolFields(),this._templates=e,this._info=r,this._scaleFn=i,this._schemaUtilsModule=s,this._symbolOptions=n}static async fromDictionaryRenderer(t,e,r,i){const[{DictionaryLoader:s},n]=await Promise.all([_e(()=>import("./index-b5c8f851.js").then(h=>h.mJ),["assets/index-b5c8f851.js","assets/index-86716609.css"]),Ps()]),o=new s(t.url,t.config,t.fieldMap);await o.fetchResources({spatialReference:r.spatialReference,fields:r.fields});const l=await zs(t.scaleExpression,r);return new be(o,e,r,l,n,t.symbolOptions)}async _analyzeFeature(t,e,r,i,s){const n=t.readLegacyFeature(),o=this._scaleFn(n,r,i),l=this._attributeHash(n)+"-"+o,h=this._groupIdCache.get(l);if(h)return h;const u={...i,spatialReference:this._info.spatialReference,abortOptions:s,fields:this._info.fields},c=await this._loader.getSymbolAsync(n,u),d=this._schemaUtilsModule.createSymbolSchema(c,this._symbolOptions),_=K(d,this._info,e,s).then(m=>{if((m==null?void 0:m.type)!=="expanded-cim")return ue.error(new Mt("mapview-bad-type",`Found unexpected type ${m==null?void 0:m.type} in dictionary response`)),null;m.hash+="-"+o;for(const f of m.layers)f.scaleFactor=o,f.templateHash+="-"+o;return this._templates.createTemplateGroup(m,null)});return this._groupIdCache.put(l,_,1),_}async analyze(t,e,r,i,s,n){const o=e.getCursor(),l=[];for(;o.next();)l.push(this._analyzeFeature(o,r,i,s,n));return Promise.all(l).then(h=>h.filter(Dr))}match(t,e,r,i,s){return null}_attributeHash(t){var r;let e="";for(const i of this._symbolFields){const s=(r=this._fieldMap)==null?void 0:r[i];s&&(e+=t.attributes[s]+"-")}return e}}export{Ks as E,Us as a,B as b,zt as e,K as i,Pr as n,Ls as o,qs as x};