text: "use strict";
  /**
   * @file createComponentXml.ts
   * @Copyright (c) Microsoft Corporation.  All rights reserved.
   *
   * Creates XML definitions for the relationships files
   */
  Object.defineProperty(exports, "__esModule", { value: true });
  /// <reference path='./xml.d.ts' />
  var path = require("path");
  var XmlGenerator = require("xml");
  var constants_1 = require("../config/constants");
  var serializationOptions_1 = require("./serializationOptions");
  var relationshipId = 0;
  function relationshipToXmlDefinition(rel) {
      if (rel.target[0] !== '/') {
          rel.target = '/' + rel.target;
      }
      return {
          Relationship: [
              {
                  _attr: {
                      Type: "http://schemas.microsoft.com/sharepoint/2012/app/relationships/" + rel.type,
                      Target: rel.target,
                      Id: "r" + relationshipId++
                  }
              }
          ]
      };
  }
  function createRelationshipsDefinition(rels) {
      return {
          Relationships: [
              {
                  _attr: {
                      xmlns: 'http://schemas.openxmlformats.org/package/2006/relationships'
                  }
              }
          ].concat(rels.map(function (rel) { return relationshipToXmlDefinition(rel); }))
      };
  }
  function createRelationshipsXml(currentFilename, rels) {
      var file = path.basename(currentFilename);
      var folder = path.dirname(currentFilename);
      return {
          filename: path.posix.join(folder, constants_1.default.RelsFolder, file + constants_1.default.RelsXml),
          xml: XmlGenerator(createRelationshipsDefinition(rels), serializationOptions_1.default)
      };
  }
  exports.default = createRelationshipsXml;
  
  //# sourceMappingURL=createRelationshipsXml.js.map
  