// All material copyright ESRI, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.7/esri/copyright.txt for details. //>>built define("require exports ../core/tsSupport/declareExtendsHelper ../core/tsSupport/decorateHelper dojo/i18n!./Feature/nls/Feature dojo/keys ../core/promiseUtils ../core/watchUtils ../core/accessorSupport/decorators ./Widget ./Feature/FeatureViewModel ./Feature/support/attachmentUtils ./support/uriUtils ./support/widget".split(" "),function(x,D,y,l,p,r,z,A,m,B,t,u,C,b){function e(b,d){return void 0===d?"esri-feature__"+b:"esri-feature__"+b+"-"+d}return function(v){function d(a){a=v.call(this)||this; a._chartMap=new Map;a._activeMediaMap=new Map;a._chartRequirePromise=null;a._refreshTimers=new Map;a._mediaInfo=new Map;a.contentEnabled=null;a.graphic=null;a.title=null;a.view=null;a.viewModel=new t;return a}y(d,v);d.prototype.postInitialize=function(){var a=this;this.own(A.init(this,"viewModel.content",function(){return a._setupMediaRefreshTimers()}))};d.prototype.destroy=function(){this._clearMediaRefreshTimers();this._activeMediaMap.clear();this._activeMediaMap=null;this._cancelChartModules(); this._destroyCharts()};d.prototype.render=function(){var a=b.tsx("div",{key:e("loading-container"),class:"esri-feature__loading-container"},b.tsx("span",{class:b.join("esri-icon-loading-indicator esri-rotating","esri-feature__loading-spinner")})),a=this.viewModel.waitingForContent?a:this._renderContent();return b.tsx("div",{class:"esri-feature"},b.tsx("div",{class:"esri-feature__size-container"},b.tsx("div",{class:"esri-feature__main-container"},a)))};d.prototype.goToMedia=function(a,c){this._setContentElementMedia(a, c)};d.prototype.nextMedia=function(a){this._pageContentElementMedia(a,"next")};d.prototype.previousMedia=function(a){this._pageContentElementMedia(a,"previous")};d.prototype._cancelChartModules=function(){this._chartRequirePromise&&this._chartRequirePromise.cancel()};d.prototype._destroyChart=function(a){var c=this._chartMap.get(a);c&&(c.chart.destroy(),c.tooltip.destroy());this._chartMap.delete(a)};d.prototype._destroyCharts=function(){this._chartMap.forEach(function(a){a.chart.destroy();a.tooltip.destroy()}); this._chartMap.clear()};d.prototype._renderContent=function(){this._destroyCharts();var a=this.viewModel.content;if("string"===typeof a)return b.tsx("div",{key:e("content-string"),innerHTML:a});if(b.isWidget(a))return b.tsx("div",{key:e("content-widget")},a.render());if(a instanceof HTMLElement)return b.tsx("div",{key:e("content-html-element"),bind:a,afterCreate:this._attachToNode});if(b.isWidgetBase(a))return b.tsx("div",{key:e("content-dijit"),bind:a.domNode,afterCreate:this._attachToNode});if(Array.isArray(a))return a.length? b.tsx("div",{key:e("content-content-elements")},a.map(this._renderContentElement,this)):null};d.prototype._renderContentElement=function(a,c){switch(a.type){case "attachments":return this._renderAttachments(a,c);case "fields":return this._renderFields(a,c);case "media":return this._renderMedia(a,c);case "text":return this._renderText(a,c);default:return null}};d.prototype._renderAttachmentInfo=function(a){var c=a.attachmentInfo,k=a.supportsResizeAttachments,f=c.contentType;a=c.name;var d=c.url,g= k&&u.isSupportedImage(f),e=-1===d.indexOf("?")?"?":"\x26",f=g?""+d+e+"w\x3d48":u.getIconPath(f),g=(n={},n["esri-feature__attachment-item-mask--icon"]=!g,n),n=(q={},q["esri-feature__attachments-image--resizable"]=k,q);return b.tsx("li",{class:"esri-feature__attachments-item",key:c},b.tsx("a",{class:"esri-feature__attachments-item-link",href:d,target:"_blank"},b.tsx("div",{classes:g,class:"esri-feature__attachment-item-mask"},b.tsx("img",{alt:a,classes:n,class:"esri-feature__attachments-image",title:a, src:f}),b.tsx("span",{class:"esri-feature__attachments-image-overlay"},b.tsx("span",{"aria-hidden":"true",class:"esri-feature__attachments-link-icon esri-icon-link-external"}))),b.tsx("span",{class:"esri-feature__attachments-filename"},a||p.noTitle)));var n,q};d.prototype._renderAttachments=function(a,c){var k=this,f=a.displayType,d=(c=a.attachmentInfos)&&c.length,g=this.get("graphic.layer.capabilities.operations.supportsResizeAttachments"),f=(h={},h["esri-feature__attachments--list"]="preview"!== f,h["esri-feature__attachments--preview"]="preview"===f,h);return d?b.tsx("div",{key:e("attachments-element"),class:b.join("esri-feature__attachments","esri-feature__content-element"),classes:f},b.tsx("div",{class:"esri-feature__attachments-title"},p.attach),b.tsx("ul",{class:"esri-feature__attachments-items"},c.map(function(c,b){return k._renderAttachmentInfo({attachmentInfo:c,attachmentInfoIndex:b,supportsResizeAttachments:g,contentElement:a})}))):null;var h};d.prototype._forceLTR=function(a){return"\x26lrm;"+ a};d.prototype._renderFieldInfo=function(a,c){var k=this.viewModel.formattedAttributes,f=k?k.content[c]||k.global:null,d=a.fieldName,k=a.label||d,f=f?null==f[d]?"":f[d]:"";a=!(!a.format||!a.format.dateFormat);f="number"!==typeof f||a?C.autoLink(f):this._forceLTR(f);a=(g={},g["esri-feature__field-data--date"]=a,g);return b.tsx("tr",{key:e("fields-element-info-row",c)},b.tsx("th",{key:e("fields-element-info-row-header",c),class:"esri-feature__field-header",innerHTML:k}),b.tsx("td",{key:e("fields-element-info-row-data", c),class:"esri-feature__field-data",classes:a,innerHTML:f}));var g};d.prototype._renderFields=function(a,c){var k=this;return(a=a.fieldInfos)?b.tsx("div",{key:e("fields-element",c),class:b.join("esri-feature__fields","esri-feature__content-element")},b.tsx("table",{class:"esri-table",summary:p.fieldsSummary,key:e("fields-element-table",c)},b.tsx("tbody",{key:e("fields-element-table-body",c)},a.map(function(a){return k._renderFieldInfo(a,c)})))):null};d.prototype._shouldOpenInNewTab=function(a){void 0=== a&&(a="");return!/^(?:mailto:|tel:)/.test(a.trim().toLowerCase())};d.prototype._clearMediaRefreshTimers=function(){this._refreshTimers.forEach(function(a){return clearTimeout(a)});this._refreshTimers.clear()};d.prototype._clearMediaRefreshTimer=function(a){var c=this._refreshTimers.get(a);c&&(clearTimeout(c),this._refreshTimers.delete(a))};d.prototype._getImageSource=function(a,c){var k=-1!==a.indexOf("?")?"\x26":"?";a=a.split("#");var b=a[1],b=void 0===b?"":b;return""+a[0]+k+"timestamp\x3d"+c+(b? "#":"")+b};d.prototype._setupMediaRefreshTimer=function(a){var c=this.get("viewModel.content");if(Array.isArray(c)&&(c=c[a])&&"media"===c.type){var b=this._activeMediaMap.get(a);isNaN(b)&&(b=0);(c=c.mediaInfos[b])&&"image"===c.type&&c.refreshInterval&&this._setRefreshTimeout(a,c)}};d.prototype._setupMediaRefreshTimers=function(){var a=this;this._clearMediaRefreshTimers();var c=this.get("viewModel.content");Array.isArray(c)&&c.forEach(function(c,b){return a._setupMediaRefreshTimer(b)})};d.prototype._updateMediaInfoTimestamp= function(a,c){var b=Date.now();this._mediaInfo.set(c,{timestamp:b,sourceURL:this._getImageSource(a,b)});this.scheduleRender()};d.prototype._setRefreshTimeout=function(a,c){var b=this,d=c.refreshInterval,e=c.value;d&&(c=6E4*d,this._updateMediaInfoTimestamp(e.sourceURL,a),c=setInterval(function(){b._updateMediaInfoTimestamp(e.sourceURL,a)},c),this._refreshTimers.set(a,c))};d.prototype._renderMediaInfoType=function(a,c){var d=a.value,f=a.title,f=void 0===f?"":f,w=a.type,g=a.refreshInterval,h=d.sourceURL, d=d.linkURL;if("image"===w)return a=this._shouldOpenInNewTab(d)?"_self":"_blank",h=(g=g?this._mediaInfo.get(c):null)?g.sourceURL:h,c=b.tsx("img",{alt:f,key:e("media-image-"+(g?g.timestamp:0),c),src:h}),(f=d?b.tsx("a",{title:f,href:d,target:a},c):null)?f:c;if(-1!==w.indexOf("chart"))return b.tsx("div",{key:e("chart",c),bind:this,"data-media-info":a,"data-content-element-index":c,class:"esri-feature__media-chart",afterCreate:this._getChartDependencies,afterUpdate:this._getChartDependencies})};d.prototype._getChartDependencies= function(a){var c=this,b=a["data-media-info"],d=a["data-content-element-index"],e=b.value,g=e.theme||"Claro",h=b.type,n=g;"string"===typeof g&&(n=g.replace(/\./g,"/"));this._cancelChartModules();this._chartRequirePromise=z.create(function(a){return x(["dojox/charting/Chart2D","dojox/charting/action2d/Tooltip","dojox/charting/themes/"+n],function(){for(var c=[],b=0;b