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

//>>built
require({cache:{"url:widgets/BusinessAnalyst/SelectPointPolygonPage.html":'\x3cdiv\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"contentContainer"\x3e\x3c/div\x3e\r\n    \x3cbr\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"searchContainer" class\x3d"esriBusinessAnalystSearchContainer"\x3e\x3c/div\x3e\r\n    \x3cdiv tabindex\x3d"0" role\x3d"button" data-dojo-attach-point\x3d"activatePinButton" title\x3d"${nls.addPoint}" class\x3d"esriBusinessAnalystButton esriBusinessAnalystPinButton esriBusinessAnalystButtonSearchPadding" data-blur-on-click\x3d"true" \x3e\x3c/div\x3e\r\n    \x3cdiv tabindex\x3d"1" role\x3d"button" data-dojo-attach-point\x3d"activatePolygonButton" title\x3d"${nls.addPolygon}" class\x3d"esriBusinessAnalystButton esriBusinessAnalystPolygonButton esriBusinessAnalystButtonSearchPadding" data-blur-on-click\x3d"true" \x3e\x3c/div\x3e\r\n    \x3cdiv tabindex\x3d"2" role\x3d"button" data-dojo-attach-point\x3d"activateFreehandPolygonButton" title\x3d"${nls.addFreehandPolygon}" class\x3d"esriBusinessAnalystButton esriBusinessAnalystFreehandPolygonButton esriBusinessAnalystButtonSearchPadding" data-blur-on-click\x3d"true" \x3e\x3c/div\x3e\r\n\x3c/div\x3e'}});
define("dojo/_base/declare dojo/_base/html dojo/_base/lang dojo/dom-class dojo/dom-style dojo/on dojo/query dojo/when dijit/_TemplatedMixin dijit/_WidgetBase esri/Color esri/dijit/Search esri/dijit/geoenrichment/_WizardPage esri/geometry/webMercatorUtils esri/graphic esri/InfoTemplate esri/symbols/PictureMarkerSymbol esri/symbols/SimpleFillSymbol esri/symbols/SimpleLineSymbol esri/toolbars/draw jimu/dijit/EditorXssFilter jimu/utils dojo/text!./SelectPointPolygonPage.html ./utils/GeocodeUtil".split(" "),
function(u,e,k,d,l,f,v,w,x,y,m,z,A,n,p,B,C,q,r,t,D,g,E,F){return u([y,x,A],{templateString:E,polygonActive:!1,freehandPolygonActive:!1,postCreate:function(){this.inherited(arguments);var a=this;this.config.firstPageText=D.getInstance().sanitize(this.config.firstPageText);this.config.searchTextBoxOption?(this.search=(new z({map:this.map})).placeAt(this.searchContainer),this.search.activeSource.outFields.push("country"),this.own(f(this.search,"select-result",function(){a._loadSearchResult()}))):(d.remove(this.activatePinButton,
"esriBusinessAnalystButtonSearchPadding"),d.remove(this.activatePolygonButton,"esriBusinessAnalystButtonSearchPadding"),d.remove(this.activateFreehandPolygonButton,"esriBusinessAnalystButtonSearchPadding"));this.config.dropPinOption?this.own(f(this.activatePinButton,"click",function(){a._onActivatePinButtonClick()})):l.set(this.activatePinButton,"display","none");this.config.drawPolygonOption?this.own(f(this.activatePolygonButton,"click",function(){a._onActivatePolygonButtonClick()})):l.set(this.activatePolygonButton,
"display","none");this.config.drawFreehandPolygonOption?this.own(f(this.activateFreehandPolygonButton,"click",function(){a._onActivateFreehandPolygonButtonClick()})):l.set(this.activateFreehandPolygonButton,"display","none")},startup:function(){this.resize();this._started||d.add(this.layoutGrid.domNode,"business-analyst-search-suggestions-overflow")},_loadSearchResult:function(){this.wizard.selectedPoint.geometry=this.search.selectedResult.feature.geometry;this.wizard.selectedPoint.locationName=this.search.selectedResult.name;
var a=n.xyToLngLat(this.search.selectedResult.feature.geometry.x,this.search.selectedResult.feature.geometry.y);this.wizard.selectedPoint.long=a[0].toFixed(5);this.wizard.selectedPoint.lat=a[1].toFixed(5);this.wizard.setSelectedCountry(this.search.selectedResult.feature.attributes.country);this.onNext()},_onActivatePinButtonClick:function(){this._executeHandler?(this._deactivate(),this._deactivatePolygon(),this._deactivateFreehandPolygon()):(this._deactivatePolygon(),this._deactivateFreehandPolygon(),
this._setActive())},_setActive:function(){this._executeHandler||(d.add(this.activatePinButton,"esriBusinessAnalystPressedButton"),this.map.setInfoWindowOnClick(!1),this.map.setMapCursor("default"),this.map.disablePan(),this._executeHandler=f(this.map,"click",this._addPoint.bind(this)))},_deactivate:function(){this._executeHandler&&(d.remove(this.activatePinButton,"esriBusinessAnalystPressedButton"),this.map.setInfoWindowOnClick(!0),this.map.enablePan(),this._executeHandler.remove(),this._executeHandler=
null)},_addPoint:function(a){if(this._executeHandler){this._deactivate();var b=n.xyToLngLat(a.mapPoint.x,a.mapPoint.y),c=this;w(F.reverseGeocode({x:b[0],y:b[1]}),function(h){var G=new C("https://@sbaseurl@/jsapi/jsapi/esri/dijit/Search/images/search-pointer.png",36,36);c.wizard.selectedPoint.pointGraphic=new p(a.mapPoint,G);c.map.graphics.add(c.wizard.selectedPoint.pointGraphic);c.map.centerAndZoom(a.mapPoint,12);c.wizard.selectedPoint.geometry=a.mapPoint;c.wizard.selectedPoint.locationName=h&&h.address&&
h.address.LongLabel?h.address.LongLabel:"";c.wizard.setSelectedCountry(h.address.CountryCode);c.wizard.selectedPoint.long=b[0].toFixed(5);c.wizard.selectedPoint.lat=b[1].toFixed(5);c.onNext()})}},_onActivatePolygonButtonClick:function(){this.polygonActive?(this._deactivatePolygon(),this._deactivate(),this._deactivateFreehandPolygon()):(this._deactivate(),this._deactivateFreehandPolygon(),this._setActivePolygon())},_setActivePolygon:function(){this.polygonActive||(d.add(this.activatePolygonButton,
"esriBusinessAnalystPressedButton"),this.polygonActive=!0,this.toolbar||(this.toolbar=new t(this.map),this.toolbar.on("draw-end",k.hitch(this,this._addPolygon))),this.map.disablePan(),this.map.setInfoWindowOnClick(!1),this.toolbar.activate("polygon"))},_deactivatePolygon:function(){this.polygonActive&&(d.remove(this.activatePolygonButton,"esriBusinessAnalystPressedButton"),this.toolbar&&(this.toolbar.deactivate(),this.map.enablePan(),this.map.setInfoWindowOnClick(!0)),this.polygonActive=!1)},_onActivateFreehandPolygonButtonClick:function(){this.freehandPolygonActive?
(this._deactivateFreehandPolygon(),this._deactivate(),this._deactivatePolygon()):(this._deactivate(),this._deactivatePolygon(),this._setActiveFreehandPolygon())},_setActiveFreehandPolygon:function(){this.freehandPolygonActive||(d.add(this.activateFreehandPolygonButton,"esriBusinessAnalystPressedButton"),this.freehandPolygonActive=!0,this.toolbar||(this.toolbar=new t(this.map),this.toolbar.on("draw-end",k.hitch(this,this._addPolygon))),this.map.disablePan(),this.map.setInfoWindowOnClick(!1),this.toolbar.activate("freehandpolygon"))},
_deactivateFreehandPolygon:function(){this.freehandPolygonActive&&(d.remove(this.activateFreehandPolygonButton,"esriBusinessAnalystPressedButton"),this.toolbar&&(this.toolbar.deactivate(),this.map.enablePan(),this.map.setInfoWindowOnClick(!0)),this.freehandPolygonActive=!1)},_addPolygon:function(a){this._deactivate();this._deactivatePolygon();this._deactivateFreehandPolygon();var b=new q(q.STYLE_SOLID,new r(r.STYLE_SOLID,new m([199,55,36,1]),2),new m([199,55,36,.5]));a=new p(a.geometry,b);a.attributes=
{title:this.nls.customPolygon};b=new B;b.title="${title}";b.content=" ";b.info={};b.info.fieldInfos=[];a.setInfoTemplate(b);this.map.graphics.add(a);this.map.infoWindow.setFeatures([a]);this.map.infoWindow.show(this.map.toScreen(a.geometry.getExtent().getCenter()));this.map.infoWindow.removeActions("addMarker");this.wizard.drawnPolygonGraphic=a},resize:function(){this._resizeContentImg()},_resizeContentImg:function(){var a=document.activeElement;e.empty(this.contentContainer);var b=e.toDom(this.config.firstPageText);
e.place(b,this.contentContainer);this.contentContainer.nodeType&&1===this.contentContainer.nodeType&&((b=v("img",this.contentContainer))&&b.length&&b.forEach(k.hitch(this,function(c){"undefined"!==typeof c.complete&&!1===c.complete?this.own(f(c,"load",k.hitch(this,function(){this._resizeImg(c)}))):this._resizeImg(c)})),b=g.getFocusNodesInDom(this.domNode),b.length&&(g.initFirstFocusNode(this.domNode,b[0]),g.initLastFocusNode(this.domNode,b[b.length-1])),this.isOpen||e.isDescendant(a,this.domNode))&&
(a=g.getFirstFocusNode(this.domNode),g.isAutoFocusFirstNodeWidget(this)&&a.focus(),this.isOpen=!1)},_resizeImg:function(a){var b=e.getContentBox(this.contentContainer),c=e.getContentBox(a);c&&c.w&&c.w>=b.w&&e.setStyle(a,{maxWidth:b.w-20+"px",maxHeight:b.h-40+"px"})}})});