text: import toDate from"../toDate/index.js";import formatters from"../_lib/format/lightFormatters/index.js";import getTimezoneOffsetInMilliseconds from"../_lib/getTimezoneOffsetInMilliseconds/index.js";import isValid from"../isValid/index.js";import subMilliseconds from"../subMilliseconds/index.js";var formattingTokensRegExp=/(\w)\1*|''|'(''|[^'])+('|$)|./g,escapedStringRegExp=/^'(.*?)'?$/,doubleQuoteRegExp=/''/g;export default function lightFormat(dirtyDate,dirtyFormatStr){if(2>arguments.length){throw new TypeError("2 arguments required, but only "+arguments.length+" present")}var originalDate=toDate(dirtyDate);if(!isValid(originalDate)){throw new RangeError("Invalid time value")}var timezoneOffset=getTimezoneOffsetInMilliseconds(originalDate),utcDate=subMilliseconds(originalDate,timezoneOffset),result=(dirtyFormatStr+"").match(formattingTokensRegExp).map(function(substring){if("''"===substring){return"'"}var firstCharacter=substring[0];if("'"===firstCharacter){return cleanEscapedString(substring)}var formatter=formatters[firstCharacter];if(formatter){return formatter(utcDate,substring,null,{})}return substring}).join("");return result}function cleanEscapedString(input){return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp,"'")}