/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import{clone as o}from"../../core/lang.js";import{property as r,subclass as l}from"../../core/accessorSupport/decorators.js";import i from"../../portal/PortalItem.js";let s=class extends e{constructor(t){super(t),this._abortController=null,this.attributionEnabled=!0,this.author=null,this.copyright=null,this.customTextElements=null,this.dpi=96,this.dynamicLegendEnabled=void 0,this.fileName=null,this.forceFeatureAttributes=!1,this.format="pdf",this.height=null,this.includeTables=!0,this.id=null,this.state="ready",this.layout="letter-ansi-a-landscape",this.layoutItem=null,this.legendEnabled=void 0,this.northArrowEnabled=void 0,this.scale=null,this.scaleBarEnabled=void 0,this.scaleBarUnit=null,this.scaleEnabled=!1,this.title=null,this.width=null}async applyTemplate(t,e){if(t?.id===this.id&&"error"!==t?.state)return;if(this._abortController&&(this._abortController.abort(),this._abortController=null),!t)return;if(this._set("state","pending"),this._resetMapSurroundInfoOptions(),this._set("id",t.id),this.set({layout:t.layout,layoutItem:t.layoutItem}),!t.layoutOptions&&t.layoutItem){const e=new AbortController;if(this._abortController=e,await t.fetchLayoutItemTemplateInfo({signal:this._abortController.signal}),"loaded"!==t.state){if("error"===t.state&&this._set("state","error"),this._abortController!==e)return;return void(this._abortController=null)}this._abortController=null}const r=e?.customLayoutOptions,l=e?.customTextElements??t.layoutTemplateInfo?.layoutOptions?.customTextElements??this.customTextElements;this.set({customTextElements:l?o(l):void 0,format:this.format??t.format,legendEnabled:r?.legend??t.layoutOptions?.legend??this.legendEnabled,dynamicLegendEnabled:r?.dynamicLegend??t.layoutOptions?.dynamicLegend??this.dynamicLegendEnabled,northArrowEnabled:r?.northArrow??t.layoutOptions?.northArrow??this.northArrowEnabled,scaleBarEnabled:r?.scaleBar??t.layoutOptions?.scaleBar??this.scaleBarEnabled}),this._set("state","ready")}reset(){this._set("id",null),this._set("state","ready"),this.set({layout:null,layoutItem:null,customTextElements:null}),this._resetMapSurroundInfoOptions()}_resetMapSurroundInfoOptions(){this.set({legendEnabled:void 0,dynamicLegendEnabled:void 0,northArrowEnabled:void 0,scaleBarEnabled:void 0})}};t([r()],s.prototype,"attributionEnabled",void 0),t([r()],s.prototype,"author",void 0),t([r()],s.prototype,"copyright",void 0),t([r()],s.prototype,"customTextElements",void 0),t([r()],s.prototype,"dpi",void 0),t([r()],s.prototype,"dynamicLegendEnabled",void 0),t([r()],s.prototype,"fileName",void 0),t([r()],s.prototype,"forceFeatureAttributes",void 0),t([r()],s.prototype,"format",void 0),t([r()],s.prototype,"height",void 0),t([r()],s.prototype,"includeTables",void 0),t([r({readOnly:!0})],s.prototype,"id",void 0),t([r({readOnly:!0})],s.prototype,"state",void 0),t([r()],s.prototype,"layout",void 0),t([r({type:i})],s.prototype,"layoutItem",void 0),t([r()],s.prototype,"legendEnabled",void 0),t([r()],s.prototype,"northArrowEnabled",void 0),t([r()],s.prototype,"scale",void 0),t([r()],s.prototype,"scaleBarEnabled",void 0),t([r()],s.prototype,"scaleBarUnit",void 0),t([r()],s.prototype,"scaleEnabled",void 0),t([r()],s.prototype,"title",void 0),t([r()],s.prototype,"width",void 0),s=t([l("esri.widgets.Print.TemplateOptions")],s);const a=s;export{a as default};
