text: // All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  // See https://js.arcgis.com/3.38/esri/copyright.txt for details.
  //>>built
  require({cache:{"url:esri/dijit/Search/templates/Search.html":'\x3cdiv role\x3d"presentation" class\x3d"${theme}"\x3e\r\n  \x3cdiv role\x3d"presentation" class\x3d"${css.searchGroup}" data-dojo-attach-point\x3d"containerNode"\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"expandNode" class\x3d"${css.searchExpandContainer}"\x3e\r\n      \x3cdiv class\x3d"${css.searchAnimateContainer}"\x3e\r\n        \x3cdiv role\x3d"button" title\x3d"${_i18n.widgets.Search.main.searchIn}" id\x3d"${id}_menu_button" class\x3d"${css.searchBtn} ${css.searchToggle}" tabindex\x3d"0" data-dojo-attach-point\x3d"sourcesBtnNode"\x3e\r\n          \x3cspan aria-hidden\x3d"true" role\x3d"presentation" class\x3d"${css.searchToggleIcon}"\x3e\x3c/span\x3e\x3cspan class\x3d"${css.searchSourceName}" data-dojo-attach-point\x3d"sourceNameNode"\x3e\x3c/span\x3e\r\n        \x3c/div\x3e\r\n        \x3cdiv class\x3d"${css.searchInputGroup}"\x3e\r\n          \x3cform data-dojo-attach-point\x3d"formNode"\x3e\r\n            \x3cinput maxlength\x3d"${maxLength}" autocomplete\x3d"off" type\x3d"text" tabindex\x3d"0" class\x3d"${css.searchInput}" value\x3d"${value}" aria-haspopup\x3d"true" id\x3d"${id}_input" data-dojo-attach-point\x3d"inputNode" role\x3d"textbox"\x3e\r\n          \x3c/form\x3e\r\n          \x3cdiv role\x3d"button" class\x3d"${css.searchClear}" tabindex\x3d"0" data-dojo-attach-point\x3d"clearNode"\x3e\x3cspan aria-hidden\x3d"true" class\x3d"${css.searchClearIcon}"\x3e\x3c/span\x3e\x3cspan aria-hidden\x3d"true" class\x3d"${css.searchSpinner}"\x3e\x3c/span\x3e\r\n          \x3c/div\x3e\r\n          \x3cdiv data-dojo-attach-point\x3d"suggestionsNode" class\x3d"${css.searchMenu} ${css.suggestionsMenu}"\x3e\x3c/div\x3e\r\n        \x3c/div\x3e\r\n      \x3c/div\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv role\x3d"button" title\x3d"${_i18n.widgets.Search.main.searchButtonTitle}" class\x3d"${css.searchBtn} ${css.searchSubmit}" tabindex\x3d"0" data-dojo-attach-point\x3d"submitNode"\x3e\r\n      \x3cspan aria-hidden\x3d"true" role\x3d"presentation" class\x3d"${css.searchIcon}"\x3e\x3c/span\x3e\r\n      \x3cspan class\x3d"${css.searchButtonText}"\x3e${_i18n.widgets.Search.main.searchButtonTitle}\x3c/span\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"sourcesNode" class\x3d"${css.searchMenu} ${css.sourcesMenu}"\x3e\x3c/div\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"noResultsMenuNode" class\x3d"${css.searchMenu} ${css.searchNoResultsMenu}"\x3e\x3c/div\x3e\r\n    \x3cdiv class\x3d"${css.searchClearFloat}"\x3e\x3c/div\x3e\r\n  \x3c/div\x3e\r\n\x3c/div\x3e'}});
  define("esri/dijit/Search","require dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/Evented dojo/Deferred dojo/keys dojo/on dojo/query dojo/uacss dojo/regexp dojo/dom dojo/dom-attr dojo/dom-class dojo/dom-style dojo/dom-construct dojo/date/locale dojo/i18n!../nls/jsapi dojo/text!./Search/templates/Search.html dijit/_WidgetBase dijit/_TemplatedMixin dijit/_FocusMixin dijit/a11yclick dijit/focus ../lang ../InfoTemplate ../kernel ../SpatialReference ../graphic ../promiseList ../symbols/PictureMarkerSymbol ../symbols/SimpleMarkerSymbol ../symbols/SimpleLineSymbol ../symbols/SimpleFillSymbol ../symbols/TextSymbol ../symbols/Font ../geometry/Point ../geometry/Extent ../geometry/normalizeUtils ../geometry/scaleUtils ../tasks/locator ../tasks/query ../Color ../styles/basic".split(" "),
  function(W,G,k,E,X,C,x,A,H,Y,Z,R,z,r,S,w,aa,y,ba,ca,da,ea,I,v,J,fa,ha,ia,F,K,ja,ka,N,la,ma,L,O,T,P,U,na,V,oa,pa){function M(a,b){a&&b&&(a._layer=b,a._sourceLayer=b)}G=G([ca,da,ea,X],{declaredClass:"esri.dijit.Search",templateString:ba,reHostedFS:/https?:\/\/services.*\.arcgis\.com/i,constructor:function(a,b){this.css={searchGroup:"searchGroup",searchInput:"searchInput",searchInputGroup:"searchInputGroup",searchBtn:"searchBtn",searchSubmit:"searchSubmit",searchIcon:"searchIcon esri-icon-search",searchButtonText:"searchButtonText",
  searchToggle:"searchToggle",searchToggleIcon:"searchIcon esri-icon-down-arrow",searchMenu:"searchMenu",searchMenuHeader:"menuHeader",searchClear:"searchClear",searchClearIcon:"searchIcon esri-icon-close searchClose",searchSpinner:"searchIcon esri-icon-loading-indicator searchSpinner",searchSourceName:"sourceName",suggestionsMenu:"suggestionsMenu",sourcesMenu:"sourcesMenu",activeSource:"active",hasValue:"hasValue",hasButtonMode:"hasButtonMode",hasMultipleSources:"hasMultipleSources",showSuggestions:"showSuggestions",
  showSources:"showSources",showNoResults:"showNoResults",searchLoading:"searchLoading",latLonHeader:"searchLatLongHeader",searchMoreResults:"moreResults",searchMoreResultsList:"resultsList",searchMoreResultsHeader:"moreHeader",searchMoreResultsItem:"moreItem",searchMoreResultsListHeader:"popupHeader",searchShowMoreResults:"showMoreResults",searchNoResultsMenu:"noResultsMenu",searchNoResultsBody:"noResultsBody",searchNoResultsHeader:"noResultsHeader",searchNoValueIcon:"noValueIcon esri-icon-notice-triangle",
  searchNoValueText:"noValueText",searchNoResultsText:"noResultsText",searchExpandContainer:"searchExpandContainer",searchAnimateContainer:"searchAnimate",searchExpanded:"searchExpanded",searchCollapsed:"searchCollapsed",searchClearFloat:"searchClearFloat"};this._allIndex="all";this._objectIdIdentifier="_objectId";this._deferreds=[];this._sourceNames=[];this.defaultSource={locator:new na("//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"),singleLineFieldName:"SingleLine",outFields:["Addr_type",
  "Match_addr","StAddr","City"],name:y.widgets.Search.main.esriLocatorName,localSearchOptions:{minScale:3E5,distance:5E4},placeholder:y.widgets.Search.main.placeholder,highlightSymbol:(new ja(W.toUrl("./Search/images/search-pointer.png"),36,36)).setOffset(9,18)};this.options={map:null,theme:"arcgisSearch",visible:!0,value:"",allPlaceholder:"",sources:[this.defaultSource],activeSourceIndex:0,suggestionDelay:350,enableSourcesMenu:!0,enableSuggestionsMenu:!0,enableInfoWindow:!0,showInfoWindowOnSelect:!0,
  enableSuggestions:!0,enableButtonMode:!1,autoNavigate:!0,autoSelect:!0,addLayersFromMap:!1,zoomScale:1E3,graphicsLayer:null,enableHighlight:!0,highlightGraphic:null,enableLabel:!1,labelSymbol:(new ma).setColor(new oa([181,56,46,.9])).setFont(new L("14px",L.STYLE_NORMAL,L.VARIANT_NORMAL,L.WEIGHT_BOLD,"Arial")),labelGraphic:null,infoTemplate:new fa(y.widgets.Search.main.searchResult,'\x3cdiv class\x3d"${searchTheme}"\x3e\x3cdiv id\x3d"${searchMoreResultsId}" class\x3d"${searchMoreResults}"\x3e\x3cdiv class\x3d"${searchMoreResultsItem}"\x3e${searchResult}\x3c/div\x3e\x3cdiv\x3e${searchMoreResultsHtml}\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e'),
  searchResults:null,suggestResults:null,selectedResult:null,magicKey:null,selectedFeatureId:null,expanded:!1,maxLength:128,maxResults:6,maxSuggestions:6,locationToAddressDistance:1500,minCharacters:3,enableSearchingAll:!0};a=k.mixin({},this.options,a);this.set(a);this._updateActiveSource();this._i18n=y;this._defaultSR=new ia(4326);this.domNode=b},startup:function(){this.inherited(arguments);this.sources||(this.sources=[]);this._mapLoaded().then(k.hitch(this,this._init))},postCreate:function(){var a=
  this;this.inherited(arguments);this._moreResultsId=this.id+"_more_results";this.own(A(this.submitNode,I,k.hitch(this,this._searchButton)));this.own(A(this.sourcesBtnNode,I,k.hitch(this,this._toggleSourcesMenu)));this.own(A(this.inputNode,I,k.hitch(this,this._inputClick)));this.own(A(this.clearNode,I,k.hitch(this,this._clearButton)));this.own(A(this.formNode,"submit",k.hitch(this,function(b){b.preventDefault();this._cancelSuggest();this.search()})));this.own(A(this.inputNode,"keyup",k.hitch(this,function(b){this._inputKey(b)})));
  this.own(A(this.sourcesBtnNode,"keyup",k.hitch(this,function(b){this._sourceBtnKey(b)})));this.own(A(this.suggestionsNode,"li:click, li:keyup",function(b){a._suggestionsEvent(b,this)}));this.own(A(this.sourcesNode,"li:click, li:keyup",function(b){a._sourcesEvent(b,this)}));this.own(A(this.inputNode,"input, paste",k.hitch(this,function(){this._suggestDelay()})));this.map&&this.map.infoWindow&&this.map.infoWindow.domNode&&this.enableInfoWindow&&(this.own(A(this.map.infoWindow.domNode,"#"+this._moreResultsId+
  "_show:click",k.hitch(this,function(b){this._showMoreResultsClick(b)}))),this.own(A(this.map.infoWindow.domNode,"#"+this._moreResultsId+"_list li a:click",k.hitch(this,function(b){this._moreResultsClick(b)}))),this.own(A(this.map.infoWindow.domNode,"#"+this._moreResultsId+" [data-switch-coordinates]:click",k.hitch(this,function(b){this._switchCoordinatesClick(b)}))));this.value&&this._checkStatus();this._hideMenus();this._updateVisible();this._insertSources(this.sources);this._setPlaceholder(this.activeSourceIndex);
  this._updateButtonMode(this.enableButtonMode);this.toggle(this.expanded)},destroy:function(){this.clear();w.empty(this.domNode);this.inherited(arguments)},clear:function(){this.clearGraphics();z.get(this.inputNode,"value")&&z.set(this.inputNode,"value","");this._changeAttrValue("value","");this.set("searchResults",null);this.set("suggestResults",null);this.set("selectedResult",null);this.set("magicKey",null);this.set("selectedFeatureId",null);r.remove(this.containerNode,this.css.hasValue);z.set(this.clearNode,
  "title","");this._hideMenus();this._closePopup();this._hideLoading();this.emit("clear-search")},show:function(){S.set(this.domNode,"display","block")},hide:function(){S.set(this.domNode,"display","none")},expand:function(){this.enableButtonMode&&(r.add(this.containerNode,this.css.searchExpanded),r.remove(this.containerNode,this.css.searchCollapsed),this._hideMenus(),this.set("expanded",!0))},collapse:function(){this.enableButtonMode&&(r.remove(this.containerNode,this.css.searchExpanded),r.add(this.containerNode,
  this.css.searchCollapsed),this._hideMenus(),this.set("expanded",!1))},toggle:function(a){this.enableButtonMode&&("undefined"===typeof a&&(a=!this.expanded),a?this.expand():this.collapse())},search:function(a){var b=new C;this._mapLoaded().then(k.hitch(this,function(){this._searchDeferred(a).then(k.hitch(this,function(d){var c=d.results;this.set("searchResults",c);0===d.numResults&&(this._noResults(d.value),this._showNoResultsMenu());this._hideLoading();this.emit("search-results",d);this._selectFirstResult(c,
  d.activeSourceIndex);b.resolve(c)}),k.hitch(this,function(d){b.reject(d)}))}));return b.promise},suggest:function(a){var b=new C;this._mapLoaded().then(k.hitch(this,function(){this._suggestDeferred(a).then(k.hitch(this,function(d){if(d){var c=d.results;this.set("suggestResults",c);this._insertSuggestions(c,d.value);this.emit("suggest-results",d);b.resolve(c)}}),k.hitch(this,function(d){b.reject(d)}))}));return b.promise},select:function(a){var b=this._getDefaultSymbol(a),d=this.labelSymbol,c=this.sources,
  e=this.activeSourceIndex,f=this.enableHighlight,h=this.enableLabel,p=this.autoNavigate,l=this.showInfoWindowOnSelect,n=this.enableInfoWindow,g=this.infoTemplate,m=a.feature?new F(a.feature.toJson()):null,t=m?a.feature._sourceLayer:null;M(m,t);if(e===this._allIndex){var u=this._getSourceIndexOfResult(a);if(null!==u){var q=c[u];e=u}}else q=c[e];q&&(q.hasOwnProperty("highlightSymbol")&&(b=q.highlightSymbol),q.hasOwnProperty("labelSymbol")&&(d=q.labelSymbol),q.hasOwnProperty("enableHighlight")&&(f=q.enableHighlight),
  q.hasOwnProperty("enableLabel")&&(h=q.enableLabel),q.hasOwnProperty("autoNavigate")&&(p=q.autoNavigate),q.hasOwnProperty("showInfoWindowOnSelect")&&(l=q.showInfoWindowOnSelect),q.hasOwnProperty("enableInfoWindow")&&(n=q.enableInfoWindow),q.hasOwnProperty("infoTemplate")?g=q.infoTemplate:q.featureLayer&&q.featureLayer.infoTemplate&&(g=q.featureLayer.infoTemplate));this._hideMenus();this._hideLoading();if(m){c=this.highlightGraphic;var B=this.graphicsLayer;u=this.labelGraphic;var D=k.mixin({},m.attributes,
  {searchTheme:this.theme,searchResult:this._searchResultHTML(a),searchMoreResults:this.css.searchMoreResults,searchMoreResultsItem:this.css.searchMoreResultsItem,searchMoreResultsId:this._moreResultsId,searchMoreResultsHtml:this._moreResultsHTML(a)}),Q=null;n&&(Q=g);u?(u.setGeometry(m.geometry),u.setAttributes(D),u.setSymbol(d),d&&"textsymbol"===d.type&&u.symbol.setText(a.name)):(u=new F(m.geometry,d,D),M(u,t),d&&"textsymbol"===d.type&&u.symbol.setText(a.name),h&&(B?B.add(u):this.map&&this.map.graphics&&
  this.map.graphics.add(u)));c?(c.setGeometry(m.geometry),c.setAttributes(D),c.setInfoTemplate(Q),c.setSymbol(b)):(c=new F(m.geometry,b,D,Q),M(c,t),f&&(B?B.add(c):this.map&&this.map.graphics&&this.map.graphics.add(c)));c&&c.symbol&&"textsymbol"===c.symbol.type&&c.symbol.setText(a.name);this.map&&this.map.infoWindow&&n&&l&&(this.map.infoWindow.setFeatures([c]),b=this._getPointFromGeometry(c.geometry),this.map.infoWindow.show(b));this.map&&p&&a&&a.hasOwnProperty("extent")&&"function"===typeof this.map.setExtent&&
  this.map.setExtent(a.extent,!0);this.set("highlightGraphic",c);this.set("labelGraphic",u)}this.set("selectedResult",a);this.emit("select-result",{result:a,source:q,sourceIndex:e})},focus:function(){v.focus(this.inputNode)},blur:function(){this.inputNode.blur();v.curNode&&v.curNode.blur()},clearGraphics:function(){var a=this.highlightGraphic,b=this.graphicsLayer,d=this.labelGraphic;a&&(b?b.remove(a):this.map&&this.map.graphics&&this.map.graphics.remove(a));d&&(b?b.remove(d):this.map&&this.map.graphics&&
  this.map.graphics.remove(d));this.set("labelGraphic",null);this.set("highlightGraphic",null)},_mapLoaded:function(){var a=new C;if(this.map)if(this.map.loaded)a.resolve();else A.once(this.map,"load",k.hitch(this,function(){a.resolve()}));else a.resolve();return a.promise},_init:function(){this._getMapLayers().then(k.hitch(this,function(){this.set("loaded",!0);this.emit("load")}))},_clearButton:function(){this.clear();v.focus(this.inputNode)},_error:function(a){return Error(this.declaredClass+" "+
  a)},_searchDeferred:function(a){var b=new C,d=this.value,c=this.activeSourceIndex;a&&a.hasOwnProperty("index")&&(c=a.index);this._showLoading();this._hideMenus();this._closePopup();this.clearGraphics();var e={magicKey:this.magicKey,text:d};a?"string"===typeof a?(e.text=a,a=this._searchQueries(e)):a="object"===typeof a&&a.hasOwnProperty("magicKey")?this._searchQueries(a):"object"===typeof a&&a.hasOwnProperty("geometry")?this._searchQueries({geometry:a}):"object"===typeof a&&a.hasOwnProperty(this._objectIdIdentifier)?
  this._searchQueries(a):"object"===typeof a&&"point"===a.type?this._searchQueries({point:a}):a instanceof Array&&2===a.length?this._searchQueries({latlon:a}):this._searchQueries(e):a=this._searchQueries(e);a.always(k.hitch(this,function(f){f=this._formatResults(f,c,d);b.resolve(f)}));return b.promise},_suggestDeferred:function(a){var b=new C;this._deferreds.push(b);a||(a=this.value);var d=this.activeSourceIndex;this._suggestQueries({text:a}).always(k.hitch(this,function(c){var e;if(c)for(var f=0;f<
  c.length;f++)c[f]&&(e=!0);e?(c=this._formatResults(c,d,a),b.resolve(c)):b.resolve()}));return b.promise},_getDefaultSymbol:function(a){var b;this.map&&(b=this.map.getBasemap());b||(b="topo");if(a&&a.feature&&a.feature.geometry)var d=a.feature.geometry.type;"polyline"===d?d="line":"circle"===d||"extent"===d?d="polygon":"multipoint"===d&&(d="point");if(d){if(a=pa.getSchemes({theme:"default",basemap:b,geometryType:d}))var c=a.primaryScheme;if(c){c.color&&c.hasOwnProperty("opacity")&&(c.color.a=c.opacity);
  var e=c;a=c.color;c=c.size;switch(d){case "point":var f=new ka;f.setColor(a);f.setSize(null!==c?c:e.size);d=new N;d.setColor(e.outline.color);d.setWidth(e.outline.width);f.setOutline(d);break;case "line":f=new N;f.setColor(a);f.setWidth(null!==c?c:e.width);break;case "polygon":f=new la,f.setColor(a),d=new N,d.setColor(e.outline.color),d.setWidth(e.outline.width),f.setOutline(d)}e=f}}return e},_selectFirstResult:function(a,b){if(this.autoSelect&&a){var d;b===this._allIndex?d=this._getFirstResult(a):
  a[b]&&a[b][0]&&(d=a[b][0]);d&&this.select(d)}},_getSourceIndexOfResult:function(a){var b=this.searchResults;if(b)for(var d in b)if(b[d]&&b[d].length)for(var c=0;c<b[d].length;c++)if(b[d][c]===a)return parseInt(d,10);return null},_getFirstResult:function(a){if(a)for(var b in a)if(a[b]&&a[b][0])return a[b][0];return!1},_onFocus:function(){this.map&&"function"===typeof this.map.disableKeyboardNavigation&&this.map.disableKeyboardNavigation();this.emit("focus");this.inherited(arguments)},_onBlur:function(){this._hideMenus();
  this.map&&"function"===typeof this.map.enableKeyboardNavigation&&this.map.enableKeyboardNavigation();this.enableButtonMode&&this.loaded&&this.collapse();this.emit("blur");this.inherited(arguments)},_getMapLayers:function(){var a=new C;if(this.addLayersFromMap&&this.map){var b=[],d=this.map.graphicsLayerIds;if(d&&d.length){for(var c=0;c<d.length;c++){var e=this.map.getLayer(d[c]);e&&b.push(this._featureLayerLoaded(e))}K(b).always(k.hitch(this,function(f){for(var h,p=this.sources,l=0;l<f.length;l++)f[l]&&
  f[l].loaded&&"Feature Layer"===f[l].type&&(p.push({featureLayer:f[l],enableSuggestions:!0}),h=!0);h&&this.set("sources",p);a.resolve()}))}else a.resolve()}else a.resolve();return a.promise},_switchCoordinatesClick:function(a){a.preventDefault();if(a=z.get(a.target,"data-switch-coordinates"))this._cancelSuggest(),this.set("value",a),this.search()},_moreResultsClick:function(a){a.preventDefault();var b=a.target;a=parseInt(z.get(b,"data-source-index"),10);b=parseInt(z.get(b,"data-index"),10);var d=this.searchResults;
  d&&d[a]&&(a=d[a][b])&&this.select(a)},_showMoreResultsClick:function(a){a.preventDefault();if(a=R.byId(this._moreResultsId)){r.toggle(a,this.css.searchShowMoreResults);var b=R.byId(this._moreResultsId+"_show");b&&(r.contains(a,this.css.searchShowMoreResults)?z.set(b,"textContent",y.widgets.Search.main.hideMoreResults):z.set(b,"textContent",y.widgets.Search.main.showMoreResults))}},_featureLayerLoaded:function(a){var b=new C;if(a.loaded)b.resolve(a);else if(a.loadError)b.reject(this._error("Layer failed to load."));
  else{var d=A.once(a,"load",k.hitch(this,function(){c.remove();b.resolve(a)}));var c=A.once(a,"error",k.hitch(this,function(){d.remove();b.reject(this._error("Layer could not be loaded."))}))}return b.promise},_getObjectSize:function(a){var b=0,d;for(d in a)a.hasOwnProperty(d)&&b++;return b},_sourcesEvent:function(a,b){var d=z.get(b,"data-index"),c=H("li",this.sourcesNode);b=E.indexOf(c,b);d!==this._allIndex&&(d=parseInt(d,10));"click"===a.type||a.keyCode===x.ENTER?(this.set("activeSourceIndex",d),
  v.focus(this.inputNode),this._hideSourcesMenu()):a.keyCode===x.UP_ARROW?(a.stopPropagation(),a.preventDefault(),a=b-1,0>a?v.focus(this.sourcesBtnNode):v.focus(c[a])):a.keyCode===x.DOWN_ARROW?(a.stopPropagation(),a.preventDefault(),a=b+1,a>=c.length?v.focus(this.sourcesBtnNode):v.focus(c[a])):a.keyCode===x.ESCAPE&&(this._hideSourcesMenu(),v.focus(this.inputNode))},_suggestionsEvent:function(a,b){var d=z.get(b,"data-source-index"),c=parseInt(z.get(b,"data-index"),10),e=H("li",this.suggestionsNode),
  f=this.sources;b=E.indexOf(e,b);d!==this._allIndex&&(d=parseInt(d,10));var h;this._clearQueryTimeout();"click"===a.type||a.keyCode===x.ENTER?((e=this.suggestResults)&&e[d]&&e[d][c]&&(h=e[d][c]),h&&(h.index=d,f[d].featureLayer?(d=f[d].featureLayer.objectIdField,h[this._objectIdIdentifier]=h.feature.attributes[d],this.set("value",this._getSuggestionName(h)),this.set("selectedFeatureId",h.feature.attributes[d])):h.magicKey&&h.text&&(this.set("value",h.text),this.set("magicKey",h.magicKey)),this.search(h),
  v.focus(this.inputNode))):a.keyCode===x.BACKSPACE||a.keyCode===x.DELETE?v.focus(this.inputNode):a.keyCode===x.UP_ARROW?(a.stopPropagation(),a.preventDefault(),h=b-1,0>h?v.focus(this.inputNode):v.focus(e[h])):a.keyCode===x.DOWN_ARROW?(a.stopPropagation(),a.preventDefault(),h=b+1,h>=e.length?v.focus(this.inputNode):v.focus(e[h])):a.keyCode===x.ESCAPE&&(this._hideMenus(),v.focus(this.inputNode))},_getResultName:function(a){var b;a.hasOwnProperty("name")&&null!==a.name&&(b=a.name.toString());b||(b=y.widgets.Search.main.untitledResult);
  return b},_getSuggestionName:function(a){var b;a.hasOwnProperty("name")&&null!==a.name&&(b=a.name.toString());a=a.text||b;a||(a=y.widgets.Search.main.untitledResult);return a},_searchResultHTML:function(a){var b="";if(a.feature&&a.feature.attributes&&a.feature.attributes.Addr_type&&"LatLong"===a.feature.attributes.Addr_type){var d=a.name.split(" ");if(2===d.length){var c=d[0];var e=d[1]}e&&c?(a=parseFloat(c),e=parseFloat(e),d=e+", "+a,b+='\x3cdiv class\x3d"'+this.css.searchMoreResultsItem+'"\x3e',
  b+='\x3cdiv class\x3d"'+this.css.latLonHeader+'"\x3e'+y.widgets.Search.main.lonlat+"\x3c/div\x3e",b=b+(a+", "+e)+'\x3c/div\x3e\x3cdiv class\x3d"'+(this.css.searchMoreResultsItem+'"\x3e'),a===e||90<a||-90>a||180<e||-180>e||(b+='\x3cdiv class\x3d"'+this.css.latLonHeader+'"\x3e'+y.widgets.Search.main.reverseLonLatHeader+"\x3c/div\x3e",b+='\x3ca data-switch-coordinates\x3d"'+d+'" tabindex\x3d"0" href\x3d"#"\x3e'+d+"\x3c/a\x3e\x3c/div\x3e")):b=a.name}else b=a.name;return b},_moreResultsHTML:function(a){var b=
  "",d="",c=this.searchResults,e=this.sources,f=0;if(c){d+='\x3cdiv class\x3d"'+this.css.searchMoreResultsItem+'"\x3e';d+='\x3ca href\x3d"#" id\x3d"'+this._moreResultsId+'_show"\x3e'+y.widgets.Search.main.showMoreResults+"\x3c/a\x3e";d=d+'\x3c/div\x3e\x3cdiv class\x3d"'+(this.css.searchMoreResultsList+'"\x3e');d+='\x3cdiv id\x3d"'+this._moreResultsId+'_list"\x3e';for(var h in c)if(c[h]){var p=c[h].length;if(p){var l=1===p&&c[h][0]===a;if(1<this._getObjectSize(c)&&!l){var n=this._getSourceName(h);d+=
  '\x3cdiv class\x3d"'+this.css.searchMoreResultsListHeader+'"\x3e'+n+"\x3c/div\x3e"}if(p&&!l){d+="\x3cul\x3e";n=e[h].maxResults||this.maxResults;for(l=0;l<p&&l<n;++l)if(c[h][l]!==a){var g=this._getResultName(c[h][l]);d+='\x3cli\x3e\x3ca tabindex\x3d"0" data-index\x3d"'+l+'" data-source-index\x3d"'+h+'" href\x3d"#"\x3e'+g+"\x3c/a\x3e\x3c/li\x3e";f++}d+="\x3c/ul\x3e"}}}d+="\x3c/div\x3e\x3c/div\x3e"}f&&(b+=d);return b},_validField:function(a,b){return a.getField(b)},_validFields:function(a,b){if(a&&b&&
  b.length){for(var d=0;d<b.length;d++)if(!this._validField(a,b[d]))return!1;return!0}return!1},_getCodedName:function(a,b){if(a&&a.length)for(var d=0,c=a.length;d<c;d++){var e=a[d];if(e.code===b)return e.name}},_getCodedValue:function(a,b,d){if(a&&a.length)for(var c=0,e=a.length;c<e;c++){var f=a[c],h=f.name,p=b;d||(h=h.toLowerCase(),p=p.toLowerCase());if(h===p)return f.code}return!1},_whereClause:function(a,b,d,c,e){var f=null;if(a){var h="",p=this.reHostedFS.test(b.url);p&&this._containsNonLatinCharacter(a)&&
  (h="N");if(d&&d.length)for(var l=0,n=d.length;l<n;l++){var g="";g=a.replace(/'/g,"''");var m=d[l],t=b.getField(m),u=b.getDomain(m);u&&"codedValue"===u.type&&(g=this._getCodedValue(u.codedValues,g,c));!1!==g&&(t=t.type,"esriFieldTypeString"===t||"esriFieldTypeDate"===t?c&&"search"===e?g=m+" \x3d "+h+"'"+g+"'":(m=p?m:"UPPER("+m+")",g=p?g:g.toUpperCase(),g=m+" LIKE "+h+"'"+(c?g+"%":"%"+g+"%")+"'"):"esriFieldTypeOID"===t||"esriFieldTypeSmallInteger"===t||"esriFieldTypeInteger"===t||"esriFieldTypeSingle"===
  t||"esriFieldTypeDouble"===t?(g=parseFloat(g),g=isNaN(g)?!1:m+" \x3d "+g):g=m+" \x3d "+g,g&&(f=f?f+" or ":"",f+=g))}}return f},_suggest:function(a){a||(a={index:this.activeSourceIndex,text:this.value});var b=new C,d=a.index,c=this.sources[d],e=this.enableSuggestions;c.hasOwnProperty("enableSuggestions")&&(e=c.enableSuggestions);var f=0;if(a.hasOwnProperty("text")&&a.text){var h=k.trim(a.text);f=a.text.length}a=c.minCharacters||this.minCharacters;if(e&&h&&f>=a&&this._supportsPagination(c)){var p="";
  c.prefix&&(p+=c.prefix);p+=h;c.suffix&&(p+=c.suffix);var l=this._defaultSR;this.map&&(l=this.map.spatialReference);e={};c.locator?(c.categories&&(e.categories=c.categories),c.locator.outSpatialReference=l,this.map&&c.localSearchOptions&&c.localSearchOptions.hasOwnProperty("distance")&&c.localSearchOptions.hasOwnProperty("minScale")&&(f=this._getScale(),!c.localSearchOptions.minScale||f&&f<=parseFloat(c.localSearchOptions.minScale))&&(e.location=this.map.extent.getCenter(),e.distance=c.localSearchOptions.distance),
  e.text=p,c.useMapExtent&&this.map&&this.map.extent&&(e.searchExtent=this.map.extent),c.searchExtent&&(e.searchExtent=c.searchExtent),e.maxSuggestions=c.maxSuggestions||this.maxSuggestions,c.sourceCountry&&(e.countryCode=c.sourceCountry),c.countryCode&&(e.countryCode=c.countryCode),c.locator.suggestLocations(e).then(k.hitch(this,function(n){b.resolve(n)}),k.hitch(this,function(n){n||(n=this._error("Locator suggestLocations could not be performed."));b.reject(n)}))):c.featureLayer?this._featureLayerLoaded(c.featureLayer).then(k.hitch(this,
  function(){var n=this._getDisplayField(c),g=c.searchFields||[n],m=[];c.suggestionTemplate?c.suggestionTemplate.replace(/(?:\$\{([^}]+)\})/g,function(B,D){m.push(D)}):m=[n];-1===E.indexOf(m,c.featureLayer.objectIdField)&&m.push(c.featureLayer.objectIdField);n=this._validField(c.featureLayer,n);var t=this._validFields(c.featureLayer,m),u=this._validFields(c.featureLayer,g);if(n&&t&&u){n=new V;c.hasOwnProperty("suggestQueryParams")&&k.mixin(n,c.suggestQueryParams);n.outSpatialReference=l;n.returnGeometry=
  !1;n.num=c.maxSuggestions||this.maxSuggestions;n.outFields=m;c.useMapExtent&&this.map&&this.map.extent&&(n.geometry=this.map.extent);c.searchExtent&&(n.geometry=c.searchExtent);if(g=this._whereClause(p,c.featureLayer,g,c.exactMatch,"suggest")){n.where=g;var q=!0}q?c.featureLayer.queryFeatures(n,k.hitch(this,function(B){var D;(B=B.features)&&(D=this._hydrateResults(B,d,!0));b.resolve(D)}),k.hitch(this,function(B){B||(B=this._error("FeatureLayer queryFeatures errored with suggestions"));b.reject(B)})):
  b.resolve()}else b.reject(this._error("Invalid FeatureLayer field"))})):b.reject(this._error("Invalid source"))}else b.resolve();return b.promise},_supportsPagination:function(a){var b;a.locator?b=!0:a.featureLayer&&a.featureLayer.advancedQueryCapabilities&&a.featureLayer.advancedQueryCapabilities.supportsPagination&&(b=!0);return b},_suggestQueries:function(a){var b=this.sources,d=this.activeSourceIndex,c=[];if(d===this._allIndex)for(d=0;d<b.length;d++){var e=a;e.index=d;e=this._suggest(e);c.push(e)}else a.index=
  d,e=this._suggest(a),c.push(e);return K(c)},_getPointFromGeometry:function(a){switch(a.type){case "extent":var b=a.getCenter();break;case "multipoint":b=a.getPoint(0);break;case "point":b=a;break;case "polygon":b=a.getCentroid();break;case "polyline":b=a.getPoint(0,0)}return b},_searchQueries:function(a){a.hasOwnProperty("index")||(a.index=this.activeSourceIndex);var b=[];if(a.index===this._allIndex)for(var d=this.sources,c=0;c<d.length;c++){var e=a;e.index=c;e=this._search(e);b.push(e)}else a=this._search(a),
  b.push(a);return K(b)},_searchButton:function(){this.enableButtonMode&&!this.expanded?(this.expand(),v.focus(this.inputNode)):(this._cancelSuggest(),this.search())},_search:function(a){a||(a={text:this.value,magicKey:null,geometry:null,point:null,index:this.activeSourceIndex,latlon:null});this.selectedFeatureId&&(a.text=null,a[this._objectIdIdentifier]=this.selectedFeatureId);var b,d=new C,c=a.index,e=this.sources[c],f;a.hasOwnProperty("text")&&a.text&&(f=k.trim(a.text));if(e){var h="";e.prefix&&
  !a.magicKey&&(h+=e.prefix);h+=f;e.suffix&&!a.magicKey&&(h+=e.suffix);var p=this._defaultSR;this.map&&(p=this.map.spatialReference);if(e.locator)if(a.hasOwnProperty("text")&&f){var l={};e.categories&&(l.categories=e.categories);e.locationType&&(l.locationType=e.locationType);p&&(e.locator.outSpatialReference=p);if(this.map&&e.localSearchOptions&&e.localSearchOptions.hasOwnProperty("distance")&&e.localSearchOptions.hasOwnProperty("minScale")){var n=this._getScale();if(!e.localSearchOptions.minScale||
  n&&n<=parseFloat(e.localSearchOptions.minScale))l.location=this.map.extent.getCenter(),l.distance=e.localSearchOptions.distance}l.address={};l.maxLocations=e.maxResults||this.maxResults;e.useMapExtent&&this.map&&this.map.extent&&(l.searchExtent=this.map.extent);e.searchExtent&&(l.searchExtent=e.searchExtent);e.sourceCountry&&(l.countryCode=e.sourceCountry);e.countryCode&&(l.countryCode=e.countryCode);a.magicKey&&(l.magicKey=a.magicKey);e.singleLineFieldName?l.address[e.singleLineFieldName]=h:l.address["Single Line Input"]=
  h;e.outFields&&(l.outFields=e.outFields);e.locator.addressToLocations(l).then(k.hitch(this,function(g){g=this._hydrateResults(g,c,!1);d.resolve(g)}),k.hitch(this,function(g){g||(g=this._error("Locator addressToLocations could not be performed"));d.reject(g)}))}else a.geometry?(b=this._getPointFromGeometry(a.geometry.geometry))?this._reverseGeocodePoint(c,b).then(function(g){d.resolve(g)},function(g){d.reject(g)}):d.reject(this._error("Invalid point to reverse geocode")):a.point?this._reverseGeocodePoint(c,
  a.point).then(function(g){d.resolve(g)},function(g){d.reject(g)}):a.latlon?(l=new O(a.latlon,this._defaultSR),this._reverseGeocodePoint(c,l).then(function(g){d.resolve(g)},function(g){d.reject(g)})):a.hasOwnProperty("text")&&!f?d.resolve([]):d.reject(this._error("Invalid query type for Locator"));else e.featureLayer?this._featureLayerLoaded(e.featureLayer).then(k.hitch(this,function(){var g=this._getDisplayField(e),m=e.searchFields||[g];g=this._validField(e.featureLayer,g);var t=this._validFields(e.featureLayer,
  m);if(g&&t){g=new V;e.hasOwnProperty("searchQueryParams")&&k.mixin(g,e.searchQueryParams);p&&(g.outSpatialReference=p,t=this.map&&this.map.getMaxResolution()||1/U.getUnitValueForSR(p))&&(g.maxAllowableOffset=t);g.returnGeometry=!0;e.outFields&&(g.outFields=e.outFields);if(!a.hasOwnProperty(this._objectIdIdentifier)){this._supportsPagination(e)&&(g.num=e.maxResults||this.maxResults);e.useMapExtent&&this.map&&this.map.extent&&(g.geometry=this.map.extent);e.searchExtent&&(g.geometry=e.searchExtent);
  var u=e.exactMatch}a.hasOwnProperty("text")&&f?(m=this._whereClause(h,e.featureLayer,m,u,"search"))?(g.where=m,m=!0):m=!1:a.hasOwnProperty(this._objectIdIdentifier)?(g.objectIds=[a[this._objectIdIdentifier]],m=!0):a.geometry?(g.geometry=a.geometry,m=!0):a.point?(g.geometry=a.point,m=!0):a.latlon?(b=new O(a.latlon,this._defaultSR),g.geometry=b,m=!0):(a.hasOwnProperty("text")&&!f?d.resolve([]):d.reject(this._error("Invalid query type for FeatureLayer")),m=!1);m?e.featureLayer.queryFeatures(g,k.hitch(this,
  function(q){q=q.features;var B;q&&(B=this._hydrateResults(q,c,!1));d.resolve(B)}),k.hitch(this,function(q){q||(q=this._error("FeatureLayer queryFeatures could not be performed"));d.reject(q)})):d.resolve()}else d.reject(this._error("Invalid FeatureLayer field"))})):d.reject(this._error("Invalid source"))}else d.reject(this._error("Source is undefined"));return d.promise},_clearQueryTimeout:function(){this._queryTimer&&clearTimeout(this._queryTimer)},_formatResults:function(a,b,d){d={activeSourceIndex:b,
  value:d,numResults:0,numErrors:0,errors:null,results:null};var c={},e={};if(a)if(b===this._allIndex)for(b=0;b<a.length;b++)a[b]&&(a[b]instanceof Error?(c[b]=a[b],d.numErrors++):(e[b]=a[b],d.numResults+=a[b].length));else a[0]&&(a[0]instanceof Error?(c[b]=a[0],d.numErrors++):(e[b]=a[0],d.numResults+=a[0].length));d.numErrors&&(d.errors=c);d.numResults&&(d.results=e);return d},_reverseGeocodePoint:function(a,b){var d=new C,c=this.sources[a];if(b&&c){var e=c.locationToAddressDistance||this.locationToAddressDistance;
  c.locator.outSpatialReference=this._defaultSR;this.map&&(c.locator.outSpatialReference=this.map.spatialReference);c.locator.locationToAddress(b,e,k.hitch(this,function(f){f=this._hydrateResults([f],a,!1);d.resolve(f)}),k.hitch(this,function(f){f||(f=this._error("Locator locationToAddress could not be performed"));d.reject(f)}))}else d.reject(this._error("No point or source defined for reverse geocoding"));return d.promise},_cancelDeferreds:function(){if(this._deferreds&&this._deferreds.length)for(var a=
  0;a<this._deferreds.length;a++)this._deferreds[a].cancel(this.declaredClass+" cancelling request");this._deferreds=[]},_sourceBtnKey:function(a){if(a){var b=H("li",this.sourcesNode);a.keyCode===x.UP_ARROW?(a.stopPropagation(),a.preventDefault(),this._showSourcesMenu(),(a=b.length)&&v.focus(b[a-1])):a.keyCode===x.DOWN_ARROW&&(a.stopPropagation(),a.preventDefault(),this._showSourcesMenu(),b[0]&&v.focus(b[0]))}},_inputKey:function(a){if(a){var b=H("li",this.suggestionsNode),d=this.suggestResults;if(a.keyCode===
  x.TAB||a.keyCode===x.ESCAPE)this._cancelSuggest(),this._hideMenus();else if(a.keyCode===x.UP_ARROW)a.stopPropagation(),a.preventDefault(),this._cancelSuggest(),d&&this._showSuggestionsMenu(),(a=b.length)&&v.focus(b[a-1]);else if(a.keyCode===x.DOWN_ARROW)a.stopPropagation(),a.preventDefault(),this._cancelSuggest(),d&&this._showSuggestionsMenu(),b[0]&&v.focus(b[0]);else{if(a.ctrlKey||a.metaKey||a.keyCode===x.copyKey||a.keyCode===x.LEFT_ARROW||a.keyCode===x.RIGHT_ARROW||a.keyCode===x.ENTER)return a;
  this._suggestDelay()}}},_cancelSuggest:function(){this._cancelDeferreds();this._clearQueryTimeout()},_suggestDelay:function(){this._cancelSuggest();this._changeValue();this._queryTimer=setTimeout(k.hitch(this,function(){this.suggest()}),this.suggestionDelay)},_changeValue:function(){this.set("magicKey",null);this.set("selectedFeatureId",null);this._changeAttrValue("value",this.inputNode.value);this._checkStatus()},_inputClick:function(){this._hideSourcesMenu();this._hideNoResultsMenu()},_getSourceName:function(a){return this._sourceNames[a]},
  _loadSources:function(a){a=E.filter(a,function(b){return!!b.featureLayer});a=E.map(a,function(b){return this._featureLayerLoaded(b.featureLayer)},this);return K(a)},_createSourceNameMap:function(a){return this._loadSources(a).then(k.hitch(this,function(){var b=E.map(a,function(d){return d.name||d.featureLayer&&d.featureLayer.name||y.widgets.Search.main.untitledSource});this._preventDuplicateSourceNames(a,b);return b}))},_getDuplicateSourceNameIndexes:function(a){var b={},d=[];E.forEach(a,function(c,
  e){b.hasOwnProperty(c)?(-1===d.indexOf(b[c])&&d.push(b[c]),d.push(e)):a.lastIndexOf(c)!==e&&(b[c]=e)});return d},_preventDuplicateSourceNames:function(a,b){if(b&&1<b.length){var d=this._getDuplicateSourceNameIndexes(b);E.forEach(d,function(c){b[c]+=this._getFieldsString(a[c])},this)}},_getFieldsString:function(a){var b="",d=a.featureLayer;if(d){a=a.searchFields||[this._getDisplayField(a)];for(var c=0;c<a.length;c++){b=0===c?b+": ":b+", ";var e=a[c],f=d.getFieldLabel(e);b+=f||e}}return b},_splitResult:function(a,
  b){b=Z.escapeString(b);return a.replace(new RegExp("(^|)("+b+")(|$)","ig"),"$1|$2|$3").split("|")},_insertSuggestions:function(a,b){if(this.enableSuggestionsMenu&&this.suggestionsNode){this._hideSourcesMenu();this._hideNoResultsMenu();var d=this.sources;if(a){var c=w.create("div");for(var e in a)if(a[e]&&a[e].length){var f=this._getSourceName(e);1<d.length&&this.activeSourceIndex===this._allIndex&&w.create("div",{className:this.css.searchMenuHeader,textContent:f},c);f=w.create("ul",{role:"menu"},
  c);for(var h=d[e].maxSuggestions||this.maxSuggestions,p=0;p<a[e].length&&p<h;++p){var l=w.create("li",{"data-index":p,"data-source-index":e,role:"menuitem",tabindex:0},f),n=this._getSuggestionName(a[e][p]);n=this._splitResult(n,b);for(var g=n.length,m=0;m<g;m++){var t=n[m];t.toLowerCase()===b.toLowerCase()?w.create("strong",{textContent:t},l):(t=document.createTextNode(t),w.place(t,l))}}}}c?(w.place(c,this.suggestionsNode,"only"),this._showSuggestionsMenu()):(w.empty(this.suggestionsNode),this._hideSuggestionsMenu())}},
  _insertSources:function(a){if(this.enableSourcesMenu&&a&&1<a.length){var b,d=this.activeSourceIndex,c=w.create("ul",{role:"menu"});if(this.enableSearchingAll){var e="";d===this._allIndex&&(e="active");w.create("li",{"data-index":this._allIndex,role:"menuitem",className:e,tabIndex:0,textContent:y.widgets.Search.main.all},c)}for(b=0;b<a.length;b++){e="";b===d&&(e=this.css.activeSource);var f=this._getSourceName(b);w.create("li",{"data-index":b,role:"menuitem",className:e,tabIndex:0,textContent:f},c)}r.add(this.containerNode,
  this.css.hasMultipleSources);w.place(c,this.sourcesNode,"only")}else r.remove(this.containerNode,this.css.hasMultipleSources),w.empty(this.sourcesNode)},_showLoading:function(){r.add(this.containerNode,this.css.searchLoading)},_hideLoading:function(){r.remove(this.containerNode,this.css.searchLoading)},_checkStatus:function(){this.value?(r.add(this.containerNode,this.css.hasValue),z.set(this.clearNode,"title",y.widgets.Search.main.clearButtonTitle)):this.clear()},_closePopup:function(){this.enableInfoWindow&&
  this.map&&this.map.infoWindow&&this.map.infoWindow.hide()},_noResults:function(a){var b;a&&(b=k.trim(a));var d=w.create("div",{className:this.css.searchNoResultsBody});a&&b?(w.create("div",{className:this.css.searchNoResultsHeader,textContent:y.widgets.Search.main.noResults},d),w.create("div",{className:this.css.searchNoResultsText,textContent:J.substitute({value:'"'+a+'"'},y.widgets.Search.main.noResultsFound)},d)):(a=w.create("div",{},d),w.create("span",{"aria-hidden":"true",className:this.css.searchNoValueIcon},
  a),w.create("span",{className:this.css.searchNoValueText,textContent:y.widgets.Search.main.emptyValue},a));w.place(d,this.noResultsMenuNode,"only")},_hideMenus:function(){this._hideSourcesMenu();this._hideSuggestionsMenu();this._hideNoResultsMenu()},_hideNoResultsMenu:function(){r.remove(this.containerNode,this.css.showNoResults)},_showNoResultsMenu:function(){this._hideSourcesMenu();this._hideSuggestionsMenu();r.add(this.containerNode,this.css.showNoResults)},_hideSourcesMenu:function(){r.remove(this.containerNode,
  this.css.showSources)},_hideSuggestionsMenu:function(){r.remove(this.containerNode,this.css.showSuggestions)},_showSourcesMenu:function(){this._hideSuggestionsMenu();this._hideNoResultsMenu();r.add(this.containerNode,this.css.showSources)},_showSuggestionsMenu:function(){this._hideSourcesMenu();this._hideNoResultsMenu();r.add(this.containerNode,this.css.showSuggestions)},_toggleSourcesMenu:function(){this._hideSuggestionsMenu();this._hideNoResultsMenu();r.toggle(this.containerNode,this.css.showSources)},
  _getFirstStringField:function(a){if(a&&(a=a.fields)&&a.length)for(var b=0;b<a.length;b++){var d=a[b];if("esriFieldTypeString"===d.type)return d.name}return""},_getDisplayField:function(a){return a.displayField||a.featureLayer.displayField||this._getFirstStringField(a.featureLayer)},_validLocation:function(a){return a&&"number"===typeof a.x&&"number"===typeof a.y},_validExtent:function(a){return a&&"number"===typeof a.xmin&&"number"===typeof a.ymin&&"number"===typeof a.xmax&&"number"===typeof a.ymax},
  _hydrateResult:function(a,b,d){var c={},e=this._defaultSR;b=this.sources[b];this.map&&(e=this.map.spatialReference);if(a.hasOwnProperty("text")&&a.hasOwnProperty("magicKey"))return a;if(a.hasOwnProperty("geometry")){var f=new F(a.toJson());c.feature=f;(f=c.feature.geometry)&&f.setSpatialReference(e)}else if(a.hasOwnProperty("location")&&this._validLocation(a.location)){var h=new O(a.location.x,a.location.y,e);f={};a.hasOwnProperty("attributes")&&(f=a.attributes);a.hasOwnProperty("address")&&"object"===
  typeof a.address&&k.mixin(f,a.address);a.hasOwnProperty("score")&&(f.score=a.score);c.feature=new F(h,null,f,null)}!c.feature&&d&&(f={},a.hasOwnProperty("attributes")&&(f=a.attributes),a.hasOwnProperty("score")&&(f.score=a.score),c.feature=new F(null,null,f,null));if(c.feature){if(a.hasOwnProperty("extent")&&this._validExtent(a.extent))c.extent=new T(a.extent),c.extent.setSpatialReference(e);else if(c.feature&&c.feature.geometry)switch(c.feature.geometry.type){case "extent":c.extent=c.feature.geometry;
  break;case "multipoint":c.extent=P.getDenormalizedExtent(c.feature.geometry);break;case "polygon":c.extent=P.getDenormalizedExtent(c.feature.geometry);break;case "polyline":c.extent=P.getDenormalizedExtent(c.feature.geometry);break;case "point":this.map?(e=this.zoomScale,b&&b.zoomScale&&(e=b.zoomScale),this._getScale()>e?c.extent=U.getExtentForScale(this.map,e).centerAt(c.feature.geometry):c.extent=this.map.extent.centerAt(c.feature.geometry)):c.extent=new T({xmin:c.feature.geometry.x-.25,ymin:c.feature.geometry.y-
  .25,xmax:c.feature.geometry.x+.25,ymax:c.feature.geometry.y+.25,spatialReference:this._defaultSR})}else c.extent=null;c.name="";b.featureLayer?b.suggestionTemplate&&d?c.name=J.substitute(a.attributes,b.suggestionTemplate):b.searchTemplate?c.name=J.substitute(a.attributes,b.searchTemplate):(f=this._getDisplayField(b),d=b.featureLayer.getField(f),e=b.featureLayer.getDomain(f),f&&a.hasOwnProperty("attributes")&&a.attributes.hasOwnProperty(f)&&(a=a.attributes[f],e&&"codedValue"===e.type?c.name=this._getCodedName(e.codedValues,
  a):d&&"esriFieldTypeDate"===d.type&&!isNaN(a)?c.name=aa.format(new Date(a)):c.name=a)):a.address&&b.searchTemplate?c.name=J.substitute(a.address,b.searchTemplate):a.hasOwnProperty("name")?c.name=a.name:a.hasOwnProperty("attributes")&&"object"===typeof a.attributes&&a.attributes.LongLabel?c.name=a.attributes.LongLabel:a.hasOwnProperty("attributes")&&"object"===typeof a.attributes&&a.attributes.Match_addr?(c.name=a.attributes.Match_addr,a.attributes.Addr_type&&"POI"===a.attributes.Addr_type&&a.attributes.StAddr&&
  a.attributes.City?c.name+=" - "+a.attributes.StAddr+", "+a.attributes.City:a.attributes.Addr_type&&"POI"===a.attributes.Addr_type&&a.attributes.City&&(c.name+=" - "+a.attributes.City)):a.hasOwnProperty("address")&&"string"===typeof a.address?c.name=a.address:a.hasOwnProperty("address")&&"object"===typeof a.address&&a.address.hasOwnProperty("Address")?a.address.hasOwnProperty("Match_addr")?c.name=a.address.Match_addr:a.address.hasOwnProperty("Address")&&(c.name=a.address.Address):c.feature&&c.feature.geometry&&
  (c.name=c.feature.geometry.x+","+c.feature.geometry.y);b.featureLayer&&c.feature&&M(c.feature,b.featureLayer);return c}},_getScale:function(){var a;this.map&&"function"===typeof this.map.getScale&&(a=this.map.getScale());return a},_hydrateResults:function(a,b,d,c){c=[];var e=0;if(a&&a.length)for(e;e<a.length;e++){var f=this._hydrateResult(a[e],b,d);f&&c.push(f)}return c},_containsNonLatinCharacter:function(a){for(var b=0;b<a.length;b++)if(255<a.charCodeAt(b))return!0;return!1},_setPlaceholder:function(a){var b=
  "",d=this.sources[a];a===this._allIndex?b=this.allPlaceholder||y.widgets.Search.main.allPlaceholder:d&&d.placeholder&&(b=d.placeholder);var c=y.widgets.Search.main.all;d&&(c=this._getSourceName(a));z.set(this.sourceNameNode,"textContent",c);z.set(this.inputNode,"placeholder",b);z.set(this.inputNode,"title",b)},_updateActiveSource:function(){var a=this.sources,b=this.activeSourceIndex,d;a&&a[b]&&(d=a[b]);d?this.set("activeSource",d):this.set("activeSource",null)},_updateVisible:function(){this.visible?
  this.show():this.hide()},_updateButtonMode:function(a){a?(r.toggle(this.containerNode,this.css.searchExpanded,this.expanded),r.toggle(this.containerNode,this.css.searchCollapsed,!this.expanded),r.add(this.containerNode,this.css.hasButtonMode)):(r.remove(this.containerNode,this.css.searchExpanded),r.remove(this.containerNode,this.css.searchCollapsed),r.remove(this.containerNode,this.css.hasButtonMode))},_setDefaultActiveSourceIndex:function(a){a&&1===a.length||!this.enableSearchingAll?this.set("activeSourceIndex",
  0):this.set("activeSourceIndex",this._allIndex)},_setEnableSourcesMenuAttr:function(a){this._set("enableSourcesMenu",a);this._created&&this._insertSources(this.sources)},_setEnableSearchingAllAttr:function(a){this._set("enableSearchingAll",a);this._created&&(this._setDefaultActiveSourceIndex(this.sources),this._hideMenus(),this._insertSources(this.sources))},_setSourcesAttr:function(a){this._createSourceNameMap(a).then(k.hitch(this,function(b){this._sourceNames=b;this._created&&(this._setDefaultActiveSourceIndex(a),
  this._hideMenus(),this._insertSources(a))}));this._set("sources",a)},_setAllPlaceholderAttr:function(a){this._set("allPlaceholder",a);this._created&&this._setPlaceholder(this.activeSourceIndex)},_setActiveSourceIndexAttr:function(a){this._set("activeSourceIndex",a);this._updateActiveSource();this._created&&(this._setPlaceholder(a),this._hideMenus(),this._insertSources(this.sources))},_setMaxLengthAttr:function(a){this._set("maxLength",a);this._created&&z.set(this.inputNode,"maxLength",a)},_setValueAttr:function(a){this.set("magicKey",
  null);this.set("selectedFeatureId",null);this._set("value",a);this._created&&(z.set(this.inputNode,"value",a),this._checkStatus())},_setVisibleAttr:function(a){this._set("visible",a);this._created&&this._updateVisible()},_setEnableButtonModeAttr:function(a){this._set("enableButtonMode",a);this._created&&this._updateButtonMode(a)},_setThemeAttr:function(a){this._created&&(r.remove(this.domNode,this.theme),r.add(this.domNode,a));this._set("theme",a)}});Y("extend-esri")&&k.setObject("dijit.Search",G,
  ha);return G});