{"version":3,"file":"dash.mediaplayer.min.js","sourceRoot":"./src/","sources":["../node_modules/browserify/node_modules/browser-pack/_prelude.js","../externals/base64.js","../externals/cea608-parser.js","../externals/xml2json.js","../index_mediaplayerOnly.js","../node_modules/base64-js/index.js","../node_modules/buffer/index.js","../node_modules/codem-isoboxer/dist/iso_boxer.js","../node_modules/core-util-is/lib/util.js","../node_modules/events/events.js","../node_modules/fast-deep-equal/index.js","../node_modules/ieee754/index.js","../node_modules/imsc/src/main/js/doc.js","../node_modules/imsc/src/main/js/html.js","../node_modules/imsc/src/main/js/isd.js","../node_modules/imsc/src/main/js/main.js","../node_modules/imsc/src/main/js/names.js","../node_modules/imsc/src/main/js/styles.js","../node_modules/imsc/src/main/js/utils.js","../node_modules/inherits/inherits_browser.js","../node_modules/is-buffer/index.js","../node_modules/isarray/index.js","../node_modules/process-nextick-args/index.js","../node_modules/process/browser.js","../node_modules/readable-stream/duplex-browser.js","../node_modules/readable-stream/lib/_stream_duplex.js","../node_modules/readable-stream/lib/_stream_passthrough.js","../node_modules/readable-stream/lib/_stream_readable.js","../node_modules/readable-stream/lib/_stream_transform.js","../node_modules/readable-stream/lib/_stream_writable.js","../node_modules/readable-stream/lib/internal/streams/BufferList.js","../node_modules/readable-stream/lib/internal/streams/destroy.js","../node_modules/readable-stream/lib/internal/streams/stream-browser.js","../node_modules/readable-stream/passthrough.js","../node_modules/readable-stream/readable-browser.js","../node_modules/readable-stream/transform.js","../node_modules/readable-stream/writable-browser.js","../node_modules/safe-buffer/index.js","../node_modules/sax/lib/sax.js","../node_modules/stream-browserify/index.js","../node_modules/string_decoder/lib/string_decoder.js","../node_modules/timers-browserify/main.js","../node_modules/util-deprecate/browser.js","core/Debug.js","core/EventBus.js","core/FactoryMaker.js","core/Settings.js","core/Utils.js","core/Version.js","core/errors/Errors.js","core/errors/ErrorsBase.js","core/events/CoreEvents.js","core/events/Events.js","core/events/EventsBase.js","dash/DashAdapter.js","dash/DashHandler.js","dash/DashMetrics.js","dash/SegmentBaseLoader.js","dash/WebmSegmentBaseLoader.js","dash/constants/DashConstants.js","dash/controllers/RepresentationController.js","dash/controllers/SegmentBaseController.js","dash/controllers/SegmentsController.js","dash/models/DashManifestModel.js","dash/parser/DashParser.js","dash/parser/maps/CommonProperty.js","dash/parser/maps/MapNode.js","dash/parser/maps/RepresentationBaseValuesMap.js","dash/parser/maps/SegmentValuesMap.js","dash/parser/matchers/BaseMatcher.js","dash/parser/matchers/DateTimeMatcher.js","dash/parser/matchers/DurationMatcher.js","dash/parser/matchers/NumericMatcher.js","dash/parser/matchers/StringMatcher.js","dash/parser/objectiron.js","dash/utils/ListSegmentsGetter.js","dash/utils/Round10.js","dash/utils/SegmentBaseGetter.js","dash/utils/SegmentsUtils.js","dash/utils/TemplateSegmentsGetter.js","dash/utils/TimelineConverter.js","dash/utils/TimelineSegmentsGetter.js","dash/vo/AdaptationSet.js","dash/vo/BaseURL.js","dash/vo/Event.js","dash/vo/EventStream.js","dash/vo/ManifestInfo.js","dash/vo/MediaInfo.js","dash/vo/Mpd.js","dash/vo/Period.js","dash/vo/Representation.js","dash/vo/RepresentationInfo.js","dash/vo/Segment.js","dash/vo/StreamInfo.js","dash/vo/UTCTiming.js","streaming/FragmentLoader.js","streaming/ManifestLoader.js","streaming/ManifestUpdater.js","streaming/MediaPlayer.js","streaming/MediaPlayerEvents.js","streaming/PreBufferSink.js","streaming/SourceBufferSink.js","streaming/Stream.js","streaming/StreamProcessor.js","streaming/XlinkLoader.js","streaming/constants/Constants.js","streaming/constants/MetricsConstants.js","streaming/controllers/AbrController.js","streaming/controllers/BaseURLController.js","streaming/controllers/BlacklistController.js","streaming/controllers/BufferController.js","streaming/controllers/EventController.js","streaming/controllers/FragmentController.js","streaming/controllers/MediaController.js","streaming/controllers/MediaSourceController.js","streaming/controllers/PlaybackController.js","streaming/controllers/ScheduleController.js","streaming/controllers/StreamController.js","streaming/controllers/TimeSyncController.js","streaming/controllers/XlinkController.js","streaming/models/BaseURLTreeModel.js","streaming/models/CmcdModel.js","streaming/models/FragmentModel.js","streaming/models/ManifestModel.js","streaming/models/MediaPlayerModel.js","streaming/models/MetricsModel.js","streaming/models/URIFragmentModel.js","streaming/models/VideoModel.js","streaming/net/FetchLoader.js","streaming/net/HTTPLoader.js","streaming/net/SchemeLoaderFactory.js","streaming/net/URLLoader.js","streaming/net/XHRLoader.js","streaming/rules/DroppedFramesHistory.js","streaming/rules/RulesContext.js","streaming/rules/SwitchRequest.js","streaming/rules/SwitchRequestHistory.js","streaming/rules/ThroughputHistory.js","streaming/rules/abr/ABRRulesCollection.js","streaming/rules/abr/AbandonRequestsRule.js","streaming/rules/abr/BolaRule.js","streaming/rules/abr/DroppedFramesRule.js","streaming/rules/abr/InsufficientBufferRule.js","streaming/rules/abr/SwitchHistoryRule.js","streaming/rules/abr/ThroughputRule.js","streaming/rules/scheduling/BufferLevelRule.js","streaming/text/EmbeddedTextHtmlRender.js","streaming/text/NotFragmentedTextBufferController.js","streaming/text/TextBufferController.js","streaming/text/TextController.js","streaming/text/TextSourceBuffer.js","streaming/text/TextTracks.js","streaming/thumbnail/ThumbnailController.js","streaming/thumbnail/ThumbnailTracks.js","streaming/utils/BaseURLSelector.js","streaming/utils/BoxParser.js","streaming/utils/Capabilities.js","streaming/utils/CustomTimeRanges.js","streaming/utils/DOMStorage.js","streaming/utils/DefaultURLUtils.js","streaming/utils/EBMLParser.js","streaming/utils/ErrorHandler.js","streaming/utils/InitCache.js","streaming/utils/IsoFile.js","streaming/utils/LiveEdgeFinder.js","streaming/utils/ObjectUtils.js","streaming/utils/RequestModifier.js","streaming/utils/SupervisorTools.js","streaming/utils/TTMLParser.js","streaming/utils/URLUtils.js","streaming/utils/VTTParser.js","streaming/utils/baseUrlResolution/BasicSelector.js","streaming/utils/baseUrlResolution/DVBSelector.js","streaming/vo/BitrateInfo.js","streaming/vo/DashJSError.js","streaming/vo/DataChunk.js","streaming/vo/FragmentRequest.js","streaming/vo/HeadRequest.js","streaming/vo/IsoBox.js","streaming/vo/IsoBoxSearchInfo.js","streaming/vo/MetricsList.js","streaming/vo/TextRequest.js","streaming/vo/TextTrackInfo.js","streaming/vo/Thumbnail.js","streaming/vo/ThumbnailTrackInfo.js","streaming/vo/URIFragmentData.js","streaming/vo/metrics/BufferLevel.js","streaming/vo/metrics/BufferState.js","streaming/vo/metrics/DVRInfo.js","streaming/vo/metrics/DroppedFrames.js","streaming/vo/metrics/HTTPRequest.js","streaming/vo/metrics/ManifestUpdate.js","streaming/vo/metrics/PlayList.js","streaming/vo/metrics/RepresentationSwitch.js","streaming/vo/metrics/RequestsQueue.js","streaming/vo/metrics/SchedulingInfo.js"],"sourcesContent":["(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=\"function\"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error(\"Cannot find module '\"+i+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=\"function\"==typeof require&&require,i=0;i> 6));\n u.push(0x80 | (63 & c));\n } else if (c < 0x10000) {\n u.push(0xE0 | (c >> 12));\n u.push(0x80 | (63 & (c >> 6)));\n u.push(0x80 | (63 & c));\n } else {\n u.push(0xF0 | (c >> 18));\n u.push(0x80 | (63 & (c >> 12)));\n u.push(0x80 | (63 & (c >> 6)));\n u.push(0x80 | (63 & c));\n }\n }\n return u;\n};\nUTF8.decode = function(u) {\n var a = [];\n var i = 0;\n while (i < u.length) {\n var v = u[i++];\n if (v < 0x80) {\n // no need to mask byte\n } else if (v < 0xE0) {\n v = (31 & v) << 6;\n v |= (63 & u[i++]);\n } else if (v < 0xF0) {\n v = (15 & v) << 12;\n v |= (63 & u[i++]) << 6;\n v |= (63 & u[i++]);\n } else {\n v = (7 & v) << 18;\n v |= (63 & u[i++]) << 12;\n v |= (63 & u[i++]) << 6;\n v |= (63 & u[i++]);\n }\n a.push(String.fromCharCode(v));\n }\n return a.join('');\n};\n\nvar BASE64 = {};\n(function(T){\n var encodeArray = function(u) {\n var i = 0;\n var a = [];\n var n = 0 | (u.length / 3);\n while (0 < n--) {\n var v = (u[i] << 16) + (u[i+1] << 8) + u[i+2];\n i += 3;\n a.push(T.charAt(63 & (v >> 18)));\n a.push(T.charAt(63 & (v >> 12)));\n a.push(T.charAt(63 & (v >> 6)));\n a.push(T.charAt(63 & v));\n }\n if (2 == (u.length - i)) {\n var v = (u[i] << 16) + (u[i+1] << 8);\n a.push(T.charAt(63 & (v >> 18)));\n a.push(T.charAt(63 & (v >> 12)));\n a.push(T.charAt(63 & (v >> 6)));\n a.push('=');\n } else if (1 == (u.length - i)) {\n var v = (u[i] << 16);\n a.push(T.charAt(63 & (v >> 18)));\n a.push(T.charAt(63 & (v >> 12)));\n a.push('==');\n }\n return a.join('');\n }\n var R = (function(){\n var a = [];\n for (var i=0; i= minLevel) {\n console.log(this.time + \" [\" + severity + \"] \" + msg);\n }\n }\n };\n\n var numArrayToHexArray = function(numArray) {\n var hexArray = [];\n for (var j = 0; j < numArray.length; j++) {\n hexArray.push(numArray[j].toString(16));\n }\n return hexArray;\n };\n\n /**\n * State of CEA-608 pen or character\n * @constructor\n */\n var PenState = function(foreground, underline, italics, background, flash) {\n this.foreground = foreground || \"white\";\n this.underline = underline || false;\n this.italics = italics || false;\n this.background = background || \"black\";\n this.flash = flash || false;\n };\n\n PenState.prototype = {\n \n reset : function() {\n this.foreground = \"white\";\n this.underline = false;\n this.italics = false;\n this.background = \"black\";\n this.flash = false;\n },\n \n setStyles : function(styles) {\n var attribs = [\"foreground\", \"underline\", \"italics\", \"background\", \"flash\"];\n for (var i = 0 ; i < attribs.length; i++) {\n var style = attribs[i];\n if (styles.hasOwnProperty(style)) {\n this[style] = styles[style];\n }\n }\n },\n \n isDefault : function() {\n return (this.foreground === \"white\" && !this.underline && !this.italics && \n this.background === \"black\" && !this.flash);\n },\n\n equals : function(other) {\n return ( (this.foreground === other.foreground) && \n (this.underline === other.underline) &&\n (this.italics === other.italics) &&\n (this.background === other.background) &&\n (this.flash === other.flash) );\n },\n\n copy : function(newPenState) {\n this.foreground = newPenState.foreground;\n this.underline = newPenState.underline;\n this.italics = newPenState.italics;\n this.background = newPenState.background;\n this.flash = newPenState.flash;\n },\n \n toString: function() {\n return (\"color=\" + this.foreground + \", underline=\" + this.underline + \", italics=\" + this.italics +\n \", background=\" + this.background + \", flash=\" + this.flash);\n }\n };\n\n /**\n * Unicode character with styling and background.\n * @constructor\n */\n var StyledUnicodeChar = function(uchar, foreground, underline, italics, background, flash) {\n this.uchar = uchar || ' '; // unicode character\n this.penState = new PenState(foreground, underline,italics, background, flash);\n };\n\n StyledUnicodeChar.prototype = {\n \n reset: function() {\n this.uchar = ' ';\n this.penState.reset();\n },\n \n setChar: function(uchar, newPenState) {\n this.uchar = uchar;\n this.penState.copy(newPenState);\n },\n \n setPenState: function(newPenState) {\n this.penState.copy(newPenState);\n },\n \n equals: function(other) {\n return this.uchar === other.uchar && this.penState.equals(other.penState);\n },\n \n copy: function(newChar) {\n this.uchar = newChar.uchar;\n this.penState.copy(newChar.penState);\n },\n \n isEmpty : function() {\n return this.uchar === ' ' && this.penState.isDefault();\n }\n };\n\n /**\n * CEA-608 row consisting of NR_COLS instances of StyledUnicodeChar.\n * @constructor\n */\n var Row = function() {\n this.chars = [];\n for (var i = 0 ; i < NR_COLS ; i++) {\n this.chars.push(new StyledUnicodeChar());\n }\n this.pos = 0;\n this.currPenState = new PenState();\n };\n\n Row.prototype = {\n \n equals: function(other) {\n var equal = true;\n for (var i = 0 ; i < NR_COLS; i ++) {\n if (!this.chars[i].equals(other.chars[i])) {\n equal = false;\n break;\n }\n }\n return equal;\n },\n \n copy: function(other) {\n for (var i = 0 ; i < NR_COLS; i ++) {\n this.chars[i].copy(other.chars[i]);\n }\n },\n \n isEmpty : function() {\n var empty = true;\n for (var i = 0 ; i < NR_COLS; i ++) {\n if (!this.chars[i].isEmpty()) {\n empty = false;\n break;\n }\n }\n return empty;\n },\n\n /**\n * Set the cursor to a valid column.\n */\n setCursor : function(absPos) {\n if (this.pos !== absPos) {\n this.pos = absPos;\n }\n if (this.pos < 0) {\n logger.log(\"ERROR\", \"Negative cursor position \" + this.pos);\n this.pos = 0;\n } else if (this.pos > NR_COLS) {\n logger.log(\"ERROR\", \"Too large cursor position \" + this.pos);\n this.pos = NR_COLS;\n }\n },\n\n /** \n * Move the cursor relative to current position.\n */\n moveCursor : function(relPos) {\n var newPos = this.pos + relPos;\n if (relPos > 1) {\n for (var i = this.pos+1; i < newPos+1 ; i++) {\n this.chars[i].setPenState(this.currPenState);\n }\n }\n this.setCursor(newPos);\n },\n\n /**\n * Backspace, move one step back and clear character.\n */\n backSpace : function () {\n this.moveCursor(-1);\n this.chars[this.pos].setChar(' ', this.currPenState);\n },\n\n insertChar: function(byte) {\n if (byte >= 0x90) { //Extended char\n this.backSpace();\n }\n var char = getCharForByte(byte);\n if (this.pos >= NR_COLS) {\n logger.log(\"ERROR\", \"Cannot insert \" + byte.toString(16) + \n \" (\" + char + \") at position \" + this.pos + \". Skipping it!\");\n return;\n }\n this.chars[this.pos].setChar(char, this.currPenState);\n this.moveCursor(1);\n },\n\n clearFromPos : function(startPos) {\n var i;\n for (i = startPos ; i < NR_COLS ; i++) {\n this.chars[i].reset();\n }\n },\n\n clear : function() {\n this.clearFromPos(0);\n this.pos = 0;\n this.currPenState.reset();\n },\n\n clearToEndOfRow : function() {\n this.clearFromPos(this.pos);\n },\n\n getTextString: function() {\n var chars = [];\n var empty = true;\n for (var i = 0 ; i < NR_COLS ; i++) {\n var char = this.chars[i].uchar;\n if (char !== \" \") {\n empty = false;\n }\n chars.push(char);\n }\n if (empty) {\n return \"\";\n } else {\n return chars.join(\"\");\n }\n },\n\n setPenStyles: function(styles) {\n this.currPenState.setStyles(styles);\n var currChar = this.chars[this.pos];\n currChar.setPenState(this.currPenState);\n }\n };\n\n /**\n * Keep a CEA-608 screen of 32x15 styled characters\n * @constructor\n */\n var CaptionScreen = function() {\n\n this.rows = [];\n for (var i = 0 ; i < NR_ROWS; i++) {\n this.rows.push(new Row()); // Note that we use zero-based numbering (0-14)\n }\n this.currRow = NR_ROWS - 1;\n this.nrRollUpRows = null;\n this.reset();\n };\n\n CaptionScreen.prototype = {\n\n reset : function() {\n for (var i = 0 ; i < NR_ROWS ; i++) {\n this.rows[i].clear();\n }\n this.currRow = NR_ROWS - 1;\n },\n\n equals : function(other) {\n var equal = true;\n for (var i = 0 ; i < NR_ROWS ; i++) {\n if (!this.rows[i].equals(other.rows[i])) {\n equal = false;\n break;\n }\n }\n return equal;\n },\n\n copy : function(other) {\n for (var i = 0 ; i < NR_ROWS ; i++) {\n this.rows[i].copy(other.rows[i]);\n }\n },\n\n isEmpty : function() {\n var empty = true;\n for (var i = 0 ; i < NR_ROWS ; i++) {\n if (!this.rows[i].isEmpty()) {\n empty = false;\n break;\n }\n }\n return empty;\n },\n\n backSpace : function() {\n var row = this.rows[this.currRow]; \n row.backSpace();\n },\n\n clearToEndOfRow : function() {\n var row = this.rows[this.currRow];\n row.clearToEndOfRow();\n },\n\n /**\n * Insert a character (without styling) in the current row.\n */\n insertChar : function(char) {\n var row = this.rows[this.currRow];\n row.insertChar(char);\n },\n\n setPen : function(styles) {\n var row = this.rows[this.currRow];\n row.setPenStyles(styles);\n },\n\n moveCursor : function(relPos) {\n var row = this.rows[this.currRow];\n row.moveCursor(relPos); \n },\n\n setCursor : function(absPos) {\n logger.log(\"INFO\", \"setCursor: \" + absPos);\n var row = this.rows[this.currRow];\n row.setCursor(absPos);\n },\n\n setPAC : function(pacData) {\n logger.log(\"INFO\", \"pacData = \" + JSON.stringify(pacData));\n var newRow = pacData.row - 1;\n if (this.nrRollUpRows && newRow < this.nrRollUpRows - 1) {\n newRow = this.nrRollUpRows-1;\n }\n this.currRow = newRow;\n var row = this.rows[this.currRow];\n if (pacData.indent !== null) {\n var indent = pacData.indent;\n var prevPos = Math.max(indent-1, 0);\n row.setCursor(pacData.indent);\n pacData.color = row.chars[prevPos].penState.foreground;\n }\n var styles = {foreground : pacData.color, underline : pacData.underline, italics : pacData.italics, background : 'black', flash : false};\n this.setPen(styles);\n },\n\n /**\n * Set background/extra foreground, but first do back_space, and then insert space (backwards compatibility).\n */\n setBkgData : function(bkgData) {\n\n logger.log(\"INFO\", \"bkgData = \" + JSON.stringify(bkgData));\n this.backSpace();\n this.setPen(bkgData);\n this.insertChar(0x20); //Space\n },\n\n setRollUpRows : function(nrRows) {\n this.nrRollUpRows = nrRows;\n },\n\n rollUp : function() {\n if (this.nrRollUpRows === null) {\n logger.log(\"DEBUG\", \"roll_up but nrRollUpRows not set yet\");\n return; //Not properly setup\n }\n logger.log(\"TEXT\", this.getDisplayText());\n var topRowIndex = this.currRow + 1 - this.nrRollUpRows;\n var topRow = this.rows.splice(topRowIndex, 1)[0];\n topRow.clear();\n this.rows.splice(this.currRow, 0, topRow);\n logger.log(\"INFO\", \"Rolling up\");\n //logger.log(\"TEXT\", this.get_display_text())\n },\n\n /**\n * Get all non-empty rows with as unicode text. \n */ \n getDisplayText : function(asOneRow) {\n asOneRow = asOneRow || false;\n var displayText = [];\n var text = \"\";\n var rowNr = -1;\n for (var i = 0 ; i < NR_ROWS ; i++) {\n var rowText = this.rows[i].getTextString();\n if (rowText) {\n rowNr = i+1;\n if (asOneRow) {\n displayText.push(\"Row \" + rowNr + ': \"' + rowText + '\"');\n } else {\n displayText.push(rowText.trim());\n }\n }\n }\n if (displayText.length > 0) {\n if (asOneRow) {\n text = \"[\" + displayText.join(\" | \") + \"]\";\n } else {\n text = displayText.join(\"\\n\");\n }\n }\n return text;\n },\n\n getTextAndFormat : function() {\n return this.rows;\n }\n };\n\n /**\n * Handle a CEA-608 channel and send decoded data to outputFilter\n * @constructor\n * @param {Number} channelNumber (1 or 2)\n * @param {CueHandler} outputFilter Output from channel1 newCue(startTime, endTime, captionScreen)\n */\n var Cea608Channel = function(channelNumber, outputFilter) {\n\n this.chNr = channelNumber;\n this.outputFilter = outputFilter;\n this.mode = null;\n this.verbose = 0;\n this.displayedMemory = new CaptionScreen();\n this.nonDisplayedMemory = new CaptionScreen();\n this.lastOutputScreen = new CaptionScreen();\n this.currRollUpRow = this.displayedMemory.rows[NR_ROWS-1];\n this.writeScreen = this.displayedMemory;\n this.mode = null;\n this.cueStartTime = null; // Keeps track of where a cue started.\n };\n\n Cea608Channel.prototype = {\n \n modes : [\"MODE_ROLL-UP\", \"MODE_POP-ON\", \"MODE_PAINT-ON\", \"MODE_TEXT\"],\n \n reset : function() {\n this.mode = null;\n this.displayedMemory.reset();\n this.nonDisplayedMemory.reset();\n this.lastOutputScreen.reset();\n this.currRollUpRow = this.displayedMemory.rows[NR_ROWS-1];\n this.writeScreen = this.displayedMemory;\n this.mode = null;\n this.cueStartTime = null;\n this.lastCueEndTime = null;\n },\n\n getHandler : function() {\n return this.outputFilter;\n },\n\n setHandler : function(newHandler) {\n this.outputFilter = newHandler;\n },\n\n setPAC : function(pacData) {\n this.writeScreen.setPAC(pacData);\n },\n\n setBkgData : function(bkgData) {\n this.writeScreen.setBkgData(bkgData);\n },\n\n setMode : function(newMode) {\n if (newMode === this.mode) {\n return;\n }\n this.mode = newMode;\n logger.log(\"INFO\", \"MODE=\" + newMode);\n if (this.mode == \"MODE_POP-ON\") {\n this.writeScreen = this.nonDisplayedMemory;\n } else {\n this.writeScreen = this.displayedMemory;\n this.writeScreen.reset();\n }\n if (this.mode !== \"MODE_ROLL-UP\") {\n this.displayedMemory.nrRollUpRows = null;\n this.nonDisplayedMemory.nrRollUpRows = null;\n }\n this.mode = newMode;\n },\n\n insertChars : function(chars) {\n for (var i = 0 ; i < chars.length ; i++) {\n this.writeScreen.insertChar(chars[i]);\n }\n var screen = this.writeScreen === this.displayedMemory ? \"DISP\" : \"NON_DISP\";\n logger.log(\"INFO\", screen + \": \" + this.writeScreen.getDisplayText(true));\n if (this.mode === \"MODE_PAINT-ON\" || this.mode === \"MODE_ROLL-UP\") {\n logger.log(\"TEXT\", \"DISPLAYED: \" + this.displayedMemory.getDisplayText(true));\n this.outputDataUpdate();\n }\n },\n\n cc_RCL: function() { // Resume Caption Loading (switch mode to Pop On)\n logger.log(\"INFO\", \"RCL - Resume Caption Loading\");\n this.setMode(\"MODE_POP-ON\");\n },\n cc_BS: function() { // BackSpace\n logger.log(\"INFO\", \"BS - BackSpace\");\n if (this.mode === \"MODE_TEXT\") {\n return;\n }\n this.writeScreen.backSpace();\n if (this.writeScreen === this.displayedMemory) {\n this.outputDataUpdate();\n }\n },\n cc_AOF : function() { // Reserved (formerly Alarm Off)\n return;\n },\n cc_AON: function() { // Reserved (formerly Alarm On)\n return;\n },\n cc_DER: function() { // Delete to End of Row\n logger.log(\"INFO\", \"DER- Delete to End of Row\");\n this.writeScreen.clearToEndOfRow();\n this.outputDataUpdate();\n },\n cc_RU: function(nrRows) { //Roll-Up Captions-2,3,or 4 Rows\n logger.log(\"INFO\", \"RU(\" + nrRows +\") - Roll Up\");\n this.writeScreen = this.displayedMemory;\n this.setMode(\"MODE_ROLL-UP\");\n this.writeScreen.setRollUpRows(nrRows);\n },\n cc_FON: function() { //Flash On\n logger.log(\"INFO\", \"FON - Flash On\");\n this.writeScreen.setPen({flash : true});\n },\n cc_RDC: function() { // Resume Direct Captioning (switch mode to PaintOn)\n logger.log(\"INFO\", \"RDC - Resume Direct Captioning\");\n this.setMode(\"MODE_PAINT-ON\");\n },\n cc_TR: function() { // Text Restart in text mode (not supported, however)\n logger.log(\"INFO\", \"TR\");\n this.setMode(\"MODE_TEXT\");\n },\n cc_RTD: function() { // Resume Text Display in Text mode (not supported, however)\n logger.log(\"INFO\", \"RTD\");\n this.setMode(\"MODE_TEXT\");\n },\n cc_EDM: function() { // Erase Displayed Memory\n logger.log(\"INFO\", \"EDM - Erase Displayed Memory\");\n this.displayedMemory.reset();\n this.outputDataUpdate();\n },\n cc_CR: function() { // Carriage Return\n logger.log(\"CR - Carriage Return\");\n this.writeScreen.rollUp();\n this.outputDataUpdate();\n },\n cc_ENM: function() { //Erase Non-Displayed Memory\n logger.log(\"INFO\", \"ENM - Erase Non-displayed Memory\");\n this.nonDisplayedMemory.reset();\n },\n cc_EOC: function() { //End of Caption (Flip Memories)\n logger.log(\"INFO\", \"EOC - End Of Caption\");\n if (this.mode === \"MODE_POP-ON\") {\n var tmp = this.displayedMemory;\n this.displayedMemory = this.nonDisplayedMemory;\n this.nonDisplayedMemory = tmp;\n this.writeScreen = this.nonDisplayedMemory;\n logger.log(\"TEXT\", \"DISP: \" + this.displayedMemory.getDisplayText());\n }\n this.outputDataUpdate();\n },\n cc_TO: function(nrCols) { // Tab Offset 1,2, or 3 columns\n logger.log(\"INFO\", \"TO(\" + nrCols + \") - Tab Offset\");\n this.writeScreen.moveCursor(nrCols);\n },\n cc_MIDROW: function(secondByte) { // Parse MIDROW command\n var styles = {flash : false};\n styles.underline = secondByte % 2 === 1;\n styles.italics = secondByte >= 0x2e;\n if (!styles.italics) {\n var colorIndex = Math.floor(secondByte/2) - 0x10;\n var colors = [\"white\", \"green\", \"blue\", \"cyan\", \"red\", \"yellow\", \"magenta\"];\n styles.foreground = colors[colorIndex];\n } else {\n styles.foreground = \"white\";\n }\n logger.log(\"INFO\", \"MIDROW: \" + JSON.stringify(styles));\n this.writeScreen.setPen(styles);\n },\n\n outputDataUpdate: function() {\n var t = logger.time;\n if (t === null) {\n return;\n }\n if (this.outputFilter) {\n if (this.outputFilter.updateData) {\n this.outputFilter.updateData(t, this.displayedMemory);\n }\n if (this.cueStartTime === null && !this.displayedMemory.isEmpty()) { // Start of a new cue\n this.cueStartTime = t;\n } else {\n if (!this.displayedMemory.equals(this.lastOutputScreen)) { \n if (this.outputFilter.newCue) {\n this.outputFilter.newCue(this.cueStartTime, t, this.lastOutputScreen);\n }\n this.cueStartTime = this.displayedMemory.isEmpty() ? null : t;\n }\n }\n this.lastOutputScreen.copy(this.displayedMemory);\n }\n },\n\n cueSplitAtTime : function(t) {\n if (this.outputFilter) {\n if (!this.displayedMemory.isEmpty()) {\n if (this.outputFilter.newCue) {\n this.outputFilter.newCue(this.cueStartTime, t, this.displayedMemory);\n }\n this.cueStartTime = t;\n }\n }\n }\n };\n\n /**\n * Parse CEA-608 data and send decoded data to out1 and out2.\n * @constructor\n * @param {Number} field CEA-608 field (1 or 2)\n * @param {CueHandler} out1 Output from channel1 newCue(startTime, endTime, captionScreen)\n * @param {CueHandler} out2 Output from channel2 newCue(startTime, endTime, captionScreen)\n */\n var Cea608Parser = function(field, out1, out2) {\n this.field = field || 1;\n this.outputs = [out1, out2];\n this.channels = [new Cea608Channel(1, out1), new Cea608Channel(2, out2)];\n this.currChNr = -1; // Will be 1 or 2\n this.lastCmdA = null; // First byte of last command\n this.lastCmdB = null; // Second byte of last command\n this.bufferedData = [];\n this.startTime = null;\n this.lastTime = null;\n this.dataCounters = {'padding' : 0, 'char' : 0, 'cmd' : 0, 'other' : 0};\n };\n\n Cea608Parser.prototype = {\n \n getHandler : function(index) {\n return this.channels[index].getHandler();\n },\n \n setHandler : function(index, newHandler) {\n this.channels[index].setHandler(newHandler);\n },\n\n /**\n * Add data for time t in forms of list of bytes (unsigned ints). The bytes are treated as pairs.\n */\n addData : function(t, byteList) {\n var cmdFound, a, b, \n charsFound = false;\n \n this.lastTime = t;\n logger.setTime(t);\n\n for (var i = 0 ; i < byteList.length ; i+=2) {\n a = byteList[i] & 0x7f;\n b = byteList[i+1] & 0x7f;\n\n if (a >= 0x10 && a <= 0x1f && a === this.lastCmdA && b === this.lastCmdB) {\n this.lastCmdA = null;\n this.lastCmdB = null;\n logger.log(\"DEBUG\", \"Repeated command (\" + numArrayToHexArray([a, b]) + \") is dropped\");\n continue; // Repeated commands are dropped (once)\n }\n\n if (a === 0 && b === 0) {\n this.dataCounters.padding += 2;\n continue;\n } else {\n logger.log(\"DATA\", \"[\" + numArrayToHexArray([byteList[i], byteList[i+1]]) +\"] -> (\" + numArrayToHexArray([a, b]) + \")\");\n }\n cmdFound = this.parseCmd(a, b);\n if (!cmdFound) {\n cmdFound = this.parseMidrow(a, b);\n }\n if (!cmdFound) {\n cmdFound = this.parsePAC(a, b);\n }\n if (!cmdFound) {\n cmdFound = this.parseBackgroundAttributes(a, b);\n }\n if (!cmdFound) {\n charsFound = this.parseChars(a, b);\n if (charsFound) {\n if (this.currChNr && this.currChNr >=0) {\n var channel = this.channels[this.currChNr-1];\n channel.insertChars(charsFound);\n } else {\n logger.log(\"WARNING\", \"No channel found yet. TEXT-MODE?\");\n }\n }\n }\n if (cmdFound) {\n this.dataCounters.cmd += 2;\n } else if (charsFound) {\n this.dataCounters.char += 2;\n } else {\n this.dataCounters.other += 2;\n logger.log(\"WARNING\", \"Couldn't parse cleaned data \" + numArrayToHexArray([a, b]) +\n \" orig: \" + numArrayToHexArray([byteList[i], byteList[i+1]]));\n }\n }\n },\n\n /**\n * Parse Command.\n * @returns {Boolean} Tells if a command was found\n */\n parseCmd: function(a, b) {\n var chNr = null;\n\n var cond1 = (a === 0x14 || a === 0x15 || a === 0x1C || a === 0x1D) && (0x20 <= b && b <= 0x2F);\n var cond2 = (a === 0x17 || a === 0x1F) && (0x21 <= b && b <= 0x23);\n if (!(cond1 || cond2)) {\n return false;\n }\n \n if (a === 0x14 || a === 0x15 || a === 0x17) {\n chNr = 1;\n } else {\n chNr = 2; // (a === 0x1C || a === 0x1D || a=== 0x1f)\n }\n\n var channel = this.channels[chNr - 1];\n\n if (a === 0x14 || a === 0x15 || a === 0x1C || a === 0x1D) {\n if (b === 0x20) {\n channel.cc_RCL();\n } else if (b === 0x21) {\n channel.cc_BS();\n } else if (b === 0x22) {\n channel.cc_AOF();\n } else if (b === 0x23) {\n channel.cc_AON();\n } else if (b === 0x24) {\n channel.cc_DER();\n } else if (b === 0x25) {\n channel.cc_RU(2);\n } else if (b === 0x26) {\n channel.cc_RU(3);\n } else if (b === 0x27) {\n channel.cc_RU(4);\n } else if (b === 0x28) {\n channel.cc_FON();\n } else if (b === 0x29) {\n channel.cc_RDC();\n } else if (b === 0x2A) {\n channel.cc_TR();\n } else if (b === 0x2B) {\n channel.cc_RTD();\n } else if (b === 0x2C) {\n channel.cc_EDM();\n } else if (b === 0x2D) {\n channel.cc_CR();\n } else if (b === 0x2E) {\n channel.cc_ENM();\n } else if (b === 0x2F) {\n channel.cc_EOC();\n }\n } else { //a == 0x17 || a == 0x1F\n channel.cc_TO(b - 0x20);\n }\n this.lastCmdA = a;\n this.lastCmdB = b;\n this.currChNr = chNr;\n return true;\n },\n\n /**\n * Parse midrow styling command\n * @returns {Boolean}\n */\n parseMidrow : function(a, b) {\n var chNr = null;\n \n if ( ((a === 0x11) || (a === 0x19)) && 0x20 <= b && b <= 0x2f) {\n if (a === 0x11) {\n chNr = 1;\n } else {\n chNr = 2;\n }\n if (chNr !== this.currChNr) {\n logger.log(\"ERROR\", \"Mismatch channel in midrow parsing\");\n return false;\n }\n var channel = this.channels[chNr-1];\n // cea608 spec says midrow codes should inject a space\n channel.insertChars([0x20]);\n channel.cc_MIDROW(b);\n logger.log(\"DEBUG\", \"MIDROW (\" + numArrayToHexArray([a, b]) + \")\");\n this.lastCmdA = a;\n this.lastCmdB = b;\n return true;\n }\n return false;\n },\n /**\n * Parse Preable Access Codes (Table 53).\n * @returns {Boolean} Tells if PAC found\n */\n parsePAC : function(a, b) {\n\n var chNr = null;\n var row = null;\n \n var case1 = ((0x11 <= a && a <= 0x17) || (0x19 <= a && a <= 0x1F)) && (0x40 <= b && b <= 0x7F);\n var case2 = (a === 0x10 || a === 0x18) && (0x40 <= b && b <= 0x5F);\n if (! (case1 || case2)) {\n return false;\n }\n\n chNr = (a <= 0x17) ? 1 : 2;\n\n if (0x40 <= b && b <= 0x5F) {\n row = (chNr === 1) ? rowsLowCh1[a] : rowsLowCh2[a];\n } else { // 0x60 <= b <= 0x7F\n row = (chNr === 1) ? rowsHighCh1[a] : rowsHighCh2[a];\n }\n var pacData = this.interpretPAC(row, b);\n var channel = this.channels[chNr-1];\n channel.setPAC(pacData);\n this.lastCmdA = a;\n this.lastCmdB = b;\n this.currChNr = chNr;\n return true;\n },\n\n /**\n * Interpret the second byte of the pac, and return the information.\n * @returns {Object} pacData with style parameters.\n */\n interpretPAC : function (row, byte) {\n var pacIndex = byte;\n var pacData = {color : null, italics : false, indent : null, underline : false, row : row};\n \n if (byte > 0x5F) {\n pacIndex = byte - 0x60;\n } else {\n pacIndex = byte - 0x40;\n }\n pacData.underline = (pacIndex & 1) === 1;\n if (pacIndex <= 0xd) {\n pacData.color = ['white', 'green', 'blue', 'cyan', 'red', 'yellow', 'magenta', 'white'][Math.floor(pacIndex/2)];\n } else if (pacIndex <= 0xf) {\n pacData.italics = true;\n pacData.color = 'white';\n } else {\n pacData.indent = (Math.floor((pacIndex-0x10)/2))*4;\n }\n return pacData; // Note that row has zero offset. The spec uses 1.\n },\n\n /**\n * Parse characters.\n * @returns An array with 1 to 2 codes corresponding to chars, if found. null otherwise.\n */\n parseChars : function(a, b) {\n\n var channelNr = null,\n charCodes = null,\n charCode1 = null,\n charCode2 = null;\n\n if (a >= 0x19) {\n channelNr = 2;\n charCode1 = a - 8;\n } else {\n channelNr = 1;\n charCode1 = a;\n }\n if (0x11 <= charCode1 && charCode1 <= 0x13) {\n // Special character\n var oneCode = b;\n if (charCode1 === 0x11) {\n oneCode = b + 0x50;\n } else if (charCode1 === 0x12) {\n oneCode = b + 0x70;\n } else {\n oneCode = b + 0x90;\n }\n logger.log(\"INFO\", \"Special char '\" + getCharForByte(oneCode) + \"' in channel \" + channelNr);\n charCodes = [oneCode];\n this.lastCmdA = a;\n this.lastCmdB = b;\n } else if (0x20 <= a && a <= 0x7f) {\n charCodes = (b === 0) ? [a] : [a, b];\n this.lastCmdA = null;\n this.lastCmdB = null;\n }\n if (charCodes) {\n var hexCodes = numArrayToHexArray(charCodes);\n logger.log(\"DEBUG\", \"Char codes = \" + hexCodes.join(\",\"));\n }\n return charCodes;\n },\n \n /**\n * Parse extended background attributes as well as new foreground color black.\n * @returns{Boolean} Tells if background attributes are found\n */\n parseBackgroundAttributes : function(a, b) {\n var bkgData,\n index,\n chNr,\n channel;\n\n var case1 = (a === 0x10 || a === 0x18) && (0x20 <= b && b <= 0x2f);\n var case2 = (a === 0x17 || a === 0x1f) && (0x2d <=b && b <= 0x2f);\n if (!(case1 || case2)) {\n return false;\n }\n bkgData = {};\n if (a === 0x10 || a === 0x18) {\n index = Math.floor((b-0x20)/2);\n bkgData.background = backgroundColors[index];\n if (b % 2 === 1) {\n bkgData.background = bkgData.background + \"_semi\";\n }\n } else if (b === 0x2d) {\n bkgData.background = \"transparent\";\n } else {\n bkgData.foreground = \"black\";\n if (b === 0x2f) {\n bkgData.underline = true;\n }\n }\n chNr = (a < 0x18) ? 1 : 2;\n channel = this.channels[chNr-1];\n channel.setBkgData(bkgData);\n this.lastCmdA = a;\n this.lastCmdB = b;\n return true;\n },\n\n /**\n * Reset state of parser and its channels.\n */\n reset : function() {\n for (var i=0 ; i < this.channels.length ; i++) {\n if (this.channels[i]) {\n this.channels[i].reset();\n }\n }\n this.lastCmdA = null;\n this.lastCmdB = null;\n },\n\n /**\n * Trigger the generation of a cue, and the start of a new one if displayScreens are not empty.\n */\n cueSplitAtTime : function(t) {\n for (var i=0 ; i < this.channels.length ; i++) {\n if (this.channels[i]) {\n this.channels[i].cueSplitAtTime(t);\n }\n }\n },\n };\n\n /**\n * Find ranges corresponding to SEA CEA-608 NALUS in sizeprepended NALU array.\n * @param {raw} dataView of binary data\n * @param {startPos} start position in raw\n * @param {size} total size of data in raw to consider\n * @returns \n */\n var findCea608Nalus = function(raw, startPos, size) {\n var nalSize = 0,\n cursor = startPos,\n nalType = 0,\n cea608NaluRanges = [],\n // Check SEI data according to ANSI-SCTE 128\n isCEA608SEI = function (payloadType, payloadSize, raw, pos) {\n if (payloadType !== 4 || payloadSize < 8) {\n return null;\n }\n var countryCode = raw.getUint8(pos);\n var providerCode = raw.getUint16(pos + 1);\n var userIdentifier = raw.getUint32(pos + 3);\n var userDataTypeCode = raw.getUint8(pos + 7);\n return countryCode == 0xB5 && providerCode == 0x31 && userIdentifier == 0x47413934 && userDataTypeCode == 0x3;\n };\n while (cursor < startPos + size) {\n nalSize = raw.getUint32(cursor);\n nalType = raw.getUint8(cursor + 4) & 0x1F;\n //console.log(time + \" NAL \" + nalType);\n if (nalType === 6) {\n // SEI NAL Unit. The NAL header is the first byte\n //console.log(\"SEI NALU of size \" + nalSize + \" at time \" + time);\n var pos = cursor + 5;\n var payloadType = -1;\n while (pos < cursor + 4 + nalSize - 1) { // The last byte should be rbsp_trailing_bits\n payloadType = 0;\n var b = 0xFF;\n while (b === 0xFF) {\n b = raw.getUint8(pos);\n payloadType += b;\n pos++;\n }\n var payloadSize = 0;\n b = 0xFF;\n while (b === 0xFF) {\n b = raw.getUint8(pos);\n payloadSize += b;\n pos++;\n }\n if (isCEA608SEI(payloadType, payloadSize, raw, pos)) {\n //console.log(\"CEA608 SEI \" + time + \" \" + payloadSize);\n cea608NaluRanges.push([pos, payloadSize]);\n }\n pos += payloadSize;\n }\n }\n cursor += nalSize + 4;\n }\n return cea608NaluRanges;\n };\n \n var extractCea608DataFromRange = function(raw, cea608Range) {\n var pos = cea608Range[0];\n var fieldData = [[], []];\n\n pos += 8; // Skip the identifier up to userDataTypeCode\n var ccCount = raw.getUint8(pos) & 0x1f;\n pos += 2; // Advance 1 and skip reserved byte\n \n for (var i = 0; i < ccCount; i++) {\n var byte = raw.getUint8(pos);\n var ccValid = byte & 0x4;\n var ccType = byte & 0x3;\n pos++;\n var ccData1 = raw.getUint8(pos); // Keep parity bit\n pos++;\n var ccData2 = raw.getUint8(pos); // Keep parity bit\n pos++;\n if (ccValid && ((ccData1 & 0x7f) + (ccData2 & 0x7f) !== 0)) { //Check validity and non-empty data\n if (ccType === 0) {\n fieldData[0].push(ccData1);\n fieldData[0].push(ccData2);\n } else if (ccType === 1) {\n fieldData[1].push(ccData1);\n fieldData[1].push(ccData2);\n }\n }\n }\n return fieldData;\n };\n\n exports.logger = logger;\n exports.PenState = PenState;\n exports.CaptionScreen = CaptionScreen; \n exports.Cea608Parser = Cea608Parser;\n exports.findCea608Nalus = findCea608Nalus;\n exports.extractCea608DataFromRange = extractCea608DataFromRange;\n\n}(typeof exports === 'undefined' ? this.cea608parser = {} : exports));\n","/*\n Copyright 2011-2013 Abdulla Abdurakhmanov\n Original sources are available at https://code.google.com/p/x2js/\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n */\n\n/*\n Further modified for dashjs to:\n - keep track of children nodes in order in attribute __children.\n - add type conversion matchers\n - re-add ignoreRoot\n - allow zero-length attributePrefix\n - don't add white-space text nodes\n - remove explicit RequireJS support\n*/\n\nfunction X2JS(config) {\n 'use strict';\n\n var VERSION = \"1.2.0\";\n\n config = config || {};\n initConfigDefaults();\n initRequiredPolyfills();\n\n function initConfigDefaults() {\n if(config.escapeMode === undefined) {\n config.escapeMode = true;\n }\n\n if (config.attributePrefix === undefined) {\n config.attributePrefix = \"_\";\n }\n\n config.arrayAccessForm = config.arrayAccessForm || \"none\";\n config.emptyNodeForm = config.emptyNodeForm || \"text\";\n\n if(config.enableToStringFunc === undefined) {\n config.enableToStringFunc = true;\n }\n config.arrayAccessFormPaths = config.arrayAccessFormPaths || [];\n if(config.skipEmptyTextNodesForObj === undefined) {\n config.skipEmptyTextNodesForObj = true;\n }\n if(config.stripWhitespaces === undefined) {\n config.stripWhitespaces = true;\n }\n config.datetimeAccessFormPaths = config.datetimeAccessFormPaths || [];\n\n if(config.useDoubleQuotes === undefined) {\n config.useDoubleQuotes = false;\n }\n\n config.xmlElementsFilter = config.xmlElementsFilter || [];\n config.jsonPropertiesFilter = config.jsonPropertiesFilter || [];\n\n if(config.keepCData === undefined) {\n config.keepCData = false;\n }\n\n if (config.ignoreRoot === undefined) {\n config.ignoreRoot = false;\n }\n }\n\n var DOMNodeTypes = {\n ELEMENT_NODE \t : 1,\n TEXT_NODE \t : 3,\n CDATA_SECTION_NODE : 4,\n COMMENT_NODE\t : 8,\n DOCUMENT_NODE \t : 9\n };\n\n function initRequiredPolyfills() {\n }\n\n function getNodeLocalName( node ) {\n var nodeLocalName = node.localName;\n if(nodeLocalName == null) // Yeah, this is IE!!\n nodeLocalName = node.baseName;\n if(nodeLocalName == null || nodeLocalName==\"\") // ==\"\" is IE too\n nodeLocalName = node.nodeName;\n return nodeLocalName;\n }\n\n function getNodePrefix(node) {\n return node.prefix;\n }\n\n function escapeXmlChars(str) {\n if(typeof(str) == \"string\")\n return str.replace(/&/g, '&').replace(//g, '>').replace(/\"/g, '"').replace(/'/g, ''');\n else\n return str;\n }\n\n function unescapeXmlChars(str) {\n return str.replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '\"').replace(/'/g, \"'\").replace(/&/g, '&');\n }\n\n function checkInStdFiltersArrayForm(stdFiltersArrayForm, obj, name, path) {\n var idx = 0;\n for(; idx < stdFiltersArrayForm.length; idx++) {\n var filterPath = stdFiltersArrayForm[idx];\n if( typeof filterPath === \"string\" ) {\n if(filterPath == path)\n break;\n }\n else\n if( filterPath instanceof RegExp) {\n if(filterPath.test(path))\n break;\n }\n else\n if( typeof filterPath === \"function\") {\n if(filterPath(obj, name, path))\n break;\n }\n }\n return idx!=stdFiltersArrayForm.length;\n }\n\n function toArrayAccessForm(obj, childName, path) {\n switch(config.arrayAccessForm) {\n case \"property\":\n if(!(obj[childName] instanceof Array))\n obj[childName+\"_asArray\"] = [obj[childName]];\n else\n obj[childName+\"_asArray\"] = obj[childName];\n break;\n /*case \"none\":\n break;*/\n }\n\n if(!(obj[childName] instanceof Array) && config.arrayAccessFormPaths.length > 0) {\n if(checkInStdFiltersArrayForm(config.arrayAccessFormPaths, obj, childName, path)) {\n obj[childName] = [obj[childName]];\n }\n }\n }\n\n function fromXmlDateTime(prop) {\n // Implementation based up on http://stackoverflow.com/questions/8178598/xml-datetime-to-javascript-date-object\n // Improved to support full spec and optional parts\n var bits = prop.split(/[-T:+Z]/g);\n\n var d = new Date(bits[0], bits[1]-1, bits[2]);\n var secondBits = bits[5].split(\"\\.\");\n d.setHours(bits[3], bits[4], secondBits[0]);\n if(secondBits.length>1)\n d.setMilliseconds(secondBits[1]);\n\n // Get supplied time zone offset in minutes\n if(bits[6] && bits[7]) {\n var offsetMinutes = bits[6] * 60 + Number(bits[7]);\n var sign = /\\d\\d-\\d\\d:\\d\\d$/.test(prop)? '-' : '+';\n\n // Apply the sign\n offsetMinutes = 0 + (sign == '-'? -1 * offsetMinutes : offsetMinutes);\n\n // Apply offset and local timezone\n d.setMinutes(d.getMinutes() - offsetMinutes - d.getTimezoneOffset())\n }\n else\n if(prop.indexOf(\"Z\", prop.length - 1) !== -1) {\n d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds()));\n }\n\n // d is now a local time equivalent to the supplied time\n return d;\n }\n\n function checkFromXmlDateTimePaths(value, childName, fullPath) {\n if(config.datetimeAccessFormPaths.length > 0) {\n var path = fullPath.split(\"\\.#\")[0];\n if(checkInStdFiltersArrayForm(config.datetimeAccessFormPaths, value, childName, path)) {\n return fromXmlDateTime(value);\n }\n else\n return value;\n }\n else\n return value;\n }\n\n function checkXmlElementsFilter(obj, childType, childName, childPath) {\n if( childType == DOMNodeTypes.ELEMENT_NODE && config.xmlElementsFilter.length > 0) {\n return checkInStdFiltersArrayForm(config.xmlElementsFilter, obj, childName, childPath);\n }\n else\n return true;\n }\n\n function parseDOMChildren( node, path ) {\n if(node.nodeType == DOMNodeTypes.DOCUMENT_NODE) {\n var result = new Object;\n var nodeChildren = node.childNodes;\n // Alternative for firstElementChild which is not supported in some environments\n for(var cidx=0; cidx 1 && result.__text!=null && config.skipEmptyTextNodesForObj) {\n if( (config.stripWhitespaces && result.__text==\"\") || (result.__text.trim()==\"\")) {\n delete result.__text;\n }\n }\n delete result.__cnt;\n\n if( config.enableToStringFunc && (result.__text!=null || result.__cdata!=null )) {\n result.toString = function() {\n return (this.__text!=null? this.__text:'')+( this.__cdata!=null ? this.__cdata:'');\n };\n }\n\n return result;\n }\n else\n if(node.nodeType == DOMNodeTypes.TEXT_NODE || node.nodeType == DOMNodeTypes.CDATA_SECTION_NODE) {\n return node.nodeValue;\n }\n }\n\n function startTag(jsonObj, element, attrList, closed) {\n var resultStr = \"<\"+ ( (jsonObj!=null && jsonObj.__prefix!=null)? (jsonObj.__prefix+\":\"):\"\") + element;\n if(attrList!=null) {\n for(var aidx = 0; aidx < attrList.length; aidx++) {\n var attrName = attrList[aidx];\n var attrVal = jsonObj[attrName];\n if(config.escapeMode)\n attrVal=escapeXmlChars(attrVal);\n resultStr+=\" \"+attrName.substr(config.attributePrefix.length)+\"=\";\n if(config.useDoubleQuotes)\n resultStr+='\"'+attrVal+'\"';\n else\n resultStr+=\"'\"+attrVal+\"'\";\n }\n }\n if(!closed)\n resultStr+=\">\";\n else\n resultStr+=\"/>\";\n return resultStr;\n }\n\n function endTag(jsonObj,elementName) {\n return \"\";\n }\n\n function endsWith(str, suffix) {\n return str.indexOf(suffix, str.length - suffix.length) !== -1;\n }\n\n function jsonXmlSpecialElem ( jsonObj, jsonObjField ) {\n if((config.arrayAccessForm==\"property\" && endsWith(jsonObjField.toString(),(\"_asArray\")))\n || jsonObjField.toString().indexOf(config.attributePrefix)==0\n || jsonObjField.toString().indexOf(\"__\")==0\n || (jsonObj[jsonObjField] instanceof Function) )\n return true;\n else\n return false;\n }\n\n function jsonXmlElemCount ( jsonObj ) {\n var elementsCnt = 0;\n if(jsonObj instanceof Object ) {\n for( var it in jsonObj ) {\n if(jsonXmlSpecialElem ( jsonObj, it) )\n continue;\n elementsCnt++;\n }\n }\n return elementsCnt;\n }\n\n function checkJsonObjPropertiesFilter(jsonObj, propertyName, jsonObjPath) {\n return config.jsonPropertiesFilter.length == 0\n || jsonObjPath==\"\"\n || checkInStdFiltersArrayForm(config.jsonPropertiesFilter, jsonObj, propertyName, jsonObjPath);\n }\n\n function parseJSONAttributes ( jsonObj ) {\n var attrList = [];\n if(jsonObj instanceof Object ) {\n for( var ait in jsonObj ) {\n if(ait.toString().indexOf(\"__\")== -1 && ait.toString().indexOf(config.attributePrefix)==0) {\n attrList.push(ait);\n }\n }\n }\n return attrList;\n }\n\n function parseJSONTextAttrs ( jsonTxtObj ) {\n var result =\"\";\n\n if(jsonTxtObj.__cdata!=null) {\n result+=\"\";\n }\n\n if(jsonTxtObj.__text!=null) {\n if(config.escapeMode)\n result+=escapeXmlChars(jsonTxtObj.__text);\n else\n result+=jsonTxtObj.__text;\n }\n return result;\n }\n\n function parseJSONTextObject ( jsonTxtObj ) {\n var result =\"\";\n\n if( jsonTxtObj instanceof Object ) {\n result+=parseJSONTextAttrs ( jsonTxtObj );\n }\n else\n if(jsonTxtObj!=null) {\n if(config.escapeMode)\n result+=escapeXmlChars(jsonTxtObj);\n else\n result+=jsonTxtObj;\n }\n\n return result;\n }\n\n function getJsonPropertyPath(jsonObjPath, jsonPropName) {\n if (jsonObjPath===\"\") {\n return jsonPropName;\n }\n else\n return jsonObjPath+\".\"+jsonPropName;\n }\n\n function parseJSONArray ( jsonArrRoot, jsonArrObj, attrList, jsonObjPath ) {\n var result = \"\";\n if(jsonArrRoot.length == 0) {\n result+=startTag(jsonArrRoot, jsonArrObj, attrList, true);\n }\n else {\n for(var arIdx = 0; arIdx < jsonArrRoot.length; arIdx++) {\n result+=startTag(jsonArrRoot[arIdx], jsonArrObj, parseJSONAttributes(jsonArrRoot[arIdx]), false);\n result+=parseJSONObject(jsonArrRoot[arIdx], getJsonPropertyPath(jsonObjPath,jsonArrObj));\n result+=endTag(jsonArrRoot[arIdx],jsonArrObj);\n }\n }\n return result;\n }\n\n function parseJSONObject ( jsonObj, jsonObjPath ) {\n var result = \"\";\n\n var elementsCnt = jsonXmlElemCount ( jsonObj );\n\n if(elementsCnt > 0) {\n for( var it in jsonObj ) {\n\n if(jsonXmlSpecialElem ( jsonObj, it) || (jsonObjPath!=\"\" && !checkJsonObjPropertiesFilter(jsonObj, it, getJsonPropertyPath(jsonObjPath,it))) )\n continue;\n\n var subObj = jsonObj[it];\n\n var attrList = parseJSONAttributes( subObj )\n\n if(subObj == null || subObj == undefined) {\n result+=startTag(subObj, it, attrList, true);\n }\n else\n if(subObj instanceof Object) {\n\n if(subObj instanceof Array) {\n result+=parseJSONArray( subObj, it, attrList, jsonObjPath );\n }\n else if(subObj instanceof Date) {\n result+=startTag(subObj, it, attrList, false);\n result+=subObj.toISOString();\n result+=endTag(subObj,it);\n }\n else {\n var subObjElementsCnt = jsonXmlElemCount ( subObj );\n if(subObjElementsCnt > 0 || subObj.__text!=null || subObj.__cdata!=null) {\n result+=startTag(subObj, it, attrList, false);\n result+=parseJSONObject(subObj, getJsonPropertyPath(jsonObjPath,it));\n result+=endTag(subObj,it);\n }\n else {\n result+=startTag(subObj, it, attrList, true);\n }\n }\n }\n else {\n result+=startTag(subObj, it, attrList, false);\n result+=parseJSONTextObject(subObj);\n result+=endTag(subObj,it);\n }\n }\n }\n result+=parseJSONTextObject(jsonObj);\n\n return result;\n }\n\n this.parseXmlString = function(xmlDocStr) {\n var isIEParser = window.ActiveXObject || \"ActiveXObject\" in window;\n if (xmlDocStr === undefined) {\n return null;\n }\n var xmlDoc;\n if (window.DOMParser) {\n var parser=new window.DOMParser();\n var parsererrorNS = null;\n try {\n xmlDoc = parser.parseFromString( xmlDocStr, \"text/xml\" );\n if(xmlDoc.getElementsByTagNameNS(\"*\", \"parsererror\").length > 0) {\n xmlDoc = null;\n }\n }\n catch(err) {\n xmlDoc = null;\n }\n }\n else {\n // IE :(\n if(xmlDocStr.indexOf(\"\") + 2 );\n }\n xmlDoc=new ActiveXObject(\"Microsoft.XMLDOM\");\n xmlDoc.async=\"false\";\n xmlDoc.loadXML(xmlDocStr);\n }\n return xmlDoc;\n };\n\n this.asArray = function(prop) {\n if (prop === undefined || prop == null)\n return [];\n else\n if(prop instanceof Array)\n return prop;\n else\n return [prop];\n };\n\n this.toXmlDateTime = function(dt) {\n if(dt instanceof Date)\n return dt.toISOString();\n else\n if(typeof(dt) === 'number' )\n return new Date(dt).toISOString();\n else\n return null;\n };\n\n this.asDateTime = function(prop) {\n if(typeof(prop) == \"string\") {\n return fromXmlDateTime(prop);\n }\n else\n return prop;\n };\n\n this.xml2json = function (xmlDoc) {\n return parseDOMChildren ( xmlDoc );\n };\n\n this.xml_str2json = function (xmlDocStr) {\n var xmlDoc = this.parseXmlString(xmlDocStr);\n if(xmlDoc!=null)\n return this.xml2json(xmlDoc);\n else\n return null;\n };\n\n this.json2xml_str = function (jsonObj) {\n return parseJSONObject ( jsonObj, \"\" );\n };\n\n this.json2xml = function (jsonObj) {\n var xmlDocStr = this.json2xml_str (jsonObj);\n return this.parseXmlString(xmlDocStr);\n };\n\n this.getVersion = function () {\n return VERSION;\n };\n}\n\nexport default X2JS;\n","/**\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2013, Dash Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * * Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * * Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport MediaPlayer from './src/streaming/MediaPlayer';\nimport FactoryMaker from './src/core/FactoryMaker';\nimport Debug from './src/core/Debug';\nimport { getVersionString } from './src/core/Version';\n\n// Shove both of these into the global scope\nvar context = (typeof window !== 'undefined' && window) || global;\n\nvar dashjs = context.dashjs;\nif (!dashjs) {\n dashjs = context.dashjs = {};\n}\n\ndashjs.MediaPlayer = MediaPlayer;\ndashjs.FactoryMaker = FactoryMaker;\ndashjs.Debug = Debug;\ndashjs.Version = getVersionString();\n\nexport default dashjs;\nexport { MediaPlayer, FactoryMaker, Debug};\n","'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n for (var i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n","/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nvar base64 = require(5)\nvar ieee754 = require(12)\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\nvar K_MAX_LENGTH = 0x7fffffff\nexports.kMaxLength = K_MAX_LENGTH\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Print warning and recommend using `buffer` v4.x which has an Object\n * implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * We report that the browser does not support typed arrays if the are not subclassable\n * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`\n * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support\n * for __proto__ and has a buggy typed array implementation.\n */\nBuffer.TYPED_ARRAY_SUPPORT = typedArraySupport()\n\nif (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&\n typeof console.error === 'function') {\n console.error(\n 'This browser lacks typed array (Uint8Array) support which is required by ' +\n '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'\n )\n}\n\nfunction typedArraySupport () {\n // Can typed array instances can be augmented?\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }\n return arr.foo() === 42\n } catch (e) {\n return false\n }\n}\n\nObject.defineProperty(Buffer.prototype, 'parent', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.buffer\n }\n})\n\nObject.defineProperty(Buffer.prototype, 'offset', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.byteOffset\n }\n})\n\nfunction createBuffer (length) {\n if (length > K_MAX_LENGTH) {\n throw new RangeError('The value \"' + length + '\" is invalid for option \"size\"')\n }\n // Return an augmented `Uint8Array` instance\n var buf = new Uint8Array(length)\n buf.__proto__ = Buffer.prototype\n return buf\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new TypeError(\n 'The \"string\" argument must be of type string. Received type number'\n )\n }\n return allocUnsafe(arg)\n }\n return from(arg, encodingOrOffset, length)\n}\n\n// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\nif (typeof Symbol !== 'undefined' && Symbol.species != null &&\n Buffer[Symbol.species] === Buffer) {\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true,\n enumerable: false,\n writable: false\n })\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\nfunction from (value, encodingOrOffset, length) {\n if (typeof value === 'string') {\n return fromString(value, encodingOrOffset)\n }\n\n if (ArrayBuffer.isView(value)) {\n return fromArrayLike(value)\n }\n\n if (value == null) {\n throw TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n }\n\n if (isInstance(value, ArrayBuffer) ||\n (value && isInstance(value.buffer, ArrayBuffer))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof value === 'number') {\n throw new TypeError(\n 'The \"value\" argument must not be of type number. Received type number'\n )\n }\n\n var valueOf = value.valueOf && value.valueOf()\n if (valueOf != null && valueOf !== value) {\n return Buffer.from(valueOf, encodingOrOffset, length)\n }\n\n var b = fromObject(value)\n if (b) return b\n\n if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&\n typeof value[Symbol.toPrimitive] === 'function') {\n return Buffer.from(\n value[Symbol.toPrimitive]('string'), encodingOrOffset, length\n )\n }\n\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(value, encodingOrOffset, length)\n}\n\n// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:\n// https://github.com/feross/buffer/pull/148\nBuffer.prototype.__proto__ = Uint8Array.prototype\nBuffer.__proto__ = Uint8Array\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be of type number')\n } else if (size < 0) {\n throw new RangeError('The value \"' + size + '\" is invalid for option \"size\"')\n }\n}\n\nfunction alloc (size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(size).fill(fill, encoding)\n : createBuffer(size).fill(fill)\n }\n return createBuffer(size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(size, fill, encoding)\n}\n\nfunction allocUnsafe (size) {\n assertSize(size)\n return createBuffer(size < 0 ? 0 : checked(size) | 0)\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(size)\n}\n\nfunction fromString (string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n\n var length = byteLength(string, encoding) | 0\n var buf = createBuffer(length)\n\n var actual = buf.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n buf = buf.slice(0, actual)\n }\n\n return buf\n}\n\nfunction fromArrayLike (array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n var buf = createBuffer(length)\n for (var i = 0; i < length; i += 1) {\n buf[i] = array[i] & 255\n }\n return buf\n}\n\nfunction fromArrayBuffer (array, byteOffset, length) {\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\"offset\" is outside of buffer bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\"length\" is outside of buffer bounds')\n }\n\n var buf\n if (byteOffset === undefined && length === undefined) {\n buf = new Uint8Array(array)\n } else if (length === undefined) {\n buf = new Uint8Array(array, byteOffset)\n } else {\n buf = new Uint8Array(array, byteOffset, length)\n }\n\n // Return an augmented `Uint8Array` instance\n buf.__proto__ = Buffer.prototype\n return buf\n}\n\nfunction fromObject (obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n var buf = createBuffer(len)\n\n if (buf.length === 0) {\n return buf\n }\n\n obj.copy(buf, 0, 0, len)\n return buf\n }\n\n if (obj.length !== undefined) {\n if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {\n return createBuffer(0)\n }\n return fromArrayLike(obj)\n }\n\n if (obj.type === 'Buffer' && Array.isArray(obj.data)) {\n return fromArrayLike(obj.data)\n }\n}\n\nfunction checked (length) {\n // Note: cannot use `length < K_MAX_LENGTH` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= K_MAX_LENGTH) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return b != null && b._isBuffer === true &&\n b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false\n}\n\nBuffer.compare = function compare (a, b) {\n if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)\n if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError(\n 'The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array'\n )\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!Array.isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (isInstance(buf, Uint8Array)) {\n buf = Buffer.from(buf)\n }\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n throw new TypeError(\n 'The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. ' +\n 'Received type ' + typeof string\n )\n }\n\n var len = string.length\n var mustMatch = (arguments.length > 2 && arguments[2] === true)\n if (!mustMatch && len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) {\n return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8\n }\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)\n// to detect a Buffer instance. It's not possible to use `instanceof Buffer`\n// reliably in a browserify context because there could be multiple different\n// copies of the 'buffer' package in use. This method works even for Buffer\n// instances that were created from another copy of the `buffer` package.\n// See: https://github.com/feross/buffer/issues/154\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.toLocaleString = Buffer.prototype.toString\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()\n if (this.length > max) str += ' ... '\n return ''\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (isInstance(target, Uint8Array)) {\n target = Buffer.from(target, target.offset, target.byteLength)\n }\n if (!Buffer.isBuffer(target)) {\n throw new TypeError(\n 'The \"target\" argument must be one of type Buffer or Uint8Array. ' +\n 'Received type ' + (typeof target)\n )\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (numberIsNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n var strLen = string.length\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (numberIsNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset >>> 0\n if (isFinite(length)) {\n length = length >>> 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf = this.subarray(start, end)\n // Return an augmented `Uint8Array` instance\n newBuf.__proto__ = Buffer.prototype\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n var limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n var limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('Index out of range')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n\n if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {\n // Use built-in when available, missing from IE11\n this.copyWithin(targetStart, start, end)\n } else if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (var i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, end),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if ((encoding === 'utf8' && code < 128) ||\n encoding === 'latin1') {\n // Fast path: If `val` fits into a single byte, use that numeric value.\n val = code\n }\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : Buffer.from(val, encoding)\n var len = bytes.length\n if (len === 0) {\n throw new TypeError('The value \"' + val +\n '\" is invalid for argument \"value\"')\n }\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node takes equal signs as end of the Base64 encoding\n str = str.split('=')[0]\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = str.trim().replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\n// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass\n// the `instanceof` check but they should be treated as of that type.\n// See: https://github.com/feross/buffer/issues/166\nfunction isInstance (obj, type) {\n return obj instanceof type ||\n (obj != null && obj.constructor != null && obj.constructor.name != null &&\n obj.constructor.name === type.name)\n}\nfunction numberIsNaN (obj) {\n // For IE11 support\n return obj !== obj // eslint-disable-line no-self-compare\n}\n","/*! codem-isoboxer v0.3.6 https://github.com/madebyhiro/codem-isoboxer/blob/master/LICENSE.txt */\nvar ISOBoxer = {};\n\nISOBoxer.parseBuffer = function(arrayBuffer) {\n return new ISOFile(arrayBuffer).parse();\n};\n\nISOBoxer.addBoxProcessor = function(type, parser) {\n if (typeof type !== 'string' || typeof parser !== 'function') {\n return;\n }\n ISOBox.prototype._boxProcessors[type] = parser;\n};\n\nISOBoxer.createFile = function() {\n return new ISOFile();\n};\n\n// See ISOBoxer.append() for 'pos' parameter syntax\nISOBoxer.createBox = function(type, parent, pos) {\n var newBox = ISOBox.create(type);\n if (parent) {\n parent.append(newBox, pos);\n }\n return newBox;\n};\n\n// See ISOBoxer.append() for 'pos' parameter syntax\nISOBoxer.createFullBox = function(type, parent, pos) {\n var newBox = ISOBoxer.createBox(type, parent, pos);\n newBox.version = 0;\n newBox.flags = 0;\n return newBox;\n};\n\nISOBoxer.Utils = {};\nISOBoxer.Utils.dataViewToString = function(dataView, encoding) {\n var impliedEncoding = encoding || 'utf-8';\n if (typeof TextDecoder !== 'undefined') {\n return new TextDecoder(impliedEncoding).decode(dataView);\n }\n var a = [];\n var i = 0;\n\n if (impliedEncoding === 'utf-8') {\n /* The following algorithm is essentially a rewrite of the UTF8.decode at\n http://bannister.us/weblog/2007/simple-base64-encodedecode-javascript/\n */\n\n while (i < dataView.byteLength) {\n var c = dataView.getUint8(i++);\n if (c < 0x80) {\n // 1-byte character (7 bits)\n } else if (c < 0xe0) {\n // 2-byte character (11 bits)\n c = (c & 0x1f) << 6;\n c |= (dataView.getUint8(i++) & 0x3f);\n } else if (c < 0xf0) {\n // 3-byte character (16 bits)\n c = (c & 0xf) << 12;\n c |= (dataView.getUint8(i++) & 0x3f) << 6;\n c |= (dataView.getUint8(i++) & 0x3f);\n } else {\n // 4-byte character (21 bits)\n c = (c & 0x7) << 18;\n c |= (dataView.getUint8(i++) & 0x3f) << 12;\n c |= (dataView.getUint8(i++) & 0x3f) << 6;\n c |= (dataView.getUint8(i++) & 0x3f);\n }\n a.push(String.fromCharCode(c));\n }\n } else { // Just map byte-by-byte (probably wrong)\n while (i < dataView.byteLength) {\n a.push(String.fromCharCode(dataView.getUint8(i++)));\n }\n }\n return a.join('');\n};\n\nISOBoxer.Utils.utf8ToByteArray = function(string) {\n // Only UTF-8 encoding is supported by TextEncoder\n var u, i;\n if (typeof TextEncoder !== 'undefined') {\n u = new TextEncoder().encode(string);\n } else {\n u = [];\n for (i = 0; i < string.length; ++i) {\n var c = string.charCodeAt(i);\n if (c < 0x80) {\n u.push(c);\n } else if (c < 0x800) {\n u.push(0xC0 | (c >> 6));\n u.push(0x80 | (63 & c));\n } else if (c < 0x10000) {\n u.push(0xE0 | (c >> 12));\n u.push(0x80 | (63 & (c >> 6)));\n u.push(0x80 | (63 & c));\n } else {\n u.push(0xF0 | (c >> 18));\n u.push(0x80 | (63 & (c >> 12)));\n u.push(0x80 | (63 & (c >> 6)));\n u.push(0x80 | (63 & c));\n }\n }\n }\n return u;\n};\n\n// Method to append a box in the list of child boxes\n// The 'pos' parameter can be either:\n// - (number) a position index at which to insert the new box\n// - (string) the type of the box after which to insert the new box\n// - (object) the box after which to insert the new box\nISOBoxer.Utils.appendBox = function(parent, box, pos) {\n box._offset = parent._cursor.offset;\n box._root = (parent._root ? parent._root : parent);\n box._raw = parent._raw;\n box._parent = parent;\n\n if (pos === -1) {\n // The new box is a sub-box of the parent but not added in boxes array,\n // for example when the new box is set as an entry (see dref and stsd for example)\n return;\n }\n\n if (pos === undefined || pos === null) {\n parent.boxes.push(box);\n return;\n }\n\n var index = -1,\n type;\n\n if (typeof pos === \"number\") {\n index = pos;\n } else {\n if (typeof pos === \"string\") {\n type = pos;\n } else if (typeof pos === \"object\" && pos.type) {\n type = pos.type;\n } else {\n parent.boxes.push(box);\n return;\n }\n\n for (var i = 0; i < parent.boxes.length; i++) {\n if (type === parent.boxes[i].type) {\n index = i + 1;\n break;\n }\n }\n }\n parent.boxes.splice(index, 0, box);\n};\n\nif (typeof exports !== 'undefined') {\n exports.parseBuffer = ISOBoxer.parseBuffer;\n exports.addBoxProcessor = ISOBoxer.addBoxProcessor;\n exports.createFile = ISOBoxer.createFile;\n exports.createBox = ISOBoxer.createBox;\n exports.createFullBox = ISOBoxer.createFullBox;\n exports.Utils = ISOBoxer.Utils;\n}\n\nISOBoxer.Cursor = function(initialOffset) {\n this.offset = (typeof initialOffset == 'undefined' ? 0 : initialOffset);\n};\n\nvar ISOFile = function(arrayBuffer) {\n this._cursor = new ISOBoxer.Cursor();\n this.boxes = [];\n if (arrayBuffer) {\n this._raw = new DataView(arrayBuffer);\n }\n};\n\nISOFile.prototype.fetch = function(type) {\n var result = this.fetchAll(type, true);\n return (result.length ? result[0] : null);\n};\n\nISOFile.prototype.fetchAll = function(type, returnEarly) {\n var result = [];\n ISOFile._sweep.call(this, type, result, returnEarly);\n return result;\n};\n\nISOFile.prototype.parse = function() {\n this._cursor.offset = 0;\n this.boxes = [];\n while (this._cursor.offset < this._raw.byteLength) {\n var box = ISOBox.parse(this);\n\n // Box could not be parsed\n if (typeof box.type === 'undefined') break;\n\n this.boxes.push(box);\n }\n return this;\n};\n\nISOFile._sweep = function(type, result, returnEarly) {\n if (this.type && this.type == type) result.push(this);\n for (var box in this.boxes) {\n if (result.length && returnEarly) return;\n ISOFile._sweep.call(this.boxes[box], type, result, returnEarly);\n }\n};\n\nISOFile.prototype.write = function() {\n\n var length = 0,\n i;\n\n for (i = 0; i < this.boxes.length; i++) {\n length += this.boxes[i].getLength(false);\n }\n\n var bytes = new Uint8Array(length);\n this._rawo = new DataView(bytes.buffer);\n this.bytes = bytes;\n this._cursor.offset = 0;\n\n for (i = 0; i < this.boxes.length; i++) {\n this.boxes[i].write();\n }\n\n return bytes.buffer;\n};\n\nISOFile.prototype.append = function(box, pos) {\n ISOBoxer.Utils.appendBox(this, box, pos);\n};\nvar ISOBox = function() {\n this._cursor = new ISOBoxer.Cursor();\n};\n\nISOBox.parse = function(parent) {\n var newBox = new ISOBox();\n newBox._offset = parent._cursor.offset;\n newBox._root = (parent._root ? parent._root : parent);\n newBox._raw = parent._raw;\n newBox._parent = parent;\n newBox._parseBox();\n parent._cursor.offset = newBox._raw.byteOffset + newBox._raw.byteLength;\n return newBox;\n};\n\nISOBox.create = function(type) {\n var newBox = new ISOBox();\n newBox.type = type;\n newBox.boxes = [];\n return newBox;\n};\n\nISOBox.prototype._boxContainers = ['dinf', 'edts', 'mdia', 'meco', 'mfra', 'minf', 'moof', 'moov', 'mvex', 'stbl', 'strk', 'traf', 'trak', 'tref', 'udta', 'vttc', 'sinf', 'schi', 'encv', 'enca'];\n\nISOBox.prototype._boxProcessors = {};\n\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Generic read/write functions\n\nISOBox.prototype._procField = function (name, type, size) {\n if (this._parsing) {\n this[name] = this._readField(type, size);\n }\n else {\n this._writeField(type, size, this[name]);\n }\n};\n\nISOBox.prototype._procFieldArray = function (name, length, type, size) {\n var i;\n if (this._parsing) {\n this[name] = [];\n for (i = 0; i < length; i++) {\n this[name][i] = this._readField(type, size);\n }\n }\n else {\n for (i = 0; i < this[name].length; i++) {\n this._writeField(type, size, this[name][i]);\n }\n }\n};\n\nISOBox.prototype._procFullBox = function() {\n this._procField('version', 'uint', 8);\n this._procField('flags', 'uint', 24);\n};\n\nISOBox.prototype._procEntries = function(name, length, fn) {\n var i;\n if (this._parsing) {\n this[name] = [];\n for (i = 0; i < length; i++) {\n this[name].push({});\n fn.call(this, this[name][i]);\n }\n }\n else {\n for (i = 0; i < length; i++) {\n fn.call(this, this[name][i]);\n }\n }\n};\n\nISOBox.prototype._procSubEntries = function(entry, name, length, fn) {\n var i;\n if (this._parsing) {\n entry[name] = [];\n for (i = 0; i < length; i++) {\n entry[name].push({});\n fn.call(this, entry[name][i]);\n }\n }\n else {\n for (i = 0; i < length; i++) {\n fn.call(this, entry[name][i]);\n }\n }\n};\n\nISOBox.prototype._procEntryField = function (entry, name, type, size) {\n if (this._parsing) {\n entry[name] = this._readField(type, size);\n }\n else {\n this._writeField(type, size, entry[name]);\n }\n};\n\nISOBox.prototype._procSubBoxes = function(name, length) {\n var i;\n if (this._parsing) {\n this[name] = [];\n for (i = 0; i < length; i++) {\n this[name].push(ISOBox.parse(this));\n }\n }\n else {\n for (i = 0; i < length; i++) {\n if (this._rawo) {\n this[name][i].write();\n } else {\n this.size += this[name][i].getLength();\n }\n }\n }\n};\n\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Read/parse functions\n\nISOBox.prototype._readField = function(type, size) {\n switch (type) {\n case 'uint':\n return this._readUint(size);\n case 'int':\n return this._readInt(size);\n case 'template':\n return this._readTemplate(size);\n case 'string':\n return (size === -1) ? this._readTerminatedString() : this._readString(size);\n case 'data':\n return this._readData(size);\n case 'utf8':\n return this._readUTF8String();\n default:\n return -1;\n }\n};\n\nISOBox.prototype._readInt = function(size) {\n var result = null,\n offset = this._cursor.offset - this._raw.byteOffset;\n switch(size) {\n case 8:\n result = this._raw.getInt8(offset);\n break;\n case 16:\n result = this._raw.getInt16(offset);\n break;\n case 32:\n result = this._raw.getInt32(offset);\n break;\n case 64:\n // Warning: JavaScript cannot handle 64-bit integers natively.\n // This will give unexpected results for integers >= 2^53\n var s1 = this._raw.getInt32(offset);\n var s2 = this._raw.getInt32(offset + 4);\n result = (s1 * Math.pow(2,32)) + s2;\n break;\n }\n this._cursor.offset += (size >> 3);\n return result;\n};\n\nISOBox.prototype._readUint = function(size) {\n var result = null,\n offset = this._cursor.offset - this._raw.byteOffset,\n s1, s2;\n switch(size) {\n case 8:\n result = this._raw.getUint8(offset);\n break;\n case 16:\n result = this._raw.getUint16(offset);\n break;\n case 24:\n s1 = this._raw.getUint16(offset);\n s2 = this._raw.getUint8(offset + 2);\n result = (s1 << 8) + s2;\n break;\n case 32:\n result = this._raw.getUint32(offset);\n break;\n case 64:\n // Warning: JavaScript cannot handle 64-bit integers natively.\n // This will give unexpected results for integers >= 2^53\n s1 = this._raw.getUint32(offset);\n s2 = this._raw.getUint32(offset + 4);\n result = (s1 * Math.pow(2,32)) + s2;\n break;\n }\n this._cursor.offset += (size >> 3);\n return result;\n};\n\nISOBox.prototype._readString = function(length) {\n var str = '';\n for (var c = 0; c < length; c++) {\n var char = this._readUint(8);\n str += String.fromCharCode(char);\n }\n return str;\n};\n\nISOBox.prototype._readTemplate = function(size) {\n var pre = this._readUint(size / 2);\n var post = this._readUint(size / 2);\n return pre + (post / Math.pow(2, size / 2));\n};\n\nISOBox.prototype._readTerminatedString = function() {\n var str = '';\n while (this._cursor.offset - this._offset < this._raw.byteLength) {\n var char = this._readUint(8);\n if (char === 0) break;\n str += String.fromCharCode(char);\n }\n return str;\n};\n\nISOBox.prototype._readData = function(size) {\n var length = (size > 0) ? size : (this._raw.byteLength - (this._cursor.offset - this._offset));\n if (length > 0) {\n var data = new Uint8Array(this._raw.buffer, this._cursor.offset, length);\n\n this._cursor.offset += length;\n return data;\n }\n else {\n return null;\n }\n};\n\nISOBox.prototype._readUTF8String = function() {\n var length = this._raw.byteLength - (this._cursor.offset - this._offset);\n var data = null;\n if (length > 0) {\n data = new DataView(this._raw.buffer, this._cursor.offset, length);\n this._cursor.offset += length;\n }\n \n return data ? ISOBoxer.Utils.dataViewToString(data) : data;\n};\n\nISOBox.prototype._parseBox = function() {\n this._parsing = true;\n this._cursor.offset = this._offset;\n\n // return immediately if there are not enough bytes to read the header\n if (this._offset + 8 > this._raw.buffer.byteLength) {\n this._root._incomplete = true;\n return;\n }\n\n this._procField('size', 'uint', 32);\n this._procField('type', 'string', 4);\n\n if (this.size === 1) { this._procField('largesize', 'uint', 64); }\n if (this.type === 'uuid') { this._procFieldArray('usertype', 16, 'uint', 8); }\n\n switch(this.size) {\n case 0:\n this._raw = new DataView(this._raw.buffer, this._offset, (this._raw.byteLength - this._cursor.offset + 8));\n break;\n case 1:\n if (this._offset + this.size > this._raw.buffer.byteLength) {\n this._incomplete = true;\n this._root._incomplete = true;\n } else {\n this._raw = new DataView(this._raw.buffer, this._offset, this.largesize);\n }\n break;\n default:\n if (this._offset + this.size > this._raw.buffer.byteLength) {\n this._incomplete = true;\n this._root._incomplete = true;\n } else {\n this._raw = new DataView(this._raw.buffer, this._offset, this.size);\n }\n }\n\n // additional parsing\n if (!this._incomplete) {\n if (this._boxProcessors[this.type]) {\n this._boxProcessors[this.type].call(this);\n }\n if (this._boxContainers.indexOf(this.type) !== -1) {\n this._parseContainerBox();\n } else{\n // Unknown box => read and store box content\n this._data = this._readData();\n }\n }\n};\n\nISOBox.prototype._parseFullBox = function() {\n this.version = this._readUint(8);\n this.flags = this._readUint(24);\n};\n\nISOBox.prototype._parseContainerBox = function() {\n this.boxes = [];\n while (this._cursor.offset - this._raw.byteOffset < this._raw.byteLength) {\n this.boxes.push(ISOBox.parse(this));\n }\n};\n\n///////////////////////////////////////////////////////////////////////////////////////////////////\n// Write functions\n\nISOBox.prototype.append = function(box, pos) {\n ISOBoxer.Utils.appendBox(this, box, pos);\n};\n\nISOBox.prototype.getLength = function() {\n this._parsing = false;\n this._rawo = null;\n\n this.size = 0;\n this._procField('size', 'uint', 32);\n this._procField('type', 'string', 4);\n\n if (this.size === 1) { this._procField('largesize', 'uint', 64); }\n if (this.type === 'uuid') { this._procFieldArray('usertype', 16, 'uint', 8); }\n\n if (this._boxProcessors[this.type]) {\n this._boxProcessors[this.type].call(this);\n }\n\n if (this._boxContainers.indexOf(this.type) !== -1) {\n for (var i = 0; i < this.boxes.length; i++) {\n this.size += this.boxes[i].getLength();\n }\n } \n\n if (this._data) {\n this._writeData(this._data);\n }\n\n return this.size;\n};\n\nISOBox.prototype.write = function() {\n this._parsing = false;\n this._cursor.offset = this._parent._cursor.offset;\n\n switch(this.size) {\n case 0:\n this._rawo = new DataView(this._parent._rawo.buffer, this._cursor.offset, (this.parent._rawo.byteLength - this._cursor.offset));\n break;\n case 1:\n this._rawo = new DataView(this._parent._rawo.buffer, this._cursor.offset, this.largesize);\n break;\n default:\n this._rawo = new DataView(this._parent._rawo.buffer, this._cursor.offset, this.size);\n }\n\n this._procField('size', 'uint', 32);\n this._procField('type', 'string', 4);\n\n if (this.size === 1) { this._procField('largesize', 'uint', 64); }\n if (this.type === 'uuid') { this._procFieldArray('usertype', 16, 'uint', 8); }\n\n if (this._boxProcessors[this.type]) {\n this._boxProcessors[this.type].call(this);\n }\n\n if (this._boxContainers.indexOf(this.type) !== -1) {\n for (var i = 0; i < this.boxes.length; i++) {\n this.boxes[i].write();\n }\n } \n\n if (this._data) {\n this._writeData(this._data);\n }\n\n this._parent._cursor.offset += this.size;\n\n return this.size;\n};\n\nISOBox.prototype._writeInt = function(size, value) {\n if (this._rawo) {\n var offset = this._cursor.offset - this._rawo.byteOffset;\n switch(size) {\n case 8:\n this._rawo.setInt8(offset, value);\n break;\n case 16:\n this._rawo.setInt16(offset, value);\n break;\n case 32:\n this._rawo.setInt32(offset, value);\n break;\n case 64:\n // Warning: JavaScript cannot handle 64-bit integers natively.\n // This will give unexpected results for integers >= 2^53\n var s1 = Math.floor(value / Math.pow(2,32));\n var s2 = value - (s1 * Math.pow(2,32));\n this._rawo.setUint32(offset, s1);\n this._rawo.setUint32(offset + 4, s2);\n break;\n }\n this._cursor.offset += (size >> 3);\n } else {\n this.size += (size >> 3);\n }\n};\n\nISOBox.prototype._writeUint = function(size, value) {\n\n if (this._rawo) {\n var offset = this._cursor.offset - this._rawo.byteOffset,\n s1, s2;\n switch(size) {\n case 8:\n this._rawo.setUint8(offset, value);\n break;\n case 16:\n this._rawo.setUint16(offset, value);\n break;\n case 24:\n s1 = (value & 0xFFFF00) >> 8;\n s2 = (value & 0x0000FF);\n this._rawo.setUint16(offset, s1);\n this._rawo.setUint8(offset + 2, s2);\n break;\n case 32:\n this._rawo.setUint32(offset, value);\n break;\n case 64:\n // Warning: JavaScript cannot handle 64-bit integers natively.\n // This will give unexpected results for integers >= 2^53\n s1 = Math.floor(value / Math.pow(2,32));\n s2 = value - (s1 * Math.pow(2,32));\n this._rawo.setUint32(offset, s1);\n this._rawo.setUint32(offset + 4, s2);\n break;\n }\n this._cursor.offset += (size >> 3);\n } else {\n this.size += (size >> 3);\n }\n};\n\nISOBox.prototype._writeString = function(size, str) {\n for (var c = 0; c < size; c++) {\n this._writeUint(8, str.charCodeAt(c));\n }\n};\n\nISOBox.prototype._writeTerminatedString = function(str) {\n if (str.length === 0) {\n return;\n }\n for (var c = 0; c < str.length; c++) {\n this._writeUint(8, str.charCodeAt(c));\n }\n this._writeUint(8, 0);\n};\n\nISOBox.prototype._writeTemplate = function(size, value) {\n var pre = Math.floor(value);\n var post = (value - pre) * Math.pow(2, size / 2);\n this._writeUint(size / 2, pre);\n this._writeUint(size / 2, post);\n};\n\nISOBox.prototype._writeData = function(data) {\n var i;\n //data to copy\n if (data) {\n if (this._rawo) {\n //Array and Uint8Array has also to be managed\n if (data instanceof Array) {\n var offset = this._cursor.offset - this._rawo.byteOffset;\n for (var i = 0; i < data.length; i++) {\n this._rawo.setInt8(offset + i, data[i]);\n }\n this._cursor.offset += data.length;\n } \n\n if (data instanceof Uint8Array) {\n this._root.bytes.set(data, this._cursor.offset);\n this._cursor.offset += data.length;\n }\n\n } else {\n //nothing to copy only size to compute\n this.size += data.length;\n }\n }\n};\n\nISOBox.prototype._writeUTF8String = function(string) {\n var u = ISOBoxer.Utils.utf8ToByteArray(string);\n if (this._rawo) {\n var dataView = new DataView(this._rawo.buffer, this._cursor.offset, u.length);\n for (var i = 0; i < u.length; i++) {\n dataView.setUint8(i, u[i]);\n }\n } else {\n this.size += u.length;\n }\n};\n\nISOBox.prototype._writeField = function(type, size, value) {\n switch (type) {\n case 'uint':\n this._writeUint(size, value);\n break;\n case 'int':\n this._writeInt(size, value);\n break;\n case 'template':\n this._writeTemplate(size, value);\n break;\n case 'string':\n if (size == -1) {\n this._writeTerminatedString(value);\n } else {\n this._writeString(size, value);\n }\n break;\n case 'data':\n this._writeData(value);\n break;\n case 'utf8':\n this._writeUTF8String(value);\n break;\n default:\n break;\n }\n};\n\n// ISO/IEC 14496-15:2014 - avc1 box\nISOBox.prototype._boxProcessors['avc1'] = ISOBox.prototype._boxProcessors['encv'] = function() {\n // SampleEntry fields\n this._procFieldArray('reserved1', 6, 'uint', 8);\n this._procField('data_reference_index', 'uint', 16);\n // VisualSampleEntry fields\n this._procField('pre_defined1', 'uint', 16);\n this._procField('reserved2', 'uint', 16);\n this._procFieldArray('pre_defined2', 3, 'uint', 32);\n this._procField('width', 'uint', 16);\n this._procField('height', 'uint', 16);\n this._procField('horizresolution', 'template', 32);\n this._procField('vertresolution', 'template', 32);\n this._procField('reserved3', 'uint', 32);\n this._procField('frame_count', 'uint', 16);\n this._procFieldArray('compressorname', 32,'uint', 8);\n this._procField('depth', 'uint', 16);\n this._procField('pre_defined3', 'int', 16);\n // AVCSampleEntry fields\n this._procField('config', 'data', -1);\n};\n\n// ISO/IEC 14496-12:2012 - 8.7.2 Data Reference Box\nISOBox.prototype._boxProcessors['dref'] = function() {\n this._procFullBox();\n this._procField('entry_count', 'uint', 32);\n this._procSubBoxes('entries', this.entry_count);\n};\n\n// ISO/IEC 14496-12:2012 - 8.6.6 Edit List Box\nISOBox.prototype._boxProcessors['elst'] = function() {\n this._procFullBox();\n this._procField('entry_count', 'uint', 32);\n this._procEntries('entries', this.entry_count, function(entry) {\n this._procEntryField(entry, 'segment_duration', 'uint', (this.version === 1) ? 64 : 32);\n this._procEntryField(entry, 'media_time', 'int', (this.version === 1) ? 64 : 32);\n this._procEntryField(entry, 'media_rate_integer', 'int', 16);\n this._procEntryField(entry, 'media_rate_fraction', 'int', 16);\n });\n};\n\n// ISO/IEC 23009-1:2014 - 5.10.3.3 Event Message Box\nISOBox.prototype._boxProcessors['emsg'] = function() {\n this._procFullBox();\n if (this.version == 1) {\n this._procField('timescale', 'uint', 32);\n this._procField('presentation_time', 'uint', 64);\n this._procField('event_duration', 'uint', 32);\n this._procField('id', 'uint', 32);\n this._procField('scheme_id_uri', 'string', -1);\n this._procField('value', 'string', -1);\n } else {\n this._procField('scheme_id_uri', 'string', -1);\n this._procField('value', 'string', -1);\n this._procField('timescale', 'uint', 32);\n this._procField('presentation_time_delta', 'uint', 32);\n this._procField('event_duration', 'uint', 32);\n this._procField('id', 'uint', 32);\n }\n this._procField('message_data', 'data', -1);\n};\n// ISO/IEC 14496-12:2012 - 8.1.2 Free Space Box\nISOBox.prototype._boxProcessors['free'] = ISOBox.prototype._boxProcessors['skip'] = function() {\n this._procField('data', 'data', -1);\n};\n\n// ISO/IEC 14496-12:2012 - 8.12.2 Original Format Box\nISOBox.prototype._boxProcessors['frma'] = function() {\n this._procField('data_format', 'uint', 32);\n};\n// ISO/IEC 14496-12:2012 - 4.3 File Type Box / 8.16.2 Segment Type Box\nISOBox.prototype._boxProcessors['ftyp'] =\nISOBox.prototype._boxProcessors['styp'] = function() {\n this._procField('major_brand', 'string', 4);\n this._procField('minor_version', 'uint', 32);\n var nbCompatibleBrands = -1;\n if (this._parsing) {\n nbCompatibleBrands = (this._raw.byteLength - (this._cursor.offset - this._raw.byteOffset)) / 4;\n }\n this._procFieldArray('compatible_brands', nbCompatibleBrands, 'string', 4);\n};\n\n// ISO/IEC 14496-12:2012 - 8.4.3 Handler Reference Box\nISOBox.prototype._boxProcessors['hdlr'] = function() {\n this._procFullBox();\n this._procField('pre_defined', 'uint', 32);\n this._procField('handler_type', 'string', 4);\n this._procFieldArray('reserved', 3, 'uint', 32);\n this._procField('name', 'string', -1);\n};\n\n// ISO/IEC 14496-12:2012 - 8.1.1 Media Data Box\nISOBox.prototype._boxProcessors['mdat'] = function() {\n this._procField('data', 'data', -1);\n};\n\n// ISO/IEC 14496-12:2012 - 8.4.2 Media Header Box\nISOBox.prototype._boxProcessors['mdhd'] = function() {\n this._procFullBox();\n this._procField('creation_time', 'uint', (this.version == 1) ? 64 : 32);\n this._procField('modification_time', 'uint', (this.version == 1) ? 64 : 32);\n this._procField('timescale', 'uint', 32);\n this._procField('duration', 'uint', (this.version == 1) ? 64 : 32);\n if (!this._parsing && typeof this.language === 'string') {\n // In case of writing and language has been set as a string, then convert it into char codes array\n this.language = ((this.language.charCodeAt(0) - 0x60) << 10) |\n ((this.language.charCodeAt(1) - 0x60) << 5) |\n ((this.language.charCodeAt(2) - 0x60));\n }\n this._procField('language', 'uint', 16);\n if (this._parsing) {\n this.language = String.fromCharCode(((this.language >> 10) & 0x1F) + 0x60,\n ((this.language >> 5) & 0x1F) + 0x60,\n (this.language & 0x1F) + 0x60);\n }\n this._procField('pre_defined', 'uint', 16);\n};\n\n// ISO/IEC 14496-12:2012 - 8.8.2 Movie Extends Header Box\nISOBox.prototype._boxProcessors['mehd'] = function() {\n this._procFullBox();\n this._procField('fragment_duration', 'uint', (this.version == 1) ? 64 : 32);\n};\n\n// ISO/IEC 14496-12:2012 - 8.8.5 Movie Fragment Header Box\nISOBox.prototype._boxProcessors['mfhd'] = function() {\n this._procFullBox();\n this._procField('sequence_number', 'uint', 32);\n};\n\n// ISO/IEC 14496-12:2012 - 8.8.11 Movie Fragment Random Access Box\nISOBox.prototype._boxProcessors['mfro'] = function() {\n this._procFullBox();\n this._procField('mfra_size', 'uint', 32); // Called mfra_size to distinguish from the normal \"size\" attribute of a box\n};\n\n\n// ISO/IEC 14496-12:2012 - 8.5.2.2 mp4a box (use AudioSampleEntry definition and naming)\nISOBox.prototype._boxProcessors['mp4a'] = ISOBox.prototype._boxProcessors['enca'] = function() {\n // SampleEntry fields\n this._procFieldArray('reserved1', 6, 'uint', 8);\n this._procField('data_reference_index', 'uint', 16);\n // AudioSampleEntry fields\n this._procFieldArray('reserved2', 2, 'uint', 32);\n this._procField('channelcount', 'uint', 16);\n this._procField('samplesize', 'uint', 16);\n this._procField('pre_defined', 'uint', 16);\n this._procField('reserved3', 'uint', 16);\n this._procField('samplerate', 'template', 32);\n // ESDescriptor fields\n this._procField('esds', 'data', -1);\n};\n\n// ISO/IEC 14496-12:2012 - 8.2.2 Movie Header Box\nISOBox.prototype._boxProcessors['mvhd'] = function() {\n this._procFullBox();\n this._procField('creation_time', 'uint', (this.version == 1) ? 64 : 32);\n this._procField('modification_time', 'uint', (this.version == 1) ? 64 : 32);\n this._procField('timescale', 'uint', 32);\n this._procField('duration', 'uint', (this.version == 1) ? 64 : 32);\n this._procField('rate', 'template', 32);\n this._procField('volume', 'template', 16);\n this._procField('reserved1', 'uint', 16);\n this._procFieldArray('reserved2', 2, 'uint', 32);\n this._procFieldArray('matrix', 9, 'template', 32);\n this._procFieldArray('pre_defined', 6,'uint', 32);\n this._procField('next_track_ID', 'uint', 32);\n};\n\n// ISO/IEC 14496-30:2014 - WebVTT Cue Payload Box.\nISOBox.prototype._boxProcessors['payl'] = function() {\n this._procField('cue_text', 'utf8');\n};\n\n//ISO/IEC 23001-7:2011 - 8.1 Protection System Specific Header Box\nISOBox.prototype._boxProcessors['pssh'] = function() {\n this._procFullBox();\n \n this._procFieldArray('SystemID', 16, 'uint', 8);\n this._procField('DataSize', 'uint', 32);\n this._procFieldArray('Data', this.DataSize, 'uint', 8);\n};\n// ISO/IEC 14496-12:2012 - 8.12.5 Scheme Type Box\nISOBox.prototype._boxProcessors['schm'] = function() {\n this._procFullBox();\n \n this._procField('scheme_type', 'uint', 32);\n this._procField('scheme_version', 'uint', 32);\n\n if (this.flags & 0x000001) {\n this._procField('scheme_uri', 'string', -1);\n }\n};\n// ISO/IEC 14496-12:2012 - 8.6.4.1 sdtp box \nISOBox.prototype._boxProcessors['sdtp'] = function() {\n this._procFullBox();\n\n var sample_count = -1;\n if (this._parsing) {\n sample_count = (this._raw.byteLength - (this._cursor.offset - this._raw.byteOffset));\n }\n\n this._procFieldArray('sample_dependency_table', sample_count, 'uint', 8);\n};\n\n// ISO/IEC 14496-12:2012 - 8.16.3 Segment Index Box\nISOBox.prototype._boxProcessors['sidx'] = function() {\n this._procFullBox();\n this._procField('reference_ID', 'uint', 32);\n this._procField('timescale', 'uint', 32);\n this._procField('earliest_presentation_time', 'uint', (this.version == 1) ? 64 : 32);\n this._procField('first_offset', 'uint', (this.version == 1) ? 64 : 32);\n this._procField('reserved', 'uint', 16);\n this._procField('reference_count', 'uint', 16);\n this._procEntries('references', this.reference_count, function(entry) {\n if (!this._parsing) {\n entry.reference = (entry.reference_type & 0x00000001) << 31;\n entry.reference |= (entry.referenced_size & 0x7FFFFFFF);\n entry.sap = (entry.starts_with_SAP & 0x00000001) << 31;\n entry.sap |= (entry.SAP_type & 0x00000003) << 28;\n entry.sap |= (entry.SAP_delta_time & 0x0FFFFFFF);\n }\n this._procEntryField(entry, 'reference', 'uint', 32);\n this._procEntryField(entry, 'subsegment_duration', 'uint', 32);\n this._procEntryField(entry, 'sap', 'uint', 32);\n if (this._parsing) {\n entry.reference_type = (entry.reference >> 31) & 0x00000001;\n entry.referenced_size = entry.reference & 0x7FFFFFFF;\n entry.starts_with_SAP = (entry.sap >> 31) & 0x00000001;\n entry.SAP_type = (entry.sap >> 28) & 0x00000007;\n entry.SAP_delta_time = (entry.sap & 0x0FFFFFFF);\n }\n });\n};\n\n// ISO/IEC 14496-12:2012 - 8.4.5.3 Sound Media Header Box\nISOBox.prototype._boxProcessors['smhd'] = function() {\n this._procFullBox();\n this._procField('balance', 'uint', 16);\n this._procField('reserved', 'uint', 16);\n};\n\n// ISO/IEC 14496-12:2012 - 8.16.4 Subsegment Index Box\nISOBox.prototype._boxProcessors['ssix'] = function() {\n this._procFullBox();\n this._procField('subsegment_count', 'uint', 32);\n this._procEntries('subsegments', this.subsegment_count, function(subsegment) {\n this._procEntryField(subsegment, 'ranges_count', 'uint', 32);\n this._procSubEntries(subsegment, 'ranges', subsegment.ranges_count, function(range) {\n this._procEntryField(range, 'level', 'uint', 8);\n this._procEntryField(range, 'range_size', 'uint', 24);\n });\n });\n};\n\n// ISO/IEC 14496-12:2012 - 8.5.2 Sample Description Box\nISOBox.prototype._boxProcessors['stsd'] = function() {\n this._procFullBox();\n this._procField('entry_count', 'uint', 32);\n this._procSubBoxes('entries', this.entry_count);\n};\n\n// ISO/IEC 14496-12:2015 - 8.7.7 Sub-Sample Information Box\nISOBox.prototype._boxProcessors['subs'] = function () {\n this._procFullBox();\n this._procField('entry_count', 'uint', 32);\n this._procEntries('entries', this.entry_count, function(entry) {\n this._procEntryField(entry, 'sample_delta', 'uint', 32);\n this._procEntryField(entry, 'subsample_count', 'uint', 16);\n this._procSubEntries(entry, 'subsamples', entry.subsample_count, function(subsample) {\n this._procEntryField(subsample, 'subsample_size', 'uint', (this.version === 1) ? 32 : 16);\n this._procEntryField(subsample, 'subsample_priority', 'uint', 8);\n this._procEntryField(subsample, 'discardable', 'uint', 8);\n this._procEntryField(subsample, 'codec_specific_parameters', 'uint', 32);\n });\n });\n};\n\n//ISO/IEC 23001-7:2011 - 8.2 Track Encryption Box\nISOBox.prototype._boxProcessors['tenc'] = function() {\n this._procFullBox();\n\n this._procField('default_IsEncrypted', 'uint', 24);\n this._procField('default_IV_size', 'uint', 8);\n this._procFieldArray('default_KID', 16, 'uint', 8);\n };\n\n// ISO/IEC 14496-12:2012 - 8.8.12 Track Fragmnent Decode Time\nISOBox.prototype._boxProcessors['tfdt'] = function() {\n this._procFullBox();\n this._procField('baseMediaDecodeTime', 'uint', (this.version == 1) ? 64 : 32);\n};\n\n// ISO/IEC 14496-12:2012 - 8.8.7 Track Fragment Header Box\nISOBox.prototype._boxProcessors['tfhd'] = function() {\n this._procFullBox();\n this._procField('track_ID', 'uint', 32);\n if (this.flags & 0x01) this._procField('base_data_offset', 'uint', 64);\n if (this.flags & 0x02) this._procField('sample_description_offset', 'uint', 32);\n if (this.flags & 0x08) this._procField('default_sample_duration', 'uint', 32);\n if (this.flags & 0x10) this._procField('default_sample_size', 'uint', 32);\n if (this.flags & 0x20) this._procField('default_sample_flags', 'uint', 32);\n};\n\n// ISO/IEC 14496-12:2012 - 8.8.10 Track Fragment Random Access Box\nISOBox.prototype._boxProcessors['tfra'] = function() {\n this._procFullBox();\n this._procField('track_ID', 'uint', 32);\n if (!this._parsing) {\n this.reserved = 0;\n this.reserved |= (this.length_size_of_traf_num & 0x00000030) << 4;\n this.reserved |= (this.length_size_of_trun_num & 0x0000000C) << 2;\n this.reserved |= (this.length_size_of_sample_num & 0x00000003);\n }\n this._procField('reserved', 'uint', 32);\n if (this._parsing) {\n this.length_size_of_traf_num = (this.reserved & 0x00000030) >> 4;\n this.length_size_of_trun_num = (this.reserved & 0x0000000C) >> 2;\n this.length_size_of_sample_num = (this.reserved & 0x00000003);\n }\n this._procField('number_of_entry', 'uint', 32);\n this._procEntries('entries', this.number_of_entry, function(entry) {\n this._procEntryField(entry, 'time', 'uint', (this.version === 1) ? 64 : 32);\n this._procEntryField(entry, 'moof_offset', 'uint', (this.version === 1) ? 64 : 32);\n this._procEntryField(entry, 'traf_number', 'uint', (this.length_size_of_traf_num + 1) * 8);\n this._procEntryField(entry, 'trun_number', 'uint', (this.length_size_of_trun_num + 1) * 8);\n this._procEntryField(entry, 'sample_number', 'uint', (this.length_size_of_sample_num + 1) * 8);\n });\n};\n\n// ISO/IEC 14496-12:2012 - 8.3.2 Track Header Box\nISOBox.prototype._boxProcessors['tkhd'] = function() {\n this._procFullBox();\n this._procField('creation_time', 'uint', (this.version == 1) ? 64 : 32);\n this._procField('modification_time', 'uint', (this.version == 1) ? 64 : 32);\n this._procField('track_ID', 'uint', 32);\n this._procField('reserved1', 'uint', 32);\n this._procField('duration', 'uint', (this.version == 1) ? 64 : 32);\n this._procFieldArray('reserved2', 2, 'uint', 32);\n this._procField('layer', 'uint', 16);\n this._procField('alternate_group', 'uint', 16);\n this._procField('volume', 'template', 16);\n this._procField('reserved3', 'uint', 16);\n this._procFieldArray('matrix', 9, 'template', 32);\n this._procField('width', 'template', 32);\n this._procField('height', 'template', 32);\n};\n\n// ISO/IEC 14496-12:2012 - 8.8.3 Track Extends Box\nISOBox.prototype._boxProcessors['trex'] = function() {\n this._procFullBox();\n this._procField('track_ID', 'uint', 32);\n this._procField('default_sample_description_index', 'uint', 32);\n this._procField('default_sample_duration', 'uint', 32);\n this._procField('default_sample_size', 'uint', 32);\n this._procField('default_sample_flags', 'uint', 32);\n};\n\n// ISO/IEC 14496-12:2012 - 8.8.8 Track Run Box\n// Note: the 'trun' box has a direct relation to the 'tfhd' box for defaults.\n// These defaults are not set explicitly here, but are left to resolve for the user.\nISOBox.prototype._boxProcessors['trun'] = function() {\n this._procFullBox();\n this._procField('sample_count', 'uint', 32);\n if (this.flags & 0x1) this._procField('data_offset', 'int', 32);\n if (this.flags & 0x4) this._procField('first_sample_flags', 'uint', 32);\n this._procEntries('samples', this.sample_count, function(sample) {\n if (this.flags & 0x100) this._procEntryField(sample, 'sample_duration', 'uint', 32);\n if (this.flags & 0x200) this._procEntryField(sample, 'sample_size', 'uint', 32);\n if (this.flags & 0x400) this._procEntryField(sample, 'sample_flags', 'uint', 32);\n if (this.flags & 0x800) this._procEntryField(sample, 'sample_composition_time_offset', (this.version === 1) ? 'int' : 'uint', 32);\n });\n};\n\n// ISO/IEC 14496-12:2012 - 8.7.2 Data Reference Box\nISOBox.prototype._boxProcessors['url '] = ISOBox.prototype._boxProcessors['urn '] = function() {\n this._procFullBox();\n if (this.type === 'urn ') {\n this._procField('name', 'string', -1);\n }\n this._procField('location', 'string', -1);\n};\n\n// ISO/IEC 14496-30:2014 - WebVTT Source Label Box\nISOBox.prototype._boxProcessors['vlab'] = function() {\n this._procField('source_label', 'utf8');\n};\n\n// ISO/IEC 14496-12:2012 - 8.4.5.2 Video Media Header Box\nISOBox.prototype._boxProcessors['vmhd'] = function() {\n this._procFullBox();\n this._procField('graphicsmode', 'uint', 16);\n this._procFieldArray('opcolor', 3, 'uint', 16);\n};\n\n// ISO/IEC 14496-30:2014 - WebVTT Configuration Box\nISOBox.prototype._boxProcessors['vttC'] = function() {\n this._procField('config', 'utf8');\n};\n\n// ISO/IEC 14496-30:2014 - WebVTT Empty Sample Box\nISOBox.prototype._boxProcessors['vtte'] = function() {\n // Nothing should happen here.\n};\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\n\nfunction isArray(arg) {\n if (Array.isArray) {\n return Array.isArray(arg);\n }\n return objectToString(arg) === '[object Array]';\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = Buffer.isBuffer;\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nvar objectCreate = Object.create || objectCreatePolyfill\nvar objectKeys = Object.keys || objectKeysPolyfill\nvar bind = Function.prototype.bind || functionBindPolyfill\n\nfunction EventEmitter() {\n if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {\n this._events = objectCreate(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n}\nmodule.exports = EventEmitter;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nvar hasDefineProperty;\ntry {\n var o = {};\n if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });\n hasDefineProperty = o.x === 0;\n} catch (err) { hasDefineProperty = false }\nif (hasDefineProperty) {\n Object.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n // check whether the input is a positive number (whose value is zero or\n // greater and not a NaN).\n if (typeof arg !== 'number' || arg < 0 || arg !== arg)\n throw new TypeError('\"defaultMaxListeners\" must be a positive number');\n defaultMaxListeners = arg;\n }\n });\n} else {\n EventEmitter.defaultMaxListeners = defaultMaxListeners;\n}\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || isNaN(n))\n throw new TypeError('\"n\" argument must be a positive number');\n this._maxListeners = n;\n return this;\n};\n\nfunction $getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return $getMaxListeners(this);\n};\n\n// These standalone emit* functions are used to optimize calling of event\n// handlers for fast cases because emit() itself often has a variable number of\n// arguments and can be deoptimized because of that. These functions always have\n// the same number of arguments and thus do not get deoptimized, so the code\n// inside them can execute faster.\nfunction emitNone(handler, isFn, self) {\n if (isFn)\n handler.call(self);\n else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n listeners[i].call(self);\n }\n}\nfunction emitOne(handler, isFn, self, arg1) {\n if (isFn)\n handler.call(self, arg1);\n else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n listeners[i].call(self, arg1);\n }\n}\nfunction emitTwo(handler, isFn, self, arg1, arg2) {\n if (isFn)\n handler.call(self, arg1, arg2);\n else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n listeners[i].call(self, arg1, arg2);\n }\n}\nfunction emitThree(handler, isFn, self, arg1, arg2, arg3) {\n if (isFn)\n handler.call(self, arg1, arg2, arg3);\n else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n listeners[i].call(self, arg1, arg2, arg3);\n }\n}\n\nfunction emitMany(handler, isFn, self, args) {\n if (isFn)\n handler.apply(self, args);\n else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n listeners[i].apply(self, args);\n }\n}\n\nEventEmitter.prototype.emit = function emit(type) {\n var er, handler, len, args, i, events;\n var doError = (type === 'error');\n\n events = this._events;\n if (events)\n doError = (doError && events.error == null);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n if (arguments.length > 1)\n er = arguments[1];\n if (er instanceof Error) {\n throw er; // Unhandled 'error' event\n } else {\n // At least give some kind of context to the user\n var err = new Error('Unhandled \"error\" event. (' + er + ')');\n err.context = er;\n throw err;\n }\n return false;\n }\n\n handler = events[type];\n\n if (!handler)\n return false;\n\n var isFn = typeof handler === 'function';\n len = arguments.length;\n switch (len) {\n // fast cases\n case 1:\n emitNone(handler, isFn, this);\n break;\n case 2:\n emitOne(handler, isFn, this, arguments[1]);\n break;\n case 3:\n emitTwo(handler, isFn, this, arguments[1], arguments[2]);\n break;\n case 4:\n emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);\n break;\n // slower\n default:\n args = new Array(len - 1);\n for (i = 1; i < len; i++)\n args[i - 1] = arguments[i];\n emitMany(handler, isFn, this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n if (typeof listener !== 'function')\n throw new TypeError('\"listener\" argument must be a function');\n\n events = target._events;\n if (!events) {\n events = target._events = objectCreate(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (!existing) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n } else {\n // If we've already got an array, just append.\n if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n }\n\n // Check for listener leak\n if (!existing.warned) {\n m = $getMaxListeners(target);\n if (m && m > 0 && existing.length > m) {\n existing.warned = true;\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' \"' + String(type) + '\" listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit.');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n if (typeof console === 'object' && console.warn) {\n console.warn('%s: %s', w.name, w.message);\n }\n }\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n switch (arguments.length) {\n case 0:\n return this.listener.call(this.target);\n case 1:\n return this.listener.call(this.target, arguments[0]);\n case 2:\n return this.listener.call(this.target, arguments[0], arguments[1]);\n case 3:\n return this.listener.call(this.target, arguments[0], arguments[1],\n arguments[2]);\n default:\n var args = new Array(arguments.length);\n for (var i = 0; i < args.length; ++i)\n args[i] = arguments[i];\n this.listener.apply(this.target, args);\n }\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = bind.call(onceWrapper, state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n if (typeof listener !== 'function')\n throw new TypeError('\"listener\" argument must be a function');\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n if (typeof listener !== 'function')\n throw new TypeError('\"listener\" argument must be a function');\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n if (typeof listener !== 'function')\n throw new TypeError('\"listener\" argument must be a function');\n\n events = this._events;\n if (!events)\n return this;\n\n list = events[type];\n if (!list)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = objectCreate(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else\n spliceOne(list, position);\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (!events)\n return this;\n\n // not listening for removeListener, no need to emit\n if (!events.removeListener) {\n if (arguments.length === 0) {\n this._events = objectCreate(null);\n this._eventsCount = 0;\n } else if (events[type]) {\n if (--this._eventsCount === 0)\n this._events = objectCreate(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = objectKeys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = objectCreate(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (!events)\n return [];\n\n var evlistener = events[type];\n if (!evlistener)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];\n};\n\n// About 1.5x faster than the two-arg version of Array#splice().\nfunction spliceOne(list, index) {\n for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)\n list[i] = list[k];\n list.pop();\n}\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction objectCreatePolyfill(proto) {\n var F = function() {};\n F.prototype = proto;\n return new F;\n}\nfunction objectKeysPolyfill(obj) {\n var keys = [];\n for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) {\n keys.push(k);\n }\n return k;\n}\nfunction functionBindPolyfill(context) {\n var fn = this;\n return function () {\n return fn.apply(context, arguments);\n };\n}\n","'use strict';\n\nvar isArray = Array.isArray;\nvar keyList = Object.keys;\nvar hasProp = Object.prototype.hasOwnProperty;\n\nmodule.exports = function equal(a, b) {\n if (a === b) return true;\n\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n var arrA = isArray(a)\n , arrB = isArray(b)\n , i\n , length\n , key;\n\n if (arrA && arrB) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n if (arrA != arrB) return false;\n\n var dateA = a instanceof Date\n , dateB = b instanceof Date;\n if (dateA != dateB) return false;\n if (dateA && dateB) return a.getTime() == b.getTime();\n\n var regexpA = a instanceof RegExp\n , regexpB = b instanceof RegExp;\n if (regexpA != regexpB) return false;\n if (regexpA && regexpB) return a.toString() == b.toString();\n\n var keys = keyList(a);\n length = keys.length;\n\n if (length !== keyList(b).length)\n return false;\n\n for (i = length; i-- !== 0;)\n if (!hasProp.call(b, keys[i])) return false;\n\n for (i = length; i-- !== 0;) {\n key = keys[i];\n if (!equal(a[key], b[key])) return false;\n }\n\n return true;\n }\n\n return a!==a && b!==b;\n};\n","exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","/* \r\n * Copyright (c) 2016, Pierre-Anthony Lemieux \r\n * All rights reserved.\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * * Redistributions of source code must retain the above copyright notice, this\r\n * list of conditions and the following disclaimer.\r\n * * Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n */\r\n\r\n/**\r\n * @module imscDoc\r\n */\r\n\r\n;\r\n(function (imscDoc, sax, imscNames, imscStyles, imscUtils) {\r\n\r\n\r\n /**\r\n * Allows a client to provide callbacks to handle children of the element\r\n * @typedef {Object} MetadataHandler\r\n * @property {?OpenTagCallBack} onOpenTag\r\n * @property {?CloseTagCallBack} onCloseTag\r\n * @property {?TextCallBack} onText\r\n */\r\n\r\n /**\r\n * Called when the opening tag of an element node is encountered.\r\n * @callback OpenTagCallBack\r\n * @param {string} ns Namespace URI of the element\r\n * @param {string} name Local name of the element\r\n * @param {Object[]} attributes List of attributes, each consisting of a\r\n * `uri`, `name` and `value`\r\n */\r\n\r\n /**\r\n * Called when the closing tag of an element node is encountered.\r\n * @callback CloseTagCallBack\r\n */\r\n\r\n /**\r\n * Called when a text node is encountered.\r\n * @callback TextCallBack\r\n * @param {string} contents Contents of the text node\r\n */\r\n\r\n /**\r\n * Parses an IMSC1 document into an opaque in-memory representation that exposes\r\n * a single method
getMediaTimeEvents()
that returns a list of time\r\n * offsets (in seconds) of the ISD, i.e. the points in time where the visual\r\n * representation of the document change. `metadataHandler` allows the caller to\r\n * be called back when nodes are present in elements. \r\n * \r\n * @param {string} xmlstring XML document\r\n * @param {?module:imscUtils.ErrorHandler} errorHandler Error callback\r\n * @param {?MetadataHandler} metadataHandler Callback for elements\r\n * @returns {Object} Opaque in-memory representation of an IMSC1 document\r\n */\r\n\r\n imscDoc.fromXML = function (xmlstring, errorHandler, metadataHandler) {\r\n var p = sax.parser(true, {xmlns: true});\r\n var estack = [];\r\n var xmllangstack = [];\r\n var xmlspacestack = [];\r\n var metadata_depth = 0;\r\n var doc = null;\r\n\r\n p.onclosetag = function (node) {\r\n\r\n if (estack[0] instanceof Styling) {\r\n\r\n /* flatten chained referential styling */\r\n\r\n for (var sid in estack[0].styles) {\r\n\r\n mergeChainedStyles(estack[0], estack[0].styles[sid], errorHandler);\r\n\r\n }\r\n\r\n } else if (estack[0] instanceof P || estack[0] instanceof Span) {\r\n\r\n /* merge anonymous spans */\r\n\r\n if (estack[0].contents.length > 1) {\r\n\r\n var cs = [estack[0].contents[0]];\r\n\r\n var c;\r\n\r\n for (c = 1; c < estack[0].contents.length; c++) {\r\n\r\n if (estack[0].contents[c] instanceof AnonymousSpan &&\r\n cs[cs.length - 1] instanceof AnonymousSpan) {\r\n\r\n cs[cs.length - 1].text += estack[0].contents[c].text;\r\n\r\n } else {\r\n\r\n cs.push(estack[0].contents[c]);\r\n\r\n }\r\n\r\n }\r\n\r\n estack[0].contents = cs;\r\n\r\n }\r\n\r\n // remove redundant nested anonymous spans (9.3.3(1)(c))\r\n\r\n if (estack[0] instanceof Span &&\r\n estack[0].contents.length === 1 &&\r\n estack[0].contents[0] instanceof AnonymousSpan) {\r\n\r\n estack[0].text = estack[0].contents[0].text;\r\n delete estack[0].contents;\r\n\r\n }\r\n\r\n } else if (estack[0] instanceof ForeignElement) {\r\n\r\n if (estack[0].node.uri === imscNames.ns_tt &&\r\n estack[0].node.local === 'metadata') {\r\n\r\n /* leave the metadata element */\r\n\r\n metadata_depth--;\r\n\r\n } else if (metadata_depth > 0 &&\r\n metadataHandler &&\r\n 'onCloseTag' in metadataHandler) {\r\n\r\n /* end of child of metadata element */\r\n\r\n metadataHandler.onCloseTag();\r\n\r\n }\r\n\r\n }\r\n\r\n // TODO: delete stylerefs?\r\n\r\n // maintain the xml:space stack\r\n\r\n xmlspacestack.shift();\r\n\r\n // maintain the xml:lang stack\r\n\r\n xmllangstack.shift();\r\n\r\n // prepare for the next element\r\n\r\n estack.shift();\r\n };\r\n\r\n p.ontext = function (str) {\r\n\r\n if (estack[0] === undefined) {\r\n\r\n /* ignoring text outside of elements */\r\n\r\n } else if (estack[0] instanceof Span || estack[0] instanceof P) {\r\n\r\n /* create an anonymous span */\r\n\r\n var s = new AnonymousSpan();\r\n\r\n s.initFromText(doc, estack[0], str, xmlspacestack[0], errorHandler);\r\n\r\n estack[0].contents.push(s);\r\n\r\n } else if (estack[0] instanceof ForeignElement &&\r\n metadata_depth > 0 &&\r\n metadataHandler &&\r\n 'onText' in metadataHandler) {\r\n\r\n /* text node within a child of metadata element */\r\n\r\n metadataHandler.onText(str);\r\n\r\n }\r\n\r\n };\r\n\r\n\r\n p.onopentag = function (node) {\r\n\r\n // maintain the xml:space stack\r\n\r\n var xmlspace = node.attributes[\"xml:space\"];\r\n\r\n if (xmlspace) {\r\n\r\n xmlspacestack.unshift(xmlspace.value);\r\n\r\n } else {\r\n\r\n if (xmlspacestack.length === 0) {\r\n\r\n xmlspacestack.unshift(\"default\");\r\n\r\n } else {\r\n\r\n xmlspacestack.unshift(xmlspacestack[0]);\r\n\r\n }\r\n\r\n }\r\n\r\n /* maintain the xml:lang stack */\r\n\r\n\r\n var xmllang = node.attributes[\"xml:lang\"];\r\n\r\n if (xmllang) {\r\n\r\n xmllangstack.unshift(xmllang.value);\r\n\r\n } else {\r\n\r\n if (xmllangstack.length === 0) {\r\n\r\n xmllangstack.unshift(\"\");\r\n\r\n } else {\r\n\r\n xmllangstack.unshift(xmllangstack[0]);\r\n\r\n }\r\n\r\n }\r\n\r\n\r\n /* process the element */\r\n\r\n if (node.uri === imscNames.ns_tt) {\r\n\r\n if (node.local === 'tt') {\r\n\r\n if (doc !== null) {\r\n\r\n reportFatal(errorHandler, \"Two elements at (\" + this.line + \",\" + this.column + \")\");\r\n\r\n }\r\n\r\n doc = new TT();\r\n\r\n doc.initFromNode(node, errorHandler);\r\n\r\n estack.unshift(doc);\r\n\r\n } else if (node.local === 'head') {\r\n\r\n if (!(estack[0] instanceof TT)) {\r\n reportFatal(errorHandler, \"Parent of element is not at (\" + this.line + \",\" + this.column + \")\");\r\n }\r\n\r\n if (doc.head !== null) {\r\n reportFatal(\"Second element at (\" + this.line + \",\" + this.column + \")\");\r\n }\r\n\r\n doc.head = new Head();\r\n\r\n estack.unshift(doc.head);\r\n\r\n } else if (node.local === 'styling') {\r\n\r\n if (!(estack[0] instanceof Head)) {\r\n reportFatal(errorHandler, \"Parent of element is not at (\" + this.line + \",\" + this.column + \")\");\r\n }\r\n\r\n if (doc.head.styling !== null) {\r\n reportFatal(\"Second element at (\" + this.line + \",\" + this.column + \")\");\r\n }\r\n\r\n doc.head.styling = new Styling();\r\n\r\n estack.unshift(doc.head.styling);\r\n\r\n } else if (node.local === 'style') {\r\n\r\n var s;\r\n\r\n if (estack[0] instanceof Styling) {\r\n\r\n s = new Style();\r\n\r\n s.initFromNode(node, errorHandler);\r\n\r\n /* ignore