/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["require","../../chunks/_rollupPluginBabelHelpers","../../chunks/tslib.es6","../../Graphic","../../core/Accessor","../../core/HandleOwner","../../core/Logger","../../core/maybe","../../core/reactiveUtils","../../core/accessorSupport/decorators/property","../../core/arrayUtils","../../core/has","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/subclass","../../symbols/support/symbolUtils"],(function(e,t,r,n,o,l,i,a,s,u,p,c,y,d,m){"use strict";const h=e=>Object.freeze(Object.defineProperty({__proto__:null,default:e},Symbol.toStringTag,{value:"Module"}));var f;const b=i.getLogger("esri.widgets.FeatureTemplates.TemplateItem");let _=f=function(e){function r(t){var r;return(r=e.call(this,t)||this)._activeFetchInfo={id:null,request:null},r.description=null,r.label=null,r.layer=null,r.template=null,r.thumbnail=null,r}t._inheritsLoose(r,e);var n=r.prototype;return n.initialize=function(){this.handles.add(s.watch((()=>{const{layer:e}=this;return[e&&"renderer"in e?e.renderer:null,this.template]}),(()=>{this._activeFetchInfo.id=null,this._activeFetchInfo.request=null,this._set("thumbnail",null)}),s.initial))},n.clone=function(){const e=a.isSome(this.thumbnail)?this.thumbnail.cloneNode(!0):null,t=new f({layer:this.layer,template:this.template});return t._set("thumbnail",e),t},r.fetchThumbnail=function(){var e=t._asyncToGenerator((function*(e,t){var r;if(T(e))return b.warn("Thumbnails for sublayers of a SubtypeGroupLayer are not yet supported."),null;const n=yield v(e,t);if(a.isNone(n))return null;const o={maxSize:36};"dictionary"===(null==(r=e.renderer)?void 0:r.type)&&(o.fieldMap=e.renderer.fieldMap,o.feature={attributes:t.prototype.attributes});return yield m.renderPreviewHTML(n,o)}));function r(t,r){return e.apply(this,arguments)}return r}(),r}(l.HandleOwnerMixin(o));function v(e,t){return S.apply(this,arguments)}function S(){return(S=t._asyncToGenerator((function*(e,t){const{renderer:r}=e;if(r){const e=new n({attributes:t.prototype.attributes}),o=yield r.getSymbolAsync(e);if(o)return o}return g(e)}))).apply(this,arguments)}function g(e){return w.apply(this,arguments)}function w(){return(w=t._asyncToGenerator((function*(t){const{geometryType:r}=t,n="point"===r||"multipoint"===r?yield new Promise(((t,r)=>e(["../../symbols/SimpleMarkerSymbol"],(e=>t(h(e))),r))):"polyline"===r?yield new Promise(((t,r)=>e(["../../symbols/SimpleLineSymbol"],(e=>t(h(e))),r))):"polygon"===r||"mesh"===r||"multipatch"===r?yield new Promise(((t,r)=>e(["../../symbols/SimpleFillSymbol"],(e=>t(h(e))),r))):null;return n?new n.default:null}))).apply(this,arguments)}function T(e){return"subtype-group"===e.type}r.__decorate([u.property({aliasOf:"template.description"})],_.prototype,"description",void 0),r.__decorate([u.property({aliasOf:"template.name"})],_.prototype,"label",void 0),r.__decorate([u.property()],_.prototype,"layer",void 0),r.__decorate([u.property()],_.prototype,"template",void 0),r.__decorate([u.property({readOnly:!0})],_.prototype,"thumbnail",void 0),_=f=r.__decorate([d.subclass("esri.widgets.FeatureTemplates.TemplateItem")],_);return _}));
