import{al as gi,b1 as ss,aY as R,au as z,aN as O,aR as Q,aQ as ut,aO as $,aq as V,aG as Zt,b7 as Rs,b8 as yi,b9 as We,ba as Pi,bb as xi,bc as bi,bd as Mi,k as Si,be as Ci,h as wi,bf as ki,A as Kt,aX as vi,B as Ue,bg as oe,bh as Es,bi as qe,bj as fs,z as _e,bk as Ii,bl as ze,bm as ms,s as ce,bn as Li,a as q,t as at,bo as qt,b3 as Ti,av as Ni,g as Ai,bp as de,bq as $s,br as E,bs as ue}from"./index.6c049565.js";import{C as zi}from"./BidiEngine.d8bba3fc.js";import{c as X,P as ve,R as I,k as B,f as ie,A as ge,X as st,o as ct,g as Oe,Z as Bt,K as ye,j as Fs,h as Gs,i as rt,l as nt,m as Oi,p as Ri,q as Ei,u as $i,t as Fi,v as ps,D as Gi,E as Hi,F as _s,G as Hs,H as Je,a as Re,n as Ee}from"./enums.0295eb81.js";import{t as ae,e as Pe,f as Di}from"./MaterialKey.bbaab8f1.js";import{e as ot,b as xe,S as Xi}from"./Utils.e8554a0e.js";import{t as Yi}from"./Rect.95b0fd2e.js";import{q as Vi,C as Bi,B as Wi,v as Ui}from"./quantizationUtils.4f3ed95a.js";import{n as be}from"./GeometryUtils.4f19e772.js";import{o as qi}from"./floatRGBA.c5518572.js";function Ji(r){return typeof r=="function"}function Ds(r,t,e,s){return Ji(r)?r(t,e,s):r}const ji=` /-, `;function ds(r){let t=r.length;for(;t--;)if(!ji.includes(r.charAt(t)))return!1;return!0}function Xs(r,t){const e=[];let s=0,i=-1;do if(i=r.indexOf("[",s),i>=s){if(i>s){const n=r.substr(s,i-s);e.push([n,null,ds(n)])}if(s=i+1,i=r.indexOf("]",s),i>=s){if(i>s){const n=t[r.substr(s,i-s)];n&&e.push([null,n,!1])}s=i+1}}while(i!==-1);if(sYs(i,s,e)}function Vs(r,t){switch(typeof r!="string"&&(r=String(r)),t){case"LowerCase":return r.toLowerCase();case"Allcaps":return r.toUpperCase();default:return r}}function ga(r,t,e,s,i,n,a=!0){const o=t/i,h=e/n,l=Math.ceil(o/2),c=Math.ceil(h/2);for(let u=0;u=-1&&N<=1&&(_=2*N*N*N-3*N*N+1,_>0&&(w=4*(b+k*t),x+=_*r[w+3],d+=_,r[w+3]<255&&(_=_*r[w+3]/250),g+=_*r[w],y+=_*r[w+1],P+=_*r[w+2],p+=_))}}s[m]=g/p,s[m+1]=y/p,s[m+2]=P/p,s[m+3]=x/d}}function Y(r){return r?{r:r[0],g:r[1],b:r[2],a:r[3]/255}:{r:0,g:0,b:0,a:0}}function Qi(r){return r.type==="CIMMarkerPlacementAlongLineRandomSize"||r.type==="CIMMarkerPlacementAlongLineSameSize"||r.type==="CIMMarkerPlacementAlongLineVariableSize"||r.type==="CIMMarkerPlacementAtExtremities"||r.type==="CIMMarkerPlacementAtMeasuredUnits"||r.type==="CIMMarkerPlacementAtRatioPositions"||r.type==="CIMMarkerPlacementOnLine"||r.type==="CIMMarkerPlacementOnVertices"}const C=(r,t=0)=>isNaN(r)||r==null?t:r,Zi=r=>{if(!r)return!1;for(const t of r)switch(t.type){case"CIMGeometricEffectBuffer":case"CIMGeometricEffectOffset":return!0}return!1};function tr(){return gi(()=>import("./geometryEngineJSON.3d6e7890.js"),["assets/geometryEngineJSON.3d6e7890.js","assets/geometryEngineBase.82b25ca5.js","assets/geometryEngineJSON.f9e9a36f.js","assets/json.879c9adc.js"])}function er(r){if(!r)return"normal";switch(r.toLowerCase()){case"italic":return"italic";case"oblique":return"oblique";default:return"normal"}}function sr(r){if(!r)return"normal";switch(r.toLowerCase()){case"bold":return"bold";case"bolder":return"bolder";case"lighter":return"lighter";default:return"normal"}}function Bs(r){let t="",e="";if(r){const s=r.toLowerCase();s.includes("italic")?t="italic":s.includes("oblique")&&(t="oblique"),s.includes("bold")?e="bold":s.includes("light")&&(e="lighter")}return{style:t,weight:e}}function Ws(r){return r.underline?"underline":r.strikethrough?"line-through":"none"}function Dt(r){if(!r)return null;switch(r.type){case"CIMPolygonSymbol":if(r.symbolLayers)for(const t of r.symbolLayers){const e=Dt(t);if(e!=null)return e}break;case"CIMTextSymbol":return Dt(r.symbol);case"CIMSolidFill":return r.color}}function Xt(r){if(r)switch(r.type){case"CIMPolygonSymbol":case"CIMLineSymbol":if(r.symbolLayers)for(const t of r.symbolLayers){const e=Xt(t);if(e!==void 0)return e}break;case"CIMTextSymbol":return Xt(r.symbol);case"CIMSolidStroke":case"CIMSolidFill":return r.color}}function le(r){if(r)switch(r.type){case"CIMPolygonSymbol":case"CIMLineSymbol":if(r.symbolLayers)for(const t of r.symbolLayers){const e=le(t);if(e!==void 0)return e}break;case"CIMTextSymbol":return le(r.symbol);case"CIMSolidStroke":case"CIMGradientStroke":case"CIMPictureStroke":return r.width}}function Us(r){switch(r){case"Left":default:return"left";case"Right":return"right";case"Center":case"Justify":return"center"}}function qs(r){switch(r){case"Top":default:return"top";case"Center":return"middle";case"Baseline":return"baseline";case"Bottom":return"bottom"}}function ir(r){return(r?Object.keys(r):[]).map(t=>({name:t,alias:t,type:typeof r[t]=="string"?"esriFieldTypeString":"esriFieldTypeDouble"}))}const Wt=r=>r.includes("data:image/svg+xml");function is(r){if(!r)return"arial-unicode-ms";const t=r.toLowerCase().split(" ").join("-");switch(t){case"serif":return"noto-serif";case"sans-serif":return"arial-unicode-ms";case"monospace":return"ubuntu-mono";case"fantasy":return"cabin-sketch";case"cursive":return"redressed";default:return t}}function ya(r){const t=rr(r)+nr(r);return is(r.family)+(t.length>0?t:"-regular")}function rr(r){if(!r.weight)return"";switch(r.weight.toLowerCase()){case"bold":case"bolder":return"-bold"}return""}function nr(r){if(!r.style)return"";switch(r.style.toLowerCase()){case"italic":case"oblique":return"-italic"}return""}const $e=new zi;function rs(r){if(!$e.hasBidiChar(r))return[r,!1];let t;return t=$e.checkContextual(r)==="rtl"?"IDNNN":"ICNNN",[$e.bidiTransform(r,t,"VLYSN"),!0]}class te{constructor(){this.setIdentity()}getAngle(){return(this.rz==null||this.rz===0&&this.rzCos!==1&&this.rzSin!==0)&&(this.rz=Math.atan2(this.rzSin,this.rzCos)),this.rz}setIdentity(){this.tx=0,this.ty=0,this.tz=0,this.s=1,this.rx=0,this.ry=0,this.rz=0,this.rzCos=1,this.rzSin=0}setTranslate(t,e){this.tx=t,this.ty=e}setTranslateZ(t){this.tz=t}setRotateCS(t,e){this.rz=void 0,this.rzCos=t,this.rzSin=e}setRotate(t){this.rz=t,this.rzCos=void 0,this.rzSin=void 0}setRotateY(t){this.ry=t}setScale(t){this.s=t}setMeasure(t){this.m=t}}class je{constructor(t){this._geometry=t}next(){const t=this._geometry;return this._geometry=null,t}}class ar{applyColorSubstituition(t,e){if(!e)return t;this._rasterizationCanvas||(this._rasterizationCanvas=document.createElement("canvas"));const{width:s,height:i}=t,n=this._rasterizationCanvas,a=n.getContext("2d");t!==n&&(n.width=s,n.height=i,a.drawImage(t,0,0,s,i));const o=a.getImageData(0,0,s,i).data;if(e){for(const l of e)if(l&&l.oldColor&&l.oldColor.length===4&&l.newColor&&l.newColor.length===4){const[c,u,f,m]=l.oldColor,[_,p,d,g]=l.newColor;if(c===_&&u===p&&f===d&&m===g)continue;for(let y=0;y0;--t)r[t][0]-=r[t-1][0],r[t][1]-=r[t-1][1]}function ys(r){if(r)for(const t of r)Ks(t)}function Qs(r){if(r){const t=r.length;for(let e=1;e1&&_>0&&i>0&&(e*f+s*m)/_/i<=this._maxCosAngle&&Jt(l,1),c===1&&(n=f,a=m,o=_),_>0&&(l=u,e=f,s=m,i=_)}this._isClosed&&i>0&&o>0&&(e*n+s*a)/o/i<=this._maxCosAngle&&Jt(t[0],1)}}}const Qt=.03;class jt{constructor(){this._path=[]}path(){return this._path}addPath(t,e){e||t.reverse(),Array.prototype.push.apply(this._path,t),e||t.reverse()}static mergePath(t,e){e&&Array.prototype.push.apply(t,e)}startPath(t){this._path.push(t)}lineTo(t){this._path.push(t)}close(){const t=this._path;t.length>1&&(t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]||t.push([t[0][0],t[0][1]]))}}class tt{constructor(t=0,e=!1){}normalize(t){const e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);e!==0&&(t[0]/=e,t[1]/=e)}calculateLength(t,e){const s=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(s*s+i*i)}calculateSegLength(t,e){return this.calculateLength(t[e],t[e+1])}calculatePathLength(t){let e=0;const s=t?t.length:0;for(let i=0;i0?[i/a,n/a]:[1,0]}getSegAngleCS(t,e,s){return this.getAngleCS(t[e],t[e+1],s)}cut(t,e,s,i){return[s<=0?t[e]:this.getSegCoord2D(t,e,s),i>=1?t[e+1]:this.getSegCoord2D(t,e,i)]}addSegment(t,e,s){s&&t.push(e[0]),t.push(e[1])}getSubCurve(t,e,s){const i=[];return this.appendSubCurve(i,t,e,s)?i:null}appendSubCurve(t,e,s,i){const n=e?e.length-1:0;let a=0,o=!0,h=0;for(;hs){const c=(s-a)/l;let u=1,f=!1;a+l>=i&&(u=(i-a)/l,f=!0);const m=this.cut(e,h,c,u);if(m&&this.addSegment(t,m,o),f)break;o=!1}}else{if(a+l>i){const c=this.cut(e,h,0,(i-a)/l);c&&this.addSegment(t,c,o);break}this.addSegment(t,[e[h],e[h+1]],o)}a+=l,++h}else++h}return!0}getCIMPointAlong(t,e){const s=t?t.length-1:0;let i=0,n=-1;for(;ne){const o=(e-i)/a;return this.getCoord2D(t[n],t[n+1],o)}i+=a}}return null}isEmpty(t,e){if(!t||t.length<=1)return!0;const s=t?t.length-1:0;let i=-1;for(;i=0==e<=0){if(g<1){const y=[_[0]-p[0],_[1]-p[1]];this.normalize(y);const P=Math.sqrt((1+g)/2);if(P>1/i){const x=-Math.abs(e)/P;c.push([u[0]-y[0]*x,u[1]-y[1]*x])}}}else switch(s){case X.Mitered:{const y=Math.sqrt((1+g)/2);if(y>0&&1/y0){const P=1/y;let x=P;for(let M=1;M0){const e=[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]],s=this._curveHelper.offset(e,this._size,X.Rounded,4,this._offsetFlattenError);if(s)return{rings:[s]}}else{if(!(this._size<0))return t;if(Math.min(t.xmax-t.xmin,t.ymax-t.ymin)+2*this._size>0)return{xmin:t.xmin-this._size,xmax:t.xmax+this._size,ymin:t.ymin-this._size,ymax:t.ymax+this._size}}if(z(t)){if(this._size===0)return t;const e=[];for(const s of t.rings){const i=this._curveHelper.offset(s,this._size,X.Rounded,4,this._offsetFlattenError);i&&e.push(i)}if(e.length)return{rings:e}}if(O(t)&&this._size>0){const e=[];for(const s of t.paths)if(s&&s.length>1){const i=this._curveHelper.offset(s,this._size,X.Rounded,4,this._offsetFlattenError),n=this._curveHelper.offset(s,-this._size,X.Rounded,4,this._offsetFlattenError);if(i&&n){for(let a=n.length-1;a>=0;a--)i.push(n[a]);i.push([i[0][0],i[0][1]]),e.push(i)}}if(e.length)return{rings:e}}ut(t)&&this._size,t=this._inputGeometries.next()}return null}}class Mt{static local(){return Mt.instance===null&&(Mt.instance=new Mt),Mt.instance}execute(t,e,s,i){return new gr(t,e,s)}}Mt.instance=null;class gr{constructor(t,e,s){var i;this._defaultPointSize=20,this._inputGeometries=t,this._geomUnitsPerPoint=s,this._rule=(i=e.rule)!=null?i:I.FullGeometry,this._defaultSize=this._defaultPointSize*s}next(){let t;for(;t=this._inputGeometries.next();){let e;if(ut(t)?e=this._processGeom([[[t.x,t.y]]]):Q(t)?e=this._processGeom([t.points]):O(t)?e=this._processGeom(t.paths):z(t)&&(e=this._processGeom(t.rings)),e&&e.length)return{paths:e}}return null}_clone(t){return[t[0],t[1]]}_mid(t,e){return[(t[0]+e[0])/2,(t[1]+e[1])/2]}_mix(t,e,s,i){return[t[0]*e+s[0]*i,t[1]*e+s[1]*i]}_add(t,e){return[t[0]+e[0],t[1]+e[1]]}_add2(t,e,s){return[t[0]+e,t[1]+s]}_sub(t,e){return[t[0]-e[0],t[1]-e[1]]}_dist(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}_norm(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}_normalize(t,e=1){const s=e/this._norm(t);t[0]*=s,t[1]*=s}_leftPerpendicular(t){const e=-t[1],s=t[0];t[0]=e,t[1]=s}_leftPerp(t){return[-t[1],t[0]]}_rightPerpendicular(t){const e=t[1],s=-t[0];t[0]=e,t[1]=s}_rightPerp(t){return[t[1],-t[0]]}_dotProduct(t,e){return t[0]*e[0]+t[1]*e[1]}_crossProduct(t,e){return t[0]*e[1]-t[1]*e[0]}_rotateDirect(t,e,s){const i=t[0]*e-t[1]*s,n=t[0]*s+t[1]*e;t[0]=i,t[1]=n}_makeCtrlPt(t){const e=[t[0],t[1]];return Jt(e,1),e}_addAngledTicks(t,e,s,i){const n=this._sub(s,e);this._normalize(n);const a=this._crossProduct(n,this._sub(i,e));let o;o=a>0?this._rightPerp(n):this._leftPerp(n);const h=Math.abs(a)/2,l=[];l.push([e[0]+(o[0]-n[0])*h,e[1]+(o[1]-n[1])*h]),l.push(e),l.push(s),l.push([s[0]+(o[0]+n[0])*h,s[1]+(o[1]+n[1])*h]),t.push(l)}_addBezier2(t,e,s,i,n){if(n--==0)return void t.push(i);const a=this._mid(e,s),o=this._mid(s,i),h=this._mid(a,o);this._addBezier2(t,e,a,h,n),this._addBezier2(t,h,o,i,n)}_addBezier3(t,e,s,i,n,a){if(a--==0)return void t.push(n);const o=this._mid(e,s),h=this._mid(s,i),l=this._mid(i,n),c=this._mid(o,h),u=this._mid(h,l),f=this._mid(c,u);this._addBezier3(t,e,o,c,f,a),this._addBezier3(t,f,u,l,n,a)}_add90DegArc(t,e,s,i,n){const a=n!=null?n:this._crossProduct(this._sub(s,e),this._sub(i,e))>0,o=this._mid(e,s),h=this._sub(o,e);a?this._leftPerpendicular(h):this._rightPerpendicular(h),o[0]+=h[0],o[1]+=h[1],this._addBezier3(t,e,this._mix(e,.33333,o,.66667),this._mix(s,.33333,o,.66667),s,4)}_addArrow(t,e,s){const i=e[0],n=e[1],a=e[e.length-1],o=this._sub(i,n);this._normalize(o);const h=this._crossProduct(o,this._sub(a,n)),l=.5*h,c=this._leftPerp(o),u=[a[0]-c[0]*h,a[1]-c[1]*h],f=e.length-1,m=[];m.push(s?[-c[0],-c[1]]:c);let _=[-o[0],-o[1]];for(let p=1;p0;p--)t.push([e[p][0]+m[p][0]*l,e[p][1]+m[p][1]*l]);t.push([u[0]+m[0][0]*l,u[1]+m[0][1]*l]),t.push([u[0]+m[0][0]*h,u[1]+m[0][1]*h]),t.push(i),t.push([u[0]-m[0][0]*h,u[1]-m[0][1]*h]),t.push([u[0]-m[0][0]*l,u[1]-m[0][1]*l]);for(let p=1;p=2?t[1]:this._add2(t[0],e*this._defaultSize,s*this._defaultSize)}_cp3(t,e,s,i){if(t.length>=3)return t[2];const n=this._mix(t[0],1-s,e,s),a=this._sub(e,t[0]);return this._normalize(a),this._rightPerpendicular(a),[n[0]+a[0]*i*this._defaultSize,n[1]+a[1]*i*this._defaultSize]}_arrowPath(t){if(t.length>2)return t;const e=t[0],s=this._cp2(t,-4,0),i=this._sub(e,s);this._normalize(i);const n=this._rightPerp(i);return[e,s,[e[0]+(n[0]-i[0])*this._defaultSize,e[1]+(n[1]-i[1])*this._defaultSize]]}_arrowLastSeg(t){const e=t[0],s=this._cp2(t,-4,0);let i;if(t.length>=3)i=t[t.length-1];else{const n=this._sub(e,s);this._normalize(n);const a=this._rightPerp(n);i=[e[0]+(a[0]-n[0])*this._defaultSize,e[1]+(a[1]-n[1])*this._defaultSize]}return[s,i]}_processGeom(t){if(!t)return null;const e=[];for(const s of t){if(!s||s.length===0)continue;const i=s.length;let n=s[0];switch(this._rule){case I.PerpendicularFromFirstSegment:{const a=this._cp2(s,0,-1),o=this._cp3(s,a,.5,4),h=[];h.push(o),h.push(this._mid(n,a)),e.push(h);break}case I.ReversedFirstSegment:{const a=this._cp2(s,0,-1);e.push([a,n]);break}case I.PerpendicularToSecondSegment:{const a=this._cp2(s,-4,1),o=this._cp3(s,a,.882353,-1.94),h=[];h.push(this._mid(a,o)),h.push(n),e.push(h);break}case I.SecondSegmentWithTicks:{const a=this._cp2(s,-4,1),o=this._cp3(s,a,.882353,-1.94),h=this._sub(o,a);let l;l=this._crossProduct(h,this._sub(n,a))>0?this._rightPerp(l):this._leftPerp(h);const c=[];c.push([a[0]+(l[0]-h[0])/3,a[1]+(l[1]-h[1])/3]),c.push(a),c.push(o),c.push([o[0]+(l[0]+h[0])/3,o[1]+(l[1]+h[1])/3]),e.push(c);break}case I.DoublePerpendicular:{const a=this._cp2(s,0,-1),o=this._cp3(s,a,.5,3),h=this._mid(n,a),l=this._sub(h,o);this._normalize(l);const c=this._crossProduct(l,this._sub(n,o));this._leftPerpendicular(l);const u=[];u.push(n),u.push([o[0]+l[0]*c,o[1]+l[1]*c]),e.push(u);const f=[];f.push([o[0]-l[0]*c,o[1]-l[1]*c]),f.push(a),e.push(f);break}case I.OppositeToFirstSegment:{const a=this._cp2(s,0,-1),o=this._cp3(s,a,.5,3),h=this._mid(n,a),l=this._sub(h,o);this._normalize(l);const c=this._crossProduct(l,this._sub(n,o));this._leftPerpendicular(l);const u=[];u.push([o[0]+l[0]*c,o[1]+l[1]*c]),u.push([o[0]-l[0]*c,o[1]-l[1]*c]),e.push(u);break}case I.TriplePerpendicular:{const a=this._cp2(s,0,-1),o=this._cp3(s,a,.5,4),h=this._mid(n,a),l=this._sub(h,o);this._normalize(l);const c=this._crossProduct(l,this._sub(n,o));this._leftPerpendicular(l);const u=[];u.push([o[0]+l[0]*c*.8,o[1]+l[1]*c*.8]),u.push([h[0]+.8*(n[0]-h[0]),h[1]+.8*(n[1]-h[1])]),e.push(u),e.push([o,h]);const f=[];f.push([o[0]-l[0]*c*.8,o[1]-l[1]*c*.8]),f.push([h[0]+.8*(a[0]-h[0]),h[1]+.8*(a[1]-h[1])]),e.push(f);break}case I.HalfCircleFirstSegment:{const a=this._cp2(s,0,-1),o=this._cp3(s,a,.5,4),h=this._mid(n,a);let l=this._sub(a,n);const c=Math.cos(Math.PI/18),u=Math.sin(Math.PI/18),f=Math.sqrt((1+c)/2),m=Math.sqrt((1-c)/2),_=[];let p;this._crossProduct(l,this._sub(o,n))>0?(_.push(n),l=this._sub(n,h),p=a):(_.push(a),l=this._sub(a,h),p=n),this._rotateDirect(l,f,m),l[0]/=f,l[1]/=f;for(let d=1;d<=18;d++)_.push(this._add(h,l)),this._rotateDirect(l,c,u);_.push(p),e.push(_);break}case I.HalfCircleSecondSegment:{const a=this._cp2(s,0,-1),o=this._cp3(s,a,1,-1);let h=this._sub(n,a);this._normalize(h);const l=this._crossProduct(h,this._sub(o,a))/2;this._leftPerpendicular(h);const c=[a[0]+h[0]*l,a[1]+h[1]*l];h=this._sub(a,c);const u=Math.cos(Math.PI/18);let f=Math.sin(Math.PI/18);l>0&&(f=-f);const m=[a];for(let _=1;_<=18;_++)this._rotateDirect(h,u,f),m.push(this._add(c,h));e.push(m);break}case I.HalfCircleExtended:{const a=this._cp2(s,0,-2),o=this._cp3(s,a,1,-1);let h;if(i>=4)h=s[3];else{const _=this._sub(n,a);h=this._add(o,_)}const l=this._dist(a,o)/2/.75,c=this._sub(a,n);this._normalize(c,l);const u=this._sub(o,h);this._normalize(u,l);const f=[h,o];e.push(f);const m=[this._clone(o)];this._addBezier3(m,o,this._add(o,u),this._add(a,c),a,4),m.push(n),e.push(m);break}case I.OpenCircle:{const a=this._cp2(s,-2,0),o=this._sub(a,n),h=Math.cos(Math.PI/18),l=-Math.sin(Math.PI/18),c=[a];for(let u=1;u<=33;u++)this._rotateDirect(o,h,l),c.push(this._add(n,o));e.push(c);break}case I.CoverageEdgesWithTicks:{const a=this._cp2(s,0,-1);let o,h;if(i>=3)o=s[2];else{const f=this._sub(a,n),m=this._leftPerp(f);o=[n[0]+m[0]-.25*f[0],n[1]+m[1]-.25*f[1]]}if(i>=4)h=s[3];else{const f=this._mid(n,a),m=this._sub(n,a);this._normalize(m),this._leftPerpendicular(m);const _=this._crossProduct(m,this._sub(o,f));this._rightPerpendicular(m),h=[o[0]+m[0]*_*2,o[1]+m[1]*_*2]}const l=this._sub(a,n);let c,u;c=this._crossProduct(l,this._sub(o,n))>0?this._rightPerp(l):this._leftPerp(l),u=[],u.push(o),u.push(n),u.push([n[0]+(c[0]-l[0])/3,n[1]+(c[1]-l[1])/3]),e.push(u),c=this._crossProduct(l,this._sub(h,a))>0?this._rightPerp(c):this._leftPerp(l),u=[],u.push([a[0]+(c[0]+l[0])/3,a[1]+(c[1]+l[1])/3]),u.push(a),u.push(h),e.push(u);break}case I.GapExtentWithDoubleTicks:{const a=this._cp2(s,0,2),o=this._cp3(s,a,0,1);let h;if(i>=4)h=s[3];else{const l=this._sub(a,n);h=this._add(o,l)}this._addAngledTicks(e,n,a,this._mid(o,h)),this._addAngledTicks(e,o,h,this._mid(n,a));break}case I.GapExtentMidline:{const a=this._cp2(s,2,0),o=this._cp3(s,a,0,1);let h;if(i>=4)h=s[3];else{const c=this._sub(a,n);h=this._add(o,c)}const l=[];l.push(this._mid(n,o)),l.push(this._mid(a,h)),e.push(l);break}case I.Chevron:{const a=this._cp2(s,-1,-1);let o;if(i>=3)o=s[2];else{const h=this._sub(a,n);this._leftPerpendicular(h),o=this._add(n,h)}e.push([a,this._makeCtrlPt(n),o]);break}case I.PerpendicularWithArc:{const a=this._cp2(s,0,-2),o=this._cp3(s,a,.5,-1);let h=this._sub(a,n);const l=this._norm(h);h[0]/=l,h[1]/=l;const c=this._crossProduct(h,this._sub(o,n));let u=this._dotProduct(h,this._sub(o,n));u<.05*l?u=.05*l:u>.95*l&&(u=.95*l);const f=[n[0]+h[0]*u,n[1]+h[1]*u];this._leftPerpendicular(h);let m=[];m.push([f[0]-h[0]*c,f[1]-h[1]*c]),m.push([f[0]+h[0]*c,f[1]+h[1]*c]),e.push(m);const _=[a[0]+h[0]*c,a[1]+h[1]*c];h=this._sub(a,_);const p=Math.cos(Math.PI/18);let d=Math.sin(Math.PI/18);c<0&&(d=-d),m=[n,a];for(let g=1;g<=9;g++)this._rotateDirect(h,p,d),m.push(this._add(_,h));e.push(m);break}case I.ClosedHalfCircle:{const a=this._cp2(s,2,0),o=this._mid(n,a),h=this._sub(a,o),l=Math.cos(Math.PI/18),c=Math.sin(Math.PI/18),u=[n,a];for(let f=1;f<=18;f++)this._rotateDirect(h,l,c),u.push(this._add(o,h));e.push(u);break}case I.TripleParallelExtended:{const a=this._cp2(s,0,-2),o=this._cp3(s,a,1,-2),h=this._mid(n,a),l=this._sub(o,a);this._normalize(l);const c=Math.abs(this._crossProduct(l,this._sub(h,a)))/2,u=this._dist(a,o),f=[a,n];f.push([n[0]+l[0]*u*.5,n[1]+l[1]*u*.5]),e.push(f);const m=[];m.push([h[0]-l[0]*c,h[1]-l[1]*c]),m.push([h[0]+l[0]*u*.375,h[1]+l[1]*u*.375]),Jt(m[m.length-1],1),m.push([h[0]+l[0]*u*.75,h[1]+l[1]*u*.75]),e.push(m);const _=[a,o];e.push(_);break}case I.ParallelWithTicks:{const a=this._cp2(s,3,0),o=this._cp3(s,a,.5,-1),h=this._sub(o,a);this._normalize(h);const l=this._crossProduct(h,this._sub(o,n));this._leftPerpendicular(h),this._addAngledTicks(e,n,a,o),this._addAngledTicks(e,this._mix(n,1,h,l),this._mix(a,1,h,l),this._mid(n,a));break}case I.Parallel:{const a=this._cp2(s,3,0),o=this._cp3(s,a,.5,-1),h=this._sub(a,n);this._normalize(h);const l=this._leftPerp(h),c=this._crossProduct(h,this._sub(o,n));let u=[n,a];e.push(u),u=[],u.push([n[0]+l[0]*c,n[1]+l[1]*c]),u.push([a[0]+l[0]*c,a[1]+l[1]*c]),e.push(u);break}case I.PerpendicularToFirstSegment:{const a=this._cp2(s,3,0),o=this._cp3(s,a,.5,-1),h=this._mid(n,a),l=this._sub(a,n);this._normalize(l);const c=this._crossProduct(l,this._sub(o,n));this._leftPerpendicular(l);const u=[];u.push([h[0]-l[0]*c*.25,h[1]-l[1]*c*.25]),u.push([h[0]+l[0]*c*1.25,h[1]+l[1]*c*1.25]),e.push(u);break}case I.ParallelOffset:{const a=this._cp2(s,3,0),o=this._cp3(s,a,.5,-1),h=this._sub(a,n);this._normalize(h);const l=this._crossProduct(h,this._sub(o,n));this._leftPerpendicular(h);const c=[];c.push([n[0]-h[0]*l,n[1]-h[1]*l]),c.push([a[0]-h[0]*l,a[1]-h[1]*l]),e.push(c);const u=[];u.push([n[0]+h[0]*l,n[1]+h[1]*l]),u.push([a[0]+h[0]*l,a[1]+h[1]*l]),e.push(u);break}case I.OffsetOpposite:{const a=this._cp2(s,3,0),o=this._cp3(s,a,.5,-1),h=this._sub(a,n);this._normalize(h);const l=this._crossProduct(h,this._sub(o,n));this._leftPerpendicular(h);const c=[];c.push([n[0]-h[0]*l,n[1]-h[1]*l]),c.push([a[0]-h[0]*l,a[1]-h[1]*l]),e.push(c);break}case I.OffsetSame:{const a=this._cp2(s,3,0),o=this._cp3(s,a,.5,-1),h=this._sub(a,n);this._normalize(h);const l=this._crossProduct(h,this._sub(o,n));this._leftPerpendicular(h);const c=[];c.push([n[0]+h[0]*l,n[1]+h[1]*l]),c.push([a[0]+h[0]*l,a[1]+h[1]*l]),e.push(c);break}case I.CircleWithArc:{let a=this._cp2(s,3,0);const o=this._cp3(s,a,.5,-1);let h,l;if(i>=4)h=s[3],l=this._crossProduct(this._sub(h,a),this._sub(o,a))>0;else{h=a,l=this._crossProduct(this._sub(h,n),this._sub(o,n))>0;const _=24*this._geomUnitsPerPoint,p=this._sub(h,n);this._normalize(p,_);const d=Math.sqrt(2)/2;this._rotateDirect(p,d,l?d:-d),a=this._add(n,p)}const c=this._sub(a,n),u=Math.cos(Math.PI/18),f=Math.sin(Math.PI/18),m=[a];for(let _=1;_<=36;_++)this._rotateDirect(c,u,f),m.push(this._add(n,c));this._add90DegArc(m,a,h,o,l),Jt(m[m.length-8],1),e.push(m);break}case I.DoubleJog:{let a,o,h=this._cp2(s,-3,1);if(a=i>=3?s[2]:this._add(n,this._sub(n,h)),i>=4)o=s[3];else{const g=n;n=h,o=a;const y=this._dist(n,g),P=this._dist(o,g);let x=30*this._geomUnitsPerPoint;.5*y0?this._rotateDirect(p,_,-_):this._rotateDirect(p,_,_);let d=[];d.push(h),d.push(this._add(l,p)),d.push(this._sub(l,p)),d.push(n),e.push(d),p=this._sub(o,a),this._normalize(p,m),this._crossProduct(p,this._sub(n,a))<0?this._rotateDirect(p,_,_):this._rotateDirect(p,_,-_),d=[],d.push(a),d.push(this._add(c,p)),d.push(this._sub(c,p)),d.push(o),e.push(d);break}case I.PerpendicularOffset:{const a=this._cp2(s,-4,1),o=this._cp3(s,a,.882353,-1.94),h=this._sub(o,a);this._crossProduct(h,this._sub(n,a))>0?this._rightPerpendicular(h):this._leftPerpendicular(h);const l=[h[0]/8,h[1]/8],c=this._sub(this._mid(a,o),l);e.push([c,n]);break}case I.LineExcludingLastSegment:{const a=this._arrowPath(s),o=[];let h=a.length-2;for(;h--;)o.push(a[h]);e.push(o);break}case I.MultivertexArrow:{const a=this._arrowPath(s),o=[];this._addArrow(o,a,!1),e.push(o);break}case I.CrossedArrow:{const a=this._arrowPath(s),o=[];this._addArrow(o,a,!0),e.push(o);break}case I.ChevronArrow:{const[a,o]=this._arrowLastSeg(s),h=10*this._geomUnitsPerPoint,l=this._sub(n,a);this._normalize(l);const c=this._crossProduct(l,this._sub(o,a)),u=this._leftPerp(l),f=[o[0]-u[0]*c*2,o[1]-u[1]*c*2],m=[];m.push([o[0]+l[0]*h,o[1]+l[1]*h]),m.push(n),m.push([f[0]+l[0]*h,f[1]+l[1]*h]),e.push(m);break}case I.ChevronArrowOffset:{const[a,o]=this._arrowLastSeg(s),h=this._sub(n,a);this._normalize(h);const l=this._crossProduct(h,this._sub(o,a));this._leftPerpendicular(h);const c=[o[0]-h[0]*l,o[1]-h[1]*l],u=[];u.push([c[0]+h[0]*l*.5,c[1]+h[1]*l*.5]),u.push(this._mid(c,n)),u.push([c[0]-h[0]*l*.5,c[1]-h[1]*l*.5]),e.push(u);break}case I.PartialFirstSegment:{const[a,o]=this._arrowLastSeg(s),h=this._sub(n,a);this._normalize(h);const l=this._crossProduct(h,this._sub(o,a));this._leftPerpendicular(h);const c=[o[0]-h[0]*l,o[1]-h[1]*l];e.push([a,c]);break}case I.Arch:{const a=this._cp2(s,0,-1),o=this._cp3(s,a,.5,1),h=this._sub(n,a),l=this._mix(o,1,h,.55),c=this._mix(o,1,h,-.55),u=[n];this._addBezier2(u,n,l,o,4),this._addBezier2(u,o,c,a,4),e.push(u);break}case I.CurvedParallelTicks:{const a=this._cp2(s,-4,1),o=this._cp3(s,a,.882353,-1.94),h=this._sub(o,a);this._crossProduct(h,this._sub(n,a))>0?this._rightPerpendicular(h):this._leftPerpendicular(h);const l=[h[0]/8,h[1]/8],c=this._sub(this._mid(a,o),l),u=this._sub(this._mix(a,.75,o,.25),l),f=this._sub(this._mix(a,.25,o,.75),l),m=[a];this._addBezier2(m,a,u,c,3),this._addBezier2(m,c,f,o,3),e.push(m);for(let _=0;_<8;_++){const p=m[2*_+1],d=[this._clone(p)];d.push(this._add(p,[h[0]/4,h[1]/4])),e.push(d)}break}case I.Arc90Degrees:{const a=this._cp2(s,0,-1),o=this._cp3(s,a,.5,1),h=[a];this._add90DegArc(h,a,n,o),e.push(h);break}case I.FullGeometry:default:e.push(s)}}return e}}class St{static local(){return St.instance===null&&(St.instance=new St),St.instance}execute(t,e,s,i){return new yr(t,e,s)}}St.instance=null;class yr extends Te{constructor(t,e,s){super(t,!0,!0),this._curveHelper=new tt,this._beginCut=(e.beginCut!==void 0?e.beginCut:1)*s,this._endCut=(e.endCut!==void 0?e.endCut:1)*s,this._middleCut=(e.middleCut!==void 0?e.middleCut:0)*s,this._invert=e.invert!==void 0&&e.invert,this._beginCut<0&&(this._beginCut=0),this._endCut<0&&(this._endCut=0),this._middleCut<0&&(this._middleCut=0)}processPath(t){const e=this._beginCut,s=this._endCut,i=this._middleCut,n=this._curveHelper.calculatePathLength(t),a=[];if(this._invert){if(!(e===0&&s===0&&i===0))if(e+s+i>=n)a.push(t);else{let o=this._curveHelper.getSubCurve(t,0,e);o&&a.push(o),o=this._curveHelper.getSubCurve(t,.5*(n-i),.5*(n+i)),o&&a.push(o),o=this._curveHelper.getSubCurve(t,n-s,s),o&&a.push(o)}}else if(e===0&&s===0&&i===0)a.push(t);else if(!(e+s+i>=n))if(i===0){const o=this._curveHelper.getSubCurve(t,e,n-s);o&&a.push(o)}else{let o=this._curveHelper.getSubCurve(t,e,.5*(n-i));o&&a.push(o),o=this._curveHelper.getSubCurve(t,.5*(n+i),n-s),o&&a.push(o)}return a.length===0?null:{paths:a}}}const xs=1e-7;class Ne{constructor(){this._values=[],this.extPtGap=0,this.ctrlPtGap=0,this._length=0,this._currentValue=0}isEmpty(){return this._values.length===0}size(){return this._values.length}init(t,e,s=!0){if(this._setEmpty(),!t||t.length===0)return!1;for(let i=0;i0&&(n/=this._currentPosition.segmentLength),this._currentPosition.copyTo(e);e.abscissa+t*this._partLengthRatio>e.segmentLength+this._tolerance;){if(s){if(s.length===0)if(n===0){const o=this._path[e.segment];s.push([o[0],o[1]])}else s.push(this.getSegCoord2D(this._path,e.segment,n));const a=this._path[e.segment+1];s.push([a[0],a[1]])}if(n=0,t-=(e.segmentLength-e.abscissa)/this._partLengthRatio,this._partSegCount)e.segment=this._nextSegment(),e.segmentLength=this.calculateSegLength(this._path,e.segment),e.abscissa=0,this._partSegCount--;else{if(!this._setPosAtNextPart())return i!==lt.FAIL&&(e.segmentLength=this.calculateSegLength(this._path,e.segment),e.isPartEnd=!0,i===lt.END?(e.abscissa=e.segmentLength,e.isPathEnd=!0):e.abscissa=e.segmentLength+t,!0);this._currentPosition.copyTo(e)}}if(e.abscissa+=t*this._partLengthRatio,s){if(s.length===0)if(n===0){const o=this._path[e.segment];s.push([o[0],o[1]])}else s.push(this.getSegCoord2D(this._path,e.segment,n));const a=e.abscissa/e.segmentLength;if(a===1){const o=this._path[e.segment+1];s.push([o[0],o[1]])}else s.push(this.getSegCoord2D(this._path,e.segment,a))}return this._partSegCount||Math.abs(e.abscissa-e.segmentLength)=this._path.length&&(s=0),this._ctrlPtEnd=he(this._path[s])===1,this._patternLength>0){const i=this._ctrlPtBegin?this._partCtrlPtGap:this._partExtPtGap,n=this._ctrlPtEnd?this._partCtrlPtGap:this._partExtPtGap;let a=Math.round((this._partLength-(i+n))/this._patternLength);a<=0&&(a=i+n>0?0:1),this._partLengthRatio=this._partLength/(i+n+a*this._patternLength),this._partLengthRatio<.01&&(this._partLengthRatio=1)}else this._partLengthRatio=1;return!0}_hasNextSegment(){return this._seg=e;)i-=e,e=this._pattern.nextValue(),a=!a;e-=i,a?(this._walker.nextPosition(e),e=this._pattern.nextValue()):this.isClosed&&(this._firstCurve=this._walker.nextCurve(e),e=this._pattern.nextValue(),this._walker.nextPosition(e),e=this._pattern.nextValue())}let s=this._walker.nextCurve(e);return s?this._walker.isPathEnd()?(this.iteratePath=!1,this._firstCurve&&(this._firstCurve.splice(0,1),jt.mergePath(s,this._firstCurve),this._firstCurve=null)):(e=this._pattern.nextValue(),!this._walker.nextPosition(e)||this._walker.isPathEnd()?(this.iteratePath=!1,this._firstCurve&&(s=this._firstCurve,this._firstCurve=null)):this.iteratePath=!0):(this.iteratePath=!1,s=this._firstCurve,this._firstCurve=null),{paths:[s]}}}class wt{static local(){return wt.instance===null&&(wt.instance=new wt),wt.instance}execute(t,e,s,i){return new xr(t,e,s)}}wt.instance=null;class xr{constructor(t,e,s){switch(this._inputGeometries=t,this._curveHelper=new tt,this._width=(e.width!==void 0?e.width:2)*s,e.method){case ie.Mitered:default:this._method=X.Mitered;break;case ie.Bevelled:this._method=X.Bevelled;break;case ie.Rounded:case ie.TrueBuffer:this._method=X.Rounded;break;case ie.Square:this._method=X.Square}this._option=e.option,this._offsetFlattenError=Qt*s}next(){let t=this._inputGeometries.next();for(;t;){if($(t)&&this._width>0){if(Math.min(t.xmax-t.xmin,t.ymax-t.ymin)-2*this._width<0)return t;const e=[];return e.push([[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]),e.push([[t.xmin+this._width,t.ymin+this._width],[t.xmax-this._width,t.ymin+this._width],[t.xmax-this._width,t.ymax-this._width],[t.xmin+this._width,t.ymax-this._width],[t.xmin+this._width,t.ymin+this._width]]),{rings:e}}if(z(t)&&this._width>0){const e=[];for(const s of t.rings){const i=this._curveHelper.calculatePathLength(s),n=this._curveHelper.offset(s,this._width,this._method,4,this._offsetFlattenError);n&&(i<0&&n.reverse(),e.push(n))}if(e.length)return{rings:e}}t=this._inputGeometries.next()}return null}}class kt{static local(){return kt.instance===null&&(kt.instance=new kt),kt.instance}execute(t,e,s,i){return new br(t,e,s)}}kt.instance=null;class br extends Te{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new tt,this._length=(e.length!==void 0?e.length:20)*s,this._angle=e.angle!==void 0?e.angle:225,this._position=e.position!==void 0?e.position:50,this._length<0&&(this._length=-this._length),this._position<20&&(this._position=20),this._position>80&&(this._position=80),this._mirror=!1}processPath(t){if(this._curveHelper.isEmpty(t,!1))return null;const e=t[0],s=t[t.length-1],i=[s[0]-e[0],s[1]-e[1]];this._curveHelper.normalize(i);const n=[e[0]+(s[0]-e[0])*this._position/100,e[1]+(s[1]-e[1])*this._position/100],a=Math.cos((90-this._angle)/180*Math.PI);let o=Math.sin((90-this._angle)/180*Math.PI);return this._mirror&&(o=-o),this._mirror=!this._mirror,{paths:[[e,[n[0]-this._length/2*a,n[1]-this._length/2*o],[n[0]+this._length/2*a,n[1]+this._length/2*o],s]]}}}class vt{static local(){return vt.instance===null&&(vt.instance=new vt),vt.instance}execute(t,e,s,i){return new Mr(t,e,s)}}vt.instance=null;class Mr{constructor(t,e,s){this._inputGeometries=t,this._offsetX=e.offsetX!==void 0?e.offsetX*s:0,this._offsetY=e.offsetY!==void 0?-e.offsetY*s:0}next(){let t=this._inputGeometries.next();for(;t;){if($(t))return{xmin:t.xmin+this._offsetX,xmax:t.xmax+this._offsetX,ymin:t.ymin+this._offsetY,ymax:t.ymax+this._offsetY};if(z(t)){const e=R(t);return this._moveMultipath(e.rings,this._offsetX,this._offsetY),e}if(O(t)){const e=R(t);return this._moveMultipath(e.paths,this._offsetX,this._offsetY),e}if(Q(t)){const e=R(t);return this._movePath(e.points,this._offsetX,this._offsetY),e}if(ut(t))return{x:t.x+this._offsetX,y:t.y+this._offsetY};t=this._inputGeometries.next()}return null}_moveMultipath(t,e,s){if(t)for(const i of t)this._movePath(i,e,s)}_movePath(t,e,s){if(t)for(const i of t)i[0]+=e,i[1]+=s}}class It{static local(){return It.instance===null&&(It.instance=new It),It.instance}execute(t,e,s,i){return new Sr(t,e,s)}}It.instance=null;class Sr{constructor(t,e,s){var i;this._inputGeometries=t,this._curveHelper=new tt,this._offset=((i=e.offset)!=null?i:1)*s,this._method=e.method,this._option=e.option,this._offsetFlattenError=Qt*s}next(){let t=this._inputGeometries.next();for(;t;){if(this._offset===0)return t;if($(t)){if(this._method===X.Rounded&&this._offset>0){const e=[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]],s=this._curveHelper.offset(e,-this._offset,this._method,4,this._offsetFlattenError);return s?{rings:[s]}:null}if(Math.min(t.xmax-t.xmin,t.ymax-t.ymin)+2*this._offset>0)return{xmin:t.xmin-this._offset,xmax:t.xmax+this._offset,ymin:t.ymin-this._offset,ymax:t.ymax+this._offset}}if(z(t)){const e=[];for(const s of t.rings){const i=this._curveHelper.offset(s,-this._offset,this._method,4,this._offsetFlattenError);i&&e.push(i)}if(e.length)return{rings:e}}if(O(t)){const e=[];for(const s of t.paths){const i=this._curveHelper.offset(s,-this._offset,this._method,4,this._offsetFlattenError);i&&e.push(i)}if(e.length)return{paths:e}}t=this._inputGeometries.next()}return null}}class Lt{static local(){return Lt.instance===null&&(Lt.instance=new Lt),Lt.instance}execute(t,e,s,i){return new Cr(t,e,s)}}Lt.instance=null;class Cr{constructor(t,e,s){this._inputGeometries=t,this._reverse=e.reverse===void 0||e.reverse}next(){let t=this._inputGeometries.next();for(;t;){if(!this._reverse)return t;if(O(t)){const e=R(t);return cr(e.paths),e}t=this._inputGeometries.next()}return null}}class Tt{static local(){return Tt.instance===null&&(Tt.instance=new Tt),Tt.instance}execute(t,e,s,i){return new wr(t,e,s)}}Tt.instance=null;class wr{constructor(t,e,s){this._inputGeometries=t,this._rotateAngle=e.angle!==void 0?e.angle*Math.PI/180:0}next(){let t=this._inputGeometries.next();for(;t;){if(this._rotateAngle===0)return t;const e=V();Zt(e,t);const s=(e[2]+e[0])/2,i=(e[3]+e[1])/2;if($(t)){const n={rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]};return this._rotateMultipath(n.rings,s,i),n}if(z(t)){const n=R(t);return this._rotateMultipath(n.rings,s,i),n}if(O(t)){const n=R(t);return this._rotateMultipath(n.paths,s,i),n}if(Q(t)){const n=R(t);return this._rotatePath(n.points,s,i),n}if(ut(t))return t;t=this._inputGeometries.next()}return null}_rotateMultipath(t,e,s){if(t)for(const i of t)this._rotatePath(i,e,s)}_rotatePath(t,e,s){if(t){const i=Math.cos(this._rotateAngle),n=Math.sin(this._rotateAngle);for(const a of t){const o=a[0]-e,h=a[1]-s;a[0]=e+o*i-h*n,a[1]=s+o*n+h*i}}}}class Nt{static local(){return Nt.instance===null&&(Nt.instance=new Nt),Nt.instance}execute(t,e,s,i){return new kr(t,e,s)}}Nt.instance=null;class kr{constructor(t,e,s){this._inputGeometries=t,this._xFactor=e.xScaleFactor!==void 0?e.xScaleFactor:1.15,this._yFactor=e.yScaleFactor!==void 0?e.yScaleFactor:1.15}next(){let t=this._inputGeometries.next();for(;t;){if(this._xFactor===1&&this._yFactor===1)return t;const e=V();Zt(e,t);const s=(e[2]+e[0])/2,i=(e[3]+e[1])/2;if($(t)){const n={rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]};return this._scaleMultipath(n.rings,s,i),n}if(z(t)){const n=R(t);return this._scaleMultipath(n.rings,s,i),n}if(O(t)){const n=R(t);return this._scaleMultipath(n.paths,s,i),n}if(Q(t)){const n=R(t);return this._scalePath(n.points,s,i),n}if(ut(t))return t;t=this._inputGeometries.next()}return null}_scaleMultipath(t,e,s){if(t)for(const i of t)this._scalePath(i,e,s)}_scalePath(t,e,s){if(t)for(const i of t){const n=(i[0]-e)*this._xFactor,a=(i[1]-s)*this._yFactor;i[0]=e+n,i[1]=s+a}}}class At{static local(){return At.instance===null&&(At.instance=new At),At.instance}execute(t,e,s,i){return new vr(t,e,s)}}At.instance=null;class vr{constructor(t,e,s){this._inputGeometries=t,this._height=(e.amplitude!==void 0?e.amplitude:2)*s,this._period=(e.period!==void 0?e.period:3)*s,this._style=e.waveform,this._height<=0&&(this._height=Math.abs(this._height)),this._period<=0&&(this._period=Math.abs(this._period)),this._pattern=new Ne,this._pattern.addValue(this._period),this._pattern.addValue(this._period),this._walker=new Ae,this._walker.updateTolerance(s)}next(){let t=this._inputGeometries.next();for(;t;){if(this._height===0||this._period===0)return t;if(O(t)){const e=this._processGeom(t.paths);if(e.length)return{paths:e}}if(z(t)){const e=this._processGeom(t.rings);if(e.length)return{rings:e}}t=this._inputGeometries.next()}return null}_processGeom(t){const e=[];for(const s of t)if(this._walker.init(s,this._pattern))switch(this._style){case ge.Sinus:default:e.push(this._constructCurve(s,!1));break;case ge.Square:e.push(this._constructSquare(s));break;case ge.Triangle:e.push(this._constructTriangle(s));break;case ge.Random:e.push(this._constructCurve(s,!0))}else e.push(s);return e}_constructCurve(t,e){const s=new jt,i=this._walker.calculatePathLength(t);let n=Math.round(i/this._period);n===0&&(n=1);const a=n*16+1,o=i/n,h=this._period/16,l=1/a,c=2*Math.PI*i/o,u=2*Math.PI*Math.random(),f=2*Math.PI*Math.random(),m=2*Math.PI*Math.random(),_=.75-Math.random()/2,p=.75-Math.random()/2,d=new it;this._walker.curPointAndAngle(d),s.startPath(d.pt);let g=0;for(;;){if(!this._walker.nextPointAndAngle(h,d)){s.lineTo(t[t.length-1]);break}{const y=g;let P;if(g+=l,e){const x=this._height/2*(1+.3*Math.sin(_*c*y+u));P=x*Math.sin(c*y+f),P+=x*Math.sin(p*c*y+m),P/=2}else P=.5*this._height*Math.sin(.5*c*y);s.lineTo([d.pt[0]-P*d.sa,d.pt[1]+P*d.ca])}}return s.path()}_constructSquare(t){const e=new jt,s=this._walker.calculatePathLength(t);Math.round(s/this._period);let i=!0;for(;;){let n=!1;if(this._walker.curPositionIsValid()){const a=new it;this._walker.curPointAndAngle(a);const o=new it;if(this._walker.nextPointAndAngle(this._period,o)){const h=new it;this._walker.nextPointAndAngle(this._period,h)&&(i?(e.startPath(a.pt),i=!1):e.lineTo(a.pt),e.lineTo([a.pt[0]-this._height/2*a.sa,a.pt[1]+this._height/2*a.ca]),e.lineTo([o.pt[0]-this._height/2*o.sa,o.pt[1]+this._height/2*o.ca]),e.lineTo([o.pt[0]+this._height/2*o.sa,o.pt[1]-this._height/2*o.ca]),e.lineTo([h.pt[0]+this._height/2*h.sa,h.pt[1]-this._height/2*h.ca]),n=!0)}}if(!n){e.lineTo(this._walker.getPathEnd());break}}return e.path()}_constructTriangle(t){const e=new jt,s=this._walker.calculatePathLength(t);Math.round(s/this._period);let i=!0;for(;;){let n=!1;if(this._walker.curPositionIsValid()){const a=new it;this._walker.curPointAndAngle(a);const o=new it;if(this._walker.nextPointAndAngle(this._period/2,o)){const h=new it;this._walker.nextPointAndAngle(this._period,h)&&(this._walker.nextPosition(this._period/2)&&(i?(e.startPath(a.pt),i=!1):e.lineTo(a.pt),e.lineTo([o.pt[0]-this._height/2*o.sa,o.pt[1]+this._height/2*o.ca]),e.lineTo([h.pt[0]+this._height/2*h.sa,h.pt[1]-this._height/2*h.ca])),n=!0)}}if(!n){e.lineTo(this._walker.getPathEnd());break}}return e.path()}}class zt{static local(){return zt.instance===null&&(zt.instance=new zt),zt.instance}execute(t,e,s,i){return new Ir(t,e,s)}}zt.instance=null;class Ir extends fe{constructor(t,e,s){var i;super(t,!0,!0),this._geometryWalker=new Ae,this._geometryWalker.updateTolerance(s),this._angleToLine=(i=e.angleToLine)!=null?i:!0,this._offset=(e.offset?e.offset:0)*s,this._originalEndings=e.endings,this._offsetAtEnd=(e.customEndingOffset?e.customEndingOffset:0)*s,this._position=-(e.offsetAlongLine?e.offsetAlongLine:0)*s,this._pattern=new Ne,this._pattern.init(e.placementTemplate,!1),this._pattern.scale(s),this._endings=this._originalEndings}processPath(t){if(this._pattern.isEmpty())return null;let e;if(this.iteratePath)e=this._pattern.nextValue();else{this._originalEndings===st.WithFullGap&&this.isClosed?this._endings=st.WithMarkers:this._endings=this._originalEndings,this._pattern.extPtGap=0;let i,n=!0;switch(this._endings){case st.NoConstraint:i=-this._position,i=this._adjustPosition(i),n=!1;break;case st.WithHalfGap:default:i=-this._pattern.lastValue()/2;break;case st.WithFullGap:i=-this._pattern.lastValue(),this._pattern.extPtGap=this._pattern.lastValue();break;case st.WithMarkers:i=0;break;case st.Custom:i=-this._position,i=this._adjustPosition(i),this._pattern.extPtGap=.5*this._offsetAtEnd}if(!this._geometryWalker.init(t,this._pattern,n))return null;this._pattern.reset();let a=0;for(;i>a;)i-=a,a=this._pattern.nextValue();a-=i,e=a,this.iteratePath=!0}const s=new it;return this._geometryWalker.nextPointAndAngle(e,s)?this._endings===st.WithFullGap&&this._geometryWalker.isPathEnd()?(this.iteratePath=!1,null):this._endings===st.WithMarkers&&this._geometryWalker.isPathEnd()&&(this.iteratePath=!1,this.isClosed)?null:(this.internalPlacement.setTranslate(s.pt[0]-this._offset*s.sa,s.pt[1]+this._offset*s.ca),this._angleToLine&&this.internalPlacement.setRotateCS(s.ca,s.sa),this.internalPlacement):(this.iteratePath=!1,null)}_adjustPosition(t){let e=t/this._pattern.length();return e-=Math.floor(e),e*this._pattern.length()}}class Ot{static local(){return Ot.instance===null&&(Ot.instance=new Ot),Ot.instance}execute(t,e,s,i){return new Lr(t,e,s)}}Ot.instance=null;class Lr extends fe{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new tt,this._angleToLine=e.angleToLine===void 0||e.angleToLine,this._offset=e.offset!==void 0?e.offset*s:0,this._type=e.extremityPlacement,this._position=e.offsetAlongLine!==void 0?e.offsetAlongLine*s:0,this._beginProcessed=!1}processPath(t){let e;switch(this._type){case ct.Both:default:this._beginProcessed?(e=this._atExtremities(t,this._position,!1),this._beginProcessed=!1,this.iteratePath=!1):(e=this._atExtremities(t,this._position,!0),this._beginProcessed=!0,this.iteratePath=!0);break;case ct.JustBegin:e=this._atExtremities(t,this._position,!0);break;case ct.JustEnd:e=this._atExtremities(t,this._position,!1);case ct.None:}return e}_atExtremities(t,e,s){const i=t.length;if(i<2)return null;const n=s?1:i-2,a=s?i:-1,o=s?1:-1;let h,l=0,c=s?t[0]:t[i-1];for(let u=n;u!==a;u+=o){h=c,c=t[u];const f=this._curveHelper.calculateLength(h,c);if(l+f>e){const m=(e-l)/f,[_,p]=this._curveHelper.getAngleCS(h,c,m),d=Qe(h,c,m);return this.internalPlacement.setTranslate(d[0]-this._offset*p,d[1]+this._offset*_),this._angleToLine&&this.internalPlacement.setRotateCS(-_,-p),this.internalPlacement}l+=f}return null}}class Rt{static local(){return Rt.instance===null&&(Rt.instance=new Rt),Rt.instance}execute(t,e,s,i){return new Tr(t,e,s)}}Rt.instance=null;class Tr extends fe{constructor(t,e,s){super(t,!0,!0),this._walker=new Ae,this._walker.updateTolerance(s),this._angleToLine=e.angleToLine===void 0||e.angleToLine,this._offset=e.offset!==void 0?e.offset*s:0,this._beginGap=e.beginPosition!==void 0?e.beginPosition*s:0,this._endGap=e.endPosition!==void 0?e.endPosition*s:0,this._flipFirst=e.flipFirst===void 0||e.flipFirst,this._pattern=new Ne,this._pattern.init(e.positionArray,!1,!1),this._subPathLen=0,this._posCount=this._pattern.size(),this._isFirst=!0,this._prevPos=0}processPath(t){if(this._pattern.isEmpty())return null;let e;if(this.iteratePath){const o=this._pattern.nextValue()*this._subPathLen,h=this._beginGap+o;e=h-this._prevPos,this._prevPos=h}else{if(this._posCount=this._pattern.size(),this._isFirst=!0,this._prevPos=0,this._subPathLen=this._walker.calculatePathLength(t)-this._beginGap-this._endGap,this._subPathLen<0)return this.iteratePath=!1,null;if(!this._walker.init(t,this._pattern,!1))return null;this._pattern.reset();const o=this._pattern.nextValue()*this._subPathLen,h=this._beginGap+o;e=h-this._prevPos,this._prevPos=h,this.iteratePath=!0}const s=new it;if(!this._walker.nextPointAndAngle(e,s,lt.END))return this.iteratePath=!1,null;this.internalPlacement.setTranslate(s.pt[0]-this._offset*s.sa,s.pt[1]+this._offset*s.ca);const i=this._isFirst&&this._flipFirst;let n,a;return this._angleToLine?(n=s.ca,a=s.sa):(n=1,a=0),i&&(n=-n,a=-a),this.internalPlacement.setRotateCS(n,a),this._isFirst=!1,this._posCount--,this._posCount===0&&(this.iteratePath=!1),this.internalPlacement}}function Nr(r){return r.rings!==void 0}class Et{static local(){return Et.instance===null&&(Et.instance=new Et),Et.instance}execute(t,e,s,i){return new Ar(t,e,s,i)}}Et.instance=null;class Ar{constructor(t,e,s,i){var n,a,o,h,l,c,u,f,m;if(this._xMin=0,this._xMax=0,this._yMin=0,this._yMax=0,this._currentX=0,this._currentY=0,this._stepX=Math.abs((n=e.stepX)!=null?n:16)*s,this._stepY=Math.abs((a=e.stepY)!=null?a:16)*s,this._stepX!==0&&this._stepY!==0&&t&&Nr(t)&&t.rings){if(this._gridType=(o=e.gridType)!=null?o:Oe.Fixed,this._gridType===Oe.Random){const _=(h=e.seed)!=null?h:13,p=1;this._randomLCG=new Rs(_*p),this._randomness=((l=e.randomness)!=null?l:100)/100,this._gridAngle=0,this._shiftOddRows=!1,this._cosAngle=1,this._sinAngle=0,this._offsetX=0,this._offsetY=0}else{if(this._randomness=0,this._gridAngle=(c=e.gridAngle)!=null?c:0,this._shiftOddRows=(u=e.shiftOddRows)!=null?u:!1,this._offsetX=((f=e.offsetX)!=null?f:0)*s,this._offsetY=((m=e.offsetY)!=null?m:0)*s,this._cosAngle=Math.cos(this._gridAngle/180*Math.PI),this._sinAngle=-Math.sin(this._gridAngle/180*Math.PI),this._stepX)if(this._offsetX<0)for(;this._offsetX<-.5*this._stepX;)this._offsetX+=this._stepX;else for(;this._offsetX>=.5*this._stepX;)this._offsetX-=this._stepX;if(this._stepY)if(this._offsetY<0)for(;this._offsetY<-.5*this._stepY;)this._offsetY+=this._stepY;else for(;this._offsetY>=.5*this._stepY;)this._offsetY-=this._stepY}this._graphicOriginX=0,this._graphicOriginY=0,this._internalPlacement=new te,this._calculateMinMax(t),this._geometry=t}}next(){return this._geometry?this._nextInside():null}_calculateMinMax(t){let e,s,i,n,a,o,h,l;this._xMin=0,this._xMax=0,this._yMin=0,this._yMax=0,a=o=Number.MAX_VALUE,h=l=-Number.MAX_VALUE;for(const c of t.rings){const u=c?c.length:0;for(let f=0;fthis._xMax){if(this._currentY++,this._currentY>this._yMax)return null;this._currentX=this._xMin,this._shiftOddRows&&this._currentY%2&&this._currentX--}let t=this._currentX*this._stepX+this._offsetX;this._shiftOddRows&&this._currentY%2&&(t+=.5*this._stepX);const e=this._currentY*this._stepY+this._offsetY;let s,i;return this._currentX++,this._gridType===Oe.Random?(s=this._graphicOriginX+t+this._stepX*this._randomness*(.5-this._randomLCG.getFloat())*2/3,i=this._graphicOriginY+e+this._stepY*this._randomness*(.5-this._randomLCG.getFloat())*2/3):(s=this._graphicOriginX+this._cosAngle*t+this._sinAngle*e,i=this._graphicOriginY-this._sinAngle*t+this._cosAngle*e),this._internalPlacement.setTranslate(s,i),this._internalPlacement}}}const zr=.001;class $t{static local(){return $t.instance===null&&($t.instance=new $t),$t.instance}execute(t,e,s,i){return new Or(t,e,s)}}$t.instance=null;class Or extends fe{constructor(t,e,s){super(t,!0,!0),this._curveHelper=new tt,this._angleToLine=e.angleToLine===void 0||e.angleToLine,this._offset=e.offset!==void 0?e.offset*s:0,this._relativeTo=e.relativeTo,this._position=e.startPointOffset!==void 0?e.startPointOffset*s:0,this._epsilon=zr*s}processPath(t){const e=this._position;if(this._relativeTo===Bt.SegmentMidpoint){for(this.iteratePath||(this._segmentCount=t.length,this._curSegment=1,this.iteratePath=!0);this._curSegments){const u=(s-o)/c,[f,m]=this._curveHelper.getAngleCS(a,h,u),_=Qe(a,h,u),p=i?-this._offset:this._offset;return this.internalPlacement.setTranslate(_[0]-p*m,_[1]+p*f),this._angleToLine&&(i?this.internalPlacement.setRotateCS(-f,-m):this.internalPlacement.setRotateCS(f,m)),this.internalPlacement}o+=c}return null}}class Ft{static local(){return Ft.instance===null&&(Ft.instance=new Ft),Ft.instance}execute(t,e,s,i){return new Er(t,e,s)}}Ft.instance=null;const Rr=1e-15;class Er extends fe{constructor(t,e,s){super(t,!0,!0),this._curveHelper=new tt,this._angleToLine=e.angleToLine===void 0||e.angleToLine,this._offset=e.offset!==void 0?e.offset*s:0,this._endPoints=e.placeOnEndPoints===void 0||e.placeOnEndPoints,this._controlPoints=e.placeOnControlPoints===void 0||e.placeOnControlPoints,this._regularVertices=e.placeOnRegularVertices===void 0||e.placeOnRegularVertices,this._tags=[],this._tagIterator=0}processPath(t){if(this.iteratePath||(this._preparePath(t),this.iteratePath=!0),this._tagIterator>=this._tags.length)return this._tags.length=0,this._tagIterator=0,this.iteratePath=!1,null;const e=this._tags[this._tagIterator];this._angleToLine&&this.internalPlacement.setRotate(e[2]);let s=e[0],i=e[1];if(this._offset!==0){const n=Math.cos(e[2]),a=Math.sin(e[2]);s-=this._offset*a,i+=this._offset*n}return this.internalPlacement.setTranslate(s,i),this._tagIterator++,this.internalPlacement}_preparePath(t){this._tags.length=0,this._tagIterator=0;const e=ur(t),s=t.length-1;let i,n,a=0,o=0,h=0,l=0,c=0;for(;ae+2*Rr;)t-r>e?t-=2*e:t+=2*e;return(r+t)/2}class $r{constructor(t=Fr){this._data=[],this._compare=t}get size(){return this._data.length}enqueue(t){if(t==null)return;const{_data:e,_compare:s}=this;e.push(t);let i=e.length-1>>>0;const n=e[i];for(;i>0;){const a=i-1>>1,o=e[a];if(!(s(o,n)<=0))break;e[a]=n,e[i]=o,i=a}}dequeue(){const{_data:t,_compare:e}=this,s=t[0],i=t.pop();if(t.length===0)return s;t[0]=i;let n=0;const a=t.length,o=t[0];let h,l,c=null;for(;;){const u=2*n+1,f=2*n+2;if(c=null,u0&&(c=u)),frt?1:0,Gr=100*222045e-21;function Hr(r){const{rings:t}=r;if(!t||t.length===0)return null;const e=Zt(V(),r);if(!e)return null;const s=4*(Math.abs(e[0])+Math.abs(e[2])+Math.abs(e[1])+Math.abs(e[3])+1)*Gr;let i=0,n=0;for(let b=0;bn&&(n=w,i=b)}if(Math.abs(n)<=2*s*s){const b=We(V(),t[i]);return[(b[0]+b[2])/2,(b[1]+b[3])/2]}const a=Pi(t[i],!1,V());if(a===null)return null;if(t.length===1&&t[0].length<4)return a;const o=[[NaN,NaN],[NaN,NaN],[NaN,NaN],[NaN,NaN]],h=[NaN,NaN,NaN,NaN],l=[NaN,NaN,NaN,NaN];let c=!1,u=re(a,r,!0);u.distance===0&&(c=!0,o[0][0]=a[0],o[0][1]=a[1],u=re(a,r,!1)),h[0]=u.distance,l[0]=0;const f=[NaN,NaN];let m=!1,_=.25,p=-1;const d=We(V(),t[i]);let g=NaN;do if(g=NaN,o[1]=Ge(r,He(d[0],d[2],_),s,e),isNaN(o[1][0])||isNaN(o[1][1])||(u=re(o[1],r,!1),g=u.distance),!isNaN(g)&&g>s&&Ie(o[1],r))m=!0,h[1]=g,l[1]=gt(o[1],a);else if(!isNaN(g)&&g>p&&(p=g,f[0]=o[1][0],f[1]=o[1][1]),_-=.01,_<.1){if(!(p>=0))break;m=!0,h[1]=p,o[1][0]=f[0],o[1][1]=f[1],l[1]=gt(o[1],a)}while(!m);m=!1,_=.5,p=-1;let y=.01,P=1;do if(g=NaN,o[2]=Ge(r,He(d[0],d[2],_),s,e),isNaN(o[2][0])||isNaN(o[2][1])||(u=re(o[2],r,!1),g=u.distance),!isNaN(g)&&g>s&&Ie(o[2],r))m=!0,h[2]=g,l[2]=gt(o[2],a);else if(!isNaN(g)&&g>p)p=g,f[0]=o[2][0],f[1]=o[2][1];else if(g>p&&(p=g,f[0]=o[2][0],f[1]=o[2][1]),_=.5+y*P,y+=.01,P*=-1,_<.3||_>.7){if(!(p>=0))break;m=!0,h[2]=p,o[2][0]=f[0],o[2][1]=f[1],l[2]=gt(o[2],a)}while(!m);m=!1,_=.75,p=-1;do if(g=NaN,o[3]=Ge(r,He(d[0],d[2],_),s,e),isNaN(o[3][0])||isNaN(o[3][1])||(u=re(o[3],r,!1),g=u.distance),!isNaN(g)&&g>s&&Ie(o[3],r))m=!0,h[3]=g,l[3]=gt(o[3],a);else if(g>p&&(p=g,f[0]=o[3][0],f[1]=o[3][1]),_+=.01,_>.9){if(!(p>=0))break;m=!0,h[3]=p,o[3][0]=f[0],o[3][1]=f[1],l[3]=gt(o[3],a)}while(!m);const x=[0,1,2,3],M=c?0:1;let k;for(let b=M;b<4;b++)for(let w=M;w<3;w++){const N=l[w],H=l[w+1];Yr(N,H)>0&&(k=x[w],x[w]=x[w+1],x[w+1]=k,l[w]=H,l[w+1]=N)}let v=M,T=0,L=0;for(let b=M;b<4;b++){switch(b){case 0:L=2*h[x[b]];break;case 1:L=1.66666666*h[x[b]];break;case 2:L=1.33333333*h[x[b]];break;case 3:L=h[x[b]]}L>T&&(T=L,v=x[b])}return o[v]}function Ie(r,t){const{rings:e}=t;let s=0;for(const i of e){const n=i.length;for(let a=1;ar[1]!=h[1]>r[1]&&((h[0]-o[0])*(r[1]-o[1])-(h[1]-o[1])*(r[0]-o[0])>0?s++:s--)}}return s!==0}function re(r,t,e){if(e&&Ie(r,t))return{coord:r,distance:0};let s=1/0,i=0,n=0;const a=[0,0],{rings:o}=t;for(const h of o)if(!(h.length<2))for(let l=0;la?yu)s&bs?(s&Ce?(t[1]+=u*(n-t[0])/c,t[0]=n):(t[1]+=u*(o-t[0])/c,t[0]=o),s=j(t,r)):i&bs?(i&Ce?(e[1]+=u*(n-e[0])/c,e[0]=n):(e[1]+=u*(o-e[0])/c,e[0]=o),i=j(e,r)):s?(s&we?(t[0]+=c*(a-t[1])/u,t[1]=a):(t[0]+=c*(h-t[1])/u,t[1]=h),s=j(t,r)):(i&we?(e[0]+=c*(a-e[1])/u,e[1]=a):(e[0]+=c*(h-e[1])/u,e[1]=h),i=j(e,r));else if(s&Ms?(s&we?(t[0]+=c*(a-t[1])/u,t[1]=a):(t[0]+=c*(h-t[1])/u,t[1]=h),s=j(t,r)):i&Ms?(i&we?(e[0]+=c*(a-e[1])/u,e[1]=a):(e[0]+=c*(h-e[1])/u,e[1]=h),i=j(e,r)):s?(s&Ce?(t[1]+=u*(n-t[0])/c,t[0]=n):(t[1]+=u*(o-t[0])/c,t[0]=o),s=j(t,r)):(i&Ce?(e[1]+=u*(n-e[0])/c,e[0]=n):(e[1]+=u*(o-e[0])/c,e[0]=o),i=j(e,r)),s&i)return 0}while(s|i);return l}function j(r,t){return(r[0]t[2]?1:0)<<1|(r[1]t[3]?1:0)<<3}function He(r,t,e){return r+(t-r)*e}function gt(r,t){return(r[0]-t[0])*(r[0]-t[0])+(r[1]-t[1])*(r[1]-t[1])}function Yr(r,t){if(rt)return 1;if(r===t)return 0;const e=isNaN(r),s=isNaN(t);return es?1:0}class Ut{constructor(t,e,s,i){this.x=t,this.y=e,this.cellSize=s,this.distancefromCellCenter=Ci(t,e,i),this.maxDistanceToPolygon=this.distancefromCellCenter+this.cellSize*Math.SQRT2}}const Vr=1,Br=100;function Wr(r){if(!r||!r.rings||r.rings.length===0)return null;const t=We(V(),r.rings[0]);if(!t)return null;const e=t[2]-t[0],s=t[3]-t[1];if(e===0||s===0)return[t[0]+e/2,t[1]+s/2];const i=Math.max(Math.min(e,s)/Br,Vr),n=new $r((m,_)=>_.maxDistanceToPolygon-m.maxDistanceToPolygon),a=Math.min(e,s);let o=a/2,h=0,l=0;for(h=t[0];h0;)u=Si(n.dequeue()),u.distancefromCellCenter>f.distancefromCellCenter&&(f=u),u.maxDistanceToPolygon-f.distancefromCellCenter<=i||(o=u.cellSize/2,n.enqueue(new Ut(u.x-o,u.y-o,o,r)),n.enqueue(new Ut(u.x+o,u.y-o,o,r)),n.enqueue(new Ut(u.x-o,u.y+o,o,r)),n.enqueue(new Ut(u.x+o,u.y+o,o,r)));return[f.x,f.y]}function Ur(r){return r.rings!==void 0}class Gt{static local(){return Gt.instance===null&&(Gt.instance=new Gt),Gt.instance}execute(t,e,s,i){return new qr(t,e,s)}}Gt.instance=null;class qr{constructor(t,e,s){this._geometry=t,this._offsetX=e.offsetX!==void 0?e.offsetX*s:0,this._offsetY=e.offsetY!==void 0?e.offsetY*s:0,this._method=e.method!==void 0?e.method:ye.OnPolygon,this._internalPlacement=new te}next(){const t=this._geometry;return this._geometry=null,t&&Ur(t)?this._polygonCenter(t):null}_polygonCenter(t){let e=!1;switch(this._method){case ye.CenterOfMass:{const s=ki(t);s&&(this._internalPlacement.setTranslate(s[0]+this._offsetX,s[1]+this._offsetY),e=!0)}break;case ye.BoundingBoxCenter:{const s=V();Zt(s,t),s&&(this._internalPlacement.setTranslate((s[2]+s[0])/2+this._offsetX,(s[3]+s[1])/2+this._offsetY),e=!0)}break;case ye.OnPolygon:default:{let s;s=wi("polylabel-placement-enabled")?Wr(t):Hr(t),s!==null&&(this._internalPlacement.setTranslate(s[0]+this._offsetX,s[1]+this._offsetY),e=!0)}}return e?this._internalPlacement:null}}function Ze(r){if(!r)return null;switch(r.type){case"CIMGeometricEffectAddControlPoints":return Pt.local();case"CIMGeometricEffectArrow":return xt.local();case"CIMGeometricEffectBuffer":return bt.local();case"CIMGeometricEffectControlMeasureLine":return Mt.local();case"CIMGeometricEffectCut":return St.local();case"CIMGeometricEffectDashes":return Ct.local();case"CIMGeometricEffectDonut":return wt.local();case"CIMGeometricEffectJog":return kt.local();case"CIMGeometricEffectMove":return vt.local();case"CIMGeometricEffectOffset":return It.local();case"CIMGeometricEffectReverse":return Lt.local();case"CIMGeometricEffectRotate":return Tt.local();case"CIMGeometricEffectScale":return Nt.local();case"CIMGeometricEffectWave":return At.local()}return null}function Jr(r){if(!r)return null;switch(r.type){case"CIMMarkerPlacementAlongLineSameSize":return zt.local();case"CIMMarkerPlacementAtExtremities":return Ot.local();case"CIMMarkerPlacementAtRatioPositions":return Rt.local();case"CIMMarkerPlacementInsidePolygon":return Et.local();case"CIMMarkerPlacementOnLine":return $t.local();case"CIMMarkerPlacementOnVertices":return Ft.local();case"CIMMarkerPlacementPolygonCenter":return Gt.local()}return null}function De(r){const t=r.getFrame(0);if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement)return t;const e=document.createElement("canvas");e.width=r.width,e.height=r.height;const s=e.getContext("2d");return t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0),e}class ti{constructor(t=0,e=0,s=0,i=0){this.x=t,this.y=e,this.width=s,this.height=i}get isEmpty(){return this.width<=0||this.height<=0}union(t){this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.width=Math.max(this.width,t.width),this.height=Math.max(this.height,t.height)}}function jr(r){return`rgb(${r.slice(0,3).toString()})`}function Kr(r){return`rgba(${r.slice(0,3).toString()},${r[3]})`}class ei{constructor(t){t&&(this._textRasterizationCanvas=t)}rasterizeText(t,e){var T;this._textRasterizationCanvas||(this._textRasterizationCanvas=document.createElement("canvas"));const s=this._textRasterizationCanvas,i=s.getContext("2d");this._setFontProperties(i,e),this._parameters=e,this._textLines=t.split(/\r?\n/),this._lineHeight=this._computeLineHeight();const n=this._computeTextWidth(i,e),{decoration:a,weight:o}=e.font;this._lineThroughWidthOffset=a&&a==="line-through"?.1*this._lineHeight:0;const h=this._lineHeight*this._textLines.length;s.width=n+2*this._lineThroughWidthOffset,s.height=h,this._renderedLineHeight=Math.round(this._lineHeight*e.pixelRatio),this._renderedHaloSize=e.halo.size*e.pixelRatio,this._renderedWidth=n*e.pixelRatio,this._renderedHeight=h*e.pixelRatio,this._lineThroughWidthOffset*=e.pixelRatio;const l=(T=e.color)!=null?T:[0,0,0,0],c=e.halo&&e.halo.color?e.halo.color:[0,0,0,0];this._fillStyle=Kr(l),this._haloStyle=jr(c);const u=this._renderedLineHeight,f=this._renderedHaloSize;i.save(),i.clearRect(0,0,s.width,s.height),this._setFontProperties(i,e);const m=Qr(i.textAlign,this._renderedWidth)+f,_=f,p=f>0;let d=this._lineThroughWidthOffset,g=0;p&&this._renderHalo(i,m,_,d,g,e),g+=_,d+=m;for(const L of this._textLines)p?(i.globalCompositeOperation="destination-out",i.fillStyle="rgb(0, 0, 0)",i.fillText(L,d,g),i.globalCompositeOperation="source-over",i.fillStyle=this._fillStyle,i.fillText(L,d,g)):(i.fillStyle=this._fillStyle,i.fillText(L,d,g)),a&&a!=="none"&&this._renderDecoration(i,d,g,a,o),g+=u;i.restore();const y=this._renderedWidth+2*this._lineThroughWidthOffset,P=this._renderedHeight,x=i.getImageData(0,0,y,P),M=new Uint8Array(x.data);if(e.premultiplyColors){let L;for(let b=0;b600)&&(s+=.3*t.measureText("w").width),s+=2*this._parameters.halo.size,Math.round(s)}_computeLineHeight(){let t=1.275*this._parameters.size;const e=this._parameters.font.decoration;return e&&e==="underline"&&(t*=1.3),Math.round(t+2*this._parameters.halo.size)}_renderDecoration(t,e,s,i,n,a){const o=.9*this._lineHeight,h=n==="bold"?.06:n==="bolder"?.09:.04;switch(t.textAlign){case"center":e-=this._renderedWidth/2;break;case"right":e-=this._renderedWidth}const l=t.textBaseline;if(i==="underline")switch(l){case"top":s+=o;break;case"middle":s+=o/2}else if(i==="line-through")switch(l){case"top":s+=o/1.5;break;case"middle":s+=o/3}const c=a?1.5*a:Math.ceil(o*h);t.save(),t.beginPath(),t.strokeStyle=t.fillStyle,t.lineWidth=c,t.moveTo(e-this._lineThroughWidthOffset,s),t.lineTo(e+this._renderedWidth+2*this._lineThroughWidthOffset,s),t.stroke(),t.restore()}}function Qr(r,t){return r==="center"?.5*t:r==="right"?t:0}class Ht{constructor(t,e,s,i){this.center=vi(t,e),this.centerT=Ue(),this.halfWidth=s/2,this.halfHeight=i/2,this.width=s,this.height=i}get x(){return this.center[0]}get y(){return this.center[1]}get blX(){return this.center[0]+this.halfWidth}get blY(){return this.center[1]+this.halfHeight}get trX(){return this.center[0]-this.halfWidth}get trY(){return this.center[1]-this.halfHeight}get xmin(){return this.x-this.halfWidth}get xmax(){return this.x+this.halfWidth}get ymin(){return this.y-this.halfHeight}get ymax(){return this.y+this.halfHeight}set x(t){this.center[0]=t}set y(t){this.center[1]=t}clone(){return new Ht(this.x,this.y,this.width,this.height)}serialize(t){return t.writeF32(this.center[0]),t.writeF32(this.center[1]),t.push(this.width),t.push(this.height),t}findCollisionDelta(t,e=4){const s=Math.abs(t.centerT[0]-this.centerT[0]),i=Math.abs(t.centerT[1]-this.centerT[1]),n=(t.halfWidth+this.halfWidth+e)/s,a=(t.halfHeight+this.halfHeight+e)/i,o=Math.min(n,a);return Math.log2(o)}extend(t){const e=Math.min(this.xmin,t.xmin),s=Math.min(this.ymin,t.ymin),i=Math.max(this.xmax,t.xmax)-e,n=Math.max(this.ymax,t.ymax)-s,a=e+i/2,o=s+n/2;this.width=i,this.height=n,this.halfWidth=i/2,this.halfHeight=n/2,this.x=a,this.y=o}static deserialize(t){const e=t.readF32(),s=t.readF32(),i=t.readInt32(),n=t.readInt32();return new Ht(e,s,i,n)}}const ns=26,si=4,Zr=ns+si,tn=ns-6,Ss=3,ht=8,en=Math.PI/180;class ii{constructor(t,e,s,i){this._rotationT=oe(),this._xBounds=0,this._yBounds=0,this.minZoom=0,this.maxZoom=255,this._bounds=null;const n=s.rect,a=new Float32Array(8);t*=i,e*=i;const o=s.code?n.width*i:s.metrics.width,h=s.code?n.height*i:s.metrics.height;a[0]=t,a[1]=e,a[2]=t+o,a[3]=e,a[4]=t,a[5]=e+h,a[6]=t+o,a[7]=e+h,this._data=a,this._setTextureCoords(n),this._scale=i,this._mosaic=s,this.x=t,this.y=e,this.maxOffset=Math.max(t+o,e+h)}get width(){return this._mosaic.metrics.width*this._scale}get mosaic(){return this._mosaic}set angle(t){this._angle=t,Es(this._rotationT,-t),this._setOffsets(this._data)}get angle(){return this._angle}get xTopLeft(){return this._data[0]}get yTopLeft(){return this._data[1]}get xBottomRight(){return this._data[6]}get yBottomRight(){return this._data[7]}get texcoords(){return this._texcoords}get textureBinding(){return this._mosaic.textureBinding}get offsets(){return this._offsets||this._setOffsets(this._data),this._offsets}get char(){return String.fromCharCode(this._mosaic.code)}get code(){return this._mosaic.code}get bounds(){if(!this._bounds){const{height:t,width:e}=this._mosaic.metrics,s=e*this._scale,i=Math.abs(t)*this._scale,n=new Float32Array(8);n[0]=this.x,n[1]=this.y,n[2]=this.x+s,n[3]=this.y,n[4]=this.x,n[5]=this.y+i,n[6]=this.x+s,n[7]=this.y+i;const a=qe(oe(),this._rotationT,this._transform);fs(n,n,a);let o=1/0,h=1/0,l=0,c=0;for(let p=0;p<4;p++){const d=n[2*p],g=n[2*p+1];o=Math.min(o,d),h=Math.min(h,g),l=Math.max(l,d),c=Math.max(c,g)}const u=l-o,f=c-h,m=o+u/2,_=h+f/2;this._bounds=new Ht(m,_,u,f)}return this._bounds}setTransform(t){this._transform=t,this._offsets=null}_setOffsets(t){this._offsets||(this._offsets={upperLeft:0,upperRight:0,lowerLeft:0,lowerRight:0});const e=this._offsets,s=new Float32Array(8),i=qe(oe(),this._rotationT,this._transform);fs(s,t,i),e.upperLeft=ot(s[0]*ht,s[1]*ht),e.upperRight=ot(s[2]*ht,s[3]*ht),e.lowerLeft=ot(s[4]*ht,s[5]*ht),e.lowerRight=ot(s[6]*ht,s[7]*ht)}_setTextureCoords({x:t,y:e,width:s,height:i}){this._texcoords={upperLeft:ot(t,e),upperRight:ot(t+s,e),lowerLeft:ot(t,e+i),lowerRight:ot(t+s,e+i)}}}const sn=(r,t)=>({code:0,page:0,sdf:!0,rect:new Yi(0,0,11,8),textureBinding:t,metrics:{advance:0,height:4,width:r,left:0,top:0}});class rn{constructor(t,e,s){this._rotation=0,this._decorate(t,e,s),this.glyphs=t,this.bounds=this._createBounds(t),this.isMultiline=e.length>1,this._hasRotation=s.angle!==0,this._transform=this._createGlyphTransform(this.bounds,s);for(const i of t)i.setTransform(this._transform)}setRotation(t){if(t===0&&this._rotation===0)return;this._rotation=t;const e=this._transform,s=Es(oe(),t);qe(e,s,e);for(const i of this.glyphs)i.setTransform(this._transform)}_decorate(t,e,s){if(!s.decoration||s.decoration==="none"||!t.length)return;const i=s.scale,n=s.decoration==="underline"?Zr:tn,a=t[0].textureBinding;for(const o of e){const h=o.startX*i,l=o.startY*i,c=(o.width+o.glyphWidthEnd)*i;t.push(new ii(h,l+n*i,sn(c,a),1))}}get boundsT(){const t=this.bounds,e=_e(Ue(),t.x,t.y);if(Ii(e,e,this._transform),this._hasRotation){const s=Math.max(t.width,t.height);return new Ht(e[0],e[1],s,s)}return new Ht(e[0],e[1],t.width,t.height)}_createBounds(t){let e=1/0,s=1/0,i=0,n=0;for(const h of t)e=Math.min(e,h.xTopLeft),s=Math.min(s,h.yTopLeft),i=Math.max(i,h.xTopLeft+h.width),n=Math.max(n,h.yBottomRight);const a=i-e,o=n-s;return new Ht(e+a/2,s+o/2,a,o)}_createGlyphTransform(t,e){const s=en*e.angle,i=oe(),n=Ue();return ze(i,i,_e(n,e.xOffset,-e.yOffset)),e.isCIM?ms(i,i,s):(ze(i,i,_e(n,t.x,t.y)),ms(i,i,s),ze(i,i,_e(n,-t.x,-t.y))),i}}class ke{constructor(t,e,s,i,n,a){this.glyphWidthEnd=0,this.startX=0,this.startY=0,this.start=Math.max(0,Math.min(e,s)),this.end=Math.max(0,Math.max(e,s)),this.endr===10,Cs=r=>r===32;function nn(r,t,e){const s=new Array,i=1/e.scale,n=e.maxLineWidth*i,a=t?r.length-1:0,o=t?-1:r.length,h=t?-1:1;let l=a,c=0,u=0,f=l,m=f,_=0,p=1/0,d=0;for(;l!==o;){const{code:y,metrics:P}=r[l],x=Math.abs(P.top);if(ts(y)||Cs(y)||(p=Math.min(p,x),d=Math.max(d,x+P.height)),ts(y))l!==a&&(s.push(new ke(r,f,l-h,c,p,d)),p=1/0,d=0),c=0,f=l+h,m=l+h,u=0;else if(Cs(y))m=l+h,u=0,_=P.advance,c+=P.advance;else if(c>n){if(m!==f){const M=m-2*h;c-=_,s.push(new ke(r,f,M,c-u,p,d)),p=1/0,d=0,f=m,c=u}else s.push(new ke(r,f,l-h,c,p,d)),p=1/0,d=0,f=l,m=l,c=0;c+=P.advance,u+=P.advance}else c+=P.advance,u+=P.advance;l+=h}const g=new ke(r,f,l-h,c,p,d);return g.start>=0&&g.end1}back(){return this._transfos[this._transfos.length-1]}push(t,e){const s=e?t.scaleRatio():1;F.multiply(t,this.back(),t),this._transfos.push(t),this._sizeTransfos.push(this._sizeTransfos[this._sizeTransfos.length-1]*s)}pop(){this._transfos.splice(-1,1),this._sizeTransfos.splice(-1,1)}drawSymbol(t,e,s){if(t)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this.drawMultiLayerSymbol(t,e);break;case"CIMTextSymbol":this.drawTextSymbol(t,e,s)}}drawMultiLayerSymbol(t,e){if(!t)return;const s=t.symbolLayers;if(!s)return;const i=t.effects;if(i&&i.length>0){const n=this.executeEffects(i,e);if(n){let a=n.next();for(;a;)this.drawSymbolLayers(s,a),a=n.next()}}else this.drawSymbolLayers(s,e)}executeEffects(t,e){const s=this._resourceManager.geometryEngine;let i=new je(e);for(const n of t){const a=Ze(n);a&&(i=a.execute(i,n,this.geomUnitsPerPoint(),s))}return i}drawSymbolLayers(t,e){let s=t.length;for(;s--;){const i=t[s];if(!i||i.enable===!1)continue;const n=i.effects;if(n&&n.length>0){const a=this.executeEffects(n,e);if(a){let o=null;for(;(o=a.next())&&(this.drawSymbolLayer(i,o),!this._earlyReturn););}}else this.drawSymbolLayer(i,e);if(this._earlyReturn)return}}drawSymbolLayer(t,e){switch(t.type){case"CIMSolidFill":this.drawSolidFill(e,t.color);break;case"CIMHatchFill":this.drawHatchFill(e,t);break;case"CIMPictureFill":this.drawPictureFill(e,t);break;case"CIMGradientFill":this.drawGradientFill(e,t);break;case"CIMSolidStroke":this.drawSolidStroke(e,t.color,t.width,t.capStyle,t.joinStyle,t.miterLimit);break;case"CIMPictureStroke":this.drawPictureStroke(e,t);break;case"CIMGradientStroke":this.drawGradientStroke(e,t);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":this.drawMarkerLayer(t,e)}}drawHatchFill(t,e){const s=this._buildHatchPolyline(e,t,this.geomUnitsPerPoint());s&&(this.pushClipPath(t),this.drawMultiLayerSymbol(e.lineSymbol,s),this.popClipPath())}drawPictureFill(t,e){}drawGradientFill(t,e){}drawPictureStroke(t,e){}drawGradientStroke(t,e){}drawMarkerLayer(t,e){const s=t.markerPlacement;if(s){const i=Jr(s);if(i){const n=s.type==="CIMMarkerPlacementInsidePolygon"||s.type==="CIMMarkerPlacementPolygonCenter"&&s.clipAtBoundary;n&&this.pushClipPath(e);const a=i.execute(e,s,this.geomUnitsPerPoint(),this._resourceManager.geometryEngine);if(a){let o=null;for(;(o=a.next())&&(this.drawMarker(t,o),!this._earlyReturn););}n&&this.popClipPath()}}else{const i=this._placementPool.acquire();if(ut(e))i.tx=e.x,i.ty=e.y,this.drawMarker(t,i);else if(z(e))[i.tx,i.ty]=Ni(e),this.drawMarker(t,i);else for(const n of e.points)if(i.tx=n[0],i.ty=n[1],this.drawMarker(t,i),this._earlyReturn)break;this._placementPool.release(i)}}drawMarker(t,e){switch(t.type){case"CIMCharacterMarker":case"CIMPictureMarker":this.drawPictureMarker(t,e);break;case"CIMVectorMarker":this.drawVectorMarker(t,e)}}drawPictureMarker(t,e){var d,g,y,P,x;if(!t)return;const s=this._resourceManager.getResource(t.url),i=(d=t.size)!=null?d:10;if(at(s)||i<=0)return;const n=s.width,a=s.height;if(!n||!a)return;const o=n/a,h=(g=t.scaleX)!=null?g:1,l=F.createIdentity(),c=t.anchorPoint;if(c){let M=c.x,k=c.y;t.anchorPointUnits!=="Absolute"&&(M*=i*o*h,k*=i),l.translate(-M,-k)}let u=(y=t.rotation)!=null?y:0;t.rotateClockwise&&(u=-u),this._mapRotation&&(u+=this._mapRotation),u&&l.rotate(u*dt);let f=(P=t.offsetX)!=null?P:0,m=(x=t.offsetY)!=null?x:0;if(f||m){if(this._mapRotation){const M=dt*this._mapRotation,k=Math.cos(M),v=Math.sin(M),T=f*v+m*k;f=f*k-m*v,m=T}l.translate(f,m)}const _=this.geomUnitsPerPoint();_!==1&&l.scale(_,_);const p=e.getAngle();p&&l.rotate(p),l.translate(e.tx,e.ty),this.push(l,!1),this.drawImage(t,i),this.pop()}drawVectorMarker(t,e){var p,d,g,y;if(!t)return;const s=t.markerGraphics;if(!s)return;const i=(p=t.size)!=null?p:10,n=t.frame,a=n?n.ymax-n.ymin:0,o=i&&a?i/a:1,h=F.createIdentity();n&&h.translate(.5*-(n.xmax+n.xmin),.5*-(n.ymax+n.ymin));const l=t.anchorPoint;if(l){let P=l.x,x=l.y;t.anchorPointUnits!=="Absolute"?n&&(P*=n.xmax-n.xmin,x*=n.ymax-n.ymin):(P/=o,x/=o),h.translate(-P,-x)}o!==1&&h.scale(o,o);let c=(d=t.rotation)!=null?d:0;t.rotateClockwise&&(c=-c),this._mapRotation&&(c+=this._mapRotation),c&&h.rotate(c*dt);let u=(g=t.offsetX)!=null?g:0,f=(y=t.offsetY)!=null?y:0;if(u||f){if(this._mapRotation){const P=dt*this._mapRotation,x=Math.cos(P),M=Math.sin(P),k=u*M+f*x;u=u*x-f*M,f=k}h.translate(u,f)}const m=this.geomUnitsPerPoint();m!==1&&h.scale(m,m);const _=e.getAngle();_&&h.rotate(_),h.translate(e.tx,e.ty),this.push(h,t.scaleSymbolsProportionally);for(const P of s)if(P&&P.symbol&&P.geometry||ni.error("Invalid marker graphic",P),this.drawSymbol(P.symbol,P.geometry,P.textString),this._earlyReturn)break;this.pop()}drawTextSymbol(t,e,s){var l,c,u,f;if(!t||!ut(e)||((l=t.height)!=null?l:10)<=0)return;const i=F.createIdentity();let n=(c=t.angle)!=null?c:0;n=-n,n&&i.rotate(n*dt);const a=(u=t.offsetX)!=null?u:0,o=(f=t.offsetY)!=null?f:0;(a||o)&&i.translate(a,o);const h=this.geomUnitsPerPoint();h!==1&&i.scale(h,h),i.translate(e.x,e.y),this.push(i,!1),this.drawText(t,s),this.pop()}_buildHatchPolyline(t,e,s){let i=(t.separation!==void 0?t.separation:4)*s,n=t.rotation!==void 0?t.rotation:0;if(i===0)return null;i<0&&(i=-i);let a=0;const o=.5*i;for(;a>o;)a-=i;for(;a<-o;)a+=i;const h=V();Zt(h,e),h[0]-=o,h[1]-=o,h[2]+=o,h[3]+=o;const l=[[h[0],h[1]],[h[0],h[3]],[h[2],h[3]],[h[2],h[1]]];for(;n>180;)n-=180;for(;n<0;)n+=180;const c=Math.cos(n*dt),u=Math.sin(n*dt),f=-i*u,m=i*c;let _,p,d,g;a=(t.offsetX!==void 0?t.offsetX*s:0)*u-(t.offsetY!==void 0?t.offsetY*s:0)*c,_=d=Number.MAX_VALUE,p=g=-Number.MAX_VALUE;for(const T of l){const L=T[0],b=T[1],w=c*L+u*b,N=-u*L+c*b;_=Math.min(_,w),d=Math.min(d,N),p=Math.max(p,w),g=Math.max(g,N)}d=Math.floor(d/i)*i;let y=c*_-u*d-f*a/i,P=u*_+c*d-m*a/i,x=c*p-u*d-f*a/i,M=u*p+c*d-m*a/i;const k=1+Math.round((g-d)/i),v=[];for(let T=0;T0))if(z(t))this._processPath(t.rings,0);else if(O(t))this._processPath(t.paths,0);else if($(t)){const e=yt(t);e&&this._processPath(e.rings,0)}else console.error("drawSolidFill Unexpected geometry type!")}drawSolidStroke(t,e,s){if(!t||this._clipCount>0)return;const i=.5*this.transformSize(s);if(z(t))this._processPath(t.rings,i);else if(O(t))this._processPath(t.paths,i);else if($(t)){const n=yt(t);n&&this._processPath(n.rings,i)}else console.error("drawSolidStroke unexpected geometry type!")}drawMarkerLayer(t,e){z(e)&&t.markerPlacement&&(t.markerPlacement.type==="CIMMarkerPlacementInsidePolygon"||t.markerPlacement.type==="CIMMarkerPlacementPolygonCenter"&&t.markerPlacement.clipAtBoundary)?this._processPath(e.rings,0):super.drawMarkerLayer(t,e)}drawHatchFill(t,e){this.drawSolidFill(t)}drawPictureFill(t,e){this.drawSolidFill(t)}drawGradientFill(t,e){this.drawSolidFill(t)}drawPictureStroke(t,e){this.drawSolidStroke(t,null,e.width)}drawGradientStroke(t,e){this.drawSolidStroke(t,null,e.width)}pushClipPath(t){this.drawSolidFill(t),this._clipCount++}popClipPath(){this._clipCount--}drawImage(t,e){var h;const{url:s}=t,i=(h=t.scaleX)!=null?h:1;let n=i*e,a=e;const o=this._resourceManager.getResource(s);!e&&q(o)&&(n=i*o.width,a=o.height),this._merge(this.transformPt([-n/2,-a/2]),0),this._merge(this.transformPt([-n/2,a/2]),0),this._merge(this.transformPt([n/2,-a/2]),0),this._merge(this.transformPt([n/2,a/2]),0)}drawText(t,e){if(!e||e.length===0)return;this._textRasterizer||(this._textRasterizer=new ei);const s=li(t),[i,n]=this._textRasterizer.computeTextSize(e,s);let a=0;switch(t.horizontalAlignment){case"Left":a=i/2;break;case"Right":a=-i/2}let o=0;switch(t.verticalAlignment){case"Bottom":o=n/2;break;case"Top":o=-n/2;break;case"Baseline":o=n/6}this._merge(this.transformPt([-i/2+a,-n/2+o]),0),this._merge(this.transformPt([-i/2+a,n/2+o]),0),this._merge(this.transformPt([i/2+a,-n/2+o]),0),this._merge(this.transformPt([i/2+a,n/2+o]),0)}_processPath(t,e){if(t)for(const s of t){const i=s?s.length:0;if(i>1){this._merge(this.transformPt(s[0]),e);for(let n=1;nthis._xmax&&(this._xmax=t[0]+e),t[1]-ethis._ymax&&(this._ymax=t[1]+e)}}class Pa extends as{constructor(){super(...arguments),this._searchPoint=[0,0],this._searchDistPoint=0}hitTest(t,e,s,i,n,a){const o=a*Kt(1);this.setTransform(),this.setGeomUnitsPerPoint(o),this._searchPoint=[(t[0]+t[2])/2,(t[1]+t[3])/2],this._searchDistPoint=(t[2]-t[0])/2/o,this._textInfo=i;const h=e&&(e.type==="CIMPointSymbol"&&e.angleAlignment!=="Map"||e.type==="CIMTextSymbol");return this._mapRotation=h?n:0,this._earlyReturn=!1,this.drawSymbol(e,s),this._earlyReturn}drawSolidFill(t,e){this._hitTestFill(t)}drawHatchFill(t,e){this._hitTestFill(t)}drawPictureFill(t,e){this._hitTestFill(t)}drawGradientFill(t,e){this._hitTestFill(t)}drawSolidStroke(t,e,s,i,n,a){this._hitTestStroke(t,s)}drawPictureStroke(t,e){this._hitTestStroke(t,e.width)}drawGradientStroke(t,e){this._hitTestStroke(t,e.width)}drawMarkerLayer(t,e){t.markerPlacement&&(t.markerPlacement.type==="CIMMarkerPlacementInsidePolygon"||t.markerPlacement.type==="CIMMarkerPlacementPolygonCenter"&&t.markerPlacement.clipAtBoundary)?this._hitTestFill(e):super.drawMarkerLayer(t,e)}pushClipPath(t){}popClipPath(){}drawImage(t,e){var c;const{url:s}=t,i=(c=t.scaleX)!=null?c:1,n=this._resourceManager.getResource(s);if(at(n)||n.height===0||e===0)return;const a=e*this.geomUnitsPerPoint(),o=a*i*(n.width/n.height),h=this.reverseTransformPt(this._searchPoint),l=this._searchDistPoint;Math.abs(h[0])g.xTopLeft&&m-g.yBottomRight&&_<-g.yTopLeft){this._earlyReturn=!0;break}}_hitTestFill(t){let e=null;if($(t)){const i=t;e=[[[i.xmin,i.ymin],[i.xmin,i.ymax],[i.xmax,i.ymax],[i.xmax,i.ymin],[i.xmin,i.ymin]]]}else if(z(t))e=t.rings;else{if(!O(t))return;e=t.paths}const s=this.reverseTransformPt(this._searchPoint);if(this._pointInPolygon(s,e)&&(this._earlyReturn=!0),!this._earlyReturn){const i=this.reverseTransformSize(this._searchDistPoint)*this.geomUnitsPerPoint();this._nearLine(s,e,i)&&(this._earlyReturn=!0)}}_hitTestStroke(t,e){let s=null;if($(t)){const o=t;s=[[[o.xmin,o.ymin],[o.xmin,o.ymax],[o.xmax,o.ymax],[o.xmax,o.ymin],[o.xmin,o.ymin]]]}else if(z(t))s=t.rings;else{if(!O(t))return;s=t.paths}const i=this.reverseTransformPt(this._searchPoint),n=e*this.geomUnitsPerPoint(),a=this.reverseTransformSize(this._searchDistPoint)*this.geomUnitsPerPoint();this._nearLine(i,s,n/2+a)&&(this._earlyReturn=!0)}_pointInPolygon(t,e){let s=0;for(const i of e){const n=i.length;for(let a=1;at[1]!=h[1]>t[1]&&((h[0]-o[0])*(t[1]-o[1])-(h[1]-o[1])*(t[0]-o[0])>0?s++:s--)}}return s!==0}_nearLine(t,e,s){for(const i of e){const n=i.length;for(let a=1;a-s&&u1){let a=this.transformPt(i[0]);s.moveTo(a[0],a[1]);for(let o=1;or?{spatialReference:r.spatialReference,rings:[[[r.xmin,r.ymin],[r.xmin,r.ymax],[r.xmax,r.ymax],[r.xmax,r.ymin],[r.xmin,r.ymin]]]}:null,ai=r=>{switch(r){case"Left":return Pe.Left;case"Right":return Pe.Right;case"Center":return Pe.Center;case"Justify":return ni.warnOnce("Horizontal alignment 'justify' is not implemented. Falling back to 'center'."),Pe.Center}},oi=r=>{switch(r){case"Top":return ae.Top;case"Center":return ae.Center;case"Bottom":return ae.Bottom;case"Baseline":return ae.Baseline}},hi=(r,t,e)=>{switch(r){case"ExtraLeading":return 1+t/e;case"Multiple":return t;case"Exact":return t/e}};function li(r,t=1){const e=Ws(r),s=Bs(r.fontStyleName),i=is(r.fontFamilyName),{weight:n,style:a}=s,o=t*(r.height||5),h=Us(r.horizontalAlignment),l=qs(r.verticalAlignment),c=Dt(r),u=Xt(r.haloSymbol),f=u?t*(0|r.haloSize):0;return{color:c,size:o,horizontalAlignment:h,verticalAlignment:l,font:{family:i,style:er(a),weight:sr(n),decoration:e},halo:{size:f||0,color:u,style:a},pixelRatio:1,premultiplyColors:!0}}const un=1e-4;function fn(r){let t,e,s,i,n,a=r[0],o=1;for(;oUi(s,t,e,i,n);case"esriGeometryPolygon":return(e,s,i,n)=>Wi(s,t,e,i,n);case"esriGeometryPolyline":return(e,s,i,n)=>Bi(s,t,e,i,n);case"esriGeometryMultipoint":return(e,s,i,n)=>Vi(s,t,e,i,n);default:return ce.getLogger("esri.views.2d.support.arcadeOnDemand").error(new Ai("mapview-arcade",`Unable to handle geometryType: ${r}`)),e=>e}}const ci=Math.PI,_n=ci/2,dn=4,gn=10,K=96/72,ws=Math.PI/180,es=ce.getLogger("esri.symbols.cim.CIMSymbolHelper");function xa(r){if(!r||!r.type)return null;let t;switch(r.type){case"cim":return r.data;case"web-style":return r;case"simple-marker":t=U.fromSimpleMarker(r);break;case"picture-marker":t=U.fromPictureMarker(r);break;case"simple-line":t=U.fromSimpleLineSymbol(r);break;case"simple-fill":t=U.fromSimpleFillSymbol(r);break;case"picture-fill":t=U.fromPictureFillSymbol(r);break;case"text":t=U.fromTextSymbol(r)}return{type:"CIMSymbolReference",symbol:t}}function Le(r,t,e){switch(t.type){case"CIMSymbolReference":return Le(r,t.symbol,e);case"CIMPointSymbol":e==null&&(e={x:0,y:0}),r.drawSymbol(t,e);break;case"CIMLineSymbol":e==null&&(e={paths:[[[0,0],[10,0]]]}),r.drawSymbol(t,e);break;case"CIMPolygonSymbol":e==null&&(e={rings:[[[0,0],[0,10],[10,10],[10,0],[0,0]]]}),r.drawSymbol(t,e);break;case"CIMTextSymbol":{const s={x:0,y:0};r.drawSymbol(t,s);break}case"CIMVectorMarker":{const s=new te;r.drawMarker(t,s);break}}return r.envelope()}function yn(r){if(!r)return 0;switch(r.type){case"CIMMarkerPlacementAlongLineSameSize":case"CIMMarkerPlacementAlongLineRandomSize":case"CIMMarkerPlacementAtExtremities":case"CIMMarkerPlacementAtMeasuredUnits":case"CIMMarkerPlacementAtRatioPositions":case"CIMMarkerPlacementOnLine":case"CIMMarkerPlacementOnVertices":return Math.abs(r.offset);default:return 0}}function Pn(r){if(!r)return 0;switch(r.type){case"CIMGeometricEffectArrow":return Math.abs(.5*r.width);case"CIMGeometricEffectBuffer":return Math.abs(r.size);case"CIMGeometricEffectExtension":case"CIMGeometricEffectRadial":return Math.abs(r.length);case"CIMGeometricEffectJog":return Math.abs(.5*r.length);case"CIMGeometricEffectMove":return Math.max(Math.abs(C(r.offsetX)),Math.abs(C(r.offsetY)));case"CIMGeometricEffectOffset":case"CIMGeometricEffectOffsetTangent":return Math.abs(r.offset);case"CIMGeometricEffectRegularPolygon":return Math.abs(r.radius);case"CIMGeometricEffectRotate":case"CIMGeometricEffectScale":default:return 0;case"CIMGeometricEffectTaperedPolygon":return .5*Math.max(Math.abs(r.fromWidth),Math.abs(r.toWidth));case"CIMGeometricEffectWave":return Math.abs(r.amplitude)}}function ks(r){if(!r)return 0;let t=0;for(const e of r)t+=Pn(e);return t}class ba{getSymbolInflateSize(t,e,s,i,n){return t||(t=[0,0,0,0]),e?this._getInflateSize(t,e,s,i,n):t}static safeSize(t){const e=Math.max(Math.abs(t[0]),Math.abs(t[2])),s=Math.max(Math.abs(t[1]),Math.abs(t[3]));return Math.sqrt(e*e+s*s)}_vectorMarkerBounds(t,e,s,i){let n=!0;const a=V();if(e&&e.markerGraphics)for(const o of e.markerGraphics){const h=[0,0,0,0];o.geometry&&(Zt(a,o.geometry),h[0]=0,h[1]=0,h[2]=0,h[3]=0,this.getSymbolInflateSize(h,o.symbol,s,0,i),a[0]+=h[0],a[1]+=h[1],a[2]+=h[2],a[3]+=h[3],n?(t[0]=a[0],t[1]=a[1],t[2]=a[2],t[3]=a[3],n=!1):(t[0]=Math.min(t[0],a[0]),t[1]=Math.min(t[1],a[1]),t[2]=Math.max(t[2],a[2]),t[3]=Math.max(t[3],a[3])))}return t}_getInflateSize(t,e,s,i,n){if(wn(e)){const a=this._getLayersInflateSize(t,e.symbolLayers,s,i,n),o=ks(e.effects);return o>0&&(a[0]-=o,a[1]-=o,a[2]+=o,a[3]+=o),a}return this._getTextInflatedSize(t,e,n)}_getLayersInflateSize(t,e,s,i,n){let a=!0;if(!e)return t;for(const o of e){if(!o)continue;let h=[0,0,0,0];switch(o.type){case"CIMSolidFill":case"CIMPictureFill":case"CIMHatchFill":case"CIMGradientFill":break;case"CIMSolidStroke":case"CIMPictureStroke":case"CIMGradientStroke":{const c=o;let u=c.width;c.capStyle===rt.Square||c.joinStyle===nt.Miter?u/=1.4142135623730951:u/=2,h[0]=-u,h[1]=-u,h[2]=u,h[3]=u;break}case"CIMCharacterMarker":case"CIMVectorMarker":case"CIMPictureMarker":{const c=o;if(o.type==="CIMVectorMarker"){const p=o;if(h=this._vectorMarkerBounds(h,p,s,n),p.frame){const d=(p.frame.xmin+p.frame.xmax)/2,g=(p.frame.ymin+p.frame.ymax)/2;h[0]-=d,h[1]-=g,h[2]-=d,h[3]-=g;const y=p.size/(p.frame.ymax-p.frame.ymin);h[0]*=y,h[1]*=y,h[2]*=y,h[3]*=y}}else if(o.type==="CIMPictureMarker"){const p=o,d=s.getResource(p.url);let g=1;q(d)&&d.height&&(g=d.width/d.height);const y=c.size/2,P=c.size*g*p.scaleX/2;h=[-P,-y,P,y]}else{const p=c.size/2;h=[-p,-p,p,p]}if(c.anchorPoint){let p,d;c.anchorPointUnits==="Absolute"?(p=c.anchorPoint.x,d=c.anchorPoint.y):(p=c.anchorPoint.x*(h[2]-h[0]),d=c.anchorPoint.y*(h[3]-h[1])),h[0]-=p,h[1]-=d,h[2]-=p,h[3]-=d}let u=C(c.rotation);if(c.rotateClockwise&&(u=-u),i&&(u-=i),u){const p=ws*u,d=Math.cos(p),g=Math.sin(p),y=V([be,be,-be,-be]);de(y,[h[0]*d-h[1]*g,h[0]*g+h[1]*d]),de(y,[h[0]*d-h[3]*g,h[0]*g+h[3]*d]),de(y,[h[2]*d-h[1]*g,h[2]*g+h[1]*d]),de(y,[h[2]*d-h[3]*g,h[2]*g+h[3]*d]),h=y}let f=C(c.offsetX),m=C(c.offsetY);if(i){const p=ws*i,d=Math.cos(p),g=Math.sin(p),y=f*g+m*d;f=f*d-m*g,m=y}h[0]+=f,h[1]+=m,h[2]+=f,h[3]+=m;const _=yn(c.markerPlacement);_>0&&(h[0]-=_,h[1]-=_,h[2]+=_,h[3]+=_);break}}const l=ks(o.effects);l>0&&(h[0]-=l,h[1]-=l,h[2]+=l,h[3]+=l),a?(t[0]=h[0],t[1]=h[1],t[2]=h[2],t[3]=h[3],a=!1):(t[0]=Math.min(t[0],h[0]),t[1]=Math.min(t[1],h[1]),t[2]=Math.max(t[2],h[2]),t[3]=Math.max(t[3],h[3]))}return t}_getTextInflatedSize(t,e,s){var f,m;const i=(f=e.height)!=null?f:gn;if(t[0]=-i/2,t[1]=-i/2,t[2]=i/2,t[3]=i/2,!s)return t;const n=s.get(e);if(!n)return t;const{text:a,mosaicItem:o}=n;if(!o||o.glyphMosaicItems.length===0)return t;const h=hi(e.lineGapType,(m=e.lineGap)!=null?m:0,i),l=rs(a)[1],c=o.glyphMosaicItems,u=ri(c,l,{scale:i/Fs,angle:C(e.angle),xOffset:C(e.offsetX),yOffset:C(e.offsetY),hAlign:ai(e.horizontalAlignment),vAlign:oi(e.verticalAlignment),maxLineWidth:512,lineHeight:Gs*Math.max(.25,Math.min(h||1,4)),decoration:e.font.decoration||"none",isCIM:!0}).boundsT;return t[0]=u.x-u.halfWidth,t[1]=-u.y-u.halfHeight,t[2]=u.x+u.halfWidth,t[3]=-u.y+u.halfHeight,t}}class U{static getEnvelope(t,e,s){const i=new hn(s);if(Array.isArray(t)){let n;for(const a of t)n?n.union(Le(i,a,e)):n=Le(i,a,e);return n}return Le(i,t,e)}static getTextureAnchor(t,e){const s=this.getEnvelope(t,null,e);if(!s)return[0,0,0];const i=(s.x+.5*s.width)*K,n=(s.y+.5*s.height)*K,a=s.width*K+2,o=s.height*K+2;return[-i/a,-n/o,o]}static rasterize(t,e,s,i,n=!0){const a=s||this.getEnvelope(e,null,i);if(!a)return[null,0,0,0,0];const o=(a.x+.5*a.width)*K,h=(a.y+.5*a.height)*K;t.width=a.width*K,t.height=a.height*K,s||(t.width+=2,t.height+=2);const l=t.getContext("2d"),c=F.createScale(K,-K);c.translate(.5*t.width-o,.5*t.height+h);const u=new ln(l,i,c);switch(e.type){case"CIMPointSymbol":{const _={type:"point",x:0,y:0};u.drawSymbol(e,_);break}case"CIMVectorMarker":{const _=new te;u.drawMarker(e,_);break}}const f=l.getImageData(0,0,t.width,t.height),m=new Uint8Array(f.data);if(n){let _;for(let p=0;p.667?Kt(Math.round(qt(f.width))):f.width,color:W(f.color)})}else!e||t.type!=="line-marker"||t.style!=="cross"&&t.style!=="x"||c.push({type:"CIMSolidStroke",enable:!0,width:e,color:W(n)});c.push({type:"CIMSolidFill",enable:!0,color:W(n)});const u={type:"CIMPolygonSymbol",symbolLayers:c};h={type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,rotation:C(-t.angle),size:C(t.size||6*e),offsetX:C(t.xoffset),offsetY:C(t.yoffset),frame:a,markerGraphics:[{type:"CIMMarkerGraphic",geometry:o,symbol:u}]}]}}return h}static fromCIMHatchFill(t,e){var u;const s=e*((u=t.separation)!=null?u:dn),i=s/2,n=4,a=R(t.lineSymbol);let o=this._getLineSymbolPeriod(a)||n;for(;of.type==="CIMSolidStroke");return c&&(c.width*=e),{type:"CIMVectorMarker",frame:l,markerGraphics:[{type:"CIMMarkerGraphic",geometry:{paths:[[[-h,0],[h,0]]]},symbol:a}],size:s}}static fetchResources(t,e,s){if(t&&e)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":{const i=t.symbolLayers;if(!i)return;for(const n of i)switch(In(n,e,s),n.type){case"CIMPictureFill":case"CIMHatchFill":case"CIMGradientFill":case"CIMPictureStroke":case"CIMGradientStroke":case"CIMCharacterMarker":case"CIMPictureMarker":"url"in n&&n.url&&s.push(e.fetchResource(n.url,null));break;case"CIMVectorMarker":{const a=n.markerGraphics;if(!a)continue;for(const o of a)if(o){const h=o.symbol;h&&U.fetchResources(h,e,s)}}}}}}static _getLineSymbolPeriod(t){if(t){const e=this._getEffectsRepeat(t.effects);if(e)return e;if(t.symbolLayers){for(const s of t.symbolLayers)if(s){const i=this._getEffectsRepeat(s.effects);if(i)return i;switch(s.type){case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":case"CIMObjectMarker3D":case"CIMglTFMarker3D":{const n=this._getPlacementRepeat(s.markerPlacement);if(n)return n}}}}}return 0}static _getEffectsRepeat(t){if(t){for(const e of t)if(e)switch(e.type){case"CIMGeometricEffectDashes":{const s=e.dashTemplate;if(s&&s.length){let i=0;for(const n of s)i+=n;return 1&s.length&&(i*=2),i}break}case"CIMGeometricEffectWave":return e.period;default:es.error(`unsupported geometric effect type ${e.type}`)}}return 0}static _getPlacementRepeat(t){if(t)switch(t.type){case"CIMMarkerPlacementAlongLineSameSize":case"CIMMarkerPlacementAlongLineRandomSize":case"CIMMarkerPlacementAlongLineVariableSize":{const e=t.placementTemplate;if(e&&e.length){let s=0;for(const i of e)s+=i;return 1&e.length&&(s*=2),s}break}}return 0}static fromCIMInsidePolygon(t){var u;const e=t.markerPlacement,s={type:t.type,...t};s.markerPlacement=null,s.anchorPoint=null;const i=Math.abs(e.stepX),n=Math.abs(e.stepY),a=((u=e.randomness)!=null?u:100)/100;let o,h,l,c;if(e.gridType==="Random"){const f=qt(Hs),m=Math.max(Math.floor(f/i),1),_=Math.max(Math.floor(f/n),1);o=m*i/2,h=_*n/2,l=2*h;const p=new Rs(e.seed),d=a*i/1.5,g=a*n/1.5;c=[];for(let y=0;y({type:"CIMMarkerGraphic",geometry:f,symbol:{type:"CIMPointSymbol",symbolLayers:[s]}})),size:l}}static getSize(t){if(t)switch(t.type){case"CIMTextSymbol":return t.height;case"CIMPointSymbol":{let e=0;if(t.symbolLayers){for(const s of t.symbolLayers)if(s)switch(s.type){case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":case"CIMObjectMarker3D":case"CIMglTFMarker3D":{const i=s.size;i>e&&(e=i);break}}}return e}case"CIMLineSymbol":case"CIMPolygonSymbol":{let e=0;if(t.symbolLayers){for(const s of t.symbolLayers)if(s)switch(s.type){case"CIMSolidStroke":case"CIMPictureStroke":case"CIMGradientStroke":{const i=s.width;i>e&&(e=i);break}case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":case"CIMObjectMarker3D":case"CIMglTFMarker3D":if(Qi(s.markerPlacement)){const i=s.size;i>e&&(e=i)}}}return e}}}static getMarkerScaleRatio(t){if(t&&t.type==="CIMVectorMarker"&&t.scaleSymbolsProportionally!==!1&&t.frame){const e=t.frame.ymax-t.frame.ymin;return t.size/e}return 1}}class A{static findApplicableOverrides(t,e,s){if(t&&e){if(t.primitiveName){let i=!1;for(const n of s)if(n.primitiveName===t.primitiveName){i=!0;break}if(!i)for(const n of e)n.primitiveName===t.primitiveName&&s.push(n)}switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(t.effects)for(const i of t.effects)A.findApplicableOverrides(i,e,s);if(t.symbolLayers)for(const i of t.symbolLayers)A.findApplicableOverrides(i,e,s);break;case"CIMTextSymbol":break;case"CIMSolidStroke":case"CIMPictureStroke":case"CIMGradientStroke":case"CIMSolidFill":case"CIMPictureFill":case"CIMHatchFill":case"CIMGradientFill":case"CIMVectorMarker":case"CIMCharacterMarker":case"CIMPictureMarker":if(t.effects)for(const i of t.effects)A.findApplicableOverrides(i,e,s);if(t.markerPlacement&&A.findApplicableOverrides(t.markerPlacement,e,s),t.type==="CIMVectorMarker"){if(t.markerGraphics)for(const i of t.markerGraphics)A.findApplicableOverrides(i,e,s),A.findApplicableOverrides(i.symbol,e,s)}else t.type==="CIMCharacterMarker"?A.findApplicableOverrides(t.symbol,e,s):t.type==="CIMHatchFill"?A.findApplicableOverrides(t.lineSymbol,e,s):t.type==="CIMPictureMarker"&&A.findApplicableOverrides(t.animatedSymbolProperties,e,s)}}}static findEffectOverrides(t,e,s){var n;if(!e||!t)return;const i=t.length;for(let a=0;a{var m;return!((m=f.valueExpressionInfo)!=null&&m.expression.includes("$feature"))})),o||(l=l.filter(f=>{var m;return!((m=f.valueExpressionInfo)!=null&&m.expression.includes("$view"))})),l.length>0){const f=ir(e.attributes);await A.evaluateOverrides(l,e,{spatialReference:s,fields:f,geometryType:n},a,o)}A.applyOverrides(h,l)}return i&&A.applyDictionaryTextOverrides(h,e,i),h}static async evaluateOverrides(t,e,s,i,n){if(!e)return;let a;for(const o of t){const h=o.valueExpressionInfo;if(h&&s){a||(a=[]),o.value=void 0;const l=$s(h.expression,s.spatialReference,s.fields).then(c=>{o.value=ee(c,e,{$view:n},s.geometryType,i)});a.push(l)}}a!==void 0&&a.length>0&&await Promise.all(a)}static applyDictionaryTextOverrides(t,e,s,i="Normal"){if(t&&t.type)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":case"CIMTextSymbol":{const n=t.symbolLayers;if(!n)return;for(const a of n)a&&a.type==="CIMVectorMarker"&&A.applyDictionaryTextOverrides(a,e,s,t.type==="CIMTextSymbol"?t.textCase:i)}break;case"CIMVectorMarker":{const n=t.markerGraphics;if(!n)return;for(const a of n)a&&A.applyDictionaryTextOverrides(a,e,s)}break;case"CIMMarkerGraphic":{const n=t.textString;if(n&&n.includes("[")){const a=Xs(n,s);t.textString=Ys(e,a,i)}}}}static applyOverrides(t,e,s,i){if(t.primitiveName){for(const n of e)if(n.primitiveName===t.primitiveName){const a=vn(n.propertyName);if(i&&i.push({cim:t,nocapPropertyName:a,value:t[a]}),n.expression&&(n.value=A.toValue(n.propertyName,n.expression)),s){let o=!1;for(const h of s)h.primitiveName===t.primitiveName&&(o=!0);o||s.push(n)}q(n.value)&&(t[a]=n.value)}}switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(t.effects)for(const n of t.effects)A.applyOverrides(n,e,s,i);if(t.symbolLayers)for(const n of t.symbolLayers)A.applyOverrides(n,e,s,i);break;case"CIMTextSymbol":break;case"CIMSolidStroke":case"CIMSolidFill":case"CIMVectorMarker":if(t.effects)for(const n of t.effects)A.applyOverrides(n,e,s,i);if(t.type==="CIMVectorMarker"&&t.markerGraphics)for(const n of t.markerGraphics)A.applyOverrides(n,e,s,i),A.applyOverrides(n.symbol,e,s,i)}}static restoreOverrides(t){for(const e of t)e.cim[e.nocapPropertyName]=e.value}static buildOverrideKey(t){let e="";for(const s of t)s.value!==void 0&&(e+=`${s.primitiveName}${s.propertyName}${JSON.stringify(s.value)}`);return e}static toValue(t,e){if(t==="DashTemplate")return e.split(" ").map(s=>Number(s));if(t==="Color"){const s=new ss(e).toRgba();return s[3]*=255,s}return e}}const Ye=r=>{if(!r)return rt.Butt;switch(r){case"butt":return rt.Butt;case"square":return rt.Square;case"round":return rt.Round}},Ve=r=>{if(!r)return nt.Miter;switch(r){case"miter":return nt.Miter;case"round":return nt.Round;case"bevel":return nt.Bevel}},xn=r=>{if(at(r))return"Center";switch(r){case"left":return"Left";case"right":return"Right";case"center":return"Center"}},bn=r=>{if(at(r))return"Center";switch(r){case"baseline":return"Baseline";case"top":return"Top";case"middle":return"Center";case"bottom":return"Bottom"}},W=r=>{if(!r)return[0,0,0,0];const{r:t,g:e,b:s,a:i}=r;return[t,e,s,255*i]},Mn=(r,t)=>{const e=Sn(t),s=Cn(r);return e&&s?`${e}-${s}`:`${e}${s}`},Sn=r=>{if(!r)return"";switch(r.toLowerCase()){case"bold":case"bolder":return"bold"}return""},Cn=r=>{if(!r)return"";switch(r.toLowerCase()){case"italic":case"oblique":return"italic"}return""},vs=(r,t)=>{const e=t==="butt";switch(r){case"dash":case"esriSLSDash":return e?[4,3]:[3,4];case"dash-dot":case"esriSLSDashDot":return e?[4,3,1,3]:[3,4,0,4];case"dot":case"esriSLSDot":return e?[1,3]:[0,4];case"long-dash":case"esriSLSLongDash":return e?[8,3]:[7,4];case"long-dash-dot":case"esriSLSLongDashDot":return e?[8,3,1,3]:[7,4,0,4];case"long-dash-dot-dot":case"esriSLSDashDotDot":return e?[8,3,1,3,1,3]:[7,4,0,4,0,4];case"short-dash":case"esriSLSShortDash":return e?[4,1]:[3,2];case"short-dash-dot":case"esriSLSShortDashDot":return e?[4,1,1,1]:[3,2,0,2];case"short-dash-dot-dot":case"esriSLSShortDashDotDot":return e?[4,1,1,1,1,1]:[3,2,0,2,0,2];case"short-dot":case"esriSLSShortDot":return e?[1,1]:[0,2];case"solid":case"esriSLSSolid":case"none":return es.error("Unexpected: style does not require rasterization"),[0,0];default:return es.error(`Tried to rasterize SLS, but found an unexpected style: ${r}!`),[0,0]}};function wn(r){return r.symbolLayers!==void 0}const Is=r=>{let s,i;const n=r;if(n==="circle"||n==="esriSMSCircle"){let o=Math.acos(.995),h=Math.ceil(ci/o/4);h===0&&(h=1),o=_n/h,h*=4;const l=[];l.push([50,0]);for(let c=1;cr==="vertical"||r==="horizontal"||r==="cross"||r==="esriSFSCross"||r==="esriSFSVertical"||r==="esriSFSHorizontal",vn=r=>r&&r.charAt(0).toLowerCase()+r.substr(1);let ne;function In(r,t,e){if(!(!r.effects||q(t.geometryEngine))){if(ne)return void e.push(ne);Zi(r.effects)&&(ne=tr(),e.push(ne),ne.then(s=>t.geometryEngine=s))}}const Ls=.05;function Ln(r){return Math.max(Math.round(r/Ls),1)*Ls}const Tn=new Set(["StartTimeOffset","Duration","RepeatDelay"]);function Nn(r,t){return Tn.has(t)?Ln(r):r}function An(r){var t;if(!r)return null;switch(r.type){case"CIMPointSymbol":{const e=r.symbolLayers;return e&&e.length===1?An(e[0]):null}case"CIMVectorMarker":{const e=r.markerGraphics;if(!e||e.length!==1)return null;const s=e[0];if(!s)return null;const i=s.geometry;if(!i)return null;const n=s.symbol;return!n||n.type!=="CIMPolygonSymbol"&&n.type!=="CIMLineSymbol"||((t=n.symbolLayers)==null?void 0:t.some(a=>!!a.effects))?null:{geom:i,asFill:n.type==="CIMPolygonSymbol"}}case"sdf":return{geom:r.geom,asFill:r.asFill}}return null}function zn(r){return r?r.rings?r.rings:r.paths?r.paths:r.xmin!==void 0&&r.ymin!==void 0&&r.xmax!==void 0&&r.ymax!==void 0?[[[r.xmin,r.ymin],[r.xmin,r.ymax],[r.xmax,r.ymax],[r.xmax,r.ymin],[r.xmin,r.ymin]]]:null:null}function On(r){let t=1/0,e=-1/0,s=1/0,i=-1/0;for(const n of r)for(const a of n)a[0]e&&(e=a[0]),a[1]i&&(i=a[1]);return new ti(t,s,e-t,i-s)}function Ts(r){let t=1/0,e=-1/0,s=1/0,i=-1/0;for(const n of r)for(const a of n)a[0]e&&(e=a[0]),a[1]i&&(i=a[1]);return[t,s,e,i]}function ui(r){return r?r.rings?Ts(r.rings):r.paths?Ts(r.paths):$(r)?[r.xmin,r.ymin,r.xmax,r.ymax]:null:null}function fi(r,t,e,s,i){const[n,a,o,h]=r;if(o0&&(x=(t.xmax-t.xmin)/(t.ymax-t.ymin),y=s.x/(e*x),P=s.y/e):(y=s.x,P=s.y)),y=.5*(t.xmax+t.xmin)+y*(t.xmax-t.xmin),P=.5*(t.ymax+t.ymin)+P*(t.ymax-t.ymin),y-=n,P-=a,y*=_,P*=_,y+=m,P+=m;let M=y/p-.5,k=P/d-.5;return i&&(M*=e*x,k*=e),[g,M,k]}function Ma(r){const t=zn(r.geom),e=On(t),s=128,i=1,n=Math.floor(.5*(.5*s-i)),a=(s-2*(n+i))/Math.max(e.width,e.height),o=Math.round(e.width*a)+2*n,h=Math.round(e.height*a)+2*n,l=[];for(const u of t)if(u&&u.length>1){const f=[];for(const m of u){let[_,p]=m;_-=e.x,p-=e.y,_*=a,p*=a,_+=n-.5,p+=n-.5,r.asFill?f.push([_,p]):f.push([Math.round(_),Math.round(p)])}if(r.asFill){const m=f.length-1;f[0][0]===f[m][0]&&f[0][1]===f[m][1]||f.push(f[0])}l.push(f)}const c=Rn(l,o,h,n);return r.asFill&&En(l,o,h,n,c),[$n(c,n),o,h]}function Rn(r,t,e,s){const i=t*e,n=new Array(i),a=s*s+1;for(let o=0;ot&&(g=t),y<0&&(y=0),P>e&&(P=e);const x=u[0]-c[0],M=u[1]-c[1],k=x*x+M*M;for(let v=d;vk?(L=u[0],b=u[1]):(w/=k,L=c[0]+w*x,b=c[1]+w*M);const N=(v-L)*(v-L)+(T-b)*(T-b),H=(e-T-1)*t+v;Nt-s&&(p=t-s),de-s&&(g=e-s);for(let y=d;yy==l[1]>y)continue;const P=(e-y-1)*t;for(let x=_;x>8^e)+s|0;while(--s!=0)}return(1+e/(1<<31))/2}function Hn(r){return Math.floor(Gn(r,Dn)*Xn)}const Dn=53290320,Xn=10,mi=ce.getLogger("esri.symbols.cim.cimAnalyzer");function os(r){switch(r){case"Butt":return Re.BUTT;case"Square":return Re.SQUARE;default:return Re.ROUND}}function hs(r){switch(r){case"Bevel":return Ee.BEVEL;case"Miter":return Ee.MITER;default:return Ee.ROUND}}function As(r,t,e,s){let i;r[t]?i=r[t]:(i={},r[t]=i),i[e]=s}function zs(r){const t=r.markerPlacement;return t&&t.angleToLine?Je.MAP:Je.SCREEN}async function Sa(r,t,e,s,i){const n=s!=null?s:[];if(!r)return n;let a,o;const h={};if(r.type!=="CIMSymbolReference")return mi.error("Expect cim type to be 'CIMSymbolReference'"),n;if(a=r.symbol,o=r.primitiveOverrides,o){const c=[];for(const u of o){const f=u.valueExpressionInfo;if(f&&t){const m=f.expression,_=$s(m,t.spatialReference,t.fields).then(p=>{at(p)||As(h,u.primitiveName,u.propertyName,p)});c.push(_)}else u.value!=null&&As(h,u.primitiveName,u.propertyName,u.value)}c.length>0&&await Promise.all(c)}const l=[];switch(U.fetchResources(a,e,l),l.length>0&&await Promise.all(l),a.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":Yn(a,o,h,t,n,e,i)}return n}function Yn(r,t,e,s,i,n,a){if(!r)return;const o=r.symbolLayers;if(!o)return;const h=r.effects;let l;const c=U.getSize(r);r.type==="CIMPointSymbol"&&r.angleAlignment==="Map"&&(l=Je.MAP);let u=o.length;for(;u--;){const f=o[u];if(!f||f.enable===!1)continue;let m;h&&h.length&&(m=[...h]);const _=f.effects;_&&_.length&&(h?m.push(..._):m=[..._]);const p=[];let d;A.findEffectOverrides(m,t,p),d=p.length>0?ia(m,p,e,s):m;const g=[];switch(A.findApplicableOverrides(f,t,g),f.type){case"CIMSolidFill":Vn(f,d,e,g,s,i);break;case"CIMPictureFill":Bn(f,d,e,g,s,n,i);break;case"CIMHatchFill":Wn(f,d,e,g,s,i);break;case"CIMGradientFill":Un(f,d,e,g,s,i);break;case"CIMSolidStroke":qn(f,d,e,g,s,i,r.type==="CIMPolygonSymbol",c);break;case"CIMPictureStroke":Jn(f,d,e,g,s,i,r.type==="CIMPolygonSymbol",c);break;case"CIMGradientStroke":jn(f,d,e,g,s,i,r.type==="CIMPolygonSymbol",c);break;case"CIMCharacterMarker":if(Be(f,d,e,g,s,i))break;break;case"CIMPictureMarker":if(Be(f,d,e,g,s,i))break;r.type==="CIMLineSymbol"&&(l=zs(f)),Kn(f,d,e,g,s,n,i,l,c);break;case"CIMVectorMarker":if(Be(f,d,e,g,s,i))break;r.type==="CIMLineSymbol"&&(l=zs(f)),Qn(f,d,e,g,s,i,n,l,c,a);break;default:mi.error("Cannot analyze CIM layer",f.type)}}}function Vn(r,t,e,s,i,n){const a=r.primitiveName,o=Y(r.color),[h,l]=et(s,a,t,null,null),c=E(JSON.stringify(r)+l).toString();n.push({type:"fill",templateHash:c,materialHash:h?()=>c:c,cim:r,materialOverrides:null,colorLocked:r.colorLocked,color:S(a,e,"Color",i,o,Z),height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,effects:t,applyRandomOffset:!1,sampleAlphaOnly:!0})}function Bn(r,t,e,s,i,n,a){const o=r.primitiveName,h=r.tintColor?Y(r.tintColor):{r:255,g:255,b:255,a:1},[l,c]=et(s,o,t,null,null),u=E(JSON.stringify(r)+c).toString(),f=E(`${r.url}${JSON.stringify(r.colorSubstitutions)}`).toString();let m=C(r.scaleX);if("width"in r){const _=r.width;let p=1;const d=n.getResource(r.url);q(d)&&(p=d.width/d.height),m/=p*(r.height/_)}a.push({type:"fill",templateHash:u,materialHash:l?()=>f:f,cim:r,materialOverrides:null,colorLocked:r.colorLocked,effects:t,color:S(o,e,"TintColor",i,h,Z),height:S(o,e,"Height",i,r.height),scaleX:S(o,e,"ScaleX",i,m),angle:S(o,e,"Rotation",i,C(r.rotation)),offsetX:S(o,e,"OffsetX",i,C(r.offsetX)),offsetY:S(o,e,"OffsetY",i,C(r.offsetY)),url:r.url,applyRandomOffset:!1,sampleAlphaOnly:!1})}function Wn(r,t,e,s,i,n){var _;const a=["Rotation","OffsetX","OffsetY"],o=s.filter(p=>p.primitiveName!==r.primitiveName||!a.includes(p.propertyName)),h=r.primitiveName,[l,c]=et(s,h,t,null,null),u=E(JSON.stringify(r)+c).toString(),f=E(`${r.separation}${JSON.stringify(r.lineSymbol)}`).toString();let m={r:255,g:255,b:255,a:1};if(r.lineSymbol){const p=(_=r.lineSymbol)==null?void 0:_.symbolLayers.find(d=>d.type==="CIMSolidStroke");p&&(m=Y(p.color))}n.push({type:"fill",templateHash:u,materialHash:l?me(f,e,o,i):f,cim:r,materialOverrides:o,colorLocked:r.colorLocked,effects:t,color:m,height:S(h,e,"Separation",i,r.separation),scaleX:1,angle:S(h,e,"Rotation",i,C(r.rotation)),offsetX:S(h,e,"OffsetX",i,C(r.offsetX)),offsetY:S(h,e,"OffsetY",i,C(r.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!0})}function Un(r,t,e,s,i,n){const a=r.primitiveName,[o,h]=et(s,a,t,null,null),l=E(JSON.stringify(r)+h).toString();n.push({type:"fill",templateHash:l,materialHash:o?me(l,e,s,i):l,cim:r,materialOverrides:null,colorLocked:r.colorLocked,effects:t,color:{r:128,g:128,b:128,a:1},height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,applyRandomOffset:!1,sampleAlphaOnly:!1})}function qn(r,t,e,s,i,n,a,o){const h=r.primitiveName,l=Y(r.color),c=r.width!==void 0?r.width:4,u=os(r.capStyle),f=hs(r.joinStyle),m=r.miterLimit,[_,p]=et(s,h,t,null,null),d=E(JSON.stringify(r)+p).toString();let g,y;if(t&&t instanceof Array&&t.length>0){const P=t[t.length-1];if(P.type==="CIMGeometricEffectDashes"&&P.lineDashEnding==="NoConstraint"&&P.offsetAlongLine===null){const x=(t=[...t]).pop();g=x.dashTemplate,y=x.scaleDash}}n.push({type:"line",templateHash:d,materialHash:_?()=>d:d,cim:r,materialOverrides:null,isOutline:a,colorLocked:r.colorLocked,effects:t,color:S(h,e,"Color",i,l,Z),width:S(h,e,"Width",i,c),cap:S(h,e,"CapStyle",i,u),join:S(h,e,"JoinStyle",i,f),miterLimit:S(h,e,"MiterLimit",i,m),referenceWidth:o,zOrder:ls(r.name),dashTemplate:g,scaleDash:y,sampleAlphaOnly:!0})}function Jn(r,t,e,s,i,n,a,o){const h=E(`${r.url}${JSON.stringify(r.colorSubstitutions)}`).toString(),l=r.primitiveName,c=Y(r.tintColor),u=r.width!==void 0?r.width:4,f=os(r.capStyle),m=hs(r.joinStyle),_=r.miterLimit,[p,d]=et(s,l,t,null,null),g=E(JSON.stringify(r)+d).toString();n.push({type:"line",templateHash:g,materialHash:p?()=>h:h,cim:r,materialOverrides:null,isOutline:a,colorLocked:r.colorLocked,effects:t,color:S(l,e,"TintColor",i,c,Z),width:S(l,e,"Width",i,u),cap:S(l,e,"CapStyle",i,f),join:S(l,e,"JoinStyle",i,m),miterLimit:S(l,e,"MiterLimit",i,_),referenceWidth:o,zOrder:ls(r.name),dashTemplate:null,scaleDash:!1,url:r.url,sampleAlphaOnly:!1})}function jn(r,t,e,s,i,n,a,o){const h=r.primitiveName,l=r.width!==void 0?r.width:4,c=os(r.capStyle),u=hs(r.joinStyle),f=r.miterLimit,[m,_]=et(s,h,t,null,null),p=E(JSON.stringify(r)+_).toString();n.push({type:"line",templateHash:p,materialHash:m?me(p,e,s,i):p,cim:r,materialOverrides:null,isOutline:a,colorLocked:r.colorLocked,effects:t,color:{r:128,g:128,b:128,a:1},width:S(h,e,"Width",i,l),cap:S(h,e,"CapStyle",i,c),join:S(h,e,"JoinStyle",i,u),miterLimit:S(h,e,"MiterLimit",i,f),referenceWidth:o,zOrder:ls(r.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1})}function Be(r,t,e,s,i,n){const a=r.markerPlacement;if(!a||a.type!=="CIMMarkerPlacementInsidePolygon")return!1;const o=a,h=Math.abs(o.stepX),l=Math.abs(o.stepY);if(h===0||l===0)return!0;const c=["Rotation","OffsetX","OffsetY"],u=s.filter(x=>x.primitiveName!==r.primitiveName||!c.includes(x.propertyName)),f="url"in r?r.url:null,[m,_]=et(s,o.primitiveName,t,null,null),p=E(JSON.stringify(r)+_).toString();let d,g,y=null;if(a.gridType==="Random"){const x=qt(Hs),M=Math.max(Math.floor(x/h),1),k=Math.max(Math.floor(x/l),1);d=l*k,y=v=>v?v*k:0,g=M*h/d}else a.shiftOddRows?(d=2*l,y=x=>x?2*x:0,g=h/l*.5):(d=l,y=null,g=h/l);let P={r:255,g:255,b:255,a:1};return"tintColor"in r&&(P=Y(r.tintColor)),n.push({type:"fill",templateHash:p,materialHash:m?me(p,e,u,i):p,cim:r,materialOverrides:u,colorLocked:r.colorLocked,effects:t,color:S(o.primitiveName,e,"TintColor",i,P,Z),height:S(o.primitiveName,e,"StepY",i,d,y),scaleX:g,angle:S(o.primitiveName,e,"GridAngle",i,o.gridAngle),offsetX:S(o.primitiveName,e,"OffsetX",i,C(o.offsetX)),offsetY:S(o.primitiveName,e,"OffsetY",i,C(o.offsetY)),url:f,applyRandomOffset:a.gridType==="Random",sampleAlphaOnly:!f}),!0}function Kn(r,t,e,s,i,n,a,o,h){var L;const l=r.primitiveName,c=C(r.size);let u=C(r.scaleX,1);const f=C(r.rotation),m=C(r.offsetX),_=C(r.offsetY),p=r.tintColor?Y(r.tintColor):{r:255,g:255,b:255,a:1},d=E(`${r.url}${JSON.stringify(r.colorSubstitutions)}${JSON.stringify(r.animatedSymbolProperties)}`).toString(),g=pi(r.markerPlacement,s,e,i),y=ra(r.animatedSymbolProperties,s,e,i),[P,x]=et(s,l,t,g,y),M=E(JSON.stringify(r)+x).toString(),k=(L=r.anchorPoint)!=null?L:{x:0,y:0};if("width"in r){const b=r.width;let w=1;const N=n.getResource(r.url);q(N)&&(w=N.width/N.height),u/=w*(c/b)}function v(b,w){return Ds(y,b,w)}const T=r.animatedSymbolProperties&&r.animatedSymbolProperties.randomizeStartTime===!0?(b,w,N,H)=>{const ft=Hn(H),mt=v(b,w);return d+`-MATERIALGROUP(${ft})-ASP(${JSON.stringify(mt)})`}:P?(b,w)=>{const N=v(b,w);return d+`-ASP(${JSON.stringify(N)})`}:d;a.push({type:"marker",templateHash:M,materialHash:T,cim:r,materialOverrides:null,colorLocked:r.colorLocked,effects:t,scaleSymbolsProportionally:!1,alignment:o,size:S(l,e,"Size",i,c),scaleX:S(l,e,"ScaleX",i,u),rotation:S(l,e,"Rotation",i,f),offsetX:S(l,e,"OffsetX",i,m),offsetY:S(l,e,"OffsetY",i,_),color:S(l,e,"TintColor",i,p,Z),anchorPoint:{x:k.x,y:-k.y},isAbsoluteAnchorPoint:r.anchorPointUnits!=="Relative",outlineColor:{r:0,g:0,b:0,a:0},outlineWidth:0,frameHeight:0,rotateClockwise:r.rotateClockwise,referenceSize:h,sizeRatio:1,markerPlacement:g,url:r.url,animatedSymbolProperties:y})}function Qn(r,t,e,s,i,n,a,o,h,l){const c=r.markerGraphics;if(!c)return;let u=0;if(r.scaleSymbolsProportionally){const m=r.frame;m&&(u=m.ymax-m.ymin)}const f=pi(r.markerPlacement,s,e,i);for(const m of c)if(m){const _=m.symbol;if(!_)continue;switch(_.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":ta(r,t,f,null,m,s,e,i,n,a,o,h,u,l);break;case"CIMTextSymbol":Zn(r,t,f,m,e,s,i,n,o,h,u)}}}function Zn(r,t,e,s,i,n,a,o,h,l,c){const u=[];A.findApplicableOverrides(s,n,u);const f=s.geometry;if(!("x"in f)||!("y"in f))return;const m=s.symbol,_=Ws(m),p=Bs(m.fontStyleName),d=is(m.fontFamilyName);m.font={family:d,decoration:_,...p};const g=r.frame,y=f.x-.5*(g.xmin+g.xmax),P=f.y-.5*(g.ymin+g.ymax),x=r.size/c,M=r.primitiveName,k=C(m.height)*x,v=C(m.angle),T=C(r.offsetX)+(C(m.offsetX)+y)*x,L=C(r.offsetY)+(C(m.offsetY)+P)*x,b=Y(Dt(m));let w=Y(Xt(m)),N=le(m);N||(w=Y(Dt(m.haloSymbol)),N=m.haloSize*x);const[H,ft]=et(n,M,t,e,null),mt=JSON.stringify(r.effects)+Number(r.colorLocked).toString()+JSON.stringify(r.anchorPoint)+r.anchorPointUnits+JSON.stringify(r.markerPlacement)+r.size.toString(),se=E(JSON.stringify(s)+mt+ft).toString();let G=S(s.primitiveName,i,"TextString",a,s.textString,Vs,m.textCase);if(G==null)return;const{fontStyleName:J}=m,Yt=d+(J?"-"+J.toLowerCase():"-regular"),pt=Yt;typeof G=="string"&&G.includes("[")&&m.fieldMap&&(G=Ki(m.fieldMap,G,m.textCase)),o.push({type:"text",templateHash:se,materialHash:H||typeof G=="function"||G.match(/\[(.*?)\]/)?(Vt,D,pe)=>pt+"-"+Ds(G,Vt,D,pe):pt+"-"+E(G),cim:m,materialOverrides:null,colorLocked:r.colorLocked,effects:t,alignment:h,anchorPoint:{x:r.anchorPoint?r.anchorPoint.x:0,y:r.anchorPoint?r.anchorPoint.y:0},isAbsoluteAnchorPoint:r.anchorPointUnits!=="Relative",fontName:Yt,decoration:_,weight:S(M,i,"Weight",a,p.weight),style:S(M,i,"Size",a,p.style),size:S(M,i,"Size",a,k),angle:S(M,i,"Rotation",a,v),offsetX:S(M,i,"OffsetX",a,T),offsetY:S(M,i,"OffsetY",a,L),horizontalAlignment:Us(m.horizontalAlignment),verticalAlignment:qs(m.verticalAlignment),text:G,color:b,outlineColor:w,outlineSize:N,referenceSize:l,sizeRatio:1,markerPlacement:e})}function ta(r,t,e,s,i,n,a,o,h,l,c,u,f,m){var y;const _=i.symbol,p=_.symbolLayers;if(!p)return;if(m)return void Os(r,t,e,s,i,a,n,o,h,l,c,u,f);let d=p.length;if(na(p))return void ea(r,t,e,s,i,p,n,a,o,h,c,u,f);const g=Ns.applyEffects(_.effects,i.geometry,l.geometryEngine);if(g)for(;d--;){const P=p[d];if(P&&P.enable!==!1)switch(P.type){case"CIMSolidFill":case"CIMSolidStroke":{const x=Ns.applyEffects(P.effects,g,l.geometryEngine),M=ui(x);if(!M)continue;const k=r.anchorPointUnits!=="Relative",[v,T,L]=fi(M,r.frame,r.size,r.anchorPoint,k),b=P.type==="CIMSolidFill",w={type:"sdf",geom:x,asFill:b},N=r.primitiveName,H=(y=C(r.size))!=null?y:10,ft=C(r.rotation),mt=C(r.offsetX),se=C(r.offsetY),G=P.path,J=P.primitiveName,Yt=Y(b?Dt(P):Xt(P)),pt=b?{r:0,g:0,b:0,a:0}:Y(Xt(P)),Vt=le(P);if(!b&&!Vt)break;let D=!1,pe="";for(const _t of n)_t.primitiveName!==J&&_t.primitiveName!==N||(_t.value!==void 0?pe+=`-${_t.primitiveName}-${_t.propertyName}-${JSON.stringify(_t.value)}`:_t.valueExpressionInfo&&(D=!0));q(t)&&typeof t=="function"&&(D=!0);const _i=JSON.stringify({...r,markerGraphics:null}),us=E(JSON.stringify(w)+G).toString(),di={type:"marker",templateHash:E(JSON.stringify(i)+JSON.stringify(P)+_i+pe).toString(),materialHash:D?()=>us:us,cim:w,materialOverrides:null,colorLocked:r.colorLocked,effects:t,scaleSymbolsProportionally:r.scaleSymbolsProportionally,alignment:c,anchorPoint:{x:T,y:L},isAbsoluteAnchorPoint:k,size:S(r.primitiveName,a,"Size",o,H),rotation:S(r.primitiveName,a,"Rotation",o,ft),offsetX:S(r.primitiveName,a,"OffsetX",o,mt),offsetY:S(r.primitiveName,a,"OffsetY",o,se),scaleX:1,frameHeight:f,rotateClockwise:r.rotateClockwise,referenceSize:u,sizeRatio:v,color:S(J,a,"Color",o,Yt,Z),outlineColor:S(J,a,"Color",o,pt,Z),outlineWidth:S(J,a,"Width",o,Vt),markerPlacement:e,animatedSymbolProperties:s,path:G};h.push(di);break}default:Os(r,t,e,s,i,a,n,o,h,l,c,u,f)}}}function ea(r,t,e,s,i,n,a,o,h,l,c,u,f){const m=i.geometry,_=n[0],p=n[1],d=ui(m);if(!d)return;const g=r.anchorPointUnits!=="Relative",[y,P,x]=fi(d,r.frame,r.size,r.anchorPoint,g),M={type:"sdf",geom:m,asFill:!0},k=r.primitiveName,v=C(r.size),T=C(r.rotation),L=C(r.offsetX),b=C(r.offsetY),w=p.path,N=p.primitiveName,H=_.primitiveName,ft=Y(Dt(p)),mt=Y(Xt(_)),se=le(_);let G=!1,J="";for(const D of a)D.primitiveName!==N&&D.primitiveName!==H&&D.primitiveName!==k||(D.value!==void 0?J+=`-${D.primitiveName}-${D.propertyName}-${JSON.stringify(D.value)}`:D.valueExpressionInfo&&(G=!0));const Yt=JSON.stringify({...r,markerGraphics:null}),pt=E(JSON.stringify(M)+w).toString(),Vt={type:"marker",templateHash:E(JSON.stringify(i)+JSON.stringify(p)+JSON.stringify(_)+Yt+J).toString(),materialHash:G?()=>pt:pt,cim:M,materialOverrides:null,colorLocked:r.colorLocked,effects:t,scaleSymbolsProportionally:r.scaleSymbolsProportionally,alignment:c,anchorPoint:{x:P,y:x},isAbsoluteAnchorPoint:g,size:S(r.primitiveName,o,"Size",h,v),rotation:S(r.primitiveName,o,"Rotation",h,T),offsetX:S(r.primitiveName,o,"OffsetX",h,L),offsetY:S(r.primitiveName,o,"OffsetY",h,b),scaleX:1,frameHeight:f,rotateClockwise:r.rotateClockwise,referenceSize:u,sizeRatio:y,color:S(N,o,"Color",h,ft,Z),outlineColor:S(H,o,"Color",h,mt,Z),outlineWidth:S(H,o,"Width",h,se),markerPlacement:e,path:w,animatedSymbolProperties:s};l.push(Vt)}function Os(r,t,e,s,i,n,a,o,h,l,c,u,f){const m=sa(r,i),_=["Rotation","OffsetX","OffsetY"],p=a.filter(b=>b.primitiveName!==r.primitiveName||!_.includes(b.propertyName));let d="";for(const b of a)b.value!==void 0&&(d+=`-${b.primitiveName}-${b.propertyName}-${JSON.stringify(b.value)}`);const[g,y,P]=U.getTextureAnchor(m,l),x=r.primitiveName,M=C(r.rotation),k=C(r.offsetX),v=C(r.offsetY),T=E(JSON.stringify(m)+d).toString(),L={type:"marker",templateHash:T,materialHash:p.length>0||q(t)&&typeof t=="function"?me(T,n,p,o):T,cim:m,materialOverrides:p,colorLocked:r.colorLocked,effects:t,scaleSymbolsProportionally:r.scaleSymbolsProportionally,alignment:c,anchorPoint:{x:g,y},isAbsoluteAnchorPoint:!1,size:r.size,rotation:S(x,n,"Rotation",o,M),offsetX:S(x,n,"OffsetX",o,k),offsetY:S(x,n,"OffsetY",o,v),color:{r:255,g:255,b:255,a:1},outlineColor:{r:0,g:0,b:0,a:0},outlineWidth:0,scaleX:1,frameHeight:f,rotateClockwise:r.rotateClockwise,referenceSize:u,sizeRatio:P/Kt(r.size),markerPlacement:e,animatedSymbolProperties:s};h.push(L)}function sa(r,t){return{type:r.type,enable:!0,name:r.name,colorLocked:r.colorLocked,primitiveName:r.primitiveName,anchorPoint:r.anchorPoint,anchorPointUnits:r.anchorPointUnits,offsetX:0,offsetY:0,rotateClockwise:r.rotateClockwise,rotation:0,size:r.size,billboardMode3D:r.billboardMode3D,depth3D:r.depth3D,frame:r.frame,markerGraphics:[t],scaleSymbolsProportionally:r.scaleSymbolsProportionally,respectFrame:r.respectFrame,clippingPath:r.clippingPath}}function ls(r){if(r&&r.indexOf("Level_")===0){const t=parseInt(r.substr(6),10);if(!isNaN(t))return t}return 0}function Z(r){if(!r||r.length===0)return null;const t=new ss(r).toRgba();return{r:t[0],g:t[1],b:t[2],a:t[3]}}function S(r,t,e,s,i,n,a){const o=t[r];if(o){const h=o[e];if(typeof h=="string"||typeof h=="number"||h instanceof Array)return n?n.call(null,h,a):h;if(h!=null&&h instanceof ue)return(l,c,u)=>{let f=ee(h,l,{$view:u},s.geometryType,c);return f!==null&&n&&(f=n.call(null,f,a)),f!==null?f:i}}return i}function cs(r){return r&&r.charAt(0).toLowerCase()+r.substr(1)}function ia(r,t,e,s){for(const i of t)if(i.valueExpressionInfo){const n=e[i.primitiveName]&&e[i.primitiveName][i.propertyName];n instanceof ue&&(i.fn=(a,o,h)=>ee(n,a,{$view:h},s.geometryType,o))}return(i,n,a)=>{for(const h of t)h.fn&&(h.value=h.fn(i,n,a));const o=[];for(let h of r){const l=h==null?void 0:h.primitiveName;if(l){let c=!1;for(const u of t)if(u.primitiveName===l){const f=cs(u.propertyName);u.value!=null&&u.value!==h[f]&&(c||(h=R(h),c=!0),h[f]=u.value)}}o.push(h)}return o}}function pi(r,t,e,s){const i=[];if(A.findApplicableOverrides(r,t,i),i.length===0)return r;for(const n of i)if(n.valueExpressionInfo){const a=e[n.primitiveName]&&e[n.primitiveName][n.propertyName];a instanceof ue&&(n.fn=(o,h,l)=>ee(a,o,{$view:l},s.geometryType,h))}return(n,a,o)=>{for(const c of i)c.fn&&(c.value=c.fn(n,a,o));const h=R(r),l=r.primitiveName;for(const c of i)if(c.primitiveName===l){const u=cs(c.propertyName);c.value!=null&&c.value!==h[u]&&(h[u]=c.value)}return h}}function ra(r,t,e,s){const i=[];if(A.findApplicableOverrides(r,t,i),i.length===0)return r;for(const n of i)if(n.valueExpressionInfo){const a=e[n.primitiveName]&&e[n.primitiveName][n.propertyName];a instanceof ue&&(n.fn=(o,h,l)=>ee(a,o,{$view:l},s.geometryType,h))}return(n,a,o)=>{for(const c of i)c.fn&&(c.value=c.fn(n,a,o));const h=R(r),l=r.primitiveName;for(const c of i)if(c.primitiveName===l){const u=cs(c.propertyName);if(c.value!=null){const f=Nn(c.value,c.propertyName);f!==h[u]&&(h[u]=f)}}return h}}function me(r,t,e,s){for(const i of e)if(i.valueExpressionInfo){const n=t[i.primitiveName]&&t[i.primitiveName][i.propertyName];n instanceof ue&&(i.fn=(a,o,h)=>ee(n,a,{$view:h},s.geometryType,o))}return(i,n,a)=>{for(const o of e)o.fn&&(o.value=o.fn(i,n,a));return E(r+A.buildOverrideKey(e)).toString()}}function Ca(r,t){if(!t||t.length===0)return r;const e=R(r);return A.applyOverrides(e,t),e}function et(r,t,e,s,i){let n=!1,a="";for(const o of r)o.primitiveName===t&&(o.value!==void 0?a+=`-${o.primitiveName}-${o.propertyName}-${JSON.stringify(o.value)}`:o.valueExpressionInfo&&(n=!0));return q(e)&&typeof e=="function"&&(n=!0),q(s)&&typeof s=="function"&&(n=!0),q(i)&&typeof i=="function"&&(n=!0),[n,a]}const na=r=>r&&r.length===2&&r[0].enable&&r[1].enable&&r[0].type==="CIMSolidStroke"&&r[1].type==="CIMSolidFill"&&!r[0].effects&&!r[1].effects,aa={marker:xe.MARKER,fill:xe.FILL,line:xe.LINE,text:xe.TEXT};class wa{constructor(t,e,s,i){const n={minScale:e==null?void 0:e.minScale,maxScale:e==null?void 0:e.maxScale},a=oa(n);this.layers=t,this.data=e,this.hash=this._createHash()+a,this.rendererKey=s;const o={isOutline:!1,placement:null,symbologyType:Xi.DEFAULT,vvFlags:s};for(const h of t){const l=aa[h.type];o.isOutline=h.type==="line"&&h.isOutline,h.materialKey=Di(l,o),h.maxVVSize=i,h.scaleInfo=n,h.templateHash+=a}}get type(){return"expanded-cim"}_createHash(){let t="";for(const e of this.layers)t+=e.templateHash;return t}}function oa(r){return r.minScale||r.maxScale?r.minScale+"-"+r.maxScale:""}export{xa as Q,Sa as T,Pa as V,ga as a,Ma as b,Hn as c,ba as d,Gn as e,or as f,Jr as g,Ns as h,ya as i,ri as j,Ds as k,wa as l,Ca as m,rs as n,U as o,vs as p,ee as q,An as r,ti as t};