1{"version":3,"file":"Strings.js","names":["getProjectStringsXMLPathAsync","projectRoot","kind","getResourceXMLPathAsync","name","setStringItem","itemToAdd","stringFileContentsJSON","resources","string","newItem","stringNameExists","findIndex","e","$","concat","removeStringItem","named","splice"],"sources":["../../src/android/Strings.ts"],"sourcesContent":["import { getResourceXMLPathAsync } from './Paths';\nimport { ResourceItemXML, ResourceKind, ResourceXML } from './Resources';\n\nexport async function getProjectStringsXMLPathAsync(\n  projectRoot: string,\n  { kind }: { kind?: ResourceKind } = {}\n): Promise<string> {\n  return getResourceXMLPathAsync(projectRoot, { kind, name: 'strings' });\n}\n\nexport function setStringItem(\n  itemToAdd: ResourceItemXML[],\n  stringFileContentsJSON: ResourceXML\n): ResourceXML {\n  if (!stringFileContentsJSON?.resources?.string) {\n    if (!stringFileContentsJSON.resources || typeof stringFileContentsJSON.resources === 'string') {\n      // file was empty and JSON is `{resources : ''}`\n      stringFileContentsJSON.resources = {};\n    }\n    stringFileContentsJSON.resources.string = itemToAdd;\n    return stringFileContentsJSON;\n  }\n\n  for (const newItem of itemToAdd) {\n    const stringNameExists = stringFileContentsJSON.resources.string.findIndex(\n      (e: ResourceItemXML) => e.$.name === newItem.$.name\n    );\n    if (stringNameExists > -1) {\n      // replace the previous item\n      stringFileContentsJSON.resources.string[stringNameExists] = newItem;\n    } else {\n      stringFileContentsJSON.resources.string =\n        stringFileContentsJSON.resources.string.concat(newItem);\n    }\n  }\n  return stringFileContentsJSON;\n}\n\nexport function removeStringItem(named: string, stringFileContentsJSON: ResourceXML): ResourceXML {\n  if (stringFileContentsJSON?.resources?.string) {\n    const stringNameExists = stringFileContentsJSON.resources.string.findIndex(\n      (e: ResourceItemXML) => e.$.name === named\n    );\n    if (stringNameExists > -1) {\n      // replace the previous value\n      stringFileContentsJSON.resources.string.splice(stringNameExists, 1);\n    }\n  }\n  return stringFileContentsJSON;\n}\n"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,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