// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("exports ../../core/fontUtils ../../core/has ../../core/lang ../../core/Logger ../../core/ObjectPool ../../core/screenUtils ../../geometry/GeometryCursor ../../geometry/support/aaBoundingRect ../../geometry/support/boundsUtils ../../geometry/support/centroid ../../geometry/support/jsonUtils ./CIMEffects ./CIMImageColorSubstitutionHelper ./CIMOperators ./CIMPlacements ./defaultCIMValues ./enums ./imageUtils ./Rect ./TextRasterizer ./utils ../../views/2d/engine/webgl/definitions ../../views/2d/engine/webgl/mesh/templates/shapingUtils ../../views/2d/layers/graphics/graphicsUtils".split(" "), function(y,R,S,T,U,V,B,J,K,W,X,p,Y,Z,L,aa,C,E,H,ba,M,m,F,ca,N){function O(a,b,c){for(const d of b){b=d.length;for(let f=1;f-c&&ee&&(e=-e);for(var f=0,g=.5*e;f>g;)f-=e;for(;f<-g;)f+=e;var h=K.create();W.getBoundsXY(h,a);h[0]-=g;h[1]-=g;h[2]+=g;h[3]+=g;for(var k=[[h[0],h[1]], [h[0],h[3]],[h[2],h[3]],[h[2],h[1]]];180d;)d+=180;h=Math.cos(d*z);var n=Math.sin(d*z);d=-e*n;g=e*h;f=m.getNumericValue(b.offsetX)*c;c*=m.getNumericValue(b.offsetY);f=f*n-c*h;var q;var l=c=Number.MAX_VALUE;var r=q=-Number.MAX_VALUE;for(var v of k){var u=v[0];const w=v[1];k=h*u+n*w;u=-n*u+h*w;l=Math.min(l,k);c=Math.min(c,u);r=Math.max(r,k);q=Math.max(q,u)}c=Math.floor(c/e)*e;v=h*l-n*c-d*f/e;l=n*l+h*c-g*f/e;k=h*r-n*c-d*f/e;h=n*r+h*c-g*f/e;e=1+Math.round((q-c)/e);f=[];for(n=0;n=e)){var d=c.width;c=c.height;if(d&&c){c=d/c;var f=m.getNumericValue(a.scaleX,1);d=t.createIdentity();var g=a.anchorPoint;if(g){var h=g.x;g=g.y;"Absolute"!==a.anchorPointUnits&&(h*=e*c*f,g*=e);d.translate(-h,-g)}c=m.getNumericValue(a.rotation);a.rotateClockwise&&(c=-c);this._mapRotation&& (c+=this._mapRotation);c&&d.rotate(c*z);c=m.getNumericValue(a.offsetX);f=m.getNumericValue(a.offsetY);if(c||f){if(this._mapRotation){g=z*this._mapRotation;h=Math.cos(g);g=Math.sin(g);const k=c*g+f*h;c=c*h-f*g;f=k}d.translate(c,f)}c=this.geomUnitsPerPoint();1!==c&&d.scale(c,c);(c=b.getAngle())&&d.rotate(c);d.translate(b.tx,b.ty);this.push(d,!1);this.drawImage(a,e);this.pop()}}}}drawVectorMarker(a,b){if(a){var c=a.markerGraphics;if(c){var e=m.getNumericValue(a.size,C.defaultCIMValues.CIMVectorMarker.size), d=a.frame,f=d?d.ymax-d.ymin:0;f=e&&f?e/f:1;e=t.createIdentity();d&&e.translate(.5*-(d.xmax+d.xmin),.5*-(d.ymax+d.ymin));var g=a.anchorPoint;if(g){var h=g.x;g=g.y;"Absolute"!==a.anchorPointUnits?d&&(h*=d.xmax-d.xmin,g*=d.ymax-d.ymin):(h/=f,g/=f);e.translate(-h,-g)}1!==f&&e.scale(f,f);d=m.getNumericValue(a.rotation);a.rotateClockwise&&(d=-d);this._mapRotation&&(d+=this._mapRotation);d&&e.rotate(d*z);d=m.getNumericValue(a.offsetX);f=m.getNumericValue(a.offsetY);if(d||f){if(this._mapRotation){g=z*this._mapRotation; h=Math.cos(g);g=Math.sin(g);const k=d*g+f*h;d=d*h-f*g;f=k}e.translate(d,f)}d=this.geomUnitsPerPoint();1!==d&&e.scale(d,d);(d=b.getAngle())&&e.rotate(d);e.translate(b.tx,b.ty);this.push(e,a.scaleSymbolsProportionally);for(const k of c)if(k?.symbol&&k.geometry||U.getLogger("esri.symbols.cim.CIMSymbolDrawHelper").error("Invalid marker graphic",k),a=k.textString,"number"===typeof a&&(a=a.toString()),this.drawSymbol(k.symbol,k.geometry,a),this._earlyReturn)break;this.pop()}}}drawTextSymbol(a,b,c){if(a&& p.isPoint(b)&&!(0>=m.getNumericValue(a.height,C.defaultCIMValues.CIMTextSymbol.height))){var e=t.createIdentity(),d=m.getNumericValue(a.angle);(d=-d)&&e.rotate(d*z);d=m.getNumericValue(a.offsetX);var f=m.getNumericValue(a.offsetY);(d||f)&&e.translate(d,f);d=this.geomUnitsPerPoint();1!==d&&e.scale(d,d);e.translate(b.x,b.y);this.push(e,!1);this.drawText(a,c);this.pop()}}}class da extends G{constructor(a,b){super(a,b);this.reset()}reset(){this._xmin=this._ymin=Infinity;this._xmax=this._ymax=-Infinity; this._clipCount=0}envelope(){return new ba(this._xmin,this._ymin,this._xmax-this._xmin,this._ymax-this._ymin)}bounds(){return K.fromValues(this._xmin,this._ymin,this._xmax,this._ymax)}drawSolidFill(a){!a||0=c||(b=Math.max(.5* this.transformSize(m.getNumericValue(c,C.defaultCIMValues.CIMSolidStroke.width)),.25),p.isPolygon(a)?this._processPath(a.rings,b):p.isPolyline(a)?this._processPath(a.paths,b):p.isExtent(a)?(a=D(a))&&this._processPath(a.rings,b):console.error("drawSolidStroke unexpected geometry type!"))}drawMarkerLayer(a,b){p.isPolygon(b)&&a.markerPlacement&&("CIMMarkerPlacementInsidePolygon"===a.markerPlacement.type||"CIMMarkerPlacementPolygonCenter"===a.markerPlacement.type&&a.markerPlacement.clipAtBoundary)?this._processPath(b.rings, 0):super.drawMarkerLayer(a,b)}drawHatchFill(a,b){this.drawSolidFill(a)}drawPictureFill(a,b){this.drawSolidFill(a)}drawGradientFill(a,b){this.drawSolidFill(a)}drawPictureStroke(a,b){this.drawSolidStroke(a,null,b.width)}drawGradientStroke(a,b){this.drawSolidStroke(a,null,b.width)}pushClipPath(a){this.drawSolidFill(a);this._clipCount++}popClipPath(){this._clipCount--}drawImage(a,b){var {url:c}=a;a=m.getNumericValue(a.scaleX,1);let e=a*b;var d=b;c=this._resourceManager.getResource(c);null!=c&&(d=c.height/ c.width,e=a*(b?1this._xmax&&(this._xmax=a[0]+b);a[1]- bthis._ymax&&(this._ymax=a[1]+b)}}class ea extends G{constructor(){super(...arguments);this._searchPoint=[0,0];this._searchDistPoint=0;this._textInfo=null}hitTest(a,b,c,e,d,f){f*=B.pt2px(1);this.setTransform();this.setGeomUnitsPerPoint(f);this._searchPoint=[(a[0]+a[2])/2,(a[1]+a[3])/2];this._searchDistPoint=(a[2]-a[0])/2/f;this._textInfo=e;this._mapRotation=b&&("CIMPointSymbol"===b.type&&"Map"!==b.angleAlignment||"CIMTextSymbol"===b.type)?d:0;S("esri-mobile")|| (a=B.px2pt(F.hittestToleranceSmallSymbol*window.devicePixelRatio),e=B.px2pt(F.hittestSmallSymbolThreshold),("CIMLineSymbol"!==b?.type&&"CIMPolygonSymbol"!==b?.type||!b.symbolLayers?.some(m.isCIMFill))&&"CIMMeshSymbol"!==b?.type&&(m.getSize(b)??0)h.xTopLeft&&b-h.yBottomRight&&c<-h.yTopLeft){this._earlyReturn= !0;break}}}_hitTestFill(a){let b=null;if(p.isExtent(a))b=[[[a.xmin,a.ymin],[a.xmin,a.ymax],[a.xmax,a.ymax],[a.xmax,a.ymin],[a.xmin,a.ymin]]];else if(p.isPolygon(a))b=a.rings;else if(p.isPolyline(a))b=a.paths;else return;a=this.reverseTransformPt(this._searchPoint);let c=0;for(var e of b){const d=e.length;for(let f=1;fa[1]!==h[1]>a[1]&&(0<(h[0]-g[0])*(a[1]-g[1])-(h[1]-g[1])*(a[0]-g[0])?c++:c--)}}0!==c&&(this._earlyReturn=!0);this._earlyReturn||(e=this.reverseTransformScalar(this._searchDistPoint)* this.prevGeomUnitsPerPoint(),O(a,b,e)&&(this._earlyReturn=!0))}_hitTestStroke(a,b){let c=null;if(p.isExtent(a))c=[[[a.xmin,a.ymin],[a.xmin,a.ymax],[a.xmax,a.ymax],[a.xmax,a.ymin],[a.xmin,a.ymin]]];else if(p.isPolygon(a))c=a.rings;else if(p.isPolyline(a))c=a.paths;else return;a=this.reverseTransformPt(this._searchPoint);b=m.getNumericValue(b,C.defaultCIMValues.CIMSolidStroke.width)*this.geomUnitsPerPoint();const e=this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint();O(a, c,b/2+e)&&(this._earlyReturn=!0)}}class fa extends G{constructor(a,b,c,e){super(b,c);this._applyAdditionalRenderProps=e;this._colorSubstitutionHelper=new Z;this._ctx=a}drawSolidFill(a,b){if(a){if(p.isPolygon(a))this._buildPath(a.rings,!0);else if(p.isPolyline(a))this._buildPath(a.paths,!0);else if(p.isExtent(a))this._buildPath(D(a).rings,!0);else if(p.isMultipoint(a))console.log("CanvasDrawHelper.drawSolidFill - No implementation!");else return;a=this._ctx;a.fillStyle="string"===typeof b?b:"rgba("+ Math.round(b[0])+","+Math.round(b[1])+","+Math.round(b[2])+","+(b[3]??255)/255+")";a.fill("evenodd")}}drawSolidStroke(a,b,c,e,d,f){if(a&&b&&0!==c){if(p.isPolygon(a))this._buildPath(a.rings,!0);else if(p.isPolyline(a))this._buildPath(a.paths,!1);else if(p.isExtent(a))this._buildPath(D(a).rings,!0);else{console.log("CanvasDrawHelper.drawSolidStroke isn't implemented!");return}a=this._ctx;a.strokeStyle="string"===typeof b?b:"rgba("+Math.round(b[0])+","+Math.round(b[1])+","+Math.round(b[2])+","+(b[3]?? 255)/255+")";a.lineWidth=Math.max(this.transformSize(c),.5);this._setCapStyle(e);this._setJoinStyle(d);a.miterLimit=f;a.stroke()}}pushClipPath(a){this._ctx.save();if(p.isPolygon(a))this._buildPath(a.rings,!0);else if(p.isPolyline(a))this._buildPath(a.paths,!0);else if(p.isExtent(a))this._buildPath(D(a).rings,!0);else return;this._ctx.clip("evenodd")}popClipPath(){this._ctx.restore()}drawImage(a,b){const {colorSubstitutions:c,url:e,tintColor:d}=a;a=m.getNumericValue(a.scaleX,1);var f=this._resourceManager.getResource(e); if(null!=f){var g=f.width/f.height*b,h=b;b||(g=f.width,h=f.height);var k=m.isSVGImage(e)||"src"in f&&m.isSVGImage(f.src);b="getFrame"in f?H.getFirstFrame(f):f;c&&(b=this._colorSubstitutionHelper.applyColorSubstituition(b,c));this._applyAdditionalRenderProps&&!k&&d&&(b=this._colorSubstitutionHelper.tintImageData(b,d));f=this.transformPt([0,0]);var [n,q]=this.getTransformAngle();k=this.transformSize(1);var l=this._ctx;l.save();l.setTransform({m11:a*k*n,m12:a*k*q,m21:-k*q,m22:k*n,m41:f[0],m42:f[1]}); l.drawImage(b,-g/2,-h/2,g,h);l.restore()}}drawText(a,b){if(b&&0!==b.length&&(this._textRasterizer||(this._textRasterizer=new M),a=P(a),a.size*=this.transformSize(B.px2pt(1)),b=this._textRasterizer.rasterizeText(b,a))){var {size:c,anchorX:e,anchorY:d,canvas:f}=b;b=c[0]*(e+.5);a=c[1]*(d-.5);var g=this._ctx,h=this.transformPt([0,0]),[k,n]=this.getTransformAngle();g.save();g.setTransform({m11:1*k,m12:1*n,m21:-1*n,m22:1*k,m41:h[0]-1*b,m42:h[1]+1*a});g.drawImage(f,0,0);g.restore()}}drawPictureFill(a,b){if(a){var {colorSubstitutions:c, height:e,offsetX:d,offsetY:f,rotation:g,scaleX:h,tintColor:k,url:n}=b;b=this._resourceManager.getResource(n);if(null!=b){if(p.isPolygon(a))this._buildPath(a.rings,!0);else if(p.isPolyline(a))this._buildPath(a.paths,!0);else if(p.isExtent(a))this._buildPath(D(a).rings,!0);else if(p.isMultipoint(a))console.log("CanvasDrawHelper.drawPictureFill - No implementation!");else return;a=this._ctx;var q=m.isSVGImage(n)||"src"in b&&m.isSVGImage(b.src),l="getFrame"in b?H.getFirstFrame(b):b;c&&(l=this._colorSubstitutionHelper.applyColorSubstituition(l, c));if(this._applyAdditionalRenderProps){if(q||k&&(l=this._colorSubstitutionHelper.tintImageData(l,k)),q=a.createPattern(l,"repeat"),l=this.transformSize(1),g||=0,d=d?l*d:0,f=f?l*f:0,e&&=l*e,l=e?e/b.height:1,b=h&&e?h*e/b.width:1,0!==g||1!==l||1!==b||0!==d||0!==f){const r=new DOMMatrix;r.rotateSelf(0,0,-g).translateSelf(d,f).scaleSelf(b,l,1);q.setTransform(r)}}else q=a.createPattern(l,"repeat");a.save();a.fillStyle=q;a.fill("evenodd");a.restore()}}}drawPictureStroke(a,b){if(a){var {colorSubstitutions:c, capStyle:e,joinStyle:d,miterLimit:f,tintColor:g,url:h,width:k}=b;b=this._resourceManager.getResource(h);if(null!=b){if(p.isPolygon(a))var n=a.rings;else if(p.isPolyline(a))n=a.paths;else if(p.isExtent(a))n=D(a).rings;else{p.isMultipoint(a)&&console.log("CanvasDrawHelper.drawPictureStroke - No implementation!");return}k||(k=b.width);a=m.isSVGImage(h)||"src"in b&&m.isSVGImage(b.src);var q="getFrame"in b?H.getFirstFrame(b):b;c&&(q=this._colorSubstitutionHelper.applyColorSubstituition(q,c));this._applyAdditionalRenderProps&& (a||g&&(q=this._colorSubstitutionHelper.tintImageData(q,g)));b=Math.max(this.transformSize(B.pt2px(k)),.5);a=b/q.width;var l=this._ctx;q=l.createPattern(q,"repeat-y");l.save();this._setCapStyle(e);this._setJoinStyle(d);void 0!==f&&(l.miterLimit=f);l.lineWidth=b;var r;for(let A of n){A=T.clone(A);var v=r=void 0,u=void 0;let I=v=void 0;n=A;for(var w=n[0],x=1;x=v-u?(n.splice(x-1,1),w=r):(r=w,w=n[x],x++),u=v;if(A&&!(1>=A.length))for(n= this.transformPt(A[0]),u=1;ua?{spatialReference:a.spatialReference,rings:[[[a.xmin,a.ymin],[a.xmin, a.ymax],[a.xmax,a.ymax],[a.xmax,a.ymin],[a.xmin,a.ymin]]]}:null,Q=(a,b,c)=>{switch(a){case "ExtraLeading":return 1+b/c;case "Multiple":return b;case "Exact":return b/c}};y.CIMSymbolDrawHelper=G;y.CanvasDrawHelper=fa;y.EnvDrawHelper=da;y.HittestDrawHelper=ea;y.Transformation=t;y.cDegToRad=z;y.lineGapType2LineHeight=Q;Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});