{"version":3,"file":"content-types-xform.js","names":["XmlStream","require","BaseXform","ContentTypesXform","render","xmlStream","model","openXml","StdDocAttributes","openNode","PROPERTY_ATTRIBUTES","mediaHash","media","forEach","medium","type","imageType","extension","leafNode","Extension","ContentType","PartName","worksheets","worksheet","name","id","hasSharedStrings","sharedStrings","count","tables","table","target","drawings","drawing","commentRefs","_ref","commentName","closeNode","parseOpen","parseText","parseClose","xmlns","module","exports"],"sources":["../../../../../lib/xlsx/xform/core/content-types-xform.js"],"sourcesContent":["const XmlStream = require('../../../utils/xml-stream');\n\nconst BaseXform = require('../base-xform');\n\n// used for rendering the [Content_Types].xml file\n// not used for parsing\nclass ContentTypesXform extends BaseXform {\n  render(xmlStream, model) {\n    xmlStream.openXml(XmlStream.StdDocAttributes);\n\n    xmlStream.openNode('Types', ContentTypesXform.PROPERTY_ATTRIBUTES);\n\n    const mediaHash = {};\n    (model.media || []).forEach(medium => {\n      if (medium.type === 'image') {\n        const imageType = medium.extension;\n        if (!mediaHash[imageType]) {\n          mediaHash[imageType] = true;\n          xmlStream.leafNode('Default', {Extension: imageType, ContentType: `image/${imageType}`});\n        }\n      }\n    });\n\n    xmlStream.leafNode('Default', {\n      Extension: 'rels',\n      ContentType: 'application/vnd.openxmlformats-package.relationships+xml',\n    });\n    xmlStream.leafNode('Default', {Extension: 'xml', ContentType: 'application/xml'});\n\n    xmlStream.leafNode('Override', {\n      PartName: '/xl/workbook.xml',\n      ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml',\n    });\n\n    model.worksheets.forEach(worksheet => {\n      const name = `/xl/worksheets/sheet${worksheet.id}.xml`;\n      xmlStream.leafNode('Override', {\n        PartName: name,\n        ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml',\n      });\n    });\n\n    xmlStream.leafNode('Override', {\n      PartName: '/xl/theme/theme1.xml',\n      ContentType: 'application/vnd.openxmlformats-officedocument.theme+xml',\n    });\n    xmlStream.leafNode('Override', {\n      PartName: '/xl/styles.xml',\n      ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml',\n    });\n\n    const hasSharedStrings = model.sharedStrings && model.sharedStrings.count;\n    if (hasSharedStrings) {\n      xmlStream.leafNode('Override', {\n        PartName: '/xl/sharedStrings.xml',\n        ContentType:\n          'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml',\n      });\n    }\n\n    if (model.tables) {\n      model.tables.forEach(table => {\n        xmlStream.leafNode('Override', {\n          PartName: `/xl/tables/${table.target}`,\n          ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml',\n        });\n      });\n    }\n\n    if (model.drawings) {\n      model.drawings.forEach(drawing => {\n        xmlStream.leafNode('Override', {\n          PartName: `/xl/drawings/${drawing.name}.xml`,\n          ContentType: 'application/vnd.openxmlformats-officedocument.drawing+xml',\n        });\n      });\n    }\n\n    if (model.commentRefs) {\n      xmlStream.leafNode('Default', {\n        Extension: 'vml',\n        ContentType: 'application/vnd.openxmlformats-officedocument.vmlDrawing',\n      });\n\n      model.commentRefs.forEach(({commentName}) => {\n        xmlStream.leafNode('Override', {\n          PartName: `/xl/${commentName}.xml`,\n          ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml',\n        });\n      });\n    }\n\n    xmlStream.leafNode('Override', {\n      PartName: '/docProps/core.xml',\n      ContentType: 'application/vnd.openxmlformats-package.core-properties+xml',\n    });\n    xmlStream.leafNode('Override', {\n      PartName: '/docProps/app.xml',\n      ContentType: 'application/vnd.openxmlformats-officedocument.extended-properties+xml',\n    });\n\n    xmlStream.closeNode();\n  }\n\n  parseOpen() {\n    return false;\n  }\n\n  parseText() {}\n\n  parseClose() {\n    return false;\n  }\n}\n\nContentTypesXform.PROPERTY_ATTRIBUTES = {\n  xmlns: 'http://schemas.openxmlformats.org/package/2006/content-types',\n};\n\nmodule.exports = ContentTypesXform;\n"],"mappings":";;AAAA,MAAMA,SAAS,GAAGC,OAAO,CAAC,2BAA2B,CAAC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