/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as t}from"tslib";import{getProjectiveTransform as e,transformProjective as o}from"../../core/perspectiveUtils.js";import{createScreenPoint as r}from"../../core/screenUtils.js";import{property as s,subclass as l}from"../../core/accessorSupport/decorators.js";import{create as i}from"../../core/libs/gl-matrix-2/factories/mat3f64.js";import{set as n}from"../../core/libs/gl-matrix-2/math/vec2.js";import{create as p}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import c from"../../geometry/Point.js";import m from"../../geometry/Polygon.js";import{projectOrLoad as f}from"../../geometry/projectionUtils.js";import a from"./GeoreferenceBase.js";const u=p();let y=class extends a{constructor(t){super(t),this.bottomLeft=null,this.bottomRight=null,this.topLeft=null,this.topRight=null,this.type="corners"}get coords(){let{topLeft:t,topRight:e,bottomLeft:o,bottomRight:r}=this;if(null==t||null==e||null==o||null==r)return null;const s=t.spatialReference;return e=this.projectOrWarn(e,s),o=this.projectOrWarn(o,s),r=this.projectOrWarn(r,s),null==e||null==o||null==r?null:new m({rings:[[[o.x,o.y],[t.x,t.y],[e.x,e.y],[r.x,r.y],[o.x,o.y]]],spatialReference:s})}set coords(t){const{topLeft:e}=this;if(null==e)return;const o=e.spatialReference;if(null==(t=this.projectOrWarn(t,o)))return;const{rings:[[r,s,l,i]]}=t;this.bottomLeft=new c({x:r[0],y:r[1],spatialReference:o}),this.topLeft=new c({x:s[0],y:s[1],spatialReference:o}),this.topRight=new c({x:l[0],y:l[1],spatialReference:o}),this.bottomRight=new c({x:i[0],y:i[1],spatialReference:o})}toSourceNormalized(t){const{topLeft:s,topRight:l,bottomRight:p,bottomLeft:c}=this;if(null==t||null==s||null==l||null==p||null==c)return null;const m=s.spatialReference;t=t.normalize();const a=f(t,m).geometry;if(null==a)return null;n(u,a.x,a.y);const y=e(i(),[s.x,s.y,c.x,c.y,l.x,l.y,p.x,p.y],[0,0,0,1,1,0,1,1]);return o(u,u,y),r(u[0],u[1])}};t([s({clonable:!1})],y.prototype,"coords",null),t([s({type:c})],y.prototype,"bottomLeft",void 0),t([s({type:c})],y.prototype,"bottomRight",void 0),t([s({type:c})],y.prototype,"topLeft",void 0),t([s({type:c})],y.prototype,"topRight",void 0),y=t([l("esri.layers.support.CornersGeoreference")],y);const h=y;export{h as default};
