// 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
define("dojo/_base/declare dojo/_base/lang dojo/_base/html dojo/json dojo/on esri/layers/FeatureLayer esri/renderers/jsonUtils esri/symbols/jsonUtils ../BaseFeatureAction jimu/dijit/Popup jimu/dijit/Search jimu/LayerInfos/LayerInfos jimu/utils".split(" "),function(l,f,g,m,h,n,k,p,q,r,t,u,v){return l(q,{name:"CreateLayer",iconClass:"icon-create-layer",isFeatureSupported:function(c,a){return 0<c.features.length&&c.features[0].geometry&&a&&a.geometryType&&a.fields&&a.objectIdField},onExecute:function(c,
a){var b;c={layerDefinition:{geometryType:a.geometryType,fields:f.clone(a.fields),objectIdField:a.objectIdField},featureSet:c.toJson()};c=new n(c);(b=a._json?m.parse(a._json):null)&&b.drawingInfo&&b.drawingInfo.renderer?(b=b.drawingInfo.renderer,b=k.fromJson(b)):b=k.fromJson(a.renderer.toJson());c.setRenderer(b);(a=a.getSelectionSymbol())&&c.setSelectionSymbol(p.fromJson(a.toJson()));this._popupAddLayer(c)},_popupAddLayer:function(c){var a=g.create("div",{style:"padding: 0 10px 0 10px;"}),b=(new t({placeholder:window.jimuNls.layerInfosMenu.labelLayer})).placeAt(a);
g.setStyle(b.searchBtn,"display","none");var d=new r({content:a,titleLabel:window.jimuNls.featureActions.CreateLayer,width:525,height:180,buttons:[{label:window.jimuNls.common.ok,onClick:f.hitch(this,function(){c.name=v.stripHTML(b.getValue());this._addLayerToMap(c);d.close();e&&e.remove&&e.remove()})},{label:window.jimuNls.common.cancel,classNames:["jimu-btn-vacation"],onClick:f.hitch(this,function(){d.close();e&&e.remove&&e.remove()})}]});b.inputSearch.focus();d.disableButton(0);var e=h(b.inputSearch,
"keyup",function(){b.getValue()?d.enableButton(0):d.disableButton(0)})},_addLayerToMap:function(c){var a=u.getInstanceSync(),b=h(a,"layerInfosChanged",f.hitch(this,function(d){c.id===d.id&&(d.enablePopup(),b.remove())}));this.map.addLayer(c)}})});