// 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/SmartEditor/fieldMap.html":'\x3cdiv class\x3d"esriCTParentNode esriCTBottomSpacing"\x3e\r\n  \x3cdiv class\x3d"esriCTHeader" data-dojo-attach-point\x3d"headerNode"\x3e\r\n  \x3c/div\x3e\r\n  \x3cdiv class\x3d"esriCTFiledsContainer esriCTHidden" data-dojo-attach-point\x3d"fieldsNode"\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"fieldMappingTableWrapper"\x3e\r\n      \x3ctable class\x3d"esriCTFieldsMatchingTable" cellspacing\x3d"5"\x3e\r\n        \x3cthead\x3e\r\n          \x3ctr class\x3d"esriCTFieldsMatchingTableRow"\x3e\r\n            \x3cth class\x3d"esriCTFieldsMatchingTableCell"\x3e${nls.fieldsMapping.fieldsInTargetLayerLabel}\x3c/th\x3e\r\n            \x3cth class\x3d"esriCTFieldsMatchingTableCell"\x3e${nls.fieldsMapping.fieldsInSourceLayerLabel}\x3c/th\x3e\r\n          \x3c/tr\x3e\r\n        \x3c/thead\x3e\r\n        \x3ctbody class\x3d"esriCTFieldsMatchingTableRow" data-dojo-attach-point\x3d"fieldsTbodyNode"\x3e\r\n        \x3c/tbody\x3e\r\n      \x3c/table\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv class\x3d"noFieldsMatching" data-dojo-attach-point\x3d"noFieldsMatching"\x3e\r\n      \x3cspan tabindex\x3d"0" role\x3d"presentation"\x3e${nls.fieldsMapping.noFieldsToMatchLabel}\x3c/span\x3e\r\n    \x3c/div\x3e\r\n  \x3c/div\x3e\r\n\x3c/div\x3e'}});
define("dojo/_base/declare dojo/Evented dojo/_base/lang dojo/text!./fieldMap.html dijit/_WidgetsInTemplateMixin jimu/BaseWidgetSetting dojo/dom-construct dojo/_base/array dojo/string dojo/on dojo/dom-class dojo/dom-style dojo/dom-attr dijit/form/TextBox dojo/keys dijit/form/Select".split(" "),function(v,w,f,x,y,z,k,q,r,l,g,t,m,u,p,A){return v([z,w,y],{baseClass:"jimu-widget-smartEditor-fieldsMapping",ValidFieldsByType:{esriFieldTypeOID:["esriFieldTypeSmallInteger","esriFieldTypeInteger","esriFieldTypeSingle",
"esriFieldTypeDouble"],esriFieldTypeSmallInteger:["esriFieldTypeOID","esriFieldTypeSmallInteger","esriFieldTypeInteger","esriFieldTypeSingle","esriFieldTypeDouble"],esriFieldTypeInteger:["esriFieldTypeOID","esriFieldTypeSmallInteger","esriFieldTypeInteger","esriFieldTypeSingle","esriFieldTypeDouble"],esriFieldTypeDouble:["esriFieldTypeOID","esriFieldTypeSmallInteger","esriFieldTypeInteger","esriFieldTypeSingle","esriFieldTypeDouble"],esriFieldTypeSingle:["esriFieldTypeOID","esriFieldTypeSmallInteger",
"esriFieldTypeInteger","esriFieldTypeSingle","esriFieldTypeDouble"],esriFieldTypeGUID:["esriFieldTypeGUID","esriFieldTypeGlobalID"],esriFieldTypeDate:["esriFieldTypeDate"],esriFieldTypeString:"esriFieldTypeSmallInteger esriFieldTypeInteger esriFieldTypeSingle esriFieldTypeDouble esriFieldTypeString esriFieldTypeGUID esriFieldTypeDate esriFieldTypeOID esriFieldTypeGlobalID".split(" ")},templateString:x,sourceLayerDetails:[],targetLayerDetails:{},mappedTargetFields:{},postCreate:function(){this.mappedTargetFields=
{};this._createFieldMap(this.sourceLayerDetails,this.targetLayerDetails);this.openOnLoad&&this.expandIconNode.click();this._setLabelWidth(window.appInfo.isRunInMobile?500:"");this.own(l(window,"resize",f.hitch(this,function(){this._setLabelWidth(500)})))},_setLabelWidth:function(a){setTimeout(f.hitch(this,function(){for(var b in this.mappedTargetFields)if(this.mappedTargetFields[b]&&this.mappedTargetFields[b].domNode&&this.mappedTargetFields[b].containerNode){var d=this.mappedTargetFields[b].containerNode.children[0];
d&&t.set(d,"width",this.mappedTargetFields[b].domNode.parentElement.clientWidth-50+"px")}}),a?a:1)},_expandCollapse:function(){g.contains(this.fieldsNode,"esriCTHidden")?(g.replace(this.expandIconNode,"esriCTArrowDown","esriCTArrowUp"),g.remove(this.fieldsNode,"esriCTHidden"),g.remove(this.iconParentNode,"esriCTHidden"),g.add(this.layerNameNode,"esriCTLayerNameWidthReduced"),m.set(this.expandIconNode,"aria-expanded","true"),this._setLabelWidth()):(g.replace(this.expandIconNode,"esriCTArrowUp","esriCTArrowDown"),
g.add(this.fieldsNode,"esriCTHidden"),g.add(this.iconParentNode,"esriCTHidden"),g.remove(this.layerNameNode,"esriCTLayerNameWidthReduced"),m.set(this.expandIconNode,"aria-expanded","false"))},_resetSourceFields:function(){if(this.mappedTargetFields)for(var a in this.mappedTargetFields){var b=this.mappedTargetFields[a];if(!b.get("disabled")){for(var d=!1,c=0;c<b.options.length;c++)if(b.options[c].isDefault){b.set("value",b.options[c].value);d=!0;break}d||b.set("value","esriCTSelectSourceLayerField")}}this._setLabelWidth()},
_clearSourceFields:function(){if(this.mappedTargetFields)for(var a in this.mappedTargetFields)this.mappedTargetFields[a].get("disabled")||this.mappedTargetFields[a].set("value","esriCTSelectSourceLayerField");this._setLabelWidth()},_createFieldMap:function(a,b){this.expandIconNode=k.create("div",{"class":"esriCTArrow esriCTArrowUp",role:"button",tabindex:"0",title:a.name,"aria-label":a.name,"aria-expanded":"false"},this.headerNode);this.layerNameNode=k.create("div",{"class":"esriCTLayerName",innerHTML:a.name},
this.headerNode);this.iconParentNode=k.create("div",{"class":"esriCTIconParentNode esriCTHidden"},this.headerNode);this.resetButtonNode=k.create("div",{"class":"esriCTResetButton",role:"button",tabindex:"0",title:this.nls.fieldsMapping.resetLabel,"aria-label":this.nls.fieldsMapping.resetLabel},this.iconParentNode);this.clearButtonNode=k.create("div",{"class":"esriCTClearButton",role:"button",tabindex:"0",title:this.nls.fieldsMapping.clearLabel,"aria-label":this.nls.fieldsMapping.clearLabel},this.iconParentNode);
this.own(l(this.layerNameNode,"click",f.hitch(this,this._expandCollapse)));this.own(l(this.expandIconNode,"click",f.hitch(this,this._expandCollapse)));this.own(l(this.expandIconNode,"keydown",f.hitch(this,function(c){c.keyCode!==p.ENTER&&c.keyCode!==p.SPACE||this._expandCollapse()})));this.own(l(this.clearButtonNode,"click",f.hitch(this,this._clearSourceFields)));this.own(l(this.clearButtonNode,"keydown",f.hitch(this,function(c){c.keyCode!==p.ENTER&&c.keyCode!==p.SPACE||this._clearSourceFields()})));
this.own(l(this.resetButtonNode,"click",f.hitch(this,this._resetSourceFields)));this.own(l(this.resetButtonNode,"keydown",f.hitch(this,function(c){c.keyCode!==p.ENTER&&c.keyCode!==p.SPACE||this._resetSourceFields()})));var d=!1;q.forEach(b.fields,f.hitch(this,function(c){var h=c.hasOwnProperty("isEditable")?c.isEditable:c.editable;"esriFieldTypeGeometry"!==c.type&&"esriFieldTypeBlob"!==c.type&&"esriFieldTypeRaster"!==c.type&&"esriFieldTypeXML"!==c.type&&"esriFieldTypeOID"!==c.type&&"esriFieldTypeGlobalID"!==
c.type&&h&&(d=!0,this._createFieldList(a,c))}));d?g.add(this.noFieldsMatching,"esriCTHidden"):(g.add(this.fieldMappingTableWrapper,"esriCTHidden"),t.set(this.iconParentNode,"display","none"));this._showMatchedFieldsInfo()},_createFieldList:function(a,b){var d=!1;var c=k.create("tr",{"class":"esriCTFieldsMatchingTableRow"},this.fieldsTbodyNode);var h=k.create("td",{"class":"esriCTFieldsMatchingTableCell esriCTTargetTD","data-th":this.nls.fieldsMapping.fieldsInTargetLayerLabel},c);var e=this._getFieldLabel(b);
h=new u({value:e,title:e,disabled:!0},k.create("div",{},h));h.textbox&&g.add(h.textbox,"textLabelEllipsis");c=k.create("td",{"class":"esriCTFieldsMatchingTableCell esriCTSourceTD","data-th":this.nls.fieldsMapping.fieldsInSourceLayerLabel},c);this.targetLayerDetails.fieldValues&&this.targetLayerDetails.fieldValues[b.name]&&(h=this.targetLayerDetails.fieldValues[b.name])&&0<h.length&&q.some(h,f.hitch(this,function(n){if("Preset"!==n.actionName&&n.enabled||"Preset"===n.actionName&&n.enabled&&this.usePresetValues)return d=
!0}));d?(this.mappedTargetFields[b.name]=new u({value:this.nls.fieldsMapping.dynamicValueText,title:this.nls.fieldsMapping.dynamicValueText,disabled:!0},k.create("div",{},c)),this.mappedTargetFields[b.name]&&this.mappedTargetFields[b.name].textbox&&g.add(this.mappedTargetFields[b.name].textbox,"textLabelEllipsis")):(this.mappedTargetFields[b.name]=new A({options:this._addSourceLayerFieldOptions(b,a),"class":"esriCTFieldsMatchingDropdown"},k.create("div",{},c)),this.own(l(this.mappedTargetFields[b.name],
"change",f.hitch(this,this._showMatchedFieldsInfo))),m.set(this.mappedTargetFields[b.name],"aria-label",r.substitute(this.nls.fieldsMapping.selectFieldAriaLabel,{targetField:b.name})),this.fieldMappingDetails&&this.fieldMappingDetails.hasOwnProperty(this.targetLayerDetails.id)&&this.fieldMappingDetails[this.targetLayerDetails.id].hasOwnProperty(a.id)&&this.fieldMappingDetails[this.targetLayerDetails.id][a.id].hasOwnProperty(b.name)&&(a=this.fieldMappingDetails[this.targetLayerDetails.id][a.id][b.name],
""===a&&(a="esriCTSelectSourceLayerField"),this.mappedTargetFields[b.name].set("value",a)),this.own(l(this.mappedTargetFields[b.name].dropDown,"close",f.hitch(this,function(){this._setLabelWidth()}))))},_getFieldLabel:function(a){var b="";a&&a.name&&(b=a.label&&a.label!==a.name?a.label+" ["+a.name+"]":a.name);return b},_addSourceLayerFieldOptions:function(a,b){var d=[],c=[];if(!b||!b.fields)return d;d.push({label:this.nls.fieldsMapping.selectSourceFieldLabel,value:"esriCTSelectSourceLayerField"});
(c=this.ValidFieldsByType[a.type])||console.log(a.type);var h=!1;q.forEach(b.fields,f.hitch(this,function(e){var n=!0;e.hasOwnProperty("visible")&&(n=e.visible);"esriFieldTypeGeometry"!==e.type&&"esriFieldTypeBlob"!==e.type&&"esriFieldTypeRaster"!==e.type&&"esriFieldTypeXML"!==e.type&&c&&-1<c.indexOf(e.type)&&n&&(!h&&a.name.toLowerCase()===e.name.toLowerCase()||a.alias&&e.alias&&a.alias.toLowerCase()===e.alias.toLowerCase()||a.alias&&a.alias.toLowerCase()===e.name.toLowerCase()||e.alias&&a.name.toLowerCase()===
e.alias.toLowerCase()?(h=!0,d.push({label:this._getFieldLabel(e),value:e.name,selected:!0,isDefault:!0})):d.push({label:this._getFieldLabel(e),value:e.name,selected:!1,isDefault:!1}))}));return d},getMatchedFields:function(){var a={},b;for(b in this.mappedTargetFields){var d=this.mappedTargetFields[b].get("value");if("esriCTSelectSourceLayerField"===d||this.mappedTargetFields[b].get("disabled"))d="";a[b]=d}return a},_showMatchedFieldsInfo:function(){var a=0,b=0,d;for(d in this.mappedTargetFields)"esriCTSelectSourceLayerField"!==
this.mappedTargetFields[d].get("value")&&b++,a++;a=r.substitute(this.nls.fieldsMapping.targetFieldsMatchedLabel,{layerName:this.sourceLayerDetails.name,matchedFields:b,totalFields:a});m.set(this.layerNameNode,"aria-label",a);m.set(this.layerNameNode,"innerHTML",a);m.set(this.layerNameNode,"title",a);m.set(this.expandIconNode,"aria-label",a);m.set(this.expandIconNode,"title",a)}})});