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,eAAe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