// 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/DistrictLookup/setting/LayerChooser.html":'\x3cdiv style\x3d"width: 100%; height: 100%;"\x3e\r\n    \x3cdiv class\x3d"esriCTLayerSelectorDiv"\x3e\r\n        \x3cdiv class\x3d"esriCTLayerChooserContainer row"\x3e\r\n            \x3cdiv class\x3d"esriCTlabel esriCTLabelContainer esriCTLayerChooserLabel" title\x3d"${nls.layerSelector.selectPolygonLayerLabel}"\x3e\r\n                ${nls.layerSelector.selectPolygonLayerLabel}\r\n            \x3c/div\x3e\r\n            \x3cdiv class\x3d"esriCTLayerChooserField"\x3e\r\n                \x3cdiv data-dojo-attach-point\x3d"itemSelectDiv"\x3e\r\n                \x3c/div\x3e\r\n                \x3cdiv class\x3d"esriCTHint"\x3e\r\n                    ${nls.layerSelector.selectPolygonLayerHintText}\r\n                \x3c/div\x3e\r\n            \x3c/div\x3e\r\n        \x3c/div\x3e\r\n        \x3cdiv class\x3d"esriCTLayerChooserContainer row"\x3e\r\n            \x3cdiv class\x3d"esriCTlabel esriCTLabelContainer esriCTLayerChooserLabel" title\x3d"${nls.layerSelector.selectRelatedPointLayerLabel}"\x3e\r\n                ${nls.layerSelector.selectRelatedPointLayerLabel}\r\n            \x3c/div\x3e\r\n            \x3cdiv class\x3d"esriCTLayerChooserField"\x3e\r\n                \x3cselect data-dojo-attach-point\x3d"relationshipSelect" style\x3d"width: 232px;" data-dojo-type\x3d"dijit/form/Select"\x3e\r\n                \x3c/select\x3e\r\n                \x3cdiv class\x3d"esriCTHint"\x3e\r\n                    ${nls.layerSelector.selectRelatedPointLayerHintText}\r\n                \x3c/div\x3e\r\n            \x3c/div\x3e\r\n        \x3c/div\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"buttonsDiv" class\x3d"buttonsDiv"\x3e\r\n        \x3cdiv class\x3d"button-container button-container-absolute" style\x3d"padding: 0px;"\x3e\r\n            \x3cdiv class\x3d"jimu-btn jimu-float-trailing jimu-leading-margin1 jimu-state-disabled"\r\n                data-dojo-attach-point\x3d"okButton" tabindex\x3d"0"\x3e\r\n                ${nls.common.ok}\x3c/div\x3e\r\n            \x3cdiv class\x3d"jimu-btn jimu-float-trailing jimu-leading-margin1" data-dojo-attach-point\x3d"cancelButton" tabindex\x3d"0"\x3e\r\n                ${nls.common.cancel}\x3c/div\x3e\r\n        \x3c/div\x3e\r\n    \x3c/div\x3e\r\n\x3c/div\x3e\r\n'}});
define("dojo/_base/declare jimu/BaseWidgetSetting dijit/_WidgetsInTemplateMixin dojo/_base/lang dojo/_base/array dojo/promise/all dojo/Deferred dojo/on dojo/dom-class dojo/text!./LayerChooser.html jimu/dijit/LayerChooserFromMap jimu/dijit/LayerChooserFromMapWithDropbox esri/request jimu/dijit/LoadingIndicator jimu/dijit/Message dojo/domReady!".split(" "),function(n,p,q,e,r,t,u,l,b,v,h,w,x,y,z){return n([p,q],{baseClass:"jimu-widget-districtlookup-setting",templateString:v,selectRouteURL:null,agolFlag:!1,
serviceFlag:!1,startup:function(){this.inherited(arguments)},postCreate:function(){this._createPrecinctChooserArgs();this.own(l(this.cancelButton,"click",e.hitch(this,function(a){this.onCancleClick(a)})));this.own(l(this.okButton,"click",e.hitch(this,this._onOKButtonClicked)));this._initLoading()},_onNextButtonClicked:function(){b.contains(this.btnNext,"jimu-state-disabled")||(b.add(this.itemSelectDiv,"esriCTHidden"),b.remove(this.relatedLayerSelectDiv,"esriCTHidden"),b.add(this.btnNext,"esriCTHidden"),
b.remove(this.btnBack,"esriCTHidden"),""===this.relationshipSelect.value?(this._errorMessage(this.nls.layerSelector.polygonLayerNotHavingRelatedLayer),b.add(this.okButton,"jimu-state-disabled")):b.remove(this.okButton,"jimu-state-disabled"))},_onOKButtonClicked:function(){if(!b.contains(this.okButton,"jimu-state-disabled"))if(this.precinctLayerInfo){if(""===this.relationshipSelect.value)return this._errorMessage(this.nls.layerSelector.errorInSelectingRelatedLayer),!1;var a={polygonLayerInfo:this.precinctLayerInfo,
relatedLayerInfo:this.pollingPlaceInfo[this.relationshipSelect.value]};this.onOkClick(a)}else return this._errorMessage(this.nls.layerSelector.errorInSelectingPolygonLayer),!1},_createPrecinctChooserArgs:function(){var a=h.createFeaturelayerFilter(["polygon"],!1);var d=h.createQueryableLayerFilter();a={multiple:!1,createMapResponse:this.map.webMapResponse,showLayerTypes:["FeatureLayer"],filter:h.andCombineFilters([a,d])};a=new h(a);a=new w({layerChooser:a});a.placeAt(this.itemSelectDiv);a.startup();
this.own(l(a,"selection-change",e.hitch(this,this._createPollingPlaceLayerOptions)))},_initLoading:function(){this.loading=new y({hidden:!0});this.loading.placeAt(this.domNode);this.loading.startup()},onOkClick:function(a){return a},onCancleClick:function(a){return a},_createPollingPlaceLayerOptions:function(a){var d=[];if(a&&0<a.length){this.precinctLayer=a[0];this.precinctLayerInfo={url:this.precinctLayer.url,geometryType:"esriGeometryPolygon",id:a[0].id};this.precinctLayerInfo.layerId=this.precinctLayer.layerId?
this.precinctLayer.layerId:this.precinctLayer.url.substr(this.precinctLayer.url.lastIndexOf("/")+1,this.precinctLayer.url.length);var k=this.precinctLayer.url.substr(0,this.precinctLayer.url.lastIndexOf("/")+1);this.precinctLayerInfo.baseURL=k;this.pollingPlaceInfo=[];var m=[];r.forEach(this.precinctLayer.relationships,e.hitch(this,function(f){var g=new u;m.push(g);x({url:k+f.relatedTableId,content:{f:"json"},handleAs:"json"}).then(e.hitch(this,function(c){g.resolve(c)}),e.hitch(this,function(){g.resolve()}))}));
t(m).then(e.hitch(this,function(f){for(var g,c=0;c<f.length;c++)f[c]&&"esriGeometryPoint"===f[c].geometryType&&(g={url:k+f[c].id,baseURL:k,relationShipId:this.precinctLayer.relationships[c].id,layerId:f[c].id,geometryType:"esriGeometryPoint",title:f[c].name},g.title&&(this.pollingPlaceInfo[d.length]=g,d.push({label:this.pollingPlaceInfo[d.length].title,value:d.length})));0<d.length?(this.relationshipSelect.options.length=0,d[0].selected=!0,this.relationshipSelect.addOption(d),b.remove(this.okButton,
"jimu-state-disabled")):this._resetRelatedLayerSelector()}),e.hitch(this,function(){this._resetRelatedLayerSelector()}))}else this._resetRelatedLayerSelector()},_resetRelatedLayerSelector:function(){this.relationshipSelect.value="";this.relationshipSelect.options.length=0;this.relationshipSelect.addOption({value:"",label:"",selected:!0});b.add(this.okButton,"jimu-state-disabled");this._errorMessage(this.nls.layerSelector.polygonLayerNotHavingRelatedLayer)},_onBtnBackClicked:function(){b.remove(this.itemSelectDiv,
"esriCTHidden");b.add(this.relatedLayerSelectDiv,"esriCTHidden");b.remove(this.btnNext,"esriCTHidden");b.add(this.btnBack,"esriCTHidden")},_errorMessage:function(a){(new z({message:a})).message=a}})});