{"version":3,"file":"getEmptyNode.mjs","names":[],"sources":["../../../src/dictionaryManipulator/getEmptyNode.ts"],"sourcesContent":["import type { ContentNode, TypedNode } from '@intlayer/types/dictionary';\n\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\nexport const getEmptyNode = (section: ContentNode): ContentNode => {\n  if (typeof section === 'string') {\n    return '';\n  }\n  if (typeof section === 'number') {\n    return 0;\n  }\n  if (typeof section === 'boolean') {\n    return true;\n  }\n  if (typeof (section as TypedNode)?.nodeType === 'string') {\n    const typedNode = section as TypedNode;\n    const content =\n      typedNode[typedNode.nodeType as unknown as keyof typeof typedNode];\n\n    if (\n      typedNode.nodeType === NodeTypes.TRANSLATION ||\n      typedNode.nodeType === NodeTypes.ENUMERATION ||\n      typedNode.nodeType === NodeTypes.PLURAL ||\n      typedNode.nodeType === NodeTypes.CONDITION ||\n      typedNode.nodeType === NodeTypes.INSERTION ||\n      typedNode.nodeType === NodeTypes.HTML\n    ) {\n      return getEmptyNode(content as ContentNode);\n    }\n\n    if (typedNode.nodeType === NodeTypes.NESTED) {\n      return 'dictionary-key';\n    }\n\n    if (typedNode.nodeType === NodeTypes.FILE) {\n      return 'file/path';\n    }\n\n    if (typedNode.nodeType === NodeTypes.MARKDOWN) {\n      return getEmptyNode(content as ContentNode);\n    }\n\n    return content;\n  }\n\n  if (!section || typeof section !== 'object') {\n    return section;\n  }\n\n  if (Array.isArray(section)) {\n    return (section as ContentNode[]).map(\n      getEmptyNode\n    ) as unknown as ContentNode;\n  }\n\n  const mappedSectionObject = Object.entries(section).map(([key, value]) => [\n    key,\n    getEmptyNode(value as ContentNode),\n  ]);\n\n  const mappedSectionArray = Object.fromEntries(mappedSectionObject);\n\n  return mappedSectionArray;\n};\n"],"mappings":";;;AAIA,MAAa,gBAAgB,YAAsC;AACjE,KAAI,OAAO,YAAY,SACrB,QAAO;AAET,KAAI,OAAO,YAAY,SACrB,QAAO;AAET,KAAI,OAAO,YAAY,UACrB,QAAO;AAET,KAAI,OAAQ,SAAuB,aAAa,UAAU;EACxD,MAAM,YAAY;EAClB,MAAM,UACJ,UAAU,UAAU;AAEtB,MACE,UAAU,aAAa,UAAU,eACjC,UAAU,aAAa,UAAU,eACjC,UAAU,aAAa,UAAU,UACjC,UAAU,aAAa,UAAU,aACjC,UAAU,aAAa,UAAU,aACjC,UAAU,aAAa,UAAU,KAEjC,QAAO,aAAa,QAAuB;AAG7C,MAAI,UAAU,aAAa,UAAU,OACnC,QAAO;AAGT,MAAI,UAAU,aAAa,UAAU,KACnC,QAAO;AAGT,MAAI,UAAU,aAAa,UAAU,SACnC,QAAO,aAAa,QAAuB;AAG7C,SAAO;;AAGT,KAAI,CAAC,WAAW,OAAO,YAAY,SACjC,QAAO;AAGT,KAAI,MAAM,QAAQ,QAAQ,CACxB,QAAQ,QAA0B,IAChC,aACD;CAGH,MAAM,sBAAsB,OAAO,QAAQ,QAAQ,CAAC,KAAK,CAAC,KAAK,WAAW,CACxE,KACA,aAAa,MAAqB,CACnC,CAAC;AAIF,QAF2B,OAAO,YAAY,oBAErB"}