// All material copyright ESRI, All Rights Reserved, unless otherwise specified.// See https://js.arcgis.com/4.6/esri/copyright.txt for details.//>>builtdefine("require exports ../core/tsSupport/declareExtendsHelper ../core/tsSupport/decorateHelper ../core/accessorSupport/decorators ../core/lang ./Geometry ./Extent ./Point ./SpatialReference ./support/webMercatorUtils ./support/zmUtils ./support/coordsUtils".split(" "),function(q,R,N,f,g,A,O,J,h,P,K,L,u){functionM(g){returnfunction(b,k){returnnull==b?k:null==k?b:g(b,k)}}varn=M(Math.min),l=M(Math.max);q=function(q){functionb(){for(vara=[],c=0;c<arguments.length;c++)a[c]=arguments[c];a=q.apply(this,a)||this;a.rings=[];a.type="polygon";returna}N(b,q);k=b;b.createEllipse=function(a){varc=a.center.x,d=a.center.y,F=a.center.z,e=a.center.m,b=a.center.hasZ,g=a.center.hasM,Q=a.longAxis,n=a.shortAxis,l=a.numberOfPoints;a=a.view;for(varr=[],f=2*Math.PI/l,h=b?3:2,v=0;v<l;v++){varp=a.toMap(Q*Math.cos(v*f)+c,n*Math.sin(v*f)+d),p=[p.x,p.y];b&&(p[2]=F);g&&(p[h]=e);r.push(p)}r.push(r[0]);returnnewk({rings:[r],spatialReference:a.spatialReference})};b.createCircle=function(a){returnk.createEllipse({center:a.center,longAxis:a.r,shortAxis:a.r,numberOfPoints:a.numberOfPoints,view:a.view})};b.fromExtent=function(a){varc=a.clone().normalize();a=a.spatialReference;vard=!1,b=!1;c.map(function(a){a.hasZ&&(d=!0);a.hasM&&(b=!0)});c={rings:c.map(function(a){varc=[[a.xmin,a.ymin],[a.xmin,a.ymax],[a.xmax,a.ymax],[a.xmax,a.ymin],[a.xmin,a.ymin]];if(d&&a.hasZ)for(varF=(a.zmax-a.zmin)/2,e=0;e<c.length;e++)c[e].push(F);if(b&&a.hasM)for(a=(a.mmax-a.mmin)/2,e=0;e<c.length;e++)c[e].push(a);returnc}),spatialReference:a};d&&(c.hasZ=!0);b&&(c.hasM=!0);returnnewk(c)};b.prototype.normalizeCtorArgs=function(a,c){vard=null,b,e,m=null;a&&!Array.isArray(a)?(d=a.rings?a.rings:null,c||(a.spatialReference?c=a.spatialReference:a.rings||(c=a)),b=a.hasZ,e=a.hasM):d=a;d=d||[];c=c||P.WGS84;d.length&&d[0]&&null!=d[0][0]&&"number"===typeofd[0][0]&&(d=[d]);if(m=d[0]&&d[0][0])void0===b&&void0===e?(b=2<m.length,e=!1):void0===b?b=!e&&3<m.length:void0===e&&(e=!b&&3<m.length);return{rings:d,spatialReference:c,hasZ:b,hasM:e}};Object.defineProperty(b.prototype,"centroid",{get:function(){vara=u.ringsCentroid([],this.rings,this.hasZ);if(isNaN(a[0])||isNaN(a[1])||this.hasZ&&isNaN(a[2]))returnnull;varc=newh;c.x=a[0];c.y=a[1];c.spatialReference=this.spatialReference;this.hasZ&&(c.z=a[2]);returnc},enumerable:!0,configurable:!0});Object.defineProperty(b.prototype,"extent",{get:function(){vara=this.hasZ,c=this.hasM,d=this.spatialReference,b=this.rings,e=a?3:2;if(!b.length||!b[0].length)returnnull;for(varm=b[0][0],g=m[0],m=m[1],f=b[0][0],k=f[0],f=f[1],h=void0,r=void0,q=void0,u=void0,v=[],p=0;p<b.length;p++){for(varB=b[p],x=B[0],G=x[0],x=x[1],y=B[0],H=y[0],y=y[1],C=void0,D=void0,A=void0,w=void0,I=0;I<B.length;I++){varz=B[I],t=z[0],E=z[1],g=n(g,t),m=n(m,E),k=l(k,t),f=l(f,E),G=n(G,t),x=n(x,E),H=l(H,t),y=l(y,E);a&&2<z.length&&(t=z[2],h=n(h,t),r=l(r,t),C=n(C,t),D=l(D,t));c&&z.length>e&&(w=z[e],q=n(h,w),u=l(r,w),A=n(C,w),w=l(D,w))}v.push(newJ({xmin:G,ymin:x,zmin:C,mmin:A,xmax:H,ymax:y,zmax:D,mmax:w,spatialReference:d}))}b=newJ;b.xmin=g;b.ymin=m;b.xmax=k;b.ymax=f;b.spatialReference=d;a&&(b.zmin=h,b.zmax=r);c&&(b.mmin=q,b.mmax=u);b.cache._partwise=1<v.length?v:null;returnb},enumerable:!0,configurable:!0});Object.defineProperty(b.prototype,"isSelfIntersecting",{get:function(){returnu.isSelfIntersecting(this.rings)},enumerable:!0,configurable:!0});b.prototype.writePaths=function(a,c,b,f){c.rings=A.clone(this.rings)};b.prototype.addRing=function(a){if(a){this.clearCache();varb=this.rings,d=b.length;if(Array.isArray(a[0]))b[d]=a.concat();else{for(varf=[],e=0,g=a.length;e<g;e++)f[e]=a[e].toArray();b[d]=f}returnthis}};b.prototype.clone=function(){vara=newk;a.spatialReference=this.spatialReference;a.rings=A.clone(this.rings);a.hasZ=this.hasZ;a.hasM=this.hasM;returna};b.prototype.contains=function(a){if(!a)return!1;K.canProject(a,this.spatialReference)&&(a=K.project(a,this.spatialReference));returnu.contains(this.rings,u.geometryToCoordinates(a))};b.prototype.isClockwise=function(a){varb=this;a=Array.isArray(a[0])?a:a.map(function(a){returnb.hasZ?b.hasM?[a.x,a.y,a.z,a.m]:[a.x,a.y,a.z]:[a.x,a.y]});returnu.isClockwise(a,this.hasM,this.hasZ)};b.prototype.getPoint=function(a,b){if(!this._validateInputs(a,b))returnnull;a=this.rings[a][b];b=this.hasZ;varc=this.hasM;returnb&&!c?newh(a[0],a[1],a[2],void0,this.spatialReference):c&&!b?newh(a[0],a[1],void0,a[2],this.spatialReference):b&&c?newh(a[0],a[1],a[2],a[3],this.spatialReference):newh(a[0],a[1],this.spatialReference)};b.prototype.insertPoint=function(a,b,d){if(!this._validateInputs(a,b,!0))returnthis;this.clearCache();L.updateSupportFromPoint(this,d);Array.isArray(d)||(d=d.toArray());this.rings[a].splice(b,0,d);returnthis};b.prototype.removePoint=function(a,b){if(!this._validateInputs(a,b))returnnull;this.clearCache();returnnewh(this.rings[a].splice(b,1)[0],this.spatialReference)};b.prototype.removeRing=function(a){if(!this._validateInputs(a,null))returnnull;this.clearCache();a=this.rings.splice(a,1)[0];varb=this.spatialReference;returna.map(function(a){returnnewh(a,b)})};b.prototype.setPoint=function(a,b,d){if(!this._validateInputs(a,b))returnthis;this.clearCache();L.updateSupportFromPoint(this,d);Array.isArray(d)||(d=d.toArray());this.rings[a][b]=d;returnthis};b.prototype._validateInputs=function(a,b,d){void0===d&&(d=!1);if(null==a||null==b||0>a||a>=this.rings.length)return!1;a=this.rings[a];returnd&&0>b||b>a.length||0>b||b>=a.length?!1:!0};b.prototype.toJSON=function(a){returnthis.write(null,a)};f([g.property({dependsOn:["hasM","hasZ","rings"]})],b.prototype,"cache",void0);f([g.property({readOnly:!0,dependsOn:["cache"]})],b.prototype,"centroid",null);f([g.property({dependsOn:["cache"],readOnly:!0})],b.prototype,"extent",null);f([g.property({dependsOn:["cache"],readOnly:!0})],b.prototype,"isSelfIntersecting",null);f([g.property({type:[[[Number]]],json:{write:{isRequired:!0}}})],b.prototype,"rings",void0);f([g.writer("rings")],b.prototype,"writePaths",null);returnb=k=f([g.subclass("esri.geometry.Polygon")],b);vark}(g.declared(O));q.prototype.toJSON.isDefaultToJSON=!0;returnq});