define(["require","exports","tslib","../../Validation","../../forms/utils","../../TemplateUtils"],function(e,t,r,c,g,p){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),p=r.__importStar(p);i.prototype._getAttributeValue=function(t,e,r){if(void 0!==(i=e[t]))return i;if(r&&0!==r.length){var i,r=r.filter(function(e){return t===e.alias})[0];return i=r&&r.name?e[r.name]:i}},i.prototype._isLabelFieldName=function(e,t,r){t=(0<t.length?t[0].attributes:{})||{};return void 0!==this._getAttributeValue(e,t,r)},i.prototype._getTokenValues=function(e,t,r){for(var i={},a=0,n=e;a<n.length;a++){var l,o=n[a].token;i.hasOwnProperty(o)||(l=this._getAttributeValue(o,t,r),l=p.getTokenValueString(o,l),i[o]=g.text.escapeTextForMarkdown(l))}return i},i.prototype.execute=function(e){var t=e.features||[],r=e.fields||[],i=e.labelFieldName||void 0;c.validation.string("labelFieldName",i);for(var a=e.valueFieldName||void 0,n={},l=this._isLabelFieldName(i,t,r),o=l?[]:p.findTokenInstances(i),u=0;u<t.length;++u){var s=t[u],d=s.attributes||{},f={},m=void 0;m=l?this._getAttributeValue(i,d,r):(v=this._getTokenValues(o,d,r),p.replacePlaceholders(i,o,v));var v=this._getAttributeValue(a,d,r),d=void 0,d=g.text.isMarkdown(m)?m:String(m);f.label=d,f.value=v,f.value||(f.value={refValueType:"data",type:"feature",data:s}),n[f.index=u]=f}return{items:n}},i.action="gcx:wf:forms::GetFormElementItemsFromFeatures",i.suite="gcx:wf:builtin",r=i;function i(){}t.GetFormElementItemsFromFeatures=r});