// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/dijit/analysis/utils","dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/_base/connect dojo/_base/event dojo/_base/fx dojo/_base/json dojo/dom-attr dojo/has dojo/i18n dojo/io-query dojo/i18n!../../nls/jsapi dojo/json dojo/string dojo/query dojo/date/locale dojo/dom-style dojo/dom-class dojo/dom-construct dojo/Deferred dojo/promise/all dojo/fx/easing dojo/number dojo/_base/window dojo/when dojo/dom dojo/on dojo/data/ItemFileWriteStore dojo/topic dijit/registry dijit/Dialog dijit/form/CheckBox ../../kernel ../../lang ../../units ../../request ./HelpWindow ../../tasks/query ../../dijit/BrowseItems ../../layers/FeatureLayer ./PluginAnalysisLayers ../../tasks/Geoprocessor ../../dijit/SingleFilter ./FeatureRecordSetLayer ./PluginLayers ./PCSList ./ItemTypes ../../layers/ArcGISImageServiceLayer ../../layers/RasterFunction".split(" "),
function(z,h,m,ia,S,H,T,E,U,ja,V,r,A,l,y,I,u,W,t,w,X,J,B,Y,F,K,L,Z,ka,aa,ba,M,ca,k,g,G,da,ea,fa,C,la,N,ma,ga,na,O,v,P,ha){z={};h.mixin(z,{_helpDialog:null,i18n:null,UNITSMAP:{Feet:"esriFeet",Yards:"esriYards",Miles:"esriMiles",Meters:"esriMeters",Kilometers:"esriKilometers",NauticalMiles:"esriNauticalMiles"},initHelpLinks:function(a,b,d){if(a){var c=aa.byNode(a),e=c?c.get("helpFileName"):d&&d.helpFileName?d.helpFileName:null,f=c?c.get("isSingleTenant"):d&&d.isSingleTenant?d.isSingleTenant:!1,n="standard",
x=c&&c.portalSelf?c.portalSelf.helpBase:d&&d.helpBase?d.helpBase:null;this._helpDialog||(this._helpDialog=new da({isPortal:f}));c&&(c.showGeoAnalyticsParams||c.showBigData)||d&&d.analysisMode&&"bigdata"===d.analysisMode?(e+="_bd",n="bigdata"):d&&d.analysisMode&&"raster"===d.analysisMode&&(e+="_ra",n="raster");y("[esriHelpTopic]",a).forEach(function(c,p,g){c&&(u.set(c,"display",k.isDefined(b)&&!0!==b?"none":""),k.isDefined(c._helpClickHandler)&&(c._helpClickHandler.remove(),c._helpClickHandler=null),
c._helpClickHandler=L(c,"click",h.hitch(this,function(b){S.stop(b);d&&d.showHelpFromUrl&&d.helpUrl?this._helpDialog.show(b,{showHelpFromUrl:d.showHelpFromUrl,helpUrl:d.helpUrl}):this._helpDialog.show(b,{helpId:E.get(c,"esriHelpTopic"),helpFileName:e,analysisGpServer:d&&d.analysisGpServer?d.analysisGpServer:null,helpParentNode:a,isPortal:f,analysisMode:n,helpBase:x})})))},this)}},constructAnalysisFeatColl:function(a){var b={},d;b.featureCollection=a.layerDefinition;for(d in b.featureCollection)b.featureCollection.hasOwnProperty(d)&&
"objectIdField"===d&&(b.featureCollection.objectIdFieldName=h.clone(b.featureCollection.objectIdField),delete b.featureCollection.objectIdField);b.featureCollection.features=a.featureSet.features;return b},constructAnalysisInputLyrObj:function(a,b,d){var c={},e,f,n;k.isDefined(d)||(d=!0);a.getMap?f=a.getMap():a._map&&(f=a._map);if(a.url&&!a._collection)c={url:a.url},e=this.isHostedService(a.url),n=10.2<=a.version&&a._useStandardizedQueries,a.getDefinitionExpression&&a.getDefinitionExpression()?c.filter=
a.getDefinitionExpression():k.isDefined(a.definitionExpression)&&""!==a.definitionExpression&&(c.filter=a.definitionExpression),a.useMapTime&&a.timeInfo&&f&&f.timeExtent&&(n||e||10.2<=a.version)&&d&&(d="",a.timeInfo.startTimeField&&!a.timeInfo.endTimeField?(f.timeExtent.startTime&&(d=a.timeInfo.startTimeField+" \x3e "+(e?"":"timestamp ")+"'"+this.formatDate(f.timeExtent.startTime)+"'"),f.timeExtent.endTime&&(f.timeExtent.startTime&&(d+=" AND "),d+=a.timeInfo.startTimeField+" \x3c "+(e?"":"timestamp ")+
"'"+this.formatDate(f.timeExtent.endTime)+"'")):!a.timeInfo.startTimeField&&a.timeInfo.endTimeField?(f.timeExtent.startTime&&(d=a.timeInfo.endTimeField+" \x3e "+(e?"":"timestamp ")+"'"+this.formatDate(f.timeExtent.startTime)+"'"),f.timeExtent.endTime&&(f.timeExtent.startTime&&(d+=" AND "),d+=a.timeInfo.endTimeField+" \x3c "+(e?"":"timestamp ")+"'"+this.formatDate(f.timeExtent.endTime)+"'")):a.timeInfo.startTimeField&&a.timeInfo.endTimeField&&(f.timeExtent.startTime&&(d=a.timeInfo.startTimeField+" \x3e "+
(e?"":"timestamp ")+"'"+this.formatDate(f.timeExtent.startTime)+"'"),f.timeExtent.endTime&&(f.timeExtent.startTime&&(d+=" AND "),d+=a.timeInfo.endTimeField+" \x3c "+(e?"":"timestamp ")+"'"+this.formatDate(f.timeExtent.endTime)+"'")),c.filter=c.filter?c.filter+(" AND "+d):d),a.credential&&(c.serviceToken=a.credential.token),-1!==c.url.indexOf("?")&&(e=c.url.substring(c.url.indexOf("?")+1,c.url.length),e=V.queryToObject(e),h.mixin(c,e),c.url=c.url.substring(0,c.url.indexOf("?")));else if(!a.url||a._collection)try{c=
a.toJson()}catch(x){a._json=A.parse(a._json),c=a.toJson()}c.name=a.name;b&&(c=new ga(c));return c},formatDate:function(a){return I.format(a,{datePattern:"yyyy-MM-dd",selector:"date"})+" "+I.format(a,{selector:"time",timePattern:"HH:mm:ss"})},isHostedService:function(a){if(!a)return!1;var b=-1!==a.indexOf(".arcgis.com/");a=-1!==a.indexOf("//services")||-1!==a.indexOf("//tiles")||-1!==a.indexOf("//features");return b&&a},isTimeEnabled:function(a){var b=10.2<=a.version&&a._useStandardizedQueries;return a.useMapTime&&
a.timeInfo&&(b||10.2<=a.version)||k.isDefined(a.time)},isTimeInstantLayer:function(a){return k.isDefined(a.timeInfo)&&k.isDefined(a.timeInfo.startTimeField)&&!k.isDefined(a.timeInfo.endTimeField)||k.isDefined(a.time)&&k.isDefined(a.time.timeType)&&"instant"===a.time.timeType},buildReport:function(a,b){var d="";b||(b={},h.mixin(b,r.analysisMsgCodes));m.forEach(a,function(a,e){var c,n,x;"string"===typeof a.message?(c=k.isDefined(b[a.messageCode])?b[a.messageCode]:a.message,d+=a.style.substring(0,a.style.indexOf("\x3c/"))+
(this._isEmptyObject(a.params)?c:l.substitute(c,a.params))+a.style.substring(a.style.indexOf("\x3c/"))):h.isArray(a.message)&&(x=[],n=h.clone(a.style),m.forEach(a.message,function(d,e){n=n.replace(/<\//,"${"+e+"}");c=k.isDefined(b[a.messageCode+"_"+e])?b[a.messageCode+"_"+e]:d;c=this._isEmptyObject(a.params)?c:l.substitute(c,a.params);x.push(c+"\x3c/")},this),n=l.substitute(n,x),d+=n)},this);return d},getLayerFeatureCount:function(a,b){var d=new ea;d.geometry=b.geometry||"";d.where=b.where||"1\x3d1";
d.geometryType=b.geometryType||"esriGeometryEnvelope";a.getDefinitionExpression&&a.getDefinitionExpression()&&!b.where?d.where=a.getDefinitionExpression():k.isDefined(a.definitionExpression)&&""!==a.definitionExpression&&!b.where&&(d.where=a.definitionExpression);return a.queryCount(d)},createPolygonFeatureCollection:function(a){var b;b={layerDefinition:null,featureSet:{features:[],geometryType:"esriGeometryPolygon"}};b.layerDefinition={currentVersion:10.2,copyrightText:"",defaultVisibility:!0,relationships:[],
isDataVersioned:!1,supportsRollbackOnFailureParameter:!0,supportsStatistics:!0,supportsAdvancedQueries:!0,geometryType:"esriGeometryPolygon",minScale:0,maxScale:0,objectIdField:"OBJECTID",templates:[],type:"Feature Layer",displayField:"TITLE",visibilityField:"VISIBLE",name:a,hasAttachments:!1,typeIdField:"TYPEID",capabilities:"Query",allowGeometryUpdates:!0,htmlPopupType:"",hasM:!1,hasZ:!1,globalIdField:"",supportedQueryFormats:"JSON",hasStaticData:!1,maxRecordCount:-1,indexes:[],types:[],drawingInfo:{renderer:{type:"simple",
symbol:{color:[0,0,0,255],outline:{color:[0,0,0,255],width:3,type:"esriSLS",style:"esriSLSSolid"},type:"esriSFS",style:"esriSFSNull"},label:"",description:""},transparency:0,labelingInfo:null,fixedSymbols:!0},fields:[{alias:"OBJECTID",name:"OBJECTID",type:"esriFieldTypeOID",editable:!1},{alias:"Title",name:"TITLE",length:50,type:"esriFieldTypeString",editable:!0},{alias:"Visible",name:"VISIBLE",type:"esriFieldTypeInteger",editable:!0},{alias:"Description",name:"DESCRIPTION",length:1073741822,type:"esriFieldTypeString",
editable:!0},{alias:"Type ID",name:"TYPEID",type:"esriFieldTypeInteger",editable:!0}]};return b},createPointFeatureCollection:function(a){var b;b={layerDefinition:null,featureSet:{features:[],geometryType:"esriGeometryPoint"}};b.layerDefinition={objectIdField:"OBJECTID",templates:[],type:"Feature Layer",drawingInfo:{renderer:{field1:"TYPEID",type:"simple",symbol:{height:24,xoffset:0,yoffset:12,width:24,contentType:"image/png",type:"esriPMS",url:"http://static.arcgis.com/images/Symbols/Basic/GreenStickpin.png"},
description:"",value:"0",label:"Stickpin"}},displayField:"TITLE",visibilityField:"VISIBLE",name:a,hasAttachments:!1,typeIdField:"TYPEID",capabilities:"Query",types:[],geometryType:"esriGeometryPoint",fields:[{alias:"OBJECTID",name:"OBJECTID",type:"esriFieldTypeOID",editable:!1},{alias:"Title",name:"TITLE",length:50,type:"esriFieldTypeString",editable:!0},{alias:"Visible",name:"VISIBLE",type:"esriFieldTypeInteger",editable:!0},{alias:"Description",name:"DESCRIPTION",length:1073741822,type:"esriFieldTypeString",
editable:!0},{alias:"Type ID",name:"TYPEID",type:"esriFieldTypeInteger",editable:!0}]};return b},createFolderStore:function(a,b){var d=new Z({data:{identifier:"id",label:"name",items:[]}});d.newItem({name:b,id:""});m.forEach(a,function(a){d.newItem({name:a.title,id:a.id})});return d},setupFoldersUI:function(a){a.folderSelect.set("store",a.folderStore);a.folderSelect.set("required",!0);a.folderSelect.set("searchAttr","name");k.isDefined(a.folderId)?a.folderStore.get(a.folderId).then(h.hitch(this,function(b){k.isDefined(b)?
a.folderSelect.set("item",b):a.folderStore.get("").then(function(b){a.folderSelect.set("item",b)},this)})):a.folderName?a.folderStore.fetch({query:{name:a.folderName},onComplete:h.hitch(this,function(b){k.isDefined(b)&&0<b.length?a.folderSelect.set("item",b[0]):a.folderStore.get("").then(function(b){a.folderSelect.set("item",b)},this)})}):a.username?a.folderSelect.set("displayedValue",a.username):a.folderStore.get("").then(function(b){a.folderSelect.set("item",b)},this)},_isEmptyObject:function(a){for(var b in a)if(a.hasOwnProperty(b))return!1;
return!0},validateServiceName:function(a,b){var d=/(:|&|<|>|%|#|\?|\\|\"|\/|\+)/.test(a),c=!0,e,f;k.isDefined(b)&&b.textInput&&(f=b.textInput);this.initI18n();if(0===a.length||0===l.trim(a).length)e=this.i18n.requiredValue,c=!1;else if(d)e=this.i18n.invalidServiceName,c=!1;else if(98<a.length)e=this.i18n.invalidServiceNameLength,c=!1;else if(170<encodeURIComponent(a).length){for(d=a+"";170<encodeURIComponent(d).length;)d=d.substring(0,d.length-1);e=l.substitute(this.i18n.suggestedServiceNameLength,
{count:d.length});c=!1}f&&!c&&f.set("invalidMessage",e);return c},getStepNumber:function(a){y(".esriAnalysisNumberLabel",a).forEach(function(a,d){var b=this._getNumberLabel(d);E.set(a,"innerHTML",b)},this)},_getNumberLabel:function(a){var b="";this.initI18n();switch(a){case 0:b=this.i18n.oneLabel;break;case 1:b=this.i18n.twoLabel;break;case 2:b=this.i18n.threeLabel;break;case 3:b=this.i18n.fourLabel;break;case 4:b=this.i18n.fiveLabel;break;case 5:b=this.i18n.sixLabel;break;case 6:b=this.i18n.sevenLabel;
break;case 7:b=this.i18n.eightLabel;break;case 8:b=this.i18n.nineLabel}return b},populateAnalysisLayers:function(a,b,d,c){if(a){var e=[],f=a.get(b);a.rerun&&!f&&(c||(c={}),c.chooseBlank=!0);a._titleRow&&u.set(a._titleRow,"display","none");a._analysisLabelRow&&u.set(a._analysisLabelRow,"display","table-row");a._selectAnalysisRow&&(u.set(a._selectAnalysisRow,"display","table-row"),W.add(a._analysisSelect.domNode,"esriTrailingMargin3"),u.set(a._analysisSelect.domNode.parentNode,"padding-bottom","1em"));
a.domNode&&this.getStepNumber(a.domNode);k.isDefined(c)&&c.chooseLabel&&e.push({value:-1,label:this.i18n.chooseLabel});k.isDefined(c)&&c.chooseBlank&&e.push({value:"  ",label:""});k.isDefined(c)&&k.isDefined(c.posIncrement)||(k.isDefined(c)||(c={}),c.posIncrement=0);a.get(d)||a.set(d,[]);m.forEach(a.get(d),function(a,b){b+=c.posIncrement;var d={value:k.isDefined(c)&&c.chooseLabel?""+b+1:""+b,label:a.name};f&&(a.name===f.name||a.url&&f.url&&a.url===f.url)&&(d.selected=!0);e.push(d)},this);a._analysisSelect.addOption(e);
a._analysisSelect.set("required",!0);c.chooseBlank&&"  "===a._analysisSelect.get("value")&&setTimeout(h.hitch(this,this._validateSelectUI,a._analysisSelect),100)}},isValidAnalysisLayer:function(a){var b,d,c,e,f,n,h,q="",p=!0;b={isValid:p,validationMessage:q};var g,Q,D=0,R=0,t=0,r,u,v;if(!k.isDefined(a)||!k.isDefined(a.toolName))return b;this.initI18n();k.isDefined(this.i18n.cblPointMsg)||(this.i18n.cblPointMsg="You need to have at least one point feature layer to run ${toolName}.");b=a.toolName;d=
a.layers;c=a.analysisLayer;e=b.charAt(0).toLowerCase()+b.substring(1);h=this.i18n;a=a.showReadyToUseLayers||!1;m.forEach(d,function(a){a instanceof P&&(r=!0);r&&1<a.bandCount&&(u=!0);r&&1===a.bandCount&&(v=!0);"esriGeometryPoint"===a.geometryType&&(n=!0,D++);if("esriGeometryPoint"===a.geometryType||"esriGeometryMultipoint"===a.geometryType)g=!0;"esriGeometryPolyline"===a.geometryType&&(Q=!0,t++);"esriGeometryPolygon"===a.geometryType&&(f=!0,R++)},this);-1!==m.indexOf(["CreateDriveTimeAreas","PlanRoutes",
"ConnectOriginsToDestinations"],b)&&(!n||c&&"esriGeometryPoint"!==c.geometryType)?(q=l.substitute(this.i18n.selectPointLayer,{toolName:h[e]}),p=!1):"AggregatePoints"!==b&&"InterpolatePoints"!==b||(!c||"esriGeometryPoint"===c.geometryType||"esriGeometryMultipoint"===c.geometryType)&&g?"CalculateDensity"===b&&(!g&&!Q||c&&"esriGeometryPoint"!==c.geometryType&&"esriGeometryMultipoint"!==c.geometryType&&"esriGeometryPolyline"!==c.geometryType)?(q=l.substitute(this.i18n.areaFeatureInvalidMsg,{toolName:h[e]}),
p=!1):"FindHotSpots"===b&&(!g&&!f||c&&"esriGeometryPoint"!==c.geometryType&&"esriGeometryMultipoint"!==c.geometryType&&"esriGeometryPolygon"!==c.geometryType)?(q=l.substitute(this.i18n.hotspotsLineFeatureMsg,{toolName:h[e]}),p=!1):"OverlayLayers"!==b&&"AggregatePoints"!==b&&"SummarizeWithin"!==b&&"SummarizeNearby"!==b&&"FindNearest"!==b&&"MergeLayers"!==b||a||0!==d.length&&(1!==d.length||d[0]!==c&&k.isDefined(c))?"ConnectOriginsToDestinations"===b&&!a&&(0===d.length||2>D)?(q=l.substitute(this.i18n.odPointMsg,
{toolName:h[e]}),p=!1):"ChooseBestFacilities"!==b||d&&0!==d.length&&0!==D?"AggregatePoints"===b&&!a&&1<d.length?(f=m.some(d,function(a){return"esriGeometryPolygon"===a.geometryType}),f||(q=l.substitute(this.i18n.aggregatePolyMsg,{toolName:h[e]}),p=!1)):"MergeLayers"===b&&!a&&1<d.length?1<D||1<t||1<R||(q=this.i18n.mergeValidationMsg,p=!1):"SummarizeWithin"!==b&&"DissolveBoundaries"!==b||(!c||"esriGeometryPolygon"===c.geometryType)&&f||a?"ExtractData"===b?(p=m.some(d,function(a){return-1!==a.capabilities.indexOf("Extract")}))||
(q=l.substitute(this.i18n.extractValidationMsg)):("ConnectOriginsToDestinations"===b||"ChooseBestFacilities"===b)&&1<d.length?(n=m.some(d,function(a){var b=k.isDefined(c)&&c.id===a.id;return"esriGeometryPoint"===a.geometryType&&!b}),n||(q=l.substitute("ChooseBestFacilities"===b?this.i18n.cblPointMsg:this.i18n.odPointMsg,{toolName:h[e]}),p=!1)):"CalculateSlope"===b||"DeriveAspect"===b||"RemapValues"===b?r?v||(p=!1,q=l.substitute(this.i18n.noSingleBandISMsg,{toolName:h[e]})):(p=!1,q=l.substitute(this.i18n.noImageServiceMsg,
{toolName:h[e]})):"ExtractRaster"===b?r||(p=!1,q=l.substitute(this.i18n.noImageServiceMsg,{toolName:h[e]})):"MonitorVegetation"===b&&(r?u||(p=!1,q=l.substitute(this.i18n.noMultiBandISMsg,{toolName:h[e]})):(p=!1,q=l.substitute(this.i18n.noImageServiceMsg,{toolName:h[e]}))):(q=l.substitute(this.i18n.selectPolyLayer,{toolName:h[e]}),p=!1):(q=l.substitute(this.i18n.cblPointMsg,{toolName:h[e]}),p=!1):(q=l.substitute(this.i18n.overlayValidationMsg,{toolName:h[e]}),p=!1):(q=l.substitute(this.i18n.selectPointLayer,
{toolName:h[e]}),p=!1);return b={isValid:p,validationMessage:q}},initI18n:function(){this.i18n||(this.i18n={},h.mixin(this.i18n,r.common),h.mixin(this.i18n,r.analysisTools),h.mixin(this.i18n,r.analysisMsgCodes),h.mixin(this.i18n,r.browseLayersDlg),h.mixin(this.i18n,r.driveTimes),h.mixin(this.i18n,r.calculateFields))},addBrowseAnalysisDialog:function(a){if(a&&a.widget){this.i18n||this.initI18n();var b="esri/dijit/analysis/PluginAnalysisLayers",d=function(a){return"\x3cimg class\x3d'grid-item galleryThumbnail' width\x3d'120px' height\x3d'80px' alt\x3d'' src\x3d'"+
(a.thumbnailUrl||this._portal.staticImagesUrl+"/desktopapp.png")+"'\x3e"},c=function(a){return'\x3cdiv class\x3d"galleryLabelContainer"\x3e\x3cspan alt\x3d\''+(a.title||a.name||"\x3cNo Title\x3e")+"'\x3e"+(a.title.replace(/_/g," ")||a.name.replace(/_/g," ")||"\x3cNo Title\x3e")+"\x3c/span\x3e\x3c/div\x3e"},e=function(a){return"\x3cimg class\x3d'grid-item-thumb' width\x3d'16px' height\x3d'16px' alt\x3d'' src\x3d'"+a.iconUrl+"'/\x3e"},f=function(a){return"\x3cimg class\x3d'grid-item-thumb' width\x3d'16px' height\x3d'16px' alt\x3d'' src\x3d'"+
a.iconUrl+"'/\x3e"},n=Y.doc.createDocumentFragment(),n=t.create("div",{style:"width:100%;height:100%;"},n),g=t.create("div",{style:"width:100%;height:10%;","class":""}),q=t.create("div",{style:"width:100%"},n),p,k,l,m=this._isCustomAnalysisQuery(a.widget);1===a.browseType?(b="esri/dijit/analysis/PluginLayers",b={portalUrl:a.widget.get("portalUrl"),message:"",plugin:b,sortDescending:!0,sort:"title",self:a.widget.get("portalSelf"),itemsPerPage:100,demandList:!0,extent:a.widget.get("map").extent,useExtent:!1,
fetchTimeout:600,galleryTemplate:"\x3cdiv class\x3d'listServiceTitle'\x3e\x3ctable cellpadding\x3d'0' cellspacing\x3d'0' width\x3d'100%'\x3e\x3ctr width\x3d'100%'\x3e\x3ctd nowrap\x3d'nowrap'\x3e  \x3cdiv  style\x3d\"position:absolute;left:80px; top:10px; width:1px; height:1px; background: transparent;\"\x3e\x3c/div\x3e\x3cdiv style\x3d'overflow:hidden;'\x3e\x3ca style\x3d\"height:16px;\"\x3e${item.title}\x3c/a\x3e\x3c/div\x3e\x3c/td\x3e\x3c/tr\x3e\x3c/table\x3e\x3ctable cellpadding\x3d'0' cellspacing\x3d'0' width\x3d'100%'\x3e\x3ctr width\x3d'100%' class\x3d'bottomRowTable'\x3e\x3ctd width\x3d'20'\x3e  \x3cspan class\x3d'esriAlignLeading'\x3e${item:_formatThumbnail}\x3c/span\x3e\x3c/td\x3e\x3ctd nowrap\x3d'nowrap'\x3e  \x3cspan class\x3d'esriAlignLeading' style\x3d'color:#656565;'\x3e${item.owner}\x3c/span\x3e\x3c/td\x3e\x3ctd style\x3d'padding-right:5px;padding-left:3px;'\x3e\x3c/td\x3e\x3c/tr\x3e\x3c/table\x3e\x3c/div\x3e",
showInfoPanel:!0,isAutoClose:!1,checkIsButtonEnabled:!0,formatThumbnail:f,formatInfoPanelImage:e,"class":"esriAnalysisLayersItems"}):b={portalUrl:a.widget.get("portalUrl"),message:"",plugin:b,sortDescending:!0,sort:"title",self:a.widget.get("portalSelf"),pagingLinks:1,rowsPerPage:6,"class":"esriBrowseAnalysisLayers itemsGallery esriFloatLeading",extent:a.widget.get("map").extent,useExtent:!m,fetchTimeout:600,galleryTemplate:'\x3cdiv style\x3d\'opacity:1;\' class\x3d\'grid-item gallery-view galleryNode\'\x3e${item:_formatItemTitle}${item:_formatThumbnail}\x3cdiv class\x3d"linksDiv" style\x3d\'display:none;\'\x3e\x3cdiv class\x3d"esriItemLinks"\x3e\x3cdiv class\x3d"esriFloatLeading"\x3e\x3ca style\x3d"text-decoration: none;"\x3e\x3cspan\x3eAdd layer to analysis\x3c/span\x3e\x3cdiv class\x3d"dijitReset dijitInline esriArrows"\x3e\x3c/div\x3e\x3c/a\x3e\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e',
formatItemTitle:c,showInfoPanel:!1,showTooltip:!0,formatThumbnail:d,style:"width:48em;height:100%;clear:both;"};c=t.toDom('\x3cdiv class\x3d"esriBrowseOptions"\x3e');t.place(c,g);d=t.create("div",{"class":"esriBrowseOption"},c);a.browseType&&1===a.browseType||(c=t.create("div",{"class":"esriBrowseOption"},c),k=new M({name:"addlayer",id:a.widget.id+(a.browseType?a.browseType:"")+"_addlayercheck","class":"",value:!1,checked:!1},t.create("input",{},c)),t.create("label",{"for":a.widget.id+"_addlayercheck",
"class":"esriBrowseOption_label",innerHTML:this.i18n.addLayer},c));c=!0;a.browseType&&1===a.browseType?c=!1:m&&(c=!1);c=new M({name:"extentcheck",id:a.widget.id+(a.browseType?a.browseType:"")+"_addextentcheck","class":"",value:c,checked:c},t.create("input",{},d));t.create("label",{"for":a.widget.id+(a.browseType?a.browseType:"")+"_addextentcheck","class":"esriBrowseOption_label",innerHTML:this.i18n.withinMapArea},d);b.messageRight=g;p=new fa(b,q);c.on("change",h.hitch(this,function(a){p.set("useExtent",
a)}));l=new ba({title:1===a.browseType?this.i18n.browseLayers:m?this.i18n.browseAnalysisLayers:this.i18n.browseAnalysisTitle,content:n,browseItems:p,addlayerCheckBox:k,style:a.browseType&&1===a.browseType?"":"padding:.75em 0;background-color: #fff;width:50em;"});a.widget.own(a.widget.get("map").on("extent-change",h.hitch(a.widget,function(b){p.set("extent",a.widget.get("map").extent)})),l.on("hide",h.hitch(l,function(a){l.browseItems.reset()})));return l}},addAnalysisReadyLayer:function(a){function b(b){var d,
e,f;"Feature Service"===c.type&&(f=new C(c.url,{outFields:["*"]}),h.mixin(c,f));h.mixin(c,b);c.id=c.title+"_"+b.id;c.title=a.item.selectedLayer?c.title+"-"+b.name:c.title.replace(/_/g," ");c.name=c.title;c.version=c.currentVersion;d=a.layersSelect.getOptions();if(a.widget.showBrowseLayers&&a.widget.showReadyToUseLayers)e=3;else if(a.widget.showBrowseLayers||a.widget.showReadyToUseLayers)e=2;d=d.splice(d.length-e,e);a.layersSelect.removeOption(d);e=a.layers.length;a.posIncrement&&(e+=a.posIncrement);
e=""+e;d.unshift({value:e,label:c.title,selected:!0});a.layersSelect.addOption(d);a.layersSelect.set("value",e);f&&(c.lyr=f,f.name=c.name);c.linfo=b;a.layers.push(c);var n;y(".js-add-layer-checkbox",a.browseDialog.browseItems.infoPanel).forEach(function(a){n=a.checked});if(a.browseDialog.addlayerCheckBox&&a.browseDialog.addlayerCheckBox.get("checked")||n)this._addLayerHandle&&this._addLayerHandle.remove(),this._addLayerHandle=a.widget.map.on("layer-add",h.hitch(this,function(d){this._addLayerHandle.remove();
a.widget.emit("add-ready-to-use-layer",{layer:d.layer,layerInfo:b,item:c})})),a.widget.map.addLayer(f);a.browseDialog.browseItems.clear()}if(k.isDefined(a)&&k.isDefined(a.item)&&k.isDefined(a.layersSelect)&&k.isDefined(a.layers)&&k.isDefined(a.browseDialog)){a.browseDialog.hide();var d,c,e,f,n,g;(d=!a.item.selectedLayer&&a.item.url?a.item.url+"/0":a.item.selectedLayer.url)&&-1!==window.location.protocol.indexOf("https:")&&(d=d.replace("http:","https:"));c={url:d,itemId:a.item.id,title:a.item.title,
type:a.item.type,analysisReady:!0};d=m.some(a.layers,function(b,d){var f=b.analysisReady&&c.analysisReady&&b.itemId===c.itemId;a.item.selectedLayer&&a.item.selectedLayer.url&&(f=b.itemId===c.itemId&&b.url===c.url);f&&(e=d);return f});f=new w;g="sync";if(d){a.posIncrement&&(e+=a.posIncrement);var q;y(".js-add-layer-checkbox",a.browseDialog.browseItems.infoPanel).forEach(function(a){q=a.checked});if(a.browseDialog.addlayerCheckBox&&a.browseDialog.addlayerCheckBox.get("checked")||q)a.posIncrement||(a.posIncrement=
0),n=a.layers[e-a.posIncrement],a.widget.map.getLayer(n.lyr.id)||(this._addLayerHandle&&this._addLayerHandle.remove(),this._addLayerHandle=a.widget.map.on("layer-add",h.hitch(this,function(b){this._addLayerHandle.remove();a.widget.emit("add-ready-to-use-layer",{layer:b.layer,layerInfo:n.linfo,item:n})})),a.widget.map.addLayer(n.lyr));a.layersSelect.set("value",""+e);a.browseDialog.browseItems.clear();f.resolve()}else a.item.selectedLayer?(c.url=a.item.selectedLayer.url,f.then(h.hitch(this,b)),setTimeout(f.resolve(a.item.selectedLayer),
500)):(g=a.item.itemDataUrl?G({url:a.item.itemDataUrl,content:{f:"json"}}):"sync",F(g,h.hitch(this,function(a){a&&a.layers&&a.layers[0].id&&(c.url=c.url.substring(0,c.url.lastIndexOf("/0"))+"/"+a.layers[0].id);G({url:c.url,content:{f:"json"}}).then(h.hitch(this,function(a){b(a);f.resolve()}))})));return f.promise}},addReadyToUseLayerOption:function(a,b){a&&(a.showReadyToUseLayers||a.showBrowseLayers)&&(b||(b=[]),a.signInPromise||(a.signInPromise=new w,setTimeout(h.hitch(this,function(){a.signInPromise.resolve()}),
100)),a.i18n||(this.initI18n(),a.i18n=this.i18n),a.signInPromise.then(h.hitch(this,function(){m.forEach(b,function(b){(a.showReadyToUseLayers||a.showBrowseLayers)&&b.addOption({type:"separator",value:""});if(a.showReadyToUseLayers){var d=a.i18n.browseAnalysisTitle;this._isCustomAnalysisQuery(a)&&(d=a.i18n.browseAnalysisLayers);b.addOption({value:"browse",label:d})}a.showBrowseLayers&&b.addOption({value:"browselayers",label:a.i18n.browseLayers})},this);a.showReadyToUseLayers&&!k.isDefined(a._browsedlg)&&
(a._browsedlg=this.addBrowseAnalysisDialog({widget:a}),a.own(a._browsedlg.browseItems.on("select-change",h.hitch(a,a._handleBrowseItemsSelect)),a._browsedlg.on("hide",h.hitch(a,function(){m.forEach(b,function(a){"browse"===a.get("value")&&a.reset()});a.layersSelect&&a.layersSelect.reset()}))));a.showBrowseLayers&&!k.isDefined(a._browseLyrsdlg)&&(a._browseLyrsdlg=this.addBrowseAnalysisDialog({widget:a,browseType:1}),a.own(a._browseLyrsdlg.on("browseitems-close",h.hitch(this,function(b){"add-layer"===
b.action&&(a._browseLyrsdlg.browseItems.plugIn._grid&&(b.selection.selectedLayer=a._browseLyrsdlg.browseItems.plugIn._selectedLayer,a._handleBrowseItemsSelect({dialog:a._browseLyrsdlg,selection:b.selection})),a._browseLyrsdlg.browseItems.closeInfoPanel())})),a._browseLyrsdlg.on("hide",h.hitch(a,function(){m.forEach(b,function(a){"browselayers"===a.get("value")&&a.reset()})}))))})))},_isCustomAnalysisQuery:function(a){var b='title:"Living Atlas Analysis Layers" AND owner:esri',d=!1;a&&a.isSingleTenant&&
(b='title:"Living Atlas Analysis Layers" AND owner:esri_livingatlas');a.portalSelf&&a.portalSelf.analysisLayersGroupQuery&&a.portalSelf.analysisLayersGroupQuery!==b?d=!0:a._portal&&a._portal.analysisLayersGroupQuery&&a._portal.analysisLayersGroupQuery!==b&&(d=!0);return d},getMaxInputByMode:function(a){var b;if(a&&a.units&&a.type){if("StraightLine"===a.type)"Miles"===a.units?b=1E3:"Yards"===a.units?b=176E4:"Kilometers"===a.units?b=B.format(1609.34,{places:2}):"Meters"===a.units?b=B.format(1609340,
{places:2}):"Feet"===a.units&&(b=528E4);else if("DrivingDistance"===a.type||"TruckingDistance"===a.type||"WalkingDistance"===a.type)"Miles"===a.units?b=300:"Yards"===a.units?b=528E3:"Kilometers"===a.units?b=B.format(482.802,{places:2}):"Meters"===a.units?b=B.format(482802,{places:2}):"Feet"===a.units&&(b=1584E3);else if("DrivingTime"===a.type||"TruckingTime"===a.type||"WalkingTime"===a.type)"Minutes"===a.units?b=300:"Seconds"===a.units?b=18E3:"Hours"===a.units&&(b=5);return b}},updateModeConstraints:function(a){var b;
a&&a.validateWidget&&a.units&&a.type&&(b=a.validateWidget.get("constraints"),b.max=this.getMaxInputByMode(a),a.validateWidget.set(b))},getTravelModes:function(a){var b=new w,d,c,e,f;k.isDefined(this.travelModes)&&0<this.travelModes.length?b.resolve(this.travelModes):a&&a.widget?a.widget.signInPromise.then(h.hitch(this,function(n){(f=a.widget.get("helperServices"))&&f.routingUtilities?(e=f.routingUtilities.url,d="sync"):d=a.widget._getSelf(a.widget.portalUrl);F(d,h.hitch(this,function(a){a&&a.helperServices&&
a.helperServices.routingUtilities&&(e=a.helperServices.routingUtilities.url);k.isDefined(e)?(c=new N(e+"/GetTravelModes"),c.execute({}).then(h.hitch(this,function(a){this.travelModes=m.map(a[0].value&&a[0].value.features,function(a){return T.fromJson(a.attributes.TravelMode)});a[1]&&a[1].paramName&&"defaultTravelMode"===a[1].paramName&&(this.defaultTravelModeId=a[1].value);b.resolve(this.travelModes)}),h.hitch(this,function(a){b.reject(a)}))):b.reject(Error("Missing Routing Utility Service to get Travel Modes"))}),
function(a){b.reject(a)})})):b.reject(Error("Missing parameter: params.widget required parameter"));return b.promise},populateTravelModes:function(a){if(a&&a.selectWidget&&a.widget){var b=[],d=a.allowmode||"all";this.initI18n();a.addStraightLine&&b.push({value:"StraightLine",label:'\x3cdiv class\x3d"esriFloatLeading bufferIcon esriStraightLineDistanceIcon"\x3e\x3c/div\x3e\x3cdiv class\x3d"esriLeadingMargin4" style\x3d"height:20px;margin-top:10px;"\x3e'+this.i18n.straightLineDistance+"\x3c/div\x3e",
selected:a.value&&"StraightLine"===a.value});this.getTravelModes({widget:a.widget}).then(h.hitch(this,function(c){m.forEach(c,function(c,f){var e=c.name,h=e.replace(/\s/g,a.separator||""),g="AUTOMOBILE"===c.type?"Driving":"TRUCK"===c.type?"Trucking":"WALK"===c.type?"Walking":"Other",l=g.toLowerCase(),m=c.units||e.split(/\s/)[1],r=k.isDefined(a.enableTravelModes)&&!a.enableTravelModes,m=c.impedanceAttributeName===c.timeAttributeName?"Time":c.impedanceAttributeName===c.distanceAttributeName?"Distance":
"Other",e={label:'\x3cdiv class\x3d"esriFloatLeading bufferIcon esri'+g+m+'Icon"\x3e\x3c/div\x3e\x3cdiv class\x3d"esriLeadingMargin4" style\x3d"height:20px;margin-top:10px;" title\x3d"'+c.description+'"\x3e'+e+"\x3c/div\x3e",value:h,travelMode:c,disabled:r,modei18nKey:l,units:m};if("all"===d||d===m.toLowerCase())"all"!==d&&(e.value=e.value.replace(m,"")),a.value&&a.value.id===c.id?e.selected=!0:!a.value&&a.selectDefaultMode&&this.defaultTravelModeId&&this.defaultTravelModeId===c.id&&(e.selected=!0),
b.push(e)},this);a.selectWidget.removeOption();a.selectWidget.addOption(b);a.widget.emit("travelmodes-added",{travelOptions:b})}),h.hitch(this,function(c){b&&0<b.length&&(a.selectWidget.removeOption(),a.selectWidget.addOption(b),a.widget.emit("travelmodes-added",{travelOptions:b}))}))}},updateDisplay:function(a,b,d){(new y.NodeList(a)).style("display",b?d?d:"block":"none")},isGreaterThanZero:function(){return 0<this.get("value")},getExprFunctions:function(){this.i18n||this.initI18n();this.exprFunctions||
(this.exprFunctions=[{type:"NumType",label:l.substitute(this.i18n.asMetersFunc,{functionName:"as_meters(\x3ci\x3enumber\x3c/i\x3e)",num:"\x3ci\x3enumber\x3c/i\x3e"}),name:"as_meters()"},{type:"NumType",label:l.substitute(this.i18n.asKilometersFunc,{functionName:"as_kilometers(\x3ci\x3enumber\x3c/i\x3e)",num:"\x3ci\x3enumber\x3c/i\x3e"}),name:"as_kilometers()"},{type:"NumType",label:l.substitute(this.i18n.asFeetFunc,{functionName:"as_feet(\x3ci\x3enumber\x3c/i\x3e)",num:"\x3ci\x3enumber\x3c/i\x3e"}),
name:"as_feet()"},{type:"NumType",label:l.substitute(this.i18n.asYardsFunc,{functionName:"as_yards(\x3ci\x3enumber\x3c/i\x3e)",num:"\x3ci\x3enumber\x3c/i\x3e"}),name:"as_yards()"},{type:"NumType",label:l.substitute(this.i18n.asMilesFunc,{functionName:"as_miles(\x3ci\x3enumber\x3c/i\x3e)",num:"\x3ci\x3enumber\x3c/i\x3e"}),name:"as_miles()"},{type:"NumType",label:l.substitute(this.i18n.asNuaticalMilesFunc,{functionName:"as_nautical_miles(\x3ci\x3enumber\x3c/i\x3e)",num:"\x3ci\x3enumber\x3c/i\x3e"}),
name:"as_nautical_miles()"},{type:"NumType",label:l.substitute(this.i18n.absFunc,{functionName:"abs(\x3ci\x3enumber\x3c/i\x3e)",num:"\x3ci\x3enumber\x3c/i\x3e"}),name:"abs()"},{type:"NumType",label:l.substitute(this.i18n.logFunc,{functionName:"log(\x3ci\x3enumber\x3c/i\x3e)",num:"\x3ci\x3enumber\x3c/i\x3e"}),name:"log()"},{type:"NumType",label:l.substitute(this.i18n.sinFunc,{functionName:"sin(\x3ci\x3enumber\x3c/i\x3e)",num:"\x3ci\x3enumber\x3c/i\x3e"}),name:"sin()"},{type:"NumType",label:l.substitute(this.i18n.cosFunc,
{functionName:"cos(\x3ci\x3enumber\x3c/i\x3e)",num:"\x3ci\x3enumber\x3c/i\x3e"}),name:"cos()"},{type:"NumType",label:l.substitute(this.i18n.tanFunc,{functionName:"tan(\x3ci\x3enumber\x3c/i\x3e)",num:"\x3ci\x3enumber\x3c/i\x3e"}),name:"tan()"},{type:"NumType",label:l.substitute(this.i18n.squareRootFunc,{functionName:"sqrt(\x3ci\x3enumber\x3c/i\x3e)",num:"\x3ci\x3enumber\x3c/i\x3e"}),name:"sqrt()"},{type:"NumType",label:l.substitute(this.i18n.minFunc,{functionName:"min(\x3ci\x3enumber\x3c/i\x3e)",num:"\x3ci\x3enumber\x3c/i\x3e"}),
name:"min()"},{type:"NumType",label:l.substitute(this.i18n.maxFunc,{functionName:"max(\x3ci\x3enumber\x3c/i\x3e)",num:"\x3ci\x3enumber\x3c/i\x3e"}),name:"max()"},{type:"NumType",label:l.substitute(this.i18n.constrainFunc,{functionName:"constrain(\x3ci\x3enumber\x3c/i\x3e, \x3ci\x3elow\x3c/i\x3e, \x3ci\x3ehigh\x3c/i\x3e",num:"\x3ci\x3enumber\x3c/i\x3e",low:"\x3ci\x3elow\x3c/i\x3e",high:"\x3ci\x3ehigh\x3c/i\x3e"}),name:"constrain(,,)"},{type:"NumType",label:l.substitute(this.i18n.iffFunc,{functionName:"iif(\x3ci\x3econdition\x3c/i\x3e,\x3ci\x3evalue if TRUE\x3c/i\x3e,\x3ci\x3evalue if FALSE\x3c/i\x3e)",
num:"\x3ci\x3enumber\x3c/i\x3e"}),name:"iif(,,)"},{type:"NumType",label:l.substitute(this.i18n.whenFunc,{functionName:"when(\x3ci\x3enumber\x3c/i\x3e)",num:"\x3ci\x3enumber\x3c/i\x3e"}),name:"when(,)"},{type:"NumType",label:l.substitute(this.i18n.decodeFunc,{functionName:"decode(\x3ci\x3eexpression\x3c/i\x3e, \x3ci\x3ecase1,return1,..caseN,returnN\x3c/i\x3e, \x3ci\x3edefault\x3c/i\x3e)",num:"\x3ci\x3enumber\x3c/i\x3e"}),name:"decode(,,,)"}]);return this.exprFunctions},addAttributeOptions:function(a){this.initI18n();
k.isDefined(a.allowSelectLabel)||(a.allowSelectLabel=!0);var b,d,c,e=["esriFieldTypeSmallInteger","esriFieldTypeInteger","esriFieldTypeSingle","esriFieldTypeDouble"];b=a.layer;d=a.selectWidget;c=b?b.fields:[];d.removeOption(d.getOptions());a.allowSelectLabel&&d.addOption({value:"",label:this.i18n.attribute});a.allowStringType&&e.push("esriFieldTypeString");var f=[];m.forEach(c,function(a){-1!==m.indexOf(e,a.type)&&a.name!==b.objectIdField&&f.push({value:a.name,label:k.isDefined(a.alias)&&""!==a.alias?
a.alias:a.name,type:"esriFieldTypeString"===a.type?"string":"number"})},this);d.addOption(f);d.set("value","0");d.set("disabled",!b||0===b.fields.length)},addStatisticsOptions:function(a){this.initI18n();var b=a.selectWidget,d=[{value:"SUM",label:this.i18n.sum},{value:"MIN",label:this.i18n.minimum},{value:"MAX",label:this.i18n.maximum},{value:"MEAN",label:a.showGeoAnalyticsParams?this.i18n.mean:this.i18n.average},{value:"STDDEV",label:this.i18n.standardDev}];b.removeOption(b.getOptions());b.addOption([{value:"0",
label:this.i18n.statistic}]);a.showGeoAnalyticsParams&&(b.addOption({value:"COUNT",label:this.i18n.count}),d.push({value:"VARIANCE",label:this.i18n.variance}),d.splice(4,0,{value:"RANGE",label:this.i18n.range}));a.type&&"number"!==a.type?a.type&&"string"===a.type&&b.addOption({value:"ANY",label:this.i18n.any}):b.addOption(d);b.set("value","0")},addFillOptions:function(a){var b=a.selectWidget,d=[{value:"ZEROES",label:this.i18n.zeroes},{value:"SPATIAL_NEIGHBORS",label:this.i18n.spatialneighbhors},{value:"SPACE_TIME_NEIGHBORS",
label:this.i18n.spacetimeneighbors},{value:"TEMPORAL_TREND",label:this.i18n.temporaltrend}];b.removeOption(b.getOptions());b.addOption([{value:"0",label:this.i18n.fill}]);a.type&&"number"!==a.type||b.addOption(d)},perMeter:function(a){var b=1;switch(a){case g.MILLIMETERS:b=1E3;break;case g.CENTIMETERS:b=100;break;case g.DECIMETERS:b=10;break;case g.METERS:b=1;break;case g.KILOMETERS:b=.001;break;case g.INCHES:b=39.370079;break;case g.FEET:b=3.2808399;break;case g.YARDS:b=1.0936133;break;case g.MILES:b=
6.2137119E-4;break;case g.NAUTICAL_MILES:b=5.399568E-4;break;case g.ACRES:b=2.4710538E-4;break;case g.ARES:b=.01;break;case g.HECTARES:b=1E-4;break;case g.SQUARE_INCHES:b=1550.0031;break;case g.SQUARE_FEET:b=10.7639104;break;case g.SQUARE_YARDS:b=1.19599005;break;case g.SQUARE_MILES:b=3.86102159E-7;break;case g.SQUARE_NAUTICAL_MILES:b=2.9155335E-7;break;case g.SQUARE_MILLIMETERS:b=1E6;break;case g.SQUARE_CENTIMETERS:b=1E4;break;case g.SQUARE_DECIMETERS:b=100;break;case g.SQUARE_METERS:b=1;break;case g.SQUARE_KILOMETERS:b=
1E-6}return b},getType:function(a){var b=null;switch(a){case g.ACRES:b=2;break;case g.ARES:b=2;break;case g.CENTIMETERS:b=1;break;case g.DECIMETERS:b=1;break;case g.FEET:b=1;break;case g.HECTARES:b=2;break;case g.INCHES:b=1;break;case g.KILOMETERS:b=1;break;case g.METERS:b=1;break;case g.MILES:b=1;break;case g.MILLIMETERS:b=1;break;case g.NAUTICAL_MILES:b=1;break;case g.SQUARE_CENTIMETERS:b=2;break;case g.SQUARE_DECIMETERS:b=2;break;case g.SQUARE_FEET:b=2;break;case g.SQUARE_INCHES:b=2;break;case g.SQUARE_KILOMETERS:b=
2;break;case g.SQUARE_METERS:b=2;break;case g.SQUARE_MILES:b=2;break;case g.SQUARE_MILLIMETERS:b=2;break;case g.SQUARE_NAUTICAL_MILES:b=2;break;case g.SQUARE_YARDS:b=2;break;case g.YARDS:b=1;break;default:b=0}return b},unitConversion:function(a,b,d){var c=!0;k.isDefined(a)||(this.emitError("The 'From' Value must be a valid numeric value: "+a),c=!1);k.isDefined(b)||(this.emitError("The 'From' Units must be defined: "+b),c=!1);k.isDefined(d)||(this.emitError("The 'To' Units must be defined: "+d),c=
!1);a instanceof Array&&(this.emitError("Only single 'From' Value supported: "+a),c=!1);b instanceof Array&&(this.emitError("Only single 'From' Units supported: "+b),c=!1);d instanceof Array&&(this.emitError("Only single 'To' Units supported: "+d),c=!1);var e=this.getType(b),f=this.getType(d);0===e&&(this.emitError("Unsupported 'From' Units: "+b),c=!1);0===f&&(this.emitError("Unsupported 'To' Units: "+d),c=!1);e!==f&&(this.emitError("Incompatible 'From' and 'To' Units: "+b+" and "+d),c=!1);return c?
b===d?+a:+a/this.perMeter(b)*this.perMeter(d):Number.NaN},emitError:function(a){console.log("error",Error(a))},isEmpty:function(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return A.stringify(a)===A.stringify({})},getNetworkAnalysisLimits:function(a){var b={},d=new w,c,e,f,g;a||d.reject(Error("Missing parameter: widget required parameter"));-1!==m.indexOf(["CreateDriveTimeAreas","EnrichLayer","SummarizeNearby"],a.toolName)?h.mixin(b,{toolName:"GenerateServiceAreas",serviceName:"asyncServiceArea"}):
"ChooseBestFacilities"===a.toolName?h.mixin(b,{toolName:"SolveLocationAllocation",serviceName:"asyncLocationAllocation"}):"PlanRoutes"===a.toolName?h.mixin(b,{toolName:"SolveVehicleRoutingProblem",serviceName:"asyncVRP"}):"FindNearest"===a.toolName?h.mixin(b,{toolName:"FindClosestFacilities",serviceName:"asyncClosestFacility"}):"ConnectOriginsToDestinations"===a.toolName&&h.mixin(b,{toolName:"FindRoutes",serviceName:"asyncRoute"});this.NALimits||(this.NALimits=[]);this.NALimits&&this.NALimits[b.toolName]?
d.resolve(this.NALimits[b.toolName]):a.signInPromise.then(h.hitch(this,function(n){(g=a.get("helperServices"))&&g.routingUtilities?(f=g.routingUtilities.url,c="sync"):c=a._getSelf(a.portalUrl);F(c,h.hitch(this,function(a){a&&a.helperServices&&a.helperServices.routingUtilities&&(f=a.helperServices.routingUtilities.url);k.isDefined(f)||d.reject(Error("Missing Routing Utility Service to get Network Analysis Service Limits."));e=new N(f+"/GetToolInfo");e.execute(b).then(h.hitch(this,function(a){a&&0<
a.length&&a[0].value&&a[0].value.serviceLimits?(this.NALimits[b.toolName]=a[0].value.serviceLimits,d.resolve(this.NALimits[b.toolName])):d.reject("Routing Utility Service 'GetToolInfo' job did not return service limits.")}),function(a){d.reject(a)})}))}),function(a){d.reject(a)});return d.promise},isEsriWorldGeocoder:function(a){var b=this.isAgoWorldGeocodeServer(a);a=this.isAgoWorldGeocodeServerProxy(a);return b||a},isAgoWorldGeocodeServer:function(a){return a&&!!a.match(/(arcgis.com\/arcgis\/rest\/services\/world\/geocodeserver).*/ig)},
isAgoWorldGeocodeServerProxy:function(a){return a&&!!a.match(/(\/servers\/[\da-z\.-]+\/rest\/services\/world\/geocodeserver).*/ig)},showMessages:function(a,b,d){E.set(b,"innerHTML",a);H.fadeIn({node:d,easing:J.quadIn,onEnd:h.hitch(this,function(){u.set(d,{display:""})})}).play()},hideMessages:function(a){H.fadeOut({node:a,easing:J.quadOut,onEnd:function(){u.set(a,{display:"none"})}}).play()},getHelpUrl:function(a){if(a.topic&&a.widget){var b;a.widget.portalSelf&&a.widget.portalSelf.helpBase?b=a.widget.portalSelf.helpBase+
"index.html#":!a.widget.isSingleTenant||a.widget.portalSelf&&a.widget.portalSelf.helpBase||(b="http://server.arcgis.com/en/portal/latest/use/");"BufferExpression"===a.topic&&(b+="Use_expressions_with_GeoAnalytics_Tools/019300000183000000/");return b}},isPCS:function(a){return!!a&&!!O&&-1!==m.indexOf(O,a)},isPCSByLayerType:function(a){var b=!!a&&!!a.fullExtent&&this.isPCS(a.fullExtent.spatialReference.wkid);!b&&a.extent&&(b=!!a&&!!a.extent&&this.isPCS(a.extent.spatialReference.wkid));!b&&a.spatialReference&&
(b=!!a&&!!a.spatialReference&&this.isPCS(a.spatialReference.wkid));return b},checkPCSforAnalysis:function(a){var b=a.widget&&a.widget.toolName,d=!!a.widget&&!!a.widget.context&&!!a.widget.context.processSR&&this.isPCS(a.widget.context.processSR.wkid),c=!0,e=a.jobParams||a.widget.jobParams,f,g,k=!!a.widget&&!!a.widget.context&&!!a.widget.context.processSR&&!!a.widget.context.processSR.wkid;if(!b||!e||!a.widget.showGeoAnalyticsParams)return!1;g="\x3ca  href\x3d'#' id\x3d'"+a.widget.id+"_warn_settings_link'\x3e"+
a.widget.i18n.analysisSettings+"\x3c/a\x3e\x3cdiv class\x3d'esriAnalysisSettingsIcon'\x3e\x3c/div\x3e";f=l.substitute(a.widget.i18n.PCSReqMsg,{defaultSpatialRef:a.widget.i18n.worldCylindrical,settingsIcon:g});"FindHotSpots"!==b||d?"CalculateDensity"!==b||d?"AggregatePoints"!==b||-1===m.indexOf(["HEXAGON","SQUARE"],e.binType)||d?"SummarizeWithin"===b&&e.summaryPolygons&&!d?c=this.isPCSByLayerType(a.widget.sumWithinLayer):"SummarizeWithin"!==b||-1===m.indexOf(["HEXAGON","SQUARE"],e.binType)||d?"JoinFeatures"===
b&&e.spatialNearDistance&&!d&&((c=this.isPCSByLayerType(a.widget.targetLayer))||(f=l.substitute(a.widget.i18n.JFPCSReqMsg,{settingsIcon:g}))):c=this.isPCSByLayerType(a.widget.summaryLayer):c=this.isPCSByLayerType(a.widget.pointLayer):c=this.isPCSByLayerType(a.widget.inputLayer):c=this.isPCSByLayerType(a.widget.analysisLayer);c||a.hasPCSWarnShown||(a.widget.set("disableRunAnalysis",c),this.settingsVM&&this.settingsDlg&&a.widget._bodyNode&&a.widget._errorMessagePane&&(this.showMessages(f,a.widget._bodyNode,
a.widget._errorMessagePane),K.byId(a.widget.id+"_warn_settings_link")&&L(K.byId(a.widget.id+"_warn_settings_link"),"click",h.hitch(a.widget,a.widget.showSettingsDlg))));!c&&a.hasPCSWarnShown&&k&&(c=!0);return c},tryParseJSON:function(a){try{var b=A.parse(a);if(b&&"object"===typeof b&&null!==b)return b}catch(d){}return!1},decodeTag:function(a){return{"\x26lt;":"\x3c","\x26gt;":"\x3e"}[a]||a},stringDecode:function(a){return a.replace(/(&lt;|&gt;)/g,this.decodeTag)},jobParamsToWidgetProps:function(a){if(a&&
a.jobParams){var b=a.jobParams,d=new w,c=[],e=[],f;for(f in b){var g;b.hasOwnProperty(f)&&("string"===typeof b[f]&&-1!==b[f].search(/(&lt;|&gt;)/g)&&(b[f]=this.stringDecode(b[f])),g="string"===typeof b[f]?this.tryParseJSON(b[f]):b[f])&&(-1!==f.toLowerCase().indexOf("layer")?e.push({key:f,obj:g}):g&&(g.Raster||g.url)&&e.push({key:f,obj:g}),b[f]=g)}for(f=0;f<e.length;f++){g=e[f].obj;var k=e[f].key;"object"===typeof g&&g.length?(b[k]=[],m.forEach(g,function(a,d){this._getFlayers(a,k,b,c,!0,d)},this)):
"object"===typeof g&&g.Raster?(g.url=g.Raster.url,this._getFlayers(g,k,b,c,!0,"Raster")):this._getFlayers(g,k,b,c)}X(c).then(h.hitch(this,function(){d.resolve(a)}),h.hitch(this,function(){d.resolve(a)}));return d.promise}},_getLayerType:function(a){return a?-1!==a.indexOf("BigDataCatalogServer")?v.BIGDATA:-1!==a.indexOf("ImageServer")?v.IS:v.FS:null},_getFlayers:function(a,b,d,c,e,f){var g,k;a.url?(g=G({url:a.url,content:{f:"json"}}),k=new w,c.push(k),g.then(h.hitch(this,function(a,b,c,f,g){var k,
l=this._getLayerType(a.url);l===v.FS?(k=new C(a.url,{mode:C.MODE_ONDEMAND,outFields:["*"],resourceInfo:g}),a.filter&&k.setDefinitionExpression(a.filter),k.filter=a.filter):l===v.BIGDATA?(k=g,h.mixin(k,a)):l===v.IS&&(g=a.Raster||a,k=new P(g.url),g.renderingRule&&k.setRenderingRule(new ha(g.renderingRule)),g.name&&(k.name=g.name),a.Raster&&a.Raster.url===a.url&&delete a.url);a.name&&(k.name=a.name);e?d[b][f]=k:e&&l===v.IS?h.mixin(d[b][f],k):d[b]=k;c.resolve()},a,b,k,f),h.hitch(this,function(a,b,c,f,
g){a={name:a.name,empty:!0};e?d[b][f]=a:d[b]=a;c.resolve()},a,b,k,f))):(c=new C(a,{outFields:["*"]}),a.name&&(c.name=a.name),e?d[b][f]=c:d[b]=c)},isLayerInLayers:function(a,b){return m.some(b,function(b){return b.name===a.name||b.url&&a.url&&b.url===a.url})},addBlankOption:function(a,b){b&&b.length?b.push({value:"  ",label:""}):a.addOption({value:"  ",label:""});setTimeout(h.hitch(this,this._validateSelectUI,a),100)},_validateSelectUI:function(a){a._hasBeenBlurred=!0;a.set("focused",!0);a.validate();
a.set("focused",!1);a._hasBeenBlurred=!1;setTimeout(h.hitch(this,function(){a.reset()}),1E3)},updateExpressions:function(a){a&&a.selectedInputLayers&&a.inputLayers&&a.data&&a.expressions&&(m.forEach(a.selectedInputLayers,function(b,d){m.forEach(a.inputLayers,function(a,e){a&&b&&(b.name===a.name||b.url===a.url)&&(b._oldIndex=d,b._newIndex=e)})}),m.forEach(a.data,function(b,d){var c;0<d&&b&&(c=a.expressions[d-1],k.isDefined(b.layer)&&(b.layer=c&&c.layer),k.isDefined(b.selectingLayer)&&(b.selectingLayer=
c&&c.selectingLayer))}),m.forEach(a.data,function(b){var d=!1,c=!1;m.forEach(a.selectedInputLayers,function(a){k.isDefined(b.layer)&&b.layer===a._oldIndex&&!d&&(b.layer=a._newIndex,d=!0);k.isDefined(b.selectingLayer)&&b.selectingLayer===a._oldIndex&&!c&&(b.selectingLayer=a._newIndex,c=!0)},this)},this))}});U("extend-esri")&&h.setObject("dijit.analysis.utils",z,ca);return z});