text: // 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/SituationAwareness/setting/FieldPicker.html":'\x3cdiv class\x3d"field-picker-main"\x3e\r\n  \x3cdiv data-dojo-attach-point\x3d"tableArea" class\x3d"tableArea"\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"btnAddField" class\x3d"btn-add-section enable"\x3e\r\n      \x3cspan class\x3d"btn-add-icon"\x3e\x3c/span\x3e\r\n      \x3cspan class\x3d"btn-add-label" data-dojo-attach-point\x3d"divLayerTitle"\x3e${nls.addField}\x3c/span\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"fieldTable"\x3e\x3c/div\x3e\r\n  \x3c/div\x3e\r\n  \x3cdiv class\x3d"jimu-r-row pad-top20" data-dojo-attach-point\x3d"chk_countOnly"\x3e\r\n    \x3cdiv class\x3d"col-1-3" data-dojo-attach-point\x3d"div_chkCount"\x3e\r\n      \x3cinput data-dojo-attach-point\x3d"chk_count_only" title\x3d"${nls.count_checkBox}"\r\n             data-dojo-attach-event\x3d"onChange:chkCountChanged" data-dojo-type\x3d"dijit/form/CheckBox" /\x3e\r\n      \x3cspan class\x3d"label"\x3e${nls.count_checkBox}\x3c/span\x3e\r\n    \x3c/div\x3e\r\n  \x3c/div\x3e\r\n  \x3cdiv class\x3d"jimu-r-row pad-top20" data-dojo-attach-point\x3d"chk_summary"\x3e\r\n    \x3cdiv class\x3d"col-1-3" data-dojo-attach-point\x3d"div_chkCount"\x3e\r\n      \x3cinput data-dojo-attach-point\x3d"chk_count" title\x3d"${nls.count_checkBox}" \r\n             data-dojo-attach-event\x3d"onChange:chkCountChanged" data-dojo-type\x3d"dijit/form/CheckBox" /\x3e\r\n      \x3cspan class\x3d"label"\x3e${nls.count_checkBox}\x3c/span\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv class\x3d"col-1-3" data-dojo-attach-point\x3d"div_chkArea"\x3e\r\n      \x3cinput data-dojo-attach-point\x3d"chk_area" title\x3d"${nls.area_checkBox}" \r\n             data-dojo-attach-event\x3d"onChange:chkAreaChanged" data-dojo-type\x3d"dijit/form/CheckBox" /\x3e\r\n      \x3cspan class\x3d"label"\x3e${nls.area_checkBox}\x3c/span\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv class\x3d"col-1-3" data-dojo-attach-point\x3d"div_chkLength"\x3e\r\n      \x3cinput data-dojo-attach-point\x3d"chk_length" title\x3d"${nls.length_checkBox}" \r\n             data-dojo-attach-event\x3d"onChange:chkLengthChanged" data-dojo-type\x3d"dijit/form/CheckBox" /\x3e\r\n      \x3cspan class\x3d"label"\x3e${nls.length_checkBox}\x3c/span\x3e\r\n    \x3c/div\x3e\r\n  \x3c/div\x3e\r\n  \x3cdiv class\x3d"jimu-r-row pad-top20" data-dojo-attach-point\x3d"chk_summaryLabels"\x3e\r\n    \x3cdiv class\x3d"col-1-3" data-dojo-attach-point\x3d"div_chkCountLabel"\x3e\r\n      \x3cspan class\x3d"label"\x3e ${nls.count_label}:\x3c/span\x3e\r\n      \x3cinput class\x3d"validationBox" data-dojo-attach-point\x3d"featureCountLabel" data-dojo-type\x3d"dijit/form/ValidationTextBox"\r\n             disabled\x3d"disabled" title\x3d"${nls.count_label}" /\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv class\x3d"col-1-3" data-dojo-attach-point\x3d"div_chkAreaLabel"\x3e\r\n      \x3cspan class\x3d"label"\x3e ${nls.area_label}:\x3c/span\x3e\r\n      \x3cinput class\x3d"validationBox" data-dojo-attach-point\x3d"featureAreaLabel" data-dojo-type\x3d"dijit/form/ValidationTextBox"\r\n             disabled\x3d"disabled" title\x3d"${nls.area_label}" /\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv class\x3d"col-1-3" data-dojo-attach-point\x3d"div_chkLengthLabel"\x3e\r\n      \x3cspan class\x3d"label"\x3e ${nls.length_label}:\x3c/span\x3e\r\n      \x3cinput class\x3d"validationBox" data-dojo-attach-point\x3d"featureLengthLabel" data-dojo-type\x3d"dijit/form/ValidationTextBox"\r\n             disabled\x3d"disabled" title\x3d"${nls.length_label}" /\x3e\r\n    \x3c/div\x3e\r\n  \x3c/div\x3e\r\n  \x3cdiv class\x3d"field-picker-footer"\x3e\r\n    \x3cdiv class\x3d"jimu-btn ok" data-dojo-attach-point\x3d"btnOk"\x3e\x3c/div\x3e\r\n    \x3cdiv class\x3d"jimu-btn cancel" data-dojo-attach-point\x3d"btnCancel"\x3e\x3c/div\x3e\r\n  \x3c/div\x3e\r\n\x3c/div\x3e\r\n'}});
  define("dojo/_base/declare dijit/_WidgetsInTemplateMixin dijit/form/Select dijit/form/ValidationTextBox dijit/registry dojo/dom-construct dojo/_base/array dojo/_base/lang dojo/_base/html dojo/dom-style dojo/dom-class dojo/Deferred dojo/on dojo/query jimu/BaseWidget jimu/dijit/Message jimu/utils esri/layers/FeatureLayer dojo/text!./FieldPicker.html dojo/Evented jimu/dijit/SimpleTable".split(" "),function(y,z,v,A,q,w,n,e,h,k,t,x,p,g,B,C,r,D,E,F,G){return y([B,z,F],{templateString:E,baseClass:"jimu-widget-SAT-setting",
  advStat:{},fieldsList:null,callerLayer:null,callerTab:null,callerOpLayers:null,layerList:null,test:!1,fields:null,hasFields:!0,constructor:function(a){this.map=a.map;a.test&&(this.test=a.test)},postMixInProperties:function(){this.inherited(arguments);this.nls.common=window.jimuNls.common},postCreate:function(){this.inherited(arguments);this.startup()},startup:function(){var a=null;this.test||(a="summary"===this.callerTab.type?[{name:"layer",title:this.nls.fieldTitle,"class":"label",type:"empty",width:"250px"},
  {name:"label",title:this.nls.layerLabel,"class":"label",type:"empty",width:"200px"},{name:"type",title:this.nls.typeTitle,"class":"sumlabel",type:"empty"},{name:"actions",title:this.nls.actionsTitle,"class":"actions",type:"actions",actions:["up","down","delete"]}]:"groupedSummary"===this.callerTab.type?[{name:"layer",title:this.nls.groupByField,"class":"label",type:"empty",width:"40%"},{name:"label",title:this.nls.layerLabel,"class":"label",type:"empty",width:"20%"},{name:"type",title:this.nls.labelType,
  "class":"label",type:"empty",width:"20%"}]:[{name:"layer",title:this.nls.fieldTitle,"class":"label",type:"empty",width:"60%"},{name:"actions",title:this.nls.actionsTitle,"class":"actions",type:"actions",actions:["up","down","delete"],width:"40%"}],this.displayFieldsTable=new G({fields:a}),this.displayFieldsTable.placeAt(this.fieldTable),h.setStyle(this.displayFieldsTable.domNode,{height:"100%"}),this.displayFieldsTable.startup(),this.operationsList=[],"summary"===this.callerTab.type?this.operationsList.push({value:"sum",
  label:this.nls.sum},{value:"avg",label:this.nls.avg},{value:"min",label:this.nls.min},{value:"max",label:this.nls.max}):"groupedSummary"===this.callerTab.type&&this.operationsList.push({value:"pre",label:this.nls.prefix},{value:"suf",label:this.nls.suffix}),"summary"===this.callerTab.type?(k.set(this.chk_summary,"display","block"),k.set(this.chk_summaryLabels,"display","block"),k.set(this.chk_countOnly,"display","none")):(k.set(this.chk_countOnly,"display","block"),k.set(this.chk_summary,"display",
  "none"),k.set(this.chk_summaryLabels,"display","none")),this.btnCancel.innerText=this.nls.common.cancel,this.own(p(this.btnCancel,"click",e.hitch(this,function(){this.emit("cancel")}))),this.btnOk.innerText=this.nls.common.ok,this.own(p(this.btnOk,"click",e.hitch(this,function(){if(!t.contains(this.btnOk,"jimu-state-disabled")){this.updateSummaryType();var a=!1,b;for(b in this.advStat.stats)this.advStat.stats.hasOwnProperty(b)&&(a=!0);a||(this.advStat=null);this.emit("ok",this.advStat)}}))),this.layerTables=
  [],this.summaryLayers=[],this.advStat={},this._getAllValidLayers().then(e.hitch(this,function(){"groupedSummary"===this.callerTab.type?(k.set(this.btnAddField,"display","none"),this.hasFields&&this._addTabRow()):this.hasFields&&(this.addHandler=this.own(p(this.btnAddField,"click",e.hitch(this,this._addTabRow))),this.own(p(this.displayFieldsTable,"row-delete",e.hitch(this,this._rowDeleted))))})))},_updateGeomOptions:function(a){a&&(this.chk_area.set("disabled","esriGeometryPolygon"!==a),this.chk_length.set("disabled",
  "esriGeometryPolyline"!==a))},_getAllValidLayers:function(a){var c=new x;n.forEach(this.callerOpLayers,e.hitch(this,function(b){0<b.newSubLayers.length?this._recurseOpLayers(b.newSubLayers):b.id===this.callerLayer&&(this.layerList=b)}));if(this.layerList.layerObject.empty){if(this.layerList.layerObject.url){var b=new D(this.layerList.layerObject.url);p(b,"load",e.hitch(this,function(){this._completeMapLayers(b,a);c.resolve("sucess")}))}}else this._completeMapLayers(this.layerList,a),c.resolve("sucess");
  return c},_recurseOpLayers:function(a){n.forEach(a,e.hitch(this,function(a){0<a.newSubLayers.length?this._recurseOpLayers(a.newSubLayers):a.id===this.callerLayer&&(this.layerList=a)}))},_completeMapLayers:function(a,c){if(a){var b="undefined"===typeof a.layerObject?a:a.layerObject,d=b.geometryType;this.objectIdField=b.objectIdField;var f={url:b.url,stats:{}},l=e.clone(b.fields),k=this.getSkipFields(b),g=[];n.forEach(l,function(b){-1===k.indexOf(b.name)&&g.push(b)});this.fields=g;this.popUpFields=
  this._getPopupFields(b);this.advStat=f;if("undefined"===typeof c){this._updateGeomOptions(d);if(this.advStat.url){if("undefined"!==typeof this.callerTab.advStat&&this.callerTab.advStat){this.callerTab.advStat.stats?this._setFields(g):this._setFields(g,!0);var b=this.callerTab.advStat.stats,m;for(m in b)"count"===m?(this.chk_count.set("value",!0),this.featureCountLabel.set("value",b[m][0].label)):"area"===m?(this.chk_area.set("value",!0),this.featureAreaLabel.set("value",b[m][0].label)):"length"===
  m?(this.chk_length.set("value",!0),this.featureLengthLabel.set("value",b[m][0].label)):"tabCount"===m?this.chk_count_only.set("value",b[m]):n.forEach(b[m],e.hitch(this,function(b){this._populateTabTableRow(m,b)}))}else this._setFields(g,!0);b=this.callerTab.advStat;if(!b||"undefined"!==typeof b&&!b.hasOwnProperty("stats"))if(b=0<this.popUpFields.length,d=this.fieldsList.length,"groupedSummary"===this.callerTab.type&&(d=1,b||this._setFields(g)),0<d){var f="summary"===this.callerTab.type?21:4,h=l=0;
  a:for(;h<d;h++){var p=!1,q=this.fieldsList[h];if(b){var r=this.popUpFields[h],u=0;b:for(;u<this.fieldsList.length;u++)if(q=this.fieldsList[u],q.value===r){p=!0;break b}}if(p)if(l+=1,l<f)this._addTabRow(q);else break a}}else t.add(this.btnAddField,"btn-add-disabled"),this.hasFields=!1}("groupedSummary"===this.callerTab.type&&0<this.popUpFields.length||"groupedSummary"!==this.callerTab.type)&&this._setFields(g)}}},_validatePopupFields:function(){var a=new x;this._getAllValidLayers(!0).then(e.hitch(this,
  function(){for(var c=[],b=0;b<this.popUpFields.length;b++){var d=this.popUpFields[b],f=0;a:for(;f<this.fields.length;f++){var l=this.fields[f];if(d===l.name){c.push(l);break a}}}this.callerTab.type="summary";this._setFields(c);b=0<this.fieldsList.length;this._setFields(this.fields);a.resolve({layer:this.callerLayer,hasPopupFields:0<c.length,hasFields:0<this.fields.length,hasSummaryPopupFields:b,hasSummaryFields:0<this.fieldsList.length,popUpFields:c,validSummaryFields:this.fieldsList,advStat:this.advStat})}));
  return a},_getPopupFields:function(a){var c=this.getSkipFields(a),b,d=[];this.objectIdField=a.objectIdField;if(a.infoTemplate)b=a.infoTemplate.info.fieldInfos;else if(a.url&&-1<a.url.indexOf("MapServer")){a=a.url.split("MapServer/")[1];var f=this.map.itemInfo.itemData.operationalLayers;b=null;for(var l=0;l<f.length;l++){var e=f[l];if(e.layerObject&&e.layerObject.infoTemplates&&(e=e.layerObject.infoTemplates[a])){b=e.infoTemplate.info.fieldInfos;break}}}if(b)for(a=0;a<b.length;a++)(f=b[a])&&f.visible&&
  -1===c.indexOf(f.fieldName)&&d.push(f.fieldName);return d},checkStringWidth:function(a){var c=w.create("div",{"class":"visDivLength",id:"SA_VisDiv",innerHTML:a},this.domNode);a=220>c.clientWidth?!0:!1;w.destroy(c);var b=a,d=q.byNode(this.domNode).id;g(".validationBox").forEach(function(a){a=q.byNode(a);d!==a.id&&(b=b?"Error"!==a.state:b)});(c=g(".field-picker-footer")[0])&&(b?h.removeClass(c.children[0],"jimu-state-disabled"):h.addClass(c.children[0],"jimu-state-disabled"));return a},_setFields:function(a,
  c){var b=["esriFieldTypeInteger","esriFieldTypeSmallInteger","esriFieldTypeDouble"];"summary"!==this.callerTab.type&&(b.push("esriFieldTypeString"),b.push("esriFieldTypeDate"));var d=[],f=[];n.forEach(a,e.hitch(this,function(a){-1<b.indexOf(a.type)&&(c&&this.popUpFields&&-1<this.popUpFields.indexOf(a.name)&&f.push(a.name),d.push({label:a.alias,value:a.name}))}));1>d.length?(t.add(this.btnAddField,"btn-add-disabled"),this.hasFields=!1):this.test||(k.set(this.displayFieldsTable.domNode,"display","block"),
  k.set(this.btnAddField,"display","inline-block"));f.length!==this.popUpFields.length&&(this.popUpFields=f);this.fieldsList=e.clone(d)},_populateTabTableRow:function(a,c){var b=this.displayFieldsTable.addRow({});b.success&&b.tr&&(b=b.tr,this._addTabFields(b),this._addTabTypes(b),this._addTabLabel(b),b.selectFields.set("value",c.expression),"summary"===this.callerTab.type||"groupedSummary"===this.callerTab.type)&&(b.labelText.set("value",c.label),b.selectTypes.set("value",a))},_addTabRow:function(a){var c=
  this.displayFieldsTable.getRows().length;"summary"!==this.callerTab.type&&3<=c?new C({message:this.nls.max_records}):"groupedSummary"===this.callerTab.type&&0<c||(c=this.displayFieldsTable.addRow({}),c.success&&c.tr&&(c=c.tr,this._addTabFields(c),this._addTabTypes(c),this._addTabLabel(c),a&&c.selectFields.set("value",a.value),this._enableOk()))},_addTabFields:function(a){var c=e.clone(this.fieldsList),b=g(".simple-table-cell",a)[0];b&&(c=new v({style:{height:"24px",width:"100%"},"class":"summary"===
  this.callerTab.type?"shortSelect":"longSelect",options:c}),c.placeAt(b),c.startup(),a.selectFields=c)},_addTabLabel:function(a){if("summary"===this.callerTab.type||"groupedSummary"===this.callerTab.type){var c=g(".simple-table-cell",a)[1],b=new A({style:{width:"100%",height:"24px"},"class":"validationBox"});b.invalidMessage=this.nls.invalid_string_width;b.placeAt(c);b.startup();b.validator=this.checkStringWidth;a.labelText=b}},_addTabTypes:function(a){if("summary"===this.callerTab.type||"groupedSummary"===
  this.callerTab.type){var c=e.clone(this.operationsList),b=g(".simple-table-cell",a)[2];b&&(c=new v({style:{width:"100%",height:"24px"},options:c}),c.placeAt(b),c.startup(),a.selectTypes=c)}},getSkipFields:function(a){var c=[];if(a.fields)for(var b=0;b<a.fields.length;b++){var d=a.fields[b];d&&d.type&&d.name&&"esriFieldTypeGeometry"===d.type&&c.push(d.name)}a.globalIdField&&""!==a.globalIdField&&c.push(a.globalIdField);a.objectIdField&&""!==a.objectIdField&&c.push(a.objectIdField);return c},getDefaultFields:function(a,
  c,b){var d={stats:{fields:[],tabCount:!1}};if("summary"!==b&&"groupedSummary"!==b){c=[];for(b=0;b<(3>a.length?a.length:3);b++){var f=a[b];c.push({value:0,expression:f.name,label:f.alias})}0<c.length&&(d.stats.outFields=c)}else"summary"===b&&c&&c.hasOwnProperty("length")&&0<c.length&&(d.stats.sum=[],n.forEach(c,e.hitch(this,function(a){d.stats.sum.push({value:0,expression:a.name||a.value,label:a.alias?a.alias:a.label?a.label:a.name||a.value})})));return d},updateSummaryType:function(){var a=this.displayFieldsTable.getRows();
  if("summary"!==this.callerTab.type&&"groupedSummary"!==this.callerTab.type){var c=[];n.forEach(a,function(a){c.push({value:0,expression:a.selectFields.value,label:a.selectFields.value})});0<c.length&&(this.advStat.stats.outFields=c);this.advStat.stats.tabCount=this.chk_count_only.checked}else this.advStat.stats.tabCount="groupedSummary"===this.callerTab.type?this.chk_count_only.checked:this.chk_count.checked,this.chk_count.checked&&(this.advStat.stats.count=[{value:0,expression:this.objectIdField,
  label:r.stripHTML(this.featureCountLabel.value?this.featureCountLabel.value:this.nls.count)}]),this.chk_area.checked&&(this.advStat.stats.area=[{value:0,expression:this.objectIdField,label:r.stripHTML(this.featureAreaLabel.value?this.featureAreaLabel.value:this.nls.area)}]),this.chk_length.checked&&(this.advStat.stats.length=[{value:0,expression:this.objectIdField,label:r.stripHTML(this.featureLengthLabel.value?this.featureLengthLabel.value:this.nls.length)}]),n.forEach(a,e.hitch(this,function(a){"undefined"===
  typeof this.advStat.stats[a.selectTypes.value]&&(this.advStat.stats[a.selectTypes.value]=[]);var b={value:0};b.expression=a.selectFields.value;for(var c=0;c<a.selectFields.options.length;c++)if(a.selectFields.options[c].value===a.selectFields.value){b.label="groupedSummary"!==this.callerTab.type?a.labelText.value?a.labelText.value:a.selectFields.options[c].label:a.labelText.value;break}"undefined"===typeof b.label&&(b.label=b.expression);this.advStat.stats[a.selectTypes.value].push(b)}));console.log("ADVSTAT",
  this.advStat)},chkCountChanged:function(a){"summary"===this.callerTab.type&&(this.updateLabel(this.featureCountLabel,a),a?this._enableOk():0===this.displayFieldsTable.getRows().length?this._disableOk():this._enableOk())},chkAreaChanged:function(a){this.updateLabel(this.featureAreaLabel,a)},chkLengthChanged:function(a){this.updateLabel(this.featureLengthLabel,a)},updateLabel:function(a,c){a.set("disabled",!c);a.validator=this.checkStringWidth;a.invalidMessage=this.nls.invalid_string_width;if(c&&""===
  a.value){var b="";a.id===this.featureCountLabel.id?b=this.nls.count:a.id===this.featureAreaLabel.id?b=this.nls.area:a.id===this.featureLengthLabel.id&&(b=this.nls.length);a.set("value",b)}this.validateAll()},validateAll:function(){var a=!0;g(".validationBox").forEach(function(b){b=q.byNode(b);a=a?"Error"!==b.state:a});var c=g(".field-picker-footer")[0];c&&(a?h.removeClass(c.children[0],"jimu-state-disabled"):h.addClass(c.children[0],"jimu-state-disabled"))},_rowDeleted:function(){this.validateAll();
  0===this.displayFieldsTable.getRows().length?"summary"===this.callerTab.type&&this.chk_count.checked?this._enableOk():this._disableOk():this._enableOk()},_disableOk:function(){var a=g(".field-picker-footer")[0];a&&h.addClass(a.children[0],"jimu-state-disabled")},_enableOk:function(){var a=g(".field-picker-footer")[0];a&&h.removeClass(a.children[0],"jimu-state-disabled")},destroy:function(){this.advStat=null}})});