@jsreport/exceljs
Version:
Excel Workbook Manager - Read and Write xlsx and csv Files.
3 lines (2 loc) • 970 kB
JavaScript
/*! ExcelJS 26-02-2025 */
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ExcelJS=e()}}((function(){var define,module,exports;return function e(t,r,i){function n(o,a){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!a&&l)return l(o,!0);if(s)return s(o,!0);var h=new Error("Cannot find module '"+o+"'");throw h.code="MODULE_NOT_FOUND",h}var c=r[o]={exports:{}};t[o][0].call(c.exports,(function(e){return n(t[o][1][e]||e)}),c,c.exports,e,t,r,i)}return r[o].exports}for(var s="function"==typeof require&&require,o=0;o<i.length;o++)n(i[o]);return n}({1:[function(e,t,r){(function(t){(function(){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.CsvFormatterStream=void 0;const i=e("stream"),n=e("./formatter");class s extends i.Transform{constructor(e){super({writableObjectMode:e.objectMode}),this.hasWrittenBOM=!1,this.formatterOptions=e,this.rowFormatter=new n.RowFormatter(e),this.hasWrittenBOM=!e.writeBOM}transform(e){return this.rowFormatter.rowTransform=e,this}_transform(e,r,i){let n=!1;try{this.hasWrittenBOM||(this.push(this.formatterOptions.BOM),this.hasWrittenBOM=!0),this.rowFormatter.format(e,(e,r)=>e?(n=!0,i(e)):(r&&r.forEach(e=>{this.push(t.from(e,"utf8"))}),n=!0,i()))}catch(e){if(n)throw e;i(e)}}_flush(e){this.rowFormatter.finish((r,i)=>r?e(r):(i&&i.forEach(e=>{this.push(t.from(e,"utf8"))}),e()))}}r.CsvFormatterStream=s}).call(this)}).call(this,e("buffer").Buffer)},{"./formatter":5,buffer:85,stream:237}],2:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.FormatterOptions=void 0;r.FormatterOptions=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t;this.objectMode=!0,this.delimiter=",",this.rowDelimiter="\n",this.quote='"',this.escape=this.quote,this.quoteColumns=!1,this.quoteHeaders=this.quoteColumns,this.headers=null,this.includeEndRowDelimiter=!1,this.writeBOM=!1,this.BOM="\ufeff",this.alwaysWriteHeaders=!1,Object.assign(this,e||{}),void 0===(null==e?void 0:e.quoteHeaders)&&(this.quoteHeaders=this.quoteColumns),!0===(null==e?void 0:e.quote)?this.quote='"':!1===(null==e?void 0:e.quote)&&(this.quote=""),"string"!=typeof(null==e?void 0:e.escape)&&(this.escape=this.quote),this.shouldWriteHeaders=!!this.headers&&(null===(t=e.writeHeaders)||void 0===t||t),this.headers=Array.isArray(this.headers)?this.headers:null,this.escapedQuote="".concat(this.escape).concat(this.quote)}}},{}],3:[function(e,t,r){"use strict";var i=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.FieldFormatter=void 0;const n=i(e("lodash.isboolean")),s=i(e("lodash.isnil")),o=i(e("lodash.escaperegexp"));r.FieldFormatter=class{constructor(e){this._headers=null,this.formatterOptions=e,null!==e.headers&&(this.headers=e.headers),this.REPLACE_REGEXP=new RegExp(e.quote,"g");const t="[".concat(e.delimiter).concat(o.default(e.rowDelimiter),"|\r|\n]");this.ESCAPE_REGEXP=new RegExp(t)}set headers(e){this._headers=e}shouldQuote(e,t){const r=t?this.formatterOptions.quoteHeaders:this.formatterOptions.quoteColumns;return n.default(r)?r:Array.isArray(r)?r[e]:null!==this._headers&&r[this._headers[e]]}format(e,t,r){const i="".concat(s.default(e)?"":e).replace(/\0/g,""),{formatterOptions:n}=this;if(""!==n.quote){if(-1!==i.indexOf(n.quote))return this.quoteField(i.replace(this.REPLACE_REGEXP,n.escapedQuote))}return-1!==i.search(this.ESCAPE_REGEXP)||this.shouldQuote(t,r)?this.quoteField(i):i}quoteField(e){const{quote:t}=this.formatterOptions;return"".concat(t).concat(e).concat(t)}}},{"lodash.escaperegexp":144,"lodash.isboolean":146,"lodash.isnil":149}],4:[function(e,t,r){"use strict";var i=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.RowFormatter=void 0;const n=i(e("lodash.isfunction")),s=i(e("lodash.isequal")),o=e("./FieldFormatter"),a=e("../types");class l{constructor(e){this.rowCount=0,this.formatterOptions=e,this.fieldFormatter=new o.FieldFormatter(e),this.headers=e.headers,this.shouldWriteHeaders=e.shouldWriteHeaders,this.hasWrittenHeaders=!1,null!==this.headers&&(this.fieldFormatter.headers=this.headers),e.transform&&(this.rowTransform=e.transform)}static isRowHashArray(e){return!!Array.isArray(e)&&(Array.isArray(e[0])&&2===e[0].length)}static isRowArray(e){return Array.isArray(e)&&!this.isRowHashArray(e)}static gatherHeaders(e){return l.isRowHashArray(e)?e.map(e=>e[0]):Array.isArray(e)?e:Object.keys(e)}static createTransform(e){return a.isSyncTransform(e)?(t,r)=>{let i=null;try{i=e(t)}catch(e){return r(e)}return r(null,i)}:(t,r)=>{e(t,r)}}set rowTransform(e){if(!n.default(e))throw new TypeError("The transform should be a function");this._rowTransform=l.createTransform(e)}format(e,t){this.callTransformer(e,(r,i)=>{if(r)return t(r);if(!e)return t(null);const n=[];if(i){const{shouldFormatColumns:e,headers:t}=this.checkHeaders(i);if(this.shouldWriteHeaders&&t&&!this.hasWrittenHeaders&&(n.push(this.formatColumns(t,!0)),this.hasWrittenHeaders=!0),e){const e=this.gatherColumns(i);n.push(this.formatColumns(e,!1))}}return t(null,n)})}finish(e){const t=[];if(this.formatterOptions.alwaysWriteHeaders&&0===this.rowCount){if(!this.headers)return e(new Error("`alwaysWriteHeaders` option is set to true but `headers` option not provided."));t.push(this.formatColumns(this.headers,!0))}return this.formatterOptions.includeEndRowDelimiter&&t.push(this.formatterOptions.rowDelimiter),e(null,t)}checkHeaders(e){if(this.headers)return{shouldFormatColumns:!0,headers:this.headers};const t=l.gatherHeaders(e);return this.headers=t,this.fieldFormatter.headers=t,this.shouldWriteHeaders?{shouldFormatColumns:!s.default(t,e),headers:t}:{shouldFormatColumns:!0,headers:null}}gatherColumns(e){if(null===this.headers)throw new Error("Headers is currently null");return Array.isArray(e)?l.isRowHashArray(e)?this.headers.map((t,r)=>{const i=e[r];return i?i[1]:""}):l.isRowArray(e)&&!this.shouldWriteHeaders?e:this.headers.map((t,r)=>e[r]):this.headers.map(t=>e[t])}callTransformer(e,t){return this._rowTransform?this._rowTransform(e,t):t(null,e)}formatColumns(e,t){const r=e.map((e,r)=>this.fieldFormatter.format(e,r,t)).join(this.formatterOptions.delimiter),{rowCount:i}=this;return this.rowCount+=1,i?[this.formatterOptions.rowDelimiter,r].join(""):r}}r.RowFormatter=l},{"../types":7,"./FieldFormatter":3,"lodash.isequal":147,"lodash.isfunction":148}],5:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.FieldFormatter=r.RowFormatter=void 0;var i=e("./RowFormatter");Object.defineProperty(r,"RowFormatter",{enumerable:!0,get:function(){return i.RowFormatter}});var n=e("./FieldFormatter");Object.defineProperty(r,"FieldFormatter",{enumerable:!0,get:function(){return n.FieldFormatter}})},{"./FieldFormatter":3,"./RowFormatter":4}],6:[function(e,t,r){(function(t){(function(){"use strict";var i=Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]},n=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},s=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t},o=function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),r.writeToPath=r.writeToString=r.writeToBuffer=r.writeToStream=r.write=r.format=r.FormatterOptions=r.CsvFormatterStream=void 0;const a=e("util"),l=e("stream"),h=s(e("fs")),c=e("./FormatterOptions"),u=e("./CsvFormatterStream");o(e("./types"),r);var f=e("./CsvFormatterStream");Object.defineProperty(r,"CsvFormatterStream",{enumerable:!0,get:function(){return f.CsvFormatterStream}});var d=e("./FormatterOptions");Object.defineProperty(r,"FormatterOptions",{enumerable:!0,get:function(){return d.FormatterOptions}}),r.format=e=>new u.CsvFormatterStream(new c.FormatterOptions(e)),r.write=(e,t)=>{const i=r.format(t),n=a.promisify((e,t)=>{i.write(e,void 0,t)});return e.reduce((e,t)=>e.then(()=>n(t)),Promise.resolve()).then(()=>i.end()).catch(e=>{i.emit("error",e)}),i},r.writeToStream=(e,t,i)=>r.write(t,i).pipe(e),r.writeToBuffer=function(e){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=[],s=new l.Writable({write(e,t,r){n.push(e),r()}});return new Promise((o,a)=>{s.on("error",a).on("finish",()=>o(t.concat(n))),r.write(e,i).pipe(s)})},r.writeToString=(e,t)=>r.writeToBuffer(e,t).then(e=>e.toString()),r.writeToPath=(e,t,i)=>{const n=h.createWriteStream(e,{encoding:"utf8"});return r.write(t,i).pipe(n)}}).call(this)}).call(this,e("buffer").Buffer)},{"./CsvFormatterStream":1,"./FormatterOptions":2,"./types":7,buffer:85,fs:84,stream:237,util:242}],7:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isSyncTransform=void 0,r.isSyncTransform=e=>1===e.length},{}],8:[function(e,t,r){(function(t){(function(){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.CsvParserStream=void 0;const i=e("string_decoder"),n=e("stream"),s=e("./transforms"),o=e("./parser");class a extends n.Transform{constructor(e){super({objectMode:e.objectMode}),this.lines="",this.rowCount=0,this.parsedRowCount=0,this.parsedLineCount=0,this.endEmitted=!1,this.headersEmitted=!1,this.parserOptions=e,this.parser=new o.Parser(e),this.headerTransformer=new s.HeaderTransformer(e),this.decoder=new i.StringDecoder(e.encoding),this.rowTransformerValidator=new s.RowTransformerValidator}get hasHitRowLimit(){return this.parserOptions.limitRows&&this.rowCount>=this.parserOptions.maxRows}get shouldEmitRows(){return this.parsedRowCount>this.parserOptions.skipRows}get shouldSkipLine(){return this.parsedLineCount<=this.parserOptions.skipLines}transform(e){return this.rowTransformerValidator.rowTransform=e,this}validate(e){return this.rowTransformerValidator.rowValidator=e,this}emit(e){if("end"===e)return this.endEmitted||(this.endEmitted=!0,super.emit("end",this.rowCount)),!1;for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return super.emit(e,...r)}_transform(e,t,r){if(this.hasHitRowLimit)return r();const i=a.wrapDoneCallback(r);try{const{lines:t}=this,r=t+this.decoder.write(e),n=this.parse(r,!0);return this.processRows(n,i)}catch(e){return i(e)}}_flush(e){const t=a.wrapDoneCallback(e);if(this.hasHitRowLimit)return t();try{const e=this.lines+this.decoder.end(),r=this.parse(e,!1);return this.processRows(r,t)}catch(e){return t(e)}}parse(e,t){if(!e)return[];const{line:r,rows:i}=this.parser.parse(e,t);return this.lines=r,i}processRows(e,r){const i=e.length,n=s=>{const o=e=>e?r(e):s%100!=0?n(s+1):void t(()=>n(s+1));if(this.checkAndEmitHeaders(),s>=i||this.hasHitRowLimit)return r();if(this.parsedLineCount+=1,this.shouldSkipLine)return o();const a=e[s];this.rowCount+=1,this.parsedRowCount+=1;const l=this.rowCount;return this.transformRow(a,(e,t)=>{if(e)return this.rowCount-=1,o(e);if(!t)return o(new Error("expected transform result"));if(t.isValid){if(t.row)return this.pushRow(t.row,o)}else this.emit("data-invalid",t.row,l,t.reason);return o()})};n(0)}transformRow(e,t){try{this.headerTransformer.transform(e,(r,i)=>r?t(r):i?i.isValid?i.row?this.shouldEmitRows?this.rowTransformerValidator.transformAndValidate(i.row,t):this.skipRow(t):(this.rowCount-=1,this.parsedRowCount-=1,t(null,{row:null,isValid:!0})):this.shouldEmitRows?t(null,{isValid:!1,row:e}):this.skipRow(t):t(new Error("Expected result from header transform")))}catch(e){t(e)}}checkAndEmitHeaders(){!this.headersEmitted&&this.headerTransformer.headers&&(this.headersEmitted=!0,this.emit("headers",this.headerTransformer.headers))}skipRow(e){return this.rowCount-=1,e(null,{row:null,isValid:!0})}pushRow(e,t){try{this.parserOptions.objectMode?this.push(e):this.push(JSON.stringify(e)),t()}catch(e){t(e)}}static wrapDoneCallback(e){let t=!1;return function(r){if(r){if(t)throw r;return t=!0,void e(r)}for(var i=arguments.length,n=new Array(i>1?i-1:0),s=1;s<i;s++)n[s-1]=arguments[s];e(...n)}}}r.CsvParserStream=a}).call(this)}).call(this,e("timers").setImmediate)},{"./parser":20,"./transforms":23,stream:237,string_decoder:87,timers:238}],9:[function(e,t,r){"use strict";var i=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.ParserOptions=void 0;const n=i(e("lodash.escaperegexp")),s=i(e("lodash.isnil"));r.ParserOptions=class{constructor(e){var t;if(this.objectMode=!0,this.delimiter=",",this.ignoreEmpty=!1,this.quote='"',this.escape=null,this.escapeChar=this.quote,this.comment=null,this.supportsComments=!1,this.ltrim=!1,this.rtrim=!1,this.trim=!1,this.headers=null,this.renameHeaders=!1,this.strictColumnHandling=!1,this.discardUnmappedColumns=!1,this.carriageReturn="\r",this.encoding="utf8",this.limitRows=!1,this.maxRows=0,this.skipLines=0,this.skipRows=0,Object.assign(this,e||{}),this.delimiter.length>1)throw new Error("delimiter option must be one character long");this.escapedDelimiter=n.default(this.delimiter),this.escapeChar=null!==(t=this.escape)&&void 0!==t?t:this.quote,this.supportsComments=!s.default(this.comment),this.NEXT_TOKEN_REGEXP=new RegExp("([^\\s]|\\r\\n|\\n|\\r|".concat(this.escapedDelimiter,")")),this.maxRows>0&&(this.limitRows=!0)}}},{"lodash.escaperegexp":144,"lodash.isnil":149}],10:[function(e,t,r){"use strict";var i=Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]},n=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},s=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t},o=function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),r.parseString=r.parseFile=r.parseStream=r.parse=r.ParserOptions=r.CsvParserStream=void 0;const a=s(e("fs")),l=e("stream"),h=e("./ParserOptions"),c=e("./CsvParserStream");o(e("./types"),r);var u=e("./CsvParserStream");Object.defineProperty(r,"CsvParserStream",{enumerable:!0,get:function(){return u.CsvParserStream}});var f=e("./ParserOptions");Object.defineProperty(r,"ParserOptions",{enumerable:!0,get:function(){return f.ParserOptions}}),r.parse=e=>new c.CsvParserStream(new h.ParserOptions(e)),r.parseStream=(e,t)=>e.pipe(new c.CsvParserStream(new h.ParserOptions(t))),r.parseFile=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return a.createReadStream(e).pipe(new c.CsvParserStream(new h.ParserOptions(t)))},r.parseString=(e,t)=>{const r=new l.Readable;return r.push(e),r.push(null),r.pipe(new c.CsvParserStream(new h.ParserOptions(t)))}},{"./CsvParserStream":8,"./ParserOptions":9,"./types":24,fs:84,stream:237}],11:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Parser=void 0;const i=e("./Scanner"),n=e("./RowParser"),s=e("./Token");class o{constructor(e){this.parserOptions=e,this.rowParser=new n.RowParser(this.parserOptions)}static removeBOM(e){return e&&65279===e.charCodeAt(0)?e.slice(1):e}parse(e,t){const r=new i.Scanner({line:o.removeBOM(e),parserOptions:this.parserOptions,hasMoreData:t});return this.parserOptions.supportsComments?this.parseWithComments(r):this.parseWithoutComments(r)}parseWithoutComments(e){const t=[];let r=!0;for(;r;)r=this.parseRow(e,t);return{line:e.line,rows:t}}parseWithComments(e){const{parserOptions:t}=this,r=[];for(let i=e.nextCharacterToken;null!==i;i=e.nextCharacterToken)if(s.Token.isTokenComment(i,t)){if(null===e.advancePastLine())return{line:e.lineFromCursor,rows:r};if(!e.hasMoreCharacters)return{line:e.lineFromCursor,rows:r};e.truncateToCursor()}else if(!this.parseRow(e,r))break;return{line:e.line,rows:r}}parseRow(e,t){if(!e.nextNonSpaceToken)return!1;const r=this.rowParser.parse(e);return null!==r&&(this.parserOptions.ignoreEmpty&&n.RowParser.isEmptyRow(r)||t.push(r),!0)}}r.Parser=o},{"./RowParser":12,"./Scanner":13,"./Token":14}],12:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.RowParser=void 0;const i=e("./column"),n=e("./Token");r.RowParser=class{constructor(e){this.parserOptions=e,this.columnParser=new i.ColumnParser(e)}static isEmptyRow(e){return""===e.join("").replace(/\s+/g,"")}parse(e){const{parserOptions:t}=this,{hasMoreData:r}=e,i=e,s=[];let o=this.getStartToken(i,s);for(;o;){if(n.Token.isTokenRowDelimiter(o))return i.advancePastToken(o),!i.hasMoreCharacters&&n.Token.isTokenCarriageReturn(o,t)&&r?null:(i.truncateToCursor(),s);if(!this.shouldSkipColumnParse(i,o,s)){const e=this.columnParser.parse(i);if(null===e)return null;s.push(e)}o=i.nextNonSpaceToken}return r?null:(i.truncateToCursor(),s)}getStartToken(e,t){const r=e.nextNonSpaceToken;return null!==r&&n.Token.isTokenDelimiter(r,this.parserOptions)?(t.push(""),e.nextNonSpaceToken):r}shouldSkipColumnParse(e,t,r){const{parserOptions:i}=this;if(n.Token.isTokenDelimiter(t,i)){e.advancePastToken(t);const s=e.nextCharacterToken;if(!e.hasMoreCharacters||null!==s&&n.Token.isTokenRowDelimiter(s))return r.push(""),!0;if(null!==s&&n.Token.isTokenDelimiter(s,i))return r.push(""),!0}return!1}}},{"./Token":14,"./column":19}],13:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Scanner=void 0;const i=e("./Token"),n=/((?:\r\n)|\n|\r)/;r.Scanner=class{constructor(e){this.cursor=0,this.line=e.line,this.lineLength=this.line.length,this.parserOptions=e.parserOptions,this.hasMoreData=e.hasMoreData,this.cursor=e.cursor||0}get hasMoreCharacters(){return this.lineLength>this.cursor}get nextNonSpaceToken(){const{lineFromCursor:e}=this,t=this.parserOptions.NEXT_TOKEN_REGEXP;if(-1===e.search(t))return null;const r=t.exec(e);if(null==r)return null;const n=r[1],s=this.cursor+(r.index||0);return new i.Token({token:n,startCursor:s,endCursor:s+n.length-1})}get nextCharacterToken(){const{cursor:e,lineLength:t}=this;return t<=e?null:new i.Token({token:this.line[e],startCursor:e,endCursor:e})}get lineFromCursor(){return this.line.substr(this.cursor)}advancePastLine(){const e=n.exec(this.lineFromCursor);return e?(this.cursor+=(e.index||0)+e[0].length,this):this.hasMoreData?null:(this.cursor=this.lineLength,this)}advanceTo(e){return this.cursor=e,this}advanceToToken(e){return this.cursor=e.startCursor,this}advancePastToken(e){return this.cursor=e.endCursor+1,this}truncateToCursor(){return this.line=this.lineFromCursor,this.lineLength=this.line.length,this.cursor=0,this}}},{"./Token":14}],14:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Token=void 0;r.Token=class{constructor(e){this.token=e.token,this.startCursor=e.startCursor,this.endCursor=e.endCursor}static isTokenRowDelimiter(e){const t=e.token;return"\r"===t||"\n"===t||"\r\n"===t}static isTokenCarriageReturn(e,t){return e.token===t.carriageReturn}static isTokenComment(e,t){return t.supportsComments&&!!e&&e.token===t.comment}static isTokenEscapeCharacter(e,t){return e.token===t.escapeChar}static isTokenQuote(e,t){return e.token===t.quote}static isTokenDelimiter(e,t){return e.token===t.delimiter}}},{}],15:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ColumnFormatter=void 0;r.ColumnFormatter=class{constructor(e){e.trim?this.format=e=>e.trim():e.ltrim?this.format=e=>e.trimLeft():e.rtrim?this.format=e=>e.trimRight():this.format=e=>e}}},{}],16:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ColumnParser=void 0;const i=e("./NonQuotedColumnParser"),n=e("./QuotedColumnParser"),s=e("../Token");r.ColumnParser=class{constructor(e){this.parserOptions=e,this.quotedColumnParser=new n.QuotedColumnParser(e),this.nonQuotedColumnParser=new i.NonQuotedColumnParser(e)}parse(e){const{nextNonSpaceToken:t}=e;return null!==t&&s.Token.isTokenQuote(t,this.parserOptions)?(e.advanceToToken(t),this.quotedColumnParser.parse(e)):this.nonQuotedColumnParser.parse(e)}}},{"../Token":14,"./NonQuotedColumnParser":17,"./QuotedColumnParser":18}],17:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.NonQuotedColumnParser=void 0;const i=e("./ColumnFormatter"),n=e("../Token");r.NonQuotedColumnParser=class{constructor(e){this.parserOptions=e,this.columnFormatter=new i.ColumnFormatter(e)}parse(e){if(!e.hasMoreCharacters)return null;const{parserOptions:t}=this,r=[];let i=e.nextCharacterToken;for(;i&&(!n.Token.isTokenDelimiter(i,t)&&!n.Token.isTokenRowDelimiter(i));i=e.nextCharacterToken)r.push(i.token),e.advancePastToken(i);return this.columnFormatter.format(r.join(""))}}},{"../Token":14,"./ColumnFormatter":15}],18:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.QuotedColumnParser=void 0;const i=e("./ColumnFormatter"),n=e("../Token");r.QuotedColumnParser=class{constructor(e){this.parserOptions=e,this.columnFormatter=new i.ColumnFormatter(e)}parse(e){if(!e.hasMoreCharacters)return null;const t=e.cursor,{foundClosingQuote:r,col:i}=this.gatherDataBetweenQuotes(e);if(!r){if(e.advanceTo(t),!e.hasMoreData)throw new Error("Parse Error: missing closing: '".concat(this.parserOptions.quote||"","' in line: at '").concat(e.lineFromCursor.replace(/[\r\n]/g,"\\n'"),"'"));return null}return this.checkForMalformedColumn(e),i}gatherDataBetweenQuotes(e){const{parserOptions:t}=this;let r=!1,i=!1;const s=[];let o=e.nextCharacterToken;for(;!i&&null!==o;o=e.nextCharacterToken){const a=n.Token.isTokenQuote(o,t);if(!r&&a)r=!0;else if(r)if(n.Token.isTokenEscapeCharacter(o,t)){e.advancePastToken(o);const r=e.nextCharacterToken;null!==r&&(n.Token.isTokenQuote(r,t)||n.Token.isTokenEscapeCharacter(r,t))?(s.push(r.token),o=r):a?i=!0:s.push(o.token)}else a?i=!0:s.push(o.token);e.advancePastToken(o)}return{col:this.columnFormatter.format(s.join("")),foundClosingQuote:i}}checkForMalformedColumn(e){const{parserOptions:t}=this,{nextNonSpaceToken:r}=e;if(r){const i=n.Token.isTokenDelimiter(r,t),s=n.Token.isTokenRowDelimiter(r);if(!i&&!s){const i=e.lineFromCursor.substr(0,10).replace(/[\r\n]/g,"\\n'");throw new Error("Parse Error: expected: '".concat(t.escapedDelimiter,"' OR new line got: '").concat(r.token,"'. at '").concat(i))}e.advanceToToken(r)}else e.hasMoreData||e.advancePastLine()}}},{"../Token":14,"./ColumnFormatter":15}],19:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ColumnFormatter=r.QuotedColumnParser=r.NonQuotedColumnParser=r.ColumnParser=void 0;var i=e("./ColumnParser");Object.defineProperty(r,"ColumnParser",{enumerable:!0,get:function(){return i.ColumnParser}});var n=e("./NonQuotedColumnParser");Object.defineProperty(r,"NonQuotedColumnParser",{enumerable:!0,get:function(){return n.NonQuotedColumnParser}});var s=e("./QuotedColumnParser");Object.defineProperty(r,"QuotedColumnParser",{enumerable:!0,get:function(){return s.QuotedColumnParser}});var o=e("./ColumnFormatter");Object.defineProperty(r,"ColumnFormatter",{enumerable:!0,get:function(){return o.ColumnFormatter}})},{"./ColumnFormatter":15,"./ColumnParser":16,"./NonQuotedColumnParser":17,"./QuotedColumnParser":18}],20:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.QuotedColumnParser=r.NonQuotedColumnParser=r.ColumnParser=r.Token=r.Scanner=r.RowParser=r.Parser=void 0;var i=e("./Parser");Object.defineProperty(r,"Parser",{enumerable:!0,get:function(){return i.Parser}});var n=e("./RowParser");Object.defineProperty(r,"RowParser",{enumerable:!0,get:function(){return n.RowParser}});var s=e("./Scanner");Object.defineProperty(r,"Scanner",{enumerable:!0,get:function(){return s.Scanner}});var o=e("./Token");Object.defineProperty(r,"Token",{enumerable:!0,get:function(){return o.Token}});var a=e("./column");Object.defineProperty(r,"ColumnParser",{enumerable:!0,get:function(){return a.ColumnParser}}),Object.defineProperty(r,"NonQuotedColumnParser",{enumerable:!0,get:function(){return a.NonQuotedColumnParser}}),Object.defineProperty(r,"QuotedColumnParser",{enumerable:!0,get:function(){return a.QuotedColumnParser}})},{"./Parser":11,"./RowParser":12,"./Scanner":13,"./Token":14,"./column":19}],21:[function(e,t,r){"use strict";var i=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.HeaderTransformer=void 0;const n=i(e("lodash.isundefined")),s=i(e("lodash.isfunction")),o=i(e("lodash.uniq")),a=i(e("lodash.groupby"));r.HeaderTransformer=class{constructor(e){this.headers=null,this.receivedHeaders=!1,this.shouldUseFirstRow=!1,this.processedFirstRow=!1,this.headersLength=0,this.parserOptions=e,!0===e.headers?this.shouldUseFirstRow=!0:Array.isArray(e.headers)?this.setHeaders(e.headers):s.default(e.headers)&&(this.headersTransform=e.headers)}transform(e,t){return this.shouldMapRow(e)?t(null,this.processRow(e)):t(null,{row:null,isValid:!0})}shouldMapRow(e){const{parserOptions:t}=this;if(!this.headersTransform&&t.renameHeaders&&!this.processedFirstRow){if(!this.receivedHeaders)throw new Error("Error renaming headers: new headers must be provided in an array");return this.processedFirstRow=!0,!1}if(!this.receivedHeaders&&Array.isArray(e)){if(this.headersTransform)this.setHeaders(this.headersTransform(e));else{if(!this.shouldUseFirstRow)return!0;this.setHeaders(e)}return!1}return!0}processRow(e){if(!this.headers)return{row:e,isValid:!0};const{parserOptions:t}=this;if(!t.discardUnmappedColumns&&e.length>this.headersLength){if(!t.strictColumnHandling)throw new Error("Unexpected Error: column header mismatch expected: ".concat(this.headersLength," columns got: ").concat(e.length));return{row:e,isValid:!1,reason:"Column header mismatch expected: ".concat(this.headersLength," columns got: ").concat(e.length)}}return t.strictColumnHandling&&e.length<this.headersLength?{row:e,isValid:!1,reason:"Column header mismatch expected: ".concat(this.headersLength," columns got: ").concat(e.length)}:{row:this.mapHeaders(e),isValid:!0}}mapHeaders(e){const t={},{headers:r,headersLength:i}=this;for(let s=0;s<i;s+=1){const i=r[s];if(!n.default(i)){const r=e[s];n.default(r)?t[i]="":t[i]=r}}return t}setHeaders(e){var t;const r=e.filter(e=>!!e);if(o.default(r).length!==r.length){const e=a.default(r),t=Object.keys(e).filter(t=>e[t].length>1);throw new Error("Duplicate headers found ".concat(JSON.stringify(t)))}this.headers=e,this.receivedHeaders=!0,this.headersLength=(null===(t=this.headers)||void 0===t?void 0:t.length)||0}}},{"lodash.groupby":145,"lodash.isfunction":148,"lodash.isundefined":150,"lodash.uniq":151}],22:[function(e,t,r){"use strict";var i=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.RowTransformerValidator=void 0;const n=i(e("lodash.isfunction")),s=e("../types");class o{constructor(){this._rowTransform=null,this._rowValidator=null}static createTransform(e){return s.isSyncTransform(e)?(t,r)=>{let i=null;try{i=e(t)}catch(e){return r(e)}return r(null,i)}:e}static createValidator(e){return s.isSyncValidate(e)?(t,r)=>{r(null,{row:t,isValid:e(t)})}:(t,r)=>{e(t,(e,i,n)=>e?r(e):r(null,i?{row:t,isValid:i,reason:n}:{row:t,isValid:!1,reason:n}))}}set rowTransform(e){if(!n.default(e))throw new TypeError("The transform should be a function");this._rowTransform=o.createTransform(e)}set rowValidator(e){if(!n.default(e))throw new TypeError("The validate should be a function");this._rowValidator=o.createValidator(e)}transformAndValidate(e,t){return this.callTransformer(e,(e,r)=>e?t(e):r?this.callValidator(r,(e,i)=>e?t(e):i&&!i.isValid?t(null,{row:r,isValid:!1,reason:i.reason}):t(null,{row:r,isValid:!0})):t(null,{row:null,isValid:!0}))}callTransformer(e,t){return this._rowTransform?this._rowTransform(e,t):t(null,e)}callValidator(e,t){return this._rowValidator?this._rowValidator(e,t):t(null,{row:e,isValid:!0})}}r.RowTransformerValidator=o},{"../types":24,"lodash.isfunction":148}],23:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.HeaderTransformer=r.RowTransformerValidator=void 0;var i=e("./RowTransformerValidator");Object.defineProperty(r,"RowTransformerValidator",{enumerable:!0,get:function(){return i.RowTransformerValidator}});var n=e("./HeaderTransformer");Object.defineProperty(r,"HeaderTransformer",{enumerable:!0,get:function(){return n.HeaderTransformer}})},{"./HeaderTransformer":21,"./RowTransformerValidator":22}],24:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isSyncValidate=r.isSyncTransform=void 0,r.isSyncTransform=e=>1===e.length,r.isSyncValidate=e=>1===e.length},{}],25:[function(e,t,r){"use strict";var i=r;i.bignum=e("bn.js"),i.define=e("./asn1/api").define,i.base=e("./asn1/base"),i.constants=e("./asn1/constants"),i.decoders=e("./asn1/decoders"),i.encoders=e("./asn1/encoders")},{"./asn1/api":26,"./asn1/base":28,"./asn1/constants":32,"./asn1/decoders":34,"./asn1/encoders":37,"bn.js":40}],26:[function(e,t,r){"use strict";var i=e("../asn1"),n=e("inherits");function s(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}r.define=function(e,t){return new s(e,t)},s.prototype._createNamed=function(t){var r;try{r=e("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){r=function(e){this._initNamed(e)}}return n(r,t),r.prototype._initNamed=function(e){t.call(this,e)},new r(this)},s.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(i.decoders[e])),this.decoders[e]},s.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},s.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(i.encoders[e])),this.encoders[e]},s.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},{"../asn1":25,inherits:142,vm:258}],27:[function(e,t,r){"use strict";var i=e("inherits"),n=e("../base").Reporter,s=e("buffer").Buffer;function o(e,t){n.call(this,t),s.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function a(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return e instanceof a||(e=new a(e,t)),this.length+=e.length,e}),this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=s.byteLength(e);else{if(!s.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}i(o,n),r.DecoderBuffer=o,o.prototype.save=function(){return{offset:this.offset,reporter:n.prototype.save.call(this)}},o.prototype.restore=function(e){var t=new o(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,n.prototype.restore.call(this,e.reporter),t},o.prototype.isEmpty=function(){return this.offset===this.length},o.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},o.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var r=new o(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},o.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},r.EncoderBuffer=a,a.prototype.join=function(e,t){return e||(e=new s(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(r){r.join(e,t),t+=r.length})):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):s.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e}},{"../base":28,buffer:85,inherits:142}],28:[function(e,t,r){"use strict";var i=r;i.Reporter=e("./reporter").Reporter,i.DecoderBuffer=e("./buffer").DecoderBuffer,i.EncoderBuffer=e("./buffer").EncoderBuffer,i.Node=e("./node")},{"./buffer":27,"./node":29,"./reporter":30}],29:[function(e,t,r){"use strict";var i=e("../base").Reporter,n=e("../base").EncoderBuffer,s=e("../base").DecoderBuffer,o=e("minimalistic-assert"),a=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],l=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(a);function h(e,t){var r={};this._baseState=r,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}t.exports=h;var c=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];h.prototype.clone=function(){var e=this._baseState,t={};c.forEach((function(r){t[r]=e[r]}));var r=new this.constructor(t.parent);return r._baseState=t,r},h.prototype._wrap=function(){var e=this._baseState;l.forEach((function(t){this[t]=function(){var r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}}),this)},h.prototype._init=function(e){var t=this._baseState;o(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),o.equal(t.children.length,1,"Root node can have only one child")},h.prototype._useArgs=function(e){var t=this._baseState,r=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==r.length&&(o(null===t.children),t.children=r,r.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(o(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach((function(r){r==(0|r)&&(r|=0);var i=e[r];t[i]=r})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){h.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),a.forEach((function(e){h.prototype[e]=function(){var t=this._baseState,r=Array.prototype.slice.call(arguments);return o(null===t.tag),t.tag=e,this._useArgs(r),this}})),h.prototype.use=function(e){o(e);var t=this._baseState;return o(null===t.use),t.use=e,this},h.prototype.optional=function(){return this._baseState.optional=!0,this},h.prototype.def=function(e){var t=this._baseState;return o(null===t.default),t.default=e,t.optional=!0,this},h.prototype.explicit=function(e){var t=this._baseState;return o(null===t.explicit&&null===t.implicit),t.explicit=e,this},h.prototype.implicit=function(e){var t=this._baseState;return o(null===t.explicit&&null===t.implicit),t.implicit=e,this},h.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},h.prototype.key=function(e){var t=this._baseState;return o(null===t.key),t.key=e,this},h.prototype.any=function(){return this._baseState.any=!0,this},h.prototype.choice=function(e){var t=this._baseState;return o(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},h.prototype.contains=function(e){var t=this._baseState;return o(null===t.use),t.contains=e,this},h.prototype._decode=function(e,t){var r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));var i,n=r.default,o=!0,a=null;if(null!==r.key&&(a=e.enterKey(r.key)),r.optional){var l=null;if(null!==r.explicit?l=r.explicit:null!==r.implicit?l=r.implicit:null!==r.tag&&(l=r.tag),null!==l||r.any){if(o=this._peekTag(e,l,r.any),e.isError(o))return o}else{var h=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),o=!0}catch(e){o=!1}e.restore(h)}}if(r.obj&&o&&(i=e.enterObject()),o){if(null!==r.explicit){var c=this._decodeTag(e,r.explicit);if(e.isError(c))return c;e=c}var u=e.offset;if(null===r.use&&null===r.choice){if(r.any)h=e.save();var f=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(f))return f;r.any?n=e.raw(h):e=f}if(t&&t.track&&null!==r.tag&&t.track(e.path(),u,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),n=r.any?n:null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),e.isError(n))return n;if(r.any||null!==r.choice||null===r.children||r.children.forEach((function(r){r._decode(e,t)})),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var d=new s(n);n=this._getUse(r.contains,e._reporterState.obj)._decode(d,t)}}return r.obj&&o&&(n=e.leaveObject(i)),null===r.key||null===n&&!0!==o?null!==a&&e.exitKey(a):e.leaveKey(a,r.key,n),n},h.prototype._decodeGeneric=function(e,t,r){var i=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,i.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&i.args?this._decodeObjid(t,i.args[0],i.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,i.args&&i.args[0],r):null!==i.use?this._getUse(i.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},h.prototype._getUse=function(e,t){var r=this._baseState;return r.useDecoder=this._use(e,t),o(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},h.prototype._decodeChoice=function(e,t){var r=this._baseState,i=null,n=!1;return Object.keys(r.choice).some((function(s){var o=e.save(),a=r.choice[s];try{var l=a._decode(e,t);if(e.isError(l))return!1;i={type:s,value:l},n=!0}catch(t){return e.restore(o),!1}return!0}),this),n?i:e.error("Choice not matched")},h.prototype._createEncoderBuffer=function(e){return new n(e,this.reporter)},h.prototype._encode=function(e,t,r){var i=this._baseState;if(null===i.default||i.default!==e){var n=this._encodeValue(e,t,r);if(void 0!==n&&!this._skipDefault(n,t,r))return n}},h.prototype._encodeValue=function(e,t,r){var n=this._baseState;if(null===n.parent)return n.children[0]._encode(e,t||new i);var s=null;if(this.reporter=t,n.optional&&void 0===e){if(null===n.default)return;e=n.default}var o=null,a=!1;if(n.any)s=this._createEncoderBuffer(e);else if(n.choice)s=this._encodeChoice(e,t);else if(n.contains)o=this._getUse(n.contains,r)._encode(e,t),a=!0;else if(n.children)o=n.children.map((function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");var i=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var n=r._encode(e[r._baseState.key],t,e);return t.leaveKey(i),n}),this).filter((function(e){return e})),o=this._createEncoderBuffer(o);else if("seqof"===n.tag||"setof"===n.tag){if(!n.args||1!==n.args.length)return t.error("Too many args for : "+n.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var l=this.clone();l._baseState.implicit=null,o=this._createEncoderBuffer(e.map((function(r){var i=this._baseState;return this._getUse(i.args[0],e)._encode(r,t)}),l))}else null!==n.use?s=this._getUse(n.use,r)._encode(e,t):(o=this._encodePrimitive(n.tag,e),a=!0);if(!n.any&&null===n.choice){var h=null!==n.implicit?n.implicit:n.tag,c=null===n.implicit?"universal":"context";null===h?null===n.use&&t.error("Tag could be omitted only for .use()"):null===n.use&&(s=this._encodeComposite(h,a,c,o))}return null!==n.explicit&&(s=this._encodeComposite(n.explicit,!1,"context",s)),s},h.prototype._encodeChoice=function(e,t){var r=this._baseState,i=r.choice[e.type];return i||o(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),i._encode(e.value,t)},h.prototype._encodePrimitive=function(e,t){var r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},h.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},h.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},{"../base":28,"minimalistic-assert":171}],30:[function(e,t,r){"use strict";var i=e("inherits");function n(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function s(e,t){this.path=e,this.rethrow(t)}r.Reporter=n,n.prototype.isError=function(e){return e instanceof s},n.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},n.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},n.prototype.enterKey=function(e){return this._reporterState.path.push(e)},n.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},n.prototype.leaveKey=function(e,t,r){var i=this._reporterState;this.exitKey(e),null!==i.obj&&(i.obj[t]=r)},n.prototype.path=function(){return this._reporterState.path.join("/")},n.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},n.prototype.leaveObject=function(e){var t=this._reporterState,r=t.obj;return t.obj=e,r},n.prototype.error=function(e){var t,r=this._reporterState,i=e instanceof s;if(t=i?e:new s(r.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!r.options.partial)throw t;return i||r.errors.push(t),t},n.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},i(s,Error),s.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,s),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},{inherits:142}],31:[function(e,t,r){"use strict";var i=e("../constants");r.tagClass={0:"universal",1:"application",2:"context",3:"private"},r.tagClassByName=i._reverse(r.tagClass),r.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},r.tagByName=i._reverse(r.tag)},{"../constants":32}],32:[function(e,t,r){"use strict";var i=r;i._reverse=function(e){var t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);var i=e[r];t[i]=r})),t},i.der=e("./der")},{"./der":31}],33:[function(e,t,r){"use strict";var i=e("inherits"),n=e("../../asn1"),s=n.base,o=n.bignum,a=n.constants.der;function l(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new h,this.tree._init(e.body)}function h(e){s.Node.call(this,"der",e)}function c(e,t){var r=e.readUInt8(t);if(e.isError(r))return r;var i=a.tagClass[r>>6],n=0==(32&r);if(31==(31&r)){var s=r;for(r=0;128==(128&s);){if(s=e.readUInt8(t),e.isError(s))return s;r<<=7,r|=127&s}}else r&=31;return{cls:i,primitive:n,tag:r,tagStr:a.tag[r]}}function u(e,t,r){var i=e.readUInt8(r);if(e.isError(i))return i;if(!t&&128===i)return null;if(0==(128&i))return i;var n=127&i;if(n>4)return e.error("length octect is too long");i=0;for(var s=0;s<n;s++){i<<=8;var o=e.readUInt8(r);if(e.isError(o))return o;i|=o}return i}t.exports=l,l.prototype.decode=function(e,t){return e instanceof s.DecoderBuffer||(e=new s.DecoderBuffer(e,t)),this.tree._decode(e,t)},i(h,s.Node),h.prototype._peekTag=function(e,t,r){if(e.isEmpty())return!1;var i=e.save(),n=c(e,'Failed to peek tag: "'+t+'"');return e.isError(n)?n:(e.restore(i),n.tag===t||n.tagStr===t||n.tagStr+"of"===t||r)},h.prototype._decodeTag=function(e,t,r){var i=c(e,'Failed to decode tag of "'+t+'"');if(e.isError(i))return i;var n=u(e,i.primitive,'Failed to get length of "'+t+'"');if(e.isError(n))return n;if(!r&&i.tag!==t&&i.tagStr!==t&&i.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(i.primitive||null!==n)return e.skip(n,'Failed to match body of: "'+t+'"');var s=e.save(),o=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(o)?o:(n=e.offset-s.offset,e.restore(s),e.skip(n,'Failed to match body of: "'+t+'"'))},h.prototype._skipUntilEnd=function(e,t){for(;;){var r=c(e,t);if(e.isError(r))return r;var i,n=u(e,r.primitive,t);if(e.isError(n))return n;if(i=r.primitive||null!==n?e.skip(n):this._skipUntilEnd(e,t),e.isError(i))return i;if("end"===r.tagStr)break}},h.prototype._decodeList=function(e,t,r,i){for(var n=[];!e.isEmpty();){var s=this._peekTag(e,"end");if(e.isError(s))return s;var o=r.decode(e,"der",i);if(e.isError(o)&&s)break;n.push(o)}return n},h.prototype._decodeStr=function(e,t){if("bitstr"===t){var r=e.readUInt8();return e.isError(r)?r:{unused:r,data:e.raw()}}if("bmpstr"===t){var i=e.raw();if(i.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");for(var n="",s=0;s<i.length/2;s++)n+=String.fromCharCode(i.readUInt16BE(2*s));return n}if("numstr"===t){var o=e.raw().toString("ascii");return this._isNumstr(o)?o:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){var a=e.raw().toString("ascii");return this._isPrintstr(a)?a:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error("Decoding of string type: "+t+" unsupported")},h.prototype._decodeObjid=function(e,t,r){for(var i,n=[],s=0;!e.isEmpty();){var o=e.readUInt8();s<<=7,s|=127&o,0==(128&o)&&(n.push(s),s=0)}128&o&&n.push(s);var a=n[0]/40|0,l=n[0]%40;if(i=r?n:[a,l].concat(n.slice(1)),t){var h=t[i.join(" ")];void 0===h&&(h=t[i.join(".")]),void 0!==h&&(i=h)}return i},h.prototype._decodeTime=function(e,t){var r=e.raw().toString();if("gentime"===t)var i=0|r.slice(0,4),n=0|r.slice(4,6),s=0|r.slice(6,8),o=0|r.slice(8,10),a=0|r.slice(10,12),l=0|r.slice(12,14);else{if("utctime"!==t)return e.error("Decoding "+t+" time is not supported yet");i=0|r.slice(0,2),n=0|r.slice(2,4),s=0|r.slice(4,6),o=0|r.slice(6,8),a=0|r.slice(8,10),l=0|r.slice(10,12);i=i<70?2e3+i:1900+i}return Date.UTC(i,n-1,s,o,a,l,0)},h.prototype._decodeNull=function(e){return null},h.prototype._decodeBool=function(e){var t=e.readUInt8();return e.isError(t)?t:0!==t},h.prototype._decodeInt=function(e,t){var r=e.raw(),i=new o(r);return t&&(i=t[i.toString(10)]||i),i},h.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree}},{"../../asn1":25,inherits:142}],34:[function(e,t,r){"use strict";var i=r;i.der=e("./der"),i.pem=e("./pem")},{"./der":33,"./pem":35}],35:[function(e,t,r){"use strict";var i=e("inherits"),n=e("buffer").Buffer,s=e("./der");function o(e){s.call(this,e),this.enc="pem"}i(o,s),t.exports=o,o.prototype.decode=function(e,t){for(var r=e.toString().split(/[\r\n]+/g),i=t.label.toUpperCase(),o=/^-----(BEGIN|END) ([^-]+)-----$/,a=-1,l=-1,h=0;h<r.length;h++){var c=r[h].match(o);if(null!==c&&c[2]===i){if(-1!==a){if("END"!==c[1])break;l=h;break}if("BEGIN"!==c[1])break;a=h}}if(-1===a||-1===l)throw new Error("PEM section not found for: "+i);var u=r.slice(a+1,l).join("");u.replace(/[^a-z0-9\+\/=]+/gi,"");var f=new n(u,"base64");return s.prototype.decode.call(this,f,t)}},{"./der":33,buffer:85,inherits:142}],36:[function(e,t,r){"use strict";var i=e("inherits"),n=e("buffer").Buffer,s=e("../../asn1"),o=s.base,a=s.constants.der;function l(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new h,this.tree._init(e.body)}function h(e){o.Node.call(this,"der",e)}function c(e){return e<10?"0"+e:e}t.exports=l,l.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},i(h,o.Node),h.prototype._encodeComposite=function(e,t,r,i){var s,o=function(e,t,r,i){var n;"seqof"===e?e="seq":"setof"===e&&(e="set");if(a.tagByName.hasOwnProperty(e))n=a.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return i.error("Unknown tag: "+e);n=e}if(n>=31)return i.error("Multi-octet tag encoding unsupported");t||(n|=32);return n|=a.tagClassByName[r||"universal"]<<6}(e,t,r,this.reporter);if(i.length<128)return(s=new n(2))[0]=o,s[1]=i.length,this._createEncoderBuffer([s,i]);for(var l=1,h=i.length;h>=256;h>>=8)l++;(s=new n(2+l))[0]=o,s[1]=128|l;h=1+l;for(var c=i.length;c>0;h--,c>>=8)s[h]=255&c;return this._createEncoderBuffer([s,i])},h.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new n(2*e.length),i=0;i<e.length;i++)r.writeUInt16BE(e.charCodeAt(i),2*i);return this._createEncoderBuffer(r)}return"numstr"===t?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===t?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus si