// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/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(R,A,g,y,S,x,p,v,B,T,U,L,r,k,M,m,V,q,W,X,Y,Z,C,n,D,aa,ba,ca,z,E,da,ea,H,fa,ga,F,I,N,J,O,ha,P,ia,ja){function G(a,b){a&&b&&(a._layer=b,a._sourceLayer=b)}A=A([X,Y,Z,S],{declaredClass:"esri.dijit.Search",templateString:W,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 ha("//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"),singleLineFieldName:"SingleLine",outFields:["Addr_type",
"Match_addr","StAddr","City"],name:q.widgets.Search.main.esriLocatorName,localSearchOptions:{minScale:3E5,distance:5E4},placeholder:q.widgets.Search.main.placeholder,highlightSymbol:(new da(R.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:150,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 ga).setColor(new ia([181,56,46,.9])).setFont(new F("14px",F.STYLE_NORMAL,F.VARIANT_NORMAL,F.WEIGHT_BOLD,"Arial")),labelGraphic:null,infoTemplate:new aa(q.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:1,enableSearchingAll:!0};var d=g.mixin({},this.options,a);this.set(d);this._updateActiveSource();this._i18n=q;this._defaultSR=new ca(4326);this.domNode=b},startup:function(){this.inherited(arguments);this.sources||(this.sources=[]);this._mapLoaded().then(g.hitch(this,this._init))},postCreate:function(){var a=
this;this.inherited(arguments);this._moreResultsId=this.id+"_more_results";this.own(v(this.submitNode,C,g.hitch(this,this._searchButton)));this.own(v(this.sourcesBtnNode,C,g.hitch(this,this._toggleSourcesMenu)));this.own(v(this.inputNode,C,g.hitch(this,this._inputClick)));this.own(v(this.clearNode,C,g.hitch(this,this._clearButton)));this.own(v(this.formNode,"submit",g.hitch(this,function(a){a.preventDefault();this._cancelSuggest();this.search()})));this.own(v(this.inputNode,"keyup",g.hitch(this,function(a){this._inputKey(a)})));
this.own(v(this.sourcesBtnNode,"keyup",g.hitch(this,function(a){this._sourceBtnKey(a)})));this.own(v(this.suggestionsNode,"li:click, li:keyup",function(b){a._suggestionsEvent(b,this)}));this.own(v(this.sourcesNode,"li:click, li:keyup",function(b){a._sourcesEvent(b,this)}));this.own(v(this.inputNode,"input, paste",g.hitch(this,function(){this._suggestDelay()})));this.map&&this.map.infoWindow&&this.map.infoWindow.domNode&&this.enableInfoWindow&&(this.own(v(this.map.infoWindow.domNode,"#"+this._moreResultsId+
"_show:click",g.hitch(this,function(a){this._showMoreResultsClick(a)}))),this.own(v(this.map.infoWindow.domNode,"#"+this._moreResultsId+"_list li a:click",g.hitch(this,function(a){this._moreResultsClick(a)}))),this.own(v(this.map.infoWindow.domNode,"#"+this._moreResultsId+" [data-switch-coordinates]:click",g.hitch(this,function(a){this._switchCoordinatesClick(a)}))));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();m.empty(this.domNode);this.inherited(arguments)},clear:function(){this.clearGraphics();r.get(this.inputNode,"value")&&r.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);k.remove(this.containerNode,this.css.hasValue);r.set(this.clearNode,
"title","");this._hideMenus();this._closePopup();this._hideLoading();this.emit("clear-search")},show:function(){M.set(this.domNode,"display","block")},hide:function(){M.set(this.domNode,"display","none")},expand:function(){this.enableButtonMode&&(k.add(this.containerNode,this.css.searchExpanded),k.remove(this.containerNode,this.css.searchCollapsed),this._hideMenus(),this.set("expanded",!0))},collapse:function(){this.enableButtonMode&&(k.remove(this.containerNode,this.css.searchExpanded),k.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 x;this._mapLoaded().then(g.hitch(this,function(){this._searchDeferred(a).then(g.hitch(this,function(a){var c=a.results;this.set("searchResults",c);0===a.numResults&&(this._noResults(a.value),this._showNoResultsMenu());this._hideLoading();this.emit("search-results",a);this._selectFirstResult(c,
a.activeSourceIndex);b.resolve(c)}),g.hitch(this,function(a){b.reject(a)}))}));return b.promise},suggest:function(a){var b=new x;this._mapLoaded().then(g.hitch(this,function(){this._suggestDeferred(a).then(g.hitch(this,function(a){if(a){var c=a.results;this.set("suggestResults",c);this._insertSuggestions(c,a.value);this.emit("suggest-results",a);b.resolve(c)}}),g.hitch(this,function(a){b.reject(a)}))}));return b.promise},select:function(a){var b=this._getDefaultSymbol(a),d=this.labelSymbol,c,e=this.sources,
f=this.activeSourceIndex,Q=this.enableHighlight,l=this.enableLabel,h=this.autoNavigate,u=this.showInfoWindowOnSelect,w=this.enableInfoWindow,K=this.infoTemplate,k=a.feature?new z(a.feature.toJson()):null,n=k?a.feature._sourceLayer:null;G(k,n);if(f===this._allIndex){var t=this._getSourceIndexOfResult(a);null!==t&&(c=e[t],f=t)}else c=e[f];c&&(c.hasOwnProperty("highlightSymbol")&&(b=c.highlightSymbol),c.hasOwnProperty("labelSymbol")&&(d=c.labelSymbol),c.hasOwnProperty("enableHighlight")&&(Q=c.enableHighlight),
c.hasOwnProperty("enableLabel")&&(l=c.enableLabel),c.hasOwnProperty("autoNavigate")&&(h=c.autoNavigate),c.hasOwnProperty("showInfoWindowOnSelect")&&(u=c.showInfoWindowOnSelect),c.hasOwnProperty("enableInfoWindow")&&(w=c.enableInfoWindow),c.hasOwnProperty("infoTemplate")?K=c.infoTemplate:c.featureLayer&&c.featureLayer.infoTemplate&&(K=c.featureLayer.infoTemplate));this._hideMenus();this._hideLoading();if(k){var e=this.highlightGraphic,m=this.graphicsLayer,t=this.labelGraphic,p=g.mixin({},k.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;w&&(q=K);t?(t.setGeometry(k.geometry),t.setAttributes(p),t.setSymbol(d),d&&"textsymbol"===d.type&&t.symbol.setText(a.name)):(t=new z(k.geometry,d,p),G(t,n),d&&"textsymbol"===d.type&&t.symbol.setText(a.name),l&&(m?m.add(t):this.map&&this.map.graphics&&
this.map.graphics.add(t)));e?(e.setGeometry(k.geometry),e.setAttributes(p),e.setInfoTemplate(q),e.setSymbol(b)):(e=new z(k.geometry,b,p,q),G(e,n),Q&&(m?m.add(e):this.map&&this.map.graphics&&this.map.graphics.add(e)));e&&e.symbol&&"textsymbol"===e.symbol.type&&e.symbol.setText(a.name);this.map&&this.map.infoWindow&&w&&u&&(this.map.infoWindow.setFeatures([e]),b=this._getPointFromGeometry(e.geometry),this.map.infoWindow.show(b));this.map&&h&&a&&a.hasOwnProperty("extent")&&"function"===typeof this.map.setExtent&&
this.map.setExtent(a.extent,!0);this.set("highlightGraphic",e);this.set("labelGraphic",t)}this.set("selectedResult",a);this.emit("select-result",{result:a,source:c,sourceIndex:f})},focus:function(){n.focus(this.inputNode)},blur:function(){this.inputNode.blur();n.curNode&&n.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 x;if(this.map)if(this.map.loaded)a.resolve();else v.once(this.map,"load",g.hitch(this,function(){a.resolve()}));else a.resolve();return a.promise},_init:function(){this._getMapLayers().then(g.hitch(this,function(){this.set("loaded",!0);this.emit("load")}))},_clearButton:function(){this.clear();n.focus(this.inputNode)},_error:function(a){return Error(this.declaredClass+" "+
a)},_searchDeferred:function(a){var b=new x,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(g.hitch(this,function(a){a=this._formatResults(a,c,d);b.resolve(a)}));return b.promise},_suggestDeferred:function(a){var b=new x;this._deferreds.push(b);a||(a=this.value);var d=this.activeSourceIndex;this._suggestQueries({text:a}).always(g.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,d,c,e;this.map&&(e=this.map.getBasemap());e||(e="topo");a&&a.feature&&a.feature.geometry&&(c=a.feature.geometry.type);"polyline"===c?c="line":"circle"===c||"extent"===c?c="polygon":"multipoint"===c&&(c="point");if(c){if(a=ja.getSchemes({theme:"default",basemap:e,geometryType:c}))d=a.primaryScheme;if(d){d.color&&d.hasOwnProperty("opacity")&&(d.color.a=d.opacity);
b=d;a=d.color;d=d.size;var f;switch(c){case "point":f=new ea;f.setColor(a);f.setSize(null!==d?d:b.size);c=new H;c.setColor(b.outline.color);c.setWidth(b.outline.width);f.setOutline(c);break;case "line":f=new H;f.setColor(a);f.setWidth(null!==d?d:b.width);break;case "polygon":f=new fa,f.setColor(a),c=new H,c.setColor(b.outline.color),c.setWidth(b.outline.width),f.setOutline(c)}b=f}}return b},_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 x;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))}E(b).always(g.hitch(this,function(b){for(var c,d=this.sources,e=0;e<b.length;e++)b[e]&&
b[e].loaded&&"Feature Layer"===b[e].type&&(d.push({featureLayer:b[e],enableSuggestions:!0}),c=!0);c&&this.set("sources",d);a.resolve()}))}else a.resolve()}else a.resolve();return a.promise},_switchCoordinatesClick:function(a){a.preventDefault();if(a=r.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(r.get(b,"data-source-index"),10);var b=parseInt(r.get(b,"data-index"),10),d=this.searchResults;
d&&d[a]&&(a=d[a][b])&&this.select(a)},_showMoreResultsClick:function(a){a.preventDefault();if(a=L.byId(this._moreResultsId)){k.toggle(a,this.css.searchShowMoreResults);var b=L.byId(this._moreResultsId+"_show");b&&(k.contains(a,this.css.searchShowMoreResults)?r.set(b,"textContent",q.widgets.Search.main.hideMoreResults):r.set(b,"textContent",q.widgets.Search.main.showMoreResults))}},_featureLayerLoaded:function(a){var b=new x;if(a.loaded)b.resolve(a);else if(a.loadError)b.reject(this._error("Layer failed to load."));
else{var d,c;d=v.once(a,"load",g.hitch(this,function(){c.remove();b.resolve(a)}));c=v.once(a,"error",g.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=r.get(b,"data-index"),c=B("li",this.sourcesNode),e=y.indexOf(c,b);d!==this._allIndex&&(d=parseInt(d,10));"click"===a.type||a.keyCode===p.ENTER?(this.set("activeSourceIndex",d),
n.focus(this.inputNode),this._hideSourcesMenu()):a.keyCode===p.UP_ARROW?(a.stopPropagation(),a.preventDefault(),d=e-1,0>d?n.focus(this.sourcesBtnNode):n.focus(c[d])):a.keyCode===p.DOWN_ARROW?(a.stopPropagation(),a.preventDefault(),d=e+1,d>=c.length?n.focus(this.sourcesBtnNode):n.focus(c[d])):a.keyCode===p.ESCAPE&&(this._hideSourcesMenu(),n.focus(this.inputNode))},_suggestionsEvent:function(a,b){var d=r.get(b,"data-source-index"),c=parseInt(r.get(b,"data-index"),10),e=B("li",this.suggestionsNode),
f=this.sources,g=y.indexOf(e,b);d!==this._allIndex&&(d=parseInt(d,10));var l;this._clearQueryTimeout();"click"===a.type||a.keyCode===p.ENTER?((e=this.suggestResults)&&e[d]&&e[d][c]&&(l=e[d][c]),l&&(l.index=d,f[d].featureLayer?(d=f[d].featureLayer.objectIdField,l[this._objectIdIdentifier]=l.feature.attributes[d],this.set("value",this._getSuggestionName(l)),this.set("selectedFeatureId",l.feature.attributes[d])):l.magicKey&&l.text&&(this.set("value",l.text),this.set("magicKey",l.magicKey)),this.search(l),
n.focus(this.inputNode))):a.keyCode===p.BACKSPACE||a.keyCode===p.DELETE?n.focus(this.inputNode):a.keyCode===p.UP_ARROW?(a.stopPropagation(),a.preventDefault(),l=g-1,0>l?n.focus(this.inputNode):n.focus(e[l])):a.keyCode===p.DOWN_ARROW?(a.stopPropagation(),a.preventDefault(),l=g+1,l>=e.length?n.focus(this.inputNode):n.focus(e[l])):a.keyCode===p.ESCAPE&&(this._hideMenus(),n.focus(this.inputNode))},_getResultName:function(a){var b;a.hasOwnProperty("name")&&null!==a.name&&(b=a.name.toString());b||(b=q.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=q.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(" "),c,e;2===d.length&&(c=d[0],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'+q.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'+q.widgets.Search.main.reverseLonLatHeader+"\x3c/div\x3e",b=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){var d=d+('\x3cdiv class\x3d"'+this.css.searchMoreResultsItem+'"\x3e'),d=d+('\x3ca href\x3d"#" id\x3d"'+this._moreResultsId+'_show"\x3e'+q.widgets.Search.main.showMoreResults+"\x3c/a\x3e"),d=d+"\x3c/div\x3e"+('\x3cdiv class\x3d"'+this.css.searchMoreResultsList+'"\x3e'),d=d+('\x3cdiv id\x3d"'+this._moreResultsId+'_list"\x3e'),g;for(g in c)if(c[g]){var l=c[g].length;if(l){var h=1===l&&c[g][0]===a;if(1<this._getObjectSize(c)&&!h)var u=this._getSourceName(g),
d=d+('\x3cdiv class\x3d"'+this.css.searchMoreResultsListHeader+'"\x3e'+u+"\x3c/div\x3e");if(l&&!h){d+="\x3cul\x3e";u=e[g].maxResults||this.maxResults;for(h=0;h<l&&h<u;++h)if(c[g][h]!==a){var w=this._getResultName(c[g][h]),d=d+('\x3cli\x3e\x3ca tabindex\x3d"0" data-index\x3d"'+h+'" data-source-index\x3d"'+g+'" href\x3d"#"\x3e'+w+"\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],g=f.name,l=b;d||(g=g.toLowerCase(),l=l.toLowerCase());if(g===l)return f.code}return!1},_whereClause:function(a,b,d,c){var e=null;if(a){var f="";this.reHostedFS.test(b.url)&&this._containsNonLatinCharacter(a)&&
(f="N");if(d&&d.length)for(var g=0,l=d.length;g<l;g++){var h="",u=a.replace(/\'/g,"''"),h=d[g],w=b.getField(h),k=b.getDomain(h);k&&"codedValue"===k.type&&(u=this._getCodedValue(k.codedValues,u,c));!1!==u&&(w=w.type,"esriFieldTypeString"===w||"esriFieldTypeDate"===w?h=c?h+" \x3d "+f+"'"+u+"'":"UPPER("+h+") LIKE "+f+"'%"+u.toUpperCase()+"%'":"esriFieldTypeOID"===w||"esriFieldTypeSmallInteger"===w||"esriFieldTypeInteger"===w||"esriFieldTypeSingle"===w||"esriFieldTypeDouble"===w?(u=parseFloat(u),h=isNaN(u)?
!1:h+" \x3d "+u):h=h+" \x3d "+u,h&&(e=e?e+" or ":"",e+=h))}}return e},_suggest:function(a){a||(a={index:this.activeSourceIndex,text:this.value});var b=new x,d=a.index,c=this.sources[d],e=this.enableSuggestions;c.hasOwnProperty("enableSuggestions")&&(e=c.enableSuggestions);var f=0,k;a.hasOwnProperty("text")&&a.text&&(k=g.trim(a.text),f=a.text.length);a=c.minCharacters||this.minCharacters;if(e&&k&&f>=a&&this._supportsPagination(c)){var l="";c.prefix&&(l+=c.prefix);l+=k;c.suffix&&(l+=c.suffix);var h=
this._defaultSR;this.map&&(h=this.map.spatialReference);e={};c.locator?(c.categories&&(e.categories=c.categories),c.locator.outSpatialReference=h,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=l,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(g.hitch(this,function(a){b.resolve(a)}),g.hitch(this,function(a){a||(a=this._error("Locator suggestLocations could not be performed."));b.reject(a)}))):c.featureLayer?this._featureLayerLoaded(c.featureLayer).then(g.hitch(this,function(){var a=
this._getDisplayField(c),e=c.searchFields||[a],f=[];c.suggestionTemplate?c.suggestionTemplate.replace(/(?:\$\{([^}]+)\})/g,function(a,b){f.push(b)}):f=[a];-1===y.indexOf(f,c.featureLayer.objectIdField)&&f.push(c.featureLayer.objectIdField);var a=this._validField(c.featureLayer,a),k=this._validFields(c.featureLayer,f),m=this._validFields(c.featureLayer,e);if(a&&k&&m){a=new P;c.hasOwnProperty("suggestQueryParams")&&g.mixin(a,c.suggestQueryParams);a.outSpatialReference=h;a.returnGeometry=!1;a.num=c.maxSuggestions||
this.maxSuggestions;a.outFields=f;c.useMapExtent&&this.map&&this.map.extent&&(a.geometry=this.map.extent);c.searchExtent&&(a.geometry=c.searchExtent);var t;if(e=this._whereClause(l,c.featureLayer,e,!1))a.where=e,t=!0;t?c.featureLayer.queryFeatures(a,g.hitch(this,function(a){var c;(a=a.features)&&(c=this._hydrateResults(a,d,!0));b.resolve(c)}),g.hitch(this,function(a){a||(a=this._error("FeatureLayer queryFeatures errored with suggestions"));b.reject(a)})):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=[],e;if(d===this._allIndex)for(d=0;d<b.length;d++)e=a,e.index=d,e=this._suggest(e),c.push(e);else a.index=d,e=this._suggest(a),c.push(e);return E(c)},_getPointFromGeometry:function(a){var b;
switch(a.type){case "extent":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=[],d;if(a.index===this._allIndex)for(var c=this.sources,e=0;e<c.length;e++)d=a,d.index=e,d=this._search(d),b.push(d);else a=this._search(a),b.push(a);return E(b)},_searchButton:function(){this.enableButtonMode&&
!this.expanded?(this.expand(),n.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 x,c=a.index,e=this.sources[c],f;a.hasOwnProperty("text")&&a.text&&(f=g.trim(a.text));if(e){var k="";e.prefix&&!a.magicKey&&(k+=e.prefix);k+=f;e.suffix&&!a.magicKey&&(k+=e.suffix);var l=
this._defaultSR;this.map&&(l=this.map.spatialReference);if(e.locator)if(a.hasOwnProperty("text")&&f){var h={};e.categories&&(h.categories=e.categories);l&&(e.locator.outSpatialReference=l);if(this.map&&e.localSearchOptions&&e.localSearchOptions.hasOwnProperty("distance")&&e.localSearchOptions.hasOwnProperty("minScale")){var m=this._getScale();if(!e.localSearchOptions.minScale||m&&m<=parseFloat(e.localSearchOptions.minScale))h.location=this.map.extent.getCenter(),h.distance=e.localSearchOptions.distance}h.address=
{};h.maxLocations=e.maxResults||this.maxResults;e.useMapExtent&&this.map&&this.map.extent&&(h.searchExtent=this.map.extent);e.searchExtent&&(h.searchExtent=e.searchExtent);e.sourceCountry&&(h.countryCode=e.sourceCountry);e.countryCode&&(h.countryCode=e.countryCode);a.magicKey&&(h.magicKey=a.magicKey);e.singleLineFieldName?h.address[e.singleLineFieldName]=k:h.address["Single Line Input"]=k;e.outFields&&(h.outFields=e.outFields);e.locator.addressToLocations(h).then(g.hitch(this,function(a){a=this._hydrateResults(a,
c,!1);d.resolve(a)}),g.hitch(this,function(a){a||(a=this._error("Locator addressToLocations could not be performed"));d.reject(a)}))}else a.geometry?(b=this._getPointFromGeometry(a.geometry.geometry))?this._reverseGeocodePoint(c,b).then(function(a){d.resolve(a)},function(a){d.reject(a)}):d.reject(this._error("Invalid point to reverse geocode")):a.point?this._reverseGeocodePoint(c,a.point).then(function(a){d.resolve(a)},function(a){d.reject(a)}):a.latlon?(h=new I(a.latlon,this._defaultSR),this._reverseGeocodePoint(c,
h).then(function(a){d.resolve(a)},function(a){d.reject(a)})):a.hasOwnProperty("text")&&!f?d.resolve([]):d.reject(this._error("Invalid query type for Locator"));else e.featureLayer?this._featureLayerLoaded(e.featureLayer).then(g.hitch(this,function(){var h=this._getDisplayField(e),m=e.searchFields||[h],h=this._validField(e.featureLayer,h),n=this._validFields(e.featureLayer,m);if(h&&n){h=new P;e.hasOwnProperty("searchQueryParams")&&g.mixin(h,e.searchQueryParams);l&&(h.outSpatialReference=l,n=this.map&&
this.map.getMaxResolution()||1/O.getUnitValueForSR(l))&&(h.maxAllowableOffset=n);h.returnGeometry=!0;e.outFields&&(h.outFields=e.outFields);var p;a.hasOwnProperty(this._objectIdIdentifier)||(this._supportsPagination(e)&&(h.num=e.maxResults||this.maxResults),e.useMapExtent&&this.map&&this.map.extent&&(h.geometry=this.map.extent),e.searchExtent&&(h.geometry=e.searchExtent),p=e.exactMatch);a.hasOwnProperty("text")&&f?(m=this._whereClause(k,e.featureLayer,m,p))?(h.where=m,m=!0):m=!1:a.hasOwnProperty(this._objectIdIdentifier)?
(h.objectIds=[a[this._objectIdIdentifier]],m=!0):a.geometry?(h.geometry=a.geometry,m=!0):a.point?(h.geometry=a.point,m=!0):a.latlon?(b=new I(a.latlon,this._defaultSR),h.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(h,g.hitch(this,function(a){a=a.features;var b;a&&(b=this._hydrateResults(a,c,!1));d.resolve(b)}),g.hitch(this,function(a){a||(a=this._error("FeatureLayer queryFeatures could not be performed"));
d.reject(a)})):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 x,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,g.hitch(this,function(b){b=
this._hydrateResults([b],a,!1);d.resolve(b)}),g.hitch(this,function(a){a||(a=this._error("Locator locationToAddress could not be performed"));d.reject(a)}))}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=B("li",this.sourcesNode);
a.keyCode===p.UP_ARROW?(a.stopPropagation(),a.preventDefault(),this._showSourcesMenu(),(a=b.length)&&n.focus(b[a-1])):a.keyCode===p.DOWN_ARROW&&(a.stopPropagation(),a.preventDefault(),this._showSourcesMenu(),b[0]&&n.focus(b[0]))}},_inputKey:function(a){if(a){var b=B("li",this.suggestionsNode),d=this.suggestResults;if(a.keyCode===p.TAB||a.keyCode===p.ESCAPE)this._cancelSuggest(),this._hideMenus();else if(a.keyCode===p.UP_ARROW)a.stopPropagation(),a.preventDefault(),this._cancelSuggest(),d&&this._showSuggestionsMenu(),
(a=b.length)&&n.focus(b[a-1]);else if(a.keyCode===p.DOWN_ARROW)a.stopPropagation(),a.preventDefault(),this._cancelSuggest(),d&&this._showSuggestionsMenu(),b[0]&&n.focus(b[0]);else{if(a.ctrlKey||a.metaKey||a.keyCode===p.copyKey||a.keyCode===p.LEFT_ARROW||a.keyCode===p.RIGHT_ARROW||a.keyCode===p.ENTER)return a;this._suggestDelay()}}},_cancelSuggest:function(){this._cancelDeferreds();this._clearQueryTimeout()},_suggestDelay:function(){this._cancelSuggest();this._changeValue();this._queryTimer=setTimeout(g.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=y.filter(a,function(a){return!!a.featureLayer});a=y.map(a,function(a){return this._featureLayerLoaded(a.featureLayer)},this);return E(a)},
_createSourceNameMap:function(a){return this._loadSources(a).then(g.hitch(this,function(){var b=y.map(a,function(a){return a.name||a.featureLayer&&a.featureLayer.name||q.widgets.Search.main.untitledSource});this._preventDuplicateSourceNames(a,b);return b}))},_getDuplicateSourceNameIndexes:function(a){var b={},d=[];y.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);y.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++)var b=0===c?b+": ":b+", ",e=a[c],f=d.getFieldLabel(e),b=b+(f||e)}return b},_splitResult:function(a,b){var d=U.escapeString(b);return a.replace(new RegExp("(^|)("+d+")(|$)","ig"),"$1|$2|$3").split("|")},_insertSuggestions:function(a,b){if(this.enableSuggestionsMenu&&
this.suggestionsNode){this._hideSourcesMenu();this._hideNoResultsMenu();var d,c=this.sources;if(a){d=m.create("div");for(var e in a)if(a[e]&&a[e].length){var f=this._getSourceName(e);1<c.length&&this.activeSourceIndex===this._allIndex&&m.create("div",{className:this.css.searchMenuHeader,textContent:f},d);for(var f=m.create("ul",{role:"menu"},d),g=c[e].maxSuggestions||this.maxSuggestions,k=0;k<a[e].length&&k<g;++k)for(var h=m.create("li",{"data-index":k,"data-source-index":e,role:"menuitem",tabindex:0},
f),n=this._getSuggestionName(a[e][k]),n=this._splitResult(n,b),p=n.length,q=0;q<p;q++){var r=n[q];r.toLowerCase()===b.toLowerCase()?m.create("strong",{textContent:r},h):(r=document.createTextNode(r),m.place(r,h))}}}d?(m.place(d,this.suggestionsNode,"only"),this._showSuggestionsMenu()):(m.empty(this.suggestionsNode),this._hideSuggestionsMenu())}},_insertSources:function(a){if(this.enableSourcesMenu&&a&&1<a.length){var b,d,c=this.activeSourceIndex,e=m.create("ul",{role:"menu"});this.enableSearchingAll&&
(b="",c===this._allIndex&&(b="active"),m.create("li",{"data-index":this._allIndex,role:"menuitem",className:b,tabIndex:0,textContent:q.widgets.Search.main.all},e));for(d=0;d<a.length;d++){b="";d===c&&(b=this.css.activeSource);var f=this._getSourceName(d);m.create("li",{"data-index":d,role:"menuitem",className:b,tabIndex:0,textContent:f},e)}k.add(this.containerNode,this.css.hasMultipleSources);m.place(e,this.sourcesNode,"only")}else k.remove(this.containerNode,this.css.hasMultipleSources),m.empty(this.sourcesNode)},
_showLoading:function(){k.add(this.containerNode,this.css.searchLoading)},_hideLoading:function(){k.remove(this.containerNode,this.css.searchLoading)},_checkStatus:function(){this.value?(k.add(this.containerNode,this.css.hasValue),r.set(this.clearNode,"title",q.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=g.trim(a));var d=m.create("div",{className:this.css.searchNoResultsBody});
a&&b?(m.create("div",{className:this.css.searchNoResultsHeader,textContent:q.widgets.Search.main.noResults},d),m.create("div",{className:this.css.searchNoResultsText,textContent:D.substitute({value:'"'+a+'"'},q.widgets.Search.main.noResultsFound)},d)):(a=m.create("div",{},d),m.create("span",{"aria-hidden":"true",className:this.css.searchNoValueIcon},a),m.create("span",{className:this.css.searchNoValueText,textContent:q.widgets.Search.main.emptyValue},a));m.place(d,this.noResultsMenuNode,"only")},
_hideMenus:function(){this._hideSourcesMenu();this._hideSuggestionsMenu();this._hideNoResultsMenu()},_hideNoResultsMenu:function(){k.remove(this.containerNode,this.css.showNoResults)},_showNoResultsMenu:function(){this._hideSourcesMenu();this._hideSuggestionsMenu();k.add(this.containerNode,this.css.showNoResults)},_hideSourcesMenu:function(){k.remove(this.containerNode,this.css.showSources)},_hideSuggestionsMenu:function(){k.remove(this.containerNode,this.css.showSuggestions)},_showSourcesMenu:function(){this._hideSuggestionsMenu();
this._hideNoResultsMenu();k.add(this.containerNode,this.css.showSources)},_showSuggestionsMenu:function(){this._hideSourcesMenu();this._hideNoResultsMenu();k.add(this.containerNode,this.css.showSuggestions)},_toggleSourcesMenu:function(){this._hideSuggestionsMenu();this._hideNoResultsMenu();k.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&&a.x&&"NaN"!==a.x&&a.y&&"NaN"!==a.y},_validExtent:function(a){return a&&a.xmin&&"NaN"!==a.xmin&&a.ymin&&"NaN"!==a.ymin&&a.xmax&&"NaN"!==a.xmax&&a.ymax&&"NaN"!==a.ymax},_hydrateResult:function(a,b,d){var c={},e=this._defaultSR,f;b=this.sources[b];this.map&&(e=this.map.spatialReference);if(a.hasOwnProperty("text")&&a.hasOwnProperty("magicKey"))return a;
if(a.hasOwnProperty("geometry"))f=new z(a.toJson()),c.feature=f,(f=c.feature.geometry)&&f.setSpatialReference(e);else if(a.hasOwnProperty("location")&&this._validLocation(a.location)){var g=new I(a.location.x,a.location.y,e);f={};a.hasOwnProperty("attributes")&&(f=a.attributes);a.hasOwnProperty("score")&&(f.score=a.score);c.feature=new z(g,null,f,null)}else c.feature=null;if(c.feature){if(a.hasOwnProperty("extent")&&this._validExtent(a.extent))c.extent=new N(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=J.getDenormalizedExtent(c.feature.geometry);break;case "polygon":c.extent=J.getDenormalizedExtent(c.feature.geometry);break;case "polyline":c.extent=J.getDenormalizedExtent(c.feature.geometry);break;case "point":this.map?(e=this.zoomScale,b&&b.zoomScale&&(e=b.zoomScale),this._getScale()>e?c.extent=O.getExtentForScale(this.map,e).centerAt(c.feature.geometry):
c.extent=this.map.extent.centerAt(c.feature.geometry)):c.extent=new N({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=D.substitute(a.attributes,b.suggestionTemplate):b.searchTemplate?c.name=D.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=V.format(new Date(a)):c.name=a)):a.address&&b.searchTemplate?c.name=D.substitute(a.address,b.searchTemplate):a.hasOwnProperty("name")?c.name=a.name: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.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&&G(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||q.widgets.Search.main.allPlaceholder:d&&d.placeholder&&(b=d.placeholder);var c=q.widgets.Search.main.all;d&&(c=this._getSourceName(a));r.set(this.sourceNameNode,"textContent",c);r.set(this.inputNode,"placeholder",b);r.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?
(k.toggle(this.containerNode,this.css.searchExpanded,this.expanded),k.toggle(this.containerNode,this.css.searchCollapsed,!this.expanded),k.add(this.containerNode,this.css.hasButtonMode)):(k.remove(this.containerNode,this.css.searchExpanded),k.remove(this.containerNode,this.css.searchCollapsed),k.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(g.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&&r.set(this.inputNode,"maxLength",a)},_setValueAttr:function(a){this.set("magicKey",null);
this.set("selectedFeatureId",null);this._set("value",a);this._created&&(r.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&&(k.remove(this.domNode,this.theme),k.add(this.domNode,a));this._set("theme",a)}});T("extend-esri")&&g.setObject("dijit.Search",A,ba);return A});