// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
require({cache:{"url:widgets/CostAnalysis/project-overview.html":'\x3cdiv\x3e\r\n  \x3cdiv class\x3d"esriCTProjectOverview" data-dojo-attach-point\x3d"projectOverviewNode"\x3e\x3c/div\x3e\r\n  \x3cdiv data-dojo-attach-point\x3d"assetSummaryInfo"\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"assetSummaryDiv"\x3e\x3c/div\x3e\r\n    \x3ctable class\x3d"esriCTTable esriCTBoldFont esriCTTotalCostTable" style\x3d"width: 100%;"\x3e\r\n      \x3ctbody\x3e\r\n        \x3ctr tabindex\x3d"0" \x3e\r\n          \x3ctd aria-label\x3d"${nls.projectOverview.totalCostLabel}" class\x3d"esriCTAssetItemsTotalCostLabel" data-dojo-attach-point\x3d"totalCostLabel"\x3e${nls.projectOverview.totalCostLabel}\x3c/td\x3e\r\n          \x3ctd class\x3d"esriCTAssetItemsTotalCost" data-dojo-attach-point\x3d"totalCost"\x3e\x3c/td\x3e\r\n        \x3c/tr\x3e\r\n        \x3ctr tabindex\x3d"0" \x3e\r\n          \x3ctd aria-label\x3d"${nls.projectOverview.grossCostLabel}" class\x3d"esriCTAssetItemsGrossCostLabel" data-dojo-attach-point\x3d"grossCostLabel"\x3e${nls.projectOverview.grossCostLabel}\x3c/td\x3e\r\n          \x3ctd class\x3d"esriCTAssetItemsGrossCost" data-dojo-attach-point\x3d"grossCost"\x3e\x3c/td\x3e\r\n        \x3c/tr\x3e\r\n        \x3ctr\x3e\r\n          \x3ctd style\x3d"font-weight: normal; font-style: italic;" colspan\x3d"2" data-dojo-attach-point\x3d"roundingLabel"\x3e${nls.projectOverview.roundingLabel}\x3c/td\x3e\r\n        \x3c/tr\x3e\r\n      \x3c/tbody\x3e\r\n    \x3c/table\x3e\r\n  \x3c/div\x3e\r\n  \x3cdiv data-dojo-attach-point\x3d"projectSummaryInfo"\x3e\r\n  \x3c/div\x3e\r\n\x3c/div\x3e'}});
define("dojo/_base/declare jimu/BaseWidget dojo/Evented dijit/_WidgetsInTemplateMixin dojo/text!./project-overview.html dojo/_base/lang dojo/_base/array dojo/dom-attr dojo/dom-class dojo/string dojo/on dojo/Deferred esri/graphic esri/geometry/Point esri/tasks/BufferParameters esri/geometry/geometryEngine esri/tasks/GeometryService esri/geometry/Polygon dojo/dom-construct jimu/dijit/LoadingIndicator ./advance-item-list jimu/utils dijit/focus".split(" "),function(A,B,C,D,r,e,n,l,p,E,u,F,v,G,H,w,I,x,
k,J,K,y,z){return A([B,C,D],{templateString:r,baseClass:"jimu-widget-cost-analysis-project-overview",postCreate:function(){this.inherited(arguments);this.listData=[{title:this.nls.projectOverview.assetItemsTitle,content:this.assetSummaryInfo,icon:"",actionIcon:"",isOpen:!0},{title:this.nls.projectOverview.assetStatisticsTitle,content:"",icon:"",actionIcon:"",actionIconTitle:"",isOpen:!1}];this.config.projectSettings.projectLayer&&(this.projectLayer=this.layerInfosObj.getLayerInfoById(this.config.projectSettings.projectLayer).layerObject,
this.updateProjectInfo(this.projectInfo),this.listData.push({title:this.nls.projectOverview.projectSummaryTitle,content:this.projectSummaryInfo,icon:"",actionIcon:"",actionIconTitle:this.nls.projectAttribute.projectAttributeText,isOpen:!1}));this._initLoadingIndicator()},updateProjectInfo:function(a){this.projectInfo=a;this.config.projectSettings.projectLayer&&(a=E.substitute(this.nls.projectOverview.projectName,{name:this.projectInfo.name}),l.set(this.projectNameDiv,"innerHTML",a),l.set(this.projectNameDiv,
"title",a),l.set(this.projectNameDiv,"aria-label",a),p.contains(this.projectNameDiv,"esriCTHidden")&&(p.remove(this.projectNameDiv,"esriCTHidden"),setTimeout(e.hitch(this,function(){y.initFirstFocusNode(this.widgetDomNode,this.projectNameDiv);z.focus(this.projectNameDiv)}),0)))},_initLoadingIndicator:function(){this._loadingIndicator=new J({hidden:!0});this._loadingIndicator.placeAt(this.domNode.parentNode.parentNode.parentNode);this._loadingIndicator.startup()},startup:function(){this.inherited(arguments);
this.projectInfo&&""===this.projectInfo.name&&(l.set(this.projectNameDiv,"title",""),l.set(this.projectNameDiv,"tabindex","-1"),p.contains(this.projectNameDiv,"esriCTHidden")||(p.add(this.projectNameDiv,"esriCTHidden"),setTimeout(e.hitch(this,function(){y.initFirstFocusNode(this.widgetDomNode,this.featureModeTextNode);z.focus(this.featureModeTextNode)}),0)));this._initProjectOverview()},_initProjectOverview:function(){var a=new K({itemList:this.listData,showArrow:!0,togglePanels:!1,openMultiple:!0,
widgetDomNode:this.widgetDomNode,fromProjectOverview:!0,nls:this.nls},k.create("div",{},this.projectOverviewNode));this.own(u(a,"onActionButtonClicked",e.hitch(this,function(c){this.emit("actionClicked",c)})));this.own(u(a,"onTitleClicked",e.hitch(this,function(c){this.emit("titleClicked",c)})));a.startup();a=this.totalCostLabel.innerHTML.replace("*",this.nls.projectOverview.roundingLabel);var b=this.grossCostLabel.innerHTML.replace("*",this.nls.projectOverview.roundingLabel);l.set(this.totalCostLabel,
"aria-label",a.replace("*",""));l.set(this.grossCostLabel,"aria-label",b.replace("*",""))},showAssetItemSummary:function(a,b){var c=0;k.empty(this.assetSummaryDiv);if(0<Object.keys(a).length){var d,g;var f=k.create("div",{},this.assetSummaryDiv);f=k.create("table",{style:{width:"100%"},"class":"esriCTTable"},f);f=k.create("tbody",{},f);for(d in a){var h=k.create("tr",{},f);k.create("td",{innerHTML:a[d].layerName,"class":"esriCTSummaryLayerTitle",colspan:3},h);for(g in a[d].templates){var q=a[d].templates[g];
var m=q.units;h=k.create("tr",{tabindex:"0"},f);if("esriGeometryPoint"!==a[d].geometryType){m=this.appUtils.applyRounding(m);var t=this.appUtils.getUnitsAbbreviation(a[d].geometryType,this.config.generalSettings.measurementUnit)}else t=this.nls.workBench.units;k.create("td",{innerHTML:g},h);k.create("td",{innerHTML:m+" "+t},h);k.create("td",{"class":"esriCTAssetItemsCost",innerHTML:this.config.generalSettings.currency+" "+this.appUtils.applyRounding(q.cost)},h);m=a[d].layerName+" "+g+" "+m+" "+t+
" "+this.config.generalSettings.currency+" "+this.appUtils.applyRounding(q.cost);l.set(h,"aria-label",m);c+=q.cost}}}else k.create("div",{style:"padding: 10px 0; text-align : center; font-weight : bold",innerHTML:this.nls.workBench.noAssetAddedMsg,tabindex:"0","aria-label":this.nls.workBench.noAssetAddedMsg,role:"presentation"},this.assetSummaryDiv);this._updateProjectCost(c);b&&this._getProjectBoundary(a)},grossCostUpdated:function(a){var b=this.appUtils.roundProjectCostValue(this.config.generalSettings.roundCostType,
a);b=this.config.generalSettings.currency+" "+b;l.set(this.grossCost,"innerHTML",b);l.set(this.grossCost,"aria-label",b);this._saveProjectAttributes(this._projectTotalCost,a)},_updateProjectCost:function(a){this._projectTotalCost=a;a=this.appUtils.roundProjectCostValue(this.config.generalSettings.roundCostType,this._projectTotalCost);a=this.config.generalSettings.currency+" "+a;l.set(this.totalCost,"innerHTML",a);this.emit("totalCostCalculated",this._projectTotalCost)},_getProjectBoundary:function(a){0===
Object.keys(a).length?this._saveProjectGeometry(new x):(this._loadingIndicator.show(),"outline"===this.config.generalSettings.projectAreaType?(a=this._convertFeatureStoredToPoints(a),this.geometryService.convexHull(a,e.hitch(this,function(b){this._loadingIndicator.hide();this._onConvexHullComplete(b)}),e.hitch(this,function(){this._loadingIndicator.show()}))):this._createBufferOnAssets(a).then(e.hitch(this,function(b){this._loadingIndicator.hide();b&&this._saveProjectGeometry(b)})))},_convertFeatureStoredToPoints:function(a){var b=
[],c;for(c in a)if(a.hasOwnProperty(c)){var d=a[c].templates;for(r in d)d=a[c].templates[r].features,b=b.concat(this._getFeatureGeometry(d))}return b},_getFeatureGeometry:function(a){var b=[];n.forEach(a,function(c){var d=c.geometry.type,g=c.geometry;"point"===d?b.push(g):n.forEach("polyline"===d?g.paths:g.rings,function(f){n.forEach(f,function(h){h=new G(h[0],h[1],g.spatialReference);b.push(h)})})});return b},_onConvexHullComplete:function(a){"polygon"!==a.type&&(a=new x);this._saveProjectGeometry(a)},
_createBufferOnAssets:function(a){var b=[],c;var d=new F;for(f in a)if(a.hasOwnProperty(f)){var g=a[f].templates;for(c in g)g=a[f].templates[c].features,b=b.concat(this._getBufferGeometry(g))}var f=this.appUtils.units[this.config.generalSettings.measurementUnit].bufferUnit;a=new H;a.distances=[this.config.generalSettings.bufferDistance];a.outSpatialReference=this.map.spatialReference;a.unit=I[f];a.geometries=b;this.map.spatialReference.isWebMercator()||4326===this.map.spatialReference.wkid?(b=w.geodesicBuffer(a.geometries,
a.distances,a.unit,!0),d.resolve(b[0])):this.geometryService.buffer(a,e.hitch(this,function(h){d.resolve(h)}),e.hitch(this,function(){d.resolve(null)}));return d.promise},_getBufferGeometry:function(a){var b=[];n.forEach(a,e.hitch(this,function(c){c=c.geometry;"polygon"===c.type&&(c=w.simplify(c));b.push(c)}));return b},_saveProjectGeometry:function(a){if(this.projectLayer){this._loadingIndicator.show();var b=new v;b.attributes={};b.attributes[this.projectLayer.objectIdField]=this.projectInfo.objectId;
b.geometry=a;this.projectLayer.applyEdits(null,[b],null,e.hitch(this,function(){this.projectLayer.refresh();this.emit("addOrModifyLabelPoint",{projectGeometry:a});this._loadingIndicator.hide()}),e.hitch(this,function(){this.appUtils.showMessage(this.nls.projectOverview.unableToSaveProjectBoundary);this._loadingIndicator.hide()}))}},_saveProjectAttributes:function(a,b){if(this.projectLayer){this._loadingIndicator.show();var c=new v;c.attributes={};c.attributes[this.projectLayer.objectIdField]=this.projectInfo.objectId;
n.forEach(this.projectLayer.fields,e.hitch(this,function(d){"TOTALASSETCOST"===d.name.toUpperCase()?c.attributes[d.name]=a:"GROSSPROJECTCOST"===d.name.toUpperCase()&&(c.attributes[d.name]=b)}));this.projectLayer.applyEdits(null,[c],null,e.hitch(this,function(){this.projectLayer.refresh();this._loadingIndicator.hide()}),e.hitch(this,function(){this.appUtils.showMessage(this.nls.projectOverview.unableToSaveProjectCost);this._loadingIndicator.hide()}))}}})});