/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
function e(e){const t=e.fieldTimeMappings??[],n=e.timeValueUnits??"years",a=t.map(({fieldName:e,timeValue:r})=>`  "${r}", $feature.${e},`);return`var timeFormat = "${r(n)}";\n\nvar hasCurrentStart = HasValue($view, ["timeProperties", "currentStart"]);\nvar hasCurrentEnd = HasValue($view, ["timeProperties", "currentEnd"]);\n\nvar hasCurrentTime = hasCurrentStart || hasCurrentEnd;\n\nif (!hasCurrentTime) {\n  return $feature.${t[0].fieldName};\n}\n\nvar currentTime = DefaultValue($view.timeProperties.currentEnd, $view.timeProperties.currentStart);\nvar formattedCurrentTime = Text(currentTime, timeFormat);\n\nvar result = Decode(formattedCurrentTime,\n${a.join("\n")}\n  null\n);\n\nreturn result;`}function r(e){switch(e){case"years":default:return"Y";case"months":return"Y-M";case"days":return"Y-M-D";case"hours":case"minutes":return"Y-M-D-H-mm";case"seconds":return"Y-M-D-H-mm-ss"}}export{e as createTimeSeriesExpression,r as getArcadeTimeFormatString};
