From 73087ac20f31d3de182a87fb3065509e0370850c Mon Sep 17 00:00:00 2001 From: Adriano Raiano Date: Fri, 20 Oct 2023 13:08:40 +0200 Subject: [PATCH] special handling for sizeRestriction attribute in xliff v2 --- CHANGELOG.md | 4 + LICENSE | 2 +- lib/js2xliff.js | 28 +- lib/xliff2js.js | 6 + package.json | 18 +- test/fixtures/example_sizeRestriction.json | 23 ++ test/fixtures/example_sizeRestriction.xliff | 25 ++ test/fixtures/index.js | 4 + test/test.js | 19 ++ xliff.js | 336 +++++--------------- xliff.min.js | 2 +- 11 files changed, 200 insertions(+), 267 deletions(-) create mode 100644 test/fixtures/example_sizeRestriction.json create mode 100644 test/fixtures/example_sizeRestriction.xliff diff --git a/CHANGELOG.md b/CHANGELOG.md index 80aeb65..c898925 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 6.2.0 + +- special handling for sizeRestriction attribute in xliff v2 + ### 6.1.0 - introduce captureSpacesBetweenElements option diff --git a/LICENSE b/LICENSE index a5521a3..d98e38c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2022 locize +Copyright (c) 2023 locize Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/lib/js2xliff.js b/lib/js2xliff.js index 38eafae..7382eb4 100644 --- a/lib/js2xliff.js +++ b/lib/js2xliff.js @@ -21,6 +21,10 @@ const js2xliffClb = (obj, opt, cb) => { srcLang: obj.sourceLanguage, trgLang: obj.targetLanguage } + + const hasSizeRestriction = !!Object.keys(obj.resources).find((nsName) => Object.keys(obj.resources[nsName]).find((k) => obj.resources[nsName][k].additionalAttributes && (obj.resources[nsName][k].additionalAttributes.sizeRestriction !== undefined || obj.resources[nsName][k].additionalAttributes['slr:sizeRestriction'] !== undefined))) + if (hasSizeRestriction) rootAttributes['xmlns:slr'] = 'urn:oasis:names:tc:xliff:sizerestriction:2.0' + const root = makeElement('xliff', rootAttributes, true) Object.keys(obj.resources).forEach((nsName) => { @@ -39,13 +43,27 @@ const js2xliffClb = (obj, opt, cb) => { } function createUnitTags (unitElements) { - return Object.keys(unitElements).map((key) => { + const hasSizeRestriction = !!Object.keys(unitElements).find((k) => unitElements[k].additionalAttributes && (unitElements[k].additionalAttributes.sizeRestriction !== undefined || unitElements[k].additionalAttributes['slr:sizeRestriction'] !== undefined)) + const preElements = [] + if (hasSizeRestriction) { + preElements.push({ + type: 'element', + name: 'slr:profiles', + attributes: { generalProfile: 'xliff:codepoints', storageProfile: 'xliff:utf8' }, + elements: [{ + type: 'element', + name: 'slr:normalization', + attributes: { general: 'nfc', storage: 'nfc' } + }] + }) + } + return preElements.concat(Object.keys(unitElements).map((key) => { if (unitElements[key].groupUnits) { return createGroupUnitTag(key, unitElements[key]) } else { return createUnitTag(key, unitElements[key]) } - }) + })) } function createGroupUnitTag (id, group) { @@ -67,7 +85,11 @@ function createUnitTag (id, unit) { }) subEle.unshift(makeElement('notes', null, noteElms)) } - const additionalAttributes = unit.additionalAttributes != null ? unit.additionalAttributes : {} + const additionalAttributes = unit.additionalAttributes != null ? { ...unit.additionalAttributes } : {} + if (additionalAttributes.sizeRestriction) { + additionalAttributes['slr:sizeRestriction'] = additionalAttributes.sizeRestriction + '' + delete additionalAttributes.sizeRestriction + } return makeElement('unit', Object.assign({ id: escape(id) }, additionalAttributes), subEle) } diff --git a/lib/xliff2js.js b/lib/xliff2js.js index 732d30f..95de5d4 100644 --- a/lib/xliff2js.js +++ b/lib/xliff2js.js @@ -63,6 +63,12 @@ function createUnits (parent, initValues) { const additionalAttributes = unit.attributes delete additionalAttributes.id + if (additionalAttributes['slr:sizeRestriction'] !== undefined) { + additionalAttributes.sizeRestriction = additionalAttributes['slr:sizeRestriction'] + if (typeof additionalAttributes.sizeRestriction === 'string') additionalAttributes.sizeRestriction = parseInt(additionalAttributes.sizeRestriction) + delete additionalAttributes['slr:sizeRestriction'] + } + switch (unit.name) { case 'unit': file[key] = createUnit(unit, initValues) diff --git a/package.json b/package.json index e57201c..f8439ea 100644 --- a/package.json +++ b/package.json @@ -122,22 +122,22 @@ "xml-js": "1.6.11" }, "devDependencies": { - "@babel/cli": "7.14.5", - "@babel/core": "7.14.5", - "@babel/preset-env": "7.14.5", + "@babel/cli": "7.23.0", + "@babel/core": "7.23.2", + "@babel/preset-env": "7.23.2", "babel-plugin-add-module-exports": "1.0.4", "browserify": "17.0.0", "cross-env": "7.0.3", - "eslint": "7.28.0", - "eslint-config-standard": "16.0.3", - "eslint-plugin-import": "2.23.4", + "eslint": "8.51.0", + "eslint-config-standard": "17.1.0", + "eslint-plugin-import": "2.28.1", "eslint-plugin-node": "11.1.0", - "eslint-plugin-promise": "5.1.0", + "eslint-plugin-promise": "6.1.1", "eslint-plugin-require-path-exists": "1.1.9", "eslint-plugin-standard": "4.1.0", "expect.js": "0.3.1", - "mocha": "9.0.0", - "uglify-js": "3.13.9" + "mocha": "10.2.0", + "uglify-js": "3.17.4" }, "scripts": { "lint": "eslint .", diff --git a/test/fixtures/example_sizeRestriction.json b/test/fixtures/example_sizeRestriction.json new file mode 100644 index 0000000..92b6cd8 --- /dev/null +++ b/test/fixtures/example_sizeRestriction.json @@ -0,0 +1,23 @@ +{ + "resources": { + "namespace1": { + "key1": { + "source": "Hello", + "target": "Hallo" + }, + "key2": { + "source": "An application to manipulate and process XLIFF documents", + "target": "Eine Applikation um XLIFF Dokumente zu manipulieren und verarbeiten", + "additionalAttributes": { + "sizeRestriction": 60 + } + }, + "key.nested": { + "source": "XLIFF Data Manager", + "target": "XLIFF Daten Manager" + } + } + }, + "sourceLanguage": "en-US", + "targetLanguage": "de-CH" +} diff --git a/test/fixtures/example_sizeRestriction.xliff b/test/fixtures/example_sizeRestriction.xliff new file mode 100644 index 0000000..9cd0ced --- /dev/null +++ b/test/fixtures/example_sizeRestriction.xliff @@ -0,0 +1,25 @@ + + + + + + + + Hello + Hallo + + + + + An application to manipulate and process XLIFF documents + Eine Applikation um XLIFF Dokumente zu manipulieren und verarbeiten + + + + + XLIFF Data Manager + XLIFF Daten Manager + + + + diff --git a/test/fixtures/index.js b/test/fixtures/index.js index a16ca7e..bd2f922 100644 --- a/test/fixtures/index.js +++ b/test/fixtures/index.js @@ -73,5 +73,9 @@ module.exports = { }, example_empty:{ xliff12: fixNewLines(fs.readFileSync(path.join(__dirname, 'example_empty12.xliff')).toString()) + }, + example_sizeRestriction: { + js: require('./example_sizeRestriction'), + xliff: fixNewLines(fs.readFileSync(path.join(__dirname, 'example_sizeRestriction.xliff')).toString()) } } diff --git a/test/test.js b/test/test.js index 6360357..761358e 100644 --- a/test/test.js +++ b/test/test.js @@ -408,6 +408,25 @@ describe('with additional attributes', () => { }) }) +describe('with sizeRestriction attribute', () => { + describe('xliff 2.0', () => { + test('xliff2js', (fn) => (done) => { + fn(fixtures.example_sizeRestriction.xliff, (err, res) => { + expect(err).not.to.be.ok() + expect(res).to.eql(fixtures.example_sizeRestriction.js) + done() + }) + }) + test('js2xliff', (fn) => (done) => { + fn(fixtures.example_sizeRestriction.js, (err, res) => { + expect(err).not.to.be.ok() + expect(res).to.eql(fixtures.example_sizeRestriction.xliff) + done() + }) + }) + }) +}) + describe('Google Actions Xliff', () => { test('xliff12ToJs', (fn) => (done) => { fn(fixtures.example_google.xliff12, { xmlLangAttr: true }, (err, res) => { diff --git a/xliff.js b/xliff.js index 26e465e..50776e8 100644 --- a/xliff.js +++ b/xliff.js @@ -5,13 +5,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; - -function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } - +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function setSegment(category, srcObj, trgObj, ntObj, key) { var srcValue = srcObj[key]; var trgValue = trgObj[key]; - if (_typeof(srcValue) === 'object' && _typeof(trgValue) === 'object') { category[key] = { groupUnits: {} @@ -19,7 +16,6 @@ function setSegment(category, srcObj, trgObj, ntObj, key) { var grpObj = category[key].groupUnits; Object.keys(srcValue).forEach(function (grpKey) { setSegment(grpObj, srcObj[key], trgObj[key], ntObj[key], grpKey); - if (ntObj && ntObj[key] && ntObj[key][grpKey]) { category[key].note = ntObj[key][grpKey]; } @@ -29,31 +25,26 @@ function setSegment(category, srcObj, trgObj, ntObj, key) { source: srcValue, target: trgValue }; - if (ntObj && ntObj[key]) { category[key].note = ntObj[key]; } } } - var createjsClb = function createjsClb(srcLng, trgLng, srcKeys, trgKeys, ntKeys, ns, cb) { var js = { sourceLanguage: srcLng, targetLanguage: trgLng, resources: {} }; - if (!cb && (!ns || typeof ns !== 'string')) { cb = ns; ns = null; } - trgKeys = trgKeys || {}; var keys = Object.keys(srcKeys); Object.keys(trgKeys).forEach(function (k) { if (keys.indexOf(k) < 0) keys.push(k); }); - if (ns && typeof ns === 'string') { js.resources[ns] = {}; var nsObj = js.resources[ns]; @@ -63,7 +54,6 @@ var createjsClb = function createjsClb(srcLng, trgLng, srcKeys, trgKeys, ntKeys, if (cb) cb(null, js); return js; } - keys.forEach(function (ns) { js.resources[ns] = {}; Object.keys(srcKeys[ns]).forEach(function (srcKey) { @@ -73,7 +63,6 @@ var createjsClb = function createjsClb(srcLng, trgLng, srcKeys, trgKeys, ntKeys, if (cb) cb(null, js); return js; }; - var createjs = function createjs(srcLng, trgLng, srcKeys, trgKeys, ns, cb, ntKeys) { if (!cb && ns === undefined) { return new Promise(function (resolve, reject) { @@ -82,7 +71,6 @@ var createjs = function createjs(srcLng, trgLng, srcKeys, trgKeys, ns, cb, ntKey }); }); } - if (!cb && typeof ns !== 'function') { return new Promise(function (resolve, reject) { return createjsClb(srcLng, trgLng, srcKeys, trgKeys, ntKeys, ns, function (err, ret) { @@ -90,13 +78,10 @@ var createjs = function createjs(srcLng, trgLng, srcKeys, trgKeys, ns, cb, ntKey }); }); } - return createjsClb(srcLng, trgLng, srcKeys, trgKeys, ntKeys, ns, cb); }; - createjs.createjsClb = createjsClb; -var _default = createjs; -exports.default = _default; +var _default = exports.default = createjs; module.exports = exports.default; },{}],2:[function(require,module,exports){ "use strict"; @@ -105,32 +90,24 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = createxliff; - var _createjs = _interopRequireDefault(require("./createjs.js")); - var _js2xliff = _interopRequireDefault(require("./js2xliff.js")); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - var createjs = _createjs.default.createjsClb; var js2xliff = _js2xliff.default.js2xliffClb; - var createxliffClb = function createxliffClb(srcLng, trgLng, srcKeys, trgKeys, ntKeys, ns, cb) { if (!ns || typeof ns !== 'string') { cb = ns; ns = null; } - if (!cb) { return js2xliff(createjs(srcLng, trgLng, srcKeys, trgKeys, ntKeys, ns)); } - createjs(srcLng, trgLng, srcKeys, trgKeys, ntKeys, ns, function (err, res) { if (err) return cb(err); js2xliff(res, cb); }); }; - function createxliff(srcLng, trgLng, srcKeys, trgKeys, ns, cb, ntKeys) { if (!cb && ns === undefined) { return new Promise(function (resolve, reject) { @@ -139,7 +116,6 @@ function createxliff(srcLng, trgLng, srcKeys, trgKeys, ns, cb, ntKeys) { }); }); } - if (!cb && typeof ns !== 'function') { return new Promise(function (resolve, reject) { return createxliffClb(srcLng, trgLng, srcKeys, trgKeys, ntKeys, ns, function (err, ret) { @@ -147,10 +123,8 @@ function createxliff(srcLng, trgLng, srcKeys, trgKeys, ns, cb, ntKeys) { }); }); } - return createxliffClb(srcLng, trgLng, srcKeys, trgKeys, ntKeys, ns, cb); } - module.exports = exports.default; },{"./createjs.js":1,"./js2xliff.js":10}],3:[function(require,module,exports){ "use strict"; @@ -159,32 +133,24 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = createxliff12; - var _createjs = _interopRequireDefault(require("./createjs.js")); - var _jsToXliff = _interopRequireDefault(require("./jsToXliff12.js")); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - var createjs = _createjs.default.createjsClb; var jsToXliff12 = _jsToXliff.default.jsToXliff12Clb; - var createxliff12Clb = function createxliff12Clb(srcLng, trgLng, srcKeys, trgKeys, ntKeys, ns, cb) { if (!ns || typeof ns !== 'string') { cb = ns; ns = null; } - if (!cb) { return jsToXliff12(createjs(srcLng, trgLng, srcKeys, trgKeys, ntKeys, ns)); } - createjs(srcLng, trgLng, srcKeys, trgKeys, ntKeys, ns, function (err, res) { if (err) return cb(err); jsToXliff12(res, cb); }); }; - function createxliff12(srcLng, trgLng, srcKeys, trgKeys, ns, cb, ntKeys) { if (!cb && ns === undefined) { return new Promise(function (resolve, reject) { @@ -193,7 +159,6 @@ function createxliff12(srcLng, trgLng, srcKeys, trgKeys, ns, cb, ntKeys) { }); }); } - if (!cb && typeof ns !== 'function') { return new Promise(function (resolve, reject) { return createxliff12Clb(srcLng, trgLng, srcKeys, trgKeys, ntKeys, ns, function (err, ret) { @@ -201,10 +166,8 @@ function createxliff12(srcLng, trgLng, srcKeys, trgKeys, ns, cb, ntKeys) { }); }); } - return createxliff12Clb(srcLng, trgLng, srcKeys, trgKeys, ntKeys, ns, cb); } - module.exports = exports.default; },{"./createjs.js":1,"./jsToXliff12.js":11}],4:[function(require,module,exports){ "use strict"; @@ -212,34 +175,35 @@ module.exports = exports.default; Object.defineProperty(exports, "__esModule", { value: true }); -Object.defineProperty(exports, "xliff2js", { +Object.defineProperty(exports, "createjs", { enumerable: true, get: function get() { - return _xliff2js.default; + return _createjs.default; } }); -Object.defineProperty(exports, "xliff12ToJs", { +Object.defineProperty(exports, "createxliff", { enumerable: true, get: function get() { - return _xliff12ToJs.default; + return _createxliff.default; } }); -Object.defineProperty(exports, "js2xliff", { +Object.defineProperty(exports, "createxliff12", { enumerable: true, get: function get() { - return _js2xliff.default; + return _createxliff2.default; } }); -Object.defineProperty(exports, "jsToXliff12", { +exports.default = void 0; +Object.defineProperty(exports, "js2xliff", { enumerable: true, get: function get() { - return _jsToXliff.default; + return _js2xliff.default; } }); -Object.defineProperty(exports, "targetOfjs", { +Object.defineProperty(exports, "jsToXliff12", { enumerable: true, get: function get() { - return _targetOfjs.default; + return _jsToXliff.default; } }); Object.defineProperty(exports, "sourceOfjs", { @@ -248,47 +212,35 @@ Object.defineProperty(exports, "sourceOfjs", { return _sourceOfjs.default; } }); -Object.defineProperty(exports, "createjs", { +Object.defineProperty(exports, "targetOfjs", { enumerable: true, get: function get() { - return _createjs.default; + return _targetOfjs.default; } }); -Object.defineProperty(exports, "createxliff", { +Object.defineProperty(exports, "xliff12ToJs", { enumerable: true, get: function get() { - return _createxliff.default; + return _xliff12ToJs.default; } }); -Object.defineProperty(exports, "createxliff12", { +Object.defineProperty(exports, "xliff2js", { enumerable: true, get: function get() { - return _createxliff2.default; + return _xliff2js.default; } }); -exports.default = void 0; - var _xliff2js = _interopRequireDefault(require("./xliff2js.js")); - var _xliff12ToJs = _interopRequireDefault(require("./xliff12ToJs.js")); - var _js2xliff = _interopRequireDefault(require("./js2xliff.js")); - var _jsToXliff = _interopRequireDefault(require("./jsToXliff12.js")); - var _targetOfjs = _interopRequireDefault(require("./targetOfjs.js")); - var _sourceOfjs = _interopRequireDefault(require("./sourceOfjs.js")); - var _createjs = _interopRequireDefault(require("./createjs.js")); - var _createxliff = _interopRequireDefault(require("./createxliff.js")); - var _createxliff2 = _interopRequireDefault(require("./createxliff12.js")); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var _default = { +var _default = exports.default = { xliff2js: _xliff2js.default, xliff12ToJs: _xliff12ToJs.default, js2xliff: _js2xliff.default, @@ -299,7 +251,6 @@ var _default = { createxliff: _createxliff.default, createxliff12: _createxliff2.default }; -exports.default = _default; },{"./createjs.js":1,"./createxliff.js":2,"./createxliff12.js":3,"./js2xliff.js":10,"./jsToXliff12.js":11,"./sourceOfjs.js":13,"./targetOfjs.js":14,"./xliff12ToJs.js":16,"./xliff2js.js":17}],5:[function(require,module,exports){ "use strict"; @@ -307,7 +258,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; -var _default = { +var _default = exports.default = { Standalone: 'Standalone', GenericSpan: 'GenericSpan', GenericSpanStart: 'GenericSpanStart', @@ -317,7 +268,6 @@ var _default = { SpanEnd: 'SpanEnd', Marker: 'Marker' }; -exports.default = _default; module.exports = exports.default; },{}],6:[function(require,module,exports){ "use strict"; @@ -326,18 +276,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; - var _ElementTypes = _interopRequireDefault(require("./ElementTypes.js")); - var _makeInlineElement = _interopRequireDefault(require("./makeInlineElement.js")); - var _elementTypeToTagMap, _factories; - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - -var _default = { +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } +function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +var _default = exports.default = { elementTypeToTagMap: (_elementTypeToTagMap = {}, _defineProperty(_elementTypeToTagMap, _ElementTypes.default.Standalone, 'x'), _defineProperty(_elementTypeToTagMap, _ElementTypes.default.GenericSpan, 'g'), _defineProperty(_elementTypeToTagMap, _ElementTypes.default.GenericSpanStart, 'bx'), _defineProperty(_elementTypeToTagMap, _ElementTypes.default.GenericSpanEnd, 'ex'), _defineProperty(_elementTypeToTagMap, _ElementTypes.default.Span, 'ph'), _defineProperty(_elementTypeToTagMap, _ElementTypes.default.SpanStart, 'bpt'), _defineProperty(_elementTypeToTagMap, _ElementTypes.default.SpanEnd, 'ept'), _defineProperty(_elementTypeToTagMap, _ElementTypes.default.Marker, 'mrk'), _elementTypeToTagMap), tagToElementTypeMap: { x: _ElementTypes.default.Standalone, @@ -367,7 +314,6 @@ var _default = { return (0, _makeInlineElement.default)(_ElementTypes.default.Marker, attributes, contents); }), _factories) }; -exports.default = _default; module.exports = exports.default; },{"./ElementTypes.js":5,"./makeInlineElement.js":8}],7:[function(require,module,exports){ "use strict"; @@ -376,18 +322,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; - var _ElementTypes = _interopRequireDefault(require("./ElementTypes.js")); - var _makeInlineElement = _interopRequireDefault(require("./makeInlineElement.js")); - var _elementTypeToTagMap, _factories; - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - -var _default = { +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } +function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +var _default = exports.default = { elementTypeToTagMap: (_elementTypeToTagMap = {}, _defineProperty(_elementTypeToTagMap, _ElementTypes.default.Standalone, 'ph'), _defineProperty(_elementTypeToTagMap, _ElementTypes.default.GenericSpan, 'pc'), _defineProperty(_elementTypeToTagMap, _ElementTypes.default.GenericSpanStart, 'sc'), _defineProperty(_elementTypeToTagMap, _ElementTypes.default.GenericSpanEnd, 'ec'), _defineProperty(_elementTypeToTagMap, _ElementTypes.default.Span, 'pc'), _defineProperty(_elementTypeToTagMap, _ElementTypes.default.SpanStart, 'sc'), _defineProperty(_elementTypeToTagMap, _ElementTypes.default.SpanEnd, 'ec'), _elementTypeToTagMap), tagToElementTypeMap: { ph: _ElementTypes.default.Standalone, @@ -411,7 +354,6 @@ var _default = { return (0, _makeInlineElement.default)(_ElementTypes.default.SpanEnd, attributes, contents); }), _factories) }; -exports.default = _default; module.exports = exports.default; },{"./ElementTypes.js":5,"./makeInlineElement.js":8}],8:[function(require,module,exports){ "use strict"; @@ -420,9 +362,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = makeInlineElement; - -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } +function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } function makeInlineElement(type, attributes, contents) { var contentsObj = contents !== undefined ? { contents: contents @@ -430,7 +373,6 @@ function makeInlineElement(type, attributes, contents) { var dataObj = Object.assign({}, attributes, contentsObj); return _defineProperty({}, type, dataObj); } - module.exports = exports.default; },{}],9:[function(require,module,exports){ "use strict"; @@ -440,11 +382,9 @@ Object.defineProperty(exports, "__esModule", { }); exports.elementTypeToTag = elementTypeToTag; exports.tagToElementType = tagToElementType; - function elementTypeToTag(type, types) { return types.elementTypeToTagMap[type]; } - function tagToElementType(tagName, types) { return types.tagToElementTypeMap[tagName]; } @@ -455,17 +395,17 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; - var _xmlJs = _interopRequireDefault(require("xml-js")); - var _ElementTypes = _interopRequireDefault(require("./inline-elements/ElementTypes2.js")); - var _objectToXml = require("./xml-js/objectToXml.js"); - var _escape = _interopRequireDefault(require("./util/escape.js")); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } +function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } +function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } +function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } var js2xliffClb = function js2xliffClb(obj, opt, cb) { if (!cb && typeof opt === 'function') { cb = opt; @@ -473,7 +413,6 @@ var js2xliffClb = function js2xliffClb(obj, opt, cb) { indent: ' ' }; } - opt = opt || { indent: ' ' }; @@ -486,6 +425,12 @@ var js2xliffClb = function js2xliffClb(obj, opt, cb) { srcLang: obj.sourceLanguage, trgLang: obj.targetLanguage }; + var hasSizeRestriction = !!Object.keys(obj.resources).find(function (nsName) { + return Object.keys(obj.resources[nsName]).find(function (k) { + return obj.resources[nsName][k].additionalAttributes && (obj.resources[nsName][k].additionalAttributes.sizeRestriction !== undefined || obj.resources[nsName][k].additionalAttributes['slr:sizeRestriction'] !== undefined); + }); + }); + if (hasSizeRestriction) rootAttributes['xmlns:slr'] = 'urn:oasis:names:tc:xliff:sizerestriction:2.0'; var root = (0, _objectToXml.makeElement)('xliff', rootAttributes, true); Object.keys(obj.resources).forEach(function (nsName) { var fileChildren = createUnitTags(obj.resources[nsName]); @@ -497,23 +442,41 @@ var js2xliffClb = function js2xliffClb(obj, opt, cb) { var xmlJs = { elements: [root] }; - var xml = _xmlJs.default.js2xml(xmlJs, options); - if (cb) cb(null, xml); return xml; }; - function createUnitTags(unitElements) { - return Object.keys(unitElements).map(function (key) { + var hasSizeRestriction = !!Object.keys(unitElements).find(function (k) { + return unitElements[k].additionalAttributes && (unitElements[k].additionalAttributes.sizeRestriction !== undefined || unitElements[k].additionalAttributes['slr:sizeRestriction'] !== undefined); + }); + var preElements = []; + if (hasSizeRestriction) { + preElements.push({ + type: 'element', + name: 'slr:profiles', + attributes: { + generalProfile: 'xliff:codepoints', + storageProfile: 'xliff:utf8' + }, + elements: [{ + type: 'element', + name: 'slr:normalization', + attributes: { + general: 'nfc', + storage: 'nfc' + } + }] + }); + } + return preElements.concat(Object.keys(unitElements).map(function (key) { if (unitElements[key].groupUnits) { return createGroupUnitTag(key, unitElements[key]); } else { return createUnitTag(key, unitElements[key]); } - }); + })); } - function createGroupUnitTag(id, group) { var additionalAttributes = group.additionalAttributes != null ? group.additionalAttributes : {}; var groupUnits = createUnitTags(group.groupUnits); @@ -521,14 +484,12 @@ function createGroupUnitTag(id, group) { id: (0, _escape.default)(id) }, additionalAttributes), groupUnits); } - function createUnitTag(id, unit) { var segment = (0, _objectToXml.makeElement)('segment', null, true); if (!unit.source && unit.target) unit.source = ''; if (unit.source) segment.elements.push((0, _objectToXml.makeElement)('source', null, (0, _objectToXml.makeValue)(unit.source, _ElementTypes.default))); if (unit.target !== undefined) segment.elements.push((0, _objectToXml.makeElement)('target', null, (0, _objectToXml.makeValue)(unit.target, _ElementTypes.default))); var subEle = [segment]; - if ('note' in unit) { var noteElms = []; createNoteObjects(unit.note).forEach(function (noteObj) { @@ -536,17 +497,18 @@ function createUnitTag(id, unit) { }); subEle.unshift((0, _objectToXml.makeElement)('notes', null, noteElms)); } - - var additionalAttributes = unit.additionalAttributes != null ? unit.additionalAttributes : {}; + var additionalAttributes = unit.additionalAttributes != null ? _objectSpread({}, unit.additionalAttributes) : {}; + if (additionalAttributes.sizeRestriction) { + additionalAttributes['slr:sizeRestriction'] = additionalAttributes.sizeRestriction + ''; + delete additionalAttributes.sizeRestriction; + } return (0, _objectToXml.makeElement)('unit', Object.assign({ id: (0, _escape.default)(id) }, additionalAttributes), subEle); } - function createNoteObjects(note) { var arrNote = []; var baseNote = (0, _objectToXml.makeText)(note); - if (Array.isArray(baseNote.text)) { baseNote.text.forEach(function (text) { arrNote.push({ @@ -557,10 +519,8 @@ function createNoteObjects(note) { } else { arrNote.push(baseNote); } - return arrNote; } - var js2xliff = function js2xliff(obj, opt, cb) { if (!cb && opt === undefined) { return new Promise(function (resolve, reject) { @@ -569,7 +529,6 @@ var js2xliff = function js2xliff(obj, opt, cb) { }); }); } - if (!cb && typeof opt !== 'function') { return new Promise(function (resolve, reject) { return js2xliffClb(obj, opt, function (err, ret) { @@ -577,13 +536,10 @@ var js2xliff = function js2xliff(obj, opt, cb) { }); }); } - return js2xliffClb(obj, opt, cb); }; - js2xliff.js2xliffClb = js2xliffClb; -var _default = js2xliff; -exports.default = _default; +var _default = exports.default = js2xliff; module.exports = exports.default; },{"./inline-elements/ElementTypes2.js":7,"./util/escape.js":15,"./xml-js/objectToXml.js":18,"xml-js":47}],11:[function(require,module,exports){ "use strict"; @@ -592,17 +548,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; - var _xmlJs = _interopRequireDefault(require("xml-js")); - var _ElementTypes = _interopRequireDefault(require("./inline-elements/ElementTypes12.js")); - var _objectToXml = require("./xml-js/objectToXml.js"); - var _escape = _interopRequireDefault(require("./util/escape.js")); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - var jsToXliff12Clb = function jsToXliff12Clb(obj, opt, cb) { if (!cb && typeof opt === 'function') { cb = opt; @@ -610,7 +560,6 @@ var jsToXliff12Clb = function jsToXliff12Clb(obj, opt, cb) { indent: ' ' }; } - opt = opt || { indent: ' ' }; @@ -633,24 +582,19 @@ var jsToXliff12Clb = function jsToXliff12Clb(obj, opt, cb) { datatype: 'plaintext', 'source-language': obj.sourceLanguage }; - if (obj.targetLanguage != null) { fileAttributes['target-language'] = obj.targetLanguage; } - var f = (0, _objectToXml.makeElement)('file', fileAttributes, [b]); root.elements.push(f); }); var xmlJs = { elements: [root] }; - var xml = _xmlJs.default.js2xml(xmlJs, options); - if (cb) cb(null, xml); return xml; }; - function createUnitTags(unitElements, obj, options) { return Object.keys(unitElements).map(function (key) { if (unitElements[key].groupUnits) { @@ -660,7 +604,6 @@ function createUnitTags(unitElements, obj, options) { } }); } - function createGroupUnitTag(key, resource, obj, options) { var additionalAttributes = resource.additionalAttributes != null ? resource.additionalAttributes : {}; var groupUnits = createUnitTags(resource.groupUnits, obj, options); @@ -668,48 +611,38 @@ function createGroupUnitTag(key, resource, obj, options) { id: (0, _escape.default)(key) }, additionalAttributes), groupUnits); } - function createTransUnitTag(key, resource, obj, options) { var additionalAttributes = resource.additionalAttributes != null ? resource.additionalAttributes : {}; var u = (0, _objectToXml.makeElement)('trans-unit', Object.assign({ id: (0, _escape.default)(key) }, additionalAttributes), true); var sourceAttributes = null; - if (options.xmlLangAttr) { sourceAttributes = { 'xml:lang': obj.sourceLanguage }; } - if (!resource.source && resource.target) resource.source = ''; if (resource.source) u.elements.push((0, _objectToXml.makeElement)('source', sourceAttributes, (0, _objectToXml.makeValue)(resource.source, _ElementTypes.default))); - if (resource.target != null) { var targetAttributes = null; - if (options.xmlLangAttr && obj.targetLanguage) { targetAttributes = { 'xml:lang': obj.targetLanguage }; } - u.elements.push((0, _objectToXml.makeElement)('target', targetAttributes, (0, _objectToXml.makeValue)(resource.target, _ElementTypes.default))); } - if ('note' in resource) { createNoteObjects(resource.note).forEach(function (noteObj) { u.elements.push((0, _objectToXml.makeElement)('note', null, [noteObj])); }); } - return u; } - function createNoteObjects(note) { var arrNote = []; var baseNote = (0, _objectToXml.makeText)(note); - if (Array.isArray(baseNote.text)) { baseNote.text.forEach(function (text) { arrNote.push({ @@ -720,10 +653,8 @@ function createNoteObjects(note) { } else { arrNote.push(baseNote); } - return arrNote; } - var jsToXliff12 = function jsToXliff12(obj, opt, cb) { if (!cb && opt === undefined) { return new Promise(function (resolve, reject) { @@ -732,7 +663,6 @@ var jsToXliff12 = function jsToXliff12(obj, opt, cb) { }); }); } - if (!cb && typeof opt !== 'function') { return new Promise(function (resolve, reject) { return jsToXliff12Clb(obj, opt, function (err, ret) { @@ -740,13 +670,10 @@ var jsToXliff12 = function jsToXliff12(obj, opt, cb) { }); }); } - return jsToXliff12Clb(obj, opt, cb); }; - jsToXliff12.jsToXliff12Clb = jsToXliff12Clb; -var _default = jsToXliff12; -exports.default = _default; +var _default = exports.default = jsToXliff12; module.exports = exports.default; },{"./inline-elements/ElementTypes12.js":6,"./util/escape.js":15,"./xml-js/objectToXml.js":18,"xml-js":47}],12:[function(require,module,exports){ "use strict"; @@ -755,11 +682,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = ofjs; - function ofjs(js, what, cb) { var res = {}; var nsKeys = Object.keys(js.resources || {}); - if (nsKeys.length === 1) { var ns = js.resources[nsKeys[0]]; var keys = Object.keys(ns); @@ -771,7 +696,6 @@ function ofjs(js, what, cb) { if (cb) return cb(null, res); return res; } - nsKeys.forEach(function (nsKey) { res[nsKey] = {}; var ns = js.resources[nsKey]; @@ -784,10 +708,8 @@ function ofjs(js, what, cb) { if (cb) return cb(null, res); return res; } - function getSegment(category, what) { var value = category[what]; - if (value === undefined && category.groupUnits) { value = {}; var groupKeys = Object.keys(category.groupUnits); @@ -796,10 +718,8 @@ function getSegment(category, what) { if (groupValue !== undefined) value[groupKey] = groupValue; }); } - return value; } - module.exports = exports.default; },{}],13:[function(require,module,exports){ "use strict"; @@ -808,15 +728,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = sourceOfjs; - var _ofjs = _interopRequireDefault(require("./ofjs.js")); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - function sourceOfjs(js, cb) { return (0, _ofjs.default)(js, 'source', cb); } - module.exports = exports.default; },{"./ofjs.js":12}],14:[function(require,module,exports){ "use strict"; @@ -825,15 +741,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = targetOfjs; - var _ofjs = _interopRequireDefault(require("./ofjs.js")); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - function targetOfjs(js, cb) { return (0, _ofjs.default)(js, 'target', cb); } - module.exports = exports.default; },{"./ofjs.js":12}],15:[function(require,module,exports){ "use strict"; @@ -849,14 +761,12 @@ var map = { '<': '<', '>': '>' }; - function _default(str) { Object.keys(map).forEach(function (char) { str = str.replace(new RegExp(char, 'g'), map[char]); }); return str; } - ; module.exports = exports.default; },{}],16:[function(require,module,exports){ @@ -866,45 +776,34 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = xliff12ToJs; - var _xmlJs = _interopRequireDefault(require("xml-js")); - var _ElementTypes = _interopRequireDefault(require("./inline-elements/ElementTypes12.js")); - var _xmlToObject = require("./xml-js/xmlToObject.js"); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - var xliff12ToJsClb = function xliff12ToJsClb(str, options, cb) { if (typeof options === 'function') { cb = options; options = {}; } - options = options || { captureSpacesBetweenElements: false }; - if (typeof str !== 'string') { var err = new Error('The first parameter was not a string'); if (cb) return cb(err); return err; } - var result = {}; var xmlObj; - try { xmlObj = _xmlJs.default.xml2js(str, options); } catch (err) { if (cb) return cb(err); return err; } - var xliffRoot = xmlObj.elements.find(function (ele) { return ele.name === 'xliff'; }); - if (xliffRoot.elements && xliffRoot.elements.length) { var elements = xliffRoot.elements.filter(function (e) { return e.type === 'element'; @@ -931,11 +830,9 @@ var xliff12ToJsClb = function xliff12ToJsClb(str, options, cb) { } else { result.resources = {}; } - if (cb) return cb(null, result); return result; }; - function createUnits(childElements) { return childElements.reduce(function (parent, child) { var key = child.attributes.id; @@ -943,66 +840,53 @@ function createUnits(childElements) { var children = child.elements.filter(function (e) { return e.name === 'trans-unit' || e.name === 'group'; }); - if (children.length) { parent[key] = createGroupTag(child, children); } else { parent[key] = createTransUnitTag(child); } - return parent; }, {}); } - function createTransUnitTag(transUnit) { var jsUnit = transUnit.elements.reduce(function (unit, element) { var value = (0, _xmlToObject.extractValue)(element.elements, _ElementTypes.default); - switch (element.name) { case 'source': case 'target': unit[element.name] = value; break; - case 'note': if (unit[element.name]) { if (!Array.isArray(unit[element.name])) { unit[element.name] = [unit[element.name]]; } - unit[element.name].push(value); } else { unit[element.name] = value; } - break; } - return unit; }, {}); return addAdditionalAttributes(jsUnit, transUnit.attributes); } - function createGroupTag(groupUnit, children) { var jsGroupUnit = { groupUnits: createUnits(children) }; return addAdditionalAttributes(jsGroupUnit, groupUnit.attributes); } - function addAdditionalAttributes(jsUnit, attributes) { var additionalAttributes = attributes; delete additionalAttributes.id; - if (Object.keys(additionalAttributes).length) { Object.assign(jsUnit, { additionalAttributes: additionalAttributes }); } - return jsUnit; } - function xliff12ToJs(str, options, cb) { if (!cb && options === undefined) { return new Promise(function (resolve, reject) { @@ -1011,7 +895,6 @@ function xliff12ToJs(str, options, cb) { }); }); } - if (!cb && typeof options !== 'function') { return new Promise(function (resolve, reject) { return xliff12ToJsClb(str, options, function (err, ret) { @@ -1019,10 +902,8 @@ function xliff12ToJs(str, options, cb) { }); }); } - xliff12ToJsClb(str, options, cb); } - module.exports = exports.default; },{"./inline-elements/ElementTypes12.js":6,"./xml-js/xmlToObject.js":19,"xml-js":47}],17:[function(require,module,exports){ "use strict"; @@ -1031,43 +912,32 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = xliffToJs; - var _xmlJs = _interopRequireDefault(require("xml-js")); - var _ElementTypes = _interopRequireDefault(require("./inline-elements/ElementTypes2.js")); - var _xmlToObject = require("./xml-js/xmlToObject.js"); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - var xliffToJsClb = function xliffToJsClb(str, options, cb) { if (typeof options === 'function') { cb = options; options = {}; } - options = options || {}; - if (typeof str !== 'string') { var err = new Error('The first parameter was not a string'); if (cb) return cb(err); return err; } - var result = {}; var xmlObj; - try { xmlObj = _xmlJs.default.xml2js(str, {}); } catch (err) { if (cb) return cb(err); return err; } - var xliffRoot = xmlObj.elements.find(function (ele) { return ele.name === 'xliff'; }); - if (xliffRoot.attributes) { var srcLang = xliffRoot.attributes.srcLang; var trgLang = xliffRoot.attributes.trgLang; @@ -1089,80 +959,70 @@ var xliffToJsClb = function xliffToJsClb(str, options, cb) { return resources; }, {}); } - if (cb) return cb(null, result); return result; }; - function createUnits(parent, initValues) { if (!parent.elements) return {}; return parent.elements.reduce(function (file, unit) { var key = unit.attributes.id; var additionalAttributes = unit.attributes; delete additionalAttributes.id; - + if (additionalAttributes['slr:sizeRestriction'] !== undefined) { + additionalAttributes.sizeRestriction = additionalAttributes['slr:sizeRestriction']; + if (typeof additionalAttributes.sizeRestriction === 'string') additionalAttributes.sizeRestriction = parseInt(additionalAttributes.sizeRestriction); + delete additionalAttributes['slr:sizeRestriction']; + } switch (unit.name) { case 'unit': file[key] = createUnit(unit, initValues); - if (Object.keys(additionalAttributes).length) { Object.assign(file[key], { additionalAttributes: additionalAttributes }); } - return file; - case 'group': file[key] = { groupUnits: createUnits(unit, initValues) }; - if (Object.keys(additionalAttributes).length) { Object.assign(file[key], { additionalAttributes: additionalAttributes }); } - return file; - default: return file; } }, {}); } - function createUnit(unit, initValues) { if (!unit.elements) return undefined; return unit.elements.reduce(function (unit, segment) { if (['segment', 'notes'].indexOf(segment.name) < 0) return unit; segment.elements.forEach(function (element) { var value = (0, _xmlToObject.extractValue)(element.elements, _ElementTypes.default); - switch (element.name) { case 'source': case 'target': unit[element.name] = value; break; - case 'note': if (unit[element.name]) { if (!Array.isArray(unit[element.name])) { unit[element.name] = [unit[element.name]]; } - unit[element.name].push(value); } else { unit[element.name] = value; } - break; } }); return unit; }, JSON.parse(JSON.stringify(initValues))); } - function xliffToJs(str, options, cb) { if (!cb && options === undefined) { return new Promise(function (resolve, reject) { @@ -1171,7 +1031,6 @@ function xliffToJs(str, options, cb) { }); }); } - if (!cb && typeof options !== 'function') { return new Promise(function (resolve, reject) { return xliffToJsClb(str, options, function (err, ret) { @@ -1179,10 +1038,8 @@ function xliffToJs(str, options, cb) { }); }); } - xliffToJsClb(str, options, cb); } - module.exports = exports.default; },{"./inline-elements/ElementTypes2.js":7,"./xml-js/xmlToObject.js":19,"xml-js":47}],18:[function(require,module,exports){ "use strict"; @@ -1193,44 +1050,35 @@ Object.defineProperty(exports, "__esModule", { exports.makeElement = makeElement; exports.makeText = makeText; exports.makeValue = makeValue; - var _typeToTagMaps = require("../inline-elements/typeToTagMaps.js"); - function makeElement(name, attributes, elements) { var el = { type: 'element', name: name }; - if (attributes !== null && attributes !== undefined) { el.attributes = attributes; } - if (Array.isArray(elements)) { el.elements = elements; } else if (elements === true) { el.elements = []; } - return el; } - function makeText(text) { return { type: 'text', text: text }; } - function makeValue(content, elementTypeInfo) { if (!Array.isArray(content)) { if (typeof content === 'string' || content instanceof String) { return [makeText(content)]; } - var elementType = Object.keys(content)[0]; var elementTag = (0, _typeToTagMaps.elementTypeToTag)(elementType, elementTypeInfo); - if (elementTag !== undefined) { var attrsSrc = Object.assign({}, content[elementType]); delete attrsSrc.id; @@ -1244,26 +1092,19 @@ function makeValue(content, elementTypeInfo) { }); return [makeElement(elementTag, attrs, contents)]; } - return [makeText(content)]; } - return content.map(function (segment) { if (typeof segment === 'string' || segment instanceof String) { return makeText(segment); } - var elementType = Object.keys(segment)[0]; var elementTag = (0, _typeToTagMaps.elementTypeToTag)(elementType, elementTypeInfo); - if (elementTag !== undefined) { var _attrsSrc = Object.assign({}, segment[elementType]); - delete _attrsSrc.id; delete _attrsSrc.contents; - var _contents = segment[elementType].hasOwnProperty('contents') ? makeValue(segment[elementType].contents, elementTypeInfo) : undefined; - var _attrs = { id: segment[elementType].id }; @@ -1272,7 +1113,6 @@ function makeValue(content, elementTypeInfo) { }); return makeElement(elementTag, _attrs, _contents); } - var segmentString = '{ ' + Object.keys(segment).reduce(function (result, segmentKey) { return result + segmentKey + ': "' + segment[segmentKey].toString() + '"'; }, '') + ' }'; @@ -1289,41 +1129,31 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.extractValue = extractValue; - var _typeToTagMaps = require("../inline-elements/typeToTagMaps.js"); - function extractValue(valueElements, elementTypeInfo) { if (valueElements === undefined || valueElements === null || valueElements === '') { return ''; } - if (Array.isArray(valueElements) && valueElements.length > 1) { return valueElements.map(function (valueElement) { return extractValue(valueElement, elementTypeInfo); }); } - var valueElement = Array.isArray(valueElements) ? valueElements[0] || '' : valueElements; - if (valueElement.type === 'text') { if (/\n\s*$/.test(valueElement.text)) { return valueElement.text.substr(0, valueElement.text.lastIndexOf('\n')); } - return valueElement.text; } - var elementType = (0, _typeToTagMaps.tagToElementType)(valueElement.name, elementTypeInfo); - if (valueElement.type === 'element' && elementType !== undefined) { var inlineElementFactory = elementTypeInfo.factories[elementType]; return inlineElementFactory(valueElement.attributes, extractValue(valueElement.elements, elementTypeInfo)); } - if (valueElement.type === 'cdata') { return valueElement.cdata; } - return ''; } },{"../inline-elements/typeToTagMaps.js":9}],20:[function(require,module,exports){ diff --git a/xliff.min.js b/xliff.min.js index 9a8777e..fa78577 100644 --- a/xliff.min.js +++ b/xliff.min.js @@ -1 +1 @@ -!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).xliff=e()}(function(){return function r(i,a,o){function s(t,e){if(!a[t]){if(!i[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(u)return u(t,!0);throw(n=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",n}n=a[t]={exports:{}},i[t][0].call(n.exports,function(e){return s(i[t][1][e]||e)},n,n.exports,r,i,a,o)}return a[t].exports}for(var u="function"==typeof require&&require,e=0;e":">"};t.exports=n.default},{}],16:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t,n){if(!n&&void 0===t)return new Promise(function(n,r){return i(e,t,function(e,t){return e?r(e):n(t)})});if(!n&&"function"!=typeof t)return new Promise(function(n,r){return i(e,t,function(e,t){return e?r(e):n(t)})});i(e,t,n)};var s=r(e("xml-js")),a=r(e("./inline-elements/ElementTypes12.js")),o=e("./xml-js/xmlToObject.js");function r(e){return e&&e.__esModule?e:{default:e}}var i=function(e,r,t){if("function"==typeof r&&(t=r,r={}),r=r||{captureSpacesBetweenElements:!1},"string"!=typeof e){var n=new Error("The first parameter was not a string");return t?t(n):n}var i={};try{a=s.default.xml2js(e,r)}catch(n){return t?t(n):n}var a,o=a.elements.find(function(e){return"xliff"===e.name});return o.elements&&o.elements.length?(a=(e=o.elements.filter(function(e){return"element"===e.type}))[0].attributes["source-language"]||o.attributes.srcLang,o=e[0].attributes["target-language"]||o.attributes.trgLang,i.sourceLanguage=a,i.targetLanguage=o,i.targetLanguage||delete i.targetLanguage,i.resources=e.reduce(function(e,t){var n=r.namespace||t.attributes.original,t=t.elements.filter(function(e){return"element"===e.type}).find(function(e){return"body"===e.name});t.elements=t.elements||[];t=t.elements.filter(function(e){return"comment"!==e.type&&"element"===e.type});return e[n]=u(t),e},{})):i.resources={},t?t(null,i):i};function u(e){return e.reduce(function(e,t){var n=t.attributes.id;if(!t.elements)return e;var r,i=t.elements.filter(function(e){return"trans-unit"===e.name||"group"===e.name});return i.length?e[n]=(r=t,l({groupUnits:u(i)},r.attributes)):e[n]=l((t=t).elements.reduce(function(e,t){var n=(0,o.extractValue)(t.elements,a.default);switch(t.name){case"source":case"target":e[t.name]=n;break;case"note":e[t.name]?(Array.isArray(e[t.name])||(e[t.name]=[e[t.name]]),e[t.name].push(n)):e[t.name]=n}return e},{}),t.attributes),e},{})}function l(e,t){return delete t.id,Object.keys(t).length&&Object.assign(e,{additionalAttributes:t}),e}t.exports=n.default},{"./inline-elements/ElementTypes12.js":6,"./xml-js/xmlToObject.js":19,"xml-js":47}],17:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t,n){if(!n&&void 0===t)return new Promise(function(n,r){return o(e,t,function(e,t){return e?r(e):n(t)})});if(!n&&"function"!=typeof t)return new Promise(function(n,r){return o(e,t,function(e,t){return e?r(e):n(t)})});o(e,t,n)};var s=a(e("xml-js")),r=a(e("./inline-elements/ElementTypes2.js")),i=e("./xml-js/xmlToObject.js");function a(e){return e&&e.__esModule?e:{default:e}}var o=function(e,i,t){if("function"==typeof i&&(t=i,i={}),i=i||{},"string"!=typeof e){var n=new Error("The first parameter was not a string");return t?t(n):n}var a={};try{r=s.default.xml2js(e,{})}catch(n){return t?t(n):n}var r,o=r.elements.find(function(e){return"xliff"===e.name});return o.attributes&&(e=o.attributes.srcLang,r=o.attributes.trgLang,a.sourceLanguage=e,a.targetLanguage=r,a.targetLanguage||delete a.targetLanguage,o.elements=o.elements.filter(function(e){return"comment"!==e.type}),a.resources=o.elements.reduce(function(e,t){var n=i.namespace||t.attributes.id,r={};return a.targetLanguage||delete r.target,t.elements=t.elements||[],t.elements=t.elements.filter(function(e){return"comment"!==e.type}),e[n]=function i(e,a){if(!e.elements)return{};return e.elements.reduce(function(e,t){var n=t.attributes.id,r=t.attributes;switch(delete r.id,t.name){case"unit":return e[n]=u(t,a),Object.keys(r).length&&Object.assign(e[n],{additionalAttributes:r}),e;case"group":return e[n]={groupUnits:i(t,a)},Object.keys(r).length&&Object.assign(e[n],{additionalAttributes:r}),e;default:return e}},{})}(t,r),e},{})),t?t(null,a):a};function u(e,t){if(e.elements)return e.elements.reduce(function(n,e){return["segment","notes"].indexOf(e.name)<0||e.elements.forEach(function(e){var t=(0,i.extractValue)(e.elements,r.default);switch(e.name){case"source":case"target":n[e.name]=t;break;case"note":n[e.name]?(Array.isArray(n[e.name])||(n[e.name]=[n[e.name]]),n[e.name].push(t)):n[e.name]=t}}),n},JSON.parse(JSON.stringify(t)))}t.exports=n.default},{"./inline-elements/ElementTypes2.js":7,"./xml-js/xmlToObject.js":19,"xml-js":47}],18:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.makeElement=l,n.makeText=f,n.makeValue=function o(e,s){if(!Array.isArray(e)){if("string"==typeof e||e instanceof String)return[f(e)];var t=Object.keys(e)[0],n=(0,u.elementTypeToTag)(t,s);if(void 0===n)return[f(e)];var r=Object.assign({},e[t]);delete r.id,delete r.contents;var i=e[t].hasOwnProperty("contents")?o(e[t].contents,s):void 0,a={id:e[t].id};return Object.keys(r).forEach(function(e){a[e]=r[e]}),[l(n,a,i)]}return e.map(function(n){if("string"==typeof n||n instanceof String)return f(n);var e=Object.keys(n)[0],t=(0,u.elementTypeToTag)(e,s);if(void 0!==t){var r=Object.assign({},n[e]);delete r.id,delete r.contents;var i=n[e].hasOwnProperty("contents")?o(n[e].contents,s):void 0,a={id:n[e].id};return Object.keys(r).forEach(function(e){a[e]=r[e]}),l(t,a,i)}i="{ "+Object.keys(n).reduce(function(e,t){return e+t+': "'+n[t].toString()+'"'},"")+" }";return{type:"comment",comment:"Warning: unexpected segment "+i+" was ignored"}})};var u=e("../inline-elements/typeToTagMaps.js");function l(e,t,n){e={type:"element",name:e};return null!=t&&(e.attributes=t),Array.isArray(n)?e.elements=n:!0===n&&(e.elements=[]),e}function f(e){return{type:"text",text:e}}},{"../inline-elements/typeToTagMaps.js":9}],19:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.extractValue=function t(e,n){if(null==e||""===e)return"";if(Array.isArray(e)&&1>16&255,a[o++]=t>>8&255,a[o++]=255&t;2===r&&(t=u[e.charCodeAt(n)]<<2|u[e.charCodeAt(n+1)]>>4,a[o++]=255&t);1===r&&(t=u[e.charCodeAt(n)]<<10|u[e.charCodeAt(n+1)]<<4|u[e.charCodeAt(n+2)]>>2,a[o++]=t>>8&255,a[o++]=255&t);return a},n.fromByteArray=function(e){for(var t,n=e.length,r=n%3,i=[],a=0,o=n-r;a>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}(r));return i.join("")}(e,a,o>2]+s[t<<4&63]+"==")):2==r&&(t=(e[n-2]<<8)+e[n-1],i.push(s[t>>10]+s[t>>4&63]+s[t<<2&63]+"="));return i.join("")};for(var s=[],u=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,a=r.length;i>>1;case"base64":return j(e).length;default:if(i)return r?-1:A(e).length;t=(""+t).toLowerCase(),i=!0}}function n(e,t,n){var r,i,a,o=!1;if((t=void 0===t||t<0?0:t)>this.length)return"";if((n=void 0===n||n>this.length?this.length:n)<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":return function(e,t,n){var r=e.length;(!t||t<0)&&(t=0);(!n||n<0||r=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:m(e,t,n,r,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?(i?Uint8Array.prototype.indexOf:Uint8Array.prototype.lastIndexOf).call(e,t,n):m(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,n,r,i){var a=1,o=e.length,s=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o/=a=2,s/=2,n/=2}function u(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i)for(var l=-1,f=n;f>8,r=r%256,i.push(r),i.push(n);return i}(t,e.length-n),e,n,r)}function b(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i>>10&1023|55296),f=56320|1023&f),r.push(f),i+=c}return function(e){var t=e.length;if(t<=v)return String.fromCharCode.apply(String,e);var n="",r=0;for(;rt&&(e+=" ... "),""},c.prototype.compare=function(e,t,n,r,i){if(N(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),(t=void 0===t?0:t)<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(i<=r&&n<=t)return 0;if(i<=r)return-1;if(n<=t)return 1;if(this===e)return 0;for(var a=(i>>>=0)-(r>>>=0),o=(n>>>=0)-(t>>>=0),s=Math.min(a,o),u=this.slice(r,i),l=e.slice(t,n),f=0;f>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||ithis.length)throw new RangeError("Attempt to write outside buffer bounds");r=r||"utf8";for(var a,o,s,u=!1;;)switch(r){case"hex":return function(e,t,n,r){n=Number(n)||0;var i=e.length-n;(!r||i<(r=Number(r)))&&(r=i),(i=t.length)/2e.length)throw new RangeError("Index out of range")}function w(e,t,n,r){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function T(e,t,n,r,i){return t=+t,n>>>=0,i||w(e,0,n,4),a.write(e,t,n,r,23,4),n+4}function S(e,t,n,r,i){return t=+t,n>>>=0,i||w(e,0,n,8),a.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n=this.length;(e=~~e)<0?(e+=n)<0&&(e=0):n>>=0,t>>>=0,n||E(e,t,this.length);for(var r=this[e],i=1,a=0;++a>>=0,t>>>=0,n||E(e,t,this.length);for(var r=this[e+--t],i=1;0>>=0,t||E(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||E(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||E(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||E(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||E(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||E(e,t,this.length);for(var r=this[e],i=1,a=0;++a>>=0,t>>>=0,n||E(e,t,this.length);for(var r=t,i=1,a=this[e+--r];0>>=0,t||E(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||E(e,2,this.length);e=this[e]|this[e+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(e,t){e>>>=0,t||E(e,2,this.length);e=this[e+1]|this[e]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||E(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||E(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return e>>>=0,t||E(e,4,this.length),a.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||E(e,4,this.length),a.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||E(e,8,this.length),a.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||E(e,8,this.length),a.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||_(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,a=0;for(this[t]=255&e;++a>>=0,n>>>=0,r||_(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,a=1;for(this[t+i]=255&e;0<=--i&&(a*=256);)this[t+i]=e/a&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeIntLE=function(e,t,n,r){e=+e,t>>>=0,r||_(this,e,t,n,(r=Math.pow(2,8*n-1))-1,-r);var i=0,a=1,o=0;for(this[t]=255&e;++i>0)-o&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){e=+e,t>>>=0,r||_(this,e,t,n,(r=Math.pow(2,8*n-1))-1,-r);var i=n-1,a=1,o=0;for(this[t+i]=255&e;0<=--i&&(a*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,1,127,-128),this[t]=255&(e=e<0?255+e+1:e),t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,4,2147483647,-2147483648),this[t]=(e=e<0?4294967295+e+1:e)>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeFloatLE=function(e,t,n){return T(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return T(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return S(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return S(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n=n||0,r||0===r||(r=this.length),t>=e.length&&(t=e.length),(r=0=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length);var i=(r=e.length-t>>=0,n=void 0===n?this.length:n>>>0,"number"==typeof(e=e||0))for(a=t;a>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return a}function j(e){return s.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(x,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function O(e,t,n,r){for(var i=0;i=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function N(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function R(e){return e!=e}}.call(this)}.call(this,L("buffer").Buffer)},{"base64-js":20,buffer:22,ieee754:24}],23:[function(e,t,n){"use strict";var r="object"==typeof Reflect?Reflect:null,u=r&&"function"==typeof r.apply?r.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};var i=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)},a=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(s,u){return new Promise(function(e,t){function n(e){s.removeListener(u,r),t(e)}function r(){"function"==typeof s.removeListener&&s.removeListener("error",n),e([].slice.call(arguments))}var i,a,o;g(s,u,r,{once:!0}),"error"!==u&&(a=n,o={once:!0},"function"==typeof(i=s).on&&g(i,"error",a,o))})},(o.EventEmitter=o).prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function l(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function f(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function c(e,t,n,r){var i,a;return l(n),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,n.listener||n),i=e._events),a=i[t]),void 0===a?(a=i[t]=n,++e._eventsCount):("function"==typeof a?a=i[t]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),0<(n=f(e))&&a.length>n&&!a.warned&&(a.warned=!0,(n=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit")).name="MaxListenersExceededWarning",n.emitter=e,n.type=t,n.count=a.length,n=n,console&&console.warn&&console.warn(n))),e}function d(e,t,n){e={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},t=function(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}.bind(e);return t.listener=n,e.wrapFn=t}function h(e,t,n){e=e._events;if(void 0===e)return[];t=e[t];return void 0===t?[]:"function"==typeof t?n?[t.listener||t]:[t]:n?function(e){for(var t=new Array(e.length),n=0;n>1,f=-7,c=n?i-1:0,d=n?-1:1,n=e[t+c];for(c+=d,a=n&(1<<-f)-1,n>>=-f,f+=s;0>=-f,f+=r;0>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:a-1,h=r?1:-1,a=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(r=Math.pow(2,-o))<1&&(o--,r*=2),2<=(t+=1<=o+f?c/r:c*Math.pow(2,1-f))*r&&(o++,r/=2),l<=o+f?(s=0,o=l):1<=o+f?(s=(t*r-1)*Math.pow(2,i),o+=f):(s=t*Math.pow(2,f-1)*Math.pow(2,i),o=0));8<=i;e[n+d]=255&s,d+=h,s/=256,i-=8);for(o=o<"===a?(x(t,"onsgmldeclaration",t.sgmlDecl),t.sgmlDecl="",t.state=T.TEXT):(v(a)&&(t.state=T.SGML_DECL_QUOTED),t.sgmlDecl+=a);continue;case T.SGML_DECL_QUOTED:a===t.q&&(t.state=T.SGML_DECL,t.q=""),t.sgmlDecl+=a;continue;case T.DOCTYPE:">"===a?(t.state=T.TEXT,x(t,"ondoctype",t.doctype),t.doctype=!0):(t.doctype+=a,"["===a?t.state=T.DOCTYPE_DTD:v(a)&&(t.state=T.DOCTYPE_QUOTED,t.q=a));continue;case T.DOCTYPE_QUOTED:t.doctype+=a,a===t.q&&(t.q="",t.state=T.DOCTYPE);continue;case T.DOCTYPE_DTD:t.doctype+=a,"]"===a?t.state=T.DOCTYPE:v(a)&&(t.state=T.DOCTYPE_DTD_QUOTED,t.q=a);continue;case T.DOCTYPE_DTD_QUOTED:t.doctype+=a,a===t.q&&(t.state=T.DOCTYPE_DTD,t.q="");continue;case T.COMMENT:"-"===a?t.state=T.COMMENT_ENDING:t.comment+=a;continue;case T.COMMENT_ENDING:"-"===a?(t.state=T.COMMENT_ENDED,t.comment=j(t.opt,t.comment),t.comment&&x(t,"oncomment",t.comment),t.comment=""):(t.comment+="-"+a,t.state=T.COMMENT);continue;case T.COMMENT_ENDED:">"!==a?(R(t,"Malformed comment"),t.comment+="--"+a,t.state=T.COMMENT):t.state=T.TEXT;continue;case T.CDATA:"]"===a?t.state=T.CDATA_ENDING:t.cdata+=a;continue;case T.CDATA_ENDING:"]"===a?t.state=T.CDATA_ENDING_2:(t.cdata+="]"+a,t.state=T.CDATA);continue;case T.CDATA_ENDING_2:">"===a?(t.cdata&&x(t,"oncdata",t.cdata),x(t,"onclosecdata"),t.cdata="",t.state=T.TEXT):"]"===a?t.cdata+="]":(t.cdata+="]]"+a,t.state=T.CDATA);continue;case T.PROC_INST:"?"===a?t.state=T.PROC_INST_ENDING:b(a)?t.state=T.PROC_INST_BODY:t.procInstName+=a;continue;case T.PROC_INST_BODY:if(!t.procInstBody&&b(a))continue;"?"===a?t.state=T.PROC_INST_ENDING:t.procInstBody+=a;continue;case T.PROC_INST_ENDING:">"===a?(x(t,"onprocessinginstruction",{name:t.procInstName,body:t.procInstBody}),t.procInstName=t.procInstBody="",t.state=T.TEXT):(t.procInstBody+="?"+a,t.state=T.PROC_INST_BODY);continue;case T.OPEN_TAG:E(m,a)?t.tagName+=a:(function(e){e.strict||(e.tagName=e.tagName[e.looseCase]());var t=e.tags[e.tags.length-1]||e,n=e.tag={name:e.tagName,attributes:{}};e.opt.xmlns&&(n.ns=t.ns);e.attribList.length=0,x(e,"onopentagstart",n)}(t),">"===a?k(t):"/"===a?t.state=T.OPEN_TAG_SLASH:(b(a)||R(t,"Invalid character in tag name"),t.state=T.ATTRIB));continue;case T.OPEN_TAG_SLASH:">"===a?(k(t,!0),I(t)):(R(t,"Forward-slash in opening tag not followed by >"),t.state=T.ATTRIB);continue;case T.ATTRIB:if(b(a))continue;">"===a?k(t):"/"===a?t.state=T.OPEN_TAG_SLASH:E(p,a)?(t.attribName=a,t.attribValue="",t.state=T.ATTRIB_NAME):R(t,"Invalid attribute name");continue;case T.ATTRIB_NAME:"="===a?t.state=T.ATTRIB_VALUE:">"===a?(R(t,"Attribute without value"),t.attribValue=t.attribName,C(t),k(t)):b(a)?t.state=T.ATTRIB_NAME_SAW_WHITE:E(m,a)?t.attribName+=a:R(t,"Invalid attribute name");continue;case T.ATTRIB_NAME_SAW_WHITE:if("="===a)t.state=T.ATTRIB_VALUE;else{if(b(a))continue;R(t,"Attribute without value"),t.tag.attributes[t.attribName]="",t.attribValue="",x(t,"onattribute",{name:t.attribName,value:""}),t.attribName="",">"===a?k(t):E(p,a)?(t.attribName=a,t.state=T.ATTRIB_NAME):(R(t,"Invalid attribute name"),t.state=T.ATTRIB)}continue;case T.ATTRIB_VALUE:if(b(a))continue;v(a)?(t.q=a,t.state=T.ATTRIB_VALUE_QUOTED):(R(t,"Unquoted attribute value"),t.state=T.ATTRIB_VALUE_UNQUOTED,t.attribValue=a);continue;case T.ATTRIB_VALUE_QUOTED:if(a!==t.q){"&"===a?t.state=T.ATTRIB_VALUE_ENTITY_Q:t.attribValue+=a;continue}C(t),t.q="",t.state=T.ATTRIB_VALUE_CLOSED;continue;case T.ATTRIB_VALUE_CLOSED:b(a)?t.state=T.ATTRIB:">"===a?k(t):"/"===a?t.state=T.OPEN_TAG_SLASH:E(p,a)?(R(t,"No whitespace between attributes"),t.attribName=a,t.attribValue="",t.state=T.ATTRIB_NAME):R(t,"Invalid attribute name");continue;case T.ATTRIB_VALUE_UNQUOTED:if(!function(e){return">"===e||b(e)}(a)){"&"===a?t.state=T.ATTRIB_VALUE_ENTITY_U:t.attribValue+=a;continue}C(t),">"===a?k(t):t.state=T.ATTRIB;continue;case T.CLOSE_TAG:if(t.tagName)">"===a?I(t):E(m,a)?t.tagName+=a:t.script?(t.script+=""===a?I(t):R(t,"Invalid characters in closing tag");continue;case T.TEXT_ENTITY:case T.ATTRIB_VALUE_ENTITY_Q:case T.ATTRIB_VALUE_ENTITY_U:switch(t.state){case T.TEXT_ENTITY:n=T.TEXT,r="textNode";break;case T.ATTRIB_VALUE_ENTITY_Q:n=T.ATTRIB_VALUE_QUOTED,r="attribValue";break;case T.ATTRIB_VALUE_ENTITY_U:n=T.ATTRIB_VALUE_UNQUOTED,r="attribValue"}";"===a?(t[r]+=function(e){var t,n=e.entity,r=n.toLowerCase(),i="";if(e.ENTITIES[n])return e.ENTITIES[n];if(e.ENTITIES[r])return e.ENTITIES[r];"#"===(n=r).charAt(0)&&(i="x"===n.charAt(1)?(n=n.slice(2),(t=parseInt(n,16)).toString(16)):(n=n.slice(1),(t=parseInt(n,10)).toString(10)));if(n=n.replace(/^0+/,""),isNaN(t)||i.toLowerCase()!==n)return R(e,"Invalid character entity"),"&"+e.entity+";";return String.fromCodePoint(t)}(t),t.entity="",t.state=n):E(t.entity.length?y:g,a)?t.entity+=a:(R(t,"Invalid character in entity name"),t[r]+="&"+t.entity+a,t.entity="",t.state=n);continue;default:throw new Error(t,"Unknown state: "+t.state)}t.position>=t.bufferCheckPosition&&function(e){for(var t=Math.max(s.MAX_BUFFER_LENGTH,10),n=0,r=0,i=u.length;r",lt:"<",quot:'"',apos:"'"},s.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(s.ENTITIES).forEach(function(e){var t=s.ENTITIES[e],t="number"==typeof t?String.fromCharCode(t):t;s.ENTITIES[e]=t}),s.STATE)s.STATE[s.STATE[e]]=e;function S(e,t,n){e[t]&&e[t](n)}function x(e,t,n){e.textNode&&A(e),S(e,t,n)}function A(e){e.textNode=j(e.opt,e.textNode),e.textNode&&S(e,"ontext",e.textNode),e.textNode=""}function j(e,t){return e.trim&&(t=t.trim()),t=e.normalize?t.replace(/\s+/g," "):t}function O(e,t){return A(e),e.trackPosition&&(t+="\nLine: "+e.line+"\nColumn: "+e.column+"\nChar: "+e.c),t=new Error(t),e.error=t,S(e,"onerror",t),e}function N(e){return e.sawRoot&&!e.closedRoot&&R(e,"Unclosed root tag"),e.state!==T.BEGIN&&e.state!==T.BEGIN_WHITESPACE&&e.state!==T.TEXT&&O(e,"Unexpected end"),A(e),e.c="",e.closed=!0,S(e,"onend"),i.call(e,e.strict,e.opt),e}function R(e,t){if("object"!=typeof e||!(e instanceof i))throw new Error("bad call to strictFail");e.strict&&O(e,t)}function L(e,t){var n=e.indexOf(":")<0?["",e]:e.split(":"),r=n[0],n=n[1];return t&&"xmlns"===e&&(r="xmlns",n=""),{prefix:r,local:n}}function C(e){var t,n,r;e.strict||(e.attribName=e.attribName[e.looseCase]()),-1!==e.attribList.indexOf(e.attribName)||e.tag.attributes.hasOwnProperty(e.attribName)||(e.opt.xmlns?(r=(n=L(e.attribName,!0)).prefix,t=n.local,"xmlns"===r&&("xml"===t&&e.attribValue!==c?R(e,"xml: prefix must be bound to "+c+"\nActual: "+e.attribValue):"xmlns"===t&&e.attribValue!==d?R(e,"xmlns: prefix must be bound to "+d+"\nActual: "+e.attribValue):(n=e.tag,r=e.tags[e.tags.length-1]||e,n.ns===r.ns&&(n.ns=Object.create(r.ns)),n.ns[t]=e.attribValue)),e.attribList.push([e.attribName,e.attribValue])):(e.tag.attributes[e.attribName]=e.attribValue,x(e,"onattribute",{name:e.attribName,value:e.attribValue}))),e.attribName=e.attribValue=""}function k(t,e){if(t.opt.xmlns){var n=t.tag,r=L(t.tagName);n.prefix=r.prefix,n.local=r.local,n.uri=n.ns[r.prefix]||"",n.prefix&&!n.uri&&(R(t,"Unbound namespace prefix: "+JSON.stringify(t.tagName)),n.uri=r.prefix);r=t.tags[t.tags.length-1]||t;n.ns&&r.ns!==n.ns&&Object.keys(n.ns).forEach(function(e){x(t,"onopennamespace",{prefix:e,uri:n.ns[e]})});for(var i=0,a=t.attribList.length;i",n.tagName="",void(n.state=T.SCRIPT);x(n,"onscript",n.script),n.script=""}for(var e=n.tags.length,t=n.tagName,r=t=!n.strict?t[n.looseCase]():t;e--;){if(n.tags[e].name===r)break;R(n,"Unexpected close tag")}if(e<0)return R(n,"Unmatched closing tag: "+n.tagName),n.textNode+="",void(n.state=T.TEXT);n.tagName=t;for(var i=n.tags.length;i-- >e;){var a=n.tag=n.tags.pop();n.tagName=n.tag.name,x(n,"onclosetag",n.tagName);var o,s={};for(o in a.ns)s[o]=a.ns[o];var u=n.tags[n.tags.length-1]||n;n.opt.xmlns&&a.ns!==u.ns&&Object.keys(a.ns).forEach(function(e){var t=a.ns[e];x(n,"onclosenamespace",{prefix:e,uri:t})})}0===e&&(n.closedRoot=!0),n.tagName=n.attribValue=n.attribName="",n.attribList.length=0,n.state=T.TEXT}function F(e,t){"<"===t?(e.state=T.OPEN_WAKA,e.startTagPosition=e.position):b(t)||(R(e,"Non-whitespace before first tag."),e.textNode=t,e.state=T.TEXT)}function M(e,t){var n="";return n=t>10),i%1024+56320)),(t+1===n||16384a.length)&&(s=a.length),t=a.substring(s-o.length,s)===o?"The ".concat(e," ").concat(r," ").concat(u(t,"type")):(i=(i="number"!=typeof i?0:i)+(s=".").length>(o=e).length||-1===o.indexOf(s,i)?"argument":"property",'The "'.concat(e,'" ').concat(i," ").concat(r," ").concat(u(t,"type"))),t+=". Received type ".concat(typeof n)},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=r},{}],31:[function(f,c,e){!function(l){!function(){"use strict";var e=Object.keys||function(e){var t,n=[];for(t in e)n.push(t);return n};c.exports=o;var t=f("./_stream_readable"),n=f("./_stream_writable");f("inherits")(o,t);for(var r=e(n.prototype),i=0;it.highWaterMark&&(t.highWaterMark=(T<=(n=e)?n=T:(n--,n|=n>>>1,n|=n>>>2,n|=n>>>4,n|=n>>>8,n|=n>>>16,n++),n)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0));var n}function x(e){var t=e._readableState;m("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(m("emitReadable",t.flowing),t.emittedReadable=!0,P.nextTick(A,e))}function A(e){var t=e._readableState;m("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,C(e)}function j(e,t){t.readingMore||(t.readingMore=!0,P.nextTick(O,e,t))}function O(e,t){for(;!t.reading&&!t.ended&&(t.length=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function I(e){var t=e._readableState;m("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,P.nextTick(F,t,e))}function F(e,t){m("endReadableNT",e.endEmitted,e.length),e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"),!e.autoDestroy||(!(e=t._writableState)||e.autoDestroy&&e.finished)&&t.destroy())}function M(e,t){for(var n=0,r=e.length;n=t.highWaterMark:0>>0),i=this.head,a=0;i;)t=i.data,n=a,s.prototype.copy.call(t,r,n),a+=i.data.length,i=i.next;return r}},{key:"consume",value:function(e,t){var n;return ei.length?i.length:e;if(a===i.length?r+=i:r+=i.slice(0,e),0===(e-=a)){a===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t).data=i.slice(a);break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=s.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var i=n.data,a=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,a),0===(e-=a)){a===i.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n).data=i.slice(a);break}++r}return this.length-=r,t}},{key:l,value:function(e,t){return u(this,i({},t,{depth:0,customInspect:!1}))}}])&&o(t.prototype,n),r&&o(t,r),e}()},{buffer:22,util:21}],38:[function(e,t,n){!function(u){!function(){"use strict";function a(e,t){s(e,t),o(e)}function o(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function s(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var n=this,r=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return r||i?t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,u.nextTick(s,this,e)):u.nextTick(s,this,e)):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?n._writableState?n._writableState.errorEmitted?u.nextTick(o,n):(n._writableState.errorEmitted=!0,u.nextTick(a,n,e)):u.nextTick(a,n,e):t?(u.nextTick(o,n),t(e)):u.nextTick(o,n)})),this},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}}}.call(this)}.call(this,e("_process"))},{_process:26}],39:[function(e,t,n){"use strict";var y=e("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function b(){}t.exports=function e(t,n,r){if("function"==typeof n)return e(t,null,n);var i,a;i=r||b,a=!1,r=function(){if(!a){a=!0;for(var e=arguments.length,t=new Array(e),n=0;n>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function u(e){var t,n,r=this.lastTotal-this.lastNeed,t=(t=this,128!=(192&(n=e)[0])?(t.lastNeed=0,"�"):1"}function p(e,t,n){if(t.ignoreInstruction)return"";for(var r in e)if(e.hasOwnProperty(r))break;var i="instructionNameFn"in t?t.instructionNameFn(r,e[r],l,u):r;if("object"==typeof e[r])return"";n=e[r]||"";return""}function m(e,t){return t.ignoreComment?"":"\x3c!--"+("commentFn"in t?t.commentFn(e,l,u):e)+"--\x3e"}function g(e,t){return t.ignoreCdata?"":"","]]]]>"))+"]]>"}function y(e,t){return t.ignoreDoctype?"":""}function b(e,t){return t.ignoreText?"":(e=(e=(e=""+e).replace(/&/g,"&")).replace(/&/g,"&").replace(//g,">"),"textFn"in t?t.textFn(e,l,u):e)}function s(e,t,n){l=(u=e).name;var r=[],i="elementNameFn"in t?t.elementNameFn(e.name,e):e.name;r.push("<"+i),e[t.attributesKey]&&r.push(d(e[t.attributesKey],t,n));var a=e[t.elementsKey]&&e[t.elementsKey].length||e[t.attributesKey]&&"preserve"===e[t.attributesKey]["xml:space"];return(a=a||("fullTagEmptyElementFn"in t?t.fullTagEmptyElementFn(e.name,e):t.fullTagEmptyElement))?(r.push(">"),e[t.elementsKey]&&e[t.elementsKey].length&&(r.push(o(e[t.elementsKey],t,n+1)),l=(u=e).name),r.push(t.spaces&&function(e,t){var n;if(e.elements&&e.elements.length)for(n=0;n")):r.push("/>"),r.join("")}function o(e,i,a,o){return e.reduce(function(e,t){var n=c(i,a,o&&!e);switch(t.type){case"element":return e+n+s(t,i,a);case"comment":return e+n+m(t[i.commentKey],i);case"doctype":return e+n+y(t[i.doctypeKey],i);case"cdata":return e+(i.indentCdata?n:"")+g(t[i.cdataKey],i);case"text":return e+(i.indentText?n:"")+b(t[i.textKey],i);case"instruction":var r={};return r[t[i.nameKey]]=t[i.attributesKey]?t:t[i.instructionKey],e+(i.indentInstruction?n:"")+p(r,i,a)}},"")}function v(e,t,n){for(var r in e)if(e.hasOwnProperty(r))switch(r){case t.parentKey:case t.attributesKey:break;case t.textKey:if(t.indentText||n)return!0;break;case t.cdataKey:if(t.indentCdata||n)return!0;break;case t.instructionKey:if(t.indentInstruction||n)return!0;break;case t.doctypeKey:case t.commentKey:default:return!0}return!1}function E(e,t,n,r){var i,a,o,s=[];for(a in e)if(e.hasOwnProperty(a))for(o=f(e[a])?e[a]:[e[a]],i=0;i":"<"+a+"/>";var o=[];if(t){if(o.push("<"+a),"object"!=typeof e)return o.push(">"+b(e,n)+""),o.join("");e[n.attributesKey]&&o.push(d(e[n.attributesKey],n,r));var s=v(e,n,!0)||e[n.attributesKey]&&"preserve"===e[n.attributesKey]["xml:space"];if(!(s=s||("fullTagEmptyElementFn"in n?n.fullTagEmptyElementFn(t,e):n.fullTagEmptyElement)))return o.push("/>"),o.join("");o.push(">")}return o.push(E(e,n,r+1,!1)),u=e,(l=t)&&o.push((i?c(n,r,!1):"")+""),o.join("")}(o[i],a,t,n,v(o[i],t)))}r=r&&!s.length}return s.join("")}t.exports=function(e,t){var n;n=t,n=i.copyOptions(n),i.ensureFlagExists("ignoreDeclaration",n),i.ensureFlagExists("ignoreInstruction",n),i.ensureFlagExists("ignoreAttributes",n),i.ensureFlagExists("ignoreText",n),i.ensureFlagExists("ignoreComment",n),i.ensureFlagExists("ignoreCdata",n),i.ensureFlagExists("ignoreDoctype",n),i.ensureFlagExists("compact",n),i.ensureFlagExists("indentText",n),i.ensureFlagExists("indentCdata",n),i.ensureFlagExists("indentAttributes",n),i.ensureFlagExists("indentInstruction",n),i.ensureFlagExists("fullTagEmptyElement",n),i.ensureFlagExists("noQuotesForNativeAttributes",n),i.ensureSpacesExists(n),"number"==typeof n.spaces&&(n.spaces=Array(n.spaces+1).join(" ")),i.ensureKeyExists("declaration",n),i.ensureKeyExists("instruction",n),i.ensureKeyExists("attributes",n),i.ensureKeyExists("text",n),i.ensureKeyExists("comment",n),i.ensureKeyExists("cdata",n),i.ensureKeyExists("doctype",n),i.ensureKeyExists("type",n),i.ensureKeyExists("name",n),i.ensureKeyExists("elements",n),i.checkFnExists("doctype",n),i.checkFnExists("instruction",n),i.checkFnExists("cdata",n),i.checkFnExists("comment",n),i.checkFnExists("text",n),i.checkFnExists("instructionName",n),i.checkFnExists("elementName",n),i.checkFnExists("attributeName",n),i.checkFnExists("attributeValue",n),i.checkFnExists("attributes",n),i.checkFnExists("fullTagEmptyElement",n);var r=[];return u=e,l="_root_",(t=n).compact?r.push(E(e,t,0,!0)):(e[t.declarationKey]&&r.push(h(e[t.declarationKey],t,0)),e[t.elementsKey]&&e[t.elementsKey].length&&r.push(o(e[t.elementsKey],t,0,!r.length))),r.join("")}},{"./array-helper":46,"./options-helper":50}],49:[function(e,t,n){!function(i){!function(){var r=e("./js2xml.js");t.exports=function(e,t){var n=null;if("string"==typeof(e=e instanceof i?e.toString():e))try{n=JSON.parse(e)}catch(e){throw new Error("The JSON structure is invalid")}else n=e;return r(n,t)}}.call(this)}.call(this,e("buffer").Buffer)},{"./js2xml.js":48,buffer:22}],50:[function(e,t,n){var r=e("./array-helper").isArray;t.exports={copyOptions:function(e){var t,n={};for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n},ensureFlagExists:function(e,t){e in t&&"boolean"==typeof t[e]||(t[e]=!1)},ensureSpacesExists:function(e){"spaces"in e&&("number"==typeof e.spaces||"string"==typeof e.spaces)||(e.spaces=0)},ensureAlwaysArrayExists:function(e){"alwaysArray"in e&&("boolean"==typeof e.alwaysArray||r(e.alwaysArray))||(e.alwaysArray=!1)},ensureKeyExists:function(e,t){e+"Key"in t&&"string"==typeof t[e+"Key"]||(t[e+"Key"]=t.compact?"_"+e:e)},checkFnExists:function(e,t){return e+"Fn"in t}}},{"./array-helper":46}],51:[function(e,t,n){var a,o,i=e("sax"),s=e("./options-helper"),u=e("./array-helper").isArray;function r(e){var t=Number(e);if(!isNaN(t))return t;t=e.toLowerCase();return"true"===t||"false"!==t&&e}function l(e,t){var n,r;if(a.compact){if(!o[a[e+"Key"]]&&(u(a.alwaysArray)?-1!==a.alwaysArray.indexOf(a[e+"Key"]):a.alwaysArray)&&(o[a[e+"Key"]]=[]),o[a[e+"Key"]]&&!u(o[a[e+"Key"]])&&(o[a[e+"Key"]]=[o[a[e+"Key"]]]),e+"Fn"in a&&"string"==typeof t&&(t=a[e+"Fn"](t,o)),"instruction"===e&&("instructionFn"in a||"instructionNameFn"in a))for(n in t)t.hasOwnProperty(n)&&("instructionFn"in a?t[n]=a.instructionFn(t[n],n,o):(r=t[n],delete t[n],t[a.instructionNameFn(n,r,o)]=r));u(o[a[e+"Key"]])?o[a[e+"Key"]].push(t):o[a[e+"Key"]]=t}else{o[a.elementsKey]||(o[a.elementsKey]=[]);var i={};if("instruction"===(i[a.typeKey]=e)){for(n in t)if(t.hasOwnProperty(n))break;i[a.nameKey]="instructionNameFn"in a?a.instructionNameFn(n,t,o):n,a.instructionHasAttributes?(i[a.attributesKey]=t[n][a.attributesKey],"instructionFn"in a&&(i[a.attributesKey]=a.instructionFn(i[a.attributesKey],n,o))):("instructionFn"in a&&(t[n]=a.instructionFn(t[n],n,o)),i[a.instructionKey]=t[n])}else e+"Fn"in a&&(t=a[e+"Fn"](t,o)),i[a[e+"Key"]]=t;a.addParent&&(i[a.parentKey]=o),o[a.elementsKey].push(i)}}function f(e){var t,n;if("attributesFn"in a&&e&&(e=a.attributesFn(e,o)),(a.trim||"attributeValueFn"in a||"attributeNameFn"in a||a.nativeTypeAttributes)&&e)for(t in e)e.hasOwnProperty(t)&&(a.trim&&(e[t]=e[t].trim()),a.nativeTypeAttributes&&(e[t]=r(e[t])),"attributeValueFn"in a&&(e[t]=a.attributeValueFn(e[t],t,o)),"attributeNameFn"in a&&(n=e[t],delete e[t],e[a.attributeNameFn(t,e[t],o)]=n));return e}function c(e){var t,n={};if(e.body&&("xml"===e.name.toLowerCase()||a.instructionHasAttributes)){for(var r,i=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g;null!==(r=i.exec(e.body));)n[r[1]]=r[2]||r[3]||r[4];n=f(n)}"xml"===e.name.toLowerCase()?a.ignoreDeclaration||(o[a.declarationKey]={},Object.keys(n).length&&(o[a.declarationKey][a.attributesKey]=n),a.addParent&&(o[a.declarationKey][a.parentKey]=o)):a.ignoreInstruction||(a.trim&&(e.body=e.body.trim()),t={},a.instructionHasAttributes&&Object.keys(n).length?(t[e.name]={},t[e.name][a.attributesKey]=n):t[e.name]=e.body,l("instruction",t))}function d(e,t){if("object"==typeof e&&(t=e.attributes,e=e.name),t=f(t),"elementNameFn"in a&&(e=a.elementNameFn(e,o)),a.compact){var n,r={};if(!a.ignoreAttributes&&t&&Object.keys(t).length)for(n in r[a.attributesKey]={},t)t.hasOwnProperty(n)&&(r[a.attributesKey][n]=t[n]);e in o||(u(a.alwaysArray)?-1===a.alwaysArray.indexOf(e):!a.alwaysArray)||(o[e]=[]),o[e]&&!u(o[e])&&(o[e]=[o[e]]),u(o[e])?o[e].push(r):o[e]=r}else o[a.elementsKey]||(o[a.elementsKey]=[]),(r={})[a.typeKey]="element",r[a.nameKey]=e,!a.ignoreAttributes&&t&&Object.keys(t).length&&(r[a.attributesKey]=t),a.alwaysChildren&&(r[a.elementsKey]=[]),o[a.elementsKey].push(r);r[a.parentKey]=o,o=r}function h(e){a.ignoreText||(e.trim()||a.captureSpacesBetweenElements)&&(a.trim&&(e=e.trim()),a.nativeType&&(e=r(e)),l("text",e=a.sanitize?e.replace(/&/g,"&").replace(//g,">"):e))}function p(e){a.ignoreComment||l("comment",e=a.trim?e.trim():e)}function m(e){var t=o[a.parentKey];a.addParent||delete o[a.parentKey],o=t}function g(e){a.ignoreCdata||l("cdata",e=a.trim?e.trim():e)}function y(e){a.ignoreDoctype||(e=e.replace(/^ /,""),l("doctype",e=a.trim?e.trim():e))}function b(e){e.note=e}t.exports=function(e,t){var n=i.parser(!0,{}),r={};return o=r,a=s.copyOptions(t),s.ensureFlagExists("ignoreDeclaration",a),s.ensureFlagExists("ignoreInstruction",a),s.ensureFlagExists("ignoreAttributes",a),s.ensureFlagExists("ignoreText",a),s.ensureFlagExists("ignoreComment",a),s.ensureFlagExists("ignoreCdata",a),s.ensureFlagExists("ignoreDoctype",a),s.ensureFlagExists("compact",a),s.ensureFlagExists("alwaysChildren",a),s.ensureFlagExists("addParent",a),s.ensureFlagExists("trim",a),s.ensureFlagExists("nativeType",a),s.ensureFlagExists("nativeTypeAttributes",a),s.ensureFlagExists("sanitize",a),s.ensureFlagExists("instructionHasAttributes",a),s.ensureFlagExists("captureSpacesBetweenElements",a),s.ensureAlwaysArrayExists(a),s.ensureKeyExists("declaration",a),s.ensureKeyExists("instruction",a),s.ensureKeyExists("attributes",a),s.ensureKeyExists("text",a),s.ensureKeyExists("comment",a),s.ensureKeyExists("cdata",a),s.ensureKeyExists("doctype",a),s.ensureKeyExists("type",a),s.ensureKeyExists("name",a),s.ensureKeyExists("elements",a),s.ensureKeyExists("parent",a),s.checkFnExists("doctype",a),s.checkFnExists("instruction",a),s.checkFnExists("cdata",a),s.checkFnExists("comment",a),s.checkFnExists("text",a),s.checkFnExists("instructionName",a),s.checkFnExists("elementName",a),s.checkFnExists("attributeName",a),s.checkFnExists("attributeValue",a),s.checkFnExists("attributes",a),n.opt={strictEntities:!0},n.onopentag=d,n.ontext=h,n.oncomment=p,n.onclosetag=m,n.onerror=b,n.oncdata=g,n.ondoctype=y,n.onprocessinginstruction=c,n.write(e).close(),r[a.elementsKey]&&(e=r[a.elementsKey],delete r[a.elementsKey],r[a.elementsKey]=e,delete r.text),r}},{"./array-helper":46,"./options-helper":50,sax:28}],52:[function(e,t,n){var r=e("./options-helper"),i=e("./xml2js");t.exports=function(e,t){var n;return t=t,t=r.copyOptions(t),r.ensureSpacesExists(t),t=i(e,e=t),n="compact"in e&&e.compact?"_parent":"parent",("addParent"in e&&e.addParent?JSON.stringify(t,function(e,t){return e===n?"_":t},e.spaces):JSON.stringify(t,null,e.spaces)).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}},{"./options-helper":50,"./xml2js":51}]},{},[4])(4)}); \ No newline at end of file +!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).xliff=e()}(function(){return function r(i,a,o){function s(t,e){if(!a[t]){if(!i[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(u)return u(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}n=a[t]={exports:{}},i[t][0].call(n.exports,function(e){return s(i[t][1][e]||e)},n,n.exports,r,i,a,o)}return a[t].exports}for(var u="function"==typeof require&&require,e=0;e":">"};t.exports=n.default},{}],16:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t,n){if(!n&&void 0===t)return new Promise(function(n,r){return i(e,t,function(e,t){return e?r(e):n(t)})});if(!n&&"function"!=typeof t)return new Promise(function(n,r){return i(e,t,function(e,t){return e?r(e):n(t)})});i(e,t,n)};var s=r(e("xml-js")),a=r(e("./inline-elements/ElementTypes12.js")),o=e("./xml-js/xmlToObject.js");function r(e){return e&&e.__esModule?e:{default:e}}var i=function(e,r,t){var n;if("function"==typeof r&&(t=r,r={}),r=r||{captureSpacesBetweenElements:!1},"string"!=typeof e)return n=new Error("The first parameter was not a string"),t?t(n):n;var i={};try{a=s.default.xml2js(e,r)}catch(n){return t?t(n):n}var a,o,e=a.elements.find(function(e){return"xliff"===e.name});return e.elements&&e.elements.length?(o=(a=e.elements.filter(function(e){return"element"===e.type}))[0].attributes["source-language"]||e.attributes.srcLang,e=a[0].attributes["target-language"]||e.attributes.trgLang,i.sourceLanguage=o,i.targetLanguage=e,i.targetLanguage||delete i.targetLanguage,i.resources=a.reduce(function(e,t){var n=r.namespace||t.attributes.original,t=t.elements.filter(function(e){return"element"===e.type}).find(function(e){return"body"===e.name}),t=(t.elements=t.elements||[],t.elements.filter(function(e){return"comment"!==e.type&&"element"===e.type}));return e[n]=u(t),e},{})):i.resources={},t?t(null,i):i};function u(e){return e.reduce(function(e,t){var n,r,i=t.attributes.id;return t.elements&&((n=t.elements.filter(function(e){return"trans-unit"===e.name||"group"===e.name})).length?e[i]=(r=t,l({groupUnits:u(n)},r.attributes)):e[i]=l((n=t).elements.reduce(function(e,t){var n=(0,o.extractValue)(t.elements,a.default);switch(t.name){case"source":case"target":e[t.name]=n;break;case"note":e[t.name]?(Array.isArray(e[t.name])||(e[t.name]=[e[t.name]]),e[t.name].push(n)):e[t.name]=n}return e},{}),n.attributes)),e},{})}function l(e,t){return delete t.id,Object.keys(t).length&&Object.assign(e,{additionalAttributes:t}),e}t.exports=n.default},{"./inline-elements/ElementTypes12.js":6,"./xml-js/xmlToObject.js":19,"xml-js":47}],17:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t,n){if(!n&&void 0===t)return new Promise(function(n,r){return o(e,t,function(e,t){return e?r(e):n(t)})});if(!n&&"function"!=typeof t)return new Promise(function(n,r){return o(e,t,function(e,t){return e?r(e):n(t)})});o(e,t,n)};var s=a(e("xml-js")),r=a(e("./inline-elements/ElementTypes2.js")),i=e("./xml-js/xmlToObject.js");function a(e){return e&&e.__esModule?e:{default:e}}var o=function(e,i,t){var n;if("function"==typeof i&&(t=i,i={}),i=i||{},"string"!=typeof e)return n=new Error("The first parameter was not a string"),t?t(n):n;var a={};try{r=s.default.xml2js(e,{})}catch(n){return t?t(n):n}var r,o,e=r.elements.find(function(e){return"xliff"===e.name});return e.attributes&&(r=e.attributes.srcLang,o=e.attributes.trgLang,a.sourceLanguage=r,a.targetLanguage=o,a.targetLanguage||delete a.targetLanguage,e.elements=e.elements.filter(function(e){return"comment"!==e.type}),a.resources=e.elements.reduce(function(e,t){var n=i.namespace||t.attributes.id,r={};return a.targetLanguage||delete r.target,t.elements=t.elements||[],t.elements=t.elements.filter(function(e){return"comment"!==e.type}),e[n]=function i(e,a){if(!e.elements)return{};return e.elements.reduce(function(e,t){var n=t.attributes.id,r=t.attributes;switch(delete r.id,void 0!==r["slr:sizeRestriction"]&&(r.sizeRestriction=r["slr:sizeRestriction"],"string"==typeof r.sizeRestriction&&(r.sizeRestriction=parseInt(r.sizeRestriction)),delete r["slr:sizeRestriction"]),t.name){case"unit":return e[n]=u(t,a),Object.keys(r).length&&Object.assign(e[n],{additionalAttributes:r}),e;case"group":return e[n]={groupUnits:i(t,a)},Object.keys(r).length&&Object.assign(e[n],{additionalAttributes:r}),e;default:return e}},{})}(t,r),e},{})),t?t(null,a):a};function u(e,t){if(e.elements)return e.elements.reduce(function(n,e){return["segment","notes"].indexOf(e.name)<0||e.elements.forEach(function(e){var t=(0,i.extractValue)(e.elements,r.default);switch(e.name){case"source":case"target":n[e.name]=t;break;case"note":n[e.name]?(Array.isArray(n[e.name])||(n[e.name]=[n[e.name]]),n[e.name].push(t)):n[e.name]=t}}),n},JSON.parse(JSON.stringify(t)))}t.exports=n.default},{"./inline-elements/ElementTypes2.js":7,"./xml-js/xmlToObject.js":19,"xml-js":47}],18:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.makeElement=l,n.makeText=f,n.makeValue=function o(e,s){{var t,n,r,i,a;if(!Array.isArray(e))return!("string"==typeof e||e instanceof String)&&(t=Object.keys(e)[0],void 0!==(n=(0,u.elementTypeToTag)(t,s)))?(delete(r=Object.assign({},e[t])).id,delete r.contents,i=e[t].hasOwnProperty("contents")?o(e[t].contents,s):void 0,a={id:e[t].id},Object.keys(r).forEach(function(e){a[e]=r[e]}),[l(n,a,i)]):[f(e)]}return e.map(function(n){var e,t,r,i,a;return"string"==typeof n||n instanceof String?f(n):(e=Object.keys(n)[0],void 0!==(t=(0,u.elementTypeToTag)(e,s))?(delete(r=Object.assign({},n[e])).id,delete r.contents,i=n[e].hasOwnProperty("contents")?o(n[e].contents,s):void 0,a={id:n[e].id},Object.keys(r).forEach(function(e){a[e]=r[e]}),l(t,a,i)):{type:"comment",comment:"Warning: unexpected segment "+("{ "+Object.keys(n).reduce(function(e,t){return e+t+': "'+n[t].toString()+'"'},"")+" }")+" was ignored"})})};var u=e("../inline-elements/typeToTagMaps.js");function l(e,t,n){e={type:"element",name:e};return null!=t&&(e.attributes=t),Array.isArray(n)?e.elements=n:!0===n&&(e.elements=[]),e}function f(e){return{type:"text",text:e}}},{"../inline-elements/typeToTagMaps.js":9}],19:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.extractValue=function t(e,n){if(null==e||""===e)return"";if(Array.isArray(e)&&1>16&255,a[o++]=t>>8&255,a[o++]=255&t;2===r&&(t=u[e.charCodeAt(n)]<<2|u[e.charCodeAt(n+1)]>>4,a[o++]=255&t);1===r&&(t=u[e.charCodeAt(n)]<<10|u[e.charCodeAt(n+1)]<<4|u[e.charCodeAt(n+2)]>>2,a[o++]=t>>8&255,a[o++]=255&t);return a},n.fromByteArray=function(e){for(var t,n=e.length,r=n%3,i=[],a=0,o=n-r;a>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}(r));return i.join("")}(e,a,o>2]+s[t<<4&63]+"==")):2==r&&(t=(e[n-2]<<8)+e[n-1],i.push(s[t>>10]+s[t>>4&63]+s[t<<2&63]+"="));return i.join("")};for(var s=[],u=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,a=r.length;i>>1;case"base64":return j(e).length;default:if(i)return r?-1:A(e).length;t=(""+t).toLowerCase(),i=!0}}function n(e,t,n){var r,i=!1;if((t=void 0===t||t<0?0:t)>this.length)return"";if((n=void 0===n||n>this.length?this.length:n)<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":var a=this,o=t,s=n,u=a.length;(!s||s<0||u=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:h(e,t,n,r,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?(i?Uint8Array.prototype.indexOf:Uint8Array.prototype.lastIndexOf).call(e,t,n):h(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function h(e,t,n,r,i){var a=1,o=e.length,s=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o/=a=2,s/=2,n/=2}function u(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i)for(var l=-1,f=n;f>8,i.push(n%256),i.push(r);return i}(t,e.length-n),e,n,r)}function x(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i>>10&1023|55296),f=56320|1023&f),r.push(f),i+=c}var d=r,p=d.length;if(p<=b)return String.fromCharCode.apply(String,d);for(var h="",m=0;mt&&(e+=" ... "),""},c.prototype.compare=function(e,t,n,r,i){if(N(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),(t=void 0===t?0:t)<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(i<=r&&n<=t)return 0;if(i<=r)return-1;if(n<=t)return 1;if(this===e)return 0;for(var a=(i>>>=0)-(r>>>=0),o=(n>>>=0)-(t>>>=0),s=Math.min(a,o),u=this.slice(r,i),l=e.slice(t,n),f=0;f>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||ithis.length)throw new RangeError("Attempt to write outside buffer bounds");r=r||"utf8";for(var a,o,s,u=!1;;)switch(r){case"hex":var l=this,f=e,c=t,d=n,p=(c=Number(c)||0,l.length-c);(!d||p<(d=Number(d)))&&(d=p),(p=f.length)/2e.length)throw new RangeError("Index out of range")}function E(e,t,n,r){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function _(e,t,n,r,i){return t=+t,n>>>=0,i||E(e,0,n,4),a.write(e,t,n,r,23,4),n+4}function w(e,t,n,r,i){return t=+t,n>>>=0,i||E(e,0,n,8),a.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n=this.length,n=((e=~~e)<0?(e+=n)<0&&(e=0):n>>=0,t>>>=0,n||m(e,t,this.length);for(var r=this[e],i=1,a=0;++a>>=0,t>>>=0,n||m(e,t,this.length);for(var r=this[e+--t],i=1;0>>=0,t||m(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||m(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||m(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||m(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||m(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||m(e,t,this.length);for(var r=this[e],i=1,a=0;++a>>=0,t>>>=0,n||m(e,t,this.length);for(var r=t,i=1,a=this[e+--r];0>>=0,t||m(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||m(e,2,this.length);t=this[e]|this[e+1]<<8;return 32768&t?4294901760|t:t},c.prototype.readInt16BE=function(e,t){e>>>=0,t||m(e,2,this.length);t=this[e+1]|this[e]<<8;return 32768&t?4294901760|t:t},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||m(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||m(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return e>>>=0,t||m(e,4,this.length),a.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||m(e,4,this.length),a.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||m(e,8,this.length),a.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||m(e,8,this.length),a.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||v(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,a=0;for(this[t]=255&e;++a>>=0,n>>>=0,r||v(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,a=1;for(this[t+i]=255&e;0<=--i&&(a*=256);)this[t+i]=e/a&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeIntLE=function(e,t,n,r){e=+e,t>>>=0,r||v(this,e,t,n,(r=Math.pow(2,8*n-1))-1,-r);var i=0,a=1,o=0;for(this[t]=255&e;++i>0)-o&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){e=+e,t>>>=0,r||v(this,e,t,n,(r=Math.pow(2,8*n-1))-1,-r);var i=n-1,a=1,o=0;for(this[t+i]=255&e;0<=--i&&(a*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,1,127,-128),this[t]=255&(e=e<0?255+e+1:e),t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,4,2147483647,-2147483648),this[t]=(e=e<0?4294967295+e+1:e)>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeFloatLE=function(e,t,n){return _(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return _(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return w(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return w(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n=n||0,r||0===r||(r=this.length),t>=e.length&&(t=e.length),(r=0=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length);var i=(r=e.length-t>>=0,n=void 0===n?this.length:n>>>0,"number"==typeof(e=e||0))for(a=t;a>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return a}function j(e){return S.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(T,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function O(e,t,n,r){for(var i=0;i=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function N(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function R(e){return e!=e}}.call(this)}.call(this,L("buffer").Buffer)},{"base64-js":20,buffer:22,ieee754:24}],23:[function(e,t,n){"use strict";var r="object"==typeof Reflect?Reflect:null,u=r&&"function"==typeof r.apply?r.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};var i=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)},a=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(s,u){return new Promise(function(e,t){function n(e){s.removeListener(u,r),t(e)}function r(){"function"==typeof s.removeListener&&s.removeListener("error",n),e([].slice.call(arguments))}var i,a,o;y(s,u,r,{once:!0}),"error"!==u&&(a=n,o={once:!0},"function"==typeof(i=s).on)&&y(i,"error",a,o)})},(o.EventEmitter=o).prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function l(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function f(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function c(e,t,n,r){var i,a;return l(n),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,n.listener||n),i=e._events),a=i[t]),void 0===a?(a=i[t]=n,++e._eventsCount):("function"==typeof a?a=i[t]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),0<(i=f(e))&&a.length>i&&!a.warned&&(a.warned=!0,(r=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit")).name="MaxListenersExceededWarning",r.emitter=e,r.type=t,r.count=a.length,n=r,console)&&console.warn&&console.warn(n)),e}function d(e,t,n){e={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},t=function(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}.bind(e);return t.listener=n,e.wrapFn=t}function p(e,t,n){e=e._events;if(void 0===e)return[];e=e[t];if(void 0===e)return[];if("function"==typeof e)return n?[e.listener||e]:[e];if(n){for(var r=e,i=new Array(r.length),a=0;a>1,f=-7,c=n?i-1:0,d=n?-1:1,i=e[t+c];for(c+=d,a=i&(1<<-f)-1,i>>=-f,f+=s;0>=-f,f+=r;0>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:a-1,p=r?1:-1,a=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(r=Math.pow(2,-o))<1&&(o--,r*=2),2<=(t+=1<=o+f?c/r:c*Math.pow(2,1-f))*r&&(o++,r/=2),l<=o+f?(s=0,o=l):1<=o+f?(s=(t*r-1)*Math.pow(2,i),o+=f):(s=t*Math.pow(2,f-1)*Math.pow(2,i),o=0));8<=i;e[n+d]=255&s,d+=p,s/=256,i-=8);for(o=o<"===a?(x(t,"onsgmldeclaration",t.sgmlDecl),t.sgmlDecl="",t.state=T.TEXT):(v(a)&&(t.state=T.SGML_DECL_QUOTED),t.sgmlDecl+=a);continue;case T.SGML_DECL_QUOTED:a===t.q&&(t.state=T.SGML_DECL,t.q=""),t.sgmlDecl+=a;continue;case T.DOCTYPE:">"===a?(t.state=T.TEXT,x(t,"ondoctype",t.doctype),t.doctype=!0):(t.doctype+=a,"["===a?t.state=T.DOCTYPE_DTD:v(a)&&(t.state=T.DOCTYPE_QUOTED,t.q=a));continue;case T.DOCTYPE_QUOTED:t.doctype+=a,a===t.q&&(t.q="",t.state=T.DOCTYPE);continue;case T.DOCTYPE_DTD:t.doctype+=a,"]"===a?t.state=T.DOCTYPE:v(a)&&(t.state=T.DOCTYPE_DTD_QUOTED,t.q=a);continue;case T.DOCTYPE_DTD_QUOTED:t.doctype+=a,a===t.q&&(t.state=T.DOCTYPE_DTD,t.q="");continue;case T.COMMENT:"-"===a?t.state=T.COMMENT_ENDING:t.comment+=a;continue;case T.COMMENT_ENDING:"-"===a?(t.state=T.COMMENT_ENDED,t.comment=j(t.opt,t.comment),t.comment&&x(t,"oncomment",t.comment),t.comment=""):(t.comment+="-"+a,t.state=T.COMMENT);continue;case T.COMMENT_ENDED:">"!==a?(R(t,"Malformed comment"),t.comment+="--"+a,t.state=T.COMMENT):t.state=T.TEXT;continue;case T.CDATA:"]"===a?t.state=T.CDATA_ENDING:t.cdata+=a;continue;case T.CDATA_ENDING:"]"===a?t.state=T.CDATA_ENDING_2:(t.cdata+="]"+a,t.state=T.CDATA);continue;case T.CDATA_ENDING_2:">"===a?(t.cdata&&x(t,"oncdata",t.cdata),x(t,"onclosecdata"),t.cdata="",t.state=T.TEXT):"]"===a?t.cdata+="]":(t.cdata+="]]"+a,t.state=T.CDATA);continue;case T.PROC_INST:"?"===a?t.state=T.PROC_INST_ENDING:b(a)?t.state=T.PROC_INST_BODY:t.procInstName+=a;continue;case T.PROC_INST_BODY:if(!t.procInstBody&&b(a))continue;"?"===a?t.state=T.PROC_INST_ENDING:t.procInstBody+=a;continue;case T.PROC_INST_ENDING:">"===a?(x(t,"onprocessinginstruction",{name:t.procInstName,body:t.procInstBody}),t.procInstName=t.procInstBody="",t.state=T.TEXT):(t.procInstBody+="?"+a,t.state=T.PROC_INST_BODY);continue;case T.OPEN_TAG:E(m,a)?t.tagName+=a:(function(e){e.strict||(e.tagName=e.tagName[e.looseCase]());var t=e.tags[e.tags.length-1]||e,n=e.tag={name:e.tagName,attributes:{}};e.opt.xmlns&&(n.ns=t.ns);e.attribList.length=0,x(e,"onopentagstart",n)}(t),">"===a?k(t):"/"===a?t.state=T.OPEN_TAG_SLASH:(b(a)||R(t,"Invalid character in tag name"),t.state=T.ATTRIB));continue;case T.OPEN_TAG_SLASH:">"===a?(k(t,!0),I(t)):(R(t,"Forward-slash in opening tag not followed by >"),t.state=T.ATTRIB);continue;case T.ATTRIB:if(b(a))continue;">"===a?k(t):"/"===a?t.state=T.OPEN_TAG_SLASH:E(h,a)?(t.attribName=a,t.attribValue="",t.state=T.ATTRIB_NAME):R(t,"Invalid attribute name");continue;case T.ATTRIB_NAME:"="===a?t.state=T.ATTRIB_VALUE:">"===a?(R(t,"Attribute without value"),t.attribValue=t.attribName,C(t),k(t)):b(a)?t.state=T.ATTRIB_NAME_SAW_WHITE:E(m,a)?t.attribName+=a:R(t,"Invalid attribute name");continue;case T.ATTRIB_NAME_SAW_WHITE:if("="===a)t.state=T.ATTRIB_VALUE;else{if(b(a))continue;R(t,"Attribute without value"),t.tag.attributes[t.attribName]="",t.attribValue="",x(t,"onattribute",{name:t.attribName,value:""}),t.attribName="",">"===a?k(t):E(h,a)?(t.attribName=a,t.state=T.ATTRIB_NAME):(R(t,"Invalid attribute name"),t.state=T.ATTRIB)}continue;case T.ATTRIB_VALUE:if(b(a))continue;v(a)?(t.q=a,t.state=T.ATTRIB_VALUE_QUOTED):(R(t,"Unquoted attribute value"),t.state=T.ATTRIB_VALUE_UNQUOTED,t.attribValue=a);continue;case T.ATTRIB_VALUE_QUOTED:if(a!==t.q){"&"===a?t.state=T.ATTRIB_VALUE_ENTITY_Q:t.attribValue+=a;continue}C(t),t.q="",t.state=T.ATTRIB_VALUE_CLOSED;continue;case T.ATTRIB_VALUE_CLOSED:b(a)?t.state=T.ATTRIB:">"===a?k(t):"/"===a?t.state=T.OPEN_TAG_SLASH:E(h,a)?(R(t,"No whitespace between attributes"),t.attribName=a,t.attribValue="",t.state=T.ATTRIB_NAME):R(t,"Invalid attribute name");continue;case T.ATTRIB_VALUE_UNQUOTED:if(!function(e){return">"===e||b(e)}(a)){"&"===a?t.state=T.ATTRIB_VALUE_ENTITY_U:t.attribValue+=a;continue}C(t),">"===a?k(t):t.state=T.ATTRIB;continue;case T.CLOSE_TAG:if(t.tagName)">"===a?I(t):E(m,a)?t.tagName+=a:t.script?(t.script+=""===a?I(t):R(t,"Invalid characters in closing tag");continue;case T.TEXT_ENTITY:case T.ATTRIB_VALUE_ENTITY_Q:case T.ATTRIB_VALUE_ENTITY_U:switch(t.state){case T.TEXT_ENTITY:n=T.TEXT,r="textNode";break;case T.ATTRIB_VALUE_ENTITY_Q:n=T.ATTRIB_VALUE_QUOTED,r="attribValue";break;case T.ATTRIB_VALUE_ENTITY_U:n=T.ATTRIB_VALUE_UNQUOTED,r="attribValue"}";"===a?(t[r]+=function(e){var t,n=e.entity,r=n.toLowerCase(),i="";if(e.ENTITIES[n])return e.ENTITIES[n];if(e.ENTITIES[r])return e.ENTITIES[r];"#"===(n=r).charAt(0)&&(i="x"===n.charAt(1)?(n=n.slice(2),(t=parseInt(n,16)).toString(16)):(n=n.slice(1),(t=parseInt(n,10)).toString(10)));if(n=n.replace(/^0+/,""),isNaN(t)||i.toLowerCase()!==n)return R(e,"Invalid character entity"),"&"+e.entity+";";return String.fromCodePoint(t)}(t),t.entity="",t.state=n):E(t.entity.length?g:y,a)?t.entity+=a:(R(t,"Invalid character in entity name"),t[r]+="&"+t.entity+a,t.entity="",t.state=n);continue;default:throw new Error(t,"Unknown state: "+t.state)}}t.position>=t.bufferCheckPosition&&!function(e){for(var t=Math.max(s.MAX_BUFFER_LENGTH,10),n=0,r=0,i=u.length;r",lt:"<",quot:'"',apos:"'"},s.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(s.ENTITIES).forEach(function(e){var t=s.ENTITIES[e],t="number"==typeof t?String.fromCharCode(t):t;s.ENTITIES[e]=t}),s.STATE)s.STATE[s.STATE[e]]=e;function S(e,t,n){e[t]&&e[t](n)}function x(e,t,n){e.textNode&&A(e),S(e,t,n)}function A(e){e.textNode=j(e.opt,e.textNode),e.textNode&&S(e,"ontext",e.textNode),e.textNode=""}function j(e,t){return e.trim&&(t=t.trim()),t=e.normalize?t.replace(/\s+/g," "):t}function O(e,t){return A(e),e.trackPosition&&(t+="\nLine: "+e.line+"\nColumn: "+e.column+"\nChar: "+e.c),t=new Error(t),e.error=t,S(e,"onerror",t),e}function N(e){return e.sawRoot&&!e.closedRoot&&R(e,"Unclosed root tag"),e.state!==T.BEGIN&&e.state!==T.BEGIN_WHITESPACE&&e.state!==T.TEXT&&O(e,"Unexpected end"),A(e),e.c="",e.closed=!0,S(e,"onend"),o.call(e,e.strict,e.opt),e}function R(e,t){if("object"!=typeof e||!(e instanceof o))throw new Error("bad call to strictFail");e.strict&&O(e,t)}function L(e,t){var n=e.indexOf(":")<0?["",e]:e.split(":"),r=n[0],n=n[1];return t&&"xmlns"===e&&(r="xmlns",n=""),{prefix:r,local:n}}function C(e){var t,n,r;e.strict||(e.attribName=e.attribName[e.looseCase]()),-1!==e.attribList.indexOf(e.attribName)||e.tag.attributes.hasOwnProperty(e.attribName)||(e.opt.xmlns?(n=(t=L(e.attribName,!0)).prefix,t=t.local,"xmlns"===n&&("xml"===t&&e.attribValue!==c?R(e,"xml: prefix must be bound to "+c+"\nActual: "+e.attribValue):"xmlns"===t&&e.attribValue!==d?R(e,"xmlns: prefix must be bound to "+d+"\nActual: "+e.attribValue):(n=e.tag,r=e.tags[e.tags.length-1]||e,n.ns===r.ns&&(n.ns=Object.create(r.ns)),n.ns[t]=e.attribValue)),e.attribList.push([e.attribName,e.attribValue])):(e.tag.attributes[e.attribName]=e.attribValue,x(e,"onattribute",{name:e.attribName,value:e.attribValue}))),e.attribName=e.attribValue=""}function k(t,e){if(t.opt.xmlns){var n=t.tag,r=L(t.tagName),r=(n.prefix=r.prefix,n.local=r.local,n.uri=n.ns[r.prefix]||"",n.prefix&&!n.uri&&(R(t,"Unbound namespace prefix: "+JSON.stringify(t.tagName)),n.uri=r.prefix),t.tags[t.tags.length-1]||t);n.ns&&r.ns!==n.ns&&Object.keys(n.ns).forEach(function(e){x(t,"onopennamespace",{prefix:e,uri:n.ns[e]})});for(var i=0,a=t.attribList.length;i",n.tagName="",void(n.state=T.SCRIPT);x(n,"onscript",n.script),n.script=""}for(var e=n.tags.length,t=n.tagName,r=t=n.strict?t:t[n.looseCase]();e--&&n.tags[e].name!==r;)R(n,"Unexpected close tag");if(e<0)R(n,"Unmatched closing tag: "+n.tagName),n.textNode+="";else{n.tagName=t;for(var i=n.tags.length;i-- >e;){var a,o=n.tag=n.tags.pop();n.tagName=n.tag.name,x(n,"onclosetag",n.tagName);for(a in o.ns)a,o.ns[a];var s=n.tags[n.tags.length-1]||n;n.opt.xmlns&&o.ns!==s.ns&&Object.keys(o.ns).forEach(function(e){var t=o.ns[e];x(n,"onclosenamespace",{prefix:e,uri:t})})}0===e&&(n.closedRoot=!0),n.tagName=n.attribValue=n.attribName="",n.attribList.length=0}}else R(n,"Weird empty close tag."),n.textNode+="";n.state=T.TEXT}function P(e,t){"<"===t?(e.state=T.OPEN_WAKA,e.startTagPosition=e.position):b(t)||(R(e,"Non-whitespace before first tag."),e.textNode=t,e.state=T.TEXT)}function F(e,t){var n="";return n=t>10),i%1024+56320),(t+1===n||16384a.length)&&(s=a.length),a=(a.substring(s-o.length,s)===o?"The ".concat(e," "):(s=(i="number"!=typeof i?0:i)+(a=".").length>(s=e).length||-1===s.indexOf(a,i)?"argument":"property",'The "'.concat(e,'" ').concat(s," "))).concat(r," ").concat(u(t,"type")),a+=". Received type ".concat(typeof n)},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=r},{}],31:[function(f,c,e){!function(l){!function(){"use strict";var e=Object.keys||function(e){var t,n=[];for(t in e)n.push(t);return n},t=(c.exports=o,f("./_stream_readable")),n=f("./_stream_writable");f("inherits")(o,t);for(var r=e(n.prototype),i=0;it.highWaterMark&&(t.highWaterMark=(T<=(n=e)?n=T:(n--,n=(n=(n=(n=(n|=n>>>1)|n>>>2)|n>>>4)|n>>>8)|n>>>16,n++),n)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var t=e._readableState;m("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(m("emitReadable",t.flowing),t.emittedReadable=!0,M.nextTick(A,e))}function A(e){var t=e._readableState;m("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,C(e)}function j(e,t){t.readingMore||(t.readingMore=!0,M.nextTick(O,e,t))}function O(e,t){for(;!t.reading&&!t.ended&&(t.length=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n)}function I(e){var t=e._readableState;m("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,M.nextTick(F,t,e))}function F(e,t){m("endReadableNT",e.endEmitted,e.length),e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy&&(!(e=t._writableState)||e.autoDestroy&&e.finished)&&t.destroy())}function P(e,t){for(var n=0,r=e.length;n=n.highWaterMark:0>>0),i=this.head,a=0;i;)t=i.data,n=a,s.prototype.copy.call(t,r,n),a+=i.data.length,i=i.next;return r}},{key:"consume",value:function(e,t){var n;return ei.length?i.length:e;if(a===i.length?r+=i:r+=i.slice(0,e),0===(e-=a)){a===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t).data=i.slice(a);break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=s.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var i=n.data,a=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,a),0===(e-=a)){a===i.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n).data=i.slice(a);break}++r}return this.length-=r,t}},{key:l,value:function(e,t){return u(this,i({},t,{depth:0,customInspect:!1}))}}])&&o(t.prototype,n),r&&o(t,r),e}()},{buffer:22,util:21}],38:[function(e,t,n){!function(u){!function(){"use strict";function a(e,t){s(e,t),o(e)}function o(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function s(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var n=this,r=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return r||i?t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,u.nextTick(s,this,e)):u.nextTick(s,this,e)):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?n._writableState?n._writableState.errorEmitted?u.nextTick(o,n):(n._writableState.errorEmitted=!0,u.nextTick(a,n,e)):u.nextTick(a,n,e):t?(u.nextTick(o,n),t(e)):u.nextTick(o,n)})),this},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}}}.call(this)}.call(this,e("_process"))},{_process:26}],39:[function(e,t,n){"use strict";var g=e("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function b(){}t.exports=function e(t,n,r){var i,a,o,s,u,l,f,c,d,p,h,m,y;return"function"==typeof n?e(t,null,n):(i=r||b,a=!1,r=function(){if(!a){a=!0;for(var e=arguments.length,t=new Array(e),n=0;n>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function u(e){var t,n=this.lastTotal-this.lastNeed,r=(t=this,128!=(192&(r=e)[0])?(t.lastNeed=0,"�"):1"}function h(e,t,n){if(t.ignoreInstruction)return"";for(var r in e)if(e.hasOwnProperty(r))break;var i="instructionNameFn"in t?t.instructionNameFn(r,e[r],l,u):r;return"object"==typeof e[r]?"":(n=e[r]||"","")}function m(e,t){return t.ignoreComment?"":"\x3c!--"+("commentFn"in t?t.commentFn(e,l,u):e)+"--\x3e"}function y(e,t){return t.ignoreCdata?"":"","]]]]>"))+"]]>"}function g(e,t){return t.ignoreDoctype?"":""}function b(e,t){return t.ignoreText?"":(e=(e=(e=""+e).replace(/&/g,"&")).replace(/&/g,"&").replace(//g,">"),"textFn"in t?t.textFn(e,l,u):e)}function s(e,t,n){l=(u=e).name;var r=[],i="elementNameFn"in t?t.elementNameFn(e.name,e):e.name,a=(r.push("<"+i),e[t.attributesKey]&&r.push(d(e[t.attributesKey],t,n)),e[t.elementsKey]&&e[t.elementsKey].length||e[t.attributesKey]&&"preserve"===e[t.attributesKey]["xml:space"]);return(a=a||("fullTagEmptyElementFn"in t?t.fullTagEmptyElementFn(e.name,e):t.fullTagEmptyElement))?(r.push(">"),e[t.elementsKey]&&e[t.elementsKey].length&&(r.push(o(e[t.elementsKey],t,n+1)),l=(u=e).name),r.push(t.spaces&&function(e,t){var n;if(e.elements&&e.elements.length)for(n=0;n")):r.push("/>"),r.join("")}function o(e,i,a,o){return e.reduce(function(e,t){var n=c(i,a,o&&!e);switch(t.type){case"element":return e+n+s(t,i,a);case"comment":return e+n+m(t[i.commentKey],i);case"doctype":return e+n+g(t[i.doctypeKey],i);case"cdata":return e+(i.indentCdata?n:"")+y(t[i.cdataKey],i);case"text":return e+(i.indentText?n:"")+b(t[i.textKey],i);case"instruction":var r={};return r[t[i.nameKey]]=t[i.attributesKey]?t:t[i.instructionKey],e+(i.indentInstruction?n:"")+h(r,i,a)}},"")}function v(e,t,n){for(var r in e)if(e.hasOwnProperty(r))switch(r){case t.parentKey:case t.attributesKey:break;case t.textKey:if(t.indentText||n)return!0;break;case t.cdataKey:if(t.indentCdata||n)return!0;break;case t.instructionKey:if(t.indentInstruction||n)return!0;break;case t.doctypeKey:case t.commentKey:default:return!0}return!1}function E(e,t,n,r){var i,a,o,s=[];for(a in e)if(e.hasOwnProperty(a))for(o=f(e[a])?e[a]:[e[a]],i=0;i":"<"+a+"/>";var o=[];if(t){if(o.push("<"+a),"object"!=typeof e)return o.push(">"+b(e,n)+""),o.join("");e[n.attributesKey]&&o.push(d(e[n.attributesKey],n,r));var s=v(e,n,!0)||e[n.attributesKey]&&"preserve"===e[n.attributesKey]["xml:space"];if(!(s=s||("fullTagEmptyElementFn"in n?n.fullTagEmptyElementFn(t,e):n.fullTagEmptyElement)))return o.push("/>"),o.join("");o.push(">")}return o.push(E(e,n,r+1,!1)),u=e,(l=t)&&o.push((i?c(n,r,!1):"")+""),o.join("")}(o[i],a,t,n,v(o[i],t)))}r=r&&!s.length}return s.join("")}t.exports=function(e,t){n=t,n=i.copyOptions(n),i.ensureFlagExists("ignoreDeclaration",n),i.ensureFlagExists("ignoreInstruction",n),i.ensureFlagExists("ignoreAttributes",n),i.ensureFlagExists("ignoreText",n),i.ensureFlagExists("ignoreComment",n),i.ensureFlagExists("ignoreCdata",n),i.ensureFlagExists("ignoreDoctype",n),i.ensureFlagExists("compact",n),i.ensureFlagExists("indentText",n),i.ensureFlagExists("indentCdata",n),i.ensureFlagExists("indentAttributes",n),i.ensureFlagExists("indentInstruction",n),i.ensureFlagExists("fullTagEmptyElement",n),i.ensureFlagExists("noQuotesForNativeAttributes",n),i.ensureSpacesExists(n),"number"==typeof n.spaces&&(n.spaces=Array(n.spaces+1).join(" ")),i.ensureKeyExists("declaration",n),i.ensureKeyExists("instruction",n),i.ensureKeyExists("attributes",n),i.ensureKeyExists("text",n),i.ensureKeyExists("comment",n),i.ensureKeyExists("cdata",n),i.ensureKeyExists("doctype",n),i.ensureKeyExists("type",n),i.ensureKeyExists("name",n),i.ensureKeyExists("elements",n),i.checkFnExists("doctype",n),i.checkFnExists("instruction",n),i.checkFnExists("cdata",n),i.checkFnExists("comment",n),i.checkFnExists("text",n),i.checkFnExists("instructionName",n),i.checkFnExists("elementName",n),i.checkFnExists("attributeName",n),i.checkFnExists("attributeValue",n),i.checkFnExists("attributes",n),i.checkFnExists("fullTagEmptyElement",n);var n,r=[];return u=e,l="_root_",(t=n).compact?r.push(E(e,t,0,!0)):(e[t.declarationKey]&&r.push(p(e[t.declarationKey],t,0)),e[t.elementsKey]&&e[t.elementsKey].length&&r.push(o(e[t.elementsKey],t,0,!r.length))),r.join("")}},{"./array-helper":46,"./options-helper":50}],49:[function(e,t,n){!function(i){!function(){var r=e("./js2xml.js");t.exports=function(e,t){var n=null;if("string"==typeof(e=e instanceof i?e.toString():e))try{n=JSON.parse(e)}catch(e){throw new Error("The JSON structure is invalid")}else n=e;return r(n,t)}}.call(this)}.call(this,e("buffer").Buffer)},{"./js2xml.js":48,buffer:22}],50:[function(e,t,n){var r=e("./array-helper").isArray;t.exports={copyOptions:function(e){var t,n={};for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n},ensureFlagExists:function(e,t){e in t&&"boolean"==typeof t[e]||(t[e]=!1)},ensureSpacesExists:function(e){"spaces"in e&&("number"==typeof e.spaces||"string"==typeof e.spaces)||(e.spaces=0)},ensureAlwaysArrayExists:function(e){"alwaysArray"in e&&("boolean"==typeof e.alwaysArray||r(e.alwaysArray))||(e.alwaysArray=!1)},ensureKeyExists:function(e,t){e+"Key"in t&&"string"==typeof t[e+"Key"]||(t[e+"Key"]=t.compact?"_"+e:e)},checkFnExists:function(e,t){return e+"Fn"in t}}},{"./array-helper":46}],51:[function(e,t,n){var a,o,i=e("sax"),s=e("./options-helper"),u=e("./array-helper").isArray;function r(e){var t,n=Number(e);return isNaN(n)?"true"===(t=e.toLowerCase())||"false"!==t&&e:n}function l(e,t){var n,r;if(a.compact){if(!o[a[e+"Key"]]&&(u(a.alwaysArray)?-1!==a.alwaysArray.indexOf(a[e+"Key"]):a.alwaysArray)&&(o[a[e+"Key"]]=[]),o[a[e+"Key"]]&&!u(o[a[e+"Key"]])&&(o[a[e+"Key"]]=[o[a[e+"Key"]]]),e+"Fn"in a&&"string"==typeof t&&(t=a[e+"Fn"](t,o)),"instruction"===e&&("instructionFn"in a||"instructionNameFn"in a))for(n in t)t.hasOwnProperty(n)&&("instructionFn"in a?t[n]=a.instructionFn(t[n],n,o):(r=t[n],delete t[n],t[a.instructionNameFn(n,r,o)]=r));u(o[a[e+"Key"]])?o[a[e+"Key"]].push(t):o[a[e+"Key"]]=t}else{o[a.elementsKey]||(o[a.elementsKey]=[]);var i={};if("instruction"===(i[a.typeKey]=e)){for(n in t)if(t.hasOwnProperty(n))break;i[a.nameKey]="instructionNameFn"in a?a.instructionNameFn(n,t,o):n,a.instructionHasAttributes?(i[a.attributesKey]=t[n][a.attributesKey],"instructionFn"in a&&(i[a.attributesKey]=a.instructionFn(i[a.attributesKey],n,o))):("instructionFn"in a&&(t[n]=a.instructionFn(t[n],n,o)),i[a.instructionKey]=t[n])}else e+"Fn"in a&&(t=a[e+"Fn"](t,o)),i[a[e+"Key"]]=t;a.addParent&&(i[a.parentKey]=o),o[a.elementsKey].push(i)}}function f(e){var t,n;if("attributesFn"in a&&(e=e&&a.attributesFn(e,o)),(a.trim||"attributeValueFn"in a||"attributeNameFn"in a||a.nativeTypeAttributes)&&e)for(t in e)e.hasOwnProperty(t)&&(a.trim&&(e[t]=e[t].trim()),a.nativeTypeAttributes&&(e[t]=r(e[t])),"attributeValueFn"in a&&(e[t]=a.attributeValueFn(e[t],t,o)),"attributeNameFn"in a)&&(n=e[t],delete e[t],e[a.attributeNameFn(t,e[t],o)]=n);return e}function c(e){var t,n={};if(e.body&&("xml"===e.name.toLowerCase()||a.instructionHasAttributes)){for(var r,i=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g;null!==(r=i.exec(e.body));)n[r[1]]=r[2]||r[3]||r[4];n=f(n)}"xml"===e.name.toLowerCase()?a.ignoreDeclaration||(o[a.declarationKey]={},Object.keys(n).length&&(o[a.declarationKey][a.attributesKey]=n),a.addParent&&(o[a.declarationKey][a.parentKey]=o)):a.ignoreInstruction||(a.trim&&(e.body=e.body.trim()),t={},a.instructionHasAttributes&&Object.keys(n).length?(t[e.name]={},t[e.name][a.attributesKey]=n):t[e.name]=e.body,l("instruction",t))}function d(e,t){if("object"==typeof e&&(t=e.attributes,e=e.name),t=f(t),"elementNameFn"in a&&(e=a.elementNameFn(e,o)),a.compact){var n,r={};if(!a.ignoreAttributes&&t&&Object.keys(t).length)for(n in r[a.attributesKey]={},t)t.hasOwnProperty(n)&&(r[a.attributesKey][n]=t[n]);e in o||(u(a.alwaysArray)?-1===a.alwaysArray.indexOf(e):!a.alwaysArray)||(o[e]=[]),o[e]&&!u(o[e])&&(o[e]=[o[e]]),u(o[e])?o[e].push(r):o[e]=r}else o[a.elementsKey]||(o[a.elementsKey]=[]),(r={})[a.typeKey]="element",r[a.nameKey]=e,!a.ignoreAttributes&&t&&Object.keys(t).length&&(r[a.attributesKey]=t),a.alwaysChildren&&(r[a.elementsKey]=[]),o[a.elementsKey].push(r);r[a.parentKey]=o,o=r}function p(e){a.ignoreText||(e.trim()||a.captureSpacesBetweenElements)&&(a.trim&&(e=e.trim()),a.nativeType&&(e=r(e)),l("text",e=a.sanitize?e.replace(/&/g,"&").replace(//g,">"):e))}function h(e){a.ignoreComment||l("comment",e=a.trim?e.trim():e)}function m(e){var t=o[a.parentKey];a.addParent||delete o[a.parentKey],o=t}function y(e){a.ignoreCdata||l("cdata",e=a.trim?e.trim():e)}function g(e){a.ignoreDoctype||(e=e.replace(/^ /,""),l("doctype",e=a.trim?e.trim():e))}function b(e){e.note=e}t.exports=function(e,t){var n=i.parser(!0,{}),r={};return o=r,a=s.copyOptions(t),s.ensureFlagExists("ignoreDeclaration",a),s.ensureFlagExists("ignoreInstruction",a),s.ensureFlagExists("ignoreAttributes",a),s.ensureFlagExists("ignoreText",a),s.ensureFlagExists("ignoreComment",a),s.ensureFlagExists("ignoreCdata",a),s.ensureFlagExists("ignoreDoctype",a),s.ensureFlagExists("compact",a),s.ensureFlagExists("alwaysChildren",a),s.ensureFlagExists("addParent",a),s.ensureFlagExists("trim",a),s.ensureFlagExists("nativeType",a),s.ensureFlagExists("nativeTypeAttributes",a),s.ensureFlagExists("sanitize",a),s.ensureFlagExists("instructionHasAttributes",a),s.ensureFlagExists("captureSpacesBetweenElements",a),s.ensureAlwaysArrayExists(a),s.ensureKeyExists("declaration",a),s.ensureKeyExists("instruction",a),s.ensureKeyExists("attributes",a),s.ensureKeyExists("text",a),s.ensureKeyExists("comment",a),s.ensureKeyExists("cdata",a),s.ensureKeyExists("doctype",a),s.ensureKeyExists("type",a),s.ensureKeyExists("name",a),s.ensureKeyExists("elements",a),s.ensureKeyExists("parent",a),s.checkFnExists("doctype",a),s.checkFnExists("instruction",a),s.checkFnExists("cdata",a),s.checkFnExists("comment",a),s.checkFnExists("text",a),s.checkFnExists("instructionName",a),s.checkFnExists("elementName",a),s.checkFnExists("attributeName",a),s.checkFnExists("attributeValue",a),s.checkFnExists("attributes",a),n.opt={strictEntities:!0},n.onopentag=d,n.ontext=p,n.oncomment=h,n.onclosetag=m,n.onerror=b,n.oncdata=y,n.ondoctype=g,n.onprocessinginstruction=c,n.write(e).close(),r[a.elementsKey]&&(t=r[a.elementsKey],delete r[a.elementsKey],r[a.elementsKey]=t,delete r.text),r}},{"./array-helper":46,"./options-helper":50,sax:28}],52:[function(e,t,n){var r=e("./options-helper"),i=e("./xml2js");t.exports=function(e,t){var n;return t=t,t=r.copyOptions(t),r.ensureSpacesExists(t),t=i(e,e=t),n="compact"in e&&e.compact?"_parent":"parent",("addParent"in e&&e.addParent?JSON.stringify(t,function(e,t){return e===n?"_":t},e.spaces):JSON.stringify(t,null,e.spaces)).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}},{"./options-helper":50,"./xml2js":51}]},{},[4])(4)}); \ No newline at end of file