/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../core/string"],(function(e,n){"use strict";const r="__begin__",s="__end__",t=new RegExp(r,"ig"),i=new RegExp(s,"ig"),l=new RegExp("^"+r,"i"),o=new RegExp(s+"$","i"),a='"',p=a+" + ",c=" + "+a;function u(e){return e.replace(new RegExp("\\[","g"),"{").replace(new RegExp("\\]","g"),"}")}function x(e){return e.replace(new RegExp("\\{","g"),"[").replace(new RegExp("\\}","g"),"]")}function g(e){const n={expression:"",type:"none"};return e.labelExpressionInfo?e.labelExpressionInfo.value?(n.expression=e.labelExpressionInfo.value,n.type="conventional"):e.labelExpressionInfo.expression&&(n.expression=e.labelExpressionInfo.expression,n.type="arcade"):null!=e.labelExpression&&(n.expression=u(e.labelExpression),n.type="conventional"),n}function f(e){const n=g(e);if(!n)return null;switch(n.type){case"conventional":return d(n.expression);case"arcade":return n.expression}return null}function E(e){const n=g(e);if(!n)return null;switch(n.type){case"conventional":return b(n.expression);case"arcade":return _(n.expression)}return null}function d(e){let u;return e?(u=n.replace(e,(e=>r+'$feature["'+e+'"]'+s)),u=l.test(u)?u.replace(l,""):a+u,u=o.test(u)?u.replace(o,""):u+a,u=u.replace(t,p).replace(i,c)):u='""',u}const w=/^\s*\{([^}]+)\}\s*$/i;function b(e){const n=e.match(w);return n&&n[1].trim()||null}const $=/^\s*(?:(?:\$feature\.(\w+))|(?:\$feature\[(["'])([\w\s]+)(\2)\]));?\s*$/i,m=/^\s*(?:(?:\$feature\.(\w+))|(?:\$feature\[(["'])([\w\s]+)(\2)\]));?\s*(?:DomainName\(\s*\$feature\s*,\s*(["'])(\1|\3)(\5)\s*\));?\s*$/i,S=/^\s*(?:DomainName\(\s*\$feature\s*,\s*(["'])([\w\s]+)(\1)\s*\));?\s*$/i;function _(e){if(!e)return null;let n=$.exec(e)||m.exec(e);return n?n[1]||n[3]:(n=S.exec(e),n?n[2]:null)}e.convertTemplatedStringToArcade=d,e.getLabelExpression=g,e.getLabelExpressionArcade=f,e.getLabelExpressionSingleField=E,e.getSingleFieldArcadeExpression=_,e.getSingleFieldTemplatedString=b,e.sqlToTemplateString=u,e.templateStringToSql=x,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
