{"version":3,"sources":["jsdelivr-header.js","/npm/json-from-text@1.1.0/src/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,aAEA,MAAM,OAAS,QAAQ,UACjB,eAAiB,QAAQ,WAAW,eAE1C,SAAS,aAAa,EAAU,GAC9B,GAAwB,iBAAb,GAAsC,KAAb,EAClC,MAAM,IAAI,MAAM,wDAIlB,IAAI,OAHyB,IAAlB,IACT,GAAgB,GAGlB,IACE,EAAY,eAAe,EAAU,SAAU,SAAU,IAAK,CAAE,WAAY,CAAC,OAAQ,OAAQ,SAAU,UACzG,CAAE,MAAO,GACP,KAAsB,yCAAlB,EAAM,QACF,IAAI,MAAM,6DAEV,CACV,CAEA,MAAM,EAAc,GAAI,EAAc,GAAI,EAAc,GAExD,IAAK,IAAI,EAAI,EAAG,EAAI,EAAU,OAAQ,IACpC,GAAyB,QAArB,EAAU,GAAG,KAAgB,CAC/B,MAAM,EAAU,EAAU,MAAM,EAAG,EAAI,GAAG,KAAI,GAAU,EAAO,QAAO,KAAK,IAC3E,IAAI,EACJ,GAAI,EACF,IACE,EAAU,OAAO,EACnB,CAAE,MAAO,GACP,EAAU,CACZ,MAEA,EAAU,EAGZ,EAAY,KAAK,GACjB,EAAY,KAAK,CAAE,KAAM,OAAQ,MAAO,EAAS,OAA2B,iBAAZ,IAChE,GAAK,CACP,KAAO,CACL,MAAM,EAAO,EAAU,GAAG,MAC1B,EAAY,KAAK,GACjB,EAAY,KAAK,CAAE,KAAM,OAAQ,MAAO,GAC1C,CAGF,MAAO,CAAE,cAAa,cAAa,cACrC,CAEA,OAAO,QAAU","file":"/npm/json-from-text@1.1.0/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/json-from-text@1.1.0/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\r\n\r\nconst jsonic = require('jsonic');\r\nconst matchRecursive = require('xregexp').matchRecursive;\r\n\r\nfunction jsonFromText(mixedStr, parseToObject) {\r\n  if (typeof mixedStr !== 'string' || mixedStr === '')\r\n    throw new Error(\"Given string is not actually a string or it's empty!\");\r\n  if (typeof parseToObject === 'undefined')\r\n    parseToObject = true;\r\n\r\n  let rawTokens;\r\n  try {\r\n    rawTokens = matchRecursive(mixedStr, '[{\\\\[]', '[\\\\]}]', 'g', { valueNames: ['text', 'left', 'center', 'right'] });\r\n  } catch (error) {\r\n    if (error.message === 'Unbalanced delimiter found in string')\r\n      throw new Error('Unbalanced amount of JSON-specific token (i.e. {, }, [, ]');\r\n    else\r\n      throw error;\r\n  }\r\n\r\n  const textResults = [], jsonResults = [], fullResults = [];\r\n\r\n  for (let i = 0; i < rawTokens.length; i++) {\r\n    if (rawTokens[i].name == 'left') {\r\n      const jsonStr = rawTokens.slice(i, i + 3).map(result => result.value).join('');\r\n      let jsonObj;\r\n      if (parseToObject) {\r\n        try {\r\n          jsonObj = jsonic(jsonStr);\r\n        } catch (err) {\r\n          jsonObj = jsonStr;\r\n        }\r\n      } else {\r\n        jsonObj = jsonStr;\r\n      }\r\n\r\n      jsonResults.push(jsonObj);\r\n      fullResults.push({ type: 'json', value: jsonObj, parsed: typeof jsonObj !== 'string' });\r\n      i += 2;\r\n    } else {\r\n      const text = rawTokens[i].value;\r\n      textResults.push(text);\r\n      fullResults.push({ type: 'text', value: text });\r\n    }\r\n  }\r\n\r\n  return { textResults, jsonResults, fullResults };\r\n}\r\n\r\nmodule.exports = jsonFromText;"]}