/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import r from"../../core/Error.js";import{Loadable as o}from"../../core/Loadable.js";import t from"../../core/Logger.js";import{MultiOriginJSONMixin as n}from"../../core/MultiOriginJSONSupport.js";import{NumericIdentifiableMixin as s}from"../../core/NumericIdentifiable.js";import{property as i,subclass as c}from"../../core/accessorSupport/decorators.js";import p from"./ControlPointsGeoreference.js";import{toControlPointsGeoreference as l,mediaGeoreferenceProperty as a}from"./mediaUtils.js";import{reader as f}from"../../core/accessorSupport/decorators/reader.js";import{writer as u}from"../../core/accessorSupport/decorators/writer.js";let m=class extends(s(n(o))){constructor(e){super(e),this.georeference=null,this.opacity=1}readGeoreference(e){return p.fromJSON(e)}writeGeoreference(e,o,n,s){const i=s?.resources?.pendingOperations,c=()=>{const i=l(this.georeference,this.contentWidth,this.contentHeight);if(i){if("control-points"!==e.type&&t.getLogger(this).warn(`only georeference of type 'control-points' may be persisted. The georeference of type '${e.type}' has been automatically converted.`),4!==i.controlPoints?.length&&s?.messages)return void s.messages.push(new r("property:unsupported","only 'control-points' georeference with 4 control points may be persisted."));o[n]=i.write({},s)}};if("control-points"!==e.type&&!this.loaded&&i)return o[n]={},void i.push(this.load().then(c));c()}get contentWidth(){return 0}get contentHeight(){return 0}toSource(e){const{georeference:r,contentWidth:o,contentHeight:t}=this;if(null==e||null==r||0===o||0===t)return null;const n=r.toSourceNormalized(e);return null==n?null:(n.x*=o,n.y*=t,n)}};e([i(a)],m.prototype,"georeference",void 0),e([f("georeference")],m.prototype,"readGeoreference",null),e([u("georeference")],m.prototype,"writeGeoreference",null),e([i({json:{read:!1,write:!1}})],m.prototype,"opacity",void 0),m=e([c("esri.layers.support.MediaElementBase")],m);export{m as default};
